8000 Fix repeated field wrapper class name generation · reddaly/protobuf-javascript@ea63156 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea63156

Browse files
egormodingonzojive
authored andcommitted
Fix repeated field wrapper class name generation
1 parent 36960c2 commit ea63156

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

generator/js_generator.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ static const char* kRepeatedFieldArrayName = "repeatedFields_";
11501150
std::string RepeatedFieldsArrayName(const GeneratorOptions& options,
11511151
const Descriptor* desc) {
11521152
return HasRepeatedFields(options, desc)
1153-
? (GetMessagePath(options, desc) + "." + kRepeatedFieldArrayName)
1153+
? (desc->name() + "." + kRepeatedFieldArrayName)
11541154
: "null";
11551155
}
11561156

@@ -2873,7 +2873,7 @@ const char * methodEndBrace = options.WantEs6() ? "}" : "};";
28732873
"\n");
28742874

28752875
if (field->is_repeated()) {
2876-
GenerateRepeatedMessageHelperMethods(options, printer, field);
2876+
GenerateRepeatedMessageHelperMethods(options, type_names, printer, field);
28772877
}
28782878

28792879
} else {
@@ -3177,7 +3177,7 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods(
31773177
}
31783178

31793179
void Generator::GenerateRepeatedMessageHelperMethods(
3180-
const GeneratorOptions& options, io::Printer* printer,
3180+
const GeneratorOptions& options, const TypeNames& type_names, io::Printer* printer,
31813181
const FieldDescriptor* field) const {
31823182

31833183
const std::string classSymbol = GetMessagePath(options, field->containing_type());
@@ -3202,13 +3202,13 @@ void Generator::GenerateRepeatedMessageHelperMethods(
32023202

32033203
printer->Annotate("addername", field);
32043204
printer->Print(
3205-
"this, $index$$oneofgroup$, opt_value, $ctor$, opt_index);\n"
3205+
"this, $index$$oneofgroup$, opt_value, $class$, opt_index);\n"
32063206
"};\n"
32073207
"\n"
32083208
"\n",
32093209
"index", JSFieldIndex(field), "oneofgroup",
3210-
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor",
3211-
GetMessagePath(options, field->message_type()));
3210+
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "class",
3211+
type_names.SubmessageTypeRef(field));
32123212
}
32133213

32143214
void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,

generator/js_generator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
439439

440440
// Generate addFoo() method for repeated message fields.
441441
void GenerateRepeatedMessageHelperMethods(const GeneratorOptions& options,
442+
const TypeNames& type_names,
442443
io::Printer* printer,
443444
const FieldDescriptor* field) const;
444445

0 commit comments

Comments
 (0)
0