From 787714f60d83f26fbb1f6f1593477784f0cce224 Mon Sep 17 00:00:00 2001 From: Eric Salo Date: Sun, 2 Oct 2022 21:22:33 -0700 Subject: [PATCH] move extension_registry declarations out of msg_internal.h PiperOrigin-RevId: 478407599 --- upb/extension_registry.h | 23 ++++++++++++++++++++--- upb/msg_internal.h | 21 ++++----------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/upb/extension_registry.h b/upb/extension_registry.h index cafe6893d4..1301564070 100644 --- a/upb/extension_registry.h +++ b/upb/extension_registry.h @@ -71,13 +71,30 @@ extern "C" { * reflection do not need to populate a upb_ExtensionRegistry directly. */ -struct upb_ExtensionRegistry; typedef struct upb_ExtensionRegistry upb_ExtensionRegistry; -/* Creates a upb_ExtensionRegistry in the given arena. The arena must outlive - * any use of the extreg. */ +// Creates a upb_ExtensionRegistry in the given arena. +// The arena must outlive any use of the extreg. upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena); +// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// + +typedef struct upb_MiniTable upb_MiniTable; +typedef struct upb_MiniTable_Extension upb_MiniTable_Extension; + +// Adds the given extension info for message type |l| and field number |num| +// into the registry. Returns false if this message type and field number were +// already in the map, or if memory allocation fails. +bool _upb_extreg_add(upb_ExtensionRegistry* r, + const upb_MiniTable_Extension** e, size_t count); + +// Looks up the extension (if any) defined for message type |l| and field +// number |num|. If an extension was found, copies the field info into |*ext| +// and returns true. Otherwise returns false. +const upb_MiniTable_Extension* _upb_extreg_get(const upb_ExtensionRegistry* r, + const upb_MiniTable* l, + uint32_t num); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/upb/msg_internal.h b/upb/msg_internal.h index 650cecb886..85bac968a1 100644 --- a/upb/msg_internal.h +++ b/upb/msg_internal.h @@ -226,11 +226,13 @@ struct upb_MiniTable { _upb_FastTable_Entry fasttable[]; }; -typedef struct { +typedef struct upb_MiniTable_Extension upb_MiniTable_Extension; + +struct upb_MiniTable_Extension { upb_MiniTable_Field field; const upb_MiniTable* extendee; upb_MiniTable_Sub sub; /* NULL unless submessage or proto2 enum */ -} upb_MiniTable_Extension; +}; typedef struct { const upb_MiniTable** msgs; @@ -253,21 +255,6 @@ UPB_INLINE uint64_t upb_MiniTable_requiredmask(const upb_MiniTable* l) { return ((1ULL << n) - 1) << 1; } -/** upb_ExtensionRegistry *****************************************************/ - -/* Adds the given extension info for message type |l| and field number |num| - * into the registry. Returns false if this message type and field number were - * already in the map, or if memory allocation fails. */ -bool _upb_extreg_add(upb_ExtensionRegistry* r, - const upb_MiniTable_Extension** e, size_t count); - -/* Looks up the extension (if any) defined for message type |l| and field - * number |num|. If an extension was found, copies the field info into |*ext| - * and returns true. Otherwise returns false. */ -const upb_MiniTable_Extension* _upb_extreg_get(const upb_ExtensionRegistry* r, - const upb_MiniTable* l, - uint32_t num); - /** upb_Message ***************************************************************/ /* Internal members of a upb_Message that track unknown fields and/or