diff --git a/protos/BUILD b/protos/BUILD index f903249a04..0167b19d5e 100644 --- a/protos/BUILD +++ b/protos/BUILD @@ -35,7 +35,6 @@ cc_library( "//upb:mem", "//upb:message", "//upb:message_copy", - "//upb:message_types", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/strings", ], @@ -59,10 +58,10 @@ cc_library( "//upb:message_accessors", "//upb:message_copy", "//upb:message_promote", - "//upb:message_types", "//upb:mini_table", "//upb:wire", "//upb:wire_reader", + "//upb/message:internal", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/protos/protos.cc b/protos/protos.cc index 57570e4039..6522405c12 100644 --- a/protos/protos.cc +++ b/protos/protos.cc @@ -18,8 +18,8 @@ #include "upb/mem/arena.h" #include "upb/message/copy.h" #include "upb/message/internal/extension.h" +#include "upb/message/message.h" #include "upb/message/promote.h" -#include "upb/message/types.h" #include "upb/mini_table/extension.h" #include "upb/mini_table/extension_registry.h" #include "upb/mini_table/message.h" diff --git a/protos/repeated_field.h b/protos/repeated_field.h index 6d37b569fa..f8f3f5acaf 100644 --- a/protos/repeated_field.h +++ b/protos/repeated_field.h @@ -22,7 +22,7 @@ #include "upb/mem/arena.h" #include "upb/message/array.h" #include "upb/message/copy.h" -#include "upb/message/types.h" +#include "upb/message/message.h" namespace protos { namespace internal { diff --git a/protos/repeated_field_iterator.h b/protos/repeated_field_iterator.h index 79c284c8db..27af26b899 100644 --- a/protos/repeated_field_iterator.h +++ b/protos/repeated_field_iterator.h @@ -18,7 +18,7 @@ #include "upb/base/string_view.h" #include "upb/mem/arena.h" #include "upb/message/array.h" -#include "upb/message/types.h" +#include "upb/message/message.h" namespace protos { namespace internal { diff --git a/upb/BUILD b/upb/BUILD index 13047648e5..eff6314ec9 100644 --- a/upb/BUILD +++ b/upb/BUILD @@ -115,6 +115,7 @@ cc_library( ":mini_descriptor", ":mini_table", ":wire", + "//upb/message:internal", ], ) @@ -228,24 +229,6 @@ alias( visibility = ["//visibility:public"], ) -alias( - name = "message_tagged_ptr", - actual = "//upb/message:tagged_ptr", - visibility = ["//upb:friends"], -) - -alias( - name = "message_types", - actual = "//upb/message:types", - visibility = ["//visibility:public"], -) - -alias( - name = "message_value", - actual = "//upb/message:value", - visibility = ["//visibility:public"], -) - alias( name = "mini_descriptor", actual = "//upb/mini_descriptor", @@ -357,9 +340,6 @@ upb_amalgamation( ":message_accessors", ":message_compare", ":message_copy", - ":message_tagged_ptr", - ":message_types", - ":message_value", ":mini_descriptor", ":mini_table", ":mini_table_compat", @@ -370,6 +350,7 @@ upb_amalgamation( ":wire_reader", "//upb/base:internal", "//upb/mem:internal", + "//upb/message:internal", "//upb/mini_descriptor:internal", "//upb/mini_table:internal", ], @@ -405,9 +386,6 @@ upb_amalgamation( ":message_accessors", ":message_compare", ":message_copy", - ":message_tagged_ptr", - ":message_types", - ":message_value", ":mini_descriptor", ":mini_table", ":mini_table_compat", @@ -418,6 +396,7 @@ upb_amalgamation( ":wire_reader", "//upb/base:internal", "//upb/mem:internal", + "//upb/message:internal", "//upb/mini_descriptor:internal", "//upb/mini_table:internal", ], @@ -454,9 +433,6 @@ upb_amalgamation( ":message_accessors", ":message_compare", ":message_copy", - ":message_tagged_ptr", - ":message_types", - ":message_value", ":mini_descriptor", ":mini_table", ":mini_table_compat", @@ -467,6 +443,7 @@ upb_amalgamation( ":wire_reader", "//upb/base:internal", "//upb/mem:internal", + "//upb/message:internal", "//upb/mini_descriptor:internal", "//upb/mini_table:internal", ], diff --git a/upb/json/BUILD b/upb/json/BUILD index 6331725465..d10498fada 100644 --- a/upb/json/BUILD +++ b/upb/json/BUILD @@ -24,7 +24,6 @@ cc_library( "//upb:lex", "//upb:mem", "//upb:message", - "//upb:message_types", "//upb:mini_table", "//upb:port", "//upb:reflection", @@ -103,7 +102,6 @@ upb_c_proto_library( # "//upb:base", # "//upb:mem", # "//upb:message", -# "//upb:message_types", # "//upb:mini_table", # "//upb:reflection", # ], diff --git a/upb/json/decode.c b/upb/json/decode.c index 531e937456..66f0929619 100644 --- a/upb/json/decode.c +++ b/upb/json/decode.c @@ -28,7 +28,6 @@ #include "upb/message/array.h" #include "upb/message/map.h" #include "upb/message/message.h" -#include "upb/message/types.h" #include "upb/mini_table/message.h" #include "upb/reflection/def.h" #include "upb/reflection/message.h" diff --git a/upb/message/BUILD b/upb/message/BUILD index 969b2ecaca..1b10994878 100644 --- a/upb/message/BUILD +++ b/upb/message/BUILD @@ -17,102 +17,118 @@ load( ) cc_library( - name = "accessors", + name = "message", srcs = [ - "accessors.c", + "array.c", + "compat.c", + "map.c", + "map_sorter.c", + "message.c", + ], + hdrs = [ + "array.h", + "compat.h", + "map.h", + "map_gencode_util.h", + "message.h", + "tagged_ptr.h", + "value.h", + ], + copts = UPB_DEFAULT_COPTS, + visibility = ["//visibility:public"], + deps = [ + ":internal", + "//upb:base", + "//upb:mem", + "//upb:mini_table", + "//upb:port", + "//upb/base:internal", + "//upb/mini_table:internal", + ], +) + +cc_library( + name = "internal", + srcs = [ + "internal/extension.c", + "internal/message.c", ], hdrs = [ - "accessors.h", "internal/accessors.h", + "internal/array.h", + "internal/extension.h", + "internal/map.h", + "internal/map_entry.h", + "internal/map_sorter.h", + "internal/message.h", + "internal/tagged_ptr.h", ], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ - ":message", - ":tagged_ptr", - ":types", "//upb:base", + "//upb:hash", "//upb:mem", "//upb:mini_table", "//upb:port", + "//upb/base:internal", ], ) cc_library( - name = "compare", + name = "accessors", srcs = [ - "compare.c", + "accessors.c", ], hdrs = [ - "compare.h", + "accessors.h", ], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ + ":internal", ":message", - ":types", + "//upb:base", "//upb:mem", "//upb:mini_table", "//upb:port", - "//upb:wire", ], ) cc_library( - name = "copy", + name = "compare", srcs = [ - "copy.c", + "compare.c", ], hdrs = [ - "copy.h", + "compare.h", ], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ - ":accessors", ":message", - ":tagged_ptr", - ":types", - "//upb:base", "//upb:mem", "//upb:mini_table", "//upb:port", - "//upb/mini_table:internal", + "//upb:wire", ], ) cc_library( - name = "message", + name = "copy", srcs = [ - "array.c", - "compat.c", - "internal/extension.c", - "internal/message.c", - "map.c", - "map_sorter.c", - "message.c", + "copy.c", ], hdrs = [ - "array.h", - "compat.h", - "internal/array.h", - "internal/extension.h", - "internal/map.h", - "internal/map_entry.h", - "internal/map_sorter.h", - "internal/message.h", - "internal/types.h", - "map.h", - "map_gencode_util.h", - "message.h", + "copy.h", ], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ - ":types", - ":value", + ":accessors", + ":internal", + ":message", "//upb:base", - "//upb:hash", "//upb:mem", "//upb:mini_table", "//upb:port", @@ -133,9 +149,8 @@ cc_library( visibility = ["//visibility:public"], deps = [ ":accessors", + ":internal", ":message", - ":tagged_ptr", - ":types", "//upb:base", "//upb:eps_copy_input_stream", "//upb:mem", @@ -161,41 +176,6 @@ cc_library( ], ) -cc_library( - name = "tagged_ptr", - hdrs = ["tagged_ptr.h"], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":types", - "//upb:port", - ], -) - -cc_library( - name = "types", - hdrs = [ - "types.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [], -) - -cc_library( - name = "value", - hdrs = [ - "value.h", - ], - copts = UPB_DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ - ":tagged_ptr", - ":types", - "//upb:base", - ], -) - proto_library( name = "message_test_proto", testonly = 1, @@ -264,6 +244,7 @@ cc_test( deps = [ ":accessors", ":copy", + ":internal", ":message", "//:protobuf", "//upb:base", @@ -298,9 +279,9 @@ cc_test( deps = [ ":accessors", ":copy", + ":internal", ":message", ":promote", - ":tagged_ptr", "//:protobuf", "//upb:base", "//upb:mem", @@ -324,14 +305,14 @@ cc_test( name = "test", srcs = ["test.cc"], deps = [ + ":internal", + ":message", ":message_test_upb_minitable_proto", ":message_test_upb_proto", ":message_test_upb_proto_reflection", - ":value", "//upb:base", "//upb:json", "//upb:mem", - "//upb:message", "//upb:mini_table", "//upb:reflection", "//upb:wire", diff --git a/upb/message/accessors.h b/upb/message/accessors.h index ac5788ebf8..e55781cb6c 100644 --- a/upb/message/accessors.h +++ b/upb/message/accessors.h @@ -20,10 +20,10 @@ #include "upb/message/internal/array.h" #include "upb/message/internal/map.h" #include "upb/message/internal/message.h" -#include "upb/message/internal/types.h" +#include "upb/message/internal/tagged_ptr.h" #include "upb/message/map.h" #include "upb/message/tagged_ptr.h" -#include "upb/message/types.h" +#include "upb/message/value.h" #include "upb/mini_table/enum.h" #include "upb/mini_table/sub.h" @@ -352,7 +352,8 @@ UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg, const upb_MiniTableField* field, upb_Message* sub_message) { _upb_Message_SetTaggedMessagePtr( - msg, mini_table, field, _upb_TaggedMessagePtr_Pack(sub_message, false)); + msg, mini_table, field, + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false)); } UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage( diff --git a/upb/message/array.h b/upb/message/array.h index 62500f0a1d..b217bfbcb8 100644 --- a/upb/message/array.h +++ b/upb/message/array.h @@ -12,7 +12,7 @@ #include "upb/base/descriptor_constants.h" #include "upb/mem/arena.h" -#include "upb/message/value.h" // IWYU pragma: export +#include "upb/message/value.h" // Must be last. #include "upb/port/def.inc" diff --git a/upb/message/compare.h b/upb/message/compare.h index 98d165c5de..db7e20a0ba 100644 --- a/upb/message/compare.h +++ b/upb/message/compare.h @@ -8,7 +8,7 @@ #ifndef UPB_MESSAGE_COMPARE_H_ #define UPB_MESSAGE_COMPARE_H_ -#include "upb/message/types.h" +#include "upb/message/message.h" #include "upb/mini_table/message.h" // Must be last. diff --git a/upb/message/copy.c b/upb/message/copy.c index 9ee6be71c3..9342293e31 100644 --- a/upb/message/copy.c +++ b/upb/message/copy.c @@ -24,6 +24,7 @@ #include "upb/message/tagged_ptr.h" #include "upb/mini_table/extension.h" #include "upb/mini_table/field.h" +#include "upb/mini_table/internal/field.h" #include "upb/mini_table/internal/size_log2.h" #include "upb/mini_table/message.h" #include "upb/mini_table/sub.h" @@ -74,9 +75,9 @@ static bool upb_Clone_MessageValue(void* value, upb_CType value_type, if (is_empty) sub = UPB_PRIVATE(_upb_MiniTable_Empty)(); UPB_ASSERT(source); upb_Message* clone = upb_Message_DeepClone( - _upb_TaggedMessagePtr_GetMessage(source), sub, arena); + UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(source), sub, arena); *(upb_TaggedMessagePtr*)value = - _upb_TaggedMessagePtr_Pack(clone, is_empty); + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(clone, is_empty); return clone != NULL; } break; } @@ -199,7 +200,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, upb_TaggedMessagePtr tagged = upb_Message_GetTaggedMessagePtr(src, field, NULL); const upb_Message* sub_message = - _upb_TaggedMessagePtr_GetMessage(tagged); + UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged); if (sub_message != NULL) { // If the message is currently in an unlinked, "empty" state we keep // it that way, because we don't want to deal with decode options, @@ -215,7 +216,8 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src, } _upb_Message_SetTaggedMessagePtr( dst, mini_table, field, - _upb_TaggedMessagePtr_Pack(dst_sub_message, is_empty)); + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(dst_sub_message, + is_empty)); } } break; case kUpb_CType_String: diff --git a/upb/message/copy.h b/upb/message/copy.h index 17f82d85c7..33fe537f4f 100644 --- a/upb/message/copy.h +++ b/upb/message/copy.h @@ -11,6 +11,7 @@ #include "upb/mem/arena.h" #include "upb/message/array.h" #include "upb/message/map.h" +#include "upb/message/message.h" #include "upb/mini_table/message.h" // Must be last. diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h index 191df0552d..2c585cd3bb 100644 --- a/upb/message/internal/accessors.h +++ b/upb/message/internal/accessors.h @@ -17,8 +17,7 @@ #include "upb/message/internal/extension.h" #include "upb/message/internal/map.h" #include "upb/message/internal/message.h" -#include "upb/message/internal/types.h" -#include "upb/message/tagged_ptr.h" +#include "upb/message/internal/tagged_ptr.h" #include "upb/mini_table/extension.h" #include "upb/mini_table/field.h" @@ -52,7 +51,7 @@ extern "C" { // Hasbit access /////////////////////////////////////////////////////////////// UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)( - const upb_Message* msg, const upb_MiniTableField* f) { + const struct upb_Message* msg, const upb_MiniTableField* f) { const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); @@ -60,7 +59,7 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_GetHasbit)( } UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)( - const upb_Message* msg, const upb_MiniTableField* f) { + const struct upb_Message* msg, const upb_MiniTableField* f) { const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); @@ -68,7 +67,7 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_SetHasbit)( } UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)( - const upb_Message* msg, const upb_MiniTableField* f) { + const struct upb_Message* msg, const upb_MiniTableField* f) { const size_t offset = UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)(f); const char mask = UPB_PRIVATE(_upb_MiniTableField_HasbitMask)(f); @@ -78,18 +77,18 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)( // Oneof case access /////////////////////////////////////////////////////////// UPB_INLINE uint32_t* UPB_PRIVATE(_upb_Message_OneofCasePtr)( - upb_Message* msg, const upb_MiniTableField* f) { + struct upb_Message* msg, const upb_MiniTableField* f) { return UPB_PTR_AT(msg, UPB_PRIVATE(_upb_MiniTableField_OneofOffset)(f), uint32_t); } UPB_INLINE uint32_t UPB_PRIVATE(_upb_Message_GetOneofCase)( - const upb_Message* msg, const upb_MiniTableField* f) { - return *UPB_PRIVATE(_upb_Message_OneofCasePtr)((upb_Message*)msg, f); + const struct upb_Message* msg, const upb_MiniTableField* f) { + return *UPB_PRIVATE(_upb_Message_OneofCasePtr)((struct upb_Message*)msg, f); } UPB_INLINE void UPB_PRIVATE(_upb_Message_SetOneofCase)( - upb_Message* msg, const upb_MiniTableField* f) { + struct upb_Message* msg, const upb_MiniTableField* f) { *UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f) = upb_MiniTableField_Number(f); } @@ -98,18 +97,18 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_SetOneofCase)( // LINT.ThenChange(GoogleInternalName2) -UPB_INLINE void* _upb_MiniTableField_GetPtr(upb_Message* msg, +UPB_INLINE void* _upb_MiniTableField_GetPtr(struct upb_Message* msg, const upb_MiniTableField* field) { return (char*)msg + field->UPB_ONLYBITS(offset); } UPB_INLINE const void* _upb_MiniTableField_GetConstPtr( - const upb_Message* msg, const upb_MiniTableField* field) { + const struct upb_Message* msg, const upb_MiniTableField* field) { return (char*)msg + field->UPB_ONLYBITS(offset); } UPB_INLINE void UPB_PRIVATE(_upb_Message_SetPresence)( - upb_Message* msg, const upb_MiniTableField* field) { + struct upb_Message* msg, const upb_MiniTableField* field) { if (field->presence > 0) { UPB_PRIVATE(_upb_Message_SetHasbit)(msg, field); } else if (upb_MiniTableField_IsInOneof(field)) { @@ -195,13 +194,13 @@ UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_DataCopy)( // returned bool value may be ignored since it will always succeed. UPB_INLINE bool _upb_Message_HasExtensionField( - const upb_Message* msg, const upb_MiniTableExtension* ext) { + const struct upb_Message* msg, const upb_MiniTableExtension* ext) { UPB_ASSERT(upb_MiniTableField_HasPresence(&ext->UPB_PRIVATE(field))); return _upb_Message_Getext(msg, ext) != NULL; } UPB_INLINE bool _upb_Message_HasNonExtensionField( - const upb_Message* msg, const upb_MiniTableField* field) { + const struct upb_Message* msg, const upb_MiniTableField* field) { UPB_ASSERT(upb_MiniTableField_HasPresence(field)); UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); if (upb_MiniTableField_IsInOneof(field)) { @@ -213,7 +212,7 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField( } static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField( - const upb_Message* msg, const upb_MiniTableField* field, + const struct upb_Message* msg, const upb_MiniTableField* field, const void* default_val, void* val) { UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); if ((upb_MiniTableField_IsInOneof(field) || @@ -227,7 +226,7 @@ static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField( } UPB_INLINE void _upb_Message_GetExtensionField( - const upb_Message* msg, const upb_MiniTableExtension* mt_ext, + const struct upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* default_val, void* val) { const struct upb_Extension* ext = _upb_Message_Getext(msg, mt_ext); const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field); @@ -240,35 +239,8 @@ UPB_INLINE void _upb_Message_GetExtensionField( } } -// Gets a mutable Array, Map or Message field. -// NOTE: For repeated/map fields, the resulting upb_Array*/upb_Map* can -// be NULL if a upb_Array/upb_Map has not been allocated yet. Array/map -// fields do not have presence, so this is semantically identical to a -// pointer to an empty array/map, and must be treated the same for all -// semantic purposes. -// -// For message fields, the pointer is guaranteed to be NULL iff the field -// is unset (as message fields do have presence). -UPB_INLINE upb_MutableMessageValue _upb_Message_GetMutableField( - const upb_Message* msg, const upb_MiniTableField* field) { - UPB_ASSUME(!upb_MiniTableField_IsScalar(field) || - upb_MiniTableField_IsSubMessage(field)); - - upb_MutableMessageValue default_val; - default_val.msg = NULL; - - upb_MutableMessageValue ret; - if (upb_MiniTableField_IsExtension(field)) { - _upb_Message_GetExtensionField(msg, (upb_MiniTableExtension*)field, - &default_val, &ret); - } else { - _upb_Message_GetNonExtensionField(msg, field, &default_val, &ret); - } - return ret; -} - UPB_INLINE void _upb_Message_SetNonExtensionField( - upb_Message* msg, const upb_MiniTableField* field, const void* val) { + struct upb_Message* msg, const upb_MiniTableField* field, const void* val) { UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); UPB_PRIVATE(_upb_Message_SetPresence)(msg, field); UPB_PRIVATE(_upb_MiniTableField_DataCopy) @@ -276,8 +248,8 @@ UPB_INLINE void _upb_Message_SetNonExtensionField( } UPB_INLINE bool _upb_Message_SetExtensionField( - upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* val, - upb_Arena* a) { + struct upb_Message* msg, const upb_MiniTableExtension* mt_ext, + const void* val, upb_Arena* a) { UPB_ASSERT(a); struct upb_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a); if (!ext) return false; @@ -287,7 +259,7 @@ UPB_INLINE bool _upb_Message_SetExtensionField( } UPB_INLINE void _upb_Message_ClearExtensionField( - upb_Message* msg, const upb_MiniTableExtension* ext_l) { + struct upb_Message* msg, const upb_MiniTableExtension* ext_l) { upb_Message_Internal* in = upb_Message_Getinternal(msg); if (!in->internal) return; const struct upb_Extension* base = @@ -301,7 +273,7 @@ UPB_INLINE void _upb_Message_ClearExtensionField( } UPB_INLINE void _upb_Message_ClearNonExtensionField( - upb_Message* msg, const upb_MiniTableField* field) { + struct upb_Message* msg, const upb_MiniTableField* field) { if (field->presence > 0) { UPB_PRIVATE(_upb_Message_ClearHasbit)(msg, field); } else if (upb_MiniTableField_IsInOneof(field)) { @@ -315,19 +287,19 @@ UPB_INLINE void _upb_Message_ClearNonExtensionField( } UPB_INLINE void _upb_Message_AssertMapIsUntagged( - const upb_Message* msg, const upb_MiniTableField* field) { + const struct upb_Message* msg, const upb_MiniTableField* field) { UPB_UNUSED(msg); UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); #ifndef NDEBUG upb_TaggedMessagePtr default_val = 0; upb_TaggedMessagePtr tagged; _upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged); - UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(tagged)); + UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(tagged)); #endif } UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap( - upb_Message* msg, const upb_MiniTableField* field, size_t key_size, + struct upb_Message* msg, const upb_MiniTableField* field, size_t key_size, size_t val_size, upb_Arena* arena) { UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)(field); _upb_Message_AssertMapIsUntagged(msg, field); diff --git a/upb/message/internal/extension.c b/upb/message/internal/extension.c index 81cfa0f519..bc180f47c8 100644 --- a/upb/message/internal/extension.c +++ b/upb/message/internal/extension.c @@ -12,14 +12,13 @@ #include "upb/mem/arena.h" #include "upb/message/internal/extension.h" #include "upb/message/internal/message.h" -#include "upb/message/types.h" #include "upb/mini_table/extension.h" // Must be last. #include "upb/port/def.inc" const struct upb_Extension* _upb_Message_Getext( - const upb_Message* msg, const upb_MiniTableExtension* e) { + const struct upb_Message* msg, const upb_MiniTableExtension* e) { size_t n; const struct upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &n); @@ -36,7 +35,7 @@ const struct upb_Extension* _upb_Message_Getext( } const struct upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)( - const upb_Message* msg, size_t* count) { + const struct upb_Message* msg, size_t* count) { const upb_Message_Internal* in = upb_Message_Getinternal(msg); if (in->internal) { *count = (in->internal->size - in->internal->ext_begin) / @@ -49,7 +48,8 @@ const struct upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)( } struct upb_Extension* _upb_Message_GetOrCreateExtension( - upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* arena) { + struct upb_Message* msg, const upb_MiniTableExtension* e, + upb_Arena* arena) { struct upb_Extension* ext = (struct upb_Extension*)_upb_Message_Getext(msg, e); if (ext) return ext; diff --git a/upb/message/internal/map.h b/upb/message/internal/map.h index 139243ca2f..da4223d305 100644 --- a/upb/message/internal/map.h +++ b/upb/message/internal/map.h @@ -5,8 +5,6 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// - #ifndef UPB_MESSAGE_INTERNAL_MAP_H_ #define UPB_MESSAGE_INTERNAL_MAP_H_ @@ -17,11 +15,18 @@ #include "upb/base/string_view.h" #include "upb/hash/str_table.h" #include "upb/mem/arena.h" -#include "upb/message/map.h" // Must be last. #include "upb/port/def.inc" +typedef enum { + kUpb_MapInsertStatus_Inserted = 0, + kUpb_MapInsertStatus_Replaced = 1, + kUpb_MapInsertStatus_OutOfMemory = 2, +} upb_MapInsertStatus; + +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + struct upb_Map { // Size of key and val, based on the map type. // Strings are represented as '0' because they must be handled specially. diff --git a/upb/message/internal/map_entry.h b/upb/message/internal/map_entry.h index 0c5c25e919..9c1ec6b5b5 100644 --- a/upb/message/internal/map_entry.h +++ b/upb/message/internal/map_entry.h @@ -12,7 +12,7 @@ #include "upb/base/string_view.h" #include "upb/hash/common.h" -#include "upb/message/internal/types.h" +#include "upb/message/internal/message.h" // Map entries aren't actually stored for map fields, they are only used during // parsing. For parsing, it helps a lot if all map entry messages have the same diff --git a/upb/message/internal/map_sorter.h b/upb/message/internal/map_sorter.h index 2a09b3c63f..65b58a5b14 100644 --- a/upb/message/internal/map_sorter.h +++ b/upb/message/internal/map_sorter.h @@ -12,6 +12,8 @@ #include +#include "upb/base/descriptor_constants.h" +#include "upb/base/string_view.h" #include "upb/mem/alloc.h" #include "upb/message/internal/extension.h" #include "upb/message/internal/map.h" @@ -50,7 +52,8 @@ UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter* s) { if (s->entries) upb_gfree(s->entries); } -UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map, +UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, + const struct upb_Map* map, _upb_sortedmap* sorted, upb_MapEntry* ent) { if (sorted->pos == sorted->end) return false; const upb_tabent* tabent = (const upb_tabent*)s->entries[sorted->pos++]; @@ -75,7 +78,7 @@ UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s, } bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type, - const upb_Map* map, _upb_sortedmap* sorted); + const struct upb_Map* map, _upb_sortedmap* sorted); bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const struct upb_Extension* exts, size_t count, diff --git a/upb/message/internal/message.c b/upb/message/internal/message.c index 08b70d2d61..1287dc327e 100644 --- a/upb/message/internal/message.c +++ b/upb/message/internal/message.c @@ -12,7 +12,6 @@ #include "upb/base/internal/log2.h" #include "upb/mem/arena.h" -#include "upb/message/internal/types.h" // Must be last. #include "upb/port/def.inc" diff --git a/upb/message/internal/message.h b/upb/message/internal/message.h index 54af496fb0..a7b5203eb3 100644 --- a/upb/message/internal/message.h +++ b/upb/message/internal/message.h @@ -12,15 +12,14 @@ ** The definitions in this file are internal to upb. **/ -#ifndef UPB_MESSAGE_INTERNAL_H_ -#define UPB_MESSAGE_INTERNAL_H_ +#ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_ +#define UPB_MESSAGE_INTERNAL_MESSAGE_H_ #include #include #include "upb/mem/arena.h" #include "upb/message/internal/extension.h" -#include "upb/message/internal/types.h" #include "upb/mini_table/message.h" // Must be last. @@ -39,7 +38,7 @@ extern const double kUpb_NaN; * these before the user's data. The user's upb_Message* points after the * upb_Message_Internal. */ -struct upb_Message_InternalData { +typedef struct { /* Total size of this structure, including the data that follows. * Must be aligned to 8, which is alignof(upb_Extension) */ uint32_t size; @@ -61,6 +60,20 @@ struct upb_Message_InternalData { uint32_t ext_begin; /* Data follows, as if there were an array: * char data[size - sizeof(upb_Message_InternalData)]; */ +} upb_Message_InternalData; + +typedef struct { + union { + upb_Message_InternalData* internal; + + // Force 8-byte alignment, since the data members may contain members that + // require 8-byte alignment. + double d; + }; +} upb_Message_Internal; + +struct upb_Message { + int unused; // Placeholder cuz Windows won't compile an empty struct. }; UPB_INLINE size_t upb_msg_sizeof(const upb_MiniTable* m) { @@ -103,4 +116,4 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need, #include "upb/port/undef.inc" -#endif /* UPB_MESSAGE_INTERNAL_H_ */ +#endif /* UPB_MESSAGE_INTERNAL_MESSAGE_H_ */ diff --git a/upb/message/internal/tagged_ptr.h b/upb/message/internal/tagged_ptr.h new file mode 100644 index 0000000000..b1c9a77b3d --- /dev/null +++ b/upb/message/internal/tagged_ptr.h @@ -0,0 +1,59 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google LLC. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ +#define UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ + +#include + +#include "upb/message/internal/message.h" + +// Must be last. +#include "upb/port/def.inc" + +typedef uintptr_t upb_TaggedMessagePtr; + +#ifdef __cplusplus +extern "C" { +#endif + +// Internal-only because empty messages cannot be created by the user. +UPB_INLINE upb_TaggedMessagePtr +UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(struct upb_Message* ptr, bool empty) { + UPB_ASSERT(((uintptr_t)ptr & 1) == 0); + return (uintptr_t)ptr | (empty ? 1 : 0); +} + +UPB_INLINE bool UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)( + upb_TaggedMessagePtr ptr) { + return ptr & 1; +} + +UPB_INLINE struct upb_Message* UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)( + upb_TaggedMessagePtr ptr) { + return (struct upb_Message*)(ptr & ~(uintptr_t)1); +} + +UPB_INLINE struct upb_Message* UPB_PRIVATE( + _upb_TaggedMessagePtr_GetNonEmptyMessage)(upb_TaggedMessagePtr ptr) { + UPB_ASSERT(!UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr)); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); +} + +UPB_INLINE struct upb_Message* UPB_PRIVATE( + _upb_TaggedMessagePtr_GetEmptyMessage)(upb_TaggedMessagePtr ptr) { + UPB_ASSERT(UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr)); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(ptr); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port/undef.inc" + +#endif /* UPB_MINI_TABLE_INTERNAL_TAGGED_PTR_H_ */ diff --git a/upb/message/internal/types.h b/upb/message/internal/types.h deleted file mode 100644 index 2bd3b0b134..0000000000 --- a/upb/message/internal/types.h +++ /dev/null @@ -1,23 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google LLC. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -#ifndef UPB_MINI_TABLE_INTERNAL_TYPES_H_ -#define UPB_MINI_TABLE_INTERNAL_TYPES_H_ - -typedef struct upb_Message_InternalData upb_Message_InternalData; - -typedef struct { - union { - upb_Message_InternalData* internal; - - // Force 8-byte alignment, since the data members may contain members that - // require 8-byte alignment. - double d; - }; -} upb_Message_Internal; - -#endif // UPB_MINI_TABLE_INTERNAL_TYPES_H_ diff --git a/upb/message/map.h b/upb/message/map.h index 4160c35163..e471a6bbe3 100644 --- a/upb/message/map.h +++ b/upb/message/map.h @@ -12,7 +12,8 @@ #include "upb/base/descriptor_constants.h" #include "upb/mem/arena.h" -#include "upb/message/value.h" // IWYU pragma: export +#include "upb/message/internal/map.h" +#include "upb/message/value.h" // Must be last. #include "upb/port/def.inc" @@ -39,12 +40,6 @@ UPB_API bool upb_Map_Get(const upb_Map* map, upb_MessageValue key, // Removes all entries in the map. UPB_API void upb_Map_Clear(upb_Map* map); -typedef enum { - kUpb_MapInsertStatus_Inserted = 0, - kUpb_MapInsertStatus_Replaced = 1, - kUpb_MapInsertStatus_OutOfMemory = 2, -} upb_MapInsertStatus; - // Sets the given key to the given value, returning whether the key was inserted // or replaced. If the key was inserted, then any existing iterators will be // invalidated. diff --git a/upb/message/message.c b/upb/message/message.c index 4f0fee1ad3..fe52731eb9 100644 --- a/upb/message/message.c +++ b/upb/message/message.c @@ -13,7 +13,6 @@ #include "upb/mem/arena.h" #include "upb/message/internal/message.h" -#include "upb/message/internal/types.h" #include "upb/mini_table/message.h" // Must be last. diff --git a/upb/message/message.h b/upb/message/message.h index bf04f6f9c6..95ac5047b8 100644 --- a/upb/message/message.h +++ b/upb/message/message.h @@ -15,13 +15,13 @@ #include #include "upb/mem/arena.h" -#include "upb/message/types.h" // IWYU pragma: export #include "upb/mini_table/message.h" // Must be last. #include "upb/port/def.inc" typedef struct upb_Extension upb_Extension; +typedef struct upb_Message upb_Message; #ifdef __cplusplus extern "C" { diff --git a/upb/message/promote.c b/upb/message/promote.c index 593b09f24c..2cd0888c83 100644 --- a/upb/message/promote.c +++ b/upb/message/promote.c @@ -18,6 +18,7 @@ #include "upb/message/internal/array.h" #include "upb/message/internal/extension.h" #include "upb/message/internal/message.h" +#include "upb/message/internal/tagged_ptr.h" #include "upb/message/map.h" #include "upb/message/message.h" #include "upb/message/tagged_ptr.h" @@ -154,7 +155,8 @@ static upb_DecodeStatus upb_Message_PromoteOne(upb_TaggedMessagePtr* tagged, const upb_MiniTable* mini_table, int decode_options, upb_Arena* arena) { - upb_Message* empty = _upb_TaggedMessagePtr_GetEmptyMessage(*tagged); + upb_Message* empty = + UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)(*tagged); size_t unknown_size; const char* unknown_data = upb_Message_GetUnknown(empty, &unknown_size); upb_Message* promoted = upb_Message_New(mini_table, arena); @@ -162,7 +164,7 @@ static upb_DecodeStatus upb_Message_PromoteOne(upb_TaggedMessagePtr* tagged, upb_DecodeStatus status = upb_Decode(unknown_data, unknown_size, promoted, mini_table, NULL, decode_options, arena); if (status == kUpb_DecodeStatus_Ok) { - *tagged = _upb_TaggedMessagePtr_Pack(promoted, false); + *tagged = UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(promoted, false); } return status; } diff --git a/upb/message/tagged_ptr.h b/upb/message/tagged_ptr.h index 9004c773dd..f2e1bfd3b6 100644 --- a/upb/message/tagged_ptr.h +++ b/upb/message/tagged_ptr.h @@ -10,15 +10,16 @@ #include -#include "upb/message/types.h" // IWYU pragma: export +#include "upb/message/internal/tagged_ptr.h" +#include "upb/message/message.h" // Must be last. #include "upb/port/def.inc" // When a upb_Message* is stored in a message, array, or map, it is stored in a -// tagged form. If the tag bit is set, the referenced upb_Message is of type +// tagged form. If the tag bit is set, the referenced upb_Message is of type // _kUpb_MiniTable_Empty (a sentinel message type with no fields) instead of -// that field's true message type. This forms the basis of what we call +// that field's true message type. This forms the basis of what we call // "dynamic tree shaking." // // See the documentation for kUpb_DecodeOption_ExperimentalAllowUnlinked for @@ -30,35 +31,16 @@ typedef uintptr_t upb_TaggedMessagePtr; extern "C" { #endif -// Internal-only because empty messages cannot be created by the user. -UPB_INLINE upb_TaggedMessagePtr _upb_TaggedMessagePtr_Pack(upb_Message* ptr, - bool empty) { - UPB_ASSERT(((uintptr_t)ptr & 1) == 0); - return (uintptr_t)ptr | (empty ? 1 : 0); -} - // Users who enable unlinked sub-messages must use this to test whether a -// message is empty before accessing it. If a message is empty, it must be +// message is empty before accessing it. If a message is empty, it must be // first promoted using the interfaces in message/promote.h. UPB_INLINE bool upb_TaggedMessagePtr_IsEmpty(upb_TaggedMessagePtr ptr) { - return ptr & 1; -} - -UPB_INLINE upb_Message* _upb_TaggedMessagePtr_GetMessage( - upb_TaggedMessagePtr ptr) { - return (upb_Message*)(ptr & ~(uintptr_t)1); + return UPB_PRIVATE(_upb_TaggedMessagePtr_IsEmpty)(ptr); } UPB_INLINE upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage( upb_TaggedMessagePtr ptr) { - UPB_ASSERT(!upb_TaggedMessagePtr_IsEmpty(ptr)); - return _upb_TaggedMessagePtr_GetMessage(ptr); -} - -UPB_INLINE upb_Message* _upb_TaggedMessagePtr_GetEmptyMessage( - upb_TaggedMessagePtr ptr) { - UPB_ASSERT(upb_TaggedMessagePtr_IsEmpty(ptr)); - return _upb_TaggedMessagePtr_GetMessage(ptr); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetNonEmptyMessage)(ptr); } #ifdef __cplusplus diff --git a/upb/message/types.h b/upb/message/types.h deleted file mode 100644 index d20cf27dfc..0000000000 --- a/upb/message/types.h +++ /dev/null @@ -1,17 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google LLC. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -#ifndef UPB_MESSAGE_TYPES_H_ -#define UPB_MESSAGE_TYPES_H_ - -// This typedef is in a leaf header to resolve a circular dependency between -// messages and mini tables. -typedef struct upb_Message { - int unused; // Placeholder cuz Windows won't compile an empty struct. -} upb_Message; - -#endif /* UPB_MESSAGE_TYPES_H_ */ diff --git a/upb/message/value.h b/upb/message/value.h index 547edc1d2e..775622c910 100644 --- a/upb/message/value.h +++ b/upb/message/value.h @@ -14,7 +14,10 @@ #include #include "upb/base/string_view.h" -#include "upb/message/tagged_ptr.h" +#include "upb/message/internal/array.h" +#include "upb/message/internal/map.h" +#include "upb/message/internal/message.h" +#include "upb/message/internal/tagged_ptr.h" typedef union { bool bool_val; diff --git a/upb/mini_descriptor/BUILD b/upb/mini_descriptor/BUILD index b1932ead98..b1793c6bf7 100644 --- a/upb/mini_descriptor/BUILD +++ b/upb/mini_descriptor/BUILD @@ -66,6 +66,7 @@ cc_test( "//upb:mini_table", "//upb:port", "//upb:wire", + "//upb/message:internal", "@com_google_absl//absl/container:flat_hash_set", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", diff --git a/upb/reflection/BUILD b/upb/reflection/BUILD index e42ebda23b..9bb1b648c5 100644 --- a/upb/reflection/BUILD +++ b/upb/reflection/BUILD @@ -64,10 +64,10 @@ bootstrap_cc_library( "//upb:base", "//upb:mem", "//upb:message", - "//upb:message_value", "//upb:mini_descriptor", "//upb:mini_table", "//upb:port", + "//upb/message:internal", ], ) @@ -138,12 +138,12 @@ bootstrap_cc_library( "//upb:message", "//upb:message_accessors", "//upb:message_copy", - "//upb:message_value", "//upb:mini_descriptor", "//upb:mini_table", "//upb:port", "//upb:wire", "//upb/base:internal", + "//upb/message:internal", "//upb/mini_descriptor:internal", ], ) diff --git a/upb/reflection/field_def.c b/upb/reflection/field_def.c index 3b6089670d..8f849a57bc 100644 --- a/upb/reflection/field_def.c +++ b/upb/reflection/field_def.c @@ -19,7 +19,6 @@ #include "upb/base/upcast.h" #include "upb/mem/arena.h" #include "upb/message/accessors.h" -#include "upb/message/value.h" #include "upb/mini_descriptor/decode.h" #include "upb/mini_descriptor/internal/encode.h" #include "upb/mini_descriptor/internal/modifiers.h" diff --git a/upb/reflection/message.h b/upb/reflection/message.h index 54af6f15af..d31f6b9b26 100644 --- a/upb/reflection/message.h +++ b/upb/reflection/message.h @@ -13,7 +13,6 @@ #include "upb/mem/arena.h" #include "upb/message/map.h" #include "upb/message/message.h" -#include "upb/message/value.h" // IWYU pragma: export #include "upb/reflection/common.h" // Must be last. diff --git a/upb/text/BUILD b/upb/text/BUILD index 6a1a97c6eb..a9ba0db436 100644 --- a/upb/text/BUILD +++ b/upb/text/BUILD @@ -25,6 +25,7 @@ cc_library( "//upb:reflection", "//upb:wire", "//upb:wire_reader", + "//upb/message:internal", ], ) diff --git a/upb/wire/BUILD b/upb/wire/BUILD index fdfb223a9e..93be09bd9f 100644 --- a/upb/wire/BUILD +++ b/upb/wire/BUILD @@ -32,11 +32,10 @@ cc_library( "//upb:mem", "//upb:message", "//upb:message_accessors", - "//upb:message_tagged_ptr", - "//upb:message_types", "//upb:mini_table", "//upb:port", "//upb/mem:internal", + "//upb/message:internal", "//upb/mini_table:internal", ], ) diff --git a/upb/wire/decode.c b/upb/wire/decode.c index a0fd7c11b6..a80f65c11c 100644 --- a/upb/wire/decode.c +++ b/upb/wire/decode.c @@ -24,6 +24,7 @@ #include "upb/message/internal/map.h" #include "upb/message/internal/map_entry.h" #include "upb/message/internal/message.h" +#include "upb/message/internal/tagged_ptr.h" #include "upb/message/map.h" #include "upb/message/message.h" #include "upb/message/tagged_ptr.h" @@ -32,6 +33,7 @@ #include "upb/mini_table/extension_registry.h" #include "upb/mini_table/field.h" #include "upb/mini_table/internal/field.h" +#include "upb/mini_table/internal/message.h" #include "upb/mini_table/internal/size_log2.h" #include "upb/mini_table/message.h" #include "upb/mini_table/sub.h" @@ -258,7 +260,8 @@ static upb_Message* _upb_Decoder_NewSubMessage(upb_Decoder* d, _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_UnlinkedSubMessage); } - upb_TaggedMessagePtr tagged = _upb_TaggedMessagePtr_Pack(msg, is_empty); + upb_TaggedMessagePtr tagged = + UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(msg, is_empty); memcpy(target, &tagged, sizeof(tagged)); return msg; } @@ -271,13 +274,14 @@ static upb_Message* _upb_Decoder_ReuseSubMessage( UPB_ASSERT(subl); if (!upb_TaggedMessagePtr_IsEmpty(tagged) || UPB_PRIVATE(_upb_MiniTable_IsEmpty)(subl)) { - return _upb_TaggedMessagePtr_GetMessage(tagged); + return UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged); } // We found an empty message from a previous parse that was performed before // this field was linked. But it is linked now, so we want to allocate a new // message of the correct type and promote data into it before continuing. - upb_Message* existing = _upb_TaggedMessagePtr_GetEmptyMessage(tagged); + upb_Message* existing = + UPB_PRIVATE(_upb_TaggedMessagePtr_GetEmptyMessage)(tagged); upb_Message* promoted = _upb_Decoder_NewSubMessage(d, subs, field, target); size_t size; const char* unknown = upb_Message_GetUnknown(existing, &size); diff --git a/upb/wire/encode.c b/upb/wire/encode.c index 1d04ce6d97..5797e97ec1 100644 --- a/upb/wire/encode.c +++ b/upb/wire/encode.c @@ -26,12 +26,14 @@ #include "upb/message/internal/map.h" #include "upb/message/internal/map_entry.h" #include "upb/message/internal/map_sorter.h" +#include "upb/message/internal/tagged_ptr.h" #include "upb/message/map.h" #include "upb/message/message.h" #include "upb/message/tagged_ptr.h" #include "upb/mini_table/extension.h" #include "upb/mini_table/field.h" #include "upb/mini_table/internal/field.h" +#include "upb/mini_table/internal/message.h" #include "upb/mini_table/message.h" #include "upb/mini_table/sub.h" #include "upb/wire/internal/constants.h" @@ -217,7 +219,8 @@ static void encode_TaggedMessagePtr(upb_encstate* e, if (upb_TaggedMessagePtr_IsEmpty(tagged)) { m = UPB_PRIVATE(_upb_MiniTable_Empty)(); } - encode_message(e, _upb_TaggedMessagePtr_GetMessage(tagged), m, size); + encode_message(e, UPB_PRIVATE(_upb_TaggedMessagePtr_GetMessage)(tagged), m, + size); } static void encode_scalar(upb_encstate* e, const void* _field_mem, diff --git a/upb/wire/encode.h b/upb/wire/encode.h index 4c5969dee7..fed261de51 100644 --- a/upb/wire/encode.h +++ b/upb/wire/encode.h @@ -14,7 +14,7 @@ #include #include "upb/mem/arena.h" -#include "upb/message/types.h" +#include "upb/message/message.h" #include "upb/mini_table/message.h" // Must be last. diff --git a/upb/wire/internal/decode_fast.c b/upb/wire/internal/decode_fast.c index 27d648ff80..9837003f3f 100644 --- a/upb/wire/internal/decode_fast.c +++ b/upb/wire/internal/decode_fast.c @@ -19,7 +19,6 @@ #include "upb/message/array.h" #include "upb/message/internal/array.h" -#include "upb/message/internal/types.h" #include "upb/mini_table/sub.h" #include "upb/wire/internal/decoder.h"