hpb: fully migrate gen_extensions from .EmitLegacy to .Emit

PiperOrigin-RevId: 691826719
pull/19055/head
Hong Shin 4 weeks ago committed by Copybara-Service
parent b72722a8d6
commit e406a1a934
  1. 22
      hpb_generator/gen_extensions.cc

@ -41,19 +41,17 @@ void WriteExtensionIdentifierHeader(const protobuf::FieldDescriptor* ext,
Context& ctx) {
std::string mini_table_name =
absl::StrCat(ExtensionIdentifierBase(ext), "_", ext->name(), "_ext");
if (ext->extension_scope()) {
ctx.EmitLegacy(
R"cc(
static const ::hpb::internal::ExtensionIdentifier<$0, $1> $2;
)cc",
ContainingTypeName(ext), CppTypeParameterName(ext), ext->name());
} else {
ctx.EmitLegacy(
std::string linkage = ext->extension_scope() ? "static" : "extern";
ctx.Emit(
{{"linkage", linkage},
{"extendee_type", ContainingTypeName(ext)},
{"extension_type", CppTypeParameterName(ext)},
{"extension_name", ext->name()}},
R"cc(
extern const ::hpb::internal::ExtensionIdentifier<$0, $1> $2;
)cc",
ContainingTypeName(ext), CppTypeParameterName(ext), ext->name());
}
$linkage$ const ::hpb::internal::ExtensionIdentifier<$extendee_type$,
$extension_type$>
$extension_name$;
)cc");
}
void WriteExtensionIdentifiersHeader(

Loading…
Cancel
Save