diff options
Diffstat (limited to 'src/google')
-rwxr-xr-x | src/google/protobuf/compiler/js/js_generator.cc | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index a25de76c..73d32762 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -2876,29 +2876,6 @@ void Generator::GenerateClassDeserializeBinaryField( "Group" : "Message", "grpfield", (field->type() == FieldDescriptor::TYPE_GROUP) ? (SimpleItoa(field->number()) + ", ") : ""); - } else if (field->is_repeated() && - field->cpp_type() != FieldDescriptor::CPPTYPE_STRING) { - printer->Print( - " if (reader.getWireType() == 2) {\n" - " var value = /** @type {$fieldtype_packed$} */ " - "(reader.readPacked$reader$());\n" - " msg.set$list_name$(value);\n" - " } else {\n" - " var value = /** @type {$fieldtype$} */ " - "(reader.read$reader$());\n" - " msg.add$name$(value);\n" - " }\n", - "fieldtype_packed", JSFieldTypeAnnotation(options, field, false, true, - /* singular_if_not_packed */ false, - BYTES_U8), - "fieldtype", JSFieldTypeAnnotation(options, field, false, true, - /* singular_if_not_packed */ true, - BYTES_U8), - "reader", JSBinaryReaderMethodType(field), - "list_name", JSGetterName(options, field), - "name", JSGetterName(options, field, - BYTES_DEFAULT, /* drop_list = */ true) - ); } else { printer->Print( " var value = /** @type {$fieldtype$} */ " @@ -2910,15 +2887,14 @@ void Generator::GenerateClassDeserializeBinaryField( JSBinaryReadWriteMethodName(field, /* is_writer = */ false)); } - if (field->is_repeated() && - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->cpp_type() == FieldDescriptor::CPPTYPE_STRING)) { + if (field->is_repeated() && !field->is_packed()) { printer->Print( " msg.add$name$(value);\n", "name", JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true)); - } else if (!field->is_repeated()) { - // Singular fields, receive a |value| as the field's value ; set this as - // the field's value directly. + } else { + // Singular fields, and packed repeated fields, receive a |value| either + // as the field's value or as the array of all the field's values; set + // this as the field's value directly. printer->Print( " msg.set$name$(value);\n", "name", JSGetterName(options, field)); |