ruby-upb.h 223 KB

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