diff --git a/hpb/extension.h b/hpb/extension.h index 100296dfab..d5fa632e31 100644 --- a/hpb/extension.h +++ b/hpb/extension.h @@ -61,14 +61,14 @@ class ExtensionIdentifier : public ExtensionMiniTableProvider { using Extension = ExtensionType; using Extendee = ExtendeeType; - private: constexpr explicit ExtensionIdentifier( const upb_MiniTableExtension* mini_table_ext) : ExtensionMiniTableProvider(mini_table_ext) {} + + private: constexpr uint32_t number() const { return upb_MiniTableExtension_Number(mini_table_ext()); } - friend struct PrivateAccess; }; diff --git a/hpb/internal/internal.h b/hpb/internal/internal.h index 028af6d510..1019f13237 100644 --- a/hpb/internal/internal.h +++ b/hpb/internal/internal.h @@ -9,7 +9,6 @@ #define GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ #include -#include #include "upb/mem/arena.h" #include "upb/message/message.h" @@ -38,11 +37,6 @@ struct PrivateAccess { return typename T::Proxy(upb_Message_New(T::minitable(), arena), arena); } - template - static auto InvokeConstructor(Args&&... args) { - return T(std::forward(args)...); - } - template static constexpr uint32_t GetExtensionNumber(const ExtensionId& id) { return id.number(); diff --git a/hpb_generator/gen_extensions.cc b/hpb_generator/gen_extensions.cc index 8374ed20cb..7be6767618 100644 --- a/hpb_generator/gen_extensions.cc +++ b/hpb_generator/gen_extensions.cc @@ -9,6 +9,7 @@ #include "absl/strings/str_cat.h" #include "google/protobuf/compiler/hpb/context.h" +#include "google/protobuf/compiler/hpb/gen_utils.h" #include "google/protobuf/compiler/hpb/names.h" #include "upb_generator/c/names.h" @@ -68,18 +69,14 @@ void WriteExtensionIdentifier(const protobuf::FieldDescriptor* ext, if (ext->extension_scope()) { ctx.EmitLegacy( R"cc( - const hpb::internal::ExtensionIdentifier<$0, $3> $4::$2 = - hpb::internal::PrivateAccess::InvokeConstructor< - hpb::internal::ExtensionIdentifier<$0, $3>>(&$1); + const hpb::internal::ExtensionIdentifier<$0, $3> $4::$2(&$1); )cc", ContainingTypeName(ext), mini_table_name, ext->name(), CppTypeParameterName(ext), ClassName(ext->extension_scope())); } else { ctx.EmitLegacy( R"cc( - const hpb::internal::ExtensionIdentifier<$0, $3> $2 = - hpb::internal::PrivateAccess::InvokeConstructor< - hpb::internal::ExtensionIdentifier<$0, $3>>(&$1); + const hpb::internal::ExtensionIdentifier<$0, $3> $2(&$1); )cc", ContainingTypeName(ext), mini_table_name, ext->name(), CppTypeParameterName(ext));