Auto-generate files after cl/602785269
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index d2ed041..bbbd7fc 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c
@@ -5292,7 +5292,7 @@ return NULL; } } else { - upb_Array* msg_array = (upb_Array*)msg_ext->data.ptr; + upb_Array* msg_array = (upb_Array*)msg_ext->data.array_val; UPB_ASSERT(msg_array); upb_Array* cloned_array = upb_Array_DeepClone( msg_array, upb_MiniTableField_CType(field), @@ -5300,7 +5300,7 @@ if (!cloned_array) { return NULL; } - dst_ext->data.ptr = (void*)cloned_array; + dst_ext->data.array_val = cloned_array; } } @@ -8550,7 +8550,7 @@ static void encode_msgset_item(upb_encstate* e, const upb_Extension* ext) { size_t size; encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup); - encode_message(e, ext->data.ptr, + encode_message(e, ext->data.msg_val, upb_MiniTableExtension_GetSubMessage(ext->ext), &size); encode_varint(e, size); encode_tag(e, kUpb_MsgSet_Message, kUpb_WireType_Delimited);
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index fcc8cb3..b9436e6 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h
@@ -1843,85 +1843,8 @@ #ifndef UPB_MESSAGE_INTERNAL_EXTENSION_H_ #define UPB_MESSAGE_INTERNAL_EXTENSION_H_ +#include <stddef.h> -/* -** Our memory representation for parsing tables and messages themselves. -** Functions in this file are used by generated code and possibly reflection. -** -** The definitions in this file are internal to upb. -**/ - -#ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_ -#define UPB_MESSAGE_INTERNAL_MESSAGE_H_ - -#include <stdlib.h> -#include <string.h> - - -// Must be last. - -#ifdef __cplusplus -extern "C" { -#endif - -extern const float kUpb_FltInfinity; -extern const double kUpb_Infinity; -extern const double kUpb_NaN; - -// Internal members of a upb_Message that track unknown fields and/or -// extensions. We can change this without breaking binary compatibility. - -typedef struct upb_Message_Internal { - // Total size of this structure, including the data that follows. - // Must be aligned to 8, which is alignof(upb_Extension) - uint32_t size; - - /* Offsets relative to the beginning of this structure. - * - * Unknown data grows forward from the beginning to unknown_end. - * Extension data grows backward from size to ext_begin. - * When the two meet, we're out of data and have to realloc. - * - * If we imagine that the final member of this struct is: - * char data[size - overhead]; // overhead = sizeof(upb_Message_Internal) - * - * Then we have: - * unknown data: data[0 .. (unknown_end - overhead)] - * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */ - uint32_t unknown_end; - uint32_t ext_begin; - // Data follows, as if there were an array: - // char data[size - sizeof(upb_Message_Internal)]; -} upb_Message_Internal; - -// Inline version upb_Message_New(), for internal use. -UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m, - upb_Arena* a) { - const int size = m->UPB_PRIVATE(size); - struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size); - if (UPB_UNLIKELY(!msg)) return NULL; - memset(msg, 0, size); - return msg; -} - -// Discards the unknown fields for this message only. -void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg); - -// Adds unknown data (serialized protobuf data) to the given message. -// The data is copied into the message instance. -bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg, - const char* data, size_t len, - upb_Arena* arena); - -bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, - upb_Arena* arena); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - - -#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */ #ifndef UPB_MINI_TABLE_EXTENSION_H_ #define UPB_MINI_TABLE_EXTENSION_H_ @@ -2024,11 +1947,7 @@ // the most common extension type. typedef struct { const upb_MiniTableExtension* ext; - union { - upb_StringView str; - void* ptr; - char scalar_data[8]; - } data; + upb_MessageValue data; } upb_Extension; #ifdef __cplusplus @@ -2519,6 +2438,85 @@ #endif /* UPB_MESSAGE_INTERNAL_MAP_H_ */ +/* +** Our memory representation for parsing tables and messages themselves. +** Functions in this file are used by generated code and possibly reflection. +** +** The definitions in this file are internal to upb. +**/ + +#ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_ +#define UPB_MESSAGE_INTERNAL_MESSAGE_H_ + +#include <stdlib.h> +#include <string.h> + + +// Must be last. + +#ifdef __cplusplus +extern "C" { +#endif + +extern const float kUpb_FltInfinity; +extern const double kUpb_Infinity; +extern const double kUpb_NaN; + +// Internal members of a upb_Message that track unknown fields and/or +// extensions. We can change this without breaking binary compatibility. + +typedef struct upb_Message_Internal { + // Total size of this structure, including the data that follows. + // Must be aligned to 8, which is alignof(upb_Extension) + uint32_t size; + + /* Offsets relative to the beginning of this structure. + * + * Unknown data grows forward from the beginning to unknown_end. + * Extension data grows backward from size to ext_begin. + * When the two meet, we're out of data and have to realloc. + * + * If we imagine that the final member of this struct is: + * char data[size - overhead]; // overhead = sizeof(upb_Message_Internal) + * + * Then we have: + * unknown data: data[0 .. (unknown_end - overhead)] + * extensions data: data[(ext_begin - overhead) .. (size - overhead)] */ + uint32_t unknown_end; + uint32_t ext_begin; + // Data follows, as if there were an array: + // char data[size - sizeof(upb_Message_Internal)]; +} upb_Message_Internal; + +// Inline version upb_Message_New(), for internal use. +UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m, + upb_Arena* a) { + const int size = m->UPB_PRIVATE(size); + struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size); + if (UPB_UNLIKELY(!msg)) return NULL; + memset(msg, 0, size); + return msg; +} + +// Discards the unknown fields for this message only. +void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg); + +// Adds unknown data (serialized protobuf data) to the given message. +// The data is copied into the message instance. +bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg, + const char* data, size_t len, + upb_Arena* arena); + +bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, + upb_Arena* arena); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */ + #ifndef UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ #define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_