diff --git a/upb/message/accessors.c b/upb/message/accessors.c index ec507b3a26..43848040a7 100644 --- a/upb/message/accessors.c +++ b/upb/message/accessors.c @@ -195,7 +195,7 @@ upb_UnknownToMessageRet upb_MiniTable_PromoteUnknownToMessage( // Callers should check that message is not set first before calling // PromotoUnknownToMessage. UPB_ASSERT(mini_table->subs[field->submsg_index].submsg == sub_mini_table); - UPB_ASSERT(upb_MiniTable_GetMessage(msg, field, NULL) == NULL); + UPB_ASSERT(upb_Message_GetMessage(msg, field, NULL) == NULL); upb_UnknownToMessageRet ret; ret.status = kUpb_UnknownToMessage_Ok; do { @@ -223,7 +223,7 @@ upb_UnknownToMessageRet upb_MiniTable_PromoteUnknownToMessage( } } while (unknown.status == kUpb_FindUnknown_Ok); if (message) { - upb_MiniTable_SetMessage(msg, mini_table, field, message); + upb_Message_SetMessage(msg, mini_table, field, message); ret.message = message; } return ret; diff --git a/upb/message/accessors.h b/upb/message/accessors.h index 9a26fd9f63..059c2696cd 100644 --- a/upb/message/accessors.h +++ b/upb/message/accessors.h @@ -405,7 +405,7 @@ UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg, return _upb_Message_SetField(msg, field, &value, a); } -UPB_API_INLINE void upb_MiniTable_SetEnumProto2( +UPB_API_INLINE void upb_Message_SetEnumProto2( upb_Message* msg, const upb_MiniTable* msg_mini_table, const upb_MiniTableField* field, int32_t value) { UPB_ASSERT(field->descriptortype == kUpb_FieldType_Enum); @@ -524,7 +524,7 @@ UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg, return _upb_Message_SetField(msg, field, &value, a); } -UPB_API_INLINE const upb_Message* upb_MiniTable_GetMessage( +UPB_API_INLINE const upb_Message* upb_Message_GetMessage( const upb_Message* msg, const upb_MiniTableField* field, upb_Message* default_val) { UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message || @@ -537,10 +537,10 @@ UPB_API_INLINE const upb_Message* upb_MiniTable_GetMessage( return ret; } -UPB_API_INLINE void upb_MiniTable_SetMessage(upb_Message* msg, - const upb_MiniTable* mini_table, - const upb_MiniTableField* field, - upb_Message* sub_message) { +UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg, + const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* sub_message) { UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message || field->descriptortype == kUpb_FieldType_Group); UPB_ASSUME(!upb_IsRepeatedOrMap(field)); @@ -550,7 +550,7 @@ UPB_API_INLINE void upb_MiniTable_SetMessage(upb_Message* msg, _upb_Message_SetNonExtensionField(msg, field, &sub_message); } -UPB_API_INLINE upb_Message* upb_MiniTable_GetMutableMessage( +UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage( upb_Message* msg, const upb_MiniTable* mini_table, const upb_MiniTableField* field, upb_Arena* arena) { UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message || @@ -719,7 +719,7 @@ typedef struct { // Promotes unknown data inside message to a upb_Message parsing the unknown. // // The unknown data is removed from message after field value is set -// using upb_MiniTable_SetMessage. +// using upb_Message_SetMessage. upb_UnknownToMessageRet upb_MiniTable_PromoteUnknownToMessage( upb_Message* msg, const upb_MiniTable* mini_table, const upb_MiniTableField* field, const upb_MiniTable* sub_mini_table, diff --git a/upb/message/accessors_test.cc b/upb/message/accessors_test.cc index edb9cd8a3a..4ef13af219 100644 --- a/upb/message/accessors_test.cc +++ b/upb/message/accessors_test.cc @@ -261,7 +261,7 @@ TEST(GeneratedCode, SubMessage) { find_proto2_field(kFieldOptionalNestedMessage); const upb_Message* test_message = - upb_MiniTable_GetMessage(msg, optional_message_field, NULL); + upb_Message_GetMessage(msg, optional_message_field, NULL); EXPECT_EQ(NULL, test_message); EXPECT_EQ(false, upb_Message_HasField(msg, optional_message_field)); @@ -277,7 +277,7 @@ TEST(GeneratedCode, SubMessage) { // Read back using mini table API. const upb_Message* sub_message = - upb_MiniTable_GetMessage(msg, optional_message_field, NULL); + upb_Message_GetMessage(msg, optional_message_field, NULL); EXPECT_EQ(true, sub_message != NULL); const upb_MiniTableField* nested_message_a_field = @@ -296,11 +296,11 @@ TEST(GeneratedCode, SubMessage) { upb_Message* new_nested_message = protobuf_test_messages_proto2_TestAllTypesProto2_NestedMessage_new(arena); upb_Message_SetInt32(new_nested_message, nested_message_a_field, 123, NULL); - upb_MiniTable_SetMessage( + upb_Message_SetMessage( msg, &protobuf_test_messages_proto2_TestAllTypesProto2_msg_init, optional_message_field, new_nested_message); - upb_Message* mutable_message = upb_MiniTable_GetMutableMessage( + upb_Message* mutable_message = upb_Message_GetOrCreateMutableMessage( msg, &protobuf_test_messages_proto2_TestAllTypesProto2_msg_init, optional_message_field, arena); EXPECT_EQ( @@ -373,10 +373,10 @@ TEST(GeneratedCode, GetMutableMessage) { // Message. const upb_MiniTableField* optional_message_field = find_proto2_field(kFieldOptionalNestedMessage); - upb_Message* msg1 = upb_MiniTable_GetMutableMessage( + upb_Message* msg1 = upb_Message_GetOrCreateMutableMessage( msg, &protobuf_test_messages_proto2_TestAllTypesProto2_msg_init, optional_message_field, arena); - upb_Message* msg2 = upb_MiniTable_GetMutableMessage( + upb_Message* msg2 = upb_Message_GetOrCreateMutableMessage( msg, &protobuf_test_messages_proto2_TestAllTypesProto2_msg_init, optional_message_field, arena); // Verify that newly constructed sub message is stored in msg. @@ -653,7 +653,7 @@ TEST(GeneratedCode, PromoteUnknownMessage) { &upb_test_ModelWithExtensions_msg_init, decode_options, arena); EXPECT_EQ(promote_result.status, kUpb_UnknownToMessage_Ok); const upb_Message* promoted_message = - upb_MiniTable_GetMessage(msg, &mini_table->fields[1], NULL); + upb_Message_GetMessage(msg, &mini_table->fields[1], NULL); EXPECT_EQ(upb_test_ModelWithExtensions_random_int32( (upb_test_ModelWithExtensions*)promoted_message), 12);