diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-27 15:37:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-02-04 18:23:20 +0000 |
commit | 3493f580bb53c62e3c6233f8472aafc849225079 (patch) | |
tree | bdf0faab2c854dc15df87e868651cde18fed2fd9 | |
parent | 16652e3cc0ef22e26d2481b70531a452e9da37f3 (diff) | |
download | qtwebengine-chromium-3493f580bb53c62e3c6233f8472aafc849225079.tar.gz |
Fix protozero generated sources
Avoid using the details of the classes before they have been defined.
Required for clang_cl and MSVC.
Change-Id: Ia9123cf46e513ced7a88e94c4e93d66de2d9930a
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r-- | chromium/third_party/perfetto/src/protozero/protoc_plugin/cppgen_plugin.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/chromium/third_party/perfetto/src/protozero/protoc_plugin/cppgen_plugin.cc b/chromium/third_party/perfetto/src/protozero/protoc_plugin/cppgen_plugin.cc index 817f0784202..7e6c3f059a4 100644 --- a/chromium/third_party/perfetto/src/protozero/protoc_plugin/cppgen_plugin.cc +++ b/chromium/third_party/perfetto/src/protozero/protoc_plugin/cppgen_plugin.cc @@ -403,16 +403,9 @@ void CppObjGenerator::GenClassDecl(const Descriptor* msg, Printer* p) const { p->Print("void clear_$n$() { $n$_.clear(); }\n", "n", field->lowercase_name()); - if (field->type() == TYPE_MESSAGE && !field->options().lazy()) { - p->Print( - "$t$* add_$n$() { $n$_.emplace_back(); return &$n$_.back(); " - "}\n", - "t", GetCppType(field, false), "n", field->lowercase_name()); - } else { - p->Print( - "$t$* add_$n$() { $n$_.emplace_back(); return &$n$_.back(); }\n", - "t", GetCppType(field, false), "n", field->lowercase_name()); - } + p->Print( + "$t$* add_$n$(); \n", "t", GetCppType(field, false), + "n", field->lowercase_name()); } } p->Outdent(); @@ -472,6 +465,20 @@ void CppObjGenerator::GenClassDef(const Descriptor* msg, Printer* p) const { std::string proto_type = GetFullName(msg, true); + // Non-inline accessors: + for (int i = 0; i < msg->field_count(); i++) { + const FieldDescriptor* field = msg->field(i); + if (!field->options().lazy() && field->is_repeated()) { + p->Print("$t$* $f$::add_$n$() {\n", "f", full_name, + "t", GetCppType(field, false), "n", field->lowercase_name()); + p->Indent(); + p->Print("$n$_.emplace_back();\n", "n", field->lowercase_name()); + p->Print("return &$n$_.back();\n", "n", field->lowercase_name()); + p->Outdent(); + p->Print("}\n\n"); + } + } + // Genrate the ParseRawProto() method definition. p->Print("void $f$::ParseRawProto(const std::string& raw) {\n", "f", full_name); |