From 75bc576eb7af41ecb997f6ed5f6eb35b8f0afccb Mon Sep 17 00:00:00 2001 From: serkangunes Date: Mon, 20 Feb 2017 16:00:14 +0000 Subject: [PATCH 1/2] Update parse.js This check is wrong as the types.packed fields includes only the built in primitive types. But at this point type of the repeated enum is a custom type like test.TestMessage therefore types.packed[type] !== undefined always returns false and code never enters that if condition and it does not set the packed flag to false. However when the syntax is set to proto2 this flag should be always set to false. --- src/parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse.js b/src/parse.js index 4ec497229..d8d445749 100644 --- a/src/parse.js +++ b/src/parse.js @@ -336,7 +336,7 @@ function parse(source, root, options) { field.comment = cmnt(trailingLine); // JSON defaults to packed=true if not set so we have to set packed=false explicity when // parsing proto2 descriptors without the option, where applicable. - if (field.repeated && types.packed[type] !== undefined && !isProto3) + if (field.repeated && !isProto3) field.setOption("packed", false, /* ifNotSet */ true); parent.add(field); } From dba295a3dc868366ccbac407ad3e1a67c26a8c1f Mon Sep 17 00:00:00 2001 From: serkangunes Date: Mon, 20 Feb 2017 16:14:28 +0000 Subject: [PATCH 2/2] Update parse.js Added support for turning on the packed option manually. --- src/parse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parse.js b/src/parse.js index d8d445749..170a2dcf1 100644 --- a/src/parse.js +++ b/src/parse.js @@ -336,7 +336,8 @@ function parse(source, root, options) { field.comment = cmnt(trailingLine); // JSON defaults to packed=true if not set so we have to set packed=false explicity when // parsing proto2 descriptors without the option, where applicable. - if (field.repeated && !isProto3) + var packed = field.getOption('packed'); + if (field.repeated && packed === undefined && !isProto3) field.setOption("packed", false, /* ifNotSet */ true); parent.add(field); }