diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 4157999576..2874f54eee 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -5025,6 +5025,35 @@ void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) { } +#include + + +// Must be last. + +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* f, + upb_Message* map_entry_message, upb_Arena* arena) { + // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. + const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( + mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(map_entry_mini_table); + UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2); + const upb_MiniTableField* map_entry_key_field = + &map_entry_mini_table->UPB_PRIVATE(fields)[0]; + const upb_MiniTableField* map_entry_value_field = + &map_entry_mini_table->UPB_PRIVATE(fields)[1]; + // Map key/value cannot have explicit defaults, + // hence assuming a zero default is valid. + upb_MessageValue default_val; + memset(&default_val, 0, sizeof(upb_MessageValue)); + upb_MessageValue map_entry_key = + upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); + upb_MessageValue map_entry_value = upb_Message_GetField( + map_entry_message, map_entry_value_field, default_val); + return upb_Map_Set(map, map_entry_key, map_entry_value, arena); +} + + #include #include @@ -5491,35 +5520,6 @@ size_t upb_Message_ExtensionCount(const upb_Message* msg) { #include -// Must be last. - -bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, - const upb_MiniTableField* f, - upb_Message* map_entry_message, upb_Arena* arena) { - // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. - const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( - mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); - UPB_ASSERT(map_entry_mini_table); - UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2); - const upb_MiniTableField* map_entry_key_field = - &map_entry_mini_table->UPB_PRIVATE(fields)[0]; - const upb_MiniTableField* map_entry_value_field = - &map_entry_mini_table->UPB_PRIVATE(fields)[1]; - // Map key/value cannot have explicit defaults, - // hence assuming a zero default is valid. - upb_MessageValue default_val; - memset(&default_val, 0, sizeof(upb_MessageValue)); - upb_MessageValue map_entry_key = - upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); - upb_MessageValue map_entry_value = upb_Message_GetField( - map_entry_message, map_entry_value_field, default_val); - return upb_Map_Set(map, map_entry_key, map_entry_value, arena); -} - - -#include - - // Must be last. bool upb_Message_IsExactlyEqual(const upb_Message* msg1, diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index f124dc39fb..0648cbf9c4 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -4541,6 +4541,35 @@ void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) { } +#include + + +// Must be last. + +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* f, + upb_Message* map_entry_message, upb_Arena* arena) { + // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. + const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( + mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); + UPB_ASSERT(map_entry_mini_table); + UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2); + const upb_MiniTableField* map_entry_key_field = + &map_entry_mini_table->UPB_PRIVATE(fields)[0]; + const upb_MiniTableField* map_entry_value_field = + &map_entry_mini_table->UPB_PRIVATE(fields)[1]; + // Map key/value cannot have explicit defaults, + // hence assuming a zero default is valid. + upb_MessageValue default_val; + memset(&default_val, 0, sizeof(upb_MessageValue)); + upb_MessageValue map_entry_key = + upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); + upb_MessageValue map_entry_value = upb_Message_GetField( + map_entry_message, map_entry_value_field, default_val); + return upb_Map_Set(map, map_entry_key, map_entry_value, arena); +} + + #include #include @@ -5007,35 +5036,6 @@ size_t upb_Message_ExtensionCount(const upb_Message* msg) { #include -// Must be last. - -bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, - const upb_MiniTableField* f, - upb_Message* map_entry_message, upb_Arena* arena) { - // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. - const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( - mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); - UPB_ASSERT(map_entry_mini_table); - UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2); - const upb_MiniTableField* map_entry_key_field = - &map_entry_mini_table->UPB_PRIVATE(fields)[0]; - const upb_MiniTableField* map_entry_value_field = - &map_entry_mini_table->UPB_PRIVATE(fields)[1]; - // Map key/value cannot have explicit defaults, - // hence assuming a zero default is valid. - upb_MessageValue default_val; - memset(&default_val, 0, sizeof(upb_MessageValue)); - upb_MessageValue map_entry_key = - upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); - upb_MessageValue map_entry_value = upb_Message_GetField( - map_entry_message, map_entry_value_field, default_val); - return upb_Map_Set(map, map_entry_key, map_entry_value, arena); -} - - -#include - - // Must be last. bool upb_Message_IsExactlyEqual(const upb_Message* msg1, diff --git a/upb/cmake/CMakeLists.txt b/upb/cmake/CMakeLists.txt index 308bc33600..0dc98ec32d 100644 --- a/upb/cmake/CMakeLists.txt +++ b/upb/cmake/CMakeLists.txt @@ -91,7 +91,6 @@ target_link_libraries(generated_code_support__only_for_generated_code_do_not_use base mem message - message_accessors mini_descriptor mini_table wire