Skip to content

Commit

Permalink
update some more functions to match the accessor naming convention
Browse files Browse the repository at this point in the history
upb_MiniTable_SetEnumProto2() -> upb_Message_SetEnumProto2()
upb_MiniTable_GetMessage() -> upb_Message_GetMessage()
upb_MiniTable_SetMessage() -> upb_Message_SetMessage()
upb_MiniTable_GetMutableMessage() -> upb_Message_GetOrCreateMutableMessage()

PiperOrigin-RevId: 500781434
  • Loading branch information
ericsalo authored and copybara-github committed Jan 9, 2023
1 parent b5384af commit 87f9b86
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions upb/message/accessors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions upb/message/accessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ||
Expand All @@ -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));
Expand All @@ -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 ||
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions upb/message/accessors_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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 =
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 87f9b86

Please sign in to comment.