ruby-upb.h 231 KB

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