php-upb.h 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885
  1. /* Amalgamated source file */
  2. #include <stdint.h>/*
  3. * This is where we define macros used across upb.
  4. *
  5. * All of these macros are undef'd in port_undef.inc to avoid leaking them to
  6. * users.
  7. *
  8. * The correct usage is:
  9. *
  10. * #include "upb/foobar.h"
  11. * #include "upb/baz.h"
  12. *
  13. * // MUST be last included header.
  14. * #include "upb/port_def.inc"
  15. *
  16. * // Code for this file.
  17. * // <...>
  18. *
  19. * // Can be omitted for .c files, required for .h.
  20. * #include "upb/port_undef.inc"
  21. *
  22. * This file is private and must not be included by users!
  23. */
  24. #include <stdint.h>
  25. #include <stddef.h>
  26. #if UINTPTR_MAX == 0xffffffff
  27. #define UPB_SIZE(size32, size64) size32
  28. #else
  29. #define UPB_SIZE(size32, size64) size64
  30. #endif
  31. /* If we always read/write as a consistent type to each address, this shouldn't
  32. * violate aliasing.
  33. */
  34. #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
  35. #define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
  36. *UPB_PTR_AT(msg, case_offset, int) == case_val \
  37. ? *UPB_PTR_AT(msg, offset, fieldtype) \
  38. : default
  39. #define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
  40. *UPB_PTR_AT(msg, case_offset, int) = case_val; \
  41. *UPB_PTR_AT(msg, offset, fieldtype) = value;
  42. #define UPB_MAPTYPE_STRING 0
  43. /* UPB_INLINE: inline if possible, emit standalone code if required. */
  44. #ifdef __cplusplus
  45. #define UPB_INLINE inline
  46. #elif defined (__GNUC__) || defined(__clang__)
  47. #define UPB_INLINE static __inline__
  48. #else
  49. #define UPB_INLINE static
  50. #endif
  51. #define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
  52. #define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
  53. #define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, 16)
  54. #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
  55. /* Hints to the compiler about likely/unlikely branches. */
  56. #if defined (__GNUC__) || defined(__clang__)
  57. #define UPB_LIKELY(x) __builtin_expect((x),1)
  58. #define UPB_UNLIKELY(x) __builtin_expect((x),0)
  59. #else
  60. #define UPB_LIKELY(x) (x)
  61. #define UPB_UNLIKELY(x) (x)
  62. #endif
  63. /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
  64. * doesn't provide these preprocessor symbols. */
  65. #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  66. #define UPB_BIG_ENDIAN
  67. #endif
  68. /* Macros for function attributes on compilers that support them. */
  69. #ifdef __GNUC__
  70. #define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
  71. #define UPB_NOINLINE __attribute__((noinline))
  72. #define UPB_NORETURN __attribute__((__noreturn__))
  73. #else /* !defined(__GNUC__) */
  74. #define UPB_FORCEINLINE
  75. #define UPB_NOINLINE
  76. #define UPB_NORETURN
  77. #endif
  78. #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
  79. /* C99/C++11 versions. */
  80. #include <stdio.h>
  81. #define _upb_snprintf snprintf
  82. #define _upb_vsnprintf vsnprintf
  83. #define _upb_va_copy(a, b) va_copy(a, b)
  84. #elif defined(_MSC_VER)
  85. /* Microsoft C/C++ versions. */
  86. #include <stdarg.h>
  87. #include <stdio.h>
  88. #if _MSC_VER < 1900
  89. int msvc_snprintf(char* s, size_t n, const char* format, ...);
  90. int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
  91. #define UPB_MSVC_VSNPRINTF
  92. #define _upb_snprintf msvc_snprintf
  93. #define _upb_vsnprintf msvc_vsnprintf
  94. #else
  95. #define _upb_snprintf snprintf
  96. #define _upb_vsnprintf vsnprintf
  97. #endif
  98. #define _upb_va_copy(a, b) va_copy(a, b)
  99. #elif defined __GNUC__
  100. /* A few hacky workarounds for functions not in C89.
  101. * For internal use only!
  102. * TODO(haberman): fix these by including our own implementations, or finding
  103. * another workaround.
  104. */
  105. #define _upb_snprintf __builtin_snprintf
  106. #define _upb_vsnprintf __builtin_vsnprintf
  107. #define _upb_va_copy(a, b) __va_copy(a, b)
  108. #else
  109. #error Need implementations of [v]snprintf and va_copy
  110. #endif
  111. #ifdef __cplusplus
  112. #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || \
  113. (defined(_MSC_VER) && _MSC_VER >= 1900)
  114. /* C++11 is present */
  115. #else
  116. #error upb requires C++11 for C++ support
  117. #endif
  118. #endif
  119. #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
  120. #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
  121. #define UPB_UNUSED(var) (void)var
  122. /* UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
  123. */
  124. #ifdef NDEBUG
  125. #ifdef __GNUC__
  126. #define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable()
  127. #elif defined _MSC_VER
  128. #define UPB_ASSUME(expr) if (!(expr)) __assume(0)
  129. #else
  130. #define UPB_ASSUME(expr) do {} if (false && (expr))
  131. #endif
  132. #else
  133. #define UPB_ASSUME(expr) assert(expr)
  134. #endif
  135. /* UPB_ASSERT(): in release mode, we use the expression without letting it be
  136. * evaluated. This prevents "unused variable" warnings. */
  137. #ifdef NDEBUG
  138. #define UPB_ASSERT(expr) do {} while (false && (expr))
  139. #else
  140. #define UPB_ASSERT(expr) assert(expr)
  141. #endif
  142. /* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
  143. * exist in debug mode. This turns into regular assert. */
  144. #define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
  145. #if defined(__GNUC__) || defined(__clang__)
  146. #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
  147. #else
  148. #define UPB_UNREACHABLE() do { assert(0); } while(0)
  149. #endif
  150. /* UPB_INFINITY representing floating-point positive infinity. */
  151. #include <math.h>
  152. #ifdef INFINITY
  153. #define UPB_INFINITY INFINITY
  154. #else
  155. #define UPB_INFINITY (1.0 / 0.0)
  156. #endif
  157. /*
  158. ** upb_decode: parsing into a upb_msg using a upb_msglayout.
  159. */
  160. #ifndef UPB_DECODE_H_
  161. #define UPB_DECODE_H_
  162. /*
  163. ** Our memory representation for parsing tables and messages themselves.
  164. ** Functions in this file are used by generated code and possibly reflection.
  165. **
  166. ** The definitions in this file are internal to upb.
  167. **/
  168. #ifndef UPB_MSG_H_
  169. #define UPB_MSG_H_
  170. #include <stdint.h>
  171. #include <string.h>
  172. /*
  173. ** upb_table
  174. **
  175. ** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
  176. ** This file defines very fast int->upb_value (inttable) and string->upb_value
  177. ** (strtable) hash tables.
  178. **
  179. ** The table uses chained scatter with Brent's variation (inspired by the Lua
  180. ** implementation of hash tables). The hash function for strings is Austin
  181. ** Appleby's "MurmurHash."
  182. **
  183. ** The inttable uses uintptr_t as its key, which guarantees it can be used to
  184. ** store pointers or integers of at least 32 bits (upb isn't really useful on
  185. ** systems where sizeof(void*) < 4).
  186. **
  187. ** The table must be homogenous (all values of the same type). In debug
  188. ** mode, we check this on insert and lookup.
  189. */
  190. #ifndef UPB_TABLE_H_
  191. #define UPB_TABLE_H_
  192. #include <stdint.h>
  193. #include <string.h>
  194. /*
  195. ** This file contains shared definitions that are widely used across upb.
  196. */
  197. #ifndef UPB_H_
  198. #define UPB_H_
  199. #include <assert.h>
  200. #include <stdarg.h>
  201. #include <stdbool.h>
  202. #include <stddef.h>
  203. #include <stdint.h>
  204. #include <string.h>
  205. #ifdef __cplusplus
  206. extern "C" {
  207. #endif
  208. /* upb_status *****************************************************************/
  209. #define UPB_STATUS_MAX_MESSAGE 127
  210. typedef struct {
  211. bool ok;
  212. char msg[UPB_STATUS_MAX_MESSAGE]; /* Error message; NULL-terminated. */
  213. } upb_status;
  214. const char *upb_status_errmsg(const upb_status *status);
  215. bool upb_ok(const upb_status *status);
  216. /* These are no-op if |status| is NULL. */
  217. void upb_status_clear(upb_status *status);
  218. void upb_status_seterrmsg(upb_status *status, const char *msg);
  219. void upb_status_seterrf(upb_status *status, const char *fmt, ...);
  220. void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args);
  221. void upb_status_vappenderrf(upb_status *status, const char *fmt, va_list args);
  222. /** upb_strview ************************************************************/
  223. typedef struct {
  224. const char *data;
  225. size_t size;
  226. } upb_strview;
  227. UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size) {
  228. upb_strview ret;
  229. ret.data = data;
  230. ret.size = size;
  231. return ret;
  232. }
  233. UPB_INLINE upb_strview upb_strview_makez(const char *data) {
  234. return upb_strview_make(data, strlen(data));
  235. }
  236. UPB_INLINE bool upb_strview_eql(upb_strview a, upb_strview b) {
  237. return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
  238. }
  239. #define UPB_STRVIEW_INIT(ptr, len) {ptr, len}
  240. #define UPB_STRVIEW_FORMAT "%.*s"
  241. #define UPB_STRVIEW_ARGS(view) (int)(view).size, (view).data
  242. /** upb_alloc *****************************************************************/
  243. /* A upb_alloc is a possibly-stateful allocator object.
  244. *
  245. * It could either be an arena allocator (which doesn't require individual
  246. * free() calls) or a regular malloc() (which does). The client must therefore
  247. * free memory unless it knows that the allocator is an arena allocator. */
  248. struct upb_alloc;
  249. typedef struct upb_alloc upb_alloc;
  250. /* A malloc()/free() function.
  251. * If "size" is 0 then the function acts like free(), otherwise it acts like
  252. * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */
  253. typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize,
  254. size_t size);
  255. struct upb_alloc {
  256. upb_alloc_func *func;
  257. };
  258. UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
  259. UPB_ASSERT(alloc);
  260. return alloc->func(alloc, NULL, 0, size);
  261. }
  262. UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
  263. size_t size) {
  264. UPB_ASSERT(alloc);
  265. return alloc->func(alloc, ptr, oldsize, size);
  266. }
  267. UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
  268. assert(alloc);
  269. alloc->func(alloc, ptr, 0, 0);
  270. }
  271. /* The global allocator used by upb. Uses the standard malloc()/free(). */
  272. extern upb_alloc upb_alloc_global;
  273. /* Functions that hard-code the global malloc.
  274. *
  275. * We still get benefit because we can put custom logic into our global
  276. * allocator, like injecting out-of-memory faults in debug/testing builds. */
  277. UPB_INLINE void *upb_gmalloc(size_t size) {
  278. return upb_malloc(&upb_alloc_global, size);
  279. }
  280. UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) {
  281. return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
  282. }
  283. UPB_INLINE void upb_gfree(void *ptr) {
  284. upb_free(&upb_alloc_global, ptr);
  285. }
  286. /* upb_arena ******************************************************************/
  287. /* upb_arena is a specific allocator implementation that uses arena allocation.
  288. * The user provides an allocator that will be used to allocate the underlying
  289. * arena blocks. Arenas by nature do not require the individual allocations
  290. * to be freed. However the Arena does allow users to register cleanup
  291. * functions that will run when the arena is destroyed.
  292. *
  293. * A upb_arena is *not* thread-safe.
  294. *
  295. * You could write a thread-safe arena allocator that satisfies the
  296. * upb_alloc interface, but it would not be as efficient for the
  297. * single-threaded case. */
  298. typedef void upb_cleanup_func(void *ud);
  299. struct upb_arena;
  300. typedef struct upb_arena upb_arena;
  301. typedef struct {
  302. /* We implement the allocator interface.
  303. * This must be the first member of upb_arena!
  304. * TODO(haberman): remove once handlers are gone. */
  305. upb_alloc alloc;
  306. char *ptr, *end;
  307. } _upb_arena_head;
  308. /* Creates an arena from the given initial block (if any -- n may be 0).
  309. * Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
  310. * is a fixed-size arena and cannot grow. */
  311. upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc);
  312. void upb_arena_free(upb_arena *a);
  313. bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func);
  314. void upb_arena_fuse(upb_arena *a, upb_arena *b);
  315. void *_upb_arena_slowmalloc(upb_arena *a, size_t size);
  316. UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
  317. UPB_INLINE void *upb_arena_malloc(upb_arena *a, size_t size) {
  318. _upb_arena_head *h = (_upb_arena_head*)a;
  319. void* ret;
  320. size = UPB_ALIGN_MALLOC(size);
  321. if (UPB_UNLIKELY((size_t)(h->end - h->ptr) < size)) {
  322. return _upb_arena_slowmalloc(a, size);
  323. }
  324. ret = h->ptr;
  325. h->ptr += size;
  326. return ret;
  327. }
  328. UPB_INLINE void *upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize,
  329. size_t size) {
  330. void *ret = upb_arena_malloc(a, size);
  331. if (ret && oldsize > 0) {
  332. memcpy(ret, ptr, oldsize);
  333. }
  334. return ret;
  335. }
  336. UPB_INLINE upb_arena *upb_arena_new(void) {
  337. return upb_arena_init(NULL, 0, &upb_alloc_global);
  338. }
  339. /* Constants ******************************************************************/
  340. /* Generic function type. */
  341. typedef void upb_func(void);
  342. /* A list of types as they are encoded on-the-wire. */
  343. typedef enum {
  344. UPB_WIRE_TYPE_VARINT = 0,
  345. UPB_WIRE_TYPE_64BIT = 1,
  346. UPB_WIRE_TYPE_DELIMITED = 2,
  347. UPB_WIRE_TYPE_START_GROUP = 3,
  348. UPB_WIRE_TYPE_END_GROUP = 4,
  349. UPB_WIRE_TYPE_32BIT = 5
  350. } upb_wiretype_t;
  351. /* The types a field can have. Note that this list is not identical to the
  352. * types defined in descriptor.proto, which gives INT32 and SINT32 separate
  353. * types (we distinguish the two with the "integer encoding" enum below). */
  354. typedef enum {
  355. UPB_TYPE_BOOL = 1,
  356. UPB_TYPE_FLOAT = 2,
  357. UPB_TYPE_INT32 = 3,
  358. UPB_TYPE_UINT32 = 4,
  359. UPB_TYPE_ENUM = 5, /* Enum values are int32. */
  360. UPB_TYPE_MESSAGE = 6,
  361. UPB_TYPE_DOUBLE = 7,
  362. UPB_TYPE_INT64 = 8,
  363. UPB_TYPE_UINT64 = 9,
  364. UPB_TYPE_STRING = 10,
  365. UPB_TYPE_BYTES = 11
  366. } upb_fieldtype_t;
  367. /* The repeated-ness of each field; this matches descriptor.proto. */
  368. typedef enum {
  369. UPB_LABEL_OPTIONAL = 1,
  370. UPB_LABEL_REQUIRED = 2,
  371. UPB_LABEL_REPEATED = 3
  372. } upb_label_t;
  373. /* Descriptor types, as defined in descriptor.proto. */
  374. typedef enum {
  375. /* Old (long) names. TODO(haberman): remove */
  376. UPB_DESCRIPTOR_TYPE_DOUBLE = 1,
  377. UPB_DESCRIPTOR_TYPE_FLOAT = 2,
  378. UPB_DESCRIPTOR_TYPE_INT64 = 3,
  379. UPB_DESCRIPTOR_TYPE_UINT64 = 4,
  380. UPB_DESCRIPTOR_TYPE_INT32 = 5,
  381. UPB_DESCRIPTOR_TYPE_FIXED64 = 6,
  382. UPB_DESCRIPTOR_TYPE_FIXED32 = 7,
  383. UPB_DESCRIPTOR_TYPE_BOOL = 8,
  384. UPB_DESCRIPTOR_TYPE_STRING = 9,
  385. UPB_DESCRIPTOR_TYPE_GROUP = 10,
  386. UPB_DESCRIPTOR_TYPE_MESSAGE = 11,
  387. UPB_DESCRIPTOR_TYPE_BYTES = 12,
  388. UPB_DESCRIPTOR_TYPE_UINT32 = 13,
  389. UPB_DESCRIPTOR_TYPE_ENUM = 14,
  390. UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
  391. UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
  392. UPB_DESCRIPTOR_TYPE_SINT32 = 17,
  393. UPB_DESCRIPTOR_TYPE_SINT64 = 18,
  394. UPB_DTYPE_DOUBLE = 1,
  395. UPB_DTYPE_FLOAT = 2,
  396. UPB_DTYPE_INT64 = 3,
  397. UPB_DTYPE_UINT64 = 4,
  398. UPB_DTYPE_INT32 = 5,
  399. UPB_DTYPE_FIXED64 = 6,
  400. UPB_DTYPE_FIXED32 = 7,
  401. UPB_DTYPE_BOOL = 8,
  402. UPB_DTYPE_STRING = 9,
  403. UPB_DTYPE_GROUP = 10,
  404. UPB_DTYPE_MESSAGE = 11,
  405. UPB_DTYPE_BYTES = 12,
  406. UPB_DTYPE_UINT32 = 13,
  407. UPB_DTYPE_ENUM = 14,
  408. UPB_DTYPE_SFIXED32 = 15,
  409. UPB_DTYPE_SFIXED64 = 16,
  410. UPB_DTYPE_SINT32 = 17,
  411. UPB_DTYPE_SINT64 = 18
  412. } upb_descriptortype_t;
  413. #define UPB_MAP_BEGIN ((size_t)-1)
  414. #ifdef __cplusplus
  415. } /* extern "C" */
  416. #endif
  417. #endif /* UPB_H_ */
  418. #ifdef __cplusplus
  419. extern "C" {
  420. #endif
  421. /* upb_value ******************************************************************/
  422. /* A tagged union (stored untagged inside the table) so that we can check that
  423. * clients calling table accessors are correctly typed without having to have
  424. * an explosion of accessors. */
  425. typedef enum {
  426. UPB_CTYPE_INT32 = 1,
  427. UPB_CTYPE_INT64 = 2,
  428. UPB_CTYPE_UINT32 = 3,
  429. UPB_CTYPE_UINT64 = 4,
  430. UPB_CTYPE_BOOL = 5,
  431. UPB_CTYPE_CSTR = 6,
  432. UPB_CTYPE_PTR = 7,
  433. UPB_CTYPE_CONSTPTR = 8,
  434. UPB_CTYPE_FPTR = 9,
  435. UPB_CTYPE_FLOAT = 10,
  436. UPB_CTYPE_DOUBLE = 11
  437. } upb_ctype_t;
  438. typedef struct {
  439. uint64_t val;
  440. } upb_value;
  441. /* Like strdup(), which isn't always available since it's not ANSI C. */
  442. char *upb_strdup(const char *s, upb_alloc *a);
  443. /* Variant that works with a length-delimited rather than NULL-delimited string,
  444. * as supported by strtable. */
  445. char *upb_strdup2(const char *s, size_t len, upb_alloc *a);
  446. UPB_INLINE char *upb_gstrdup(const char *s) {
  447. return upb_strdup(s, &upb_alloc_global);
  448. }
  449. UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val) {
  450. v->val = val;
  451. }
  452. UPB_INLINE upb_value _upb_value_val(uint64_t val) {
  453. upb_value ret;
  454. _upb_value_setval(&ret, val);
  455. return ret;
  456. }
  457. /* For each value ctype, define the following set of functions:
  458. *
  459. * // Get/set an int32 from a upb_value.
  460. * int32_t upb_value_getint32(upb_value val);
  461. * void upb_value_setint32(upb_value *val, int32_t cval);
  462. *
  463. * // Construct a new upb_value from an int32.
  464. * upb_value upb_value_int32(int32_t val); */
  465. #define FUNCS(name, membername, type_t, converter, proto_type) \
  466. UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \
  467. val->val = (converter)cval; \
  468. } \
  469. UPB_INLINE upb_value upb_value_ ## name(type_t val) { \
  470. upb_value ret; \
  471. upb_value_set ## name(&ret, val); \
  472. return ret; \
  473. } \
  474. UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
  475. return (type_t)(converter)val.val; \
  476. }
  477. FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32)
  478. FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64)
  479. FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32)
  480. FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64)
  481. FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL)
  482. FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR)
  483. FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR)
  484. FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
  485. FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR)
  486. #undef FUNCS
  487. UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) {
  488. memcpy(&val->val, &cval, sizeof(cval));
  489. }
  490. UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) {
  491. memcpy(&val->val, &cval, sizeof(cval));
  492. }
  493. UPB_INLINE upb_value upb_value_float(float cval) {
  494. upb_value ret;
  495. upb_value_setfloat(&ret, cval);
  496. return ret;
  497. }
  498. UPB_INLINE upb_value upb_value_double(double cval) {
  499. upb_value ret;
  500. upb_value_setdouble(&ret, cval);
  501. return ret;
  502. }
  503. #undef SET_TYPE
  504. /* upb_tabkey *****************************************************************/
  505. /* Either:
  506. * 1. an actual integer key, or
  507. * 2. a pointer to a string prefixed by its uint32_t length, owned by us.
  508. *
  509. * ...depending on whether this is a string table or an int table. We would
  510. * make this a union of those two types, but C89 doesn't support statically
  511. * initializing a non-first union member. */
  512. typedef uintptr_t upb_tabkey;
  513. UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) {
  514. char* mem = (char*)key;
  515. if (len) memcpy(len, mem, sizeof(*len));
  516. return mem + sizeof(*len);
  517. }
  518. /* upb_tabval *****************************************************************/
  519. typedef struct {
  520. uint64_t val;
  521. } upb_tabval;
  522. #define UPB_TABVALUE_EMPTY_INIT {-1}
  523. /* upb_table ******************************************************************/
  524. typedef struct _upb_tabent {
  525. upb_tabkey key;
  526. upb_tabval val;
  527. /* Internal chaining. This is const so we can create static initializers for
  528. * tables. We cast away const sometimes, but *only* when the containing
  529. * upb_table is known to be non-const. This requires a bit of care, but
  530. * the subtlety is confined to table.c. */
  531. const struct _upb_tabent *next;
  532. } upb_tabent;
  533. typedef struct {
  534. size_t count; /* Number of entries in the hash part. */
  535. size_t mask; /* Mask to turn hash value -> bucket. */
  536. uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
  537. /* Hash table entries.
  538. * Making this const isn't entirely accurate; what we really want is for it to
  539. * have the same const-ness as the table it's inside. But there's no way to
  540. * declare that in C. So we have to make it const so that we can statically
  541. * initialize const hash tables. Then we cast away const when we have to.
  542. */
  543. const upb_tabent *entries;
  544. } upb_table;
  545. typedef struct {
  546. upb_table t;
  547. } upb_strtable;
  548. typedef struct {
  549. upb_table t; /* For entries that don't fit in the array part. */
  550. const upb_tabval *array; /* Array part of the table. See const note above. */
  551. size_t array_size; /* Array part size. */
  552. size_t array_count; /* Array part number of elements. */
  553. } upb_inttable;
  554. #define UPB_ARRAY_EMPTYENT -1
  555. UPB_INLINE size_t upb_table_size(const upb_table *t) {
  556. if (t->size_lg2 == 0)
  557. return 0;
  558. else
  559. return 1 << t->size_lg2;
  560. }
  561. /* Internal-only functions, in .h file only out of necessity. */
  562. UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) {
  563. return e->key == 0;
  564. }
  565. /* Used by some of the unit tests for generic hashing functionality. */
  566. uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed);
  567. UPB_INLINE uintptr_t upb_intkey(uintptr_t key) {
  568. return key;
  569. }
  570. UPB_INLINE uint32_t upb_inthash(uintptr_t key) {
  571. return (uint32_t)key;
  572. }
  573. static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
  574. return t->entries + (hash & t->mask);
  575. }
  576. UPB_INLINE bool upb_arrhas(upb_tabval key) {
  577. return key.val != (uint64_t)-1;
  578. }
  579. /* Initialize and uninitialize a table, respectively. If memory allocation
  580. * failed, false is returned that the table is uninitialized. */
  581. bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a);
  582. bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a);
  583. void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a);
  584. void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a);
  585. UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
  586. return upb_inttable_init2(table, ctype, &upb_alloc_global);
  587. }
  588. UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
  589. return upb_strtable_init2(table, ctype, &upb_alloc_global);
  590. }
  591. UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
  592. upb_inttable_uninit2(table, &upb_alloc_global);
  593. }
  594. UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
  595. upb_strtable_uninit2(table, &upb_alloc_global);
  596. }
  597. /* Returns the number of values in the table. */
  598. size_t upb_inttable_count(const upb_inttable *t);
  599. UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
  600. return t->t.count;
  601. }
  602. void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
  603. void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
  604. upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
  605. size_t size);
  606. upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
  607. size_t size);
  608. void upb_strtable_clear(upb_strtable *t);
  609. /* Inserts the given key into the hashtable with the given value. The key must
  610. * not already exist in the hash table. For string tables, the key must be
  611. * NULL-terminated, and the table will make an internal copy of the key.
  612. * Inttables must not insert a value of UINTPTR_MAX.
  613. *
  614. * If a table resize was required but memory allocation failed, false is
  615. * returned and the table is unchanged. */
  616. bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
  617. upb_alloc *a);
  618. bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len,
  619. upb_value val, upb_alloc *a);
  620. UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
  621. upb_value val) {
  622. return upb_inttable_insert2(t, key, val, &upb_alloc_global);
  623. }
  624. UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
  625. size_t len, upb_value val) {
  626. return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
  627. }
  628. /* For NULL-terminated strings. */
  629. UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
  630. upb_value val) {
  631. return upb_strtable_insert2(t, key, strlen(key), val);
  632. }
  633. /* Looks up key in this table, returning "true" if the key was found.
  634. * If v is non-NULL, copies the value for this key into *v. */
  635. bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v);
  636. bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
  637. upb_value *v);
  638. /* For NULL-terminated strings. */
  639. UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
  640. upb_value *v) {
  641. return upb_strtable_lookup2(t, key, strlen(key), v);
  642. }
  643. /* Removes an item from the table. Returns true if the remove was successful,
  644. * and stores the removed item in *val if non-NULL. */
  645. bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
  646. bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
  647. upb_value *val, upb_alloc *alloc);
  648. UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
  649. size_t len, upb_value *val) {
  650. return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
  651. }
  652. /* For NULL-terminated strings. */
  653. UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
  654. upb_value *v) {
  655. return upb_strtable_remove2(t, key, strlen(key), v);
  656. }
  657. /* Updates an existing entry in an inttable. If the entry does not exist,
  658. * returns false and does nothing. Unlike insert/remove, this does not
  659. * invalidate iterators. */
  660. bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
  661. /* Handy routines for treating an inttable like a stack. May not be mixed with
  662. * other insert/remove calls. */
  663. bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a);
  664. upb_value upb_inttable_pop(upb_inttable *t);
  665. UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) {
  666. return upb_inttable_push2(t, val, &upb_alloc_global);
  667. }
  668. /* Convenience routines for inttables with pointer keys. */
  669. bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
  670. upb_alloc *a);
  671. bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
  672. bool upb_inttable_lookupptr(
  673. const upb_inttable *t, const void *key, upb_value *val);
  674. UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
  675. upb_value val) {
  676. return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
  677. }
  678. /* Optimizes the table for the current set of entries, for both memory use and
  679. * lookup time. Client should call this after all entries have been inserted;
  680. * inserting more entries is legal, but will likely require a table resize. */
  681. void upb_inttable_compact2(upb_inttable *t, upb_alloc *a);
  682. UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
  683. upb_inttable_compact2(t, &upb_alloc_global);
  684. }
  685. /* A special-case inlinable version of the lookup routine for 32-bit
  686. * integers. */
  687. UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
  688. upb_value *v) {
  689. *v = upb_value_int32(0); /* Silence compiler warnings. */
  690. if (key < t->array_size) {
  691. upb_tabval arrval = t->array[key];
  692. if (upb_arrhas(arrval)) {
  693. _upb_value_setval(v, arrval.val);
  694. return true;
  695. } else {
  696. return false;
  697. }
  698. } else {
  699. const upb_tabent *e;
  700. if (t->t.entries == NULL) return false;
  701. for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
  702. if ((uint32_t)e->key == key) {
  703. _upb_value_setval(v, e->val.val);
  704. return true;
  705. }
  706. if (e->next == NULL) return false;
  707. }
  708. }
  709. }
  710. /* Exposed for testing only. */
  711. bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a);
  712. /* Iterators ******************************************************************/
  713. /* Iterators for int and string tables. We are subject to some kind of unusual
  714. * design constraints:
  715. *
  716. * For high-level languages:
  717. * - we must be able to guarantee that we don't crash or corrupt memory even if
  718. * the program accesses an invalidated iterator.
  719. *
  720. * For C++11 range-based for:
  721. * - iterators must be copyable
  722. * - iterators must be comparable
  723. * - it must be possible to construct an "end" value.
  724. *
  725. * Iteration order is undefined.
  726. *
  727. * Modifying the table invalidates iterators. upb_{str,int}table_done() is
  728. * guaranteed to work even on an invalidated iterator, as long as the table it
  729. * is iterating over has not been freed. Calling next() or accessing data from
  730. * an invalidated iterator yields unspecified elements from the table, but it is
  731. * guaranteed not to crash and to return real table elements (except when done()
  732. * is true). */
  733. /* upb_strtable_iter **********************************************************/
  734. /* upb_strtable_iter i;
  735. * upb_strtable_begin(&i, t);
  736. * for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
  737. * const char *key = upb_strtable_iter_key(&i);
  738. * const upb_value val = upb_strtable_iter_value(&i);
  739. * // ...
  740. * }
  741. */
  742. typedef struct {
  743. const upb_strtable *t;
  744. size_t index;
  745. } upb_strtable_iter;
  746. void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t);
  747. void upb_strtable_next(upb_strtable_iter *i);
  748. bool upb_strtable_done(const upb_strtable_iter *i);
  749. upb_strview upb_strtable_iter_key(const upb_strtable_iter *i);
  750. upb_value upb_strtable_iter_value(const upb_strtable_iter *i);
  751. void upb_strtable_iter_setdone(upb_strtable_iter *i);
  752. bool upb_strtable_iter_isequal(const upb_strtable_iter *i1,
  753. const upb_strtable_iter *i2);
  754. /* upb_inttable_iter **********************************************************/
  755. /* upb_inttable_iter i;
  756. * upb_inttable_begin(&i, t);
  757. * for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
  758. * uintptr_t key = upb_inttable_iter_key(&i);
  759. * upb_value val = upb_inttable_iter_value(&i);
  760. * // ...
  761. * }
  762. */
  763. typedef struct {
  764. const upb_inttable *t;
  765. size_t index;
  766. bool array_part;
  767. } upb_inttable_iter;
  768. UPB_INLINE const upb_tabent *str_tabent(const upb_strtable_iter *i) {
  769. return &i->t->t.entries[i->index];
  770. }
  771. void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t);
  772. void upb_inttable_next(upb_inttable_iter *i);
  773. bool upb_inttable_done(const upb_inttable_iter *i);
  774. uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i);
  775. upb_value upb_inttable_iter_value(const upb_inttable_iter *i);
  776. void upb_inttable_iter_setdone(upb_inttable_iter *i);
  777. bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
  778. const upb_inttable_iter *i2);
  779. #ifdef __cplusplus
  780. } /* extern "C" */
  781. #endif
  782. #endif /* UPB_TABLE_H_ */
  783. #ifdef __cplusplus
  784. extern "C" {
  785. #endif
  786. #define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
  787. typedef void upb_msg;
  788. /** upb_msglayout *************************************************************/
  789. /* upb_msglayout represents the memory layout of a given upb_msgdef. The
  790. * members are public so generated code can initialize them, but users MUST NOT
  791. * read or write any of its members. */
  792. /* These aren't real labels according to descriptor.proto, but in the table we
  793. * use these for map/packed fields instead of UPB_LABEL_REPEATED. */
  794. enum {
  795. _UPB_LABEL_MAP = 4,
  796. _UPB_LABEL_PACKED = 7 /* Low 3 bits are common with UPB_LABEL_REPEATED. */
  797. };
  798. typedef struct {
  799. uint32_t number;
  800. uint16_t offset;
  801. int16_t presence; /* If >0, hasbit_index. If <0, ~oneof_index. */
  802. uint16_t submsg_index; /* undefined if descriptortype != MESSAGE or GROUP. */
  803. uint8_t descriptortype;
  804. uint8_t label; /* google.protobuf.Label or _UPB_LABEL_* above. */
  805. } upb_msglayout_field;
  806. typedef struct upb_msglayout {
  807. const struct upb_msglayout *const* submsgs;
  808. const upb_msglayout_field *fields;
  809. /* Must be aligned to sizeof(void*). Doesn't include internal members like
  810. * unknown fields, extension dict, pointer to msglayout, etc. */
  811. uint16_t size;
  812. uint16_t field_count;
  813. bool extendable;
  814. } upb_msglayout;
  815. /** upb_msg *******************************************************************/
  816. /* Internal members of a upb_msg. We can change this without breaking binary
  817. * compatibility. We put these before the user's data. The user's upb_msg*
  818. * points after the upb_msg_internal. */
  819. /* Used when a message is not extendable. */
  820. typedef struct {
  821. char *unknown;
  822. size_t unknown_len;
  823. size_t unknown_size;
  824. } upb_msg_internal;
  825. /* Used when a message is extendable. */
  826. typedef struct {
  827. upb_inttable *extdict;
  828. upb_msg_internal base;
  829. } upb_msg_internal_withext;
  830. /* Maps upb_fieldtype_t -> memory size. */
  831. extern char _upb_fieldtype_to_size[12];
  832. /* Creates a new messages with the given layout on the given arena. */
  833. upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a);
  834. /* Clears the given message. */
  835. void _upb_msg_clear(upb_msg *msg, const upb_msglayout *l);
  836. /* Discards the unknown fields for this message only. */
  837. void _upb_msg_discardunknown_shallow(upb_msg *msg);
  838. /* Adds unknown data (serialized protobuf data) to the given message. The data
  839. * is copied into the message instance. */
  840. bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
  841. upb_arena *arena);
  842. /* Returns a reference to the message's unknown data. */
  843. const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
  844. /** Hasbit access *************************************************************/
  845. UPB_INLINE bool _upb_hasbit(const upb_msg *msg, size_t idx) {
  846. return (*PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
  847. }
  848. UPB_INLINE void _upb_sethas(const upb_msg *msg, size_t idx) {
  849. (*PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
  850. }
  851. UPB_INLINE void _upb_clearhas(const upb_msg *msg, size_t idx) {
  852. (*PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
  853. }
  854. UPB_INLINE size_t _upb_msg_hasidx(const upb_msglayout_field *f) {
  855. UPB_ASSERT(f->presence > 0);
  856. return f->presence;
  857. }
  858. UPB_INLINE bool _upb_hasbit_field(const upb_msg *msg,
  859. const upb_msglayout_field *f) {
  860. return _upb_hasbit(msg, _upb_msg_hasidx(f));
  861. }
  862. UPB_INLINE void _upb_sethas_field(const upb_msg *msg,
  863. const upb_msglayout_field *f) {
  864. _upb_sethas(msg, _upb_msg_hasidx(f));
  865. }
  866. UPB_INLINE void _upb_clearhas_field(const upb_msg *msg,
  867. const upb_msglayout_field *f) {
  868. _upb_clearhas(msg, _upb_msg_hasidx(f));
  869. }
  870. /** Oneof case access *********************************************************/
  871. UPB_INLINE uint32_t *_upb_oneofcase(upb_msg *msg, size_t case_ofs) {
  872. return PTR_AT(msg, case_ofs, uint32_t);
  873. }
  874. UPB_INLINE uint32_t _upb_getoneofcase(const void *msg, size_t case_ofs) {
  875. return *PTR_AT(msg, case_ofs, uint32_t);
  876. }
  877. UPB_INLINE size_t _upb_oneofcase_ofs(const upb_msglayout_field *f) {
  878. UPB_ASSERT(f->presence < 0);
  879. return ~(int64_t)f->presence;
  880. }
  881. UPB_INLINE uint32_t *_upb_oneofcase_field(upb_msg *msg,
  882. const upb_msglayout_field *f) {
  883. return _upb_oneofcase(msg, _upb_oneofcase_ofs(f));
  884. }
  885. UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_msg *msg,
  886. const upb_msglayout_field *f) {
  887. return _upb_getoneofcase(msg, _upb_oneofcase_ofs(f));
  888. }
  889. UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_msg *msg, size_t ofs) {
  890. return *PTR_AT(msg, ofs, const upb_msg*) != NULL;
  891. }
  892. UPB_INLINE bool _upb_isrepeated(const upb_msglayout_field *field) {
  893. return (field->label & 3) == UPB_LABEL_REPEATED;
  894. }
  895. UPB_INLINE bool _upb_repeated_or_map(const upb_msglayout_field *field) {
  896. return field->label >= UPB_LABEL_REPEATED;
  897. }
  898. /** upb_array *****************************************************************/
  899. /* Our internal representation for repeated fields. */
  900. typedef struct {
  901. uintptr_t data; /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */
  902. size_t len; /* Measured in elements. */
  903. size_t size; /* Measured in elements. */
  904. } upb_array;
  905. UPB_INLINE const void *_upb_array_constptr(const upb_array *arr) {
  906. return (void*)(arr->data & ~(uintptr_t)7);
  907. }
  908. UPB_INLINE void *_upb_array_ptr(upb_array *arr) {
  909. return (void*)_upb_array_constptr(arr);
  910. }
  911. /* Creates a new array on the given arena. */
  912. upb_array *_upb_array_new(upb_arena *a, upb_fieldtype_t type);
  913. /* Resizes the capacity of the array to be at least min_size. */
  914. bool _upb_array_realloc(upb_array *arr, size_t min_size, upb_arena *arena);
  915. /* Fallback functions for when the accessors require a resize. */
  916. void *_upb_array_resize_fallback(upb_array **arr_ptr, size_t size,
  917. upb_fieldtype_t type, upb_arena *arena);
  918. bool _upb_array_append_fallback(upb_array **arr_ptr, const void *value,
  919. upb_fieldtype_t type, upb_arena *arena);
  920. UPB_INLINE bool _upb_array_reserve(upb_array *arr, size_t size,
  921. upb_arena *arena) {
  922. if (arr->size < size) return _upb_array_realloc(arr, size, arena);
  923. return true;
  924. }
  925. UPB_INLINE bool _upb_array_resize(upb_array *arr, size_t size,
  926. upb_arena *arena) {
  927. if (!_upb_array_reserve(arr, size, arena)) return false;
  928. arr->len = size;
  929. return true;
  930. }
  931. UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
  932. size_t *size) {
  933. const upb_array *arr = *PTR_AT(msg, ofs, const upb_array*);
  934. if (arr) {
  935. if (size) *size = arr->len;
  936. return _upb_array_constptr(arr);
  937. } else {
  938. if (size) *size = 0;
  939. return NULL;
  940. }
  941. }
  942. UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
  943. size_t *size) {
  944. upb_array *arr = *PTR_AT(msg, ofs, upb_array*);
  945. if (arr) {
  946. if (size) *size = arr->len;
  947. return _upb_array_ptr(arr);
  948. } else {
  949. if (size) *size = 0;
  950. return NULL;
  951. }
  952. }
  953. UPB_INLINE void *_upb_array_resize_accessor(void *msg, size_t ofs, size_t size,
  954. upb_fieldtype_t type,
  955. upb_arena *arena) {
  956. upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array*);
  957. upb_array *arr = *arr_ptr;
  958. if (!arr || arr->size < size) {
  959. return _upb_array_resize_fallback(arr_ptr, size, type, arena);
  960. }
  961. arr->len = size;
  962. return _upb_array_ptr(arr);
  963. }
  964. UPB_INLINE bool _upb_array_append_accessor(void *msg, size_t ofs,
  965. size_t elem_size,
  966. upb_fieldtype_t type,
  967. const void *value,
  968. upb_arena *arena) {
  969. upb_array **arr_ptr = PTR_AT(msg, ofs, upb_array*);
  970. upb_array *arr = *arr_ptr;
  971. void* ptr;
  972. if (!arr || arr->len == arr->size) {
  973. return _upb_array_append_fallback(arr_ptr, value, type, arena);
  974. }
  975. ptr = _upb_array_ptr(arr);
  976. memcpy(PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
  977. arr->len++;
  978. return true;
  979. }
  980. /** upb_map *******************************************************************/
  981. /* Right now we use strmaps for everything. We'll likely want to use
  982. * integer-specific maps for integer-keyed maps.*/
  983. typedef struct {
  984. /* Size of key and val, based on the map type. Strings are represented as '0'
  985. * because they must be handled specially. */
  986. char key_size;
  987. char val_size;
  988. upb_strtable table;
  989. } upb_map;
  990. /* Map entries aren't actually stored, they are only used during parsing. For
  991. * parsing, it helps a lot if all map entry messages have the same layout.
  992. * The compiler and def.c must ensure that all map entries have this layout. */
  993. typedef struct {
  994. upb_msg_internal internal;
  995. union {
  996. upb_strview str; /* For str/bytes. */
  997. upb_value val; /* For all other types. */
  998. } k;
  999. union {
  1000. upb_strview str; /* For str/bytes. */
  1001. upb_value val; /* For all other types. */
  1002. } v;
  1003. } upb_map_entry;
  1004. /* Creates a new map on the given arena with this key/value type. */
  1005. upb_map *_upb_map_new(upb_arena *a, size_t key_size, size_t value_size);
  1006. /* Converting between internal table representation and user values.
  1007. *
  1008. * _upb_map_tokey() and _upb_map_fromkey() are inverses.
  1009. * _upb_map_tovalue() and _upb_map_fromvalue() are inverses.
  1010. *
  1011. * These functions account for the fact that strings are treated differently
  1012. * from other types when stored in a map.
  1013. */
  1014. UPB_INLINE upb_strview _upb_map_tokey(const void *key, size_t size) {
  1015. if (size == UPB_MAPTYPE_STRING) {
  1016. return *(upb_strview*)key;
  1017. } else {
  1018. return upb_strview_make((const char*)key, size);
  1019. }
  1020. }
  1021. UPB_INLINE void _upb_map_fromkey(upb_strview key, void* out, size_t size) {
  1022. if (size == UPB_MAPTYPE_STRING) {
  1023. memcpy(out, &key, sizeof(key));
  1024. } else {
  1025. memcpy(out, key.data, size);
  1026. }
  1027. }
  1028. UPB_INLINE upb_value _upb_map_tovalue(const void *val, size_t size,
  1029. upb_arena *a) {
  1030. upb_value ret = {0};
  1031. if (size == UPB_MAPTYPE_STRING) {
  1032. upb_strview *strp = (upb_strview*)upb_arena_malloc(a, sizeof(*strp));
  1033. *strp = *(upb_strview*)val;
  1034. memcpy(&ret, &strp, sizeof(strp));
  1035. } else {
  1036. memcpy(&ret, val, size);
  1037. }
  1038. return ret;
  1039. }
  1040. UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
  1041. if (size == UPB_MAPTYPE_STRING) {
  1042. const upb_strview *strp = (const upb_strview*)upb_value_getptr(val);
  1043. memcpy(out, strp, sizeof(upb_strview));
  1044. } else {
  1045. memcpy(out, &val, size);
  1046. }
  1047. }
  1048. /* Map operations, shared by reflection and generated code. */
  1049. UPB_INLINE size_t _upb_map_size(const upb_map *map) {
  1050. return map->table.t.count;
  1051. }
  1052. UPB_INLINE bool _upb_map_get(const upb_map *map, const void *key,
  1053. size_t key_size, void *val, size_t val_size) {
  1054. upb_value tabval;
  1055. upb_strview k = _upb_map_tokey(key, key_size);
  1056. bool ret = upb_strtable_lookup2(&map->table, k.data, k.size, &tabval);
  1057. if (ret && val) {
  1058. _upb_map_fromvalue(tabval, val, val_size);
  1059. }
  1060. return ret;
  1061. }
  1062. UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
  1063. upb_strtable_iter it;
  1064. it.t = &map->table;
  1065. it.index = *iter;
  1066. upb_strtable_next(&it);
  1067. *iter = it.index;
  1068. if (upb_strtable_done(&it)) return NULL;
  1069. return (void*)str_tabent(&it);
  1070. }
  1071. UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size,
  1072. void *val, size_t val_size, upb_arena *arena) {
  1073. upb_strview strkey = _upb_map_tokey(key, key_size);
  1074. upb_value tabval = _upb_map_tovalue(val, val_size, arena);
  1075. upb_alloc *a = upb_arena_alloc(arena);
  1076. /* TODO(haberman): add overwrite operation to minimize number of lookups. */
  1077. upb_strtable_remove3(&map->table, strkey.data, strkey.size, NULL, a);
  1078. return upb_strtable_insert3(&map->table, strkey.data, strkey.size, tabval, a);
  1079. }
  1080. UPB_INLINE bool _upb_map_delete(upb_map *map, const void *key, size_t key_size) {
  1081. upb_strview k = _upb_map_tokey(key, key_size);
  1082. return upb_strtable_remove3(&map->table, k.data, k.size, NULL, NULL);
  1083. }
  1084. UPB_INLINE void _upb_map_clear(upb_map *map) {
  1085. upb_strtable_clear(&map->table);
  1086. }
  1087. /* Message map operations, these get the map from the message first. */
  1088. UPB_INLINE size_t _upb_msg_map_size(const upb_msg *msg, size_t ofs) {
  1089. upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
  1090. return map ? _upb_map_size(map) : 0;
  1091. }
  1092. UPB_INLINE bool _upb_msg_map_get(const upb_msg *msg, size_t ofs,
  1093. const void *key, size_t key_size, void *val,
  1094. size_t val_size) {
  1095. upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
  1096. if (!map) return false;
  1097. return _upb_map_get(map, key, key_size, val, val_size);
  1098. }
  1099. UPB_INLINE void *_upb_msg_map_next(const upb_msg *msg, size_t ofs,
  1100. size_t *iter) {
  1101. upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
  1102. if (!map) return NULL;
  1103. return _upb_map_next(map, iter);
  1104. }
  1105. UPB_INLINE bool _upb_msg_map_set(upb_msg *msg, size_t ofs, const void *key,
  1106. size_t key_size, void *val, size_t val_size,
  1107. upb_arena *arena) {
  1108. upb_map **map = PTR_AT(msg, ofs, upb_map *);
  1109. if (!*map) {
  1110. *map = _upb_map_new(arena, key_size, val_size);
  1111. }
  1112. return _upb_map_set(*map, key, key_size, val, val_size, arena);
  1113. }
  1114. UPB_INLINE bool _upb_msg_map_delete(upb_msg *msg, size_t ofs, const void *key,
  1115. size_t key_size) {
  1116. upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
  1117. if (!map) return false;
  1118. return _upb_map_delete(map, key, key_size);
  1119. }
  1120. UPB_INLINE void _upb_msg_map_clear(upb_msg *msg, size_t ofs) {
  1121. upb_map *map = *UPB_PTR_AT(msg, ofs, upb_map *);
  1122. if (!map) return;
  1123. _upb_map_clear(map);
  1124. }
  1125. /* Accessing map key/value from a pointer, used by generated code only. */
  1126. UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
  1127. const upb_tabent *ent = (const upb_tabent*)msg;
  1128. uint32_t u32len;
  1129. upb_strview k;
  1130. k.data = upb_tabstr(ent->key, &u32len);
  1131. k.size = u32len;
  1132. _upb_map_fromkey(k, key, size);
  1133. }
  1134. UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
  1135. const upb_tabent *ent = (const upb_tabent*)msg;
  1136. upb_value v;
  1137. _upb_value_setval(&v, ent->val.val);
  1138. _upb_map_fromvalue(v, val, size);
  1139. }
  1140. UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val, size_t size) {
  1141. upb_tabent *ent = (upb_tabent*)msg;
  1142. /* This is like _upb_map_tovalue() except the entry already exists so we can
  1143. * reuse the allocated upb_strview for string fields. */
  1144. if (size == UPB_MAPTYPE_STRING) {
  1145. upb_strview *strp = (upb_strview*)ent->val.val;
  1146. memcpy(strp, val, sizeof(*strp));
  1147. } else {
  1148. memcpy(&ent->val.val, val, size);
  1149. }
  1150. }
  1151. #undef PTR_AT
  1152. #ifdef __cplusplus
  1153. } /* extern "C" */
  1154. #endif
  1155. #endif /* UPB_MSG_H_ */
  1156. #ifdef __cplusplus
  1157. extern "C" {
  1158. #endif
  1159. bool upb_decode(const char *buf, size_t size, upb_msg *msg,
  1160. const upb_msglayout *l, upb_arena *arena);
  1161. #ifdef __cplusplus
  1162. } /* extern "C" */
  1163. #endif
  1164. #endif /* UPB_DECODE_H_ */
  1165. /*
  1166. ** upb_encode: parsing into a upb_msg using a upb_msglayout.
  1167. */
  1168. #ifndef UPB_ENCODE_H_
  1169. #define UPB_ENCODE_H_
  1170. #ifdef __cplusplus
  1171. extern "C" {
  1172. #endif
  1173. char *upb_encode(const void *msg, const upb_msglayout *l, upb_arena *arena,
  1174. size_t *size);
  1175. #ifdef __cplusplus
  1176. } /* extern "C" */
  1177. #endif
  1178. #endif /* UPB_ENCODE_H_ */
  1179. /* This file was generated by upbc (the upb compiler) from the input
  1180. * file:
  1181. *
  1182. * google/protobuf/descriptor.proto
  1183. *
  1184. * Do not edit -- your changes will be discarded when the file is
  1185. * regenerated. */
  1186. #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
  1187. #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
  1188. #ifdef __cplusplus
  1189. extern "C" {
  1190. #endif
  1191. struct google_protobuf_FileDescriptorSet;
  1192. struct google_protobuf_FileDescriptorProto;
  1193. struct google_protobuf_DescriptorProto;
  1194. struct google_protobuf_DescriptorProto_ExtensionRange;
  1195. struct google_protobuf_DescriptorProto_ReservedRange;
  1196. struct google_protobuf_ExtensionRangeOptions;
  1197. struct google_protobuf_FieldDescriptorProto;
  1198. struct google_protobuf_OneofDescriptorProto;
  1199. struct google_protobuf_EnumDescriptorProto;
  1200. struct google_protobuf_EnumDescriptorProto_EnumReservedRange;
  1201. struct google_protobuf_EnumValueDescriptorProto;
  1202. struct google_protobuf_ServiceDescriptorProto;
  1203. struct google_protobuf_MethodDescriptorProto;
  1204. struct google_protobuf_FileOptions;
  1205. struct google_protobuf_MessageOptions;
  1206. struct google_protobuf_FieldOptions;
  1207. struct google_protobuf_OneofOptions;
  1208. struct google_protobuf_EnumOptions;
  1209. struct google_protobuf_EnumValueOptions;
  1210. struct google_protobuf_ServiceOptions;
  1211. struct google_protobuf_MethodOptions;
  1212. struct google_protobuf_UninterpretedOption;
  1213. struct google_protobuf_UninterpretedOption_NamePart;
  1214. struct google_protobuf_SourceCodeInfo;
  1215. struct google_protobuf_SourceCodeInfo_Location;
  1216. struct google_protobuf_GeneratedCodeInfo;
  1217. struct google_protobuf_GeneratedCodeInfo_Annotation;
  1218. typedef struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet;
  1219. typedef struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto;
  1220. typedef struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto;
  1221. typedef struct google_protobuf_DescriptorProto_ExtensionRange google_protobuf_DescriptorProto_ExtensionRange;
  1222. typedef struct google_protobuf_DescriptorProto_ReservedRange google_protobuf_DescriptorProto_ReservedRange;
  1223. typedef struct google_protobuf_ExtensionRangeOptions google_protobuf_ExtensionRangeOptions;
  1224. typedef struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto;
  1225. typedef struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto;
  1226. typedef struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto;
  1227. typedef struct google_protobuf_EnumDescriptorProto_EnumReservedRange google_protobuf_EnumDescriptorProto_EnumReservedRange;
  1228. typedef struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto;
  1229. typedef struct google_protobuf_ServiceDescriptorProto google_protobuf_ServiceDescriptorProto;
  1230. typedef struct google_protobuf_MethodDescriptorProto google_protobuf_MethodDescriptorProto;
  1231. typedef struct google_protobuf_FileOptions google_protobuf_FileOptions;
  1232. typedef struct google_protobuf_MessageOptions google_protobuf_MessageOptions;
  1233. typedef struct google_protobuf_FieldOptions google_protobuf_FieldOptions;
  1234. typedef struct google_protobuf_OneofOptions google_protobuf_OneofOptions;
  1235. typedef struct google_protobuf_EnumOptions google_protobuf_EnumOptions;
  1236. typedef struct google_protobuf_EnumValueOptions google_protobuf_EnumValueOptions;
  1237. typedef struct google_protobuf_ServiceOptions google_protobuf_ServiceOptions;
  1238. typedef struct google_protobuf_MethodOptions google_protobuf_MethodOptions;
  1239. typedef struct google_protobuf_UninterpretedOption google_protobuf_UninterpretedOption;
  1240. typedef struct google_protobuf_UninterpretedOption_NamePart google_protobuf_UninterpretedOption_NamePart;
  1241. typedef struct google_protobuf_SourceCodeInfo google_protobuf_SourceCodeInfo;
  1242. typedef struct google_protobuf_SourceCodeInfo_Location google_protobuf_SourceCodeInfo_Location;
  1243. typedef struct google_protobuf_GeneratedCodeInfo google_protobuf_GeneratedCodeInfo;
  1244. typedef struct google_protobuf_GeneratedCodeInfo_Annotation google_protobuf_GeneratedCodeInfo_Annotation;
  1245. extern const upb_msglayout google_protobuf_FileDescriptorSet_msginit;
  1246. extern const upb_msglayout google_protobuf_FileDescriptorProto_msginit;
  1247. extern const upb_msglayout google_protobuf_DescriptorProto_msginit;
  1248. extern const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit;
  1249. extern const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit;
  1250. extern const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit;
  1251. extern const upb_msglayout google_protobuf_FieldDescriptorProto_msginit;
  1252. extern const upb_msglayout google_protobuf_OneofDescriptorProto_msginit;
  1253. extern const upb_msglayout google_protobuf_EnumDescriptorProto_msginit;
  1254. extern const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit;
  1255. extern const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit;
  1256. extern const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit;
  1257. extern const upb_msglayout google_protobuf_MethodDescriptorProto_msginit;
  1258. extern const upb_msglayout google_protobuf_FileOptions_msginit;
  1259. extern const upb_msglayout google_protobuf_MessageOptions_msginit;
  1260. extern const upb_msglayout google_protobuf_FieldOptions_msginit;
  1261. extern const upb_msglayout google_protobuf_OneofOptions_msginit;
  1262. extern const upb_msglayout google_protobuf_EnumOptions_msginit;
  1263. extern const upb_msglayout google_protobuf_EnumValueOptions_msginit;
  1264. extern const upb_msglayout google_protobuf_ServiceOptions_msginit;
  1265. extern const upb_msglayout google_protobuf_MethodOptions_msginit;
  1266. extern const upb_msglayout google_protobuf_UninterpretedOption_msginit;
  1267. extern const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit;
  1268. extern const upb_msglayout google_protobuf_SourceCodeInfo_msginit;
  1269. extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit;
  1270. extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit;
  1271. extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit;
  1272. typedef enum {
  1273. google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
  1274. google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
  1275. google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
  1276. } google_protobuf_FieldDescriptorProto_Label;
  1277. typedef enum {
  1278. google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
  1279. google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
  1280. google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
  1281. google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
  1282. google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
  1283. google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
  1284. google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
  1285. google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
  1286. google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
  1287. google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
  1288. google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
  1289. google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
  1290. google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
  1291. google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
  1292. google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
  1293. google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
  1294. google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
  1295. google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
  1296. } google_protobuf_FieldDescriptorProto_Type;
  1297. typedef enum {
  1298. google_protobuf_FieldOptions_STRING = 0,
  1299. google_protobuf_FieldOptions_CORD = 1,
  1300. google_protobuf_FieldOptions_STRING_PIECE = 2
  1301. } google_protobuf_FieldOptions_CType;
  1302. typedef enum {
  1303. google_protobuf_FieldOptions_JS_NORMAL = 0,
  1304. google_protobuf_FieldOptions_JS_STRING = 1,
  1305. google_protobuf_FieldOptions_JS_NUMBER = 2
  1306. } google_protobuf_FieldOptions_JSType;
  1307. typedef enum {
  1308. google_protobuf_FileOptions_SPEED = 1,
  1309. google_protobuf_FileOptions_CODE_SIZE = 2,
  1310. google_protobuf_FileOptions_LITE_RUNTIME = 3
  1311. } google_protobuf_FileOptions_OptimizeMode;
  1312. typedef enum {
  1313. google_protobuf_MethodOptions_IDEMPOTENCY_UNKNOWN = 0,
  1314. google_protobuf_MethodOptions_NO_SIDE_EFFECTS = 1,
  1315. google_protobuf_MethodOptions_IDEMPOTENT = 2
  1316. } google_protobuf_MethodOptions_IdempotencyLevel;
  1317. /* google.protobuf.FileDescriptorSet */
  1318. UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_new(upb_arena *arena) {
  1319. return (google_protobuf_FileDescriptorSet *)_upb_msg_new(&google_protobuf_FileDescriptorSet_msginit, arena);
  1320. }
  1321. UPB_INLINE google_protobuf_FileDescriptorSet *google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size,
  1322. upb_arena *arena) {
  1323. google_protobuf_FileDescriptorSet *ret = google_protobuf_FileDescriptorSet_new(arena);
  1324. return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorSet_msginit, arena)) ? ret : NULL;
  1325. }
  1326. UPB_INLINE char *google_protobuf_FileDescriptorSet_serialize(const google_protobuf_FileDescriptorSet *msg, upb_arena *arena, size_t *len) {
  1327. return upb_encode(msg, &google_protobuf_FileDescriptorSet_msginit, arena, len);
  1328. }
  1329. UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
  1330. UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len) { return (const google_protobuf_FileDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
  1331. UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_mutable_file(google_protobuf_FileDescriptorSet *msg, size_t *len) {
  1332. return (google_protobuf_FileDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
  1333. }
  1334. UPB_INLINE google_protobuf_FileDescriptorProto** google_protobuf_FileDescriptorSet_resize_file(google_protobuf_FileDescriptorSet *msg, size_t len, upb_arena *arena) {
  1335. return (google_protobuf_FileDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
  1336. }
  1337. UPB_INLINE struct google_protobuf_FileDescriptorProto* google_protobuf_FileDescriptorSet_add_file(google_protobuf_FileDescriptorSet *msg, upb_arena *arena) {
  1338. struct google_protobuf_FileDescriptorProto* sub = (struct google_protobuf_FileDescriptorProto*)_upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
  1339. bool ok = _upb_array_append_accessor(
  1340. msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1341. if (!ok) return NULL;
  1342. return sub;
  1343. }
  1344. /* google.protobuf.FileDescriptorProto */
  1345. UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_new(upb_arena *arena) {
  1346. return (google_protobuf_FileDescriptorProto *)_upb_msg_new(&google_protobuf_FileDescriptorProto_msginit, arena);
  1347. }
  1348. UPB_INLINE google_protobuf_FileDescriptorProto *google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size,
  1349. upb_arena *arena) {
  1350. google_protobuf_FileDescriptorProto *ret = google_protobuf_FileDescriptorProto_new(arena);
  1351. return (ret && upb_decode(buf, size, ret, &google_protobuf_FileDescriptorProto_msginit, arena)) ? ret : NULL;
  1352. }
  1353. UPB_INLINE char *google_protobuf_FileDescriptorProto_serialize(const google_protobuf_FileDescriptorProto *msg, upb_arena *arena, size_t *len) {
  1354. return upb_encode(msg, &google_protobuf_FileDescriptorProto_msginit, arena, len);
  1355. }
  1356. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1357. UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  1358. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1359. UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_package(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
  1360. UPB_INLINE upb_strview const* google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
  1361. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(40, 80)); }
  1362. UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
  1363. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(44, 88)); }
  1364. UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
  1365. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(48, 96)); }
  1366. UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_FileDescriptorProto_service(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_ServiceDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(48, 96), len); }
  1367. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(52, 104)); }
  1368. UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(52, 104), len); }
  1369. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_options(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 4); }
  1370. UPB_INLINE const google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_FileOptions*); }
  1371. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 5); }
  1372. UPB_INLINE const google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_source_code_info(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const google_protobuf_SourceCodeInfo*); }
  1373. UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(56, 112), len); }
  1374. UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(60, 120), len); }
  1375. UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg) { return _upb_hasbit(msg, 3); }
  1376. UPB_INLINE upb_strview google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
  1377. UPB_INLINE void google_protobuf_FileDescriptorProto_set_name(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
  1378. _upb_sethas(msg, 1);
  1379. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  1380. }
  1381. UPB_INLINE void google_protobuf_FileDescriptorProto_set_package(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
  1382. _upb_sethas(msg, 2);
  1383. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
  1384. }
  1385. UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_mutable_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1386. return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
  1387. }
  1388. UPB_INLINE upb_strview* google_protobuf_FileDescriptorProto_resize_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1389. return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_TYPE_STRING, arena);
  1390. }
  1391. UPB_INLINE bool google_protobuf_FileDescriptorProto_add_dependency(google_protobuf_FileDescriptorProto *msg, upb_strview val, upb_arena *arena) {
  1392. return _upb_array_append_accessor(msg, UPB_SIZE(36, 72), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
  1393. arena);
  1394. }
  1395. UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_mutable_message_type(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1396. return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len);
  1397. }
  1398. UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_FileDescriptorProto_resize_message_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1399. return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_TYPE_MESSAGE, arena);
  1400. }
  1401. UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_FileDescriptorProto_add_message_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1402. struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
  1403. bool ok = _upb_array_append_accessor(
  1404. msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1405. if (!ok) return NULL;
  1406. return sub;
  1407. }
  1408. UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_mutable_enum_type(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1409. return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len);
  1410. }
  1411. UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_FileDescriptorProto_resize_enum_type(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1412. return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_TYPE_MESSAGE, arena);
  1413. }
  1414. UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_FileDescriptorProto_add_enum_type(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1415. struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
  1416. bool ok = _upb_array_append_accessor(
  1417. msg, UPB_SIZE(44, 88), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1418. if (!ok) return NULL;
  1419. return sub;
  1420. }
  1421. UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_mutable_service(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1422. return (google_protobuf_ServiceDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(48, 96), len);
  1423. }
  1424. UPB_INLINE google_protobuf_ServiceDescriptorProto** google_protobuf_FileDescriptorProto_resize_service(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1425. return (google_protobuf_ServiceDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(48, 96), len, UPB_TYPE_MESSAGE, arena);
  1426. }
  1427. UPB_INLINE struct google_protobuf_ServiceDescriptorProto* google_protobuf_FileDescriptorProto_add_service(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1428. struct google_protobuf_ServiceDescriptorProto* sub = (struct google_protobuf_ServiceDescriptorProto*)_upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
  1429. bool ok = _upb_array_append_accessor(
  1430. msg, UPB_SIZE(48, 96), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1431. if (!ok) return NULL;
  1432. return sub;
  1433. }
  1434. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_mutable_extension(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1435. return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(52, 104), len);
  1436. }
  1437. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_FileDescriptorProto_resize_extension(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1438. return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(52, 104), len, UPB_TYPE_MESSAGE, arena);
  1439. }
  1440. UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_FileDescriptorProto_add_extension(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1441. struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
  1442. bool ok = _upb_array_append_accessor(
  1443. msg, UPB_SIZE(52, 104), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1444. if (!ok) return NULL;
  1445. return sub;
  1446. }
  1447. UPB_INLINE void google_protobuf_FileDescriptorProto_set_options(google_protobuf_FileDescriptorProto *msg, google_protobuf_FileOptions* value) {
  1448. _upb_sethas(msg, 4);
  1449. *UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_FileOptions*) = value;
  1450. }
  1451. UPB_INLINE struct google_protobuf_FileOptions* google_protobuf_FileDescriptorProto_mutable_options(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1452. struct google_protobuf_FileOptions* sub = (struct google_protobuf_FileOptions*)google_protobuf_FileDescriptorProto_options(msg);
  1453. if (sub == NULL) {
  1454. sub = (struct google_protobuf_FileOptions*)_upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
  1455. if (!sub) return NULL;
  1456. google_protobuf_FileDescriptorProto_set_options(msg, sub);
  1457. }
  1458. return sub;
  1459. }
  1460. UPB_INLINE void google_protobuf_FileDescriptorProto_set_source_code_info(google_protobuf_FileDescriptorProto *msg, google_protobuf_SourceCodeInfo* value) {
  1461. _upb_sethas(msg, 5);
  1462. *UPB_PTR_AT(msg, UPB_SIZE(32, 64), google_protobuf_SourceCodeInfo*) = value;
  1463. }
  1464. UPB_INLINE struct google_protobuf_SourceCodeInfo* google_protobuf_FileDescriptorProto_mutable_source_code_info(google_protobuf_FileDescriptorProto *msg, upb_arena *arena) {
  1465. struct google_protobuf_SourceCodeInfo* sub = (struct google_protobuf_SourceCodeInfo*)google_protobuf_FileDescriptorProto_source_code_info(msg);
  1466. if (sub == NULL) {
  1467. sub = (struct google_protobuf_SourceCodeInfo*)_upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
  1468. if (!sub) return NULL;
  1469. google_protobuf_FileDescriptorProto_set_source_code_info(msg, sub);
  1470. }
  1471. return sub;
  1472. }
  1473. UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1474. return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 112), len);
  1475. }
  1476. UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_public_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1477. return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(56, 112), len, UPB_TYPE_INT32, arena);
  1478. }
  1479. UPB_INLINE bool google_protobuf_FileDescriptorProto_add_public_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) {
  1480. return _upb_array_append_accessor(msg, UPB_SIZE(56, 112), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
  1481. arena);
  1482. }
  1483. UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_mutable_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t *len) {
  1484. return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(60, 120), len);
  1485. }
  1486. UPB_INLINE int32_t* google_protobuf_FileDescriptorProto_resize_weak_dependency(google_protobuf_FileDescriptorProto *msg, size_t len, upb_arena *arena) {
  1487. return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(60, 120), len, UPB_TYPE_INT32, arena);
  1488. }
  1489. UPB_INLINE bool google_protobuf_FileDescriptorProto_add_weak_dependency(google_protobuf_FileDescriptorProto *msg, int32_t val, upb_arena *arena) {
  1490. return _upb_array_append_accessor(msg, UPB_SIZE(60, 120), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
  1491. arena);
  1492. }
  1493. UPB_INLINE void google_protobuf_FileDescriptorProto_set_syntax(google_protobuf_FileDescriptorProto *msg, upb_strview value) {
  1494. _upb_sethas(msg, 3);
  1495. *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
  1496. }
  1497. /* google.protobuf.DescriptorProto */
  1498. UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_new(upb_arena *arena) {
  1499. return (google_protobuf_DescriptorProto *)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
  1500. }
  1501. UPB_INLINE google_protobuf_DescriptorProto *google_protobuf_DescriptorProto_parse(const char *buf, size_t size,
  1502. upb_arena *arena) {
  1503. google_protobuf_DescriptorProto *ret = google_protobuf_DescriptorProto_new(arena);
  1504. return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_msginit, arena)) ? ret : NULL;
  1505. }
  1506. UPB_INLINE char *google_protobuf_DescriptorProto_serialize(const google_protobuf_DescriptorProto *msg, upb_arena *arena, size_t *len) {
  1507. return upb_encode(msg, &google_protobuf_DescriptorProto_msginit, arena, len);
  1508. }
  1509. UPB_INLINE bool google_protobuf_DescriptorProto_has_name(const google_protobuf_DescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1510. UPB_INLINE upb_strview google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  1511. UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
  1512. UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
  1513. UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40)); }
  1514. UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
  1515. UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(24, 48)); }
  1516. UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
  1517. UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 56)); }
  1518. UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_protobuf_DescriptorProto_extension_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ExtensionRange* const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
  1519. UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(32, 64)); }
  1520. UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_FieldDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(32, 64), len); }
  1521. UPB_INLINE bool google_protobuf_DescriptorProto_has_options(const google_protobuf_DescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1522. UPB_INLINE const google_protobuf_MessageOptions* google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_MessageOptions*); }
  1523. UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(36, 72)); }
  1524. UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_OneofDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(36, 72), len); }
  1525. UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(40, 80)); }
  1526. UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_protobuf_DescriptorProto_reserved_range(const google_protobuf_DescriptorProto *msg, size_t *len) { return (const google_protobuf_DescriptorProto_ReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(40, 80), len); }
  1527. UPB_INLINE upb_strview const* google_protobuf_DescriptorProto_reserved_name(const google_protobuf_DescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(44, 88), len); }
  1528. UPB_INLINE void google_protobuf_DescriptorProto_set_name(google_protobuf_DescriptorProto *msg, upb_strview value) {
  1529. _upb_sethas(msg, 1);
  1530. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  1531. }
  1532. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_field(google_protobuf_DescriptorProto *msg, size_t *len) {
  1533. return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
  1534. }
  1535. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_field(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1536. return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
  1537. }
  1538. UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_field(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1539. struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
  1540. bool ok = _upb_array_append_accessor(
  1541. msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1542. if (!ok) return NULL;
  1543. return sub;
  1544. }
  1545. UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_mutable_nested_type(google_protobuf_DescriptorProto *msg, size_t *len) {
  1546. return (google_protobuf_DescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
  1547. }
  1548. UPB_INLINE google_protobuf_DescriptorProto** google_protobuf_DescriptorProto_resize_nested_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1549. return (google_protobuf_DescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_MESSAGE, arena);
  1550. }
  1551. UPB_INLINE struct google_protobuf_DescriptorProto* google_protobuf_DescriptorProto_add_nested_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1552. struct google_protobuf_DescriptorProto* sub = (struct google_protobuf_DescriptorProto*)_upb_msg_new(&google_protobuf_DescriptorProto_msginit, arena);
  1553. bool ok = _upb_array_append_accessor(
  1554. msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1555. if (!ok) return NULL;
  1556. return sub;
  1557. }
  1558. UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_mutable_enum_type(google_protobuf_DescriptorProto *msg, size_t *len) {
  1559. return (google_protobuf_EnumDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
  1560. }
  1561. UPB_INLINE google_protobuf_EnumDescriptorProto** google_protobuf_DescriptorProto_resize_enum_type(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1562. return (google_protobuf_EnumDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_MESSAGE, arena);
  1563. }
  1564. UPB_INLINE struct google_protobuf_EnumDescriptorProto* google_protobuf_DescriptorProto_add_enum_type(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1565. struct google_protobuf_EnumDescriptorProto* sub = (struct google_protobuf_EnumDescriptorProto*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
  1566. bool ok = _upb_array_append_accessor(
  1567. msg, UPB_SIZE(24, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1568. if (!ok) return NULL;
  1569. return sub;
  1570. }
  1571. UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_mutable_extension_range(google_protobuf_DescriptorProto *msg, size_t *len) {
  1572. return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
  1573. }
  1574. UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange** google_protobuf_DescriptorProto_resize_extension_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1575. return (google_protobuf_DescriptorProto_ExtensionRange**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_TYPE_MESSAGE, arena);
  1576. }
  1577. UPB_INLINE struct google_protobuf_DescriptorProto_ExtensionRange* google_protobuf_DescriptorProto_add_extension_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1578. struct google_protobuf_DescriptorProto_ExtensionRange* sub = (struct google_protobuf_DescriptorProto_ExtensionRange*)_upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
  1579. bool ok = _upb_array_append_accessor(
  1580. msg, UPB_SIZE(28, 56), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1581. if (!ok) return NULL;
  1582. return sub;
  1583. }
  1584. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_mutable_extension(google_protobuf_DescriptorProto *msg, size_t *len) {
  1585. return (google_protobuf_FieldDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 64), len);
  1586. }
  1587. UPB_INLINE google_protobuf_FieldDescriptorProto** google_protobuf_DescriptorProto_resize_extension(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1588. return (google_protobuf_FieldDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 64), len, UPB_TYPE_MESSAGE, arena);
  1589. }
  1590. UPB_INLINE struct google_protobuf_FieldDescriptorProto* google_protobuf_DescriptorProto_add_extension(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1591. struct google_protobuf_FieldDescriptorProto* sub = (struct google_protobuf_FieldDescriptorProto*)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
  1592. bool ok = _upb_array_append_accessor(
  1593. msg, UPB_SIZE(32, 64), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1594. if (!ok) return NULL;
  1595. return sub;
  1596. }
  1597. UPB_INLINE void google_protobuf_DescriptorProto_set_options(google_protobuf_DescriptorProto *msg, google_protobuf_MessageOptions* value) {
  1598. _upb_sethas(msg, 2);
  1599. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_MessageOptions*) = value;
  1600. }
  1601. UPB_INLINE struct google_protobuf_MessageOptions* google_protobuf_DescriptorProto_mutable_options(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1602. struct google_protobuf_MessageOptions* sub = (struct google_protobuf_MessageOptions*)google_protobuf_DescriptorProto_options(msg);
  1603. if (sub == NULL) {
  1604. sub = (struct google_protobuf_MessageOptions*)_upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
  1605. if (!sub) return NULL;
  1606. google_protobuf_DescriptorProto_set_options(msg, sub);
  1607. }
  1608. return sub;
  1609. }
  1610. UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_mutable_oneof_decl(google_protobuf_DescriptorProto *msg, size_t *len) {
  1611. return (google_protobuf_OneofDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 72), len);
  1612. }
  1613. UPB_INLINE google_protobuf_OneofDescriptorProto** google_protobuf_DescriptorProto_resize_oneof_decl(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1614. return (google_protobuf_OneofDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 72), len, UPB_TYPE_MESSAGE, arena);
  1615. }
  1616. UPB_INLINE struct google_protobuf_OneofDescriptorProto* google_protobuf_DescriptorProto_add_oneof_decl(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1617. struct google_protobuf_OneofDescriptorProto* sub = (struct google_protobuf_OneofDescriptorProto*)_upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
  1618. bool ok = _upb_array_append_accessor(
  1619. msg, UPB_SIZE(36, 72), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1620. if (!ok) return NULL;
  1621. return sub;
  1622. }
  1623. UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_mutable_reserved_range(google_protobuf_DescriptorProto *msg, size_t *len) {
  1624. return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(40, 80), len);
  1625. }
  1626. UPB_INLINE google_protobuf_DescriptorProto_ReservedRange** google_protobuf_DescriptorProto_resize_reserved_range(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1627. return (google_protobuf_DescriptorProto_ReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(40, 80), len, UPB_TYPE_MESSAGE, arena);
  1628. }
  1629. UPB_INLINE struct google_protobuf_DescriptorProto_ReservedRange* google_protobuf_DescriptorProto_add_reserved_range(google_protobuf_DescriptorProto *msg, upb_arena *arena) {
  1630. struct google_protobuf_DescriptorProto_ReservedRange* sub = (struct google_protobuf_DescriptorProto_ReservedRange*)_upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
  1631. bool ok = _upb_array_append_accessor(
  1632. msg, UPB_SIZE(40, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1633. if (!ok) return NULL;
  1634. return sub;
  1635. }
  1636. UPB_INLINE upb_strview* google_protobuf_DescriptorProto_mutable_reserved_name(google_protobuf_DescriptorProto *msg, size_t *len) {
  1637. return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(44, 88), len);
  1638. }
  1639. UPB_INLINE upb_strview* google_protobuf_DescriptorProto_resize_reserved_name(google_protobuf_DescriptorProto *msg, size_t len, upb_arena *arena) {
  1640. return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(44, 88), len, UPB_TYPE_STRING, arena);
  1641. }
  1642. UPB_INLINE bool google_protobuf_DescriptorProto_add_reserved_name(google_protobuf_DescriptorProto *msg, upb_strview val, upb_arena *arena) {
  1643. return _upb_array_append_accessor(msg, UPB_SIZE(44, 88), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
  1644. arena);
  1645. }
  1646. /* google.protobuf.DescriptorProto.ExtensionRange */
  1647. UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_new(upb_arena *arena) {
  1648. return (google_protobuf_DescriptorProto_ExtensionRange *)_upb_msg_new(&google_protobuf_DescriptorProto_ExtensionRange_msginit, arena);
  1649. }
  1650. UPB_INLINE google_protobuf_DescriptorProto_ExtensionRange *google_protobuf_DescriptorProto_ExtensionRange_parse(const char *buf, size_t size,
  1651. upb_arena *arena) {
  1652. google_protobuf_DescriptorProto_ExtensionRange *ret = google_protobuf_DescriptorProto_ExtensionRange_new(arena);
  1653. return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena)) ? ret : NULL;
  1654. }
  1655. UPB_INLINE char *google_protobuf_DescriptorProto_ExtensionRange_serialize(const google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena, size_t *len) {
  1656. return upb_encode(msg, &google_protobuf_DescriptorProto_ExtensionRange_msginit, arena, len);
  1657. }
  1658. UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_hasbit(msg, 1); }
  1659. UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_start(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
  1660. UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_hasbit(msg, 2); }
  1661. UPB_INLINE int32_t google_protobuf_DescriptorProto_ExtensionRange_end(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  1662. UPB_INLINE bool google_protobuf_DescriptorProto_ExtensionRange_has_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return _upb_hasbit(msg, 3); }
  1663. UPB_INLINE const google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_options(const google_protobuf_DescriptorProto_ExtensionRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const google_protobuf_ExtensionRangeOptions*); }
  1664. UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_start(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
  1665. _upb_sethas(msg, 1);
  1666. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
  1667. }
  1668. UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_end(google_protobuf_DescriptorProto_ExtensionRange *msg, int32_t value) {
  1669. _upb_sethas(msg, 2);
  1670. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  1671. }
  1672. UPB_INLINE void google_protobuf_DescriptorProto_ExtensionRange_set_options(google_protobuf_DescriptorProto_ExtensionRange *msg, google_protobuf_ExtensionRangeOptions* value) {
  1673. _upb_sethas(msg, 3);
  1674. *UPB_PTR_AT(msg, UPB_SIZE(12, 16), google_protobuf_ExtensionRangeOptions*) = value;
  1675. }
  1676. UPB_INLINE struct google_protobuf_ExtensionRangeOptions* google_protobuf_DescriptorProto_ExtensionRange_mutable_options(google_protobuf_DescriptorProto_ExtensionRange *msg, upb_arena *arena) {
  1677. struct google_protobuf_ExtensionRangeOptions* sub = (struct google_protobuf_ExtensionRangeOptions*)google_protobuf_DescriptorProto_ExtensionRange_options(msg);
  1678. if (sub == NULL) {
  1679. sub = (struct google_protobuf_ExtensionRangeOptions*)_upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
  1680. if (!sub) return NULL;
  1681. google_protobuf_DescriptorProto_ExtensionRange_set_options(msg, sub);
  1682. }
  1683. return sub;
  1684. }
  1685. /* google.protobuf.DescriptorProto.ReservedRange */
  1686. UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_new(upb_arena *arena) {
  1687. return (google_protobuf_DescriptorProto_ReservedRange *)_upb_msg_new(&google_protobuf_DescriptorProto_ReservedRange_msginit, arena);
  1688. }
  1689. UPB_INLINE google_protobuf_DescriptorProto_ReservedRange *google_protobuf_DescriptorProto_ReservedRange_parse(const char *buf, size_t size,
  1690. upb_arena *arena) {
  1691. google_protobuf_DescriptorProto_ReservedRange *ret = google_protobuf_DescriptorProto_ReservedRange_new(arena);
  1692. return (ret && upb_decode(buf, size, ret, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena)) ? ret : NULL;
  1693. }
  1694. UPB_INLINE char *google_protobuf_DescriptorProto_ReservedRange_serialize(const google_protobuf_DescriptorProto_ReservedRange *msg, upb_arena *arena, size_t *len) {
  1695. return upb_encode(msg, &google_protobuf_DescriptorProto_ReservedRange_msginit, arena, len);
  1696. }
  1697. UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_hasbit(msg, 1); }
  1698. UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_start(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
  1699. UPB_INLINE bool google_protobuf_DescriptorProto_ReservedRange_has_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return _upb_hasbit(msg, 2); }
  1700. UPB_INLINE int32_t google_protobuf_DescriptorProto_ReservedRange_end(const google_protobuf_DescriptorProto_ReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  1701. UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_start(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
  1702. _upb_sethas(msg, 1);
  1703. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
  1704. }
  1705. UPB_INLINE void google_protobuf_DescriptorProto_ReservedRange_set_end(google_protobuf_DescriptorProto_ReservedRange *msg, int32_t value) {
  1706. _upb_sethas(msg, 2);
  1707. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  1708. }
  1709. /* google.protobuf.ExtensionRangeOptions */
  1710. UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_new(upb_arena *arena) {
  1711. return (google_protobuf_ExtensionRangeOptions *)_upb_msg_new(&google_protobuf_ExtensionRangeOptions_msginit, arena);
  1712. }
  1713. UPB_INLINE google_protobuf_ExtensionRangeOptions *google_protobuf_ExtensionRangeOptions_parse(const char *buf, size_t size,
  1714. upb_arena *arena) {
  1715. google_protobuf_ExtensionRangeOptions *ret = google_protobuf_ExtensionRangeOptions_new(arena);
  1716. return (ret && upb_decode(buf, size, ret, &google_protobuf_ExtensionRangeOptions_msginit, arena)) ? ret : NULL;
  1717. }
  1718. UPB_INLINE char *google_protobuf_ExtensionRangeOptions_serialize(const google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena, size_t *len) {
  1719. return upb_encode(msg, &google_protobuf_ExtensionRangeOptions_msginit, arena, len);
  1720. }
  1721. UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
  1722. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ExtensionRangeOptions_uninterpreted_option(const google_protobuf_ExtensionRangeOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
  1723. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_mutable_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t *len) {
  1724. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
  1725. }
  1726. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ExtensionRangeOptions_resize_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, size_t len, upb_arena *arena) {
  1727. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
  1728. }
  1729. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ExtensionRangeOptions_add_uninterpreted_option(google_protobuf_ExtensionRangeOptions *msg, upb_arena *arena) {
  1730. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  1731. bool ok = _upb_array_append_accessor(
  1732. msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1733. if (!ok) return NULL;
  1734. return sub;
  1735. }
  1736. /* google.protobuf.FieldDescriptorProto */
  1737. UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_new(upb_arena *arena) {
  1738. return (google_protobuf_FieldDescriptorProto *)_upb_msg_new(&google_protobuf_FieldDescriptorProto_msginit, arena);
  1739. }
  1740. UPB_INLINE google_protobuf_FieldDescriptorProto *google_protobuf_FieldDescriptorProto_parse(const char *buf, size_t size,
  1741. upb_arena *arena) {
  1742. google_protobuf_FieldDescriptorProto *ret = google_protobuf_FieldDescriptorProto_new(arena);
  1743. return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldDescriptorProto_msginit, arena)) ? ret : NULL;
  1744. }
  1745. UPB_INLINE char *google_protobuf_FieldDescriptorProto_serialize(const google_protobuf_FieldDescriptorProto *msg, upb_arena *arena, size_t *len) {
  1746. return upb_encode(msg, &google_protobuf_FieldDescriptorProto_msginit, arena, len);
  1747. }
  1748. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 6); }
  1749. UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 40), upb_strview); }
  1750. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 7); }
  1751. UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 56), upb_strview); }
  1752. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_number(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 3); }
  1753. UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t); }
  1754. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_label(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1755. UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  1756. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1757. UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
  1758. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 8); }
  1759. UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 72), upb_strview); }
  1760. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 9); }
  1761. UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 88), upb_strview); }
  1762. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 11); }
  1763. UPB_INLINE const google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 120), const google_protobuf_FieldOptions*); }
  1764. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 4); }
  1765. UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t); }
  1766. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 10); }
  1767. UPB_INLINE upb_strview google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 104), upb_strview); }
  1768. UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_proto3_optional(const google_protobuf_FieldDescriptorProto *msg) { return _upb_hasbit(msg, 5); }
  1769. UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), bool); }
  1770. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
  1771. _upb_sethas(msg, 6);
  1772. *UPB_PTR_AT(msg, UPB_SIZE(36, 40), upb_strview) = value;
  1773. }
  1774. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_extendee(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
  1775. _upb_sethas(msg, 7);
  1776. *UPB_PTR_AT(msg, UPB_SIZE(44, 56), upb_strview) = value;
  1777. }
  1778. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_number(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
  1779. _upb_sethas(msg, 3);
  1780. *UPB_PTR_AT(msg, UPB_SIZE(24, 24), int32_t) = value;
  1781. }
  1782. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_label(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
  1783. _upb_sethas(msg, 1);
  1784. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  1785. }
  1786. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
  1787. _upb_sethas(msg, 2);
  1788. *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
  1789. }
  1790. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_type_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
  1791. _upb_sethas(msg, 8);
  1792. *UPB_PTR_AT(msg, UPB_SIZE(52, 72), upb_strview) = value;
  1793. }
  1794. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_default_value(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
  1795. _upb_sethas(msg, 9);
  1796. *UPB_PTR_AT(msg, UPB_SIZE(60, 88), upb_strview) = value;
  1797. }
  1798. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_options(google_protobuf_FieldDescriptorProto *msg, google_protobuf_FieldOptions* value) {
  1799. _upb_sethas(msg, 11);
  1800. *UPB_PTR_AT(msg, UPB_SIZE(76, 120), google_protobuf_FieldOptions*) = value;
  1801. }
  1802. UPB_INLINE struct google_protobuf_FieldOptions* google_protobuf_FieldDescriptorProto_mutable_options(google_protobuf_FieldDescriptorProto *msg, upb_arena *arena) {
  1803. struct google_protobuf_FieldOptions* sub = (struct google_protobuf_FieldOptions*)google_protobuf_FieldDescriptorProto_options(msg);
  1804. if (sub == NULL) {
  1805. sub = (struct google_protobuf_FieldOptions*)_upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
  1806. if (!sub) return NULL;
  1807. google_protobuf_FieldDescriptorProto_set_options(msg, sub);
  1808. }
  1809. return sub;
  1810. }
  1811. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_oneof_index(google_protobuf_FieldDescriptorProto *msg, int32_t value) {
  1812. _upb_sethas(msg, 4);
  1813. *UPB_PTR_AT(msg, UPB_SIZE(28, 28), int32_t) = value;
  1814. }
  1815. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_json_name(google_protobuf_FieldDescriptorProto *msg, upb_strview value) {
  1816. _upb_sethas(msg, 10);
  1817. *UPB_PTR_AT(msg, UPB_SIZE(68, 104), upb_strview) = value;
  1818. }
  1819. UPB_INLINE void google_protobuf_FieldDescriptorProto_set_proto3_optional(google_protobuf_FieldDescriptorProto *msg, bool value) {
  1820. _upb_sethas(msg, 5);
  1821. *UPB_PTR_AT(msg, UPB_SIZE(32, 32), bool) = value;
  1822. }
  1823. /* google.protobuf.OneofDescriptorProto */
  1824. UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_new(upb_arena *arena) {
  1825. return (google_protobuf_OneofDescriptorProto *)_upb_msg_new(&google_protobuf_OneofDescriptorProto_msginit, arena);
  1826. }
  1827. UPB_INLINE google_protobuf_OneofDescriptorProto *google_protobuf_OneofDescriptorProto_parse(const char *buf, size_t size,
  1828. upb_arena *arena) {
  1829. google_protobuf_OneofDescriptorProto *ret = google_protobuf_OneofDescriptorProto_new(arena);
  1830. return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofDescriptorProto_msginit, arena)) ? ret : NULL;
  1831. }
  1832. UPB_INLINE char *google_protobuf_OneofDescriptorProto_serialize(const google_protobuf_OneofDescriptorProto *msg, upb_arena *arena, size_t *len) {
  1833. return upb_encode(msg, &google_protobuf_OneofDescriptorProto_msginit, arena, len);
  1834. }
  1835. UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_name(const google_protobuf_OneofDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1836. UPB_INLINE upb_strview google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  1837. UPB_INLINE bool google_protobuf_OneofDescriptorProto_has_options(const google_protobuf_OneofDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1838. UPB_INLINE const google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_options(const google_protobuf_OneofDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_OneofOptions*); }
  1839. UPB_INLINE void google_protobuf_OneofDescriptorProto_set_name(google_protobuf_OneofDescriptorProto *msg, upb_strview value) {
  1840. _upb_sethas(msg, 1);
  1841. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  1842. }
  1843. UPB_INLINE void google_protobuf_OneofDescriptorProto_set_options(google_protobuf_OneofDescriptorProto *msg, google_protobuf_OneofOptions* value) {
  1844. _upb_sethas(msg, 2);
  1845. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_OneofOptions*) = value;
  1846. }
  1847. UPB_INLINE struct google_protobuf_OneofOptions* google_protobuf_OneofDescriptorProto_mutable_options(google_protobuf_OneofDescriptorProto *msg, upb_arena *arena) {
  1848. struct google_protobuf_OneofOptions* sub = (struct google_protobuf_OneofOptions*)google_protobuf_OneofDescriptorProto_options(msg);
  1849. if (sub == NULL) {
  1850. sub = (struct google_protobuf_OneofOptions*)_upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
  1851. if (!sub) return NULL;
  1852. google_protobuf_OneofDescriptorProto_set_options(msg, sub);
  1853. }
  1854. return sub;
  1855. }
  1856. /* google.protobuf.EnumDescriptorProto */
  1857. UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_new(upb_arena *arena) {
  1858. return (google_protobuf_EnumDescriptorProto *)_upb_msg_new(&google_protobuf_EnumDescriptorProto_msginit, arena);
  1859. }
  1860. UPB_INLINE google_protobuf_EnumDescriptorProto *google_protobuf_EnumDescriptorProto_parse(const char *buf, size_t size,
  1861. upb_arena *arena) {
  1862. google_protobuf_EnumDescriptorProto *ret = google_protobuf_EnumDescriptorProto_new(arena);
  1863. return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_msginit, arena)) ? ret : NULL;
  1864. }
  1865. UPB_INLINE char *google_protobuf_EnumDescriptorProto_serialize(const google_protobuf_EnumDescriptorProto *msg, upb_arena *arena, size_t *len) {
  1866. return upb_encode(msg, &google_protobuf_EnumDescriptorProto_msginit, arena, len);
  1867. }
  1868. UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_name(const google_protobuf_EnumDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1869. UPB_INLINE upb_strview google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  1870. UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
  1871. UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumValueDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
  1872. UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_options(const google_protobuf_EnumDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1873. UPB_INLINE const google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_options(const google_protobuf_EnumDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_EnumOptions*); }
  1874. UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 40)); }
  1875. UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* google_protobuf_EnumDescriptorProto_reserved_range(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (const google_protobuf_EnumDescriptorProto_EnumReservedRange* const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
  1876. UPB_INLINE upb_strview const* google_protobuf_EnumDescriptorProto_reserved_name(const google_protobuf_EnumDescriptorProto *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
  1877. UPB_INLINE void google_protobuf_EnumDescriptorProto_set_name(google_protobuf_EnumDescriptorProto *msg, upb_strview value) {
  1878. _upb_sethas(msg, 1);
  1879. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  1880. }
  1881. UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_mutable_value(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
  1882. return (google_protobuf_EnumValueDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
  1883. }
  1884. UPB_INLINE google_protobuf_EnumValueDescriptorProto** google_protobuf_EnumDescriptorProto_resize_value(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
  1885. return (google_protobuf_EnumValueDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
  1886. }
  1887. UPB_INLINE struct google_protobuf_EnumValueDescriptorProto* google_protobuf_EnumDescriptorProto_add_value(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
  1888. struct google_protobuf_EnumValueDescriptorProto* sub = (struct google_protobuf_EnumValueDescriptorProto*)_upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
  1889. bool ok = _upb_array_append_accessor(
  1890. msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1891. if (!ok) return NULL;
  1892. return sub;
  1893. }
  1894. UPB_INLINE void google_protobuf_EnumDescriptorProto_set_options(google_protobuf_EnumDescriptorProto *msg, google_protobuf_EnumOptions* value) {
  1895. _upb_sethas(msg, 2);
  1896. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_EnumOptions*) = value;
  1897. }
  1898. UPB_INLINE struct google_protobuf_EnumOptions* google_protobuf_EnumDescriptorProto_mutable_options(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
  1899. struct google_protobuf_EnumOptions* sub = (struct google_protobuf_EnumOptions*)google_protobuf_EnumDescriptorProto_options(msg);
  1900. if (sub == NULL) {
  1901. sub = (struct google_protobuf_EnumOptions*)_upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
  1902. if (!sub) return NULL;
  1903. google_protobuf_EnumDescriptorProto_set_options(msg, sub);
  1904. }
  1905. return sub;
  1906. }
  1907. UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_mutable_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
  1908. return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
  1909. }
  1910. UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange** google_protobuf_EnumDescriptorProto_resize_reserved_range(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
  1911. return (google_protobuf_EnumDescriptorProto_EnumReservedRange**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_MESSAGE, arena);
  1912. }
  1913. UPB_INLINE struct google_protobuf_EnumDescriptorProto_EnumReservedRange* google_protobuf_EnumDescriptorProto_add_reserved_range(google_protobuf_EnumDescriptorProto *msg, upb_arena *arena) {
  1914. struct google_protobuf_EnumDescriptorProto_EnumReservedRange* sub = (struct google_protobuf_EnumDescriptorProto_EnumReservedRange*)_upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
  1915. bool ok = _upb_array_append_accessor(
  1916. msg, UPB_SIZE(20, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  1917. if (!ok) return NULL;
  1918. return sub;
  1919. }
  1920. UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_mutable_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t *len) {
  1921. return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
  1922. }
  1923. UPB_INLINE upb_strview* google_protobuf_EnumDescriptorProto_resize_reserved_name(google_protobuf_EnumDescriptorProto *msg, size_t len, upb_arena *arena) {
  1924. return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_STRING, arena);
  1925. }
  1926. UPB_INLINE bool google_protobuf_EnumDescriptorProto_add_reserved_name(google_protobuf_EnumDescriptorProto *msg, upb_strview val, upb_arena *arena) {
  1927. return _upb_array_append_accessor(msg, UPB_SIZE(24, 48), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
  1928. arena);
  1929. }
  1930. /* google.protobuf.EnumDescriptorProto.EnumReservedRange */
  1931. UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_new(upb_arena *arena) {
  1932. return (google_protobuf_EnumDescriptorProto_EnumReservedRange *)_upb_msg_new(&google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena);
  1933. }
  1934. UPB_INLINE google_protobuf_EnumDescriptorProto_EnumReservedRange *google_protobuf_EnumDescriptorProto_EnumReservedRange_parse(const char *buf, size_t size,
  1935. upb_arena *arena) {
  1936. google_protobuf_EnumDescriptorProto_EnumReservedRange *ret = google_protobuf_EnumDescriptorProto_EnumReservedRange_new(arena);
  1937. return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena)) ? ret : NULL;
  1938. }
  1939. UPB_INLINE char *google_protobuf_EnumDescriptorProto_EnumReservedRange_serialize(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, upb_arena *arena, size_t *len) {
  1940. return upb_encode(msg, &google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit, arena, len);
  1941. }
  1942. UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_hasbit(msg, 1); }
  1943. UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_start(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
  1944. UPB_INLINE bool google_protobuf_EnumDescriptorProto_EnumReservedRange_has_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return _upb_hasbit(msg, 2); }
  1945. UPB_INLINE int32_t google_protobuf_EnumDescriptorProto_EnumReservedRange_end(const google_protobuf_EnumDescriptorProto_EnumReservedRange *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  1946. UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_start(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
  1947. _upb_sethas(msg, 1);
  1948. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
  1949. }
  1950. UPB_INLINE void google_protobuf_EnumDescriptorProto_EnumReservedRange_set_end(google_protobuf_EnumDescriptorProto_EnumReservedRange *msg, int32_t value) {
  1951. _upb_sethas(msg, 2);
  1952. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  1953. }
  1954. /* google.protobuf.EnumValueDescriptorProto */
  1955. UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_new(upb_arena *arena) {
  1956. return (google_protobuf_EnumValueDescriptorProto *)_upb_msg_new(&google_protobuf_EnumValueDescriptorProto_msginit, arena);
  1957. }
  1958. UPB_INLINE google_protobuf_EnumValueDescriptorProto *google_protobuf_EnumValueDescriptorProto_parse(const char *buf, size_t size,
  1959. upb_arena *arena) {
  1960. google_protobuf_EnumValueDescriptorProto *ret = google_protobuf_EnumValueDescriptorProto_new(arena);
  1961. return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueDescriptorProto_msginit, arena)) ? ret : NULL;
  1962. }
  1963. UPB_INLINE char *google_protobuf_EnumValueDescriptorProto_serialize(const google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena, size_t *len) {
  1964. return upb_encode(msg, &google_protobuf_EnumValueDescriptorProto_msginit, arena, len);
  1965. }
  1966. UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_name(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  1967. UPB_INLINE upb_strview google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview); }
  1968. UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_number(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  1969. UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
  1970. UPB_INLINE bool google_protobuf_EnumValueDescriptorProto_has_options(const google_protobuf_EnumValueDescriptorProto *msg) { return _upb_hasbit(msg, 3); }
  1971. UPB_INLINE const google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_options(const google_protobuf_EnumValueDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 24), const google_protobuf_EnumValueOptions*); }
  1972. UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_name(google_protobuf_EnumValueDescriptorProto *msg, upb_strview value) {
  1973. _upb_sethas(msg, 2);
  1974. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), upb_strview) = value;
  1975. }
  1976. UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_number(google_protobuf_EnumValueDescriptorProto *msg, int32_t value) {
  1977. _upb_sethas(msg, 1);
  1978. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
  1979. }
  1980. UPB_INLINE void google_protobuf_EnumValueDescriptorProto_set_options(google_protobuf_EnumValueDescriptorProto *msg, google_protobuf_EnumValueOptions* value) {
  1981. _upb_sethas(msg, 3);
  1982. *UPB_PTR_AT(msg, UPB_SIZE(16, 24), google_protobuf_EnumValueOptions*) = value;
  1983. }
  1984. UPB_INLINE struct google_protobuf_EnumValueOptions* google_protobuf_EnumValueDescriptorProto_mutable_options(google_protobuf_EnumValueDescriptorProto *msg, upb_arena *arena) {
  1985. struct google_protobuf_EnumValueOptions* sub = (struct google_protobuf_EnumValueOptions*)google_protobuf_EnumValueDescriptorProto_options(msg);
  1986. if (sub == NULL) {
  1987. sub = (struct google_protobuf_EnumValueOptions*)_upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
  1988. if (!sub) return NULL;
  1989. google_protobuf_EnumValueDescriptorProto_set_options(msg, sub);
  1990. }
  1991. return sub;
  1992. }
  1993. /* google.protobuf.ServiceDescriptorProto */
  1994. UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_new(upb_arena *arena) {
  1995. return (google_protobuf_ServiceDescriptorProto *)_upb_msg_new(&google_protobuf_ServiceDescriptorProto_msginit, arena);
  1996. }
  1997. UPB_INLINE google_protobuf_ServiceDescriptorProto *google_protobuf_ServiceDescriptorProto_parse(const char *buf, size_t size,
  1998. upb_arena *arena) {
  1999. google_protobuf_ServiceDescriptorProto *ret = google_protobuf_ServiceDescriptorProto_new(arena);
  2000. return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceDescriptorProto_msginit, arena)) ? ret : NULL;
  2001. }
  2002. UPB_INLINE char *google_protobuf_ServiceDescriptorProto_serialize(const google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena, size_t *len) {
  2003. return upb_encode(msg, &google_protobuf_ServiceDescriptorProto_msginit, arena, len);
  2004. }
  2005. UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_name(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  2006. UPB_INLINE upb_strview google_protobuf_ServiceDescriptorProto_name(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  2007. UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(16, 32)); }
  2008. UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_ServiceDescriptorProto_method(const google_protobuf_ServiceDescriptorProto *msg, size_t *len) { return (const google_protobuf_MethodDescriptorProto* const*)_upb_array_accessor(msg, UPB_SIZE(16, 32), len); }
  2009. UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_options(const google_protobuf_ServiceDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  2010. UPB_INLINE const google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_options(const google_protobuf_ServiceDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const google_protobuf_ServiceOptions*); }
  2011. UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_name(google_protobuf_ServiceDescriptorProto *msg, upb_strview value) {
  2012. _upb_sethas(msg, 1);
  2013. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  2014. }
  2015. UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_mutable_method(google_protobuf_ServiceDescriptorProto *msg, size_t *len) {
  2016. return (google_protobuf_MethodDescriptorProto**)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 32), len);
  2017. }
  2018. UPB_INLINE google_protobuf_MethodDescriptorProto** google_protobuf_ServiceDescriptorProto_resize_method(google_protobuf_ServiceDescriptorProto *msg, size_t len, upb_arena *arena) {
  2019. return (google_protobuf_MethodDescriptorProto**)_upb_array_resize_accessor(msg, UPB_SIZE(16, 32), len, UPB_TYPE_MESSAGE, arena);
  2020. }
  2021. UPB_INLINE struct google_protobuf_MethodDescriptorProto* google_protobuf_ServiceDescriptorProto_add_method(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) {
  2022. struct google_protobuf_MethodDescriptorProto* sub = (struct google_protobuf_MethodDescriptorProto*)_upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
  2023. bool ok = _upb_array_append_accessor(
  2024. msg, UPB_SIZE(16, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2025. if (!ok) return NULL;
  2026. return sub;
  2027. }
  2028. UPB_INLINE void google_protobuf_ServiceDescriptorProto_set_options(google_protobuf_ServiceDescriptorProto *msg, google_protobuf_ServiceOptions* value) {
  2029. _upb_sethas(msg, 2);
  2030. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), google_protobuf_ServiceOptions*) = value;
  2031. }
  2032. UPB_INLINE struct google_protobuf_ServiceOptions* google_protobuf_ServiceDescriptorProto_mutable_options(google_protobuf_ServiceDescriptorProto *msg, upb_arena *arena) {
  2033. struct google_protobuf_ServiceOptions* sub = (struct google_protobuf_ServiceOptions*)google_protobuf_ServiceDescriptorProto_options(msg);
  2034. if (sub == NULL) {
  2035. sub = (struct google_protobuf_ServiceOptions*)_upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
  2036. if (!sub) return NULL;
  2037. google_protobuf_ServiceDescriptorProto_set_options(msg, sub);
  2038. }
  2039. return sub;
  2040. }
  2041. /* google.protobuf.MethodDescriptorProto */
  2042. UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_new(upb_arena *arena) {
  2043. return (google_protobuf_MethodDescriptorProto *)_upb_msg_new(&google_protobuf_MethodDescriptorProto_msginit, arena);
  2044. }
  2045. UPB_INLINE google_protobuf_MethodDescriptorProto *google_protobuf_MethodDescriptorProto_parse(const char *buf, size_t size,
  2046. upb_arena *arena) {
  2047. google_protobuf_MethodDescriptorProto *ret = google_protobuf_MethodDescriptorProto_new(arena);
  2048. return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodDescriptorProto_msginit, arena)) ? ret : NULL;
  2049. }
  2050. UPB_INLINE char *google_protobuf_MethodDescriptorProto_serialize(const google_protobuf_MethodDescriptorProto *msg, upb_arena *arena, size_t *len) {
  2051. return upb_encode(msg, &google_protobuf_MethodDescriptorProto_msginit, arena, len);
  2052. }
  2053. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_name(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 3); }
  2054. UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_name(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  2055. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_input_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 4); }
  2056. UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_input_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
  2057. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_output_type(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 5); }
  2058. UPB_INLINE upb_strview google_protobuf_MethodDescriptorProto_output_type(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview); }
  2059. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_options(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 6); }
  2060. UPB_INLINE const google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_options(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const google_protobuf_MethodOptions*); }
  2061. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 1); }
  2062. UPB_INLINE bool google_protobuf_MethodDescriptorProto_client_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2063. UPB_INLINE bool google_protobuf_MethodDescriptorProto_has_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return _upb_hasbit(msg, 2); }
  2064. UPB_INLINE bool google_protobuf_MethodDescriptorProto_server_streaming(const google_protobuf_MethodDescriptorProto *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
  2065. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_name(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
  2066. _upb_sethas(msg, 3);
  2067. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  2068. }
  2069. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_input_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
  2070. _upb_sethas(msg, 4);
  2071. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
  2072. }
  2073. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_output_type(google_protobuf_MethodDescriptorProto *msg, upb_strview value) {
  2074. _upb_sethas(msg, 5);
  2075. *UPB_PTR_AT(msg, UPB_SIZE(20, 40), upb_strview) = value;
  2076. }
  2077. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_options(google_protobuf_MethodDescriptorProto *msg, google_protobuf_MethodOptions* value) {
  2078. _upb_sethas(msg, 6);
  2079. *UPB_PTR_AT(msg, UPB_SIZE(28, 56), google_protobuf_MethodOptions*) = value;
  2080. }
  2081. UPB_INLINE struct google_protobuf_MethodOptions* google_protobuf_MethodDescriptorProto_mutable_options(google_protobuf_MethodDescriptorProto *msg, upb_arena *arena) {
  2082. struct google_protobuf_MethodOptions* sub = (struct google_protobuf_MethodOptions*)google_protobuf_MethodDescriptorProto_options(msg);
  2083. if (sub == NULL) {
  2084. sub = (struct google_protobuf_MethodOptions*)_upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
  2085. if (!sub) return NULL;
  2086. google_protobuf_MethodDescriptorProto_set_options(msg, sub);
  2087. }
  2088. return sub;
  2089. }
  2090. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_client_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
  2091. _upb_sethas(msg, 1);
  2092. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2093. }
  2094. UPB_INLINE void google_protobuf_MethodDescriptorProto_set_server_streaming(google_protobuf_MethodDescriptorProto *msg, bool value) {
  2095. _upb_sethas(msg, 2);
  2096. *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
  2097. }
  2098. /* google.protobuf.FileOptions */
  2099. UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_new(upb_arena *arena) {
  2100. return (google_protobuf_FileOptions *)_upb_msg_new(&google_protobuf_FileOptions_msginit, arena);
  2101. }
  2102. UPB_INLINE google_protobuf_FileOptions *google_protobuf_FileOptions_parse(const char *buf, size_t size,
  2103. upb_arena *arena) {
  2104. google_protobuf_FileOptions *ret = google_protobuf_FileOptions_new(arena);
  2105. return (ret && upb_decode(buf, size, ret, &google_protobuf_FileOptions_msginit, arena)) ? ret : NULL;
  2106. }
  2107. UPB_INLINE char *google_protobuf_FileOptions_serialize(const google_protobuf_FileOptions *msg, upb_arena *arena, size_t *len) {
  2108. return upb_encode(msg, &google_protobuf_FileOptions_msginit, arena, len);
  2109. }
  2110. UPB_INLINE bool google_protobuf_FileOptions_has_java_package(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 11); }
  2111. UPB_INLINE upb_strview google_protobuf_FileOptions_java_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview); }
  2112. UPB_INLINE bool google_protobuf_FileOptions_has_java_outer_classname(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 12); }
  2113. UPB_INLINE upb_strview google_protobuf_FileOptions_java_outer_classname(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview); }
  2114. UPB_INLINE bool google_protobuf_FileOptions_has_optimize_for(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 1); }
  2115. UPB_INLINE int32_t google_protobuf_FileOptions_optimize_for(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  2116. UPB_INLINE bool google_protobuf_FileOptions_has_java_multiple_files(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 2); }
  2117. UPB_INLINE bool google_protobuf_FileOptions_java_multiple_files(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
  2118. UPB_INLINE bool google_protobuf_FileOptions_has_go_package(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 13); }
  2119. UPB_INLINE upb_strview google_protobuf_FileOptions_go_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview); }
  2120. UPB_INLINE bool google_protobuf_FileOptions_has_cc_generic_services(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 3); }
  2121. UPB_INLINE bool google_protobuf_FileOptions_cc_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool); }
  2122. UPB_INLINE bool google_protobuf_FileOptions_has_java_generic_services(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 4); }
  2123. UPB_INLINE bool google_protobuf_FileOptions_java_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool); }
  2124. UPB_INLINE bool google_protobuf_FileOptions_has_py_generic_services(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 5); }
  2125. UPB_INLINE bool google_protobuf_FileOptions_py_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool); }
  2126. UPB_INLINE bool google_protobuf_FileOptions_has_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 6); }
  2127. UPB_INLINE bool google_protobuf_FileOptions_java_generate_equals_and_hash(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool); }
  2128. UPB_INLINE bool google_protobuf_FileOptions_has_deprecated(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 7); }
  2129. UPB_INLINE bool google_protobuf_FileOptions_deprecated(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool); }
  2130. UPB_INLINE bool google_protobuf_FileOptions_has_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 8); }
  2131. UPB_INLINE bool google_protobuf_FileOptions_java_string_check_utf8(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool); }
  2132. UPB_INLINE bool google_protobuf_FileOptions_has_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 9); }
  2133. UPB_INLINE bool google_protobuf_FileOptions_cc_enable_arenas(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool); }
  2134. UPB_INLINE bool google_protobuf_FileOptions_has_objc_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 14); }
  2135. UPB_INLINE upb_strview google_protobuf_FileOptions_objc_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview); }
  2136. UPB_INLINE bool google_protobuf_FileOptions_has_csharp_namespace(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 15); }
  2137. UPB_INLINE upb_strview google_protobuf_FileOptions_csharp_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview); }
  2138. UPB_INLINE bool google_protobuf_FileOptions_has_swift_prefix(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 16); }
  2139. UPB_INLINE upb_strview google_protobuf_FileOptions_swift_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview); }
  2140. UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 17); }
  2141. UPB_INLINE upb_strview google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview); }
  2142. UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 18); }
  2143. UPB_INLINE upb_strview google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview); }
  2144. UPB_INLINE bool google_protobuf_FileOptions_has_php_generic_services(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 10); }
  2145. UPB_INLINE bool google_protobuf_FileOptions_php_generic_services(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
  2146. UPB_INLINE bool google_protobuf_FileOptions_has_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 19); }
  2147. UPB_INLINE upb_strview google_protobuf_FileOptions_php_metadata_namespace(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview); }
  2148. UPB_INLINE bool google_protobuf_FileOptions_has_ruby_package(const google_protobuf_FileOptions *msg) { return _upb_hasbit(msg, 20); }
  2149. UPB_INLINE upb_strview google_protobuf_FileOptions_ruby_package(const google_protobuf_FileOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview); }
  2150. UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(108, 192)); }
  2151. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FileOptions_uninterpreted_option(const google_protobuf_FileOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(108, 192), len); }
  2152. UPB_INLINE void google_protobuf_FileOptions_set_java_package(google_protobuf_FileOptions *msg, upb_strview value) {
  2153. _upb_sethas(msg, 11);
  2154. *UPB_PTR_AT(msg, UPB_SIZE(28, 32), upb_strview) = value;
  2155. }
  2156. UPB_INLINE void google_protobuf_FileOptions_set_java_outer_classname(google_protobuf_FileOptions *msg, upb_strview value) {
  2157. _upb_sethas(msg, 12);
  2158. *UPB_PTR_AT(msg, UPB_SIZE(36, 48), upb_strview) = value;
  2159. }
  2160. UPB_INLINE void google_protobuf_FileOptions_set_optimize_for(google_protobuf_FileOptions *msg, int32_t value) {
  2161. _upb_sethas(msg, 1);
  2162. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  2163. }
  2164. UPB_INLINE void google_protobuf_FileOptions_set_java_multiple_files(google_protobuf_FileOptions *msg, bool value) {
  2165. _upb_sethas(msg, 2);
  2166. *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
  2167. }
  2168. UPB_INLINE void google_protobuf_FileOptions_set_go_package(google_protobuf_FileOptions *msg, upb_strview value) {
  2169. _upb_sethas(msg, 13);
  2170. *UPB_PTR_AT(msg, UPB_SIZE(44, 64), upb_strview) = value;
  2171. }
  2172. UPB_INLINE void google_protobuf_FileOptions_set_cc_generic_services(google_protobuf_FileOptions *msg, bool value) {
  2173. _upb_sethas(msg, 3);
  2174. *UPB_PTR_AT(msg, UPB_SIZE(17, 17), bool) = value;
  2175. }
  2176. UPB_INLINE void google_protobuf_FileOptions_set_java_generic_services(google_protobuf_FileOptions *msg, bool value) {
  2177. _upb_sethas(msg, 4);
  2178. *UPB_PTR_AT(msg, UPB_SIZE(18, 18), bool) = value;
  2179. }
  2180. UPB_INLINE void google_protobuf_FileOptions_set_py_generic_services(google_protobuf_FileOptions *msg, bool value) {
  2181. _upb_sethas(msg, 5);
  2182. *UPB_PTR_AT(msg, UPB_SIZE(19, 19), bool) = value;
  2183. }
  2184. UPB_INLINE void google_protobuf_FileOptions_set_java_generate_equals_and_hash(google_protobuf_FileOptions *msg, bool value) {
  2185. _upb_sethas(msg, 6);
  2186. *UPB_PTR_AT(msg, UPB_SIZE(20, 20), bool) = value;
  2187. }
  2188. UPB_INLINE void google_protobuf_FileOptions_set_deprecated(google_protobuf_FileOptions *msg, bool value) {
  2189. _upb_sethas(msg, 7);
  2190. *UPB_PTR_AT(msg, UPB_SIZE(21, 21), bool) = value;
  2191. }
  2192. UPB_INLINE void google_protobuf_FileOptions_set_java_string_check_utf8(google_protobuf_FileOptions *msg, bool value) {
  2193. _upb_sethas(msg, 8);
  2194. *UPB_PTR_AT(msg, UPB_SIZE(22, 22), bool) = value;
  2195. }
  2196. UPB_INLINE void google_protobuf_FileOptions_set_cc_enable_arenas(google_protobuf_FileOptions *msg, bool value) {
  2197. _upb_sethas(msg, 9);
  2198. *UPB_PTR_AT(msg, UPB_SIZE(23, 23), bool) = value;
  2199. }
  2200. UPB_INLINE void google_protobuf_FileOptions_set_objc_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
  2201. _upb_sethas(msg, 14);
  2202. *UPB_PTR_AT(msg, UPB_SIZE(52, 80), upb_strview) = value;
  2203. }
  2204. UPB_INLINE void google_protobuf_FileOptions_set_csharp_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
  2205. _upb_sethas(msg, 15);
  2206. *UPB_PTR_AT(msg, UPB_SIZE(60, 96), upb_strview) = value;
  2207. }
  2208. UPB_INLINE void google_protobuf_FileOptions_set_swift_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
  2209. _upb_sethas(msg, 16);
  2210. *UPB_PTR_AT(msg, UPB_SIZE(68, 112), upb_strview) = value;
  2211. }
  2212. UPB_INLINE void google_protobuf_FileOptions_set_php_class_prefix(google_protobuf_FileOptions *msg, upb_strview value) {
  2213. _upb_sethas(msg, 17);
  2214. *UPB_PTR_AT(msg, UPB_SIZE(76, 128), upb_strview) = value;
  2215. }
  2216. UPB_INLINE void google_protobuf_FileOptions_set_php_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
  2217. _upb_sethas(msg, 18);
  2218. *UPB_PTR_AT(msg, UPB_SIZE(84, 144), upb_strview) = value;
  2219. }
  2220. UPB_INLINE void google_protobuf_FileOptions_set_php_generic_services(google_protobuf_FileOptions *msg, bool value) {
  2221. _upb_sethas(msg, 10);
  2222. *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
  2223. }
  2224. UPB_INLINE void google_protobuf_FileOptions_set_php_metadata_namespace(google_protobuf_FileOptions *msg, upb_strview value) {
  2225. _upb_sethas(msg, 19);
  2226. *UPB_PTR_AT(msg, UPB_SIZE(92, 160), upb_strview) = value;
  2227. }
  2228. UPB_INLINE void google_protobuf_FileOptions_set_ruby_package(google_protobuf_FileOptions *msg, upb_strview value) {
  2229. _upb_sethas(msg, 20);
  2230. *UPB_PTR_AT(msg, UPB_SIZE(100, 176), upb_strview) = value;
  2231. }
  2232. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_mutable_uninterpreted_option(google_protobuf_FileOptions *msg, size_t *len) {
  2233. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(108, 192), len);
  2234. }
  2235. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FileOptions_resize_uninterpreted_option(google_protobuf_FileOptions *msg, size_t len, upb_arena *arena) {
  2236. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(108, 192), len, UPB_TYPE_MESSAGE, arena);
  2237. }
  2238. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FileOptions_add_uninterpreted_option(google_protobuf_FileOptions *msg, upb_arena *arena) {
  2239. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2240. bool ok = _upb_array_append_accessor(
  2241. msg, UPB_SIZE(108, 192), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2242. if (!ok) return NULL;
  2243. return sub;
  2244. }
  2245. /* google.protobuf.MessageOptions */
  2246. UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_new(upb_arena *arena) {
  2247. return (google_protobuf_MessageOptions *)_upb_msg_new(&google_protobuf_MessageOptions_msginit, arena);
  2248. }
  2249. UPB_INLINE google_protobuf_MessageOptions *google_protobuf_MessageOptions_parse(const char *buf, size_t size,
  2250. upb_arena *arena) {
  2251. google_protobuf_MessageOptions *ret = google_protobuf_MessageOptions_new(arena);
  2252. return (ret && upb_decode(buf, size, ret, &google_protobuf_MessageOptions_msginit, arena)) ? ret : NULL;
  2253. }
  2254. UPB_INLINE char *google_protobuf_MessageOptions_serialize(const google_protobuf_MessageOptions *msg, upb_arena *arena, size_t *len) {
  2255. return upb_encode(msg, &google_protobuf_MessageOptions_msginit, arena, len);
  2256. }
  2257. UPB_INLINE bool google_protobuf_MessageOptions_has_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return _upb_hasbit(msg, 1); }
  2258. UPB_INLINE bool google_protobuf_MessageOptions_message_set_wire_format(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2259. UPB_INLINE bool google_protobuf_MessageOptions_has_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return _upb_hasbit(msg, 2); }
  2260. UPB_INLINE bool google_protobuf_MessageOptions_no_standard_descriptor_accessor(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
  2261. UPB_INLINE bool google_protobuf_MessageOptions_has_deprecated(const google_protobuf_MessageOptions *msg) { return _upb_hasbit(msg, 3); }
  2262. UPB_INLINE bool google_protobuf_MessageOptions_deprecated(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool); }
  2263. UPB_INLINE bool google_protobuf_MessageOptions_has_map_entry(const google_protobuf_MessageOptions *msg) { return _upb_hasbit(msg, 4); }
  2264. UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool); }
  2265. UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(8, 8)); }
  2266. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MessageOptions_uninterpreted_option(const google_protobuf_MessageOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(8, 8), len); }
  2267. UPB_INLINE void google_protobuf_MessageOptions_set_message_set_wire_format(google_protobuf_MessageOptions *msg, bool value) {
  2268. _upb_sethas(msg, 1);
  2269. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2270. }
  2271. UPB_INLINE void google_protobuf_MessageOptions_set_no_standard_descriptor_accessor(google_protobuf_MessageOptions *msg, bool value) {
  2272. _upb_sethas(msg, 2);
  2273. *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
  2274. }
  2275. UPB_INLINE void google_protobuf_MessageOptions_set_deprecated(google_protobuf_MessageOptions *msg, bool value) {
  2276. _upb_sethas(msg, 3);
  2277. *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool) = value;
  2278. }
  2279. UPB_INLINE void google_protobuf_MessageOptions_set_map_entry(google_protobuf_MessageOptions *msg, bool value) {
  2280. _upb_sethas(msg, 4);
  2281. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), bool) = value;
  2282. }
  2283. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_mutable_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t *len) {
  2284. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 8), len);
  2285. }
  2286. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MessageOptions_resize_uninterpreted_option(google_protobuf_MessageOptions *msg, size_t len, upb_arena *arena) {
  2287. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(8, 8), len, UPB_TYPE_MESSAGE, arena);
  2288. }
  2289. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MessageOptions_add_uninterpreted_option(google_protobuf_MessageOptions *msg, upb_arena *arena) {
  2290. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2291. bool ok = _upb_array_append_accessor(
  2292. msg, UPB_SIZE(8, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2293. if (!ok) return NULL;
  2294. return sub;
  2295. }
  2296. /* google.protobuf.FieldOptions */
  2297. UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_new(upb_arena *arena) {
  2298. return (google_protobuf_FieldOptions *)_upb_msg_new(&google_protobuf_FieldOptions_msginit, arena);
  2299. }
  2300. UPB_INLINE google_protobuf_FieldOptions *google_protobuf_FieldOptions_parse(const char *buf, size_t size,
  2301. upb_arena *arena) {
  2302. google_protobuf_FieldOptions *ret = google_protobuf_FieldOptions_new(arena);
  2303. return (ret && upb_decode(buf, size, ret, &google_protobuf_FieldOptions_msginit, arena)) ? ret : NULL;
  2304. }
  2305. UPB_INLINE char *google_protobuf_FieldOptions_serialize(const google_protobuf_FieldOptions *msg, upb_arena *arena, size_t *len) {
  2306. return upb_encode(msg, &google_protobuf_FieldOptions_msginit, arena, len);
  2307. }
  2308. UPB_INLINE bool google_protobuf_FieldOptions_has_ctype(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 1); }
  2309. UPB_INLINE int32_t google_protobuf_FieldOptions_ctype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  2310. UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 3); }
  2311. UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool); }
  2312. UPB_INLINE bool google_protobuf_FieldOptions_has_deprecated(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 4); }
  2313. UPB_INLINE bool google_protobuf_FieldOptions_deprecated(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool); }
  2314. UPB_INLINE bool google_protobuf_FieldOptions_has_lazy(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 5); }
  2315. UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool); }
  2316. UPB_INLINE bool google_protobuf_FieldOptions_has_jstype(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 2); }
  2317. UPB_INLINE int32_t google_protobuf_FieldOptions_jstype(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t); }
  2318. UPB_INLINE bool google_protobuf_FieldOptions_has_weak(const google_protobuf_FieldOptions *msg) { return _upb_hasbit(msg, 6); }
  2319. UPB_INLINE bool google_protobuf_FieldOptions_weak(const google_protobuf_FieldOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool); }
  2320. UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(28, 32)); }
  2321. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_FieldOptions_uninterpreted_option(const google_protobuf_FieldOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); }
  2322. UPB_INLINE void google_protobuf_FieldOptions_set_ctype(google_protobuf_FieldOptions *msg, int32_t value) {
  2323. _upb_sethas(msg, 1);
  2324. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  2325. }
  2326. UPB_INLINE void google_protobuf_FieldOptions_set_packed(google_protobuf_FieldOptions *msg, bool value) {
  2327. _upb_sethas(msg, 3);
  2328. *UPB_PTR_AT(msg, UPB_SIZE(24, 24), bool) = value;
  2329. }
  2330. UPB_INLINE void google_protobuf_FieldOptions_set_deprecated(google_protobuf_FieldOptions *msg, bool value) {
  2331. _upb_sethas(msg, 4);
  2332. *UPB_PTR_AT(msg, UPB_SIZE(25, 25), bool) = value;
  2333. }
  2334. UPB_INLINE void google_protobuf_FieldOptions_set_lazy(google_protobuf_FieldOptions *msg, bool value) {
  2335. _upb_sethas(msg, 5);
  2336. *UPB_PTR_AT(msg, UPB_SIZE(26, 26), bool) = value;
  2337. }
  2338. UPB_INLINE void google_protobuf_FieldOptions_set_jstype(google_protobuf_FieldOptions *msg, int32_t value) {
  2339. _upb_sethas(msg, 2);
  2340. *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int32_t) = value;
  2341. }
  2342. UPB_INLINE void google_protobuf_FieldOptions_set_weak(google_protobuf_FieldOptions *msg, bool value) {
  2343. _upb_sethas(msg, 6);
  2344. *UPB_PTR_AT(msg, UPB_SIZE(27, 27), bool) = value;
  2345. }
  2346. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_mutable_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t *len) {
  2347. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len);
  2348. }
  2349. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_FieldOptions_resize_uninterpreted_option(google_protobuf_FieldOptions *msg, size_t len, upb_arena *arena) {
  2350. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_TYPE_MESSAGE, arena);
  2351. }
  2352. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_FieldOptions_add_uninterpreted_option(google_protobuf_FieldOptions *msg, upb_arena *arena) {
  2353. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2354. bool ok = _upb_array_append_accessor(
  2355. msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2356. if (!ok) return NULL;
  2357. return sub;
  2358. }
  2359. /* google.protobuf.OneofOptions */
  2360. UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_new(upb_arena *arena) {
  2361. return (google_protobuf_OneofOptions *)_upb_msg_new(&google_protobuf_OneofOptions_msginit, arena);
  2362. }
  2363. UPB_INLINE google_protobuf_OneofOptions *google_protobuf_OneofOptions_parse(const char *buf, size_t size,
  2364. upb_arena *arena) {
  2365. google_protobuf_OneofOptions *ret = google_protobuf_OneofOptions_new(arena);
  2366. return (ret && upb_decode(buf, size, ret, &google_protobuf_OneofOptions_msginit, arena)) ? ret : NULL;
  2367. }
  2368. UPB_INLINE char *google_protobuf_OneofOptions_serialize(const google_protobuf_OneofOptions *msg, upb_arena *arena, size_t *len) {
  2369. return upb_encode(msg, &google_protobuf_OneofOptions_msginit, arena, len);
  2370. }
  2371. UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
  2372. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_OneofOptions_uninterpreted_option(const google_protobuf_OneofOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
  2373. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_mutable_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t *len) {
  2374. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
  2375. }
  2376. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_OneofOptions_resize_uninterpreted_option(google_protobuf_OneofOptions *msg, size_t len, upb_arena *arena) {
  2377. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
  2378. }
  2379. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_OneofOptions_add_uninterpreted_option(google_protobuf_OneofOptions *msg, upb_arena *arena) {
  2380. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2381. bool ok = _upb_array_append_accessor(
  2382. msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2383. if (!ok) return NULL;
  2384. return sub;
  2385. }
  2386. /* google.protobuf.EnumOptions */
  2387. UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_new(upb_arena *arena) {
  2388. return (google_protobuf_EnumOptions *)_upb_msg_new(&google_protobuf_EnumOptions_msginit, arena);
  2389. }
  2390. UPB_INLINE google_protobuf_EnumOptions *google_protobuf_EnumOptions_parse(const char *buf, size_t size,
  2391. upb_arena *arena) {
  2392. google_protobuf_EnumOptions *ret = google_protobuf_EnumOptions_new(arena);
  2393. return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumOptions_msginit, arena)) ? ret : NULL;
  2394. }
  2395. UPB_INLINE char *google_protobuf_EnumOptions_serialize(const google_protobuf_EnumOptions *msg, upb_arena *arena, size_t *len) {
  2396. return upb_encode(msg, &google_protobuf_EnumOptions_msginit, arena, len);
  2397. }
  2398. UPB_INLINE bool google_protobuf_EnumOptions_has_allow_alias(const google_protobuf_EnumOptions *msg) { return _upb_hasbit(msg, 1); }
  2399. UPB_INLINE bool google_protobuf_EnumOptions_allow_alias(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2400. UPB_INLINE bool google_protobuf_EnumOptions_has_deprecated(const google_protobuf_EnumOptions *msg) { return _upb_hasbit(msg, 2); }
  2401. UPB_INLINE bool google_protobuf_EnumOptions_deprecated(const google_protobuf_EnumOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool); }
  2402. UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
  2403. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumOptions_uninterpreted_option(const google_protobuf_EnumOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
  2404. UPB_INLINE void google_protobuf_EnumOptions_set_allow_alias(google_protobuf_EnumOptions *msg, bool value) {
  2405. _upb_sethas(msg, 1);
  2406. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2407. }
  2408. UPB_INLINE void google_protobuf_EnumOptions_set_deprecated(google_protobuf_EnumOptions *msg, bool value) {
  2409. _upb_sethas(msg, 2);
  2410. *UPB_PTR_AT(msg, UPB_SIZE(2, 2), bool) = value;
  2411. }
  2412. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_mutable_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t *len) {
  2413. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
  2414. }
  2415. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumOptions_resize_uninterpreted_option(google_protobuf_EnumOptions *msg, size_t len, upb_arena *arena) {
  2416. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
  2417. }
  2418. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumOptions_add_uninterpreted_option(google_protobuf_EnumOptions *msg, upb_arena *arena) {
  2419. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2420. bool ok = _upb_array_append_accessor(
  2421. msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2422. if (!ok) return NULL;
  2423. return sub;
  2424. }
  2425. /* google.protobuf.EnumValueOptions */
  2426. UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_new(upb_arena *arena) {
  2427. return (google_protobuf_EnumValueOptions *)_upb_msg_new(&google_protobuf_EnumValueOptions_msginit, arena);
  2428. }
  2429. UPB_INLINE google_protobuf_EnumValueOptions *google_protobuf_EnumValueOptions_parse(const char *buf, size_t size,
  2430. upb_arena *arena) {
  2431. google_protobuf_EnumValueOptions *ret = google_protobuf_EnumValueOptions_new(arena);
  2432. return (ret && upb_decode(buf, size, ret, &google_protobuf_EnumValueOptions_msginit, arena)) ? ret : NULL;
  2433. }
  2434. UPB_INLINE char *google_protobuf_EnumValueOptions_serialize(const google_protobuf_EnumValueOptions *msg, upb_arena *arena, size_t *len) {
  2435. return upb_encode(msg, &google_protobuf_EnumValueOptions_msginit, arena, len);
  2436. }
  2437. UPB_INLINE bool google_protobuf_EnumValueOptions_has_deprecated(const google_protobuf_EnumValueOptions *msg) { return _upb_hasbit(msg, 1); }
  2438. UPB_INLINE bool google_protobuf_EnumValueOptions_deprecated(const google_protobuf_EnumValueOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2439. UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
  2440. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_EnumValueOptions_uninterpreted_option(const google_protobuf_EnumValueOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
  2441. UPB_INLINE void google_protobuf_EnumValueOptions_set_deprecated(google_protobuf_EnumValueOptions *msg, bool value) {
  2442. _upb_sethas(msg, 1);
  2443. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2444. }
  2445. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_mutable_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t *len) {
  2446. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
  2447. }
  2448. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_EnumValueOptions_resize_uninterpreted_option(google_protobuf_EnumValueOptions *msg, size_t len, upb_arena *arena) {
  2449. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
  2450. }
  2451. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_EnumValueOptions_add_uninterpreted_option(google_protobuf_EnumValueOptions *msg, upb_arena *arena) {
  2452. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2453. bool ok = _upb_array_append_accessor(
  2454. msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2455. if (!ok) return NULL;
  2456. return sub;
  2457. }
  2458. /* google.protobuf.ServiceOptions */
  2459. UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_new(upb_arena *arena) {
  2460. return (google_protobuf_ServiceOptions *)_upb_msg_new(&google_protobuf_ServiceOptions_msginit, arena);
  2461. }
  2462. UPB_INLINE google_protobuf_ServiceOptions *google_protobuf_ServiceOptions_parse(const char *buf, size_t size,
  2463. upb_arena *arena) {
  2464. google_protobuf_ServiceOptions *ret = google_protobuf_ServiceOptions_new(arena);
  2465. return (ret && upb_decode(buf, size, ret, &google_protobuf_ServiceOptions_msginit, arena)) ? ret : NULL;
  2466. }
  2467. UPB_INLINE char *google_protobuf_ServiceOptions_serialize(const google_protobuf_ServiceOptions *msg, upb_arena *arena, size_t *len) {
  2468. return upb_encode(msg, &google_protobuf_ServiceOptions_msginit, arena, len);
  2469. }
  2470. UPB_INLINE bool google_protobuf_ServiceOptions_has_deprecated(const google_protobuf_ServiceOptions *msg) { return _upb_hasbit(msg, 1); }
  2471. UPB_INLINE bool google_protobuf_ServiceOptions_deprecated(const google_protobuf_ServiceOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2472. UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(4, 8)); }
  2473. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_ServiceOptions_uninterpreted_option(const google_protobuf_ServiceOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); }
  2474. UPB_INLINE void google_protobuf_ServiceOptions_set_deprecated(google_protobuf_ServiceOptions *msg, bool value) {
  2475. _upb_sethas(msg, 1);
  2476. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2477. }
  2478. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_mutable_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t *len) {
  2479. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len);
  2480. }
  2481. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_ServiceOptions_resize_uninterpreted_option(google_protobuf_ServiceOptions *msg, size_t len, upb_arena *arena) {
  2482. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_TYPE_MESSAGE, arena);
  2483. }
  2484. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_ServiceOptions_add_uninterpreted_option(google_protobuf_ServiceOptions *msg, upb_arena *arena) {
  2485. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2486. bool ok = _upb_array_append_accessor(
  2487. msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2488. if (!ok) return NULL;
  2489. return sub;
  2490. }
  2491. /* google.protobuf.MethodOptions */
  2492. UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_new(upb_arena *arena) {
  2493. return (google_protobuf_MethodOptions *)_upb_msg_new(&google_protobuf_MethodOptions_msginit, arena);
  2494. }
  2495. UPB_INLINE google_protobuf_MethodOptions *google_protobuf_MethodOptions_parse(const char *buf, size_t size,
  2496. upb_arena *arena) {
  2497. google_protobuf_MethodOptions *ret = google_protobuf_MethodOptions_new(arena);
  2498. return (ret && upb_decode(buf, size, ret, &google_protobuf_MethodOptions_msginit, arena)) ? ret : NULL;
  2499. }
  2500. UPB_INLINE char *google_protobuf_MethodOptions_serialize(const google_protobuf_MethodOptions *msg, upb_arena *arena, size_t *len) {
  2501. return upb_encode(msg, &google_protobuf_MethodOptions_msginit, arena, len);
  2502. }
  2503. UPB_INLINE bool google_protobuf_MethodOptions_has_deprecated(const google_protobuf_MethodOptions *msg) { return _upb_hasbit(msg, 2); }
  2504. UPB_INLINE bool google_protobuf_MethodOptions_deprecated(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool); }
  2505. UPB_INLINE bool google_protobuf_MethodOptions_has_idempotency_level(const google_protobuf_MethodOptions *msg) { return _upb_hasbit(msg, 1); }
  2506. UPB_INLINE int32_t google_protobuf_MethodOptions_idempotency_level(const google_protobuf_MethodOptions *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  2507. UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 24)); }
  2508. UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_MethodOptions_uninterpreted_option(const google_protobuf_MethodOptions *msg, size_t *len) { return (const google_protobuf_UninterpretedOption* const*)_upb_array_accessor(msg, UPB_SIZE(20, 24), len); }
  2509. UPB_INLINE void google_protobuf_MethodOptions_set_deprecated(google_protobuf_MethodOptions *msg, bool value) {
  2510. _upb_sethas(msg, 2);
  2511. *UPB_PTR_AT(msg, UPB_SIZE(16, 16), bool) = value;
  2512. }
  2513. UPB_INLINE void google_protobuf_MethodOptions_set_idempotency_level(google_protobuf_MethodOptions *msg, int32_t value) {
  2514. _upb_sethas(msg, 1);
  2515. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  2516. }
  2517. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_mutable_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t *len) {
  2518. return (google_protobuf_UninterpretedOption**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 24), len);
  2519. }
  2520. UPB_INLINE google_protobuf_UninterpretedOption** google_protobuf_MethodOptions_resize_uninterpreted_option(google_protobuf_MethodOptions *msg, size_t len, upb_arena *arena) {
  2521. return (google_protobuf_UninterpretedOption**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 24), len, UPB_TYPE_MESSAGE, arena);
  2522. }
  2523. UPB_INLINE struct google_protobuf_UninterpretedOption* google_protobuf_MethodOptions_add_uninterpreted_option(google_protobuf_MethodOptions *msg, upb_arena *arena) {
  2524. struct google_protobuf_UninterpretedOption* sub = (struct google_protobuf_UninterpretedOption*)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2525. bool ok = _upb_array_append_accessor(
  2526. msg, UPB_SIZE(20, 24), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2527. if (!ok) return NULL;
  2528. return sub;
  2529. }
  2530. /* google.protobuf.UninterpretedOption */
  2531. UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_new(upb_arena *arena) {
  2532. return (google_protobuf_UninterpretedOption *)_upb_msg_new(&google_protobuf_UninterpretedOption_msginit, arena);
  2533. }
  2534. UPB_INLINE google_protobuf_UninterpretedOption *google_protobuf_UninterpretedOption_parse(const char *buf, size_t size,
  2535. upb_arena *arena) {
  2536. google_protobuf_UninterpretedOption *ret = google_protobuf_UninterpretedOption_new(arena);
  2537. return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_msginit, arena)) ? ret : NULL;
  2538. }
  2539. UPB_INLINE char *google_protobuf_UninterpretedOption_serialize(const google_protobuf_UninterpretedOption *msg, upb_arena *arena, size_t *len) {
  2540. return upb_encode(msg, &google_protobuf_UninterpretedOption_msginit, arena, len);
  2541. }
  2542. UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(56, 80)); }
  2543. UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_protobuf_UninterpretedOption_name(const google_protobuf_UninterpretedOption *msg, size_t *len) { return (const google_protobuf_UninterpretedOption_NamePart* const*)_upb_array_accessor(msg, UPB_SIZE(56, 80), len); }
  2544. UPB_INLINE bool google_protobuf_UninterpretedOption_has_identifier_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 4); }
  2545. UPB_INLINE upb_strview google_protobuf_UninterpretedOption_identifier_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview); }
  2546. UPB_INLINE bool google_protobuf_UninterpretedOption_has_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 1); }
  2547. UPB_INLINE uint64_t google_protobuf_UninterpretedOption_positive_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t); }
  2548. UPB_INLINE bool google_protobuf_UninterpretedOption_has_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 2); }
  2549. UPB_INLINE int64_t google_protobuf_UninterpretedOption_negative_int_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t); }
  2550. UPB_INLINE bool google_protobuf_UninterpretedOption_has_double_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 3); }
  2551. UPB_INLINE double google_protobuf_UninterpretedOption_double_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 24), double); }
  2552. UPB_INLINE bool google_protobuf_UninterpretedOption_has_string_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 5); }
  2553. UPB_INLINE upb_strview google_protobuf_UninterpretedOption_string_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview); }
  2554. UPB_INLINE bool google_protobuf_UninterpretedOption_has_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return _upb_hasbit(msg, 6); }
  2555. UPB_INLINE upb_strview google_protobuf_UninterpretedOption_aggregate_value(const google_protobuf_UninterpretedOption *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview); }
  2556. UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_mutable_name(google_protobuf_UninterpretedOption *msg, size_t *len) {
  2557. return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_mutable_accessor(msg, UPB_SIZE(56, 80), len);
  2558. }
  2559. UPB_INLINE google_protobuf_UninterpretedOption_NamePart** google_protobuf_UninterpretedOption_resize_name(google_protobuf_UninterpretedOption *msg, size_t len, upb_arena *arena) {
  2560. return (google_protobuf_UninterpretedOption_NamePart**)_upb_array_resize_accessor(msg, UPB_SIZE(56, 80), len, UPB_TYPE_MESSAGE, arena);
  2561. }
  2562. UPB_INLINE struct google_protobuf_UninterpretedOption_NamePart* google_protobuf_UninterpretedOption_add_name(google_protobuf_UninterpretedOption *msg, upb_arena *arena) {
  2563. struct google_protobuf_UninterpretedOption_NamePart* sub = (struct google_protobuf_UninterpretedOption_NamePart*)_upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
  2564. bool ok = _upb_array_append_accessor(
  2565. msg, UPB_SIZE(56, 80), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2566. if (!ok) return NULL;
  2567. return sub;
  2568. }
  2569. UPB_INLINE void google_protobuf_UninterpretedOption_set_identifier_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
  2570. _upb_sethas(msg, 4);
  2571. *UPB_PTR_AT(msg, UPB_SIZE(32, 32), upb_strview) = value;
  2572. }
  2573. UPB_INLINE void google_protobuf_UninterpretedOption_set_positive_int_value(google_protobuf_UninterpretedOption *msg, uint64_t value) {
  2574. _upb_sethas(msg, 1);
  2575. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), uint64_t) = value;
  2576. }
  2577. UPB_INLINE void google_protobuf_UninterpretedOption_set_negative_int_value(google_protobuf_UninterpretedOption *msg, int64_t value) {
  2578. _upb_sethas(msg, 2);
  2579. *UPB_PTR_AT(msg, UPB_SIZE(16, 16), int64_t) = value;
  2580. }
  2581. UPB_INLINE void google_protobuf_UninterpretedOption_set_double_value(google_protobuf_UninterpretedOption *msg, double value) {
  2582. _upb_sethas(msg, 3);
  2583. *UPB_PTR_AT(msg, UPB_SIZE(24, 24), double) = value;
  2584. }
  2585. UPB_INLINE void google_protobuf_UninterpretedOption_set_string_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
  2586. _upb_sethas(msg, 5);
  2587. *UPB_PTR_AT(msg, UPB_SIZE(40, 48), upb_strview) = value;
  2588. }
  2589. UPB_INLINE void google_protobuf_UninterpretedOption_set_aggregate_value(google_protobuf_UninterpretedOption *msg, upb_strview value) {
  2590. _upb_sethas(msg, 6);
  2591. *UPB_PTR_AT(msg, UPB_SIZE(48, 64), upb_strview) = value;
  2592. }
  2593. /* google.protobuf.UninterpretedOption.NamePart */
  2594. UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_new(upb_arena *arena) {
  2595. return (google_protobuf_UninterpretedOption_NamePart *)_upb_msg_new(&google_protobuf_UninterpretedOption_NamePart_msginit, arena);
  2596. }
  2597. UPB_INLINE google_protobuf_UninterpretedOption_NamePart *google_protobuf_UninterpretedOption_NamePart_parse(const char *buf, size_t size,
  2598. upb_arena *arena) {
  2599. google_protobuf_UninterpretedOption_NamePart *ret = google_protobuf_UninterpretedOption_NamePart_new(arena);
  2600. return (ret && upb_decode(buf, size, ret, &google_protobuf_UninterpretedOption_NamePart_msginit, arena)) ? ret : NULL;
  2601. }
  2602. UPB_INLINE char *google_protobuf_UninterpretedOption_NamePart_serialize(const google_protobuf_UninterpretedOption_NamePart *msg, upb_arena *arena, size_t *len) {
  2603. return upb_encode(msg, &google_protobuf_UninterpretedOption_NamePart_msginit, arena, len);
  2604. }
  2605. UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_hasbit(msg, 2); }
  2606. UPB_INLINE upb_strview google_protobuf_UninterpretedOption_NamePart_name_part(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  2607. UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_has_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return _upb_hasbit(msg, 1); }
  2608. UPB_INLINE bool google_protobuf_UninterpretedOption_NamePart_is_extension(const google_protobuf_UninterpretedOption_NamePart *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool); }
  2609. UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_name_part(google_protobuf_UninterpretedOption_NamePart *msg, upb_strview value) {
  2610. _upb_sethas(msg, 2);
  2611. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  2612. }
  2613. UPB_INLINE void google_protobuf_UninterpretedOption_NamePart_set_is_extension(google_protobuf_UninterpretedOption_NamePart *msg, bool value) {
  2614. _upb_sethas(msg, 1);
  2615. *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
  2616. }
  2617. /* google.protobuf.SourceCodeInfo */
  2618. UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_new(upb_arena *arena) {
  2619. return (google_protobuf_SourceCodeInfo *)_upb_msg_new(&google_protobuf_SourceCodeInfo_msginit, arena);
  2620. }
  2621. UPB_INLINE google_protobuf_SourceCodeInfo *google_protobuf_SourceCodeInfo_parse(const char *buf, size_t size,
  2622. upb_arena *arena) {
  2623. google_protobuf_SourceCodeInfo *ret = google_protobuf_SourceCodeInfo_new(arena);
  2624. return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_msginit, arena)) ? ret : NULL;
  2625. }
  2626. UPB_INLINE char *google_protobuf_SourceCodeInfo_serialize(const google_protobuf_SourceCodeInfo *msg, upb_arena *arena, size_t *len) {
  2627. return upb_encode(msg, &google_protobuf_SourceCodeInfo_msginit, arena, len);
  2628. }
  2629. UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
  2630. UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf_SourceCodeInfo_location(const google_protobuf_SourceCodeInfo *msg, size_t *len) { return (const google_protobuf_SourceCodeInfo_Location* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
  2631. UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_mutable_location(google_protobuf_SourceCodeInfo *msg, size_t *len) {
  2632. return (google_protobuf_SourceCodeInfo_Location**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
  2633. }
  2634. UPB_INLINE google_protobuf_SourceCodeInfo_Location** google_protobuf_SourceCodeInfo_resize_location(google_protobuf_SourceCodeInfo *msg, size_t len, upb_arena *arena) {
  2635. return (google_protobuf_SourceCodeInfo_Location**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
  2636. }
  2637. UPB_INLINE struct google_protobuf_SourceCodeInfo_Location* google_protobuf_SourceCodeInfo_add_location(google_protobuf_SourceCodeInfo *msg, upb_arena *arena) {
  2638. struct google_protobuf_SourceCodeInfo_Location* sub = (struct google_protobuf_SourceCodeInfo_Location*)_upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
  2639. bool ok = _upb_array_append_accessor(
  2640. msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2641. if (!ok) return NULL;
  2642. return sub;
  2643. }
  2644. /* google.protobuf.SourceCodeInfo.Location */
  2645. UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_new(upb_arena *arena) {
  2646. return (google_protobuf_SourceCodeInfo_Location *)_upb_msg_new(&google_protobuf_SourceCodeInfo_Location_msginit, arena);
  2647. }
  2648. UPB_INLINE google_protobuf_SourceCodeInfo_Location *google_protobuf_SourceCodeInfo_Location_parse(const char *buf, size_t size,
  2649. upb_arena *arena) {
  2650. google_protobuf_SourceCodeInfo_Location *ret = google_protobuf_SourceCodeInfo_Location_new(arena);
  2651. return (ret && upb_decode(buf, size, ret, &google_protobuf_SourceCodeInfo_Location_msginit, arena)) ? ret : NULL;
  2652. }
  2653. UPB_INLINE char *google_protobuf_SourceCodeInfo_Location_serialize(const google_protobuf_SourceCodeInfo_Location *msg, upb_arena *arena, size_t *len) {
  2654. return upb_encode(msg, &google_protobuf_SourceCodeInfo_Location_msginit, arena, len);
  2655. }
  2656. UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 40), len); }
  2657. UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(24, 48), len); }
  2658. UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_hasbit(msg, 1); }
  2659. UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_leading_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview); }
  2660. UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return _upb_hasbit(msg, 2); }
  2661. UPB_INLINE upb_strview google_protobuf_SourceCodeInfo_Location_trailing_comments(const google_protobuf_SourceCodeInfo_Location *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview); }
  2662. UPB_INLINE upb_strview const* google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(28, 56), len); }
  2663. UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_path(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
  2664. return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 40), len);
  2665. }
  2666. UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_path(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
  2667. return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 40), len, UPB_TYPE_INT32, arena);
  2668. }
  2669. UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_path(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) {
  2670. return _upb_array_append_accessor(msg, UPB_SIZE(20, 40), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
  2671. arena);
  2672. }
  2673. UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_mutable_span(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
  2674. return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 48), len);
  2675. }
  2676. UPB_INLINE int32_t* google_protobuf_SourceCodeInfo_Location_resize_span(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
  2677. return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(24, 48), len, UPB_TYPE_INT32, arena);
  2678. }
  2679. UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_span(google_protobuf_SourceCodeInfo_Location *msg, int32_t val, upb_arena *arena) {
  2680. return _upb_array_append_accessor(msg, UPB_SIZE(24, 48), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
  2681. arena);
  2682. }
  2683. UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_leading_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
  2684. _upb_sethas(msg, 1);
  2685. *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_strview) = value;
  2686. }
  2687. UPB_INLINE void google_protobuf_SourceCodeInfo_Location_set_trailing_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview value) {
  2688. _upb_sethas(msg, 2);
  2689. *UPB_PTR_AT(msg, UPB_SIZE(12, 24), upb_strview) = value;
  2690. }
  2691. UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_mutable_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t *len) {
  2692. return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 56), len);
  2693. }
  2694. UPB_INLINE upb_strview* google_protobuf_SourceCodeInfo_Location_resize_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, size_t len, upb_arena *arena) {
  2695. return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(28, 56), len, UPB_TYPE_STRING, arena);
  2696. }
  2697. UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_add_leading_detached_comments(google_protobuf_SourceCodeInfo_Location *msg, upb_strview val, upb_arena *arena) {
  2698. return _upb_array_append_accessor(msg, UPB_SIZE(28, 56), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val,
  2699. arena);
  2700. }
  2701. /* google.protobuf.GeneratedCodeInfo */
  2702. UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_new(upb_arena *arena) {
  2703. return (google_protobuf_GeneratedCodeInfo *)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_msginit, arena);
  2704. }
  2705. UPB_INLINE google_protobuf_GeneratedCodeInfo *google_protobuf_GeneratedCodeInfo_parse(const char *buf, size_t size,
  2706. upb_arena *arena) {
  2707. google_protobuf_GeneratedCodeInfo *ret = google_protobuf_GeneratedCodeInfo_new(arena);
  2708. return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_msginit, arena)) ? ret : NULL;
  2709. }
  2710. UPB_INLINE char *google_protobuf_GeneratedCodeInfo_serialize(const google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena, size_t *len) {
  2711. return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_msginit, arena, len);
  2712. }
  2713. UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo *msg) { return _upb_has_submsg_nohasbit(msg, UPB_SIZE(0, 0)); }
  2714. UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_protobuf_GeneratedCodeInfo_annotation(const google_protobuf_GeneratedCodeInfo *msg, size_t *len) { return (const google_protobuf_GeneratedCodeInfo_Annotation* const*)_upb_array_accessor(msg, UPB_SIZE(0, 0), len); }
  2715. UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_mutable_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t *len) {
  2716. return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_mutable_accessor(msg, UPB_SIZE(0, 0), len);
  2717. }
  2718. UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation** google_protobuf_GeneratedCodeInfo_resize_annotation(google_protobuf_GeneratedCodeInfo *msg, size_t len, upb_arena *arena) {
  2719. return (google_protobuf_GeneratedCodeInfo_Annotation**)_upb_array_resize_accessor(msg, UPB_SIZE(0, 0), len, UPB_TYPE_MESSAGE, arena);
  2720. }
  2721. UPB_INLINE struct google_protobuf_GeneratedCodeInfo_Annotation* google_protobuf_GeneratedCodeInfo_add_annotation(google_protobuf_GeneratedCodeInfo *msg, upb_arena *arena) {
  2722. struct google_protobuf_GeneratedCodeInfo_Annotation* sub = (struct google_protobuf_GeneratedCodeInfo_Annotation*)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
  2723. bool ok = _upb_array_append_accessor(
  2724. msg, UPB_SIZE(0, 0), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena);
  2725. if (!ok) return NULL;
  2726. return sub;
  2727. }
  2728. /* google.protobuf.GeneratedCodeInfo.Annotation */
  2729. UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_new(upb_arena *arena) {
  2730. return (google_protobuf_GeneratedCodeInfo_Annotation *)_upb_msg_new(&google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena);
  2731. }
  2732. UPB_INLINE google_protobuf_GeneratedCodeInfo_Annotation *google_protobuf_GeneratedCodeInfo_Annotation_parse(const char *buf, size_t size,
  2733. upb_arena *arena) {
  2734. google_protobuf_GeneratedCodeInfo_Annotation *ret = google_protobuf_GeneratedCodeInfo_Annotation_new(arena);
  2735. return (ret && upb_decode(buf, size, ret, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena)) ? ret : NULL;
  2736. }
  2737. UPB_INLINE char *google_protobuf_GeneratedCodeInfo_Annotation_serialize(const google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_arena *arena, size_t *len) {
  2738. return upb_encode(msg, &google_protobuf_GeneratedCodeInfo_Annotation_msginit, arena, len);
  2739. }
  2740. UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(const google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) { return (int32_t const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); }
  2741. UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_hasbit(msg, 3); }
  2742. UPB_INLINE upb_strview google_protobuf_GeneratedCodeInfo_Annotation_source_file(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview); }
  2743. UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_hasbit(msg, 1); }
  2744. UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_begin(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t); }
  2745. UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return _upb_hasbit(msg, 2); }
  2746. UPB_INLINE int32_t google_protobuf_GeneratedCodeInfo_Annotation_end(const google_protobuf_GeneratedCodeInfo_Annotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t); }
  2747. UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_mutable_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t *len) {
  2748. return (int32_t*)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len);
  2749. }
  2750. UPB_INLINE int32_t* google_protobuf_GeneratedCodeInfo_Annotation_resize_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, size_t len, upb_arena *arena) {
  2751. return (int32_t*)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_TYPE_INT32, arena);
  2752. }
  2753. UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_add_path(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t val, upb_arena *arena) {
  2754. return _upb_array_append_accessor(msg, UPB_SIZE(20, 32), UPB_SIZE(4, 4), UPB_TYPE_INT32, &val,
  2755. arena);
  2756. }
  2757. UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_source_file(google_protobuf_GeneratedCodeInfo_Annotation *msg, upb_strview value) {
  2758. _upb_sethas(msg, 3);
  2759. *UPB_PTR_AT(msg, UPB_SIZE(12, 16), upb_strview) = value;
  2760. }
  2761. UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_begin(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
  2762. _upb_sethas(msg, 1);
  2763. *UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t) = value;
  2764. }
  2765. UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_protobuf_GeneratedCodeInfo_Annotation *msg, int32_t value) {
  2766. _upb_sethas(msg, 2);
  2767. *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
  2768. }
  2769. #ifdef __cplusplus
  2770. } /* extern "C" */
  2771. #endif
  2772. #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */
  2773. /*
  2774. ** Defs are upb's internal representation of the constructs that can appear
  2775. ** in a .proto file:
  2776. **
  2777. ** - upb_msgdef: describes a "message" construct.
  2778. ** - upb_fielddef: describes a message field.
  2779. ** - upb_filedef: describes a .proto file and its defs.
  2780. ** - upb_enumdef: describes an enum.
  2781. ** - upb_oneofdef: describes a oneof.
  2782. **
  2783. ** TODO: definitions of services.
  2784. */
  2785. #ifndef UPB_DEF_H_
  2786. #define UPB_DEF_H_
  2787. #ifdef __cplusplus
  2788. extern "C" {
  2789. #endif /* __cplusplus */
  2790. struct upb_enumdef;
  2791. typedef struct upb_enumdef upb_enumdef;
  2792. struct upb_fielddef;
  2793. typedef struct upb_fielddef upb_fielddef;
  2794. struct upb_filedef;
  2795. typedef struct upb_filedef upb_filedef;
  2796. struct upb_msgdef;
  2797. typedef struct upb_msgdef upb_msgdef;
  2798. struct upb_oneofdef;
  2799. typedef struct upb_oneofdef upb_oneofdef;
  2800. struct upb_symtab;
  2801. typedef struct upb_symtab upb_symtab;
  2802. typedef enum {
  2803. UPB_SYNTAX_PROTO2 = 2,
  2804. UPB_SYNTAX_PROTO3 = 3
  2805. } upb_syntax_t;
  2806. /* All the different kind of well known type messages. For simplicity of check,
  2807. * number wrappers and string wrappers are grouped together. Make sure the
  2808. * order and merber of these groups are not changed.
  2809. */
  2810. typedef enum {
  2811. UPB_WELLKNOWN_UNSPECIFIED,
  2812. UPB_WELLKNOWN_ANY,
  2813. UPB_WELLKNOWN_FIELDMASK,
  2814. UPB_WELLKNOWN_DURATION,
  2815. UPB_WELLKNOWN_TIMESTAMP,
  2816. /* number wrappers */
  2817. UPB_WELLKNOWN_DOUBLEVALUE,
  2818. UPB_WELLKNOWN_FLOATVALUE,
  2819. UPB_WELLKNOWN_INT64VALUE,
  2820. UPB_WELLKNOWN_UINT64VALUE,
  2821. UPB_WELLKNOWN_INT32VALUE,
  2822. UPB_WELLKNOWN_UINT32VALUE,
  2823. /* string wrappers */
  2824. UPB_WELLKNOWN_STRINGVALUE,
  2825. UPB_WELLKNOWN_BYTESVALUE,
  2826. UPB_WELLKNOWN_BOOLVALUE,
  2827. UPB_WELLKNOWN_VALUE,
  2828. UPB_WELLKNOWN_LISTVALUE,
  2829. UPB_WELLKNOWN_STRUCT
  2830. } upb_wellknowntype_t;
  2831. /* upb_fielddef ***************************************************************/
  2832. /* Maximum field number allowed for FieldDefs. This is an inherent limit of the
  2833. * protobuf wire format. */
  2834. #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
  2835. const char *upb_fielddef_fullname(const upb_fielddef *f);
  2836. upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f);
  2837. upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f);
  2838. upb_label_t upb_fielddef_label(const upb_fielddef *f);
  2839. uint32_t upb_fielddef_number(const upb_fielddef *f);
  2840. const char *upb_fielddef_name(const upb_fielddef *f);
  2841. const char *upb_fielddef_jsonname(const upb_fielddef *f);
  2842. bool upb_fielddef_isextension(const upb_fielddef *f);
  2843. bool upb_fielddef_lazy(const upb_fielddef *f);
  2844. bool upb_fielddef_packed(const upb_fielddef *f);
  2845. const upb_filedef *upb_fielddef_file(const upb_fielddef *f);
  2846. const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
  2847. const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
  2848. const upb_oneofdef *upb_fielddef_realcontainingoneof(const upb_fielddef *f);
  2849. uint32_t upb_fielddef_index(const upb_fielddef *f);
  2850. bool upb_fielddef_issubmsg(const upb_fielddef *f);
  2851. bool upb_fielddef_isstring(const upb_fielddef *f);
  2852. bool upb_fielddef_isseq(const upb_fielddef *f);
  2853. bool upb_fielddef_isprimitive(const upb_fielddef *f);
  2854. bool upb_fielddef_ismap(const upb_fielddef *f);
  2855. int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
  2856. int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
  2857. uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
  2858. uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f);
  2859. bool upb_fielddef_defaultbool(const upb_fielddef *f);
  2860. float upb_fielddef_defaultfloat(const upb_fielddef *f);
  2861. double upb_fielddef_defaultdouble(const upb_fielddef *f);
  2862. const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len);
  2863. bool upb_fielddef_hassubdef(const upb_fielddef *f);
  2864. bool upb_fielddef_haspresence(const upb_fielddef *f);
  2865. const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
  2866. const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
  2867. const upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f);
  2868. /* Internal only. */
  2869. uint32_t upb_fielddef_selectorbase(const upb_fielddef *f);
  2870. /* upb_oneofdef ***************************************************************/
  2871. typedef upb_inttable_iter upb_oneof_iter;
  2872. const char *upb_oneofdef_name(const upb_oneofdef *o);
  2873. const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
  2874. int upb_oneofdef_numfields(const upb_oneofdef *o);
  2875. uint32_t upb_oneofdef_index(const upb_oneofdef *o);
  2876. bool upb_oneofdef_issynthetic(const upb_oneofdef *o);
  2877. /* Oneof lookups:
  2878. * - ntof: look up a field by name.
  2879. * - ntofz: look up a field by name (as a null-terminated string).
  2880. * - itof: look up a field by number. */
  2881. const upb_fielddef *upb_oneofdef_ntof(const upb_oneofdef *o,
  2882. const char *name, size_t length);
  2883. UPB_INLINE const upb_fielddef *upb_oneofdef_ntofz(const upb_oneofdef *o,
  2884. const char *name) {
  2885. return upb_oneofdef_ntof(o, name, strlen(name));
  2886. }
  2887. const upb_fielddef *upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num);
  2888. /* upb_oneof_iter i;
  2889. * for(upb_oneof_begin(&i, e); !upb_oneof_done(&i); upb_oneof_next(&i)) {
  2890. * // ...
  2891. * }
  2892. */
  2893. void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o);
  2894. void upb_oneof_next(upb_oneof_iter *iter);
  2895. bool upb_oneof_done(upb_oneof_iter *iter);
  2896. upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter);
  2897. void upb_oneof_iter_setdone(upb_oneof_iter *iter);
  2898. bool upb_oneof_iter_isequal(const upb_oneof_iter *iter1,
  2899. const upb_oneof_iter *iter2);
  2900. /* upb_msgdef *****************************************************************/
  2901. typedef upb_inttable_iter upb_msg_field_iter;
  2902. typedef upb_strtable_iter upb_msg_oneof_iter;
  2903. /* Well-known field tag numbers for map-entry messages. */
  2904. #define UPB_MAPENTRY_KEY 1
  2905. #define UPB_MAPENTRY_VALUE 2
  2906. /* Well-known field tag numbers for Any messages. */
  2907. #define UPB_ANY_TYPE 1
  2908. #define UPB_ANY_VALUE 2
  2909. /* Well-known field tag numbers for timestamp messages. */
  2910. #define UPB_DURATION_SECONDS 1
  2911. #define UPB_DURATION_NANOS 2
  2912. /* Well-known field tag numbers for duration messages. */
  2913. #define UPB_TIMESTAMP_SECONDS 1
  2914. #define UPB_TIMESTAMP_NANOS 2
  2915. const char *upb_msgdef_fullname(const upb_msgdef *m);
  2916. const upb_filedef *upb_msgdef_file(const upb_msgdef *m);
  2917. const char *upb_msgdef_name(const upb_msgdef *m);
  2918. int upb_msgdef_numfields(const upb_msgdef *m);
  2919. int upb_msgdef_numoneofs(const upb_msgdef *m);
  2920. int upb_msgdef_numrealoneofs(const upb_msgdef *m);
  2921. upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
  2922. bool upb_msgdef_mapentry(const upb_msgdef *m);
  2923. upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m);
  2924. bool upb_msgdef_iswrapper(const upb_msgdef *m);
  2925. bool upb_msgdef_isnumberwrapper(const upb_msgdef *m);
  2926. const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i);
  2927. const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,
  2928. size_t len);
  2929. const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name,
  2930. size_t len);
  2931. const upb_msglayout *upb_msgdef_layout(const upb_msgdef *m);
  2932. const upb_fielddef *_upb_msgdef_field(const upb_msgdef *m, int i);
  2933. UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m,
  2934. const char *name) {
  2935. return upb_msgdef_ntoo(m, name, strlen(name));
  2936. }
  2937. UPB_INLINE const upb_fielddef *upb_msgdef_ntofz(const upb_msgdef *m,
  2938. const char *name) {
  2939. return upb_msgdef_ntof(m, name, strlen(name));
  2940. }
  2941. /* Internal-only. */
  2942. size_t upb_msgdef_selectorcount(const upb_msgdef *m);
  2943. uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m);
  2944. /* Lookup of either field or oneof by name. Returns whether either was found.
  2945. * If the return is true, then the found def will be set, and the non-found
  2946. * one set to NULL. */
  2947. bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
  2948. const upb_fielddef **f, const upb_oneofdef **o);
  2949. UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name,
  2950. const upb_fielddef **f,
  2951. const upb_oneofdef **o) {
  2952. return upb_msgdef_lookupname(m, name, strlen(name), f, o);
  2953. }
  2954. /* Returns a field by either JSON name or regular proto name. */
  2955. const upb_fielddef *upb_msgdef_lookupjsonname(const upb_msgdef *m,
  2956. const char *name, size_t len);
  2957. /* Iteration over fields and oneofs. For example:
  2958. *
  2959. * upb_msg_field_iter i;
  2960. * for(upb_msg_field_begin(&i, m);
  2961. * !upb_msg_field_done(&i);
  2962. * upb_msg_field_next(&i)) {
  2963. * upb_fielddef *f = upb_msg_iter_field(&i);
  2964. * // ...
  2965. * }
  2966. *
  2967. * For C we don't have separate iterators for const and non-const.
  2968. * It is the caller's responsibility to cast the upb_fielddef* to
  2969. * const if the upb_msgdef* is const. */
  2970. void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m);
  2971. void upb_msg_field_next(upb_msg_field_iter *iter);
  2972. bool upb_msg_field_done(const upb_msg_field_iter *iter);
  2973. upb_fielddef *upb_msg_iter_field(const upb_msg_field_iter *iter);
  2974. void upb_msg_field_iter_setdone(upb_msg_field_iter *iter);
  2975. bool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1,
  2976. const upb_msg_field_iter * iter2);
  2977. /* Similar to above, we also support iterating through the oneofs in a
  2978. * msgdef. */
  2979. void upb_msg_oneof_begin(upb_msg_oneof_iter * iter, const upb_msgdef *m);
  2980. void upb_msg_oneof_next(upb_msg_oneof_iter * iter);
  2981. bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter);
  2982. const upb_oneofdef *upb_msg_iter_oneof(const upb_msg_oneof_iter *iter);
  2983. void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter * iter);
  2984. bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1,
  2985. const upb_msg_oneof_iter *iter2);
  2986. /* upb_enumdef ****************************************************************/
  2987. typedef upb_strtable_iter upb_enum_iter;
  2988. const char *upb_enumdef_fullname(const upb_enumdef *e);
  2989. const char *upb_enumdef_name(const upb_enumdef *e);
  2990. const upb_filedef *upb_enumdef_file(const upb_enumdef *e);
  2991. int32_t upb_enumdef_default(const upb_enumdef *e);
  2992. int upb_enumdef_numvals(const upb_enumdef *e);
  2993. /* Enum lookups:
  2994. * - ntoi: look up a name with specified length.
  2995. * - ntoiz: look up a name provided as a null-terminated string.
  2996. * - iton: look up an integer, returning the name as a null-terminated
  2997. * string. */
  2998. bool upb_enumdef_ntoi(const upb_enumdef *e, const char *name, size_t len,
  2999. int32_t *num);
  3000. UPB_INLINE bool upb_enumdef_ntoiz(const upb_enumdef *e,
  3001. const char *name, int32_t *num) {
  3002. return upb_enumdef_ntoi(e, name, strlen(name), num);
  3003. }
  3004. const char *upb_enumdef_iton(const upb_enumdef *e, int32_t num);
  3005. /* upb_enum_iter i;
  3006. * for(upb_enum_begin(&i, e); !upb_enum_done(&i); upb_enum_next(&i)) {
  3007. * // ...
  3008. * }
  3009. */
  3010. void upb_enum_begin(upb_enum_iter *iter, const upb_enumdef *e);
  3011. void upb_enum_next(upb_enum_iter *iter);
  3012. bool upb_enum_done(upb_enum_iter *iter);
  3013. const char *upb_enum_iter_name(upb_enum_iter *iter);
  3014. int32_t upb_enum_iter_number(upb_enum_iter *iter);
  3015. /* upb_filedef ****************************************************************/
  3016. const char *upb_filedef_name(const upb_filedef *f);
  3017. const char *upb_filedef_package(const upb_filedef *f);
  3018. const char *upb_filedef_phpprefix(const upb_filedef *f);
  3019. const char *upb_filedef_phpnamespace(const upb_filedef *f);
  3020. upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
  3021. int upb_filedef_depcount(const upb_filedef *f);
  3022. int upb_filedef_msgcount(const upb_filedef *f);
  3023. int upb_filedef_enumcount(const upb_filedef *f);
  3024. const upb_filedef *upb_filedef_dep(const upb_filedef *f, int i);
  3025. const upb_msgdef *upb_filedef_msg(const upb_filedef *f, int i);
  3026. const upb_enumdef *upb_filedef_enum(const upb_filedef *f, int i);
  3027. /* upb_symtab *****************************************************************/
  3028. upb_symtab *upb_symtab_new(void);
  3029. void upb_symtab_free(upb_symtab* s);
  3030. const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
  3031. const upb_msgdef *upb_symtab_lookupmsg2(
  3032. const upb_symtab *s, const char *sym, size_t len);
  3033. const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
  3034. const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name);
  3035. const upb_filedef *upb_symtab_lookupfile2(
  3036. const upb_symtab *s, const char *name, size_t len);
  3037. int upb_symtab_filecount(const upb_symtab *s);
  3038. const upb_filedef *upb_symtab_addfile(
  3039. upb_symtab *s, const google_protobuf_FileDescriptorProto *file,
  3040. upb_status *status);
  3041. /* For generated code only: loads a generated descriptor. */
  3042. typedef struct upb_def_init {
  3043. struct upb_def_init **deps; /* Dependencies of this file. */
  3044. const upb_msglayout **layouts; /* Pre-order layouts of all messages. */
  3045. const char *filename;
  3046. upb_strview descriptor; /* Serialized descriptor. */
  3047. } upb_def_init;
  3048. bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init);
  3049. #ifdef __cplusplus
  3050. } /* extern "C" */
  3051. #endif /* __cplusplus */
  3052. #endif /* UPB_DEF_H_ */
  3053. /* This file was generated by upbc (the upb compiler) from the input
  3054. * file:
  3055. *
  3056. * google/protobuf/descriptor.proto
  3057. *
  3058. * Do not edit -- your changes will be discarded when the file is
  3059. * regenerated. */
  3060. #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPBDEFS_H_
  3061. #define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPBDEFS_H_
  3062. #ifdef __cplusplus
  3063. extern "C" {
  3064. #endif
  3065. extern upb_def_init google_protobuf_descriptor_proto_upbdefinit;
  3066. UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorSet_getmsgdef(upb_symtab *s) {
  3067. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3068. return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorSet");
  3069. }
  3070. UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorProto_getmsgdef(upb_symtab *s) {
  3071. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3072. return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorProto");
  3073. }
  3074. UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_getmsgdef(upb_symtab *s) {
  3075. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3076. return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto");
  3077. }
  3078. UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ExtensionRange_getmsgdef(upb_symtab *s) {
  3079. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3080. return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ExtensionRange");
  3081. }
  3082. UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ReservedRange_getmsgdef(upb_symtab *s) {
  3083. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3084. return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ReservedRange");
  3085. }
  3086. UPB_INLINE const upb_msgdef *google_protobuf_ExtensionRangeOptions_getmsgdef(upb_symtab *s) {
  3087. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3088. return upb_symtab_lookupmsg(s, "google.protobuf.ExtensionRangeOptions");
  3089. }
  3090. UPB_INLINE const upb_msgdef *google_protobuf_FieldDescriptorProto_getmsgdef(upb_symtab *s) {
  3091. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3092. return upb_symtab_lookupmsg(s, "google.protobuf.FieldDescriptorProto");
  3093. }
  3094. UPB_INLINE const upb_msgdef *google_protobuf_OneofDescriptorProto_getmsgdef(upb_symtab *s) {
  3095. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3096. return upb_symtab_lookupmsg(s, "google.protobuf.OneofDescriptorProto");
  3097. }
  3098. UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_getmsgdef(upb_symtab *s) {
  3099. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3100. return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto");
  3101. }
  3102. UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_EnumReservedRange_getmsgdef(upb_symtab *s) {
  3103. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3104. return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto.EnumReservedRange");
  3105. }
  3106. UPB_INLINE const upb_msgdef *google_protobuf_EnumValueDescriptorProto_getmsgdef(upb_symtab *s) {
  3107. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3108. return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescriptorProto");
  3109. }
  3110. UPB_INLINE const upb_msgdef *google_protobuf_ServiceDescriptorProto_getmsgdef(upb_symtab *s) {
  3111. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3112. return upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto");
  3113. }
  3114. UPB_INLINE const upb_msgdef *google_protobuf_MethodDescriptorProto_getmsgdef(upb_symtab *s) {
  3115. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3116. return upb_symtab_lookupmsg(s, "google.protobuf.MethodDescriptorProto");
  3117. }
  3118. UPB_INLINE const upb_msgdef *google_protobuf_FileOptions_getmsgdef(upb_symtab *s) {
  3119. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3120. return upb_symtab_lookupmsg(s, "google.protobuf.FileOptions");
  3121. }
  3122. UPB_INLINE const upb_msgdef *google_protobuf_MessageOptions_getmsgdef(upb_symtab *s) {
  3123. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3124. return upb_symtab_lookupmsg(s, "google.protobuf.MessageOptions");
  3125. }
  3126. UPB_INLINE const upb_msgdef *google_protobuf_FieldOptions_getmsgdef(upb_symtab *s) {
  3127. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3128. return upb_symtab_lookupmsg(s, "google.protobuf.FieldOptions");
  3129. }
  3130. UPB_INLINE const upb_msgdef *google_protobuf_OneofOptions_getmsgdef(upb_symtab *s) {
  3131. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3132. return upb_symtab_lookupmsg(s, "google.protobuf.OneofOptions");
  3133. }
  3134. UPB_INLINE const upb_msgdef *google_protobuf_EnumOptions_getmsgdef(upb_symtab *s) {
  3135. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3136. return upb_symtab_lookupmsg(s, "google.protobuf.EnumOptions");
  3137. }
  3138. UPB_INLINE const upb_msgdef *google_protobuf_EnumValueOptions_getmsgdef(upb_symtab *s) {
  3139. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3140. return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueOptions");
  3141. }
  3142. UPB_INLINE const upb_msgdef *google_protobuf_ServiceOptions_getmsgdef(upb_symtab *s) {
  3143. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3144. return upb_symtab_lookupmsg(s, "google.protobuf.ServiceOptions");
  3145. }
  3146. UPB_INLINE const upb_msgdef *google_protobuf_MethodOptions_getmsgdef(upb_symtab *s) {
  3147. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3148. return upb_symtab_lookupmsg(s, "google.protobuf.MethodOptions");
  3149. }
  3150. UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_getmsgdef(upb_symtab *s) {
  3151. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3152. return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption");
  3153. }
  3154. UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_NamePart_getmsgdef(upb_symtab *s) {
  3155. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3156. return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption.NamePart");
  3157. }
  3158. UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_getmsgdef(upb_symtab *s) {
  3159. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3160. return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo");
  3161. }
  3162. UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_Location_getmsgdef(upb_symtab *s) {
  3163. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3164. return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo.Location");
  3165. }
  3166. UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_getmsgdef(upb_symtab *s) {
  3167. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3168. return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo");
  3169. }
  3170. UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_Annotation_getmsgdef(upb_symtab *s) {
  3171. _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit);
  3172. return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo.Annotation");
  3173. }
  3174. #ifdef __cplusplus
  3175. } /* extern "C" */
  3176. #endif
  3177. #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPBDEFS_H_ */
  3178. #ifndef UPB_REFLECTION_H_
  3179. #define UPB_REFLECTION_H_
  3180. typedef union {
  3181. bool bool_val;
  3182. float float_val;
  3183. double double_val;
  3184. int32_t int32_val;
  3185. int64_t int64_val;
  3186. uint32_t uint32_val;
  3187. uint64_t uint64_val;
  3188. const upb_map* map_val;
  3189. const upb_msg* msg_val;
  3190. const upb_array* array_val;
  3191. upb_strview str_val;
  3192. } upb_msgval;
  3193. typedef union {
  3194. upb_map* map;
  3195. upb_msg* msg;
  3196. upb_array* array;
  3197. } upb_mutmsgval;
  3198. /** upb_msg *******************************************************************/
  3199. /* Creates a new message of the given type in the given arena. */
  3200. upb_msg *upb_msg_new(const upb_msgdef *m, upb_arena *a);
  3201. /* Returns the value associated with this field. */
  3202. upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f);
  3203. /* Returns a mutable pointer to a map, array, or submessage value. If the given
  3204. * arena is non-NULL this will construct a new object if it was not previously
  3205. * present. May not be called for primitive fields. */
  3206. upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f, upb_arena *a);
  3207. /* May only be called for fields where upb_fielddef_haspresence(f) == true. */
  3208. bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f);
  3209. /* Returns the field that is set in the oneof, or NULL if none are set. */
  3210. const upb_fielddef *upb_msg_whichoneof(const upb_msg *msg,
  3211. const upb_oneofdef *o);
  3212. /* Sets the given field to the given value. For a msg/array/map/string, the
  3213. * value must be in the same arena. */
  3214. void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val,
  3215. upb_arena *a);
  3216. /* Clears any field presence and sets the value back to its default. */
  3217. void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f);
  3218. /* Clear all data and unknown fields. */
  3219. void upb_msg_clear(upb_msg *msg, const upb_msgdef *m);
  3220. /* Iterate over present fields.
  3221. *
  3222. * size_t iter = UPB_MSG_BEGIN;
  3223. * const upb_fielddef *f;
  3224. * upb_msgval val;
  3225. * while (upb_msg_next(msg, m, ext_pool, &f, &val, &iter)) {
  3226. * process_field(f, val);
  3227. * }
  3228. *
  3229. * If ext_pool is NULL, no extensions will be returned. If the given symtab
  3230. * returns extensions that don't match what is in this message, those extensions
  3231. * will be skipped.
  3232. */
  3233. #define UPB_MSG_BEGIN -1
  3234. bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m,
  3235. const upb_symtab *ext_pool, const upb_fielddef **f,
  3236. upb_msgval *val, size_t *iter);
  3237. /* Adds unknown data (serialized protobuf data) to the given message. The data
  3238. * is copied into the message instance. */
  3239. void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
  3240. upb_arena *arena);
  3241. /* Clears all unknown field data from this message and all submessages. */
  3242. bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth);
  3243. /* Returns a reference to the message's unknown data. */
  3244. const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
  3245. /** upb_array *****************************************************************/
  3246. /* Creates a new array on the given arena that holds elements of this type. */
  3247. upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type);
  3248. /* Returns the size of the array. */
  3249. size_t upb_array_size(const upb_array *arr);
  3250. /* Returns the given element, which must be within the array's current size. */
  3251. upb_msgval upb_array_get(const upb_array *arr, size_t i);
  3252. /* Sets the given element, which must be within the array's current size. */
  3253. void upb_array_set(upb_array *arr, size_t i, upb_msgval val);
  3254. /* Appends an element to the array. Returns false on allocation failure. */
  3255. bool upb_array_append(upb_array *array, upb_msgval val, upb_arena *arena);
  3256. /* Changes the size of a vector. New elements are initialized to empty/0.
  3257. * Returns false on allocation failure. */
  3258. bool upb_array_resize(upb_array *array, size_t size, upb_arena *arena);
  3259. /** upb_map *******************************************************************/
  3260. /* Creates a new map on the given arena with the given key/value size. */
  3261. upb_map *upb_map_new(upb_arena *a, upb_fieldtype_t key_type,
  3262. upb_fieldtype_t value_type);
  3263. /* Returns the number of entries in the map. */
  3264. size_t upb_map_size(const upb_map *map);
  3265. /* Stores a value for the given key into |*val| (or the zero value if the key is
  3266. * not present). Returns whether the key was present. The |val| pointer may be
  3267. * NULL, in which case the function tests whether the given key is present. */
  3268. bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val);
  3269. /* Removes all entries in the map. */
  3270. void upb_map_clear(upb_map *map);
  3271. /* Sets the given key to the given value. Returns true if this was a new key in
  3272. * the map, or false if an existing key was replaced. */
  3273. bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
  3274. upb_arena *arena);
  3275. /* Deletes this key from the table. Returns true if the key was present. */
  3276. bool upb_map_delete(upb_map *map, upb_msgval key);
  3277. /* Map iteration:
  3278. *
  3279. * size_t iter = UPB_MAP_BEGIN;
  3280. * while (upb_mapiter_next(map, &iter)) {
  3281. * upb_msgval key = upb_mapiter_key(map, iter);
  3282. * upb_msgval val = upb_mapiter_value(map, iter);
  3283. *
  3284. * // If mutating is desired.
  3285. * upb_mapiter_setvalue(map, iter, value2);
  3286. * }
  3287. */
  3288. /* Advances to the next entry. Returns false if no more entries are present. */
  3289. bool upb_mapiter_next(const upb_map *map, size_t *iter);
  3290. /* Returns true if the iterator still points to a valid entry, or false if the
  3291. * iterator is past the last element. It is an error to call this function with
  3292. * UPB_MAP_BEGIN (you must call next() at least once first). */
  3293. bool upb_mapiter_done(const upb_map *map, size_t iter);
  3294. /* Returns the key and value for this entry of the map. */
  3295. upb_msgval upb_mapiter_key(const upb_map *map, size_t iter);
  3296. upb_msgval upb_mapiter_value(const upb_map *map, size_t iter);
  3297. /* Sets the value for this entry. The iterator must not be done, and the
  3298. * iterator must not have been initialized const. */
  3299. void upb_mapiter_setvalue(upb_map *map, size_t iter, upb_msgval value);
  3300. #endif /* UPB_REFLECTION_H_ */
  3301. #ifndef UPB_JSONDECODE_H_
  3302. #define UPB_JSONDECODE_H_
  3303. #ifdef __cplusplus
  3304. extern "C" {
  3305. #endif
  3306. enum {
  3307. UPB_JSONDEC_IGNOREUNKNOWN = 1
  3308. };
  3309. bool upb_json_decode(const char *buf, size_t size, upb_msg *msg,
  3310. const upb_msgdef *m, const upb_symtab *any_pool,
  3311. int options, upb_arena *arena, upb_status *status);
  3312. #ifdef __cplusplus
  3313. } /* extern "C" */
  3314. #endif
  3315. #endif /* UPB_JSONDECODE_H_ */
  3316. #ifndef UPB_JSONENCODE_H_
  3317. #define UPB_JSONENCODE_H_
  3318. #ifdef __cplusplus
  3319. extern "C" {
  3320. #endif
  3321. enum {
  3322. /* When set, emits 0/default values. TOOD(haberman): proto3 only? */
  3323. UPB_JSONENC_EMITDEFAULTS = 1,
  3324. /* When set, use normal (snake_caes) field names instead of JSON (camelCase)
  3325. names. */
  3326. UPB_JSONENC_PROTONAMES = 2
  3327. };
  3328. /* Encodes the given |msg| to JSON format. The message's reflection is given in
  3329. * |m|. The symtab in |symtab| is used to find extensions (if NULL, extensions
  3330. * will not be printed).
  3331. *
  3332. * Output is placed in the given buffer, and always NULL-terminated. The output
  3333. * size (excluding NULL) is returned. This means that a return value >= |size|
  3334. * implies that the output was truncated. (These are the same semantics as
  3335. * snprintf()). */
  3336. size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
  3337. const upb_symtab *ext_pool, int options, char *buf,
  3338. size_t size, upb_status *status);
  3339. #ifdef __cplusplus
  3340. } /* extern "C" */
  3341. #endif
  3342. #endif /* UPB_JSONENCODE_H_ */
  3343. /* See port_def.inc. This should #undef all macros #defined there. */
  3344. #undef UPB_MAPTYPE_STRING
  3345. #undef UPB_SIZE
  3346. #undef UPB_PTR_AT
  3347. #undef UPB_READ_ONEOF
  3348. #undef UPB_WRITE_ONEOF
  3349. #undef UPB_INLINE
  3350. #undef UPB_ALIGN_UP
  3351. #undef UPB_ALIGN_DOWN
  3352. #undef UPB_ALIGN_MALLOC
  3353. #undef UPB_ALIGN_OF
  3354. #undef UPB_FORCEINLINE
  3355. #undef UPB_NOINLINE
  3356. #undef UPB_NORETURN
  3357. #undef UPB_MAX
  3358. #undef UPB_MIN
  3359. #undef UPB_UNUSED
  3360. #undef UPB_ASSUME
  3361. #undef UPB_ASSERT
  3362. #undef UPB_ASSERT_DEBUGVAR
  3363. #undef UPB_UNREACHABLE
  3364. #undef UPB_INFINITY
  3365. #undef UPB_MSVC_VSNPRINTF
  3366. #undef _upb_snprintf
  3367. #undef _upb_vsnprintf
  3368. #undef _upb_va_copy