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

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