Skip to content

Commit

Permalink
Remove the proto_ns substitution variable and replace its use with …
Browse files Browse the repository at this point in the history
…`pb` or

`pbi` where appropriate.

The `proto_ns` variable not fully qualified and risks forgetting the prefix
`::` which could potentially break codegen if user namespace has a matching
subnamespace.

PiperOrigin-RevId: 714982016
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 13, 2025
1 parent 4214ee7 commit d36971b
Show file tree
Hide file tree
Showing 24 changed files with 849 additions and 1,214 deletions.
4 changes: 2 additions & 2 deletions editions/golden/compare_cpp_codegen_failure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
- // optional int32 int32_field = 1;
+ // int32 int32_field = 1;
if (cached_has_bits & 0x00000001u) {
target = ::proto2::internal::WireFormatLite::
WriteInt32ToArrayWithField<1>(
target =
::proto2::internal::WireFormatLite::WriteInt32ToArrayWithField<1>(
@@ @@
(void)cached_has_bits;

Expand Down
2 changes: 1 addition & 1 deletion editions/golden/compare_cpp_codegen_failure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<testsuites tests="1" name="AllTests">
<testsuite name="EditionsCodegenTests">
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.cc" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; target = ::proto2::internal::WireFormatLite::&#x0A; WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; target =&#x0A; ::proto2::internal::WireFormatLite::WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
</testcase>
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.h" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.h&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;&#x0A;#ifndef third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;#define third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;&#x0A;#include &lt;limits&gt;&#x0A;#include &lt;string&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &lt;utility&gt;&#x0A;&#x0A;#include &quot;third_party/protobuf/runtime_version.h&quot;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/arena.h&quot;&#x0A;#include &quot;third_party/protobuf/arenastring.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_decl.h&quot;&#x0A;#include &quot;third_party/protobuf/v2/generated_message_table.h&quot;&#x0A;#include &quot;third_party/protobuf/v2/generated_message_table_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/metadata_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/message_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;&#x0A;#endif // third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;, with the difference:&#x0A;@@ @@&#x0A; enum : int {&#x0A; kInt32FieldFieldNumber = 1,&#x0A; };&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; bool has_int32_field() const;&#x0A; void clear_int32_field() ;&#x0A; ::int32_t int32_field() const;&#x0A;@@ @@&#x0A; &#x0A; // SimpleProto3&#x0A; &#x0A;-// optional int32 int32_field = 1;&#x0A;+// int32 int32_field = 1;&#x0A; inline bool SimpleProto3::has_int32_field() const {&#x0A; bool value = (_impl_._has_bits_[0] &amp; 0x00000001u) != 0;&#x0A; return value;" type=""></failure>
Expand Down
42 changes: 19 additions & 23 deletions src/google/protobuf/compiler/cpp/enum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {

if (has_reflection_) {
p->Emit(R"(
$dllexport_decl $const ::$proto_ns$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor();
$dllexport_decl $const $pb$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor();
)");
} else {
p->Emit(R"cc(
Expand Down Expand Up @@ -243,8 +243,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
p->Emit(R"cc(
template <>
inline $return_type$ $Msg_Enum$_Name($Msg_Enum$ value) {
return ::$proto_ns$::internal::NameOfDenseEnum<$Msg_Enum$_descriptor,
$kMin$, $kMax$>(
return $pbi$::NameOfDenseEnum<$Msg_Enum$_descriptor, $kMin$, $kMax$>(
static_cast<int>(value));
}
)cc");
Expand All @@ -254,7 +253,7 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
template <typename T>
$return_type$ $Msg_Enum$_Name(T value) {
$static_assert$;
return ::$proto_ns$::internal::NameOfEnum($Msg_Enum$_descriptor(), value);
return $pbi$::NameOfEnum($Msg_Enum$_descriptor(), value);
}
)cc");
}
Expand All @@ -264,8 +263,8 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) {
inline bool $Msg_Enum$_Parse(
//~
absl::string_view name, $Msg_Enum$* $nonnull$ value) {
return ::$proto_ns$::internal::ParseNamedEnum<$Msg_Enum$>(
$Msg_Enum$_descriptor(), name, value);
return $pbi$::ParseNamedEnum<$Msg_Enum$>($Msg_Enum$_descriptor(), name,
value);
}
)cc");
} else {
Expand Down Expand Up @@ -344,7 +343,7 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* p) const {

if (has_reflection_) {
p->Emit(R"(
static inline const ::$proto_ns$::EnumDescriptor* $nonnull$ $Enum$_descriptor() {
static inline const $pb$::EnumDescriptor* $nonnull$ $Enum$_descriptor() {
return $Msg_Enum$_descriptor();
}
)");
Expand Down Expand Up @@ -410,8 +409,8 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {

if (has_reflection_) {
p->Emit({{"idx", idx}}, R"cc(
const ::$proto_ns$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor() {
::$proto_ns$::internal::AssignDescriptors(&$desc_table$);
const $pb$::EnumDescriptor* $nonnull$ $Msg_Enum$_descriptor() {
$pbi$::AssignDescriptors(&$desc_table$);
return $file_level_enum_descriptors$[$idx$];
}
)cc");
Expand Down Expand Up @@ -527,39 +526,36 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* p) {
}},
},
R"cc(
static ::$proto_ns$::internal::ExplicitlyConstructed<std::string>
static $pbi$::ExplicitlyConstructed<std::string>
$Msg_Enum$_strings[$num_unique$] = {};
static const char $Msg_Enum$_names[] = {
$names$,
};
static const ::$proto_ns$::internal::EnumEntry $Msg_Enum$_entries[] =
{
$entries$,
static const $pbi$::EnumEntry $Msg_Enum$_entries[] = {
$entries$,
};
static const int $Msg_Enum$_entries_by_number[] = {
$entries_by_number$,
};
$return_type$ $Msg_Enum$_Name($Msg_Enum$ value) {
static const bool kDummy =
::$proto_ns$::internal::InitializeEnumStrings(
$Msg_Enum$_entries, $Msg_Enum$_entries_by_number,
$num_unique$, $Msg_Enum$_strings);
static const bool kDummy = $pbi$::InitializeEnumStrings(
$Msg_Enum$_entries, $Msg_Enum$_entries_by_number, $num_unique$,
$Msg_Enum$_strings);
(void)kDummy;
int idx = ::$proto_ns$::internal::LookUpEnumName(
$Msg_Enum$_entries, $Msg_Enum$_entries_by_number, $num_unique$,
value);
return idx == -1 ? ::$proto_ns$::internal::GetEmptyString()
: $Msg_Enum$_strings[idx].get();
int idx = $pbi$::LookUpEnumName($Msg_Enum$_entries,
$Msg_Enum$_entries_by_number,
$num_unique$, value);
return idx == -1 ? $pbi$::GetEmptyString() : $Msg_Enum$_strings[idx].get();
}
bool $Msg_Enum$_Parse(absl::string_view name, $Msg_Enum$* $nonnull$ value) {
int int_value;
bool success = ::$proto_ns$::internal::LookUpEnumValue(
bool success = $pbi$::LookUpEnumValue(
$Msg_Enum$_entries, $num_declared$, name, &int_value);
if (success) {
*value = static_cast<$Msg_Enum$>(int_value);
Expand Down
5 changes: 2 additions & 3 deletions src/google/protobuf/compiler/cpp/extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ void ExtensionGenerator::GenerateDeclaration(io::Printer* p) const {
R"cc(
inline $constant_qualifier $constexpr int $constant_name$ =
$number$;
$id_qualifier$ ::$proto_ns$::internal::ExtensionIdentifier<
$extendee$, ::$proto_ns$::internal::$type_traits$, $field_type$,
$packed$>
$id_qualifier$ $pbi$::ExtensionIdentifier<
$extendee$, $pbi$::$type_traits$, $field_type$, $packed$>
$name$;
)cc");
}
Expand Down
12 changes: 6 additions & 6 deletions src/google/protobuf/compiler/cpp/field_generators/cord_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CordFieldGenerator : public FieldGeneratorBase {
void GenerateOneofCopyConstruct(io::Printer* p) const override {
auto vars = p->WithVars(variables_);
p->Emit(R"cc(
$field$ = ::$proto_ns$::Arena::Create<absl::Cord>(arena, *from.$field$);
$field$ = $pb$::Arena::Create<absl::Cord>(arena, *from.$field$);
)cc");
}
};
Expand Down Expand Up @@ -276,7 +276,7 @@ void CordFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" $pbi$::WireFormatLite::$declared_type$Size(\n"
" this_._internal_$name$());\n");
}

Expand Down Expand Up @@ -362,7 +362,7 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name_internal$();
$field$ = new ::absl::Cord;
::$proto_ns$::Arena* arena = GetArena();
$pb$::Arena* arena = GetArena();
if (arena != nullptr) {
arena->Own($field$);
}
Expand All @@ -379,7 +379,7 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name_internal$();
$field$ = new ::absl::Cord;
::$proto_ns$::Arena* arena = GetArena();
$pb$::Arena* arena = GetArena();
if (arena != nullptr) {
arena->Own($field$);
}
Expand All @@ -396,7 +396,7 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions(
clear_$oneof_name$();
set_has_$name_internal$();
$field$ = new ::absl::Cord;
::$proto_ns$::Arena* arena = GetArena();
$pb$::Arena* arena = GetArena();
if (arena != nullptr) {
arena->Own($field$);
}
Expand Down Expand Up @@ -447,7 +447,7 @@ void CordOneofFieldGenerator::GenerateArenaDestructorCode(
void CordOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
printer->Emit(R"cc(
if (oneof_needs_init) {
_this->$field$ = ::$proto_ns$::Arena::Create<absl::Cord>(arena);
_this->$field$ = $pb$::Arena::Create<absl::Cord>(arena);
}
*_this->$field$ = *from.$field$;
)cc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts,
}

return {
{"Map", absl::Substitute("::google::protobuf::Map<$0, $1>", key_type, val_type)},
{"Map", absl::Substitute("::$2::Map<$0, $1>", key_type, val_type,
ProtobufNamespace(opts))},
{"Entry", ClassName(field->message_type(), false)},
{"Key", PrimitiveTypeName(opts, key->cpp_type())},
{"Val", val_type},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts,
QualifiedDefaultInstanceName(field->message_type(), opts);
std::string default_ptr =
QualifiedDefaultInstancePtr(field->message_type(), opts);
absl::string_view base = "::google::protobuf::MessageLite";
std::string base =
absl::StrCat("::", ProtobufNamespace(opts), "::", "MessageLite");

return {
{"Submsg", qualified_type},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ void SingularPrimitive::GenerateSerializeWithCachedSizesToArray(
// template parameter that handles the EnsureSpace and the writing
// of the tag+value to the array
p->Emit(R"cc(
target = ::$proto_ns$::internal::WireFormatLite::
Write$declared_type$ToArrayWithField<$number$>(
target =
$pbi$::WireFormatLite::Write$declared_type$ToArrayWithField<$number$>(
stream, this_._internal_$name$(), target);
)cc");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,14 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
$annotate_add$;
// @@protoc_insertion_point(field_add:$pkg.Msg.field$)
}
inline const ::$proto_ns$::RepeatedPtrField<std::string>&
$Msg$::$name$() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
inline const $pb$::RepeatedPtrField<std::string>& $Msg$::$name$() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_list$;
// @@protoc_insertion_point(field_list:$pkg.Msg.field$)
return _internal_$name_internal$();
}
inline ::$proto_ns$::RepeatedPtrField<std::string>* $nonnull$
inline $pb$::RepeatedPtrField<std::string>* $nonnull$
$Msg$::mutable_$name$() ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_mutable_list$;
Expand Down Expand Up @@ -938,12 +938,12 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
)cc");
} else {
p->Emit(R"cc(
inline const ::$proto_ns$::RepeatedPtrField<std::string>&
inline const $pb$::RepeatedPtrField<std::string>&
$Msg$::_internal_$name_internal$() const {
$TsanDetectConcurrentRead$;
return $field_$;
}
inline ::$proto_ns$::RepeatedPtrField<std::string>* $nonnull$
inline $pb$::RepeatedPtrField<std::string>* $nonnull$
$Msg$::_internal_mutable_$name_internal$() {
$TsanDetectConcurrentRead$;
return &$field_$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,14 @@ void RepeatedStringView::GenerateInlineAccessorDefinitions(
$annotate_add$;
// @@protoc_insertion_point(field_add_string_piece:$pkg.Msg.field$)
}
inline const ::$proto_ns$::RepeatedPtrField<std::string>&
$Msg$::$name$() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
inline const $pb$::RepeatedPtrField<std::string>& $Msg$::$name$() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_list$;
// @@protoc_insertion_point(field_list:$pkg.Msg.field$)
return _internal_$name_internal$();
}
inline ::$proto_ns$::RepeatedPtrField<std::string>* $nonnull$
inline $pb$::RepeatedPtrField<std::string>* $nonnull$
$Msg$::mutable_$name$() ABSL_ATTRIBUTE_LIFETIME_BOUND {
$WeakDescriptorSelfPin$;
$annotate_mutable_list$;
Expand Down Expand Up @@ -770,12 +770,12 @@ void RepeatedStringView::GenerateInlineAccessorDefinitions(
)cc");
} else {
p->Emit(R"cc(
inline const ::$proto_ns$::RepeatedPtrField<std::string>&
inline const $pb$::RepeatedPtrField<std::string>&
$Msg$::_internal_$name_internal$() const {
$TsanDetectConcurrentRead$;
return $field_$;
}
inline ::$proto_ns$::RepeatedPtrField<std::string>* $nonnull$
inline $pb$::RepeatedPtrField<std::string>* $nonnull$
$Msg$::_internal_mutable_$name_internal$() {
$TsanDetectConcurrentRead$;
return &$field_$;
Expand Down
9 changes: 4 additions & 5 deletions src/google/protobuf/compiler/cpp/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ void FileGenerator::GenerateSourcePrelude(io::Printer* p) {
// required by the standard.
p->Emit(R"cc(
PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::$proto_ns$;
namespace _pbi = ::$proto_ns$::internal;
namespace _fl = ::$proto_ns$::internal::field_layout;
namespace _pb = $pb$;
namespace _pbi = $pbi$;
namespace _fl = $pbi$::field_layout;
)cc");
}

Expand Down Expand Up @@ -1775,8 +1775,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(io::Printer* p) {
// just use the symbol to force-link the C++ generated code when necessary.
p->Emit(R"cc(
extern "C" {
$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable
$desc_table$;
$dllexport_decl $extern const $pbi$::DescriptorTable $desc_table$;
} // extern "C"
)cc");
}
Expand Down
Loading

0 comments on commit d36971b

Please sign in to comment.