upb: clean up some of the includes in upb/message/

PiperOrigin-RevId: 594135760
diff --git a/upb/message/internal/accessors.h b/upb/message/internal/accessors.h
index 089fb64..191df05 100644
--- a/upb/message/internal/accessors.h
+++ b/upb/message/internal/accessors.h
@@ -14,13 +14,10 @@
 
 #include "upb/base/string_view.h"
 #include "upb/mem/arena.h"
-#include "upb/message/array.h"
 #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/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"
@@ -232,7 +229,7 @@
 UPB_INLINE void _upb_Message_GetExtensionField(
     const upb_Message* msg, const upb_MiniTableExtension* mt_ext,
     const void* default_val, void* val) {
-  const upb_Extension* ext = _upb_Message_Getext(msg, mt_ext);
+  const struct upb_Extension* ext = _upb_Message_Getext(msg, mt_ext);
   const upb_MiniTableField* f = &mt_ext->UPB_PRIVATE(field);
   UPB_ASSUME(upb_MiniTableField_IsExtension(f));
 
@@ -282,7 +279,7 @@
     upb_Message* msg, const upb_MiniTableExtension* mt_ext, const void* val,
     upb_Arena* a) {
   UPB_ASSERT(a);
-  upb_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a);
+  struct upb_Extension* ext = _upb_Message_GetOrCreateExtension(msg, mt_ext, a);
   if (!ext) return false;
   UPB_PRIVATE(_upb_MiniTableField_DataCopy)
   (&mt_ext->UPB_PRIVATE(field), &ext->data, val);
@@ -293,12 +290,13 @@
     upb_Message* msg, const upb_MiniTableExtension* ext_l) {
   upb_Message_Internal* in = upb_Message_Getinternal(msg);
   if (!in->internal) return;
-  const upb_Extension* base =
-      UPB_PTR_AT(in->internal, in->internal->ext_begin, upb_Extension);
-  upb_Extension* ext = (upb_Extension*)_upb_Message_Getext(msg, ext_l);
+  const struct upb_Extension* base =
+      UPB_PTR_AT(in->internal, in->internal->ext_begin, struct upb_Extension);
+  struct upb_Extension* ext =
+      (struct upb_Extension*)_upb_Message_Getext(msg, ext_l);
   if (ext) {
     *ext = *base;
-    in->internal->ext_begin += sizeof(upb_Extension);
+    in->internal->ext_begin += sizeof(struct upb_Extension);
   }
 }
 
@@ -328,13 +326,13 @@
 #endif
 }
 
-UPB_INLINE upb_Map* _upb_Message_GetOrCreateMutableMap(
+UPB_INLINE struct upb_Map* _upb_Message_GetOrCreateMutableMap(
     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);
-  upb_Map* map = NULL;
-  upb_Map* default_map_value = NULL;
+  struct upb_Map* map = NULL;
+  struct upb_Map* default_map_value = NULL;
   _upb_Message_GetNonExtensionField(msg, field, &default_map_value, &map);
   if (!map) {
     map = _upb_Map_New(arena, key_size, val_size);
diff --git a/upb/message/internal/array.h b/upb/message/internal/array.h
index 4d03e4b..96152f0 100644
--- a/upb/message/internal/array.h
+++ b/upb/message/internal/array.h
@@ -10,7 +10,7 @@
 
 #include <string.h>
 
-#include "upb/message/array.h"
+#include "upb/mem/arena.h"
 
 // Must be last.
 #include "upb/port/def.inc"
@@ -39,7 +39,7 @@
   size_t UPB_PRIVATE(capacity);  // Allocated storage. Measured in elements.
 };
 
-UPB_INLINE void UPB_PRIVATE(_upb_Array_SetTaggedPtr)(upb_Array* array,
+UPB_INLINE void UPB_PRIVATE(_upb_Array_SetTaggedPtr)(struct upb_Array* array,
                                                      void* data, size_t lg2) {
   UPB_ASSERT(lg2 != 1);
   UPB_ASSERT(lg2 <= 4);
@@ -47,29 +47,31 @@
   array->data = (uintptr_t)data | bits;
 }
 
-UPB_INLINE size_t UPB_PRIVATE(_upb_Array_ElemSizeLg2)(const upb_Array* array) {
+UPB_INLINE size_t
+UPB_PRIVATE(_upb_Array_ElemSizeLg2)(const struct upb_Array* array) {
   const size_t bits = array->data & _UPB_ARRAY_MASK_LG2;
   const size_t lg2 = bits + (bits != 0);
   return lg2;
 }
 
-UPB_INLINE const void* _upb_array_constptr(const upb_Array* array) {
+UPB_INLINE const void* _upb_array_constptr(const struct upb_Array* array) {
   UPB_PRIVATE(_upb_Array_ElemSizeLg2)(array);  // Check assertions.
   return (void*)(array->data & ~(uintptr_t)_UPB_ARRAY_MASK_ALL);
 }
 
-UPB_INLINE void* _upb_array_ptr(upb_Array* array) {
+UPB_INLINE void* _upb_array_ptr(struct upb_Array* array) {
   return (void*)_upb_array_constptr(array);
 }
 
-UPB_INLINE upb_Array* UPB_PRIVATE(_upb_Array_New)(upb_Arena* arena,
-                                                  size_t init_capacity,
-                                                  int elem_size_lg2) {
+UPB_INLINE struct upb_Array* UPB_PRIVATE(_upb_Array_New)(upb_Arena* arena,
+                                                         size_t init_capacity,
+                                                         int elem_size_lg2) {
   UPB_ASSERT(elem_size_lg2 != 1);
   UPB_ASSERT(elem_size_lg2 <= 4);
-  const size_t array_size = UPB_ALIGN_UP(sizeof(upb_Array), UPB_MALLOC_ALIGN);
+  const size_t array_size =
+      UPB_ALIGN_UP(sizeof(struct upb_Array), UPB_MALLOC_ALIGN);
   const size_t bytes = array_size + (init_capacity << elem_size_lg2);
-  upb_Array* array = (upb_Array*)upb_Arena_Malloc(arena, bytes);
+  struct upb_Array* array = (struct upb_Array*)upb_Arena_Malloc(arena, bytes);
   if (!array) return NULL;
   UPB_PRIVATE(_upb_Array_SetTaggedPtr)
   (array, UPB_PTR_AT(array, array_size, void), elem_size_lg2);
@@ -79,19 +81,19 @@
 }
 
 // Resizes the capacity of the array to be at least min_size.
-bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_size,
+bool UPB_PRIVATE(_upb_Array_Realloc)(struct upb_Array* array, size_t min_size,
                                      upb_Arena* arena);
 
-UPB_INLINE bool UPB_PRIVATE(_upb_Array_Reserve)(upb_Array* array, size_t size,
-                                                upb_Arena* arena) {
+UPB_INLINE bool UPB_PRIVATE(_upb_Array_Reserve)(struct upb_Array* array,
+                                                size_t size, upb_Arena* arena) {
   if (array->UPB_PRIVATE(capacity) < size)
     return UPB_PRIVATE(_upb_Array_Realloc)(array, size, arena);
   return true;
 }
 
 // Resize without initializing new elements.
-UPB_INLINE bool _upb_Array_ResizeUninitialized(upb_Array* array, size_t size,
-                                               upb_Arena* arena) {
+UPB_INLINE bool _upb_Array_ResizeUninitialized(struct upb_Array* array,
+                                               size_t size, upb_Arena* arena) {
   UPB_ASSERT(size <= array->UPB_ONLYBITS(size) ||
              arena);  // Allow NULL arena when shrinking.
   if (!UPB_PRIVATE(_upb_Array_Reserve)(array, size, arena)) return false;
@@ -102,7 +104,7 @@
 // This function is intended for situations where elem_size is compile-time
 // constant or a known expression of the form (1 << lg2), so that the expression
 // i*elem_size does not result in an actual multiplication.
-UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(upb_Array* array, size_t i,
+UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(struct upb_Array* array, size_t i,
                                             const void* data,
                                             size_t elem_size) {
   UPB_ASSERT(i < array->UPB_ONLYBITS(size));
diff --git a/upb/message/internal/extension.h b/upb/message/internal/extension.h
index 86b1e6f..9325732 100644
--- a/upb/message/internal/extension.h
+++ b/upb/message/internal/extension.h
@@ -10,7 +10,7 @@
 
 #include "upb/base/string_view.h"
 #include "upb/mem/arena.h"
-#include "upb/message/message.h"
+#include "upb/message/internal/message.h"
 #include "upb/mini_table/extension.h"
 
 // Must be last.
@@ -40,18 +40,19 @@
 // Adds the given extension data to the given message.
 // |ext| is copied into the message instance.
 // This logically replaces any previously-added extension with this number.
-upb_Extension* _upb_Message_GetOrCreateExtension(
-    upb_Message* msg, const upb_MiniTableExtension* ext, upb_Arena* arena);
+struct upb_Extension* _upb_Message_GetOrCreateExtension(
+    struct upb_Message* msg, const upb_MiniTableExtension* ext,
+    upb_Arena* arena);
 
 // Returns an array of extensions for this message.
 // Note: the array is ordered in reverse relative to the order of creation.
-const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(const upb_Message* msg,
-                                                       size_t* count);
+const struct upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(
+    const struct upb_Message* msg, size_t* count);
 
 // Returns an extension for a message with a given mini table,
 // or NULL if no extension exists with this mini table.
-const upb_Extension* _upb_Message_Getext(const upb_Message* msg,
-                                         const upb_MiniTableExtension* ext);
+const struct upb_Extension* _upb_Message_Getext(
+    const struct upb_Message* msg, const upb_MiniTableExtension* ext);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/upb/message/internal/map.h b/upb/message/internal/map.h
index 51bc16b..139243c 100644
--- a/upb/message/internal/map.h
+++ b/upb/message/internal/map.h
@@ -81,7 +81,7 @@
   }
 }
 
-UPB_INLINE void* _upb_map_next(const upb_Map* map, size_t* iter) {
+UPB_INLINE void* _upb_map_next(const struct upb_Map* map, size_t* iter) {
   upb_strtable_iter it;
   it.t = &map->table;
   it.index = *iter;
@@ -91,17 +91,17 @@
   return (void*)str_tabent(&it);
 }
 
-UPB_INLINE void _upb_Map_Clear(upb_Map* map) {
+UPB_INLINE void _upb_Map_Clear(struct upb_Map* map) {
   upb_strtable_clear(&map->table);
 }
 
-UPB_INLINE bool _upb_Map_Delete(upb_Map* map, const void* key, size_t key_size,
-                                upb_value* val) {
+UPB_INLINE bool _upb_Map_Delete(struct upb_Map* map, const void* key,
+                                size_t key_size, upb_value* val) {
   upb_StringView k = _upb_map_tokey(key, key_size);
   return upb_strtable_remove2(&map->table, k.data, k.size, val);
 }
 
-UPB_INLINE bool _upb_Map_Get(const upb_Map* map, const void* key,
+UPB_INLINE bool _upb_Map_Get(const struct upb_Map* map, const void* key,
                              size_t key_size, void* val, size_t val_size) {
   upb_value tabval;
   upb_StringView k = _upb_map_tokey(key, key_size);
@@ -112,9 +112,10 @@
   return ret;
 }
 
-UPB_INLINE upb_MapInsertStatus _upb_Map_Insert(upb_Map* map, const void* key,
-                                               size_t key_size, void* val,
-                                               size_t val_size, upb_Arena* a) {
+UPB_INLINE upb_MapInsertStatus _upb_Map_Insert(struct upb_Map* map,
+                                               const void* key, size_t key_size,
+                                               void* val, size_t val_size,
+                                               upb_Arena* a) {
   upb_StringView strkey = _upb_map_tokey(key, key_size);
   upb_value tabval = {0};
   if (!_upb_map_tovalue(val, val_size, &tabval, a)) {
@@ -131,7 +132,7 @@
                  : kUpb_MapInsertStatus_Inserted;
 }
 
-UPB_INLINE size_t _upb_Map_Size(const upb_Map* map) {
+UPB_INLINE size_t _upb_Map_Size(const struct upb_Map* map) {
   return map->table.t.count;
 }
 
@@ -143,7 +144,7 @@
 }
 
 // Creates a new map on the given arena with this key/value type.
-upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size);
+struct upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/upb/message/internal/map_sorter.h b/upb/message/internal/map_sorter.h
index 93be85e..2a09b3c 100644
--- a/upb/message/internal/map_sorter.h
+++ b/upb/message/internal/map_sorter.h
@@ -63,9 +63,9 @@
 
 UPB_INLINE bool _upb_sortedmap_nextext(_upb_mapsorter* s,
                                        _upb_sortedmap* sorted,
-                                       const upb_Extension** ext) {
+                                       const struct upb_Extension** ext) {
   if (sorted->pos == sorted->end) return false;
-  *ext = (const upb_Extension*)s->entries[sorted->pos++];
+  *ext = (const struct upb_Extension*)s->entries[sorted->pos++];
   return true;
 }
 
@@ -77,8 +77,9 @@
 bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
                             const upb_Map* map, _upb_sortedmap* sorted);
 
-bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts,
-                             size_t count, _upb_sortedmap* sorted);
+bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
+                             const struct upb_Extension* exts, size_t count,
+                             _upb_sortedmap* sorted);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/upb/message/internal/message.c b/upb/message/internal/message.c
index 94ed339..08b70d2 100644
--- a/upb/message/internal/message.c
+++ b/upb/message/internal/message.c
@@ -5,14 +5,13 @@
 // license that can be found in the LICENSE file or at
 // https://developers.google.com/open-source/licenses/bsd
 
-#include "upb/message/message.h"
+#include "upb/message/internal/message.h"
 
 #include <math.h>
 #include <string.h>
 
 #include "upb/base/internal/log2.h"
 #include "upb/mem/arena.h"
-#include "upb/message/internal/message.h"
 #include "upb/message/internal/types.h"
 
 // Must be last.
@@ -24,7 +23,7 @@
 
 static const size_t realloc_overhead = sizeof(upb_Message_InternalData);
 
-bool UPB_PRIVATE(_upb_Message_Realloc)(upb_Message* msg, size_t need,
+bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
                                        upb_Arena* arena) {
   upb_Message_Internal* in = upb_Message_Getinternal(msg);
   if (!in->internal) {
diff --git a/upb/message/internal/message.h b/upb/message/internal/message.h
index 5cbc652..54af496 100644
--- a/upb/message/internal/message.h
+++ b/upb/message/internal/message.h
@@ -68,31 +68,33 @@
 }
 
 // Inline version upb_Message_New(), for internal use.
-UPB_INLINE upb_Message* _upb_Message_New(const upb_MiniTable* mini_table,
-                                         upb_Arena* arena) {
+UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* mini_table,
+                                                upb_Arena* arena) {
   size_t size = upb_msg_sizeof(mini_table);
   void* mem = upb_Arena_Malloc(arena, size + sizeof(upb_Message_Internal));
   if (UPB_UNLIKELY(!mem)) return NULL;
-  upb_Message* msg = UPB_PTR_AT(mem, sizeof(upb_Message_Internal), upb_Message);
+  struct upb_Message* msg =
+      UPB_PTR_AT(mem, sizeof(upb_Message_Internal), struct upb_Message);
   memset(mem, 0, size);
   return msg;
 }
 
 UPB_INLINE upb_Message_Internal* upb_Message_Getinternal(
-    const upb_Message* msg) {
+    const struct upb_Message* msg) {
   ptrdiff_t size = sizeof(upb_Message_Internal);
   return (upb_Message_Internal*)((char*)msg - size);
 }
 
 // Discards the unknown fields for this message only.
-void _upb_Message_DiscardUnknown_shallow(upb_Message* msg);
+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)(upb_Message* msg, const char* data,
-                                          size_t len, upb_Arena* arena);
+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)(upb_Message* msg, size_t need,
+bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
                                        upb_Arena* arena);
 
 #ifdef __cplusplus
diff --git a/upb/message/value.h b/upb/message/value.h
index 99df025..547edc1 100644
--- a/upb/message/value.h
+++ b/upb/message/value.h
@@ -15,7 +15,6 @@
 
 #include "upb/base/string_view.h"
 #include "upb/message/tagged_ptr.h"
-#include "upb/message/types.h"
 
 typedef union {
   bool bool_val;
@@ -27,7 +26,7 @@
   uint64_t uint64_val;
   const struct upb_Array* array_val;
   const struct upb_Map* map_val;
-  const upb_Message* msg_val;
+  const struct upb_Message* msg_val;
   upb_StringView str_val;
 
   // EXPERIMENTAL: A tagged upb_Message*.  Users must use this instead of
@@ -40,7 +39,7 @@
 typedef union {
   struct upb_Array* array;
   struct upb_Map* map;
-  upb_Message* msg;
+  struct upb_Message* msg;
 } upb_MutableMessageValue;
 
 #endif /* UPB_MESSAGE_VALUE_H_ */