From 8741da3e45876f8c55ca062a08726f542f646423 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 13 Sep 2017 14:23:59 -0700 Subject: Revert "Fix js conformance tests. (#3604)" (#3633) This reverts commit 2bd55a9fbcd2815b3332bf309bc20f59eef0b36b. --- src/google/protobuf/compiler/js/js_generator.cc | 34 ++++--------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src/google') 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)); -- cgit v1.2.3