You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

def.h 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. /*
  2. * Copyright (c) 2009-2021, Google LLC
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of Google LLC nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
  20. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef UPB_DEF_H_
  28. #define UPB_DEF_H_
  29. #include "google/protobuf/descriptor.upb.h"
  30. #include "upb/internal/table.h"
  31. #include "upb/upb.h"
  32. /* Must be last. */
  33. #include "upb/port_def.inc"
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif /* __cplusplus */
  38. struct upb_EnumDef;
  39. typedef struct upb_EnumDef upb_EnumDef;
  40. struct upb_EnumValueDef;
  41. typedef struct upb_EnumValueDef upb_EnumValueDef;
  42. struct upb_ExtensionRange;
  43. typedef struct upb_ExtensionRange upb_ExtensionRange;
  44. struct upb_FieldDef;
  45. typedef struct upb_FieldDef upb_FieldDef;
  46. struct upb_FileDef;
  47. typedef struct upb_FileDef upb_FileDef;
  48. struct upb_MethodDef;
  49. typedef struct upb_MethodDef upb_MethodDef;
  50. struct upb_MessageDef;
  51. typedef struct upb_MessageDef upb_MessageDef;
  52. struct upb_OneofDef;
  53. typedef struct upb_OneofDef upb_OneofDef;
  54. struct upb_ServiceDef;
  55. typedef struct upb_ServiceDef upb_ServiceDef;
  56. struct upb_streamdef;
  57. typedef struct upb_streamdef upb_streamdef;
  58. struct upb_DefPool;
  59. typedef struct upb_DefPool upb_DefPool;
  60. typedef enum
  61. {
  62. kUpb_Syntax_Proto2 = 2,
  63. kUpb_Syntax_Proto3 = 3
  64. } upb_Syntax;
  65. /* All the different kind of well known type messages. For simplicity of check,
  66. * number wrappers and string wrappers are grouped together. Make sure the
  67. * order and merber of these groups are not changed.
  68. */
  69. typedef enum
  70. {
  71. kUpb_WellKnown_Unspecified,
  72. kUpb_WellKnown_Any,
  73. kUpb_WellKnown_FieldMask,
  74. kUpb_WellKnown_Duration,
  75. kUpb_WellKnown_Timestamp,
  76. /* number wrappers */
  77. kUpb_WellKnown_DoubleValue,
  78. kUpb_WellKnown_FloatValue,
  79. kUpb_WellKnown_Int64Value,
  80. kUpb_WellKnown_UInt64Value,
  81. kUpb_WellKnown_Int32Value,
  82. kUpb_WellKnown_UInt32Value,
  83. /* string wrappers */
  84. kUpb_WellKnown_StringValue,
  85. kUpb_WellKnown_BytesValue,
  86. kUpb_WellKnown_BoolValue,
  87. kUpb_WellKnown_Value,
  88. kUpb_WellKnown_ListValue,
  89. kUpb_WellKnown_Struct
  90. } upb_WellKnown;
  91. /* upb_FieldDef ***************************************************************/
  92. /* Maximum field number allowed for FieldDefs. This is an inherent limit of the
  93. * protobuf wire format. */
  94. #define kUpb_MaxFieldNumber ((1 << 29) - 1)
  95. const google_protobuf_FieldOptions* upb_FieldDef_Options(const upb_FieldDef* f);
  96. bool upb_FieldDef_HasOptions(const upb_FieldDef* f);
  97. const char* upb_FieldDef_FullName(const upb_FieldDef* f);
  98. upb_CType upb_FieldDef_CType(const upb_FieldDef* f);
  99. upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f);
  100. upb_Label upb_FieldDef_Label(const upb_FieldDef* f);
  101. uint32_t upb_FieldDef_Number(const upb_FieldDef* f);
  102. const char* upb_FieldDef_Name(const upb_FieldDef* f);
  103. const char* upb_FieldDef_JsonName(const upb_FieldDef* f);
  104. bool upb_FieldDef_HasJsonName(const upb_FieldDef* f);
  105. bool upb_FieldDef_IsExtension(const upb_FieldDef* f);
  106. bool upb_FieldDef_IsPacked(const upb_FieldDef* f);
  107. const upb_FileDef* upb_FieldDef_File(const upb_FieldDef* f);
  108. const upb_MessageDef* upb_FieldDef_ContainingType(const upb_FieldDef* f);
  109. const upb_MessageDef* upb_FieldDef_ExtensionScope(const upb_FieldDef* f);
  110. const upb_OneofDef* upb_FieldDef_ContainingOneof(const upb_FieldDef* f);
  111. const upb_OneofDef* upb_FieldDef_RealContainingOneof(const upb_FieldDef* f);
  112. uint32_t upb_FieldDef_Index(const upb_FieldDef* f);
  113. bool upb_FieldDef_IsSubMessage(const upb_FieldDef* f);
  114. bool upb_FieldDef_IsString(const upb_FieldDef* f);
  115. bool upb_FieldDef_IsOptional(const upb_FieldDef* f);
  116. bool upb_FieldDef_IsRequired(const upb_FieldDef* f);
  117. bool upb_FieldDef_IsRepeated(const upb_FieldDef* f);
  118. bool upb_FieldDef_IsPrimitive(const upb_FieldDef* f);
  119. bool upb_FieldDef_IsMap(const upb_FieldDef* f);
  120. bool upb_FieldDef_HasDefault(const upb_FieldDef* f);
  121. bool upb_FieldDef_HasSubDef(const upb_FieldDef* f);
  122. bool upb_FieldDef_HasPresence(const upb_FieldDef* f);
  123. const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f);
  124. const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f);
  125. const upb_MiniTable_Field* upb_FieldDef_MiniTable(const upb_FieldDef* f);
  126. const upb_MiniTable_Extension* _upb_FieldDef_ExtensionMiniTable(
  127. const upb_FieldDef* f
  128. );
  129. bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef* f);
  130. /* upb_OneofDef ***************************************************************/
  131. const google_protobuf_OneofOptions* upb_OneofDef_Options(const upb_OneofDef* o);
  132. bool upb_OneofDef_HasOptions(const upb_OneofDef* o);
  133. const char* upb_OneofDef_Name(const upb_OneofDef* o);
  134. const upb_MessageDef* upb_OneofDef_ContainingType(const upb_OneofDef* o);
  135. uint32_t upb_OneofDef_Index(const upb_OneofDef* o);
  136. bool upb_OneofDef_IsSynthetic(const upb_OneofDef* o);
  137. int upb_OneofDef_FieldCount(const upb_OneofDef* o);
  138. const upb_FieldDef* upb_OneofDef_Field(const upb_OneofDef* o, int i);
  139. /* Oneof lookups:
  140. * - ntof: look up a field by name.
  141. * - ntofz: look up a field by name (as a null-terminated string).
  142. * - itof: look up a field by number. */
  143. const upb_FieldDef* upb_OneofDef_LookupNameWithSize(const upb_OneofDef* o, const char* name, size_t length);
  144. UPB_INLINE const upb_FieldDef* upb_OneofDef_LookupName(const upb_OneofDef* o, const char* name)
  145. {
  146. return upb_OneofDef_LookupNameWithSize(o, name, strlen(name));
  147. }
  148. const upb_FieldDef* upb_OneofDef_LookupNumber(const upb_OneofDef* o, uint32_t num);
  149. /* upb_MessageDef *************************************************************/
  150. /* Well-known field tag numbers for map-entry messages. */
  151. #define kUpb_MapEntry_KeyFieldNumber 1
  152. #define kUpb_MapEntry_ValueFieldNumber 2
  153. /* Well-known field tag numbers for Any messages. */
  154. #define kUpb_Any_TypeFieldNumber 1
  155. #define kUpb_Any_ValueFieldNumber 2
  156. /* Well-known field tag numbers for duration messages. */
  157. #define kUpb_Duration_SecondsFieldNumber 1
  158. #define kUpb_Duration_NanosFieldNumber 2
  159. /* Well-known field tag numbers for timestamp messages. */
  160. #define kUpb_Timestamp_SecondsFieldNumber 1
  161. #define kUpb_Timestamp_NanosFieldNumber 2
  162. const google_protobuf_MessageOptions* upb_MessageDef_Options(
  163. const upb_MessageDef* m
  164. );
  165. bool upb_MessageDef_HasOptions(const upb_MessageDef* m);
  166. const char* upb_MessageDef_FullName(const upb_MessageDef* m);
  167. const upb_FileDef* upb_MessageDef_File(const upb_MessageDef* m);
  168. const upb_MessageDef* upb_MessageDef_ContainingType(const upb_MessageDef* m);
  169. const char* upb_MessageDef_Name(const upb_MessageDef* m);
  170. upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m);
  171. upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m);
  172. int upb_MessageDef_ExtensionRangeCount(const upb_MessageDef* m);
  173. int upb_MessageDef_FieldCount(const upb_MessageDef* m);
  174. int upb_MessageDef_OneofCount(const upb_MessageDef* m);
  175. const upb_ExtensionRange* upb_MessageDef_ExtensionRange(const upb_MessageDef* m, int i);
  176. const upb_FieldDef* upb_MessageDef_Field(const upb_MessageDef* m, int i);
  177. const upb_OneofDef* upb_MessageDef_Oneof(const upb_MessageDef* m, int i);
  178. const upb_FieldDef* upb_MessageDef_FindFieldByNumber(const upb_MessageDef* m, uint32_t i);
  179. const upb_FieldDef* upb_MessageDef_FindFieldByNameWithSize(
  180. const upb_MessageDef* m, const char* name, size_t len
  181. );
  182. const upb_OneofDef* upb_MessageDef_FindOneofByNameWithSize(
  183. const upb_MessageDef* m, const char* name, size_t len
  184. );
  185. const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m);
  186. UPB_INLINE const upb_OneofDef* upb_MessageDef_FindOneofByName(
  187. const upb_MessageDef* m, const char* name
  188. )
  189. {
  190. return upb_MessageDef_FindOneofByNameWithSize(m, name, strlen(name));
  191. }
  192. UPB_INLINE const upb_FieldDef* upb_MessageDef_FindFieldByName(
  193. const upb_MessageDef* m, const char* name
  194. )
  195. {
  196. return upb_MessageDef_FindFieldByNameWithSize(m, name, strlen(name));
  197. }
  198. UPB_INLINE bool upb_MessageDef_IsMapEntry(const upb_MessageDef* m)
  199. {
  200. return google_protobuf_MessageOptions_map_entry(upb_MessageDef_Options(m));
  201. }
  202. UPB_INLINE bool upb_MessageDef_IsMessageSet(const upb_MessageDef* m)
  203. {
  204. return google_protobuf_MessageOptions_message_set_wire_format(
  205. upb_MessageDef_Options(m)
  206. );
  207. }
  208. /* Nested entities. */
  209. int upb_MessageDef_NestedMessageCount(const upb_MessageDef* m);
  210. int upb_MessageDef_NestedEnumCount(const upb_MessageDef* m);
  211. int upb_MessageDef_NestedExtensionCount(const upb_MessageDef* m);
  212. const upb_MessageDef* upb_MessageDef_NestedMessage(const upb_MessageDef* m, int i);
  213. const upb_EnumDef* upb_MessageDef_NestedEnum(const upb_MessageDef* m, int i);
  214. const upb_FieldDef* upb_MessageDef_NestedExtension(const upb_MessageDef* m, int i);
  215. /* Lookup of either field or oneof by name. Returns whether either was found.
  216. * If the return is true, then the found def will be set, and the non-found
  217. * one set to NULL. */
  218. bool upb_MessageDef_FindByNameWithSize(const upb_MessageDef* m, const char* name, size_t len, const upb_FieldDef** f, const upb_OneofDef** o);
  219. UPB_INLINE bool upb_MessageDef_FindByName(const upb_MessageDef* m, const char* name, const upb_FieldDef** f, const upb_OneofDef** o)
  220. {
  221. return upb_MessageDef_FindByNameWithSize(m, name, strlen(name), f, o);
  222. }
  223. /* Returns a field by either JSON name or regular proto name. */
  224. const upb_FieldDef* upb_MessageDef_FindByJsonNameWithSize(
  225. const upb_MessageDef* m, const char* name, size_t len
  226. );
  227. UPB_INLINE const upb_FieldDef* upb_MessageDef_FindByJsonName(
  228. const upb_MessageDef* m, const char* name
  229. )
  230. {
  231. return upb_MessageDef_FindByJsonNameWithSize(m, name, strlen(name));
  232. }
  233. /* upb_ExtensionRange *********************************************************/
  234. const google_protobuf_ExtensionRangeOptions* upb_ExtensionRange_Options(
  235. const upb_ExtensionRange* r
  236. );
  237. bool upb_ExtensionRange_HasOptions(const upb_ExtensionRange* r);
  238. int32_t upb_ExtensionRange_Start(const upb_ExtensionRange* r);
  239. int32_t upb_ExtensionRange_End(const upb_ExtensionRange* r);
  240. /* upb_EnumDef ****************************************************************/
  241. const google_protobuf_EnumOptions* upb_EnumDef_Options(const upb_EnumDef* e);
  242. bool upb_EnumDef_HasOptions(const upb_EnumDef* e);
  243. const char* upb_EnumDef_FullName(const upb_EnumDef* e);
  244. const char* upb_EnumDef_Name(const upb_EnumDef* e);
  245. const upb_FileDef* upb_EnumDef_File(const upb_EnumDef* e);
  246. const upb_MessageDef* upb_EnumDef_ContainingType(const upb_EnumDef* e);
  247. int32_t upb_EnumDef_Default(const upb_EnumDef* e);
  248. int upb_EnumDef_ValueCount(const upb_EnumDef* e);
  249. const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i);
  250. const upb_EnumValueDef* upb_EnumDef_FindValueByNameWithSize(
  251. const upb_EnumDef* e, const char* name, size_t len
  252. );
  253. const upb_EnumValueDef* upb_EnumDef_FindValueByNumber(const upb_EnumDef* e, int32_t num);
  254. bool upb_EnumDef_CheckNumber(const upb_EnumDef* e, int32_t num);
  255. // Convenience wrapper.
  256. UPB_INLINE const upb_EnumValueDef* upb_EnumDef_FindValueByName(
  257. const upb_EnumDef* e, const char* name
  258. )
  259. {
  260. return upb_EnumDef_FindValueByNameWithSize(e, name, strlen(name));
  261. }
  262. /* upb_EnumValueDef ***********************************************************/
  263. const google_protobuf_EnumValueOptions* upb_EnumValueDef_Options(
  264. const upb_EnumValueDef* e
  265. );
  266. bool upb_EnumValueDef_HasOptions(const upb_EnumValueDef* e);
  267. const char* upb_EnumValueDef_FullName(const upb_EnumValueDef* e);
  268. const char* upb_EnumValueDef_Name(const upb_EnumValueDef* e);
  269. int32_t upb_EnumValueDef_Number(const upb_EnumValueDef* e);
  270. uint32_t upb_EnumValueDef_Index(const upb_EnumValueDef* e);
  271. const upb_EnumDef* upb_EnumValueDef_Enum(const upb_EnumValueDef* e);
  272. /* upb_FileDef ****************************************************************/
  273. const google_protobuf_FileOptions* upb_FileDef_Options(const upb_FileDef* f);
  274. bool upb_FileDef_HasOptions(const upb_FileDef* f);
  275. const char* upb_FileDef_Name(const upb_FileDef* f);
  276. const char* upb_FileDef_Package(const upb_FileDef* f);
  277. upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f);
  278. int upb_FileDef_DependencyCount(const upb_FileDef* f);
  279. int upb_FileDef_PublicDependencyCount(const upb_FileDef* f);
  280. int upb_FileDef_WeakDependencyCount(const upb_FileDef* f);
  281. int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f);
  282. int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f);
  283. int upb_FileDef_TopLevelExtensionCount(const upb_FileDef* f);
  284. int upb_FileDef_ServiceCount(const upb_FileDef* f);
  285. const upb_FileDef* upb_FileDef_Dependency(const upb_FileDef* f, int i);
  286. const upb_FileDef* upb_FileDef_PublicDependency(const upb_FileDef* f, int i);
  287. const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i);
  288. const upb_MessageDef* upb_FileDef_TopLevelMessage(const upb_FileDef* f, int i);
  289. const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i);
  290. const upb_FieldDef* upb_FileDef_TopLevelExtension(const upb_FileDef* f, int i);
  291. const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i);
  292. const upb_DefPool* upb_FileDef_Pool(const upb_FileDef* f);
  293. const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f);
  294. const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f);
  295. /* upb_MethodDef **************************************************************/
  296. const google_protobuf_MethodOptions* upb_MethodDef_Options(
  297. const upb_MethodDef* m
  298. );
  299. bool upb_MethodDef_HasOptions(const upb_MethodDef* m);
  300. const char* upb_MethodDef_FullName(const upb_MethodDef* m);
  301. int upb_MethodDef_Index(const upb_MethodDef* m);
  302. const char* upb_MethodDef_Name(const upb_MethodDef* m);
  303. const upb_ServiceDef* upb_MethodDef_Service(const upb_MethodDef* m);
  304. const upb_MessageDef* upb_MethodDef_InputType(const upb_MethodDef* m);
  305. const upb_MessageDef* upb_MethodDef_OutputType(const upb_MethodDef* m);
  306. bool upb_MethodDef_ClientStreaming(const upb_MethodDef* m);
  307. bool upb_MethodDef_ServerStreaming(const upb_MethodDef* m);
  308. /* upb_ServiceDef *************************************************************/
  309. const google_protobuf_ServiceOptions* upb_ServiceDef_Options(
  310. const upb_ServiceDef* s
  311. );
  312. bool upb_ServiceDef_HasOptions(const upb_ServiceDef* s);
  313. const char* upb_ServiceDef_FullName(const upb_ServiceDef* s);
  314. const char* upb_ServiceDef_Name(const upb_ServiceDef* s);
  315. int upb_ServiceDef_Index(const upb_ServiceDef* s);
  316. const upb_FileDef* upb_ServiceDef_File(const upb_ServiceDef* s);
  317. int upb_ServiceDef_MethodCount(const upb_ServiceDef* s);
  318. const upb_MethodDef* upb_ServiceDef_Method(const upb_ServiceDef* s, int i);
  319. const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, const char* name);
  320. /* upb_DefPool ****************************************************************/
  321. upb_DefPool* upb_DefPool_New(void);
  322. void upb_DefPool_Free(upb_DefPool* s);
  323. const upb_MessageDef* upb_DefPool_FindMessageByName(const upb_DefPool* s, const char* sym);
  324. const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize(
  325. const upb_DefPool* s, const char* sym, size_t len
  326. );
  327. const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, const char* sym);
  328. const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, const char* sym);
  329. const upb_FieldDef* upb_DefPool_FindExtensionByName(const upb_DefPool* s, const char* sym);
  330. const upb_FieldDef* upb_DefPool_FindExtensionByNameWithSize(
  331. const upb_DefPool* s, const char* sym, size_t len
  332. );
  333. const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, const char* name);
  334. const upb_ServiceDef* upb_DefPool_FindServiceByName(const upb_DefPool* s, const char* name);
  335. const upb_ServiceDef* upb_DefPool_FindServiceByNameWithSize(
  336. const upb_DefPool* s, const char* name, size_t size
  337. );
  338. const upb_FileDef* upb_DefPool_FindFileContainingSymbol(const upb_DefPool* s, const char* name);
  339. const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s, const char* name, size_t len);
  340. const upb_FileDef* upb_DefPool_AddFile(
  341. upb_DefPool* s, const google_protobuf_FileDescriptorProto* file, upb_Status* status
  342. );
  343. size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s);
  344. upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s);
  345. const upb_FieldDef* _upb_DefPool_FindExtensionByMiniTable(
  346. const upb_DefPool* s, const upb_MiniTable_Extension* ext
  347. );
  348. const upb_FieldDef* upb_DefPool_FindExtensionByNumber(const upb_DefPool* s, const upb_MessageDef* m, int32_t fieldnum);
  349. const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry(
  350. const upb_DefPool* s
  351. );
  352. const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s, const upb_MessageDef* m, size_t* count);
  353. /* For generated code only: loads a generated descriptor. */
  354. typedef struct _upb_DefPool_Init
  355. {
  356. struct _upb_DefPool_Init** deps; /* Dependencies of this file. */
  357. const upb_MiniTable_File* layout;
  358. const char* filename;
  359. upb_StringView descriptor; /* Serialized descriptor. */
  360. } _upb_DefPool_Init;
  361. // Should only be directly called by tests. This variant lets us suppress
  362. // the use of compiled-in tables, forcing a rebuild of the tables at runtime.
  363. bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init, bool rebuild_minitable);
  364. UPB_INLINE bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init)
  365. {
  366. return _upb_DefPool_LoadDefInitEx(s, init, false);
  367. }
  368. #include "upb/port_undef.inc"
  369. #ifdef __cplusplus
  370. } /* extern "C" */
  371. #endif /* __cplusplus */
  372. #endif /* UPB_DEF_H_ */