diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 2cbba81605..48a4310f1e 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -23,7 +23,7 @@ set(rules_jvm_external-version "6.7") set(rules_kotlin-version "2.3.20") set(rules_license-version "1.0.0") set(rules_pkg-version "1.0.1") -set(rules_python-version "1.6.0") +set(rules_python-version "2.3.0") set(rules_rust-version "0.69.0") set(rules_ruby-version "0.20.1") set(rules_fuzzing-version "0.5.3") diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 40243036a5..1ca1ab2e43 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -495,7 +495,7 @@ Error, UINTPTR_MAX is undefined /* aarch64 supports big and little endian modes; fasttable performs multibyte * tag loads assumes the tag of a varint is in the low bits. */ -#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \ +#if !defined(_WIN32) && (defined(__x86_64__) || defined(__AARCH64EL__)) && \ UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail) #define UPB_FASTTABLE_SUPPORTED 1 #else @@ -514,7 +514,11 @@ Error, UINTPTR_MAX is undefined * This is useful for releasing code that might be used on multiple platforms, * for example the PHP or Ruby C extensions. */ #elif defined(UPB_TRY_ENABLE_FASTTABLE) -#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#if UPB_FASTTABLE_SUPPORTED +#define UPB_FASTTABLE 1 +#else +#define UPB_FASTTABLE 0 +#endif #else #define UPB_FASTTABLE 0 #endif @@ -568,6 +572,12 @@ Error, UINTPTR_MAX is undefined #define UPB_RETAIN #endif +#if defined(__GNUC__) || defined(__clang__) +#define UPB_HIDDEN __attribute__((visibility("hidden"))) +#else +#define UPB_HIDDEN +#endif + // Linker arrays combine elements from multiple translation units into a single // array that can be iterated over at runtime. // @@ -621,7 +631,7 @@ Error, UINTPTR_MAX is undefined #elif defined(__MACH__) -/* As described in: https://stackoverflow.com/a/22366882 */ + /* As described in: https://stackoverflow.com/a/22366882 */ #define UPB_LINKARR_APPEND(name) \ __attribute__(( \ section("__DATA,__la_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS @@ -640,10 +650,10 @@ Error, UINTPTR_MAX is undefined #elif defined(_MSC_VER) -/* See: - * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 - * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 - * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ + /* See: + * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 + * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 + * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ #define UPB_STRINGIFY_INTERNAL(x) #x #define UPB_STRINGIFY(x) UPB_STRINGIFY_INTERNAL(x) #define UPB_CONCAT(a, b, c) a##b##c @@ -652,7 +662,7 @@ Error, UINTPTR_MAX is undefined #define UPB_LINKARR_APPEND(name) \ __pragma(section(UPB_LINKARR_NAME(name, $j), read)) \ __declspec(allocate(UPB_LINKARR_NAME(name, $j))) -// clang-format off + // clang-format off #define UPB_LINKARR_DECLARE(name, type) \ __pragma(message(UPB_LINKARR_NAME(name, $j))) \ __pragma(section(UPB_LINKARR_NAME(name, $a), read)) \ @@ -663,13 +673,13 @@ Error, UINTPTR_MAX is undefined type __stop_linkarr_##name; \ UPB_LINKARR_APPEND(name) \ __declspec(selectany) type UPB_linkarr_internal_empty_##name[1] = {0} -// clang-format on + // clang-format on #define UPB_LINKARR_START(name) (&__start_linkarr_##name) #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name) #else -// Linker arrays are not supported on this platform. Make macros no-ops. + // Linker arrays are not supported on this platform. Make macros no-ops. #define UPB_LINKARR_APPEND(name) #define UPB_LINKARR_DECLARE(name, type) \ UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \ @@ -9207,6 +9217,25 @@ void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) { } } +bool upb_Message_NextSerializableField(const upb_Message* msg, + const upb_MiniTable* mt, + const upb_MiniTableField** f, + uintptr_t* iter) { + const size_t field_count = upb_MiniTable_FieldCount(mt); + uintptr_t i = *iter; + while (i < field_count) { + const upb_MiniTableField* field = upb_MiniTable_GetFieldByIndex(mt, i); + if (UPB_PRIVATE(_upb_Message_FieldIsSet)(msg, field)) { + *f = field; + *iter = i + 1; + return true; + } + i++; + } + *iter = i; + return false; +} + #include #include @@ -9591,7 +9620,7 @@ bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, if (!(options & kUpb_CompareOption_IncludeUnknownFields)) return true; // The wire encoder enforces a maximum depth of 100 so we match that here. - return UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(msg1, msg2, 100) == + return _upb_Message_UnknownFieldsAreEqual(msg1, msg2, 100) == kUpb_UnknownCompareResult_Equal; } @@ -9654,10 +9683,17 @@ static void upb_UnknownFields_Grow(upb_UnknownField_Context* ctx, upb_UnknownField** ptr, upb_UnknownField** end) { size_t old = (*ptr - *base); - size_t new = UPB_MAX(4, old * 2); + size_t new; + if (upb_MulOverflow((uint32_t)2, old, &new)) { + upb_UnknownFields_OutOfMemory(ctx); + } + new = UPB_MAX(4, new); + size_t new_bytes; + if (upb_MulOverflow(new, sizeof(**base), &new_bytes)) { + upb_UnknownFields_OutOfMemory(ctx); + } - *base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base), - new * sizeof(**base)); + *base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base), new_bytes); if (!*base) upb_UnknownFields_OutOfMemory(ctx); *ptr = *base + old; @@ -9705,11 +9741,25 @@ static void upb_UnknownFields_SortRecursive(upb_UnknownField* arr, size_t start, static void upb_UnknownFields_Sort(upb_UnknownField_Context* ctx, upb_UnknownFields* fields) { if (ctx->tmp_size < fields->size) { - const int oldsize = ctx->tmp_size * sizeof(*ctx->tmp); + size_t oldsize; + if (upb_MulOverflow(sizeof(*ctx->tmp), ctx->tmp_size, &oldsize)) { + upb_UnknownFields_OutOfMemory(ctx); + } ctx->tmp_size = UPB_MAX(8, ctx->tmp_size); - while (ctx->tmp_size < fields->size) ctx->tmp_size *= 2; - const int newsize = ctx->tmp_size * sizeof(*ctx->tmp); - ctx->tmp = upb_grealloc(ctx->tmp, oldsize, newsize); + while (ctx->tmp_size < fields->size) { + if (upb_MulOverflow((uint32_t)2, ctx->tmp_size, &ctx->tmp_size)) { + upb_UnknownFields_OutOfMemory(ctx); + } + } + size_t newsize; + if (upb_MulOverflow(ctx->tmp_size, sizeof(*ctx->tmp), &newsize)) { + upb_UnknownFields_OutOfMemory(ctx); + } + upb_UnknownField* tmp = upb_grealloc(ctx->tmp, oldsize, newsize); + if (!tmp) { + upb_UnknownFields_OutOfMemory(ctx); + } + ctx->tmp = tmp; } upb_UnknownFields_SortRecursive(fields->fields, 0, fields->size, ctx->tmp); } @@ -9953,7 +10003,7 @@ static upb_UnknownCompareResult upb_UnknownField_Compare( return ret; } -upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( +upb_UnknownCompareResult _upb_Message_UnknownFieldsAreEqual( const upb_Message* msg1, const upb_Message* msg2, int max_depth) { bool msg1_empty = !upb_Message_HasUnknown(msg1); bool msg2_empty = !upb_Message_HasUnknown(msg2); @@ -10316,6 +10366,7 @@ bool upb_Message_MergeFrom(upb_Message* dst, const upb_Message* src, // so we don't want to unnecessarily have the bad API or bloat the passed-in // arena with this very-short-term allocation. upb_Arena* encode_arena = upb_Arena_New(); + if (!encode_arena) return false; upb_EncodeStatus e_status = upb_Encode(src, mt, 0, encode_arena, &buf, &size); if (e_status != kUpb_EncodeStatus_Ok) { upb_Arena_Free(encode_arena); @@ -15266,7 +15317,12 @@ const void* _upb_DefBuilder_ResolveAny(upb_DefBuilder* ctx, } else { // Remove components from base until we find an entry or run out. size_t baselen = base ? strlen(base) : 0; - char* tmp = upb_gmalloc(sym.size + baselen + 1); + size_t alloc_size; + if (upb_AddOverflow(sym.size, baselen + 1, &alloc_size)) { + _upb_DefBuilder_OomErr(ctx); + } + char* tmp = upb_gmalloc(alloc_size); + if (!tmp) _upb_DefBuilder_OomErr(ctx); while (1) { char* p = tmp; if (baselen) { @@ -19201,40 +19257,7 @@ static char* encode_map(char* ptr, upb_encstate* e, const upb_Message* msg, static bool encode_shouldencode(const upb_Message* msg, const upb_MiniTableField* f) { - if (f->presence == 0) { - // Proto3 presence or map/array. - const void* mem = UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), void); - switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { - case kUpb_FieldRep_1Byte: { - char ch; - memcpy(&ch, mem, 1); - return ch != 0; - } - case kUpb_FieldRep_4Byte: { - uint32_t u32; - memcpy(&u32, mem, 4); - return u32 != 0; - } - case kUpb_FieldRep_8Byte: { - uint64_t u64; - memcpy(&u64, mem, 8); - return u64 != 0; - } - case kUpb_FieldRep_StringView: { - const upb_StringView* str = (const upb_StringView*)mem; - return str->size != 0; - } - default: - UPB_UNREACHABLE(); - } - } else if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { - // Proto2 presence: hasbit. - return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, f); - } else { - // Field is in a oneof. - return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == - upb_MiniTableField_Number(f); - } + return UPB_PRIVATE(_upb_Message_FieldIsSet)(msg, f); } static char* encode_field(char* ptr, upb_encstate* e, const upb_Message* msg, @@ -19644,3 +19667,5 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)( #undef _UPB_STRINGIFY #undef _UPB_STRINGIFY2 #undef UPB_CONSTRUCTOR +#undef UPB_RETAIN +#undef UPB_HIDDEN diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index b96d839a69..cbd4c83d18 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -494,7 +494,7 @@ Error, UINTPTR_MAX is undefined /* aarch64 supports big and little endian modes; fasttable performs multibyte * tag loads assumes the tag of a varint is in the low bits. */ -#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \ +#if !defined(_WIN32) && (defined(__x86_64__) || defined(__AARCH64EL__)) && \ UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail) #define UPB_FASTTABLE_SUPPORTED 1 #else @@ -513,7 +513,11 @@ Error, UINTPTR_MAX is undefined * This is useful for releasing code that might be used on multiple platforms, * for example the PHP or Ruby C extensions. */ #elif defined(UPB_TRY_ENABLE_FASTTABLE) -#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#if UPB_FASTTABLE_SUPPORTED +#define UPB_FASTTABLE 1 +#else +#define UPB_FASTTABLE 0 +#endif #else #define UPB_FASTTABLE 0 #endif @@ -567,6 +571,12 @@ Error, UINTPTR_MAX is undefined #define UPB_RETAIN #endif +#if defined(__GNUC__) || defined(__clang__) +#define UPB_HIDDEN __attribute__((visibility("hidden"))) +#else +#define UPB_HIDDEN +#endif + // Linker arrays combine elements from multiple translation units into a single // array that can be iterated over at runtime. // @@ -620,7 +630,7 @@ Error, UINTPTR_MAX is undefined #elif defined(__MACH__) -/* As described in: https://stackoverflow.com/a/22366882 */ + /* As described in: https://stackoverflow.com/a/22366882 */ #define UPB_LINKARR_APPEND(name) \ __attribute__(( \ section("__DATA,__la_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS @@ -639,10 +649,10 @@ Error, UINTPTR_MAX is undefined #elif defined(_MSC_VER) -/* See: - * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 - * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 - * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ + /* See: + * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 + * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 + * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ #define UPB_STRINGIFY_INTERNAL(x) #x #define UPB_STRINGIFY(x) UPB_STRINGIFY_INTERNAL(x) #define UPB_CONCAT(a, b, c) a##b##c @@ -651,7 +661,7 @@ Error, UINTPTR_MAX is undefined #define UPB_LINKARR_APPEND(name) \ __pragma(section(UPB_LINKARR_NAME(name, $j), read)) \ __declspec(allocate(UPB_LINKARR_NAME(name, $j))) -// clang-format off + // clang-format off #define UPB_LINKARR_DECLARE(name, type) \ __pragma(message(UPB_LINKARR_NAME(name, $j))) \ __pragma(section(UPB_LINKARR_NAME(name, $a), read)) \ @@ -662,13 +672,13 @@ Error, UINTPTR_MAX is undefined type __stop_linkarr_##name; \ UPB_LINKARR_APPEND(name) \ __declspec(selectany) type UPB_linkarr_internal_empty_##name[1] = {0} -// clang-format on + // clang-format on #define UPB_LINKARR_START(name) (&__start_linkarr_##name) #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name) #else -// Linker arrays are not supported on this platform. Make macros no-ops. + // Linker arrays are not supported on this platform. Make macros no-ops. #define UPB_LINKARR_APPEND(name) #define UPB_LINKARR_DECLARE(name, type) \ UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \ @@ -5038,6 +5048,9 @@ upb_Message_GetOrCreateMutableMessage(struct upb_Message* msg, const upb_MiniTable* sub_mini_table = upb_MiniTable_SubMessage(f); UPB_ASSERT(sub_mini_table); sub_message = _upb_Message_New(sub_mini_table, arena); + if (!sub_message) { + return NULL; + } *UPB_PTR_AT(msg, f->UPB_ONLYBITS(offset), struct upb_Message*) = sub_message; UPB_PRIVATE(_upb_Message_SetPresence)(msg, f); @@ -5045,6 +5058,44 @@ upb_Message_GetOrCreateMutableMessage(struct upb_Message* msg, return sub_message; } +UPB_INLINE bool UPB_PRIVATE(_upb_Message_FieldIsSet)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + if (f->presence == 0) { + // Proto3 presence or map/array. + const void* mem = UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), void); + switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { + case kUpb_FieldRep_1Byte: { + char ch; + memcpy(&ch, mem, 1); + return ch != 0; + } + case kUpb_FieldRep_4Byte: { + uint32_t u32; + memcpy(&u32, mem, 4); + return u32 != 0; + } + case kUpb_FieldRep_8Byte: { + uint64_t u64; + memcpy(&u64, mem, 8); + return u64 != 0; + } + case kUpb_FieldRep_StringView: { + const upb_StringView* str = (const upb_StringView*)mem; + return str->size != 0; + } + default: + UPB_UNREACHABLE(); + } + } else if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { + // Proto2 presence: hasbit. + return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, f); + } else { + // Field is in a oneof. + return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == + upb_MiniTableField_Number(f); + } +} + UPB_API_INLINE upb_StringView upb_Message_GetString(const struct upb_Message* msg, const upb_MiniTableField* f, upb_StringView default_val) { @@ -5770,6 +5821,29 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_NextExtensionReverse)( const struct upb_Message* msg, const upb_MiniTableExtension** out_e, upb_MessageValue* out_v, uintptr_t* iter); +#define kUpb_Message_SerializableFieldBegin 0 + +// Iterates over all fields in the message that are set/present. +// +// NOTE: Unset/NULL repeated fields and maps are not considered set and will be +// ignored. However, allocated repeated fields and maps (non-NULL pointer) with +// zero elements are considered set/present and will be returned by this +// iterator. Callers that need to skip empty collections should check their +// sizes explicitly. +// +// To start iterating, set `iter = kUpb_Message_SerializableFieldBegin`. +// Returns true if a serializable field was found, sets `*f` to that field, +// and updates `*iter`. Returns false when iteration is complete. +// +// const upb_MiniTableField* f; +// uintptr_t iter = kUpb_Message_SerializableFieldBegin; +// while (upb_Message_NextSerializableField(msg, mt, &f, &iter)) { +// // ... +// } +UPB_NODISCARD UPB_API bool upb_Message_NextSerializableField( + const upb_Message* msg, const upb_MiniTable* mt, + const upb_MiniTableField** f, uintptr_t* iter); + // Mark a message and all of its descendents as frozen/immutable. UPB_API void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m); @@ -17887,7 +17961,7 @@ typedef enum { kUpb_UnknownCompareResult_MaxDepthExceeded = 3, } upb_UnknownCompareResult; -upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( +upb_UnknownCompareResult _upb_Message_UnknownFieldsAreEqual( const upb_Message* msg1, const upb_Message* msg2, int max_depth); #ifdef __cplusplus @@ -19724,3 +19798,5 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) { #undef _UPB_STRINGIFY #undef _UPB_STRINGIFY2 #undef UPB_CONSTRUCTOR +#undef UPB_RETAIN +#undef UPB_HIDDEN diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index e5766f5d03..9e81b6f1ca 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -495,7 +495,7 @@ Error, UINTPTR_MAX is undefined /* aarch64 supports big and little endian modes; fasttable performs multibyte * tag loads assumes the tag of a varint is in the low bits. */ -#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \ +#if !defined(_WIN32) && (defined(__x86_64__) || defined(__AARCH64EL__)) && \ UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail) #define UPB_FASTTABLE_SUPPORTED 1 #else @@ -514,7 +514,11 @@ Error, UINTPTR_MAX is undefined * This is useful for releasing code that might be used on multiple platforms, * for example the PHP or Ruby C extensions. */ #elif defined(UPB_TRY_ENABLE_FASTTABLE) -#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#if UPB_FASTTABLE_SUPPORTED +#define UPB_FASTTABLE 1 +#else +#define UPB_FASTTABLE 0 +#endif #else #define UPB_FASTTABLE 0 #endif @@ -568,6 +572,12 @@ Error, UINTPTR_MAX is undefined #define UPB_RETAIN #endif +#if defined(__GNUC__) || defined(__clang__) +#define UPB_HIDDEN __attribute__((visibility("hidden"))) +#else +#define UPB_HIDDEN +#endif + // Linker arrays combine elements from multiple translation units into a single // array that can be iterated over at runtime. // @@ -621,7 +631,7 @@ Error, UINTPTR_MAX is undefined #elif defined(__MACH__) -/* As described in: https://stackoverflow.com/a/22366882 */ + /* As described in: https://stackoverflow.com/a/22366882 */ #define UPB_LINKARR_APPEND(name) \ __attribute__(( \ section("__DATA,__la_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS @@ -640,10 +650,10 @@ Error, UINTPTR_MAX is undefined #elif defined(_MSC_VER) -/* See: - * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 - * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 - * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ + /* See: + * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 + * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 + * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ #define UPB_STRINGIFY_INTERNAL(x) #x #define UPB_STRINGIFY(x) UPB_STRINGIFY_INTERNAL(x) #define UPB_CONCAT(a, b, c) a##b##c @@ -652,7 +662,7 @@ Error, UINTPTR_MAX is undefined #define UPB_LINKARR_APPEND(name) \ __pragma(section(UPB_LINKARR_NAME(name, $j), read)) \ __declspec(allocate(UPB_LINKARR_NAME(name, $j))) -// clang-format off + // clang-format off #define UPB_LINKARR_DECLARE(name, type) \ __pragma(message(UPB_LINKARR_NAME(name, $j))) \ __pragma(section(UPB_LINKARR_NAME(name, $a), read)) \ @@ -663,13 +673,13 @@ Error, UINTPTR_MAX is undefined type __stop_linkarr_##name; \ UPB_LINKARR_APPEND(name) \ __declspec(selectany) type UPB_linkarr_internal_empty_##name[1] = {0} -// clang-format on + // clang-format on #define UPB_LINKARR_START(name) (&__start_linkarr_##name) #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name) #else -// Linker arrays are not supported on this platform. Make macros no-ops. + // Linker arrays are not supported on this platform. Make macros no-ops. #define UPB_LINKARR_APPEND(name) #define UPB_LINKARR_DECLARE(name, type) \ UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \ @@ -7960,6 +7970,25 @@ void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) { } } +bool upb_Message_NextSerializableField(const upb_Message* msg, + const upb_MiniTable* mt, + const upb_MiniTableField** f, + uintptr_t* iter) { + const size_t field_count = upb_MiniTable_FieldCount(mt); + uintptr_t i = *iter; + while (i < field_count) { + const upb_MiniTableField* field = upb_MiniTable_GetFieldByIndex(mt, i); + if (UPB_PRIVATE(_upb_Message_FieldIsSet)(msg, field)) { + *f = field; + *iter = i + 1; + return true; + } + i++; + } + *iter = i; + return false; +} + #include #include @@ -8344,7 +8373,7 @@ bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, if (!(options & kUpb_CompareOption_IncludeUnknownFields)) return true; // The wire encoder enforces a maximum depth of 100 so we match that here. - return UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(msg1, msg2, 100) == + return _upb_Message_UnknownFieldsAreEqual(msg1, msg2, 100) == kUpb_UnknownCompareResult_Equal; } @@ -8407,10 +8436,17 @@ static void upb_UnknownFields_Grow(upb_UnknownField_Context* ctx, upb_UnknownField** ptr, upb_UnknownField** end) { size_t old = (*ptr - *base); - size_t new = UPB_MAX(4, old * 2); + size_t new; + if (upb_MulOverflow((uint32_t)2, old, &new)) { + upb_UnknownFields_OutOfMemory(ctx); + } + new = UPB_MAX(4, new); + size_t new_bytes; + if (upb_MulOverflow(new, sizeof(**base), &new_bytes)) { + upb_UnknownFields_OutOfMemory(ctx); + } - *base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base), - new * sizeof(**base)); + *base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base), new_bytes); if (!*base) upb_UnknownFields_OutOfMemory(ctx); *ptr = *base + old; @@ -8458,11 +8494,25 @@ static void upb_UnknownFields_SortRecursive(upb_UnknownField* arr, size_t start, static void upb_UnknownFields_Sort(upb_UnknownField_Context* ctx, upb_UnknownFields* fields) { if (ctx->tmp_size < fields->size) { - const int oldsize = ctx->tmp_size * sizeof(*ctx->tmp); + size_t oldsize; + if (upb_MulOverflow(sizeof(*ctx->tmp), ctx->tmp_size, &oldsize)) { + upb_UnknownFields_OutOfMemory(ctx); + } ctx->tmp_size = UPB_MAX(8, ctx->tmp_size); - while (ctx->tmp_size < fields->size) ctx->tmp_size *= 2; - const int newsize = ctx->tmp_size * sizeof(*ctx->tmp); - ctx->tmp = upb_grealloc(ctx->tmp, oldsize, newsize); + while (ctx->tmp_size < fields->size) { + if (upb_MulOverflow((uint32_t)2, ctx->tmp_size, &ctx->tmp_size)) { + upb_UnknownFields_OutOfMemory(ctx); + } + } + size_t newsize; + if (upb_MulOverflow(ctx->tmp_size, sizeof(*ctx->tmp), &newsize)) { + upb_UnknownFields_OutOfMemory(ctx); + } + upb_UnknownField* tmp = upb_grealloc(ctx->tmp, oldsize, newsize); + if (!tmp) { + upb_UnknownFields_OutOfMemory(ctx); + } + ctx->tmp = tmp; } upb_UnknownFields_SortRecursive(fields->fields, 0, fields->size, ctx->tmp); } @@ -8706,7 +8756,7 @@ static upb_UnknownCompareResult upb_UnknownField_Compare( return ret; } -upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( +upb_UnknownCompareResult _upb_Message_UnknownFieldsAreEqual( const upb_Message* msg1, const upb_Message* msg2, int max_depth) { bool msg1_empty = !upb_Message_HasUnknown(msg1); bool msg2_empty = !upb_Message_HasUnknown(msg2); @@ -9069,6 +9119,7 @@ bool upb_Message_MergeFrom(upb_Message* dst, const upb_Message* src, // so we don't want to unnecessarily have the bad API or bloat the passed-in // arena with this very-short-term allocation. upb_Arena* encode_arena = upb_Arena_New(); + if (!encode_arena) return false; upb_EncodeStatus e_status = upb_Encode(src, mt, 0, encode_arena, &buf, &size); if (e_status != kUpb_EncodeStatus_Ok) { upb_Arena_Free(encode_arena); @@ -14019,7 +14070,12 @@ const void* _upb_DefBuilder_ResolveAny(upb_DefBuilder* ctx, } else { // Remove components from base until we find an entry or run out. size_t baselen = base ? strlen(base) : 0; - char* tmp = upb_gmalloc(sym.size + baselen + 1); + size_t alloc_size; + if (upb_AddOverflow(sym.size, baselen + 1, &alloc_size)) { + _upb_DefBuilder_OomErr(ctx); + } + char* tmp = upb_gmalloc(alloc_size); + if (!tmp) _upb_DefBuilder_OomErr(ctx); while (1) { char* p = tmp; if (baselen) { @@ -18664,40 +18720,7 @@ static char* encode_map(char* ptr, upb_encstate* e, const upb_Message* msg, static bool encode_shouldencode(const upb_Message* msg, const upb_MiniTableField* f) { - if (f->presence == 0) { - // Proto3 presence or map/array. - const void* mem = UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), void); - switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { - case kUpb_FieldRep_1Byte: { - char ch; - memcpy(&ch, mem, 1); - return ch != 0; - } - case kUpb_FieldRep_4Byte: { - uint32_t u32; - memcpy(&u32, mem, 4); - return u32 != 0; - } - case kUpb_FieldRep_8Byte: { - uint64_t u64; - memcpy(&u64, mem, 8); - return u64 != 0; - } - case kUpb_FieldRep_StringView: { - const upb_StringView* str = (const upb_StringView*)mem; - return str->size != 0; - } - default: - UPB_UNREACHABLE(); - } - } else if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { - // Proto2 presence: hasbit. - return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, f); - } else { - // Field is in a oneof. - return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == - upb_MiniTableField_Number(f); - } + return UPB_PRIVATE(_upb_Message_FieldIsSet)(msg, f); } static char* encode_field(char* ptr, upb_encstate* e, const upb_Message* msg, @@ -19107,3 +19130,5 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)( #undef _UPB_STRINGIFY #undef _UPB_STRINGIFY2 #undef UPB_CONSTRUCTOR +#undef UPB_RETAIN +#undef UPB_HIDDEN diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 4b9ecbc9ff..6f27aee692 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -494,7 +494,7 @@ Error, UINTPTR_MAX is undefined /* aarch64 supports big and little endian modes; fasttable performs multibyte * tag loads assumes the tag of a varint is in the low bits. */ -#if (defined(__x86_64__) || defined(__AARCH64EL__)) && \ +#if !defined(_WIN32) && (defined(__x86_64__) || defined(__AARCH64EL__)) && \ UPB_HAS_ATTRIBUTE(preserve_none) && UPB_HAS_ATTRIBUTE(musttail) #define UPB_FASTTABLE_SUPPORTED 1 #else @@ -513,7 +513,11 @@ Error, UINTPTR_MAX is undefined * This is useful for releasing code that might be used on multiple platforms, * for example the PHP or Ruby C extensions. */ #elif defined(UPB_TRY_ENABLE_FASTTABLE) -#define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED +#if UPB_FASTTABLE_SUPPORTED +#define UPB_FASTTABLE 1 +#else +#define UPB_FASTTABLE 0 +#endif #else #define UPB_FASTTABLE 0 #endif @@ -567,6 +571,12 @@ Error, UINTPTR_MAX is undefined #define UPB_RETAIN #endif +#if defined(__GNUC__) || defined(__clang__) +#define UPB_HIDDEN __attribute__((visibility("hidden"))) +#else +#define UPB_HIDDEN +#endif + // Linker arrays combine elements from multiple translation units into a single // array that can be iterated over at runtime. // @@ -620,7 +630,7 @@ Error, UINTPTR_MAX is undefined #elif defined(__MACH__) -/* As described in: https://stackoverflow.com/a/22366882 */ + /* As described in: https://stackoverflow.com/a/22366882 */ #define UPB_LINKARR_APPEND(name) \ __attribute__(( \ section("__DATA,__la_" #name))) UPB_LINKARR_ATTR UPB_NO_SANITIZE_ADDRESS @@ -639,10 +649,10 @@ Error, UINTPTR_MAX is undefined #elif defined(_MSC_VER) -/* See: - * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 - * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 - * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ + /* See: + * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 + * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165 + * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */ #define UPB_STRINGIFY_INTERNAL(x) #x #define UPB_STRINGIFY(x) UPB_STRINGIFY_INTERNAL(x) #define UPB_CONCAT(a, b, c) a##b##c @@ -651,7 +661,7 @@ Error, UINTPTR_MAX is undefined #define UPB_LINKARR_APPEND(name) \ __pragma(section(UPB_LINKARR_NAME(name, $j), read)) \ __declspec(allocate(UPB_LINKARR_NAME(name, $j))) -// clang-format off + // clang-format off #define UPB_LINKARR_DECLARE(name, type) \ __pragma(message(UPB_LINKARR_NAME(name, $j))) \ __pragma(section(UPB_LINKARR_NAME(name, $a), read)) \ @@ -662,13 +672,13 @@ Error, UINTPTR_MAX is undefined type __stop_linkarr_##name; \ UPB_LINKARR_APPEND(name) \ __declspec(selectany) type UPB_linkarr_internal_empty_##name[1] = {0} -// clang-format on + // clang-format on #define UPB_LINKARR_START(name) (&__start_linkarr_##name) #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name) #else -// Linker arrays are not supported on this platform. Make macros no-ops. + // Linker arrays are not supported on this platform. Make macros no-ops. #define UPB_LINKARR_APPEND(name) #define UPB_LINKARR_DECLARE(name, type) \ UPB_STATIC_ASSERT(sizeof("__la_" #name) <= 17, \ @@ -5038,6 +5048,9 @@ upb_Message_GetOrCreateMutableMessage(struct upb_Message* msg, const upb_MiniTable* sub_mini_table = upb_MiniTable_SubMessage(f); UPB_ASSERT(sub_mini_table); sub_message = _upb_Message_New(sub_mini_table, arena); + if (!sub_message) { + return NULL; + } *UPB_PTR_AT(msg, f->UPB_ONLYBITS(offset), struct upb_Message*) = sub_message; UPB_PRIVATE(_upb_Message_SetPresence)(msg, f); @@ -5045,6 +5058,44 @@ upb_Message_GetOrCreateMutableMessage(struct upb_Message* msg, return sub_message; } +UPB_INLINE bool UPB_PRIVATE(_upb_Message_FieldIsSet)( + const struct upb_Message* msg, const upb_MiniTableField* f) { + if (f->presence == 0) { + // Proto3 presence or map/array. + const void* mem = UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), void); + switch (UPB_PRIVATE(_upb_MiniTableField_GetRep)(f)) { + case kUpb_FieldRep_1Byte: { + char ch; + memcpy(&ch, mem, 1); + return ch != 0; + } + case kUpb_FieldRep_4Byte: { + uint32_t u32; + memcpy(&u32, mem, 4); + return u32 != 0; + } + case kUpb_FieldRep_8Byte: { + uint64_t u64; + memcpy(&u64, mem, 8); + return u64 != 0; + } + case kUpb_FieldRep_StringView: { + const upb_StringView* str = (const upb_StringView*)mem; + return str->size != 0; + } + default: + UPB_UNREACHABLE(); + } + } else if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(f)) { + // Proto2 presence: hasbit. + return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, f); + } else { + // Field is in a oneof. + return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) == + upb_MiniTableField_Number(f); + } +} + UPB_API_INLINE upb_StringView upb_Message_GetString(const struct upb_Message* msg, const upb_MiniTableField* f, upb_StringView default_val) { @@ -5770,6 +5821,29 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_NextExtensionReverse)( const struct upb_Message* msg, const upb_MiniTableExtension** out_e, upb_MessageValue* out_v, uintptr_t* iter); +#define kUpb_Message_SerializableFieldBegin 0 + +// Iterates over all fields in the message that are set/present. +// +// NOTE: Unset/NULL repeated fields and maps are not considered set and will be +// ignored. However, allocated repeated fields and maps (non-NULL pointer) with +// zero elements are considered set/present and will be returned by this +// iterator. Callers that need to skip empty collections should check their +// sizes explicitly. +// +// To start iterating, set `iter = kUpb_Message_SerializableFieldBegin`. +// Returns true if a serializable field was found, sets `*f` to that field, +// and updates `*iter`. Returns false when iteration is complete. +// +// const upb_MiniTableField* f; +// uintptr_t iter = kUpb_Message_SerializableFieldBegin; +// while (upb_Message_NextSerializableField(msg, mt, &f, &iter)) { +// // ... +// } +UPB_NODISCARD UPB_API bool upb_Message_NextSerializableField( + const upb_Message* msg, const upb_MiniTable* mt, + const upb_MiniTableField** f, uintptr_t* iter); + // Mark a message and all of its descendents as frozen/immutable. UPB_API void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m); @@ -17601,7 +17675,7 @@ typedef enum { kUpb_UnknownCompareResult_MaxDepthExceeded = 3, } upb_UnknownCompareResult; -upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( +upb_UnknownCompareResult _upb_Message_UnknownFieldsAreEqual( const upb_Message* msg1, const upb_Message* msg2, int max_depth); #ifdef __cplusplus @@ -19548,3 +19622,5 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) { #undef _UPB_STRINGIFY #undef _UPB_STRINGIFY2 #undef UPB_CONSTRUCTOR +#undef UPB_RETAIN +#undef UPB_HIDDEN diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 12271b0112..2d590aa678 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -43,9 +43,18 @@ class Any::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Any, _impl_._has_bits_); + + static constexpr Any::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Any::ParseTableT_ Any::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Any::ParseTableT_ Any::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Any, _impl_._has_bits_), @@ -60,9 +69,6 @@ constexpr Any::ParseTableT_ Any::InternalGenerateParseTable_(const ::_pbi::Class class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Any>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // bytes value = 2; {::_pbi::TcParser::FastBS1, @@ -111,39 +117,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Any::Any( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Any::PlacementNew_( +inline void* PROTOBUF_NONNULL Any::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Any(arena); } -constexpr auto Any::InternalNewImpl_() { +constexpr auto Any::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Any), alignof(Any)); } -constexpr auto Any::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Any::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Any::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Any::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Any::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Any::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Any, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Any, _impl_._cached_size_), &file_reflection_data[0], }; } struct AnyGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr AnyGlobalsTypeInternal() - : MessageGlobalsBase(Any::InternalGenerateClassData_( - _default, &Any_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -229,11 +228,11 @@ namespace protobuf { } Any::Any(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Any_globals_.GetClassData()) { + : Super_(arena, &Any_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Any) } PROTOBUF_NDEBUG_INLINE Any::Impl_::Impl_( @@ -248,7 +247,7 @@ Any::Any( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Any& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Any_globals_.GetClassData()) { + : Super_(arena, &Any_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -267,14 +266,16 @@ PROTOBUF_NDEBUG_INLINE Any::Impl_::Impl_( : type_url_(arena), value_(arena) {} -inline void Any::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void Any::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Any& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } Any::~Any() { // @@protoc_insertion_point(destructor:google.protobuf.Any) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Any::SharedDtor(MessageLite& self) { +inline void Any::Helpers_::SharedDtor(MessageLite& self) { Any& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -291,7 +292,7 @@ Any::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Any_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Any_globals_)); - return Any_globals_.GetClassData(); + return &Any_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Any::Helpers_::Clear(MessageLite& base) { @@ -444,18 +445,23 @@ void Any::CopyFrom(const Any& from) { } -void Any::InternalSwap(Any* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Any::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Any* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - auto* arena = GetArena(); + Any& this_ = static_cast(self); + auto* arena = this_.GetArena(); ABSL_DCHECK_EQ(arena, other->GetArena()); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.type_url_, &other->_impl_.type_url_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.value_, &other->_impl_.value_, arena); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.type_url_, &other->_impl_.type_url_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.value_, &other->_impl_.value_, + arena); } ::google::protobuf::Metadata Any::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Any_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 1a176f583e..2b35144f18 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Any* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Any)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public inline Any& operator=(Any&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -188,7 +188,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public inline void Swap(Any* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -196,7 +196,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public void UnsafeArenaSwap(Any* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -247,11 +247,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Any* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Any"; } @@ -263,15 +258,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -314,23 +302,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Any final : public // @@protoc_insertion_point(class_scope:google.protobuf.Any) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Any* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<1, 2, 0, 36, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index be0ae8fef4..a1089694d5 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -43,9 +43,18 @@ class Mixin::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Mixin, _impl_._has_bits_); + + static constexpr Mixin::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Mixin::ParseTableT_ Mixin::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Mixin::ParseTableT_ Mixin::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Mixin, _impl_._has_bits_), @@ -60,9 +69,6 @@ constexpr Mixin::ParseTableT_ Mixin::InternalGenerateParseTable_(const ::_pbi::C class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Mixin>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // string root = 2; {::_pbi::TcParser::FastUS1, @@ -112,39 +118,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Mixin::Mixin( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Mixin::PlacementNew_( +inline void* PROTOBUF_NONNULL Mixin::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Mixin(arena); } -constexpr auto Mixin::InternalNewImpl_() { +constexpr auto Mixin::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Mixin), alignof(Mixin)); } -constexpr auto Mixin::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Mixin::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Mixin::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Mixin::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Mixin::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Mixin::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Mixin, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Mixin, _impl_._cached_size_), &file_reflection_data[2], }; } struct MixinGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr MixinGlobalsTypeInternal() - : MessageGlobalsBase(Mixin::InternalGenerateClassData_( - _default, &Mixin_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -166,9 +165,18 @@ class Method::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Method, _impl_._has_bits_); + + static constexpr Method::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Method::ParseTableT_ Method::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Method::ParseTableT_ Method::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Method, _impl_._has_bits_), @@ -183,9 +191,6 @@ constexpr Method::ParseTableT_ Method::InternalGenerateParseTable_(const ::_pbi: class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Method>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // string edition = 8 [deprecated = true]; {::_pbi::TcParser::FastUS1, @@ -289,39 +294,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Method::Method( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Method::PlacementNew_( +inline void* PROTOBUF_NONNULL Method::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Method(arena); } -constexpr auto Method::InternalNewImpl_() { +constexpr auto Method::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Method), alignof(Method)); } -constexpr auto Method::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Method::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Method::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Method::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Method::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Method::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Method, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Method, _impl_._cached_size_), &file_reflection_data[1], }; } struct MethodGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr MethodGlobalsTypeInternal() - : MessageGlobalsBase(Method::InternalGenerateClassData_( - _default, &Method_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -343,9 +341,18 @@ class Api::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Api, _impl_._has_bits_); + + static constexpr Api::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Api::ParseTableT_ Api::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Api::ParseTableT_ Api::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Api, _impl_._has_bits_), @@ -360,9 +367,6 @@ constexpr Api::ParseTableT_ Api::InternalGenerateParseTable_(const ::_pbi::Class class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Api>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // string edition = 8; {::_pbi::TcParser::FastUS1, @@ -474,39 +478,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Api::Api( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Api::PlacementNew_( +inline void* PROTOBUF_NONNULL Api::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Api(arena); } -constexpr auto Api::InternalNewImpl_() { +constexpr auto Api::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Api), alignof(Api)); } -constexpr auto Api::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Api::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Api::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Api::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Api::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Api::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Api, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Api, _impl_._cached_size_), &file_reflection_data[0], }; } struct ApiGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr ApiGlobalsTypeInternal() - : MessageGlobalsBase(Api::InternalGenerateClassData_( - _default, &Api_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -652,11 +649,11 @@ void Api::clear_source_context() { } Api::Api(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Api_globals_.GetClassData()) { + : Super_(arena, &Api_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Api) } PROTOBUF_NDEBUG_INLINE Api::Impl_::Impl_( @@ -693,7 +690,7 @@ Api::Api( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Api& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Api_globals_.GetClassData()) { + : Super_(arena, &Api_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -733,9 +730,11 @@ PROTOBUF_NDEBUG_INLINE Api::Impl_::Impl_( version_(arena), edition_(arena) {} -inline void Api::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); - ::memset(reinterpret_cast(&_impl_) + +inline void Api::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Api& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); + ::memset(reinterpret_cast(&this_._impl_) + offsetof(Impl_, source_context_), 0, offsetof(Impl_, syntax_) - @@ -744,9 +743,9 @@ inline void Api::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { } Api::~Api() { // @@protoc_insertion_point(destructor:google.protobuf.Api) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Api::SharedDtor(MessageLite& self) { +inline void Api::Helpers_::SharedDtor(MessageLite& self) { Api& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -765,7 +764,7 @@ Api::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Api_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Api_globals_)); - return Api_globals_.GetClassData(); + return &Api_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Api::Helpers_::Clear(MessageLite& base) { @@ -1077,28 +1076,33 @@ void Api::CopyFrom(const Api& from) { } -void Api::InternalSwap(Api* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Api::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Api* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - auto* arena = GetArena(); + Api& this_ = static_cast(self); + auto* arena = this_.GetArena(); ABSL_DCHECK_EQ(arena, other->GetArena()); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.methods_.InternalSwap(&other->_impl_.methods_); - _impl_.options_.InternalSwap(&other->_impl_.options_); - _impl_.mixins_.InternalSwap(&other->_impl_.mixins_); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.version_, &other->_impl_.version_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.edition_, &other->_impl_.edition_, arena); - ::google::protobuf::internal::memswap< - PROTOBUF_FIELD_OFFSET(Api, _impl_.syntax_) - + sizeof(Api::_impl_.syntax_) - - PROTOBUF_FIELD_OFFSET(Api, _impl_.source_context_)>( - reinterpret_cast(&_impl_.source_context_), - reinterpret_cast(&other->_impl_.source_context_)); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + this_._impl_.methods_.InternalSwap(&other->_impl_.methods_); + this_._impl_.options_.InternalSwap(&other->_impl_.options_); + this_._impl_.mixins_.InternalSwap(&other->_impl_.mixins_); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.name_, &other->_impl_.name_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.version_, &other->_impl_.version_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.edition_, &other->_impl_.edition_, + arena); + ::google::protobuf::internal::memswap( + reinterpret_cast(&this_._impl_.source_context_), + reinterpret_cast(&other->_impl_.source_context_)); } ::google::protobuf::Metadata Api::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Api_globals_.class_data); } // =================================================================== @@ -1109,11 +1113,11 @@ void Method::clear_options() { } Method::Method(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Method_globals_.GetClassData()) { + : Super_(arena, &Method_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Method) } PROTOBUF_NDEBUG_INLINE Method::Impl_::Impl_( @@ -1137,7 +1141,7 @@ Method::Method( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Method& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Method_globals_.GetClassData()) { + : Super_(arena, &Method_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -1170,9 +1174,11 @@ PROTOBUF_NDEBUG_INLINE Method::Impl_::Impl_( response_type_url_(arena), edition_(arena) {} -inline void Method::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); - ::memset(reinterpret_cast(&_impl_) + +inline void Method::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Method& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); + ::memset(reinterpret_cast(&this_._impl_) + offsetof(Impl_, request_streaming_), 0, offsetof(Impl_, syntax_) - @@ -1181,9 +1187,9 @@ inline void Method::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { } Method::~Method() { // @@protoc_insertion_point(destructor:google.protobuf.Method) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Method::SharedDtor(MessageLite& self) { +inline void Method::Helpers_::SharedDtor(MessageLite& self) { Method& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -1202,7 +1208,7 @@ Method::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Method_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Method_globals_)); - return Method_globals_.GetClassData(); + return &Method_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Method::Helpers_::Clear(MessageLite& base) { @@ -1511,37 +1517,43 @@ void Method::CopyFrom(const Method& from) { } -void Method::InternalSwap(Method* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Method::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Method* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - auto* arena = GetArena(); + Method& this_ = static_cast(self); + auto* arena = this_.GetArena(); ABSL_DCHECK_EQ(arena, other->GetArena()); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.options_.InternalSwap(&other->_impl_.options_); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.request_type_url_, &other->_impl_.request_type_url_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.response_type_url_, &other->_impl_.response_type_url_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.edition_, &other->_impl_.edition_, arena); - ::google::protobuf::internal::memswap< - PROTOBUF_FIELD_OFFSET(Method, _impl_.syntax_) - + sizeof(Method::_impl_.syntax_) - - PROTOBUF_FIELD_OFFSET(Method, _impl_.request_streaming_)>( - reinterpret_cast(&_impl_.request_streaming_), - reinterpret_cast(&other->_impl_.request_streaming_)); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + this_._impl_.options_.InternalSwap(&other->_impl_.options_); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.name_, &other->_impl_.name_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.request_type_url_, &other->_impl_.request_type_url_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.response_type_url_, &other->_impl_.response_type_url_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.edition_, &other->_impl_.edition_, + arena); + ::google::protobuf::internal::memswap( + reinterpret_cast(&this_._impl_.request_streaming_), + reinterpret_cast(&other->_impl_.request_streaming_)); } ::google::protobuf::Metadata Method::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Method_globals_.class_data); } // =================================================================== Mixin::Mixin(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Mixin_globals_.GetClassData()) { + : Super_(arena, &Mixin_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin) } PROTOBUF_NDEBUG_INLINE Mixin::Impl_::Impl_( @@ -1556,7 +1568,7 @@ Mixin::Mixin( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Mixin& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Mixin_globals_.GetClassData()) { + : Super_(arena, &Mixin_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -1575,14 +1587,16 @@ PROTOBUF_NDEBUG_INLINE Mixin::Impl_::Impl_( : name_(arena), root_(arena) {} -inline void Mixin::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void Mixin::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Mixin& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } Mixin::~Mixin() { // @@protoc_insertion_point(destructor:google.protobuf.Mixin) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Mixin::SharedDtor(MessageLite& self) { +inline void Mixin::Helpers_::SharedDtor(MessageLite& self) { Mixin& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -1599,7 +1613,7 @@ Mixin::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Mixin_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Mixin_globals_)); - return Mixin_globals_.GetClassData(); + return &Mixin_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Mixin::Helpers_::Clear(MessageLite& base) { @@ -1754,18 +1768,23 @@ void Mixin::CopyFrom(const Mixin& from) { } -void Mixin::InternalSwap(Mixin* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Mixin::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Mixin* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - auto* arena = GetArena(); + Mixin& this_ = static_cast(self); + auto* arena = this_.GetArena(); ABSL_DCHECK_EQ(arena, other->GetArena()); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.name_, &other->_impl_.name_, arena); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.root_, &other->_impl_.root_, arena); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.name_, &other->_impl_.name_, + arena); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.root_, &other->_impl_.root_, + arena); } ::google::protobuf::Metadata Mixin::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Mixin_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 42b33eccd4..6c426c7184 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -79,7 +79,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Mixin* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Mixin)); } #endif @@ -100,7 +100,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi inline Mixin& operator=(Mixin&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi inline void Swap(Mixin* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -145,7 +145,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi void UnsafeArenaSwap(Mixin* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -196,11 +196,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Mixin* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Mixin"; } @@ -212,15 +207,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -263,23 +251,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Mixin final : publi // @@protoc_insertion_point(class_scope:google.protobuf.Mixin) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Mixin* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<1, 2, 0, 38, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; @@ -320,7 +311,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Method* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Method)); } #endif @@ -341,7 +332,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ inline Method& operator=(Method&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -378,7 +369,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ inline void Swap(Method* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -386,7 +377,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ void UnsafeArenaSwap(Method* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -437,11 +428,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Method* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Method"; } @@ -453,15 +439,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -590,23 +569,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Method final : publ // @@protoc_insertion_point(class_scope:google.protobuf.Method) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Method* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<3, 8, 1, 83, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; @@ -653,7 +635,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Api* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Api)); } #endif @@ -674,7 +656,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public inline Api& operator=(Api&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -711,7 +693,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public inline void Swap(Api* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -719,7 +701,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public void UnsafeArenaSwap(Api* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -770,11 +752,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Api* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Api"; } @@ -786,15 +763,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -943,23 +913,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Api final : public // @@protoc_insertion_point(class_scope:google.protobuf.Api) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Api* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<3, 8, 4, 54, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index a34206fce3..e89c3f0d07 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -39,9 +39,18 @@ class Duration::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Duration, _impl_._has_bits_); + + static constexpr Duration::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Duration::ParseTableT_ Duration::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Duration::ParseTableT_ Duration::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Duration, _impl_._has_bits_), @@ -56,9 +65,6 @@ constexpr Duration::ParseTableT_ Duration::InternalGenerateParseTable_(const ::_ class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Duration>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // int32 nanos = 2; {::_pbi::TcParser::SingularVarintNoZag1<::uint32_t, offsetof(Duration, _impl_.nanos_), 1>(), @@ -100,39 +106,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Duration::Duration( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Duration::PlacementNew_( +inline void* PROTOBUF_NONNULL Duration::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Duration(arena); } -constexpr auto Duration::InternalNewImpl_() { +constexpr auto Duration::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(Duration), alignof(Duration)); } -constexpr auto Duration::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Duration::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Duration::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Duration::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Duration::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Duration::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Duration, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Duration, _impl_._cached_size_), &file_reflection_data[0], }; } struct DurationGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr DurationGlobalsTypeInternal() - : MessageGlobalsBase(Duration::InternalGenerateClassData_( - _default, &Duration_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -207,17 +206,17 @@ namespace protobuf { Duration::Duration(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Duration_globals_.GetClassData()) { + : Super_(arena, &Duration_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) } Duration::Duration( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Duration& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Duration_globals_.GetClassData()), + : Super_(arena, &Duration_globals_.class_data), #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena), #endif // PROTOBUF_CUSTOM_VTABLE @@ -230,9 +229,11 @@ PROTOBUF_NDEBUG_INLINE Duration::Impl_::Impl_( [[maybe_unused]] ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) {} -inline void Duration::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); - ::memset(reinterpret_cast(&_impl_) + +inline void Duration::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Duration& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); + ::memset(reinterpret_cast(&this_._impl_) + offsetof(Impl_, seconds_), 0, offsetof(Impl_, nanos_) - @@ -241,9 +242,9 @@ inline void Duration::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { } Duration::~Duration() { // @@protoc_insertion_point(destructor:google.protobuf.Duration) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Duration::SharedDtor(MessageLite& self) { +inline void Duration::Helpers_::SharedDtor(MessageLite& self) { Duration& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -258,7 +259,7 @@ Duration::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Duration_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Duration_globals_)); - return Duration_globals_.GetClassData(); + return &Duration_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Duration::Helpers_::Clear(MessageLite& base) { @@ -402,20 +403,22 @@ void Duration::CopyFrom(const Duration& from) { } -void Duration::InternalSwap(Duration* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Duration::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Duration* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::google::protobuf::internal::memswap< - PROTOBUF_FIELD_OFFSET(Duration, _impl_.nanos_) - + sizeof(Duration::_impl_.nanos_) - - PROTOBUF_FIELD_OFFSET(Duration, _impl_.seconds_)>( - reinterpret_cast(&_impl_.seconds_), - reinterpret_cast(&other->_impl_.seconds_)); + Duration& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::google::protobuf::internal::memswap( + reinterpret_cast(&this_._impl_.seconds_), + reinterpret_cast(&other->_impl_.seconds_)); } ::google::protobuf::Metadata Duration::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Duration_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 96408f59b8..c01ab5dced 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Duration* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Duration)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu inline Duration& operator=(Duration&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu inline void Swap(Duration* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu void UnsafeArenaSwap(Duration* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -188,11 +188,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Duration* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Duration"; } @@ -204,15 +199,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -245,23 +233,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Duration final : pu // @@protoc_insertion_point(class_scope:google.protobuf.Duration) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Duration* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<1, 2, 0, 0, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index feb5b2e087..ef62391915 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -36,9 +36,18 @@ namespace google { namespace protobuf { class Empty::_Internal { public: + + static constexpr Empty::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Empty::ParseTableT_ Empty::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Empty::ParseTableT_ Empty::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Empty, @@ -54,9 +63,6 @@ constexpr Empty::ParseTableT_ Empty::InternalGenerateParseTable_(const ::_pbi::C class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Empty>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ {::_pbi::TcParser::MiniParse, {}}, }}, {{ @@ -77,38 +83,31 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Empty::Empty( #endif // PROTOBUF_CUSTOM_VTABLE ) { } -inline void* PROTOBUF_NONNULL Empty::PlacementNew_( +inline void* PROTOBUF_NONNULL Empty::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Empty(arena); } -constexpr auto Empty::InternalNewImpl_() { +constexpr auto Empty::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(Empty), alignof(Empty)); } -constexpr auto Empty::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Empty::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Empty::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Empty::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Empty::SharedDtor, - &Empty::Clear, &Empty::ByteSizeLong, &Empty::_InternalSerialize, + &Empty::Helpers_::SharedDtor, + &Empty::Clear, &Empty::ByteSizeLong, &Empty::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Empty, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Empty, _impl_._cached_size_), &file_reflection_data[0], }; } struct EmptyGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr EmptyGlobalsTypeInternal() - : MessageGlobalsBase(Empty::InternalGenerateClassData_( - _default, &Empty_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -176,7 +175,7 @@ namespace protobuf { Empty::Empty(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Empty_globals_.GetClassData()) { + : Super_(arena, &Empty_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE @@ -186,7 +185,7 @@ Empty::Empty( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Empty& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Empty_globals_.GetClassData()) { + : Super_(arena, &Empty_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -204,7 +203,7 @@ Empty::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Empty_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Empty_globals_)); - return Empty_globals_.GetClassData(); + return &Empty_globals_.class_data; } @@ -214,7 +213,7 @@ Empty::GetClassData() const { ::google::protobuf::Metadata Empty::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Empty_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index f94da0d36e..9964df18aa 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Empty* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Empty)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi inline Empty& operator=(Empty&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi inline void Swap(Empty* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi void UnsafeArenaSwap(Empty* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -172,15 +172,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -189,23 +182,22 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Empty final : publi // @@protoc_insertion_point(class_scope:google.protobuf.Empty) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) - struct Helpers_ { + struct Helpers_ : public Super_::Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<0, 0, 0, 0, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index d2110e3445..98a9b3fb59 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -39,9 +39,18 @@ class FieldMask::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(FieldMask, _impl_._has_bits_); + + static constexpr FieldMask::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr FieldMask::ParseTableT_ FieldMask::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr FieldMask::ParseTableT_ FieldMask::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(FieldMask, _impl_._has_bits_), @@ -56,9 +65,6 @@ constexpr FieldMask::ParseTableT_ FieldMask::InternalGenerateParseTable_(const : class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::FieldMask>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // repeated string paths = 1; {::_pbi::TcParser::FastUR1, @@ -100,39 +106,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr FieldMask::FieldMask( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL FieldMask::PlacementNew_( +inline void* PROTOBUF_NONNULL FieldMask::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) FieldMask(arena); } -constexpr auto FieldMask::InternalNewImpl_() { +constexpr auto FieldMask::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(FieldMask), alignof(FieldMask)); } -constexpr auto FieldMask::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &FieldMask::MergeImpl, - Super_::GetNewImpl(), +constexpr auto FieldMask::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &FieldMask::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &FieldMask::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &FieldMask::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(FieldMask, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(FieldMask, _impl_._cached_size_), &file_reflection_data[0], }; } struct FieldMaskGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr FieldMaskGlobalsTypeInternal() - : MessageGlobalsBase(FieldMask::InternalGenerateClassData_( - _default, &FieldMask_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -205,11 +204,11 @@ namespace protobuf { FieldMask::FieldMask(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, FieldMask_globals_.GetClassData()) { + : Super_(arena, &FieldMask_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldMask) } PROTOBUF_NDEBUG_INLINE FieldMask::Impl_::Impl_( @@ -229,7 +228,7 @@ FieldMask::FieldMask( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const FieldMask& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, FieldMask_globals_.GetClassData()) { + : Super_(arena, &FieldMask_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -251,14 +250,16 @@ PROTOBUF_NDEBUG_INLINE FieldMask::Impl_::Impl_( } {} -inline void FieldMask::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void FieldMask::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + FieldMask& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } FieldMask::~FieldMask() { // @@protoc_insertion_point(destructor:google.protobuf.FieldMask) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void FieldMask::SharedDtor(MessageLite& self) { +inline void FieldMask::Helpers_::SharedDtor(MessageLite& self) { FieldMask& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -273,7 +274,7 @@ FieldMask::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&FieldMask_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&FieldMask_globals_)); - return FieldMask_globals_.GetClassData(); + return &FieldMask_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void FieldMask::Helpers_::Clear(MessageLite& base) { @@ -394,15 +395,18 @@ void FieldMask::CopyFrom(const FieldMask& from) { } -void FieldMask::InternalSwap(FieldMask* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void FieldMask::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + FieldMask* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.paths_.InternalSwap(&other->_impl_.paths_); + FieldMask& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + this_._impl_.paths_.InternalSwap(&other->_impl_.paths_); } ::google::protobuf::Metadata FieldMask::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(FieldMask_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 295522b4a5..17e4b83556 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( FieldMask* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(FieldMask)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p inline FieldMask& operator=(FieldMask&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p inline void Swap(FieldMask* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p void UnsafeArenaSwap(FieldMask* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -188,11 +188,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(FieldMask* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.FieldMask"; } @@ -204,15 +199,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -250,23 +238,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED FieldMask final : p // @@protoc_insertion_point(class_scope:google.protobuf.FieldMask) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, FieldMask* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<0, 1, 0, 39, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 07f251f6e9..2379d5649f 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -39,9 +39,18 @@ class SourceContext::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(SourceContext, _impl_._has_bits_); + + static constexpr SourceContext::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr SourceContext::ParseTableT_ SourceContext::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr SourceContext::ParseTableT_ SourceContext::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(SourceContext, _impl_._has_bits_), @@ -56,9 +65,6 @@ constexpr SourceContext::ParseTableT_ SourceContext::InternalGenerateParseTable_ class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::SourceContext>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // string file_name = 1; {::_pbi::TcParser::FastUS1, @@ -98,39 +104,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr SourceContext::SourceContext( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL SourceContext::PlacementNew_( +inline void* PROTOBUF_NONNULL SourceContext::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) SourceContext(arena); } -constexpr auto SourceContext::InternalNewImpl_() { +constexpr auto SourceContext::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(SourceContext), alignof(SourceContext)); } -constexpr auto SourceContext::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &SourceContext::MergeImpl, - Super_::GetNewImpl(), +constexpr auto SourceContext::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &SourceContext::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &SourceContext::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &SourceContext::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(SourceContext, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(SourceContext, _impl_._cached_size_), &file_reflection_data[0], }; } struct SourceContextGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr SourceContextGlobalsTypeInternal() - : MessageGlobalsBase(SourceContext::InternalGenerateClassData_( - _default, &SourceContext_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -203,11 +202,11 @@ namespace protobuf { SourceContext::SourceContext(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, SourceContext_globals_.GetClassData()) { + : Super_(arena, &SourceContext_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceContext) } PROTOBUF_NDEBUG_INLINE SourceContext::Impl_::Impl_( @@ -221,7 +220,7 @@ SourceContext::SourceContext( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const SourceContext& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, SourceContext_globals_.GetClassData()) { + : Super_(arena, &SourceContext_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -239,14 +238,16 @@ PROTOBUF_NDEBUG_INLINE SourceContext::Impl_::Impl_( [[maybe_unused]] ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) : file_name_(arena) {} -inline void SourceContext::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void SourceContext::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + SourceContext& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } SourceContext::~SourceContext() { // @@protoc_insertion_point(destructor:google.protobuf.SourceContext) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void SourceContext::SharedDtor(MessageLite& self) { +inline void SourceContext::Helpers_::SharedDtor(MessageLite& self) { SourceContext& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -262,7 +263,7 @@ SourceContext::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&SourceContext_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&SourceContext_globals_)); - return SourceContext_globals_.GetClassData(); + return &SourceContext_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void SourceContext::Helpers_::Clear(MessageLite& base) { @@ -383,17 +384,21 @@ void SourceContext::CopyFrom(const SourceContext& from) { } -void SourceContext::InternalSwap(SourceContext* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void SourceContext::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + SourceContext* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - auto* arena = GetArena(); + SourceContext& this_ = static_cast(self); + auto* arena = this_.GetArena(); ABSL_DCHECK_EQ(arena, other->GetArena()); - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.file_name_, &other->_impl_.file_name_, arena); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::_pbi::ArenaStringPtr::InternalSwap(&this_._impl_.file_name_, &other->_impl_.file_name_, + arena); } ::google::protobuf::Metadata SourceContext::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(SourceContext_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index c47e1cf9c3..51f134c4c2 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( SourceContext* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(SourceContext)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final inline SourceContext& operator=(SourceContext&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final inline void Swap(SourceContext* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final void UnsafeArenaSwap(SourceContext* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -188,11 +188,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(SourceContext* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.SourceContext"; } @@ -204,15 +199,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -239,23 +227,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED SourceContext final // @@protoc_insertion_point(class_scope:google.protobuf.SourceContext) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, SourceContext* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<0, 1, 0, 47, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 3b49ee86d1..8af3e794f7 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -45,9 +45,18 @@ class ListValue::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(ListValue, _impl_._has_bits_); + + static constexpr ListValue::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr ListValue::ParseTableT_ ListValue::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr ListValue::ParseTableT_ ListValue::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(ListValue, _impl_._has_bits_), @@ -62,9 +71,6 @@ constexpr ListValue::ParseTableT_ ListValue::InternalGenerateParseTable_(const : class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::ListValue>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // repeated .google.protobuf.Value values = 1; {::_pbi::TcParser::FastMcR1, @@ -105,39 +111,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr ListValue::ListValue( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL ListValue::PlacementNew_( +inline void* PROTOBUF_NONNULL ListValue::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) ListValue(arena); } -constexpr auto ListValue::InternalNewImpl_() { +constexpr auto ListValue::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(ListValue), alignof(ListValue)); } -constexpr auto ListValue::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &ListValue::MergeImpl, - Super_::GetNewImpl(), +constexpr auto ListValue::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &ListValue::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &ListValue::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &ListValue::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(ListValue, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(ListValue, _impl_._cached_size_), &file_reflection_data[3], }; } struct ListValueGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr ListValueGlobalsTypeInternal() - : MessageGlobalsBase(ListValue::InternalGenerateClassData_( - _default, &ListValue_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -159,9 +158,18 @@ class Struct::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Struct, _impl_._has_bits_); + + static constexpr Struct::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Struct::ParseTableT_ Struct::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Struct::ParseTableT_ Struct::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Struct, _impl_._has_bits_), @@ -176,9 +184,6 @@ constexpr Struct::ParseTableT_ Struct::InternalGenerateParseTable_(const ::_pbi: class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Struct>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // map fields = 1; {::_pbi::TcParser::FastMiniParse1, @@ -226,39 +231,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Struct::Struct( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Struct::PlacementNew_( +inline void* PROTOBUF_NONNULL Struct::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Struct(arena); } -constexpr auto Struct::InternalNewImpl_() { +constexpr auto Struct::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Struct), alignof(Struct)); } -constexpr auto Struct::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Struct::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Struct::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Struct::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Struct::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Struct::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Struct, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Struct, _impl_._cached_size_), &file_reflection_data[1], }; } struct StructGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr StructGlobalsTypeInternal() - : MessageGlobalsBase(Struct::InternalGenerateClassData_( - _default, &Struct_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -275,7 +273,59 @@ static_assert(PROTOBUF_FIELD_OFFSET(StructGlobalsTypeInternal, _default) == PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const StructGlobalsTypeInternal Struct_globals_ PROTOBUF_MESSAGE_GLOBALS_SECTION(.data.rel.ro); -constexpr Struct_FieldsEntry_DoNotUse::ParseTableT_ Struct_FieldsEntry_DoNotUse::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +class PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct_FieldsEntry_DoNotUse final + : public ::google::protobuf::internal::MapEntry<::std::string, ::google::protobuf::Message, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE> { + using Super_ = + ::google::protobuf::internal::MapEntry<::std::string, ::google::protobuf::Message, + ::google::protobuf::internal::WireFormatLite::TYPE_STRING, + ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE>; + + public: + Struct_FieldsEntry_DoNotUse(); + template + explicit constexpr Struct_FieldsEntry_DoNotUse(::google::protobuf::internal::ConstantInitialized, + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL + class_data); + explicit Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + + + private: + friend class ::google::protobuf::MessageLite; + friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; + friend ::google::protobuf::internal::PrivateAccess; + friend Struct_FieldsEntry_DoNotUseGlobalsTypeInternal; + + using ParseTableT_ = + ::google::protobuf::internal::TcParseTable<1, 2, + 1, 46, + 2>; + + class _Internal; + struct Helpers_ : public Super_::Helpers_ { + PROTOBUF_NODEBUG Helpers_(); + }; + + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; +}; +class Struct_FieldsEntry_DoNotUse::_Internal { + public: + using HasBits = decltype(::std::declval()._impl_._has_bits_); + static constexpr ::int32_t kHasBitsOffset = + 8 * PROTOBUF_FIELD_OFFSET(Struct_FieldsEntry_DoNotUse, _impl_._has_bits_); + + static constexpr Struct_FieldsEntry_DoNotUse::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); +}; + +constexpr Struct_FieldsEntry_DoNotUse::ParseTableT_ Struct_FieldsEntry_DoNotUse::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Struct_FieldsEntry_DoNotUse, _impl_._has_bits_), @@ -290,9 +340,6 @@ constexpr Struct_FieldsEntry_DoNotUse::ParseTableT_ Struct_FieldsEntry_DoNotUse: class_data, nullptr, // post_loop_handler ::_pbi::TcParser::DiscardEverythingFallback, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Struct_FieldsEntry_DoNotUse>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // .google.protobuf.Value value = 2; {::_pbi::TcParser::FastMcS1, @@ -331,39 +378,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Struct_FieldsEntry_DoNotUse::Struct_Fie #endif // PROTOBUF_CUSTOM_VTABLE ) { } -inline void* PROTOBUF_NONNULL Struct_FieldsEntry_DoNotUse::PlacementNew_( +inline void* PROTOBUF_NONNULL Struct_FieldsEntry_DoNotUse::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Struct_FieldsEntry_DoNotUse(arena); } -constexpr auto Struct_FieldsEntry_DoNotUse::InternalNewImpl_() { +constexpr auto Struct_FieldsEntry_DoNotUse::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Struct_FieldsEntry_DoNotUse), alignof(Struct_FieldsEntry_DoNotUse)); } -constexpr auto Struct_FieldsEntry_DoNotUse::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Struct_FieldsEntry_DoNotUse::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Struct_FieldsEntry_DoNotUse::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Struct_FieldsEntry_DoNotUse::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Struct_FieldsEntry_DoNotUse::SharedDtor, - &Struct_FieldsEntry_DoNotUse::ClearImpl, Super_::ByteSizeLongImpl, - Super_::_InternalSerializeImpl, + &Struct_FieldsEntry_DoNotUse::Helpers_::SharedDtor, + &Struct_FieldsEntry_DoNotUse::ClearImpl, Super_::ByteSizeLongImpl, + Super_::_InternalSerializeImpl, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Struct_FieldsEntry_DoNotUse, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Struct_FieldsEntry_DoNotUse, _impl_._cached_size_), &file_reflection_data[0], }; } struct Struct_FieldsEntry_DoNotUseGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr Struct_FieldsEntry_DoNotUseGlobalsTypeInternal() - : MessageGlobalsBase(Struct_FieldsEntry_DoNotUse::InternalGenerateClassData_( - _default, &Struct_FieldsEntry_DoNotUse_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -384,9 +424,18 @@ class Value::_Internal { public: static constexpr ::int32_t kOneofCaseOffset = PROTOBUF_FIELD_OFFSET(::google::protobuf::Value, _impl_._oneof_case_); + + static constexpr Value::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Value::ParseTableT_ Value::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Value::ParseTableT_ Value::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Value, @@ -402,9 +451,6 @@ constexpr Value::ParseTableT_ Value::InternalGenerateParseTable_(const ::_pbi::C class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Value>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // bool bool_value = 4; {::_pbi::TcParser::FastMiniParse1, @@ -458,39 +504,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Value::Value( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Value::PlacementNew_( +inline void* PROTOBUF_NONNULL Value::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Value(arena); } -constexpr auto Value::InternalNewImpl_() { +constexpr auto Value::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(Value), alignof(Value)); } -constexpr auto Value::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Value::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Value::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Value::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Value::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Value::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Value, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Value, _impl_._cached_size_), &file_reflection_data[2], }; } struct ValueGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr ValueGlobalsTypeInternal() - : MessageGlobalsBase(Value::InternalGenerateClassData_( - _default, &Value_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -607,10 +646,10 @@ PROTOBUF_CONSTINIT const uint32_t NullValue_internal_data_[] = { #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse() - : Super_(Struct_FieldsEntry_DoNotUse_globals_.GetClassData()) {} + : Super_(&Struct_FieldsEntry_DoNotUse_globals_.class_data) {} PROTOBUF_ALWAYS_INLINE_NODEBUG Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) - : Super_(arena, Struct_FieldsEntry_DoNotUse_globals_.GetClassData()) {} + : Super_(arena, &Struct_FieldsEntry_DoNotUse_globals_.class_data) {} #else // PROTOBUF_CUSTOM_VTABLE Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse() : Super_() {} Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) : Super_(arena) {} @@ -620,17 +659,17 @@ Struct_FieldsEntry_DoNotUse::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Struct_FieldsEntry_DoNotUse_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Struct_FieldsEntry_DoNotUse_globals_)); - return Struct_FieldsEntry_DoNotUse_globals_.GetClassData(); + return &Struct_FieldsEntry_DoNotUse_globals_.class_data; } // =================================================================== Struct::Struct(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Struct_globals_.GetClassData()) { + : Super_(arena, &Struct_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) } PROTOBUF_NDEBUG_INLINE Struct::Impl_::Impl_( @@ -650,7 +689,7 @@ Struct::Struct( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Struct& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Struct_globals_.GetClassData()) { + : Super_(arena, &Struct_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -672,14 +711,16 @@ PROTOBUF_NDEBUG_INLINE Struct::Impl_::Impl_( } {} -inline void Struct::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void Struct::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Struct& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } Struct::~Struct() { // @@protoc_insertion_point(destructor:google.protobuf.Struct) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Struct::SharedDtor(MessageLite& self) { +inline void Struct::Helpers_::SharedDtor(MessageLite& self) { Struct& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -694,7 +735,7 @@ Struct::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Struct_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Struct_globals_)); - return Struct_globals_.GetClassData(); + return &Struct_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Struct::Helpers_::Clear(MessageLite& base) { @@ -832,15 +873,18 @@ void Struct::CopyFrom(const Struct& from) { } -void Struct::InternalSwap(Struct* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Struct::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Struct* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.fields_.InternalSwap(&other->_impl_.fields_); + Struct& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + this_._impl_.fields_.InternalSwap(&other->_impl_.fields_); } ::google::protobuf::Metadata Struct::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Struct_globals_.class_data); } // =================================================================== @@ -872,11 +916,11 @@ void Value::set_allocated_list_value(::google::protobuf::ListValue* PROTOBUF_NUL } Value::Value(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Value_globals_.GetClassData()) { + : Super_(arena, &Value_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) } PROTOBUF_NDEBUG_INLINE Value::Impl_::Impl_( @@ -890,7 +934,7 @@ Value::Value( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Value& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Value_globals_.GetClassData()) { + : Super_(arena, &Value_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -931,14 +975,16 @@ PROTOBUF_NDEBUG_INLINE Value::Impl_::Impl_( : kind_{}, _oneof_case_{} {} -inline void Value::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void Value::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Value& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } Value::~Value() { // @@protoc_insertion_point(destructor:google.protobuf.Value) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Value::SharedDtor(MessageLite& self) { +inline void Value::Helpers_::SharedDtor(MessageLite& self) { Value& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -1000,7 +1046,7 @@ Value::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Value_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Value_globals_)); - return Value_globals_.GetClassData(); + return &Value_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Value::Helpers_::Clear(MessageLite& base) { @@ -1217,25 +1263,28 @@ void Value::CopyFrom(const Value& from) { } -void Value::InternalSwap(Value* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Value::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Value* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_.kind_, other->_impl_.kind_); - swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); + Value& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_.kind_, other->_impl_.kind_); + swap(this_._impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); } ::google::protobuf::Metadata Value::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Value_globals_.class_data); } // =================================================================== ListValue::ListValue(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, ListValue_globals_.GetClassData()) { + : Super_(arena, &ListValue_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) } PROTOBUF_NDEBUG_INLINE ListValue::Impl_::Impl_( @@ -1255,7 +1304,7 @@ ListValue::ListValue( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const ListValue& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, ListValue_globals_.GetClassData()) { + : Super_(arena, &ListValue_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { @@ -1277,14 +1326,16 @@ PROTOBUF_NDEBUG_INLINE ListValue::Impl_::Impl_( } {} -inline void ListValue::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); +inline void ListValue::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + ListValue& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); } ListValue::~ListValue() { // @@protoc_insertion_point(destructor:google.protobuf.ListValue) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void ListValue::SharedDtor(MessageLite& self) { +inline void ListValue::Helpers_::SharedDtor(MessageLite& self) { ListValue& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -1299,7 +1350,7 @@ ListValue::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&ListValue_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&ListValue_globals_)); - return ListValue_globals_.GetClassData(); + return &ListValue_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void ListValue::Helpers_::Clear(MessageLite& base) { @@ -1420,15 +1471,18 @@ void ListValue::CopyFrom(const ListValue& from) { } -void ListValue::InternalSwap(ListValue* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void ListValue::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + ListValue* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - _impl_.values_.InternalSwap(&other->_impl_.values_); + ListValue& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + this_._impl_.values_.InternalSwap(&other->_impl_.values_); } ::google::protobuf::Metadata ListValue::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(ListValue_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 70b41c2efb..0cad5a1f63 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -131,7 +131,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( ListValue* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(ListValue)); } #endif @@ -152,7 +152,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p inline ListValue& operator=(ListValue&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -189,7 +189,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p inline void Swap(ListValue* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -197,7 +197,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p void UnsafeArenaSwap(ListValue* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -248,11 +248,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(ListValue* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.ListValue"; } @@ -264,15 +259,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -304,23 +292,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED ListValue final : p // @@protoc_insertion_point(class_scope:google.protobuf.ListValue) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, ListValue* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<0, 1, 1, 0, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; @@ -360,7 +351,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Struct* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Struct)); } #endif @@ -381,7 +372,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ inline Struct& operator=(Struct&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -418,7 +409,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ inline void Swap(Struct* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -426,7 +417,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ void UnsafeArenaSwap(Struct* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -477,11 +468,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Struct* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Struct"; } @@ -493,15 +479,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -528,23 +507,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ // @@protoc_insertion_point(class_scope:google.protobuf.Struct) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Struct* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<0, 1, 2, 37, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; @@ -565,7 +547,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ const Struct& from_msg); ::google::protobuf::internal::HasBits<1> _has_bits_; ::google::protobuf::internal::CachedSize _cached_size_; - ::google::protobuf::internal::MapField fields_; + ::google::protobuf::internal::MapField<&Struct_FieldsEntry_DoNotUse_globals_, ::std::string, ::google::protobuf::Value> fields_; PROTOBUF_TSAN_DECLARE_MEMBER }; union { Impl_ _impl_; }; @@ -573,51 +555,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct final : publ }; // ------------------------------------------------------------------- -class PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Struct_FieldsEntry_DoNotUse final - : public ::google::protobuf::internal::MapEntry<::std::string, ::google::protobuf::Message, - ::google::protobuf::internal::WireFormatLite::TYPE_STRING, - ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE> { - using Super_ = - ::google::protobuf::internal::MapEntry<::std::string, ::google::protobuf::Message, - ::google::protobuf::internal::WireFormatLite::TYPE_STRING, - ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE>; - - public: - Struct_FieldsEntry_DoNotUse(); - template - explicit constexpr Struct_FieldsEntry_DoNotUse(::google::protobuf::internal::ConstantInitialized, - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL - class_data); - explicit Struct_FieldsEntry_DoNotUse(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr const void* PROTOBUF_NONNULL internal_message_globals() { - return &Struct_FieldsEntry_DoNotUse_globals_; - } - - - static constexpr auto InternalGenerateClassData_( - const ::google::protobuf::MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); - - private: - friend class ::google::protobuf::MessageLite; - friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; - friend ::google::protobuf::internal::PrivateAccess; - friend Struct_FieldsEntry_DoNotUseGlobalsTypeInternal; - - using ParseTableT_ = - ::google::protobuf::internal::TcParseTable<1, 2, - 1, 46, - 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; - - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); -}; // ------------------------------------------------------------------- class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : public ::google::protobuf::Message @@ -631,7 +568,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Value* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Value)); } #endif @@ -652,7 +589,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi inline Value& operator=(Value&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -698,7 +635,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi inline void Swap(Value* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -706,7 +643,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi void UnsafeArenaSwap(Value* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -757,11 +694,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Value* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Value"; } @@ -773,15 +705,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -887,16 +812,22 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi // @@protoc_insertion_point(class_scope:google.protobuf.Value) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Value* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; void set_has_null_value(); void set_has_number_value(); void set_has_string_value(); @@ -909,9 +840,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Value final : publi ::google::protobuf::internal::TcParseTable<0, 6, 2, 42, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 19a5858b62..e33e099b23 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -39,9 +39,18 @@ class Timestamp::_Internal { using HasBits = decltype(::std::declval()._impl_._has_bits_); static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(Timestamp, _impl_._has_bits_); + + static constexpr Timestamp::ParseTableT_ GenerateParseTable( + const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); + static constexpr auto GenerateClassData(); + + static void* PROTOBUF_NONNULL PlacementNew(const void* PROTOBUF_NONNULL, + void* PROTOBUF_NONNULL mem, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static constexpr auto NewImpl(); }; -constexpr Timestamp::ParseTableT_ Timestamp::InternalGenerateParseTable_(const ::_pbi::ClassData* class_data) { +constexpr Timestamp::ParseTableT_ Timestamp::_Internal::GenerateParseTable(const ::_pbi::ClassData* class_data) { return ParseTableT_{ { PROTOBUF_FIELD_OFFSET(Timestamp, _impl_._has_bits_), @@ -56,9 +65,6 @@ constexpr Timestamp::ParseTableT_ Timestamp::InternalGenerateParseTable_(const : class_data, nullptr, // post_loop_handler ::_pbi::TcParser::MpUnknownFields, // fallback - #ifdef PROTOBUF_PREFETCH_PARSE_TABLE - ::_pbi::TcParser::GetTable<::google::protobuf::Timestamp>(), // to_prefetch - #endif // PROTOBUF_PREFETCH_PARSE_TABLE }, {{ // int32 nanos = 2; {::_pbi::TcParser::SingularVarintNoZag1<::uint32_t, offsetof(Timestamp, _impl_.nanos_), 1>(), @@ -100,39 +106,32 @@ PROTOBUF_ALWAYS_INLINE_NODEBUG constexpr Timestamp::Timestamp( ), _impl_(internal_visibility(), ::_pbi::ConstantInitialized()) { } -inline void* PROTOBUF_NONNULL Timestamp::PlacementNew_( +inline void* PROTOBUF_NONNULL Timestamp::_Internal::PlacementNew( const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) { return ::new (mem) Timestamp(arena); } -constexpr auto Timestamp::InternalNewImpl_() { +constexpr auto Timestamp::_Internal::NewImpl() { return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(Timestamp), alignof(Timestamp)); } -constexpr auto Timestamp::InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* tc_table) { - return ::google::protobuf::internal::ClassDataFull{ - ::google::protobuf::internal::ClassData{ - &prototype, - tc_table, - nullptr, // IsInitialized - &Timestamp::MergeImpl, - Super_::GetNewImpl(), +constexpr auto Timestamp::_Internal::GenerateClassData() { + return ::google::protobuf::internal::ClassData{ + nullptr, // IsInitialized + &Timestamp::MergeImpl, + Super_::GetNewImpl(), #if defined(PROTOBUF_CUSTOM_VTABLE) - &Timestamp::SharedDtor, - &Helpers_::Clear, &Helpers_::ByteSizeLong, - &Helpers_::_InternalSerialize, + &Timestamp::Helpers_::SharedDtor, + &Helpers_::Clear, &Helpers_::ByteSizeLong, + &Helpers_::_InternalSerialize, #endif // PROTOBUF_CUSTOM_VTABLE - PROTOBUF_FIELD_OFFSET(Timestamp, _impl_._cached_size_), - false, - }, + PROTOBUF_FIELD_OFFSET(Timestamp, _impl_._cached_size_), &file_reflection_data[0], }; } struct TimestampGlobalsTypeInternal : ::_pbi::MessageGlobalsBase { constexpr TimestampGlobalsTypeInternal() - : MessageGlobalsBase(Timestamp::InternalGenerateClassData_( - _default, &Timestamp_globals_._table.header)), + : MessageGlobalsBase( + ::_pbi::PrivateAccess::GenerateClassData()), _default(::_pbi::ConstantInitialized{}, GetClassData()), _table(::_pbi::PrivateAccess::GenerateParseTable( GetClassData())) {} @@ -207,17 +206,17 @@ namespace protobuf { Timestamp::Timestamp(::google::protobuf::Arena* PROTOBUF_NULLABLE arena) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Timestamp_globals_.GetClassData()) { + : Super_(arena, &Timestamp_globals_.class_data) { #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena) { #endif // PROTOBUF_CUSTOM_VTABLE - SharedCtor(arena); + Helpers_::SharedCtor(*this, arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } Timestamp::Timestamp( ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Timestamp& from) #if defined(PROTOBUF_CUSTOM_VTABLE) - : Super_(arena, Timestamp_globals_.GetClassData()), + : Super_(arena, &Timestamp_globals_.class_data), #else // PROTOBUF_CUSTOM_VTABLE : Super_(arena), #endif // PROTOBUF_CUSTOM_VTABLE @@ -230,9 +229,11 @@ PROTOBUF_NDEBUG_INLINE Timestamp::Impl_::Impl_( [[maybe_unused]] ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) {} -inline void Timestamp::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { - new (&_impl_) Impl_(internal_visibility(), arena); - ::memset(reinterpret_cast(&_impl_) + +inline void Timestamp::Helpers_::SharedCtor( + ::_pb::MessageLite& self, ::_pb::Arena* PROTOBUF_NULLABLE arena) { + Timestamp& this_ = static_cast(self); + new (&this_._impl_) Impl_(this_.internal_visibility(), arena); + ::memset(reinterpret_cast(&this_._impl_) + offsetof(Impl_, seconds_), 0, offsetof(Impl_, nanos_) - @@ -241,9 +242,9 @@ inline void Timestamp::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) { } Timestamp::~Timestamp() { // @@protoc_insertion_point(destructor:google.protobuf.Timestamp) - SharedDtor(*this); + Helpers_::SharedDtor(*this); } -inline void Timestamp::SharedDtor(MessageLite& self) { +inline void Timestamp::Helpers_::SharedDtor(MessageLite& self) { Timestamp& this_ = static_cast(self); if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) { this_.CheckHasBitConsistency(); @@ -258,7 +259,7 @@ Timestamp::GetClassData() const { ::google::protobuf::internal::PrefetchToLocalCache(&Timestamp_globals_); ::google::protobuf::internal::PrefetchToLocalCache( ::google::protobuf::internal::MessageGlobalsBase::ToParseTableBase(&Timestamp_globals_)); - return Timestamp_globals_.GetClassData(); + return &Timestamp_globals_.class_data; } #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_NOINLINE void Timestamp::Helpers_::Clear(MessageLite& base) { @@ -402,20 +403,22 @@ void Timestamp::CopyFrom(const Timestamp& from) { } -void Timestamp::InternalSwap(Timestamp* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { +void Timestamp::Helpers_::InternalSwap( + ::_pb::MessageLite& PROTOBUF_RESTRICT self, + Timestamp* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) { using ::std::swap; - _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); - ::google::protobuf::internal::memswap< - PROTOBUF_FIELD_OFFSET(Timestamp, _impl_.nanos_) - + sizeof(Timestamp::_impl_.nanos_) - - PROTOBUF_FIELD_OFFSET(Timestamp, _impl_.seconds_)>( - reinterpret_cast(&_impl_.seconds_), - reinterpret_cast(&other->_impl_.seconds_)); + Timestamp& this_ = static_cast(self); + this_._internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(this_._impl_._has_bits_[0], other->_impl_._has_bits_[0]); + ::google::protobuf::internal::memswap( + reinterpret_cast(&this_._impl_.seconds_), + reinterpret_cast(&other->_impl_.seconds_)); } ::google::protobuf::Metadata Timestamp::GetMetadata() const { - return Super_::GetMetadataImpl(GetClassData()->full()); + return Super_::GetMetadataImpl(Timestamp_globals_.class_data); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index a9c1ed7fbe..89998f82b8 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -71,7 +71,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p #if defined(PROTOBUF_CUSTOM_VTABLE) PROTOBUF_ALWAYS_INLINE_NODEBUG void operator delete( Timestamp* PROTOBUF_NONNULL msg, ::std::destroying_delete_t) { - SharedDtor(*msg); + Helpers_::SharedDtor(*msg); ::google::protobuf::internal::SizedDelete(msg, sizeof(Timestamp)); } #endif @@ -92,7 +92,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p inline Timestamp& operator=(Timestamp&& from) noexcept { if (this == &from) return *this; if (::google::protobuf::internal::CanMoveWithInternalSwap(GetArena(), from.GetArena())) { - InternalSwap(&from); + Helpers_::InternalSwap(*this, &from); } else { CopyFrom(from); } @@ -129,7 +129,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p inline void Swap(Timestamp* PROTOBUF_NONNULL other) { if (other == this) return; if (::google::protobuf::internal::CanUseInternalSwap(GetArena(), other->GetArena())) { - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } else { ::google::protobuf::internal::GenericSwap(this, other); } @@ -137,7 +137,7 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p void UnsafeArenaSwap(Timestamp* PROTOBUF_NONNULL other) { if (other == this) return; ABSL_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); + Helpers_::InternalSwap(*this, other); } // implements Message ---------------------------------------------- @@ -188,11 +188,6 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p return _impl_._cached_size_.Get(); } - private: - void SharedCtor(::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static void SharedDtor(MessageLite& self); - void InternalSwap(Timestamp* PROTOBUF_NONNULL other); - private: static ::absl::string_view FullMessageName() { return "google.protobuf.Timestamp"; } @@ -204,15 +199,8 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p *this = ::std::move(from); } const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL GetClassData() const PROTOBUF_FINAL; - static void* PROTOBUF_NONNULL PlacementNew_( - const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem, - ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); - static constexpr auto InternalNewImpl_(); public: - static constexpr auto InternalGenerateClassData_( - const MessageLite& prototype, - const ::google::protobuf::internal::TcParseTableBase* PROTOBUF_NULLABLE tc_table = nullptr); [[nodiscard]] ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -245,23 +233,26 @@ class PROTOBUF_EXPORT PROTOBUF_FUTURE_ADD_EARLY_WARN_UNUSED Timestamp final : p // @@protoc_insertion_point(class_scope:google.protobuf.Timestamp) private: class _Internal; -#if defined(PROTOBUF_CUSTOM_VTABLE) struct Helpers_ { PROTOBUF_NODEBUG Helpers_(); + + static void SharedCtor(MessageLite& self, + ::google::protobuf::Arena* PROTOBUF_NULLABLE arena); + static void SharedDtor(MessageLite& self); + static void InternalSwap(MessageLite& self, Timestamp* PROTOBUF_NONNULL other); + +#if defined(PROTOBUF_CUSTOM_VTABLE) static void Clear(::google::protobuf::MessageLite& msg); [[nodiscard]] static::size_t ByteSizeLong(const ::google::protobuf::MessageLite& msg); [[nodiscard]] static ::uint8_t* PROTOBUF_NONNULL _InternalSerialize( const ::google::protobuf::MessageLite& msg, ::uint8_t* PROTOBUF_NONNULL target, ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream); - }; #endif // PROTOBUF_CUSTOM_VTABLE + }; using ParseTableT_ = ::google::protobuf::internal::TcParseTable<1, 2, 0, 0, 2>; - static constexpr ParseTableT_ InternalGenerateParseTable_( - const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL class_data); - friend class ::google::protobuf::internal::TcParser; friend class ::google::protobuf::MessageLite; friend class ::google::protobuf::Arena; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 4587090e4d..6e713689bb 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -47,9 +47,18 @@ class Option::_Internal { using HasBits = decltype(::std::declval