codec_gen.go 137 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style.
  3. // license that can be found in the LICENSE file.
  4. // Code generated by generate-types. DO NOT EDIT.
  5. package impl
  6. import (
  7. "math"
  8. "unicode/utf8"
  9. "google.golang.org/protobuf/internal/encoding/wire"
  10. "google.golang.org/protobuf/reflect/protoreflect"
  11. )
  12. // sizeBool returns the size of wire encoding a bool pointer as a Bool.
  13. func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
  14. v := *p.Bool()
  15. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  16. }
  17. // appendBool wire encodes a bool pointer as a Bool.
  18. func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  19. v := *p.Bool()
  20. b = wire.AppendVarint(b, wiretag)
  21. b = wire.AppendVarint(b, wire.EncodeBool(v))
  22. return b, nil
  23. }
  24. // consumeBool wire decodes a bool pointer as a Bool.
  25. func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  26. if wtyp != wire.VarintType {
  27. return 0, errUnknown
  28. }
  29. v, n := wire.ConsumeVarint(b)
  30. if n < 0 {
  31. return 0, wire.ParseError(n)
  32. }
  33. *p.Bool() = wire.DecodeBool(v)
  34. return n, nil
  35. }
  36. var coderBool = pointerCoderFuncs{
  37. size: sizeBool,
  38. marshal: appendBool,
  39. unmarshal: consumeBool,
  40. }
  41. // sizeBoolNoZero returns the size of wire encoding a bool pointer as a Bool.
  42. // The zero value is not encoded.
  43. func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  44. v := *p.Bool()
  45. if v == false {
  46. return 0
  47. }
  48. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  49. }
  50. // appendBoolNoZero wire encodes a bool pointer as a Bool.
  51. // The zero value is not encoded.
  52. func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  53. v := *p.Bool()
  54. if v == false {
  55. return b, nil
  56. }
  57. b = wire.AppendVarint(b, wiretag)
  58. b = wire.AppendVarint(b, wire.EncodeBool(v))
  59. return b, nil
  60. }
  61. var coderBoolNoZero = pointerCoderFuncs{
  62. size: sizeBoolNoZero,
  63. marshal: appendBoolNoZero,
  64. unmarshal: consumeBool,
  65. }
  66. // sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
  67. // It panics if the pointer is nil.
  68. func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  69. v := **p.BoolPtr()
  70. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  71. }
  72. // appendBoolPtr wire encodes a *bool pointer as a Bool.
  73. // It panics if the pointer is nil.
  74. func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  75. v := **p.BoolPtr()
  76. b = wire.AppendVarint(b, wiretag)
  77. b = wire.AppendVarint(b, wire.EncodeBool(v))
  78. return b, nil
  79. }
  80. // consumeBoolPtr wire decodes a *bool pointer as a Bool.
  81. func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  82. if wtyp != wire.VarintType {
  83. return 0, errUnknown
  84. }
  85. v, n := wire.ConsumeVarint(b)
  86. if n < 0 {
  87. return 0, wire.ParseError(n)
  88. }
  89. vp := p.BoolPtr()
  90. if *vp == nil {
  91. *vp = new(bool)
  92. }
  93. **vp = wire.DecodeBool(v)
  94. return n, nil
  95. }
  96. var coderBoolPtr = pointerCoderFuncs{
  97. size: sizeBoolPtr,
  98. marshal: appendBoolPtr,
  99. unmarshal: consumeBoolPtr,
  100. }
  101. // sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
  102. func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  103. s := *p.BoolSlice()
  104. for _, v := range s {
  105. size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
  106. }
  107. return size
  108. }
  109. // appendBoolSlice encodes a []bool pointer as a repeated Bool.
  110. func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  111. s := *p.BoolSlice()
  112. for _, v := range s {
  113. b = wire.AppendVarint(b, wiretag)
  114. b = wire.AppendVarint(b, wire.EncodeBool(v))
  115. }
  116. return b, nil
  117. }
  118. // consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
  119. func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  120. sp := p.BoolSlice()
  121. if wtyp == wire.BytesType {
  122. s := *sp
  123. b, n = wire.ConsumeBytes(b)
  124. if n < 0 {
  125. return 0, wire.ParseError(n)
  126. }
  127. for len(b) > 0 {
  128. v, n := wire.ConsumeVarint(b)
  129. if n < 0 {
  130. return 0, wire.ParseError(n)
  131. }
  132. s = append(s, wire.DecodeBool(v))
  133. b = b[n:]
  134. }
  135. *sp = s
  136. return n, nil
  137. }
  138. if wtyp != wire.VarintType {
  139. return 0, errUnknown
  140. }
  141. v, n := wire.ConsumeVarint(b)
  142. if n < 0 {
  143. return 0, wire.ParseError(n)
  144. }
  145. *sp = append(*sp, wire.DecodeBool(v))
  146. return n, nil
  147. }
  148. var coderBoolSlice = pointerCoderFuncs{
  149. size: sizeBoolSlice,
  150. marshal: appendBoolSlice,
  151. unmarshal: consumeBoolSlice,
  152. }
  153. // sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
  154. func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  155. s := *p.BoolSlice()
  156. if len(s) == 0 {
  157. return 0
  158. }
  159. n := 0
  160. for _, v := range s {
  161. n += wire.SizeVarint(wire.EncodeBool(v))
  162. }
  163. return tagsize + wire.SizeBytes(n)
  164. }
  165. // appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
  166. func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  167. s := *p.BoolSlice()
  168. if len(s) == 0 {
  169. return b, nil
  170. }
  171. b = wire.AppendVarint(b, wiretag)
  172. n := 0
  173. for _, v := range s {
  174. n += wire.SizeVarint(wire.EncodeBool(v))
  175. }
  176. b = wire.AppendVarint(b, uint64(n))
  177. for _, v := range s {
  178. b = wire.AppendVarint(b, wire.EncodeBool(v))
  179. }
  180. return b, nil
  181. }
  182. var coderBoolPackedSlice = pointerCoderFuncs{
  183. size: sizeBoolPackedSlice,
  184. marshal: appendBoolPackedSlice,
  185. unmarshal: consumeBoolSlice,
  186. }
  187. // sizeBoolValue returns the size of wire encoding a bool value as a Bool.
  188. func sizeBoolValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  189. return tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
  190. }
  191. // appendBoolValue encodes a bool value as a Bool.
  192. func appendBoolValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  193. b = wire.AppendVarint(b, wiretag)
  194. b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
  195. return b, nil
  196. }
  197. // consumeBoolValue decodes a bool value as a Bool.
  198. func consumeBoolValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  199. if wtyp != wire.VarintType {
  200. return protoreflect.Value{}, 0, errUnknown
  201. }
  202. v, n := wire.ConsumeVarint(b)
  203. if n < 0 {
  204. return protoreflect.Value{}, 0, wire.ParseError(n)
  205. }
  206. return protoreflect.ValueOfBool(wire.DecodeBool(v)), n, nil
  207. }
  208. var coderBoolValue = valueCoderFuncs{
  209. size: sizeBoolValue,
  210. marshal: appendBoolValue,
  211. unmarshal: consumeBoolValue,
  212. }
  213. // sizeBoolSliceValue returns the size of wire encoding a []bool value as a repeated Bool.
  214. func sizeBoolSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  215. list := listv.List()
  216. for i, llen := 0, list.Len(); i < llen; i++ {
  217. v := list.Get(i)
  218. size += tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
  219. }
  220. return size
  221. }
  222. // appendBoolSliceValue encodes a []bool value as a repeated Bool.
  223. func appendBoolSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  224. list := listv.List()
  225. for i, llen := 0, list.Len(); i < llen; i++ {
  226. v := list.Get(i)
  227. b = wire.AppendVarint(b, wiretag)
  228. b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
  229. }
  230. return b, nil
  231. }
  232. // consumeBoolSliceValue wire decodes a []bool value as a repeated Bool.
  233. func consumeBoolSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  234. list := listv.List()
  235. if wtyp == wire.BytesType {
  236. b, n = wire.ConsumeBytes(b)
  237. if n < 0 {
  238. return protoreflect.Value{}, 0, wire.ParseError(n)
  239. }
  240. for len(b) > 0 {
  241. v, n := wire.ConsumeVarint(b)
  242. if n < 0 {
  243. return protoreflect.Value{}, 0, wire.ParseError(n)
  244. }
  245. list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
  246. b = b[n:]
  247. }
  248. return listv, n, nil
  249. }
  250. if wtyp != wire.VarintType {
  251. return protoreflect.Value{}, 0, errUnknown
  252. }
  253. v, n := wire.ConsumeVarint(b)
  254. if n < 0 {
  255. return protoreflect.Value{}, 0, wire.ParseError(n)
  256. }
  257. list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
  258. return listv, n, nil
  259. }
  260. var coderBoolSliceValue = valueCoderFuncs{
  261. size: sizeBoolSliceValue,
  262. marshal: appendBoolSliceValue,
  263. unmarshal: consumeBoolSliceValue,
  264. }
  265. // sizeBoolPackedSliceValue returns the size of wire encoding a []bool value as a packed repeated Bool.
  266. func sizeBoolPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  267. list := listv.List()
  268. n := 0
  269. for i, llen := 0, list.Len(); i < llen; i++ {
  270. v := list.Get(i)
  271. n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
  272. }
  273. return tagsize + wire.SizeBytes(n)
  274. }
  275. // appendBoolPackedSliceValue encodes a []bool value as a packed repeated Bool.
  276. func appendBoolPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  277. list := listv.List()
  278. llen := list.Len()
  279. if llen == 0 {
  280. return b, nil
  281. }
  282. b = wire.AppendVarint(b, wiretag)
  283. n := 0
  284. for i := 0; i < llen; i++ {
  285. v := list.Get(i)
  286. n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
  287. }
  288. b = wire.AppendVarint(b, uint64(n))
  289. for i := 0; i < llen; i++ {
  290. v := list.Get(i)
  291. b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
  292. }
  293. return b, nil
  294. }
  295. var coderBoolPackedSliceValue = valueCoderFuncs{
  296. size: sizeBoolPackedSliceValue,
  297. marshal: appendBoolPackedSliceValue,
  298. unmarshal: consumeBoolSliceValue,
  299. }
  300. // sizeEnumValue returns the size of wire encoding a value as a Enum.
  301. func sizeEnumValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  302. return tagsize + wire.SizeVarint(uint64(v.Enum()))
  303. }
  304. // appendEnumValue encodes a value as a Enum.
  305. func appendEnumValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  306. b = wire.AppendVarint(b, wiretag)
  307. b = wire.AppendVarint(b, uint64(v.Enum()))
  308. return b, nil
  309. }
  310. // consumeEnumValue decodes a value as a Enum.
  311. func consumeEnumValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  312. if wtyp != wire.VarintType {
  313. return protoreflect.Value{}, 0, errUnknown
  314. }
  315. v, n := wire.ConsumeVarint(b)
  316. if n < 0 {
  317. return protoreflect.Value{}, 0, wire.ParseError(n)
  318. }
  319. return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
  320. }
  321. var coderEnumValue = valueCoderFuncs{
  322. size: sizeEnumValue,
  323. marshal: appendEnumValue,
  324. unmarshal: consumeEnumValue,
  325. }
  326. // sizeEnumSliceValue returns the size of wire encoding a [] value as a repeated Enum.
  327. func sizeEnumSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  328. list := listv.List()
  329. for i, llen := 0, list.Len(); i < llen; i++ {
  330. v := list.Get(i)
  331. size += tagsize + wire.SizeVarint(uint64(v.Enum()))
  332. }
  333. return size
  334. }
  335. // appendEnumSliceValue encodes a [] value as a repeated Enum.
  336. func appendEnumSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  337. list := listv.List()
  338. for i, llen := 0, list.Len(); i < llen; i++ {
  339. v := list.Get(i)
  340. b = wire.AppendVarint(b, wiretag)
  341. b = wire.AppendVarint(b, uint64(v.Enum()))
  342. }
  343. return b, nil
  344. }
  345. // consumeEnumSliceValue wire decodes a [] value as a repeated Enum.
  346. func consumeEnumSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  347. list := listv.List()
  348. if wtyp == wire.BytesType {
  349. b, n = wire.ConsumeBytes(b)
  350. if n < 0 {
  351. return protoreflect.Value{}, 0, wire.ParseError(n)
  352. }
  353. for len(b) > 0 {
  354. v, n := wire.ConsumeVarint(b)
  355. if n < 0 {
  356. return protoreflect.Value{}, 0, wire.ParseError(n)
  357. }
  358. list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
  359. b = b[n:]
  360. }
  361. return listv, n, nil
  362. }
  363. if wtyp != wire.VarintType {
  364. return protoreflect.Value{}, 0, errUnknown
  365. }
  366. v, n := wire.ConsumeVarint(b)
  367. if n < 0 {
  368. return protoreflect.Value{}, 0, wire.ParseError(n)
  369. }
  370. list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
  371. return listv, n, nil
  372. }
  373. var coderEnumSliceValue = valueCoderFuncs{
  374. size: sizeEnumSliceValue,
  375. marshal: appendEnumSliceValue,
  376. unmarshal: consumeEnumSliceValue,
  377. }
  378. // sizeEnumPackedSliceValue returns the size of wire encoding a [] value as a packed repeated Enum.
  379. func sizeEnumPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  380. list := listv.List()
  381. n := 0
  382. for i, llen := 0, list.Len(); i < llen; i++ {
  383. v := list.Get(i)
  384. n += wire.SizeVarint(uint64(v.Enum()))
  385. }
  386. return tagsize + wire.SizeBytes(n)
  387. }
  388. // appendEnumPackedSliceValue encodes a [] value as a packed repeated Enum.
  389. func appendEnumPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  390. list := listv.List()
  391. llen := list.Len()
  392. if llen == 0 {
  393. return b, nil
  394. }
  395. b = wire.AppendVarint(b, wiretag)
  396. n := 0
  397. for i := 0; i < llen; i++ {
  398. v := list.Get(i)
  399. n += wire.SizeVarint(uint64(v.Enum()))
  400. }
  401. b = wire.AppendVarint(b, uint64(n))
  402. for i := 0; i < llen; i++ {
  403. v := list.Get(i)
  404. b = wire.AppendVarint(b, uint64(v.Enum()))
  405. }
  406. return b, nil
  407. }
  408. var coderEnumPackedSliceValue = valueCoderFuncs{
  409. size: sizeEnumPackedSliceValue,
  410. marshal: appendEnumPackedSliceValue,
  411. unmarshal: consumeEnumSliceValue,
  412. }
  413. // sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
  414. func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
  415. v := *p.Int32()
  416. return tagsize + wire.SizeVarint(uint64(v))
  417. }
  418. // appendInt32 wire encodes a int32 pointer as a Int32.
  419. func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  420. v := *p.Int32()
  421. b = wire.AppendVarint(b, wiretag)
  422. b = wire.AppendVarint(b, uint64(v))
  423. return b, nil
  424. }
  425. // consumeInt32 wire decodes a int32 pointer as a Int32.
  426. func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  427. if wtyp != wire.VarintType {
  428. return 0, errUnknown
  429. }
  430. v, n := wire.ConsumeVarint(b)
  431. if n < 0 {
  432. return 0, wire.ParseError(n)
  433. }
  434. *p.Int32() = int32(v)
  435. return n, nil
  436. }
  437. var coderInt32 = pointerCoderFuncs{
  438. size: sizeInt32,
  439. marshal: appendInt32,
  440. unmarshal: consumeInt32,
  441. }
  442. // sizeInt32NoZero returns the size of wire encoding a int32 pointer as a Int32.
  443. // The zero value is not encoded.
  444. func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  445. v := *p.Int32()
  446. if v == 0 {
  447. return 0
  448. }
  449. return tagsize + wire.SizeVarint(uint64(v))
  450. }
  451. // appendInt32NoZero wire encodes a int32 pointer as a Int32.
  452. // The zero value is not encoded.
  453. func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  454. v := *p.Int32()
  455. if v == 0 {
  456. return b, nil
  457. }
  458. b = wire.AppendVarint(b, wiretag)
  459. b = wire.AppendVarint(b, uint64(v))
  460. return b, nil
  461. }
  462. var coderInt32NoZero = pointerCoderFuncs{
  463. size: sizeInt32NoZero,
  464. marshal: appendInt32NoZero,
  465. unmarshal: consumeInt32,
  466. }
  467. // sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
  468. // It panics if the pointer is nil.
  469. func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  470. v := **p.Int32Ptr()
  471. return tagsize + wire.SizeVarint(uint64(v))
  472. }
  473. // appendInt32Ptr wire encodes a *int32 pointer as a Int32.
  474. // It panics if the pointer is nil.
  475. func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  476. v := **p.Int32Ptr()
  477. b = wire.AppendVarint(b, wiretag)
  478. b = wire.AppendVarint(b, uint64(v))
  479. return b, nil
  480. }
  481. // consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
  482. func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  483. if wtyp != wire.VarintType {
  484. return 0, errUnknown
  485. }
  486. v, n := wire.ConsumeVarint(b)
  487. if n < 0 {
  488. return 0, wire.ParseError(n)
  489. }
  490. vp := p.Int32Ptr()
  491. if *vp == nil {
  492. *vp = new(int32)
  493. }
  494. **vp = int32(v)
  495. return n, nil
  496. }
  497. var coderInt32Ptr = pointerCoderFuncs{
  498. size: sizeInt32Ptr,
  499. marshal: appendInt32Ptr,
  500. unmarshal: consumeInt32Ptr,
  501. }
  502. // sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
  503. func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  504. s := *p.Int32Slice()
  505. for _, v := range s {
  506. size += tagsize + wire.SizeVarint(uint64(v))
  507. }
  508. return size
  509. }
  510. // appendInt32Slice encodes a []int32 pointer as a repeated Int32.
  511. func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  512. s := *p.Int32Slice()
  513. for _, v := range s {
  514. b = wire.AppendVarint(b, wiretag)
  515. b = wire.AppendVarint(b, uint64(v))
  516. }
  517. return b, nil
  518. }
  519. // consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
  520. func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  521. sp := p.Int32Slice()
  522. if wtyp == wire.BytesType {
  523. s := *sp
  524. b, n = wire.ConsumeBytes(b)
  525. if n < 0 {
  526. return 0, wire.ParseError(n)
  527. }
  528. for len(b) > 0 {
  529. v, n := wire.ConsumeVarint(b)
  530. if n < 0 {
  531. return 0, wire.ParseError(n)
  532. }
  533. s = append(s, int32(v))
  534. b = b[n:]
  535. }
  536. *sp = s
  537. return n, nil
  538. }
  539. if wtyp != wire.VarintType {
  540. return 0, errUnknown
  541. }
  542. v, n := wire.ConsumeVarint(b)
  543. if n < 0 {
  544. return 0, wire.ParseError(n)
  545. }
  546. *sp = append(*sp, int32(v))
  547. return n, nil
  548. }
  549. var coderInt32Slice = pointerCoderFuncs{
  550. size: sizeInt32Slice,
  551. marshal: appendInt32Slice,
  552. unmarshal: consumeInt32Slice,
  553. }
  554. // sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
  555. func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  556. s := *p.Int32Slice()
  557. if len(s) == 0 {
  558. return 0
  559. }
  560. n := 0
  561. for _, v := range s {
  562. n += wire.SizeVarint(uint64(v))
  563. }
  564. return tagsize + wire.SizeBytes(n)
  565. }
  566. // appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
  567. func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  568. s := *p.Int32Slice()
  569. if len(s) == 0 {
  570. return b, nil
  571. }
  572. b = wire.AppendVarint(b, wiretag)
  573. n := 0
  574. for _, v := range s {
  575. n += wire.SizeVarint(uint64(v))
  576. }
  577. b = wire.AppendVarint(b, uint64(n))
  578. for _, v := range s {
  579. b = wire.AppendVarint(b, uint64(v))
  580. }
  581. return b, nil
  582. }
  583. var coderInt32PackedSlice = pointerCoderFuncs{
  584. size: sizeInt32PackedSlice,
  585. marshal: appendInt32PackedSlice,
  586. unmarshal: consumeInt32Slice,
  587. }
  588. // sizeInt32Value returns the size of wire encoding a int32 value as a Int32.
  589. func sizeInt32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  590. return tagsize + wire.SizeVarint(uint64(int32(v.Int())))
  591. }
  592. // appendInt32Value encodes a int32 value as a Int32.
  593. func appendInt32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  594. b = wire.AppendVarint(b, wiretag)
  595. b = wire.AppendVarint(b, uint64(int32(v.Int())))
  596. return b, nil
  597. }
  598. // consumeInt32Value decodes a int32 value as a Int32.
  599. func consumeInt32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  600. if wtyp != wire.VarintType {
  601. return protoreflect.Value{}, 0, errUnknown
  602. }
  603. v, n := wire.ConsumeVarint(b)
  604. if n < 0 {
  605. return protoreflect.Value{}, 0, wire.ParseError(n)
  606. }
  607. return protoreflect.ValueOfInt32(int32(v)), n, nil
  608. }
  609. var coderInt32Value = valueCoderFuncs{
  610. size: sizeInt32Value,
  611. marshal: appendInt32Value,
  612. unmarshal: consumeInt32Value,
  613. }
  614. // sizeInt32SliceValue returns the size of wire encoding a []int32 value as a repeated Int32.
  615. func sizeInt32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  616. list := listv.List()
  617. for i, llen := 0, list.Len(); i < llen; i++ {
  618. v := list.Get(i)
  619. size += tagsize + wire.SizeVarint(uint64(int32(v.Int())))
  620. }
  621. return size
  622. }
  623. // appendInt32SliceValue encodes a []int32 value as a repeated Int32.
  624. func appendInt32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  625. list := listv.List()
  626. for i, llen := 0, list.Len(); i < llen; i++ {
  627. v := list.Get(i)
  628. b = wire.AppendVarint(b, wiretag)
  629. b = wire.AppendVarint(b, uint64(int32(v.Int())))
  630. }
  631. return b, nil
  632. }
  633. // consumeInt32SliceValue wire decodes a []int32 value as a repeated Int32.
  634. func consumeInt32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  635. list := listv.List()
  636. if wtyp == wire.BytesType {
  637. b, n = wire.ConsumeBytes(b)
  638. if n < 0 {
  639. return protoreflect.Value{}, 0, wire.ParseError(n)
  640. }
  641. for len(b) > 0 {
  642. v, n := wire.ConsumeVarint(b)
  643. if n < 0 {
  644. return protoreflect.Value{}, 0, wire.ParseError(n)
  645. }
  646. list.Append(protoreflect.ValueOfInt32(int32(v)))
  647. b = b[n:]
  648. }
  649. return listv, n, nil
  650. }
  651. if wtyp != wire.VarintType {
  652. return protoreflect.Value{}, 0, errUnknown
  653. }
  654. v, n := wire.ConsumeVarint(b)
  655. if n < 0 {
  656. return protoreflect.Value{}, 0, wire.ParseError(n)
  657. }
  658. list.Append(protoreflect.ValueOfInt32(int32(v)))
  659. return listv, n, nil
  660. }
  661. var coderInt32SliceValue = valueCoderFuncs{
  662. size: sizeInt32SliceValue,
  663. marshal: appendInt32SliceValue,
  664. unmarshal: consumeInt32SliceValue,
  665. }
  666. // sizeInt32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Int32.
  667. func sizeInt32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  668. list := listv.List()
  669. n := 0
  670. for i, llen := 0, list.Len(); i < llen; i++ {
  671. v := list.Get(i)
  672. n += wire.SizeVarint(uint64(int32(v.Int())))
  673. }
  674. return tagsize + wire.SizeBytes(n)
  675. }
  676. // appendInt32PackedSliceValue encodes a []int32 value as a packed repeated Int32.
  677. func appendInt32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  678. list := listv.List()
  679. llen := list.Len()
  680. if llen == 0 {
  681. return b, nil
  682. }
  683. b = wire.AppendVarint(b, wiretag)
  684. n := 0
  685. for i := 0; i < llen; i++ {
  686. v := list.Get(i)
  687. n += wire.SizeVarint(uint64(int32(v.Int())))
  688. }
  689. b = wire.AppendVarint(b, uint64(n))
  690. for i := 0; i < llen; i++ {
  691. v := list.Get(i)
  692. b = wire.AppendVarint(b, uint64(int32(v.Int())))
  693. }
  694. return b, nil
  695. }
  696. var coderInt32PackedSliceValue = valueCoderFuncs{
  697. size: sizeInt32PackedSliceValue,
  698. marshal: appendInt32PackedSliceValue,
  699. unmarshal: consumeInt32SliceValue,
  700. }
  701. // sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
  702. func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
  703. v := *p.Int32()
  704. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  705. }
  706. // appendSint32 wire encodes a int32 pointer as a Sint32.
  707. func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  708. v := *p.Int32()
  709. b = wire.AppendVarint(b, wiretag)
  710. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  711. return b, nil
  712. }
  713. // consumeSint32 wire decodes a int32 pointer as a Sint32.
  714. func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  715. if wtyp != wire.VarintType {
  716. return 0, errUnknown
  717. }
  718. v, n := wire.ConsumeVarint(b)
  719. if n < 0 {
  720. return 0, wire.ParseError(n)
  721. }
  722. *p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
  723. return n, nil
  724. }
  725. var coderSint32 = pointerCoderFuncs{
  726. size: sizeSint32,
  727. marshal: appendSint32,
  728. unmarshal: consumeSint32,
  729. }
  730. // sizeSint32NoZero returns the size of wire encoding a int32 pointer as a Sint32.
  731. // The zero value is not encoded.
  732. func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  733. v := *p.Int32()
  734. if v == 0 {
  735. return 0
  736. }
  737. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  738. }
  739. // appendSint32NoZero wire encodes a int32 pointer as a Sint32.
  740. // The zero value is not encoded.
  741. func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  742. v := *p.Int32()
  743. if v == 0 {
  744. return b, nil
  745. }
  746. b = wire.AppendVarint(b, wiretag)
  747. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  748. return b, nil
  749. }
  750. var coderSint32NoZero = pointerCoderFuncs{
  751. size: sizeSint32NoZero,
  752. marshal: appendSint32NoZero,
  753. unmarshal: consumeSint32,
  754. }
  755. // sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
  756. // It panics if the pointer is nil.
  757. func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  758. v := **p.Int32Ptr()
  759. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  760. }
  761. // appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
  762. // It panics if the pointer is nil.
  763. func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  764. v := **p.Int32Ptr()
  765. b = wire.AppendVarint(b, wiretag)
  766. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  767. return b, nil
  768. }
  769. // consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
  770. func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  771. if wtyp != wire.VarintType {
  772. return 0, errUnknown
  773. }
  774. v, n := wire.ConsumeVarint(b)
  775. if n < 0 {
  776. return 0, wire.ParseError(n)
  777. }
  778. vp := p.Int32Ptr()
  779. if *vp == nil {
  780. *vp = new(int32)
  781. }
  782. **vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
  783. return n, nil
  784. }
  785. var coderSint32Ptr = pointerCoderFuncs{
  786. size: sizeSint32Ptr,
  787. marshal: appendSint32Ptr,
  788. unmarshal: consumeSint32Ptr,
  789. }
  790. // sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
  791. func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  792. s := *p.Int32Slice()
  793. for _, v := range s {
  794. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  795. }
  796. return size
  797. }
  798. // appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
  799. func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  800. s := *p.Int32Slice()
  801. for _, v := range s {
  802. b = wire.AppendVarint(b, wiretag)
  803. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  804. }
  805. return b, nil
  806. }
  807. // consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
  808. func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  809. sp := p.Int32Slice()
  810. if wtyp == wire.BytesType {
  811. s := *sp
  812. b, n = wire.ConsumeBytes(b)
  813. if n < 0 {
  814. return 0, wire.ParseError(n)
  815. }
  816. for len(b) > 0 {
  817. v, n := wire.ConsumeVarint(b)
  818. if n < 0 {
  819. return 0, wire.ParseError(n)
  820. }
  821. s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
  822. b = b[n:]
  823. }
  824. *sp = s
  825. return n, nil
  826. }
  827. if wtyp != wire.VarintType {
  828. return 0, errUnknown
  829. }
  830. v, n := wire.ConsumeVarint(b)
  831. if n < 0 {
  832. return 0, wire.ParseError(n)
  833. }
  834. *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
  835. return n, nil
  836. }
  837. var coderSint32Slice = pointerCoderFuncs{
  838. size: sizeSint32Slice,
  839. marshal: appendSint32Slice,
  840. unmarshal: consumeSint32Slice,
  841. }
  842. // sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
  843. func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  844. s := *p.Int32Slice()
  845. if len(s) == 0 {
  846. return 0
  847. }
  848. n := 0
  849. for _, v := range s {
  850. n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  851. }
  852. return tagsize + wire.SizeBytes(n)
  853. }
  854. // appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
  855. func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  856. s := *p.Int32Slice()
  857. if len(s) == 0 {
  858. return b, nil
  859. }
  860. b = wire.AppendVarint(b, wiretag)
  861. n := 0
  862. for _, v := range s {
  863. n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  864. }
  865. b = wire.AppendVarint(b, uint64(n))
  866. for _, v := range s {
  867. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  868. }
  869. return b, nil
  870. }
  871. var coderSint32PackedSlice = pointerCoderFuncs{
  872. size: sizeSint32PackedSlice,
  873. marshal: appendSint32PackedSlice,
  874. unmarshal: consumeSint32Slice,
  875. }
  876. // sizeSint32Value returns the size of wire encoding a int32 value as a Sint32.
  877. func sizeSint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  878. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
  879. }
  880. // appendSint32Value encodes a int32 value as a Sint32.
  881. func appendSint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  882. b = wire.AppendVarint(b, wiretag)
  883. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
  884. return b, nil
  885. }
  886. // consumeSint32Value decodes a int32 value as a Sint32.
  887. func consumeSint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  888. if wtyp != wire.VarintType {
  889. return protoreflect.Value{}, 0, errUnknown
  890. }
  891. v, n := wire.ConsumeVarint(b)
  892. if n < 0 {
  893. return protoreflect.Value{}, 0, wire.ParseError(n)
  894. }
  895. return protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))), n, nil
  896. }
  897. var coderSint32Value = valueCoderFuncs{
  898. size: sizeSint32Value,
  899. marshal: appendSint32Value,
  900. unmarshal: consumeSint32Value,
  901. }
  902. // sizeSint32SliceValue returns the size of wire encoding a []int32 value as a repeated Sint32.
  903. func sizeSint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  904. list := listv.List()
  905. for i, llen := 0, list.Len(); i < llen; i++ {
  906. v := list.Get(i)
  907. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
  908. }
  909. return size
  910. }
  911. // appendSint32SliceValue encodes a []int32 value as a repeated Sint32.
  912. func appendSint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  913. list := listv.List()
  914. for i, llen := 0, list.Len(); i < llen; i++ {
  915. v := list.Get(i)
  916. b = wire.AppendVarint(b, wiretag)
  917. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
  918. }
  919. return b, nil
  920. }
  921. // consumeSint32SliceValue wire decodes a []int32 value as a repeated Sint32.
  922. func consumeSint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  923. list := listv.List()
  924. if wtyp == wire.BytesType {
  925. b, n = wire.ConsumeBytes(b)
  926. if n < 0 {
  927. return protoreflect.Value{}, 0, wire.ParseError(n)
  928. }
  929. for len(b) > 0 {
  930. v, n := wire.ConsumeVarint(b)
  931. if n < 0 {
  932. return protoreflect.Value{}, 0, wire.ParseError(n)
  933. }
  934. list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
  935. b = b[n:]
  936. }
  937. return listv, n, nil
  938. }
  939. if wtyp != wire.VarintType {
  940. return protoreflect.Value{}, 0, errUnknown
  941. }
  942. v, n := wire.ConsumeVarint(b)
  943. if n < 0 {
  944. return protoreflect.Value{}, 0, wire.ParseError(n)
  945. }
  946. list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
  947. return listv, n, nil
  948. }
  949. var coderSint32SliceValue = valueCoderFuncs{
  950. size: sizeSint32SliceValue,
  951. marshal: appendSint32SliceValue,
  952. unmarshal: consumeSint32SliceValue,
  953. }
  954. // sizeSint32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sint32.
  955. func sizeSint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  956. list := listv.List()
  957. n := 0
  958. for i, llen := 0, list.Len(); i < llen; i++ {
  959. v := list.Get(i)
  960. n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
  961. }
  962. return tagsize + wire.SizeBytes(n)
  963. }
  964. // appendSint32PackedSliceValue encodes a []int32 value as a packed repeated Sint32.
  965. func appendSint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  966. list := listv.List()
  967. llen := list.Len()
  968. if llen == 0 {
  969. return b, nil
  970. }
  971. b = wire.AppendVarint(b, wiretag)
  972. n := 0
  973. for i := 0; i < llen; i++ {
  974. v := list.Get(i)
  975. n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
  976. }
  977. b = wire.AppendVarint(b, uint64(n))
  978. for i := 0; i < llen; i++ {
  979. v := list.Get(i)
  980. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
  981. }
  982. return b, nil
  983. }
  984. var coderSint32PackedSliceValue = valueCoderFuncs{
  985. size: sizeSint32PackedSliceValue,
  986. marshal: appendSint32PackedSliceValue,
  987. unmarshal: consumeSint32SliceValue,
  988. }
  989. // sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
  990. func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
  991. v := *p.Uint32()
  992. return tagsize + wire.SizeVarint(uint64(v))
  993. }
  994. // appendUint32 wire encodes a uint32 pointer as a Uint32.
  995. func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  996. v := *p.Uint32()
  997. b = wire.AppendVarint(b, wiretag)
  998. b = wire.AppendVarint(b, uint64(v))
  999. return b, nil
  1000. }
  1001. // consumeUint32 wire decodes a uint32 pointer as a Uint32.
  1002. func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1003. if wtyp != wire.VarintType {
  1004. return 0, errUnknown
  1005. }
  1006. v, n := wire.ConsumeVarint(b)
  1007. if n < 0 {
  1008. return 0, wire.ParseError(n)
  1009. }
  1010. *p.Uint32() = uint32(v)
  1011. return n, nil
  1012. }
  1013. var coderUint32 = pointerCoderFuncs{
  1014. size: sizeUint32,
  1015. marshal: appendUint32,
  1016. unmarshal: consumeUint32,
  1017. }
  1018. // sizeUint32NoZero returns the size of wire encoding a uint32 pointer as a Uint32.
  1019. // The zero value is not encoded.
  1020. func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1021. v := *p.Uint32()
  1022. if v == 0 {
  1023. return 0
  1024. }
  1025. return tagsize + wire.SizeVarint(uint64(v))
  1026. }
  1027. // appendUint32NoZero wire encodes a uint32 pointer as a Uint32.
  1028. // The zero value is not encoded.
  1029. func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1030. v := *p.Uint32()
  1031. if v == 0 {
  1032. return b, nil
  1033. }
  1034. b = wire.AppendVarint(b, wiretag)
  1035. b = wire.AppendVarint(b, uint64(v))
  1036. return b, nil
  1037. }
  1038. var coderUint32NoZero = pointerCoderFuncs{
  1039. size: sizeUint32NoZero,
  1040. marshal: appendUint32NoZero,
  1041. unmarshal: consumeUint32,
  1042. }
  1043. // sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
  1044. // It panics if the pointer is nil.
  1045. func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1046. v := **p.Uint32Ptr()
  1047. return tagsize + wire.SizeVarint(uint64(v))
  1048. }
  1049. // appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
  1050. // It panics if the pointer is nil.
  1051. func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1052. v := **p.Uint32Ptr()
  1053. b = wire.AppendVarint(b, wiretag)
  1054. b = wire.AppendVarint(b, uint64(v))
  1055. return b, nil
  1056. }
  1057. // consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
  1058. func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1059. if wtyp != wire.VarintType {
  1060. return 0, errUnknown
  1061. }
  1062. v, n := wire.ConsumeVarint(b)
  1063. if n < 0 {
  1064. return 0, wire.ParseError(n)
  1065. }
  1066. vp := p.Uint32Ptr()
  1067. if *vp == nil {
  1068. *vp = new(uint32)
  1069. }
  1070. **vp = uint32(v)
  1071. return n, nil
  1072. }
  1073. var coderUint32Ptr = pointerCoderFuncs{
  1074. size: sizeUint32Ptr,
  1075. marshal: appendUint32Ptr,
  1076. unmarshal: consumeUint32Ptr,
  1077. }
  1078. // sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
  1079. func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1080. s := *p.Uint32Slice()
  1081. for _, v := range s {
  1082. size += tagsize + wire.SizeVarint(uint64(v))
  1083. }
  1084. return size
  1085. }
  1086. // appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
  1087. func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1088. s := *p.Uint32Slice()
  1089. for _, v := range s {
  1090. b = wire.AppendVarint(b, wiretag)
  1091. b = wire.AppendVarint(b, uint64(v))
  1092. }
  1093. return b, nil
  1094. }
  1095. // consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
  1096. func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1097. sp := p.Uint32Slice()
  1098. if wtyp == wire.BytesType {
  1099. s := *sp
  1100. b, n = wire.ConsumeBytes(b)
  1101. if n < 0 {
  1102. return 0, wire.ParseError(n)
  1103. }
  1104. for len(b) > 0 {
  1105. v, n := wire.ConsumeVarint(b)
  1106. if n < 0 {
  1107. return 0, wire.ParseError(n)
  1108. }
  1109. s = append(s, uint32(v))
  1110. b = b[n:]
  1111. }
  1112. *sp = s
  1113. return n, nil
  1114. }
  1115. if wtyp != wire.VarintType {
  1116. return 0, errUnknown
  1117. }
  1118. v, n := wire.ConsumeVarint(b)
  1119. if n < 0 {
  1120. return 0, wire.ParseError(n)
  1121. }
  1122. *sp = append(*sp, uint32(v))
  1123. return n, nil
  1124. }
  1125. var coderUint32Slice = pointerCoderFuncs{
  1126. size: sizeUint32Slice,
  1127. marshal: appendUint32Slice,
  1128. unmarshal: consumeUint32Slice,
  1129. }
  1130. // sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
  1131. func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1132. s := *p.Uint32Slice()
  1133. if len(s) == 0 {
  1134. return 0
  1135. }
  1136. n := 0
  1137. for _, v := range s {
  1138. n += wire.SizeVarint(uint64(v))
  1139. }
  1140. return tagsize + wire.SizeBytes(n)
  1141. }
  1142. // appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
  1143. func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1144. s := *p.Uint32Slice()
  1145. if len(s) == 0 {
  1146. return b, nil
  1147. }
  1148. b = wire.AppendVarint(b, wiretag)
  1149. n := 0
  1150. for _, v := range s {
  1151. n += wire.SizeVarint(uint64(v))
  1152. }
  1153. b = wire.AppendVarint(b, uint64(n))
  1154. for _, v := range s {
  1155. b = wire.AppendVarint(b, uint64(v))
  1156. }
  1157. return b, nil
  1158. }
  1159. var coderUint32PackedSlice = pointerCoderFuncs{
  1160. size: sizeUint32PackedSlice,
  1161. marshal: appendUint32PackedSlice,
  1162. unmarshal: consumeUint32Slice,
  1163. }
  1164. // sizeUint32Value returns the size of wire encoding a uint32 value as a Uint32.
  1165. func sizeUint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  1166. return tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
  1167. }
  1168. // appendUint32Value encodes a uint32 value as a Uint32.
  1169. func appendUint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1170. b = wire.AppendVarint(b, wiretag)
  1171. b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
  1172. return b, nil
  1173. }
  1174. // consumeUint32Value decodes a uint32 value as a Uint32.
  1175. func consumeUint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  1176. if wtyp != wire.VarintType {
  1177. return protoreflect.Value{}, 0, errUnknown
  1178. }
  1179. v, n := wire.ConsumeVarint(b)
  1180. if n < 0 {
  1181. return protoreflect.Value{}, 0, wire.ParseError(n)
  1182. }
  1183. return protoreflect.ValueOfUint32(uint32(v)), n, nil
  1184. }
  1185. var coderUint32Value = valueCoderFuncs{
  1186. size: sizeUint32Value,
  1187. marshal: appendUint32Value,
  1188. unmarshal: consumeUint32Value,
  1189. }
  1190. // sizeUint32SliceValue returns the size of wire encoding a []uint32 value as a repeated Uint32.
  1191. func sizeUint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1192. list := listv.List()
  1193. for i, llen := 0, list.Len(); i < llen; i++ {
  1194. v := list.Get(i)
  1195. size += tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
  1196. }
  1197. return size
  1198. }
  1199. // appendUint32SliceValue encodes a []uint32 value as a repeated Uint32.
  1200. func appendUint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1201. list := listv.List()
  1202. for i, llen := 0, list.Len(); i < llen; i++ {
  1203. v := list.Get(i)
  1204. b = wire.AppendVarint(b, wiretag)
  1205. b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
  1206. }
  1207. return b, nil
  1208. }
  1209. // consumeUint32SliceValue wire decodes a []uint32 value as a repeated Uint32.
  1210. func consumeUint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  1211. list := listv.List()
  1212. if wtyp == wire.BytesType {
  1213. b, n = wire.ConsumeBytes(b)
  1214. if n < 0 {
  1215. return protoreflect.Value{}, 0, wire.ParseError(n)
  1216. }
  1217. for len(b) > 0 {
  1218. v, n := wire.ConsumeVarint(b)
  1219. if n < 0 {
  1220. return protoreflect.Value{}, 0, wire.ParseError(n)
  1221. }
  1222. list.Append(protoreflect.ValueOfUint32(uint32(v)))
  1223. b = b[n:]
  1224. }
  1225. return listv, n, nil
  1226. }
  1227. if wtyp != wire.VarintType {
  1228. return protoreflect.Value{}, 0, errUnknown
  1229. }
  1230. v, n := wire.ConsumeVarint(b)
  1231. if n < 0 {
  1232. return protoreflect.Value{}, 0, wire.ParseError(n)
  1233. }
  1234. list.Append(protoreflect.ValueOfUint32(uint32(v)))
  1235. return listv, n, nil
  1236. }
  1237. var coderUint32SliceValue = valueCoderFuncs{
  1238. size: sizeUint32SliceValue,
  1239. marshal: appendUint32SliceValue,
  1240. unmarshal: consumeUint32SliceValue,
  1241. }
  1242. // sizeUint32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Uint32.
  1243. func sizeUint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1244. list := listv.List()
  1245. n := 0
  1246. for i, llen := 0, list.Len(); i < llen; i++ {
  1247. v := list.Get(i)
  1248. n += wire.SizeVarint(uint64(uint32(v.Uint())))
  1249. }
  1250. return tagsize + wire.SizeBytes(n)
  1251. }
  1252. // appendUint32PackedSliceValue encodes a []uint32 value as a packed repeated Uint32.
  1253. func appendUint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1254. list := listv.List()
  1255. llen := list.Len()
  1256. if llen == 0 {
  1257. return b, nil
  1258. }
  1259. b = wire.AppendVarint(b, wiretag)
  1260. n := 0
  1261. for i := 0; i < llen; i++ {
  1262. v := list.Get(i)
  1263. n += wire.SizeVarint(uint64(uint32(v.Uint())))
  1264. }
  1265. b = wire.AppendVarint(b, uint64(n))
  1266. for i := 0; i < llen; i++ {
  1267. v := list.Get(i)
  1268. b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
  1269. }
  1270. return b, nil
  1271. }
  1272. var coderUint32PackedSliceValue = valueCoderFuncs{
  1273. size: sizeUint32PackedSliceValue,
  1274. marshal: appendUint32PackedSliceValue,
  1275. unmarshal: consumeUint32SliceValue,
  1276. }
  1277. // sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
  1278. func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
  1279. v := *p.Int64()
  1280. return tagsize + wire.SizeVarint(uint64(v))
  1281. }
  1282. // appendInt64 wire encodes a int64 pointer as a Int64.
  1283. func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1284. v := *p.Int64()
  1285. b = wire.AppendVarint(b, wiretag)
  1286. b = wire.AppendVarint(b, uint64(v))
  1287. return b, nil
  1288. }
  1289. // consumeInt64 wire decodes a int64 pointer as a Int64.
  1290. func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1291. if wtyp != wire.VarintType {
  1292. return 0, errUnknown
  1293. }
  1294. v, n := wire.ConsumeVarint(b)
  1295. if n < 0 {
  1296. return 0, wire.ParseError(n)
  1297. }
  1298. *p.Int64() = int64(v)
  1299. return n, nil
  1300. }
  1301. var coderInt64 = pointerCoderFuncs{
  1302. size: sizeInt64,
  1303. marshal: appendInt64,
  1304. unmarshal: consumeInt64,
  1305. }
  1306. // sizeInt64NoZero returns the size of wire encoding a int64 pointer as a Int64.
  1307. // The zero value is not encoded.
  1308. func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1309. v := *p.Int64()
  1310. if v == 0 {
  1311. return 0
  1312. }
  1313. return tagsize + wire.SizeVarint(uint64(v))
  1314. }
  1315. // appendInt64NoZero wire encodes a int64 pointer as a Int64.
  1316. // The zero value is not encoded.
  1317. func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1318. v := *p.Int64()
  1319. if v == 0 {
  1320. return b, nil
  1321. }
  1322. b = wire.AppendVarint(b, wiretag)
  1323. b = wire.AppendVarint(b, uint64(v))
  1324. return b, nil
  1325. }
  1326. var coderInt64NoZero = pointerCoderFuncs{
  1327. size: sizeInt64NoZero,
  1328. marshal: appendInt64NoZero,
  1329. unmarshal: consumeInt64,
  1330. }
  1331. // sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
  1332. // It panics if the pointer is nil.
  1333. func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1334. v := **p.Int64Ptr()
  1335. return tagsize + wire.SizeVarint(uint64(v))
  1336. }
  1337. // appendInt64Ptr wire encodes a *int64 pointer as a Int64.
  1338. // It panics if the pointer is nil.
  1339. func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1340. v := **p.Int64Ptr()
  1341. b = wire.AppendVarint(b, wiretag)
  1342. b = wire.AppendVarint(b, uint64(v))
  1343. return b, nil
  1344. }
  1345. // consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
  1346. func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1347. if wtyp != wire.VarintType {
  1348. return 0, errUnknown
  1349. }
  1350. v, n := wire.ConsumeVarint(b)
  1351. if n < 0 {
  1352. return 0, wire.ParseError(n)
  1353. }
  1354. vp := p.Int64Ptr()
  1355. if *vp == nil {
  1356. *vp = new(int64)
  1357. }
  1358. **vp = int64(v)
  1359. return n, nil
  1360. }
  1361. var coderInt64Ptr = pointerCoderFuncs{
  1362. size: sizeInt64Ptr,
  1363. marshal: appendInt64Ptr,
  1364. unmarshal: consumeInt64Ptr,
  1365. }
  1366. // sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
  1367. func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1368. s := *p.Int64Slice()
  1369. for _, v := range s {
  1370. size += tagsize + wire.SizeVarint(uint64(v))
  1371. }
  1372. return size
  1373. }
  1374. // appendInt64Slice encodes a []int64 pointer as a repeated Int64.
  1375. func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1376. s := *p.Int64Slice()
  1377. for _, v := range s {
  1378. b = wire.AppendVarint(b, wiretag)
  1379. b = wire.AppendVarint(b, uint64(v))
  1380. }
  1381. return b, nil
  1382. }
  1383. // consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
  1384. func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1385. sp := p.Int64Slice()
  1386. if wtyp == wire.BytesType {
  1387. s := *sp
  1388. b, n = wire.ConsumeBytes(b)
  1389. if n < 0 {
  1390. return 0, wire.ParseError(n)
  1391. }
  1392. for len(b) > 0 {
  1393. v, n := wire.ConsumeVarint(b)
  1394. if n < 0 {
  1395. return 0, wire.ParseError(n)
  1396. }
  1397. s = append(s, int64(v))
  1398. b = b[n:]
  1399. }
  1400. *sp = s
  1401. return n, nil
  1402. }
  1403. if wtyp != wire.VarintType {
  1404. return 0, errUnknown
  1405. }
  1406. v, n := wire.ConsumeVarint(b)
  1407. if n < 0 {
  1408. return 0, wire.ParseError(n)
  1409. }
  1410. *sp = append(*sp, int64(v))
  1411. return n, nil
  1412. }
  1413. var coderInt64Slice = pointerCoderFuncs{
  1414. size: sizeInt64Slice,
  1415. marshal: appendInt64Slice,
  1416. unmarshal: consumeInt64Slice,
  1417. }
  1418. // sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
  1419. func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1420. s := *p.Int64Slice()
  1421. if len(s) == 0 {
  1422. return 0
  1423. }
  1424. n := 0
  1425. for _, v := range s {
  1426. n += wire.SizeVarint(uint64(v))
  1427. }
  1428. return tagsize + wire.SizeBytes(n)
  1429. }
  1430. // appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
  1431. func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1432. s := *p.Int64Slice()
  1433. if len(s) == 0 {
  1434. return b, nil
  1435. }
  1436. b = wire.AppendVarint(b, wiretag)
  1437. n := 0
  1438. for _, v := range s {
  1439. n += wire.SizeVarint(uint64(v))
  1440. }
  1441. b = wire.AppendVarint(b, uint64(n))
  1442. for _, v := range s {
  1443. b = wire.AppendVarint(b, uint64(v))
  1444. }
  1445. return b, nil
  1446. }
  1447. var coderInt64PackedSlice = pointerCoderFuncs{
  1448. size: sizeInt64PackedSlice,
  1449. marshal: appendInt64PackedSlice,
  1450. unmarshal: consumeInt64Slice,
  1451. }
  1452. // sizeInt64Value returns the size of wire encoding a int64 value as a Int64.
  1453. func sizeInt64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  1454. return tagsize + wire.SizeVarint(uint64(v.Int()))
  1455. }
  1456. // appendInt64Value encodes a int64 value as a Int64.
  1457. func appendInt64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1458. b = wire.AppendVarint(b, wiretag)
  1459. b = wire.AppendVarint(b, uint64(v.Int()))
  1460. return b, nil
  1461. }
  1462. // consumeInt64Value decodes a int64 value as a Int64.
  1463. func consumeInt64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  1464. if wtyp != wire.VarintType {
  1465. return protoreflect.Value{}, 0, errUnknown
  1466. }
  1467. v, n := wire.ConsumeVarint(b)
  1468. if n < 0 {
  1469. return protoreflect.Value{}, 0, wire.ParseError(n)
  1470. }
  1471. return protoreflect.ValueOfInt64(int64(v)), n, nil
  1472. }
  1473. var coderInt64Value = valueCoderFuncs{
  1474. size: sizeInt64Value,
  1475. marshal: appendInt64Value,
  1476. unmarshal: consumeInt64Value,
  1477. }
  1478. // sizeInt64SliceValue returns the size of wire encoding a []int64 value as a repeated Int64.
  1479. func sizeInt64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1480. list := listv.List()
  1481. for i, llen := 0, list.Len(); i < llen; i++ {
  1482. v := list.Get(i)
  1483. size += tagsize + wire.SizeVarint(uint64(v.Int()))
  1484. }
  1485. return size
  1486. }
  1487. // appendInt64SliceValue encodes a []int64 value as a repeated Int64.
  1488. func appendInt64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1489. list := listv.List()
  1490. for i, llen := 0, list.Len(); i < llen; i++ {
  1491. v := list.Get(i)
  1492. b = wire.AppendVarint(b, wiretag)
  1493. b = wire.AppendVarint(b, uint64(v.Int()))
  1494. }
  1495. return b, nil
  1496. }
  1497. // consumeInt64SliceValue wire decodes a []int64 value as a repeated Int64.
  1498. func consumeInt64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  1499. list := listv.List()
  1500. if wtyp == wire.BytesType {
  1501. b, n = wire.ConsumeBytes(b)
  1502. if n < 0 {
  1503. return protoreflect.Value{}, 0, wire.ParseError(n)
  1504. }
  1505. for len(b) > 0 {
  1506. v, n := wire.ConsumeVarint(b)
  1507. if n < 0 {
  1508. return protoreflect.Value{}, 0, wire.ParseError(n)
  1509. }
  1510. list.Append(protoreflect.ValueOfInt64(int64(v)))
  1511. b = b[n:]
  1512. }
  1513. return listv, n, nil
  1514. }
  1515. if wtyp != wire.VarintType {
  1516. return protoreflect.Value{}, 0, errUnknown
  1517. }
  1518. v, n := wire.ConsumeVarint(b)
  1519. if n < 0 {
  1520. return protoreflect.Value{}, 0, wire.ParseError(n)
  1521. }
  1522. list.Append(protoreflect.ValueOfInt64(int64(v)))
  1523. return listv, n, nil
  1524. }
  1525. var coderInt64SliceValue = valueCoderFuncs{
  1526. size: sizeInt64SliceValue,
  1527. marshal: appendInt64SliceValue,
  1528. unmarshal: consumeInt64SliceValue,
  1529. }
  1530. // sizeInt64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Int64.
  1531. func sizeInt64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1532. list := listv.List()
  1533. n := 0
  1534. for i, llen := 0, list.Len(); i < llen; i++ {
  1535. v := list.Get(i)
  1536. n += wire.SizeVarint(uint64(v.Int()))
  1537. }
  1538. return tagsize + wire.SizeBytes(n)
  1539. }
  1540. // appendInt64PackedSliceValue encodes a []int64 value as a packed repeated Int64.
  1541. func appendInt64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1542. list := listv.List()
  1543. llen := list.Len()
  1544. if llen == 0 {
  1545. return b, nil
  1546. }
  1547. b = wire.AppendVarint(b, wiretag)
  1548. n := 0
  1549. for i := 0; i < llen; i++ {
  1550. v := list.Get(i)
  1551. n += wire.SizeVarint(uint64(v.Int()))
  1552. }
  1553. b = wire.AppendVarint(b, uint64(n))
  1554. for i := 0; i < llen; i++ {
  1555. v := list.Get(i)
  1556. b = wire.AppendVarint(b, uint64(v.Int()))
  1557. }
  1558. return b, nil
  1559. }
  1560. var coderInt64PackedSliceValue = valueCoderFuncs{
  1561. size: sizeInt64PackedSliceValue,
  1562. marshal: appendInt64PackedSliceValue,
  1563. unmarshal: consumeInt64SliceValue,
  1564. }
  1565. // sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
  1566. func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
  1567. v := *p.Int64()
  1568. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  1569. }
  1570. // appendSint64 wire encodes a int64 pointer as a Sint64.
  1571. func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1572. v := *p.Int64()
  1573. b = wire.AppendVarint(b, wiretag)
  1574. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  1575. return b, nil
  1576. }
  1577. // consumeSint64 wire decodes a int64 pointer as a Sint64.
  1578. func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1579. if wtyp != wire.VarintType {
  1580. return 0, errUnknown
  1581. }
  1582. v, n := wire.ConsumeVarint(b)
  1583. if n < 0 {
  1584. return 0, wire.ParseError(n)
  1585. }
  1586. *p.Int64() = wire.DecodeZigZag(v)
  1587. return n, nil
  1588. }
  1589. var coderSint64 = pointerCoderFuncs{
  1590. size: sizeSint64,
  1591. marshal: appendSint64,
  1592. unmarshal: consumeSint64,
  1593. }
  1594. // sizeSint64NoZero returns the size of wire encoding a int64 pointer as a Sint64.
  1595. // The zero value is not encoded.
  1596. func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1597. v := *p.Int64()
  1598. if v == 0 {
  1599. return 0
  1600. }
  1601. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  1602. }
  1603. // appendSint64NoZero wire encodes a int64 pointer as a Sint64.
  1604. // The zero value is not encoded.
  1605. func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1606. v := *p.Int64()
  1607. if v == 0 {
  1608. return b, nil
  1609. }
  1610. b = wire.AppendVarint(b, wiretag)
  1611. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  1612. return b, nil
  1613. }
  1614. var coderSint64NoZero = pointerCoderFuncs{
  1615. size: sizeSint64NoZero,
  1616. marshal: appendSint64NoZero,
  1617. unmarshal: consumeSint64,
  1618. }
  1619. // sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
  1620. // It panics if the pointer is nil.
  1621. func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1622. v := **p.Int64Ptr()
  1623. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  1624. }
  1625. // appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
  1626. // It panics if the pointer is nil.
  1627. func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1628. v := **p.Int64Ptr()
  1629. b = wire.AppendVarint(b, wiretag)
  1630. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  1631. return b, nil
  1632. }
  1633. // consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
  1634. func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1635. if wtyp != wire.VarintType {
  1636. return 0, errUnknown
  1637. }
  1638. v, n := wire.ConsumeVarint(b)
  1639. if n < 0 {
  1640. return 0, wire.ParseError(n)
  1641. }
  1642. vp := p.Int64Ptr()
  1643. if *vp == nil {
  1644. *vp = new(int64)
  1645. }
  1646. **vp = wire.DecodeZigZag(v)
  1647. return n, nil
  1648. }
  1649. var coderSint64Ptr = pointerCoderFuncs{
  1650. size: sizeSint64Ptr,
  1651. marshal: appendSint64Ptr,
  1652. unmarshal: consumeSint64Ptr,
  1653. }
  1654. // sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
  1655. func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1656. s := *p.Int64Slice()
  1657. for _, v := range s {
  1658. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  1659. }
  1660. return size
  1661. }
  1662. // appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
  1663. func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1664. s := *p.Int64Slice()
  1665. for _, v := range s {
  1666. b = wire.AppendVarint(b, wiretag)
  1667. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  1668. }
  1669. return b, nil
  1670. }
  1671. // consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
  1672. func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1673. sp := p.Int64Slice()
  1674. if wtyp == wire.BytesType {
  1675. s := *sp
  1676. b, n = wire.ConsumeBytes(b)
  1677. if n < 0 {
  1678. return 0, wire.ParseError(n)
  1679. }
  1680. for len(b) > 0 {
  1681. v, n := wire.ConsumeVarint(b)
  1682. if n < 0 {
  1683. return 0, wire.ParseError(n)
  1684. }
  1685. s = append(s, wire.DecodeZigZag(v))
  1686. b = b[n:]
  1687. }
  1688. *sp = s
  1689. return n, nil
  1690. }
  1691. if wtyp != wire.VarintType {
  1692. return 0, errUnknown
  1693. }
  1694. v, n := wire.ConsumeVarint(b)
  1695. if n < 0 {
  1696. return 0, wire.ParseError(n)
  1697. }
  1698. *sp = append(*sp, wire.DecodeZigZag(v))
  1699. return n, nil
  1700. }
  1701. var coderSint64Slice = pointerCoderFuncs{
  1702. size: sizeSint64Slice,
  1703. marshal: appendSint64Slice,
  1704. unmarshal: consumeSint64Slice,
  1705. }
  1706. // sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
  1707. func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1708. s := *p.Int64Slice()
  1709. if len(s) == 0 {
  1710. return 0
  1711. }
  1712. n := 0
  1713. for _, v := range s {
  1714. n += wire.SizeVarint(wire.EncodeZigZag(v))
  1715. }
  1716. return tagsize + wire.SizeBytes(n)
  1717. }
  1718. // appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
  1719. func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1720. s := *p.Int64Slice()
  1721. if len(s) == 0 {
  1722. return b, nil
  1723. }
  1724. b = wire.AppendVarint(b, wiretag)
  1725. n := 0
  1726. for _, v := range s {
  1727. n += wire.SizeVarint(wire.EncodeZigZag(v))
  1728. }
  1729. b = wire.AppendVarint(b, uint64(n))
  1730. for _, v := range s {
  1731. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  1732. }
  1733. return b, nil
  1734. }
  1735. var coderSint64PackedSlice = pointerCoderFuncs{
  1736. size: sizeSint64PackedSlice,
  1737. marshal: appendSint64PackedSlice,
  1738. unmarshal: consumeSint64Slice,
  1739. }
  1740. // sizeSint64Value returns the size of wire encoding a int64 value as a Sint64.
  1741. func sizeSint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  1742. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
  1743. }
  1744. // appendSint64Value encodes a int64 value as a Sint64.
  1745. func appendSint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1746. b = wire.AppendVarint(b, wiretag)
  1747. b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
  1748. return b, nil
  1749. }
  1750. // consumeSint64Value decodes a int64 value as a Sint64.
  1751. func consumeSint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  1752. if wtyp != wire.VarintType {
  1753. return protoreflect.Value{}, 0, errUnknown
  1754. }
  1755. v, n := wire.ConsumeVarint(b)
  1756. if n < 0 {
  1757. return protoreflect.Value{}, 0, wire.ParseError(n)
  1758. }
  1759. return protoreflect.ValueOfInt64(wire.DecodeZigZag(v)), n, nil
  1760. }
  1761. var coderSint64Value = valueCoderFuncs{
  1762. size: sizeSint64Value,
  1763. marshal: appendSint64Value,
  1764. unmarshal: consumeSint64Value,
  1765. }
  1766. // sizeSint64SliceValue returns the size of wire encoding a []int64 value as a repeated Sint64.
  1767. func sizeSint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1768. list := listv.List()
  1769. for i, llen := 0, list.Len(); i < llen; i++ {
  1770. v := list.Get(i)
  1771. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
  1772. }
  1773. return size
  1774. }
  1775. // appendSint64SliceValue encodes a []int64 value as a repeated Sint64.
  1776. func appendSint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1777. list := listv.List()
  1778. for i, llen := 0, list.Len(); i < llen; i++ {
  1779. v := list.Get(i)
  1780. b = wire.AppendVarint(b, wiretag)
  1781. b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
  1782. }
  1783. return b, nil
  1784. }
  1785. // consumeSint64SliceValue wire decodes a []int64 value as a repeated Sint64.
  1786. func consumeSint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  1787. list := listv.List()
  1788. if wtyp == wire.BytesType {
  1789. b, n = wire.ConsumeBytes(b)
  1790. if n < 0 {
  1791. return protoreflect.Value{}, 0, wire.ParseError(n)
  1792. }
  1793. for len(b) > 0 {
  1794. v, n := wire.ConsumeVarint(b)
  1795. if n < 0 {
  1796. return protoreflect.Value{}, 0, wire.ParseError(n)
  1797. }
  1798. list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
  1799. b = b[n:]
  1800. }
  1801. return listv, n, nil
  1802. }
  1803. if wtyp != wire.VarintType {
  1804. return protoreflect.Value{}, 0, errUnknown
  1805. }
  1806. v, n := wire.ConsumeVarint(b)
  1807. if n < 0 {
  1808. return protoreflect.Value{}, 0, wire.ParseError(n)
  1809. }
  1810. list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
  1811. return listv, n, nil
  1812. }
  1813. var coderSint64SliceValue = valueCoderFuncs{
  1814. size: sizeSint64SliceValue,
  1815. marshal: appendSint64SliceValue,
  1816. unmarshal: consumeSint64SliceValue,
  1817. }
  1818. // sizeSint64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sint64.
  1819. func sizeSint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  1820. list := listv.List()
  1821. n := 0
  1822. for i, llen := 0, list.Len(); i < llen; i++ {
  1823. v := list.Get(i)
  1824. n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
  1825. }
  1826. return tagsize + wire.SizeBytes(n)
  1827. }
  1828. // appendSint64PackedSliceValue encodes a []int64 value as a packed repeated Sint64.
  1829. func appendSint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1830. list := listv.List()
  1831. llen := list.Len()
  1832. if llen == 0 {
  1833. return b, nil
  1834. }
  1835. b = wire.AppendVarint(b, wiretag)
  1836. n := 0
  1837. for i := 0; i < llen; i++ {
  1838. v := list.Get(i)
  1839. n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
  1840. }
  1841. b = wire.AppendVarint(b, uint64(n))
  1842. for i := 0; i < llen; i++ {
  1843. v := list.Get(i)
  1844. b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
  1845. }
  1846. return b, nil
  1847. }
  1848. var coderSint64PackedSliceValue = valueCoderFuncs{
  1849. size: sizeSint64PackedSliceValue,
  1850. marshal: appendSint64PackedSliceValue,
  1851. unmarshal: consumeSint64SliceValue,
  1852. }
  1853. // sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
  1854. func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
  1855. v := *p.Uint64()
  1856. return tagsize + wire.SizeVarint(v)
  1857. }
  1858. // appendUint64 wire encodes a uint64 pointer as a Uint64.
  1859. func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1860. v := *p.Uint64()
  1861. b = wire.AppendVarint(b, wiretag)
  1862. b = wire.AppendVarint(b, v)
  1863. return b, nil
  1864. }
  1865. // consumeUint64 wire decodes a uint64 pointer as a Uint64.
  1866. func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1867. if wtyp != wire.VarintType {
  1868. return 0, errUnknown
  1869. }
  1870. v, n := wire.ConsumeVarint(b)
  1871. if n < 0 {
  1872. return 0, wire.ParseError(n)
  1873. }
  1874. *p.Uint64() = v
  1875. return n, nil
  1876. }
  1877. var coderUint64 = pointerCoderFuncs{
  1878. size: sizeUint64,
  1879. marshal: appendUint64,
  1880. unmarshal: consumeUint64,
  1881. }
  1882. // sizeUint64NoZero returns the size of wire encoding a uint64 pointer as a Uint64.
  1883. // The zero value is not encoded.
  1884. func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1885. v := *p.Uint64()
  1886. if v == 0 {
  1887. return 0
  1888. }
  1889. return tagsize + wire.SizeVarint(v)
  1890. }
  1891. // appendUint64NoZero wire encodes a uint64 pointer as a Uint64.
  1892. // The zero value is not encoded.
  1893. func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1894. v := *p.Uint64()
  1895. if v == 0 {
  1896. return b, nil
  1897. }
  1898. b = wire.AppendVarint(b, wiretag)
  1899. b = wire.AppendVarint(b, v)
  1900. return b, nil
  1901. }
  1902. var coderUint64NoZero = pointerCoderFuncs{
  1903. size: sizeUint64NoZero,
  1904. marshal: appendUint64NoZero,
  1905. unmarshal: consumeUint64,
  1906. }
  1907. // sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
  1908. // It panics if the pointer is nil.
  1909. func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1910. v := **p.Uint64Ptr()
  1911. return tagsize + wire.SizeVarint(v)
  1912. }
  1913. // appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
  1914. // It panics if the pointer is nil.
  1915. func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1916. v := **p.Uint64Ptr()
  1917. b = wire.AppendVarint(b, wiretag)
  1918. b = wire.AppendVarint(b, v)
  1919. return b, nil
  1920. }
  1921. // consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
  1922. func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1923. if wtyp != wire.VarintType {
  1924. return 0, errUnknown
  1925. }
  1926. v, n := wire.ConsumeVarint(b)
  1927. if n < 0 {
  1928. return 0, wire.ParseError(n)
  1929. }
  1930. vp := p.Uint64Ptr()
  1931. if *vp == nil {
  1932. *vp = new(uint64)
  1933. }
  1934. **vp = v
  1935. return n, nil
  1936. }
  1937. var coderUint64Ptr = pointerCoderFuncs{
  1938. size: sizeUint64Ptr,
  1939. marshal: appendUint64Ptr,
  1940. unmarshal: consumeUint64Ptr,
  1941. }
  1942. // sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
  1943. func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1944. s := *p.Uint64Slice()
  1945. for _, v := range s {
  1946. size += tagsize + wire.SizeVarint(v)
  1947. }
  1948. return size
  1949. }
  1950. // appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
  1951. func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1952. s := *p.Uint64Slice()
  1953. for _, v := range s {
  1954. b = wire.AppendVarint(b, wiretag)
  1955. b = wire.AppendVarint(b, v)
  1956. }
  1957. return b, nil
  1958. }
  1959. // consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
  1960. func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  1961. sp := p.Uint64Slice()
  1962. if wtyp == wire.BytesType {
  1963. s := *sp
  1964. b, n = wire.ConsumeBytes(b)
  1965. if n < 0 {
  1966. return 0, wire.ParseError(n)
  1967. }
  1968. for len(b) > 0 {
  1969. v, n := wire.ConsumeVarint(b)
  1970. if n < 0 {
  1971. return 0, wire.ParseError(n)
  1972. }
  1973. s = append(s, v)
  1974. b = b[n:]
  1975. }
  1976. *sp = s
  1977. return n, nil
  1978. }
  1979. if wtyp != wire.VarintType {
  1980. return 0, errUnknown
  1981. }
  1982. v, n := wire.ConsumeVarint(b)
  1983. if n < 0 {
  1984. return 0, wire.ParseError(n)
  1985. }
  1986. *sp = append(*sp, v)
  1987. return n, nil
  1988. }
  1989. var coderUint64Slice = pointerCoderFuncs{
  1990. size: sizeUint64Slice,
  1991. marshal: appendUint64Slice,
  1992. unmarshal: consumeUint64Slice,
  1993. }
  1994. // sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
  1995. func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1996. s := *p.Uint64Slice()
  1997. if len(s) == 0 {
  1998. return 0
  1999. }
  2000. n := 0
  2001. for _, v := range s {
  2002. n += wire.SizeVarint(v)
  2003. }
  2004. return tagsize + wire.SizeBytes(n)
  2005. }
  2006. // appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
  2007. func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2008. s := *p.Uint64Slice()
  2009. if len(s) == 0 {
  2010. return b, nil
  2011. }
  2012. b = wire.AppendVarint(b, wiretag)
  2013. n := 0
  2014. for _, v := range s {
  2015. n += wire.SizeVarint(v)
  2016. }
  2017. b = wire.AppendVarint(b, uint64(n))
  2018. for _, v := range s {
  2019. b = wire.AppendVarint(b, v)
  2020. }
  2021. return b, nil
  2022. }
  2023. var coderUint64PackedSlice = pointerCoderFuncs{
  2024. size: sizeUint64PackedSlice,
  2025. marshal: appendUint64PackedSlice,
  2026. unmarshal: consumeUint64Slice,
  2027. }
  2028. // sizeUint64Value returns the size of wire encoding a uint64 value as a Uint64.
  2029. func sizeUint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  2030. return tagsize + wire.SizeVarint(v.Uint())
  2031. }
  2032. // appendUint64Value encodes a uint64 value as a Uint64.
  2033. func appendUint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2034. b = wire.AppendVarint(b, wiretag)
  2035. b = wire.AppendVarint(b, v.Uint())
  2036. return b, nil
  2037. }
  2038. // consumeUint64Value decodes a uint64 value as a Uint64.
  2039. func consumeUint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  2040. if wtyp != wire.VarintType {
  2041. return protoreflect.Value{}, 0, errUnknown
  2042. }
  2043. v, n := wire.ConsumeVarint(b)
  2044. if n < 0 {
  2045. return protoreflect.Value{}, 0, wire.ParseError(n)
  2046. }
  2047. return protoreflect.ValueOfUint64(v), n, nil
  2048. }
  2049. var coderUint64Value = valueCoderFuncs{
  2050. size: sizeUint64Value,
  2051. marshal: appendUint64Value,
  2052. unmarshal: consumeUint64Value,
  2053. }
  2054. // sizeUint64SliceValue returns the size of wire encoding a []uint64 value as a repeated Uint64.
  2055. func sizeUint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2056. list := listv.List()
  2057. for i, llen := 0, list.Len(); i < llen; i++ {
  2058. v := list.Get(i)
  2059. size += tagsize + wire.SizeVarint(v.Uint())
  2060. }
  2061. return size
  2062. }
  2063. // appendUint64SliceValue encodes a []uint64 value as a repeated Uint64.
  2064. func appendUint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2065. list := listv.List()
  2066. for i, llen := 0, list.Len(); i < llen; i++ {
  2067. v := list.Get(i)
  2068. b = wire.AppendVarint(b, wiretag)
  2069. b = wire.AppendVarint(b, v.Uint())
  2070. }
  2071. return b, nil
  2072. }
  2073. // consumeUint64SliceValue wire decodes a []uint64 value as a repeated Uint64.
  2074. func consumeUint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  2075. list := listv.List()
  2076. if wtyp == wire.BytesType {
  2077. b, n = wire.ConsumeBytes(b)
  2078. if n < 0 {
  2079. return protoreflect.Value{}, 0, wire.ParseError(n)
  2080. }
  2081. for len(b) > 0 {
  2082. v, n := wire.ConsumeVarint(b)
  2083. if n < 0 {
  2084. return protoreflect.Value{}, 0, wire.ParseError(n)
  2085. }
  2086. list.Append(protoreflect.ValueOfUint64(v))
  2087. b = b[n:]
  2088. }
  2089. return listv, n, nil
  2090. }
  2091. if wtyp != wire.VarintType {
  2092. return protoreflect.Value{}, 0, errUnknown
  2093. }
  2094. v, n := wire.ConsumeVarint(b)
  2095. if n < 0 {
  2096. return protoreflect.Value{}, 0, wire.ParseError(n)
  2097. }
  2098. list.Append(protoreflect.ValueOfUint64(v))
  2099. return listv, n, nil
  2100. }
  2101. var coderUint64SliceValue = valueCoderFuncs{
  2102. size: sizeUint64SliceValue,
  2103. marshal: appendUint64SliceValue,
  2104. unmarshal: consumeUint64SliceValue,
  2105. }
  2106. // sizeUint64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Uint64.
  2107. func sizeUint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2108. list := listv.List()
  2109. n := 0
  2110. for i, llen := 0, list.Len(); i < llen; i++ {
  2111. v := list.Get(i)
  2112. n += wire.SizeVarint(v.Uint())
  2113. }
  2114. return tagsize + wire.SizeBytes(n)
  2115. }
  2116. // appendUint64PackedSliceValue encodes a []uint64 value as a packed repeated Uint64.
  2117. func appendUint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2118. list := listv.List()
  2119. llen := list.Len()
  2120. if llen == 0 {
  2121. return b, nil
  2122. }
  2123. b = wire.AppendVarint(b, wiretag)
  2124. n := 0
  2125. for i := 0; i < llen; i++ {
  2126. v := list.Get(i)
  2127. n += wire.SizeVarint(v.Uint())
  2128. }
  2129. b = wire.AppendVarint(b, uint64(n))
  2130. for i := 0; i < llen; i++ {
  2131. v := list.Get(i)
  2132. b = wire.AppendVarint(b, v.Uint())
  2133. }
  2134. return b, nil
  2135. }
  2136. var coderUint64PackedSliceValue = valueCoderFuncs{
  2137. size: sizeUint64PackedSliceValue,
  2138. marshal: appendUint64PackedSliceValue,
  2139. unmarshal: consumeUint64SliceValue,
  2140. }
  2141. // sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
  2142. func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
  2143. return tagsize + wire.SizeFixed32()
  2144. }
  2145. // appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
  2146. func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2147. v := *p.Int32()
  2148. b = wire.AppendVarint(b, wiretag)
  2149. b = wire.AppendFixed32(b, uint32(v))
  2150. return b, nil
  2151. }
  2152. // consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
  2153. func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2154. if wtyp != wire.Fixed32Type {
  2155. return 0, errUnknown
  2156. }
  2157. v, n := wire.ConsumeFixed32(b)
  2158. if n < 0 {
  2159. return 0, wire.ParseError(n)
  2160. }
  2161. *p.Int32() = int32(v)
  2162. return n, nil
  2163. }
  2164. var coderSfixed32 = pointerCoderFuncs{
  2165. size: sizeSfixed32,
  2166. marshal: appendSfixed32,
  2167. unmarshal: consumeSfixed32,
  2168. }
  2169. // sizeSfixed32NoZero returns the size of wire encoding a int32 pointer as a Sfixed32.
  2170. // The zero value is not encoded.
  2171. func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  2172. v := *p.Int32()
  2173. if v == 0 {
  2174. return 0
  2175. }
  2176. return tagsize + wire.SizeFixed32()
  2177. }
  2178. // appendSfixed32NoZero wire encodes a int32 pointer as a Sfixed32.
  2179. // The zero value is not encoded.
  2180. func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2181. v := *p.Int32()
  2182. if v == 0 {
  2183. return b, nil
  2184. }
  2185. b = wire.AppendVarint(b, wiretag)
  2186. b = wire.AppendFixed32(b, uint32(v))
  2187. return b, nil
  2188. }
  2189. var coderSfixed32NoZero = pointerCoderFuncs{
  2190. size: sizeSfixed32NoZero,
  2191. marshal: appendSfixed32NoZero,
  2192. unmarshal: consumeSfixed32,
  2193. }
  2194. // sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
  2195. // It panics if the pointer is nil.
  2196. func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  2197. return tagsize + wire.SizeFixed32()
  2198. }
  2199. // appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
  2200. // It panics if the pointer is nil.
  2201. func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2202. v := **p.Int32Ptr()
  2203. b = wire.AppendVarint(b, wiretag)
  2204. b = wire.AppendFixed32(b, uint32(v))
  2205. return b, nil
  2206. }
  2207. // consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
  2208. func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2209. if wtyp != wire.Fixed32Type {
  2210. return 0, errUnknown
  2211. }
  2212. v, n := wire.ConsumeFixed32(b)
  2213. if n < 0 {
  2214. return 0, wire.ParseError(n)
  2215. }
  2216. vp := p.Int32Ptr()
  2217. if *vp == nil {
  2218. *vp = new(int32)
  2219. }
  2220. **vp = int32(v)
  2221. return n, nil
  2222. }
  2223. var coderSfixed32Ptr = pointerCoderFuncs{
  2224. size: sizeSfixed32Ptr,
  2225. marshal: appendSfixed32Ptr,
  2226. unmarshal: consumeSfixed32Ptr,
  2227. }
  2228. // sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
  2229. func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2230. s := *p.Int32Slice()
  2231. size = len(s) * (tagsize + wire.SizeFixed32())
  2232. return size
  2233. }
  2234. // appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
  2235. func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2236. s := *p.Int32Slice()
  2237. for _, v := range s {
  2238. b = wire.AppendVarint(b, wiretag)
  2239. b = wire.AppendFixed32(b, uint32(v))
  2240. }
  2241. return b, nil
  2242. }
  2243. // consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
  2244. func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2245. sp := p.Int32Slice()
  2246. if wtyp == wire.BytesType {
  2247. s := *sp
  2248. b, n = wire.ConsumeBytes(b)
  2249. if n < 0 {
  2250. return 0, wire.ParseError(n)
  2251. }
  2252. for len(b) > 0 {
  2253. v, n := wire.ConsumeFixed32(b)
  2254. if n < 0 {
  2255. return 0, wire.ParseError(n)
  2256. }
  2257. s = append(s, int32(v))
  2258. b = b[n:]
  2259. }
  2260. *sp = s
  2261. return n, nil
  2262. }
  2263. if wtyp != wire.Fixed32Type {
  2264. return 0, errUnknown
  2265. }
  2266. v, n := wire.ConsumeFixed32(b)
  2267. if n < 0 {
  2268. return 0, wire.ParseError(n)
  2269. }
  2270. *sp = append(*sp, int32(v))
  2271. return n, nil
  2272. }
  2273. var coderSfixed32Slice = pointerCoderFuncs{
  2274. size: sizeSfixed32Slice,
  2275. marshal: appendSfixed32Slice,
  2276. unmarshal: consumeSfixed32Slice,
  2277. }
  2278. // sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
  2279. func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2280. s := *p.Int32Slice()
  2281. if len(s) == 0 {
  2282. return 0
  2283. }
  2284. n := len(s) * wire.SizeFixed32()
  2285. return tagsize + wire.SizeBytes(n)
  2286. }
  2287. // appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
  2288. func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2289. s := *p.Int32Slice()
  2290. if len(s) == 0 {
  2291. return b, nil
  2292. }
  2293. b = wire.AppendVarint(b, wiretag)
  2294. n := len(s) * wire.SizeFixed32()
  2295. b = wire.AppendVarint(b, uint64(n))
  2296. for _, v := range s {
  2297. b = wire.AppendFixed32(b, uint32(v))
  2298. }
  2299. return b, nil
  2300. }
  2301. var coderSfixed32PackedSlice = pointerCoderFuncs{
  2302. size: sizeSfixed32PackedSlice,
  2303. marshal: appendSfixed32PackedSlice,
  2304. unmarshal: consumeSfixed32Slice,
  2305. }
  2306. // sizeSfixed32Value returns the size of wire encoding a int32 value as a Sfixed32.
  2307. func sizeSfixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  2308. return tagsize + wire.SizeFixed32()
  2309. }
  2310. // appendSfixed32Value encodes a int32 value as a Sfixed32.
  2311. func appendSfixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2312. b = wire.AppendVarint(b, wiretag)
  2313. b = wire.AppendFixed32(b, uint32(v.Int()))
  2314. return b, nil
  2315. }
  2316. // consumeSfixed32Value decodes a int32 value as a Sfixed32.
  2317. func consumeSfixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  2318. if wtyp != wire.Fixed32Type {
  2319. return protoreflect.Value{}, 0, errUnknown
  2320. }
  2321. v, n := wire.ConsumeFixed32(b)
  2322. if n < 0 {
  2323. return protoreflect.Value{}, 0, wire.ParseError(n)
  2324. }
  2325. return protoreflect.ValueOfInt32(int32(v)), n, nil
  2326. }
  2327. var coderSfixed32Value = valueCoderFuncs{
  2328. size: sizeSfixed32Value,
  2329. marshal: appendSfixed32Value,
  2330. unmarshal: consumeSfixed32Value,
  2331. }
  2332. // sizeSfixed32SliceValue returns the size of wire encoding a []int32 value as a repeated Sfixed32.
  2333. func sizeSfixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2334. list := listv.List()
  2335. size = list.Len() * (tagsize + wire.SizeFixed32())
  2336. return size
  2337. }
  2338. // appendSfixed32SliceValue encodes a []int32 value as a repeated Sfixed32.
  2339. func appendSfixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2340. list := listv.List()
  2341. for i, llen := 0, list.Len(); i < llen; i++ {
  2342. v := list.Get(i)
  2343. b = wire.AppendVarint(b, wiretag)
  2344. b = wire.AppendFixed32(b, uint32(v.Int()))
  2345. }
  2346. return b, nil
  2347. }
  2348. // consumeSfixed32SliceValue wire decodes a []int32 value as a repeated Sfixed32.
  2349. func consumeSfixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  2350. list := listv.List()
  2351. if wtyp == wire.BytesType {
  2352. b, n = wire.ConsumeBytes(b)
  2353. if n < 0 {
  2354. return protoreflect.Value{}, 0, wire.ParseError(n)
  2355. }
  2356. for len(b) > 0 {
  2357. v, n := wire.ConsumeFixed32(b)
  2358. if n < 0 {
  2359. return protoreflect.Value{}, 0, wire.ParseError(n)
  2360. }
  2361. list.Append(protoreflect.ValueOfInt32(int32(v)))
  2362. b = b[n:]
  2363. }
  2364. return listv, n, nil
  2365. }
  2366. if wtyp != wire.Fixed32Type {
  2367. return protoreflect.Value{}, 0, errUnknown
  2368. }
  2369. v, n := wire.ConsumeFixed32(b)
  2370. if n < 0 {
  2371. return protoreflect.Value{}, 0, wire.ParseError(n)
  2372. }
  2373. list.Append(protoreflect.ValueOfInt32(int32(v)))
  2374. return listv, n, nil
  2375. }
  2376. var coderSfixed32SliceValue = valueCoderFuncs{
  2377. size: sizeSfixed32SliceValue,
  2378. marshal: appendSfixed32SliceValue,
  2379. unmarshal: consumeSfixed32SliceValue,
  2380. }
  2381. // sizeSfixed32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sfixed32.
  2382. func sizeSfixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2383. list := listv.List()
  2384. n := list.Len() * wire.SizeFixed32()
  2385. return tagsize + wire.SizeBytes(n)
  2386. }
  2387. // appendSfixed32PackedSliceValue encodes a []int32 value as a packed repeated Sfixed32.
  2388. func appendSfixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2389. list := listv.List()
  2390. llen := list.Len()
  2391. if llen == 0 {
  2392. return b, nil
  2393. }
  2394. b = wire.AppendVarint(b, wiretag)
  2395. n := llen * wire.SizeFixed32()
  2396. b = wire.AppendVarint(b, uint64(n))
  2397. for i := 0; i < llen; i++ {
  2398. v := list.Get(i)
  2399. b = wire.AppendFixed32(b, uint32(v.Int()))
  2400. }
  2401. return b, nil
  2402. }
  2403. var coderSfixed32PackedSliceValue = valueCoderFuncs{
  2404. size: sizeSfixed32PackedSliceValue,
  2405. marshal: appendSfixed32PackedSliceValue,
  2406. unmarshal: consumeSfixed32SliceValue,
  2407. }
  2408. // sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
  2409. func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
  2410. return tagsize + wire.SizeFixed32()
  2411. }
  2412. // appendFixed32 wire encodes a uint32 pointer as a Fixed32.
  2413. func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2414. v := *p.Uint32()
  2415. b = wire.AppendVarint(b, wiretag)
  2416. b = wire.AppendFixed32(b, v)
  2417. return b, nil
  2418. }
  2419. // consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
  2420. func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2421. if wtyp != wire.Fixed32Type {
  2422. return 0, errUnknown
  2423. }
  2424. v, n := wire.ConsumeFixed32(b)
  2425. if n < 0 {
  2426. return 0, wire.ParseError(n)
  2427. }
  2428. *p.Uint32() = v
  2429. return n, nil
  2430. }
  2431. var coderFixed32 = pointerCoderFuncs{
  2432. size: sizeFixed32,
  2433. marshal: appendFixed32,
  2434. unmarshal: consumeFixed32,
  2435. }
  2436. // sizeFixed32NoZero returns the size of wire encoding a uint32 pointer as a Fixed32.
  2437. // The zero value is not encoded.
  2438. func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  2439. v := *p.Uint32()
  2440. if v == 0 {
  2441. return 0
  2442. }
  2443. return tagsize + wire.SizeFixed32()
  2444. }
  2445. // appendFixed32NoZero wire encodes a uint32 pointer as a Fixed32.
  2446. // The zero value is not encoded.
  2447. func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2448. v := *p.Uint32()
  2449. if v == 0 {
  2450. return b, nil
  2451. }
  2452. b = wire.AppendVarint(b, wiretag)
  2453. b = wire.AppendFixed32(b, v)
  2454. return b, nil
  2455. }
  2456. var coderFixed32NoZero = pointerCoderFuncs{
  2457. size: sizeFixed32NoZero,
  2458. marshal: appendFixed32NoZero,
  2459. unmarshal: consumeFixed32,
  2460. }
  2461. // sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
  2462. // It panics if the pointer is nil.
  2463. func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  2464. return tagsize + wire.SizeFixed32()
  2465. }
  2466. // appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
  2467. // It panics if the pointer is nil.
  2468. func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2469. v := **p.Uint32Ptr()
  2470. b = wire.AppendVarint(b, wiretag)
  2471. b = wire.AppendFixed32(b, v)
  2472. return b, nil
  2473. }
  2474. // consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
  2475. func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2476. if wtyp != wire.Fixed32Type {
  2477. return 0, errUnknown
  2478. }
  2479. v, n := wire.ConsumeFixed32(b)
  2480. if n < 0 {
  2481. return 0, wire.ParseError(n)
  2482. }
  2483. vp := p.Uint32Ptr()
  2484. if *vp == nil {
  2485. *vp = new(uint32)
  2486. }
  2487. **vp = v
  2488. return n, nil
  2489. }
  2490. var coderFixed32Ptr = pointerCoderFuncs{
  2491. size: sizeFixed32Ptr,
  2492. marshal: appendFixed32Ptr,
  2493. unmarshal: consumeFixed32Ptr,
  2494. }
  2495. // sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
  2496. func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2497. s := *p.Uint32Slice()
  2498. size = len(s) * (tagsize + wire.SizeFixed32())
  2499. return size
  2500. }
  2501. // appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
  2502. func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2503. s := *p.Uint32Slice()
  2504. for _, v := range s {
  2505. b = wire.AppendVarint(b, wiretag)
  2506. b = wire.AppendFixed32(b, v)
  2507. }
  2508. return b, nil
  2509. }
  2510. // consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
  2511. func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2512. sp := p.Uint32Slice()
  2513. if wtyp == wire.BytesType {
  2514. s := *sp
  2515. b, n = wire.ConsumeBytes(b)
  2516. if n < 0 {
  2517. return 0, wire.ParseError(n)
  2518. }
  2519. for len(b) > 0 {
  2520. v, n := wire.ConsumeFixed32(b)
  2521. if n < 0 {
  2522. return 0, wire.ParseError(n)
  2523. }
  2524. s = append(s, v)
  2525. b = b[n:]
  2526. }
  2527. *sp = s
  2528. return n, nil
  2529. }
  2530. if wtyp != wire.Fixed32Type {
  2531. return 0, errUnknown
  2532. }
  2533. v, n := wire.ConsumeFixed32(b)
  2534. if n < 0 {
  2535. return 0, wire.ParseError(n)
  2536. }
  2537. *sp = append(*sp, v)
  2538. return n, nil
  2539. }
  2540. var coderFixed32Slice = pointerCoderFuncs{
  2541. size: sizeFixed32Slice,
  2542. marshal: appendFixed32Slice,
  2543. unmarshal: consumeFixed32Slice,
  2544. }
  2545. // sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
  2546. func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2547. s := *p.Uint32Slice()
  2548. if len(s) == 0 {
  2549. return 0
  2550. }
  2551. n := len(s) * wire.SizeFixed32()
  2552. return tagsize + wire.SizeBytes(n)
  2553. }
  2554. // appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
  2555. func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2556. s := *p.Uint32Slice()
  2557. if len(s) == 0 {
  2558. return b, nil
  2559. }
  2560. b = wire.AppendVarint(b, wiretag)
  2561. n := len(s) * wire.SizeFixed32()
  2562. b = wire.AppendVarint(b, uint64(n))
  2563. for _, v := range s {
  2564. b = wire.AppendFixed32(b, v)
  2565. }
  2566. return b, nil
  2567. }
  2568. var coderFixed32PackedSlice = pointerCoderFuncs{
  2569. size: sizeFixed32PackedSlice,
  2570. marshal: appendFixed32PackedSlice,
  2571. unmarshal: consumeFixed32Slice,
  2572. }
  2573. // sizeFixed32Value returns the size of wire encoding a uint32 value as a Fixed32.
  2574. func sizeFixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  2575. return tagsize + wire.SizeFixed32()
  2576. }
  2577. // appendFixed32Value encodes a uint32 value as a Fixed32.
  2578. func appendFixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2579. b = wire.AppendVarint(b, wiretag)
  2580. b = wire.AppendFixed32(b, uint32(v.Uint()))
  2581. return b, nil
  2582. }
  2583. // consumeFixed32Value decodes a uint32 value as a Fixed32.
  2584. func consumeFixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  2585. if wtyp != wire.Fixed32Type {
  2586. return protoreflect.Value{}, 0, errUnknown
  2587. }
  2588. v, n := wire.ConsumeFixed32(b)
  2589. if n < 0 {
  2590. return protoreflect.Value{}, 0, wire.ParseError(n)
  2591. }
  2592. return protoreflect.ValueOfUint32(uint32(v)), n, nil
  2593. }
  2594. var coderFixed32Value = valueCoderFuncs{
  2595. size: sizeFixed32Value,
  2596. marshal: appendFixed32Value,
  2597. unmarshal: consumeFixed32Value,
  2598. }
  2599. // sizeFixed32SliceValue returns the size of wire encoding a []uint32 value as a repeated Fixed32.
  2600. func sizeFixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2601. list := listv.List()
  2602. size = list.Len() * (tagsize + wire.SizeFixed32())
  2603. return size
  2604. }
  2605. // appendFixed32SliceValue encodes a []uint32 value as a repeated Fixed32.
  2606. func appendFixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2607. list := listv.List()
  2608. for i, llen := 0, list.Len(); i < llen; i++ {
  2609. v := list.Get(i)
  2610. b = wire.AppendVarint(b, wiretag)
  2611. b = wire.AppendFixed32(b, uint32(v.Uint()))
  2612. }
  2613. return b, nil
  2614. }
  2615. // consumeFixed32SliceValue wire decodes a []uint32 value as a repeated Fixed32.
  2616. func consumeFixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  2617. list := listv.List()
  2618. if wtyp == wire.BytesType {
  2619. b, n = wire.ConsumeBytes(b)
  2620. if n < 0 {
  2621. return protoreflect.Value{}, 0, wire.ParseError(n)
  2622. }
  2623. for len(b) > 0 {
  2624. v, n := wire.ConsumeFixed32(b)
  2625. if n < 0 {
  2626. return protoreflect.Value{}, 0, wire.ParseError(n)
  2627. }
  2628. list.Append(protoreflect.ValueOfUint32(uint32(v)))
  2629. b = b[n:]
  2630. }
  2631. return listv, n, nil
  2632. }
  2633. if wtyp != wire.Fixed32Type {
  2634. return protoreflect.Value{}, 0, errUnknown
  2635. }
  2636. v, n := wire.ConsumeFixed32(b)
  2637. if n < 0 {
  2638. return protoreflect.Value{}, 0, wire.ParseError(n)
  2639. }
  2640. list.Append(protoreflect.ValueOfUint32(uint32(v)))
  2641. return listv, n, nil
  2642. }
  2643. var coderFixed32SliceValue = valueCoderFuncs{
  2644. size: sizeFixed32SliceValue,
  2645. marshal: appendFixed32SliceValue,
  2646. unmarshal: consumeFixed32SliceValue,
  2647. }
  2648. // sizeFixed32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Fixed32.
  2649. func sizeFixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2650. list := listv.List()
  2651. n := list.Len() * wire.SizeFixed32()
  2652. return tagsize + wire.SizeBytes(n)
  2653. }
  2654. // appendFixed32PackedSliceValue encodes a []uint32 value as a packed repeated Fixed32.
  2655. func appendFixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2656. list := listv.List()
  2657. llen := list.Len()
  2658. if llen == 0 {
  2659. return b, nil
  2660. }
  2661. b = wire.AppendVarint(b, wiretag)
  2662. n := llen * wire.SizeFixed32()
  2663. b = wire.AppendVarint(b, uint64(n))
  2664. for i := 0; i < llen; i++ {
  2665. v := list.Get(i)
  2666. b = wire.AppendFixed32(b, uint32(v.Uint()))
  2667. }
  2668. return b, nil
  2669. }
  2670. var coderFixed32PackedSliceValue = valueCoderFuncs{
  2671. size: sizeFixed32PackedSliceValue,
  2672. marshal: appendFixed32PackedSliceValue,
  2673. unmarshal: consumeFixed32SliceValue,
  2674. }
  2675. // sizeFloat returns the size of wire encoding a float32 pointer as a Float.
  2676. func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
  2677. return tagsize + wire.SizeFixed32()
  2678. }
  2679. // appendFloat wire encodes a float32 pointer as a Float.
  2680. func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2681. v := *p.Float32()
  2682. b = wire.AppendVarint(b, wiretag)
  2683. b = wire.AppendFixed32(b, math.Float32bits(v))
  2684. return b, nil
  2685. }
  2686. // consumeFloat wire decodes a float32 pointer as a Float.
  2687. func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2688. if wtyp != wire.Fixed32Type {
  2689. return 0, errUnknown
  2690. }
  2691. v, n := wire.ConsumeFixed32(b)
  2692. if n < 0 {
  2693. return 0, wire.ParseError(n)
  2694. }
  2695. *p.Float32() = math.Float32frombits(v)
  2696. return n, nil
  2697. }
  2698. var coderFloat = pointerCoderFuncs{
  2699. size: sizeFloat,
  2700. marshal: appendFloat,
  2701. unmarshal: consumeFloat,
  2702. }
  2703. // sizeFloatNoZero returns the size of wire encoding a float32 pointer as a Float.
  2704. // The zero value is not encoded.
  2705. func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  2706. v := *p.Float32()
  2707. if v == 0 && !math.Signbit(float64(v)) {
  2708. return 0
  2709. }
  2710. return tagsize + wire.SizeFixed32()
  2711. }
  2712. // appendFloatNoZero wire encodes a float32 pointer as a Float.
  2713. // The zero value is not encoded.
  2714. func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2715. v := *p.Float32()
  2716. if v == 0 && !math.Signbit(float64(v)) {
  2717. return b, nil
  2718. }
  2719. b = wire.AppendVarint(b, wiretag)
  2720. b = wire.AppendFixed32(b, math.Float32bits(v))
  2721. return b, nil
  2722. }
  2723. var coderFloatNoZero = pointerCoderFuncs{
  2724. size: sizeFloatNoZero,
  2725. marshal: appendFloatNoZero,
  2726. unmarshal: consumeFloat,
  2727. }
  2728. // sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
  2729. // It panics if the pointer is nil.
  2730. func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  2731. return tagsize + wire.SizeFixed32()
  2732. }
  2733. // appendFloatPtr wire encodes a *float32 pointer as a Float.
  2734. // It panics if the pointer is nil.
  2735. func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2736. v := **p.Float32Ptr()
  2737. b = wire.AppendVarint(b, wiretag)
  2738. b = wire.AppendFixed32(b, math.Float32bits(v))
  2739. return b, nil
  2740. }
  2741. // consumeFloatPtr wire decodes a *float32 pointer as a Float.
  2742. func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2743. if wtyp != wire.Fixed32Type {
  2744. return 0, errUnknown
  2745. }
  2746. v, n := wire.ConsumeFixed32(b)
  2747. if n < 0 {
  2748. return 0, wire.ParseError(n)
  2749. }
  2750. vp := p.Float32Ptr()
  2751. if *vp == nil {
  2752. *vp = new(float32)
  2753. }
  2754. **vp = math.Float32frombits(v)
  2755. return n, nil
  2756. }
  2757. var coderFloatPtr = pointerCoderFuncs{
  2758. size: sizeFloatPtr,
  2759. marshal: appendFloatPtr,
  2760. unmarshal: consumeFloatPtr,
  2761. }
  2762. // sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
  2763. func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2764. s := *p.Float32Slice()
  2765. size = len(s) * (tagsize + wire.SizeFixed32())
  2766. return size
  2767. }
  2768. // appendFloatSlice encodes a []float32 pointer as a repeated Float.
  2769. func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2770. s := *p.Float32Slice()
  2771. for _, v := range s {
  2772. b = wire.AppendVarint(b, wiretag)
  2773. b = wire.AppendFixed32(b, math.Float32bits(v))
  2774. }
  2775. return b, nil
  2776. }
  2777. // consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
  2778. func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2779. sp := p.Float32Slice()
  2780. if wtyp == wire.BytesType {
  2781. s := *sp
  2782. b, n = wire.ConsumeBytes(b)
  2783. if n < 0 {
  2784. return 0, wire.ParseError(n)
  2785. }
  2786. for len(b) > 0 {
  2787. v, n := wire.ConsumeFixed32(b)
  2788. if n < 0 {
  2789. return 0, wire.ParseError(n)
  2790. }
  2791. s = append(s, math.Float32frombits(v))
  2792. b = b[n:]
  2793. }
  2794. *sp = s
  2795. return n, nil
  2796. }
  2797. if wtyp != wire.Fixed32Type {
  2798. return 0, errUnknown
  2799. }
  2800. v, n := wire.ConsumeFixed32(b)
  2801. if n < 0 {
  2802. return 0, wire.ParseError(n)
  2803. }
  2804. *sp = append(*sp, math.Float32frombits(v))
  2805. return n, nil
  2806. }
  2807. var coderFloatSlice = pointerCoderFuncs{
  2808. size: sizeFloatSlice,
  2809. marshal: appendFloatSlice,
  2810. unmarshal: consumeFloatSlice,
  2811. }
  2812. // sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
  2813. func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2814. s := *p.Float32Slice()
  2815. if len(s) == 0 {
  2816. return 0
  2817. }
  2818. n := len(s) * wire.SizeFixed32()
  2819. return tagsize + wire.SizeBytes(n)
  2820. }
  2821. // appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
  2822. func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2823. s := *p.Float32Slice()
  2824. if len(s) == 0 {
  2825. return b, nil
  2826. }
  2827. b = wire.AppendVarint(b, wiretag)
  2828. n := len(s) * wire.SizeFixed32()
  2829. b = wire.AppendVarint(b, uint64(n))
  2830. for _, v := range s {
  2831. b = wire.AppendFixed32(b, math.Float32bits(v))
  2832. }
  2833. return b, nil
  2834. }
  2835. var coderFloatPackedSlice = pointerCoderFuncs{
  2836. size: sizeFloatPackedSlice,
  2837. marshal: appendFloatPackedSlice,
  2838. unmarshal: consumeFloatSlice,
  2839. }
  2840. // sizeFloatValue returns the size of wire encoding a float32 value as a Float.
  2841. func sizeFloatValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  2842. return tagsize + wire.SizeFixed32()
  2843. }
  2844. // appendFloatValue encodes a float32 value as a Float.
  2845. func appendFloatValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2846. b = wire.AppendVarint(b, wiretag)
  2847. b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
  2848. return b, nil
  2849. }
  2850. // consumeFloatValue decodes a float32 value as a Float.
  2851. func consumeFloatValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  2852. if wtyp != wire.Fixed32Type {
  2853. return protoreflect.Value{}, 0, errUnknown
  2854. }
  2855. v, n := wire.ConsumeFixed32(b)
  2856. if n < 0 {
  2857. return protoreflect.Value{}, 0, wire.ParseError(n)
  2858. }
  2859. return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
  2860. }
  2861. var coderFloatValue = valueCoderFuncs{
  2862. size: sizeFloatValue,
  2863. marshal: appendFloatValue,
  2864. unmarshal: consumeFloatValue,
  2865. }
  2866. // sizeFloatSliceValue returns the size of wire encoding a []float32 value as a repeated Float.
  2867. func sizeFloatSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2868. list := listv.List()
  2869. size = list.Len() * (tagsize + wire.SizeFixed32())
  2870. return size
  2871. }
  2872. // appendFloatSliceValue encodes a []float32 value as a repeated Float.
  2873. func appendFloatSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2874. list := listv.List()
  2875. for i, llen := 0, list.Len(); i < llen; i++ {
  2876. v := list.Get(i)
  2877. b = wire.AppendVarint(b, wiretag)
  2878. b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
  2879. }
  2880. return b, nil
  2881. }
  2882. // consumeFloatSliceValue wire decodes a []float32 value as a repeated Float.
  2883. func consumeFloatSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  2884. list := listv.List()
  2885. if wtyp == wire.BytesType {
  2886. b, n = wire.ConsumeBytes(b)
  2887. if n < 0 {
  2888. return protoreflect.Value{}, 0, wire.ParseError(n)
  2889. }
  2890. for len(b) > 0 {
  2891. v, n := wire.ConsumeFixed32(b)
  2892. if n < 0 {
  2893. return protoreflect.Value{}, 0, wire.ParseError(n)
  2894. }
  2895. list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
  2896. b = b[n:]
  2897. }
  2898. return listv, n, nil
  2899. }
  2900. if wtyp != wire.Fixed32Type {
  2901. return protoreflect.Value{}, 0, errUnknown
  2902. }
  2903. v, n := wire.ConsumeFixed32(b)
  2904. if n < 0 {
  2905. return protoreflect.Value{}, 0, wire.ParseError(n)
  2906. }
  2907. list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
  2908. return listv, n, nil
  2909. }
  2910. var coderFloatSliceValue = valueCoderFuncs{
  2911. size: sizeFloatSliceValue,
  2912. marshal: appendFloatSliceValue,
  2913. unmarshal: consumeFloatSliceValue,
  2914. }
  2915. // sizeFloatPackedSliceValue returns the size of wire encoding a []float32 value as a packed repeated Float.
  2916. func sizeFloatPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  2917. list := listv.List()
  2918. n := list.Len() * wire.SizeFixed32()
  2919. return tagsize + wire.SizeBytes(n)
  2920. }
  2921. // appendFloatPackedSliceValue encodes a []float32 value as a packed repeated Float.
  2922. func appendFloatPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2923. list := listv.List()
  2924. llen := list.Len()
  2925. if llen == 0 {
  2926. return b, nil
  2927. }
  2928. b = wire.AppendVarint(b, wiretag)
  2929. n := llen * wire.SizeFixed32()
  2930. b = wire.AppendVarint(b, uint64(n))
  2931. for i := 0; i < llen; i++ {
  2932. v := list.Get(i)
  2933. b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
  2934. }
  2935. return b, nil
  2936. }
  2937. var coderFloatPackedSliceValue = valueCoderFuncs{
  2938. size: sizeFloatPackedSliceValue,
  2939. marshal: appendFloatPackedSliceValue,
  2940. unmarshal: consumeFloatSliceValue,
  2941. }
  2942. // sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
  2943. func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
  2944. return tagsize + wire.SizeFixed64()
  2945. }
  2946. // appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
  2947. func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2948. v := *p.Int64()
  2949. b = wire.AppendVarint(b, wiretag)
  2950. b = wire.AppendFixed64(b, uint64(v))
  2951. return b, nil
  2952. }
  2953. // consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
  2954. func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  2955. if wtyp != wire.Fixed64Type {
  2956. return 0, errUnknown
  2957. }
  2958. v, n := wire.ConsumeFixed64(b)
  2959. if n < 0 {
  2960. return 0, wire.ParseError(n)
  2961. }
  2962. *p.Int64() = int64(v)
  2963. return n, nil
  2964. }
  2965. var coderSfixed64 = pointerCoderFuncs{
  2966. size: sizeSfixed64,
  2967. marshal: appendSfixed64,
  2968. unmarshal: consumeSfixed64,
  2969. }
  2970. // sizeSfixed64NoZero returns the size of wire encoding a int64 pointer as a Sfixed64.
  2971. // The zero value is not encoded.
  2972. func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  2973. v := *p.Int64()
  2974. if v == 0 {
  2975. return 0
  2976. }
  2977. return tagsize + wire.SizeFixed64()
  2978. }
  2979. // appendSfixed64NoZero wire encodes a int64 pointer as a Sfixed64.
  2980. // The zero value is not encoded.
  2981. func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2982. v := *p.Int64()
  2983. if v == 0 {
  2984. return b, nil
  2985. }
  2986. b = wire.AppendVarint(b, wiretag)
  2987. b = wire.AppendFixed64(b, uint64(v))
  2988. return b, nil
  2989. }
  2990. var coderSfixed64NoZero = pointerCoderFuncs{
  2991. size: sizeSfixed64NoZero,
  2992. marshal: appendSfixed64NoZero,
  2993. unmarshal: consumeSfixed64,
  2994. }
  2995. // sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
  2996. // It panics if the pointer is nil.
  2997. func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  2998. return tagsize + wire.SizeFixed64()
  2999. }
  3000. // appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
  3001. // It panics if the pointer is nil.
  3002. func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3003. v := **p.Int64Ptr()
  3004. b = wire.AppendVarint(b, wiretag)
  3005. b = wire.AppendFixed64(b, uint64(v))
  3006. return b, nil
  3007. }
  3008. // consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
  3009. func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3010. if wtyp != wire.Fixed64Type {
  3011. return 0, errUnknown
  3012. }
  3013. v, n := wire.ConsumeFixed64(b)
  3014. if n < 0 {
  3015. return 0, wire.ParseError(n)
  3016. }
  3017. vp := p.Int64Ptr()
  3018. if *vp == nil {
  3019. *vp = new(int64)
  3020. }
  3021. **vp = int64(v)
  3022. return n, nil
  3023. }
  3024. var coderSfixed64Ptr = pointerCoderFuncs{
  3025. size: sizeSfixed64Ptr,
  3026. marshal: appendSfixed64Ptr,
  3027. unmarshal: consumeSfixed64Ptr,
  3028. }
  3029. // sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
  3030. func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3031. s := *p.Int64Slice()
  3032. size = len(s) * (tagsize + wire.SizeFixed64())
  3033. return size
  3034. }
  3035. // appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
  3036. func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3037. s := *p.Int64Slice()
  3038. for _, v := range s {
  3039. b = wire.AppendVarint(b, wiretag)
  3040. b = wire.AppendFixed64(b, uint64(v))
  3041. }
  3042. return b, nil
  3043. }
  3044. // consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
  3045. func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3046. sp := p.Int64Slice()
  3047. if wtyp == wire.BytesType {
  3048. s := *sp
  3049. b, n = wire.ConsumeBytes(b)
  3050. if n < 0 {
  3051. return 0, wire.ParseError(n)
  3052. }
  3053. for len(b) > 0 {
  3054. v, n := wire.ConsumeFixed64(b)
  3055. if n < 0 {
  3056. return 0, wire.ParseError(n)
  3057. }
  3058. s = append(s, int64(v))
  3059. b = b[n:]
  3060. }
  3061. *sp = s
  3062. return n, nil
  3063. }
  3064. if wtyp != wire.Fixed64Type {
  3065. return 0, errUnknown
  3066. }
  3067. v, n := wire.ConsumeFixed64(b)
  3068. if n < 0 {
  3069. return 0, wire.ParseError(n)
  3070. }
  3071. *sp = append(*sp, int64(v))
  3072. return n, nil
  3073. }
  3074. var coderSfixed64Slice = pointerCoderFuncs{
  3075. size: sizeSfixed64Slice,
  3076. marshal: appendSfixed64Slice,
  3077. unmarshal: consumeSfixed64Slice,
  3078. }
  3079. // sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
  3080. func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3081. s := *p.Int64Slice()
  3082. if len(s) == 0 {
  3083. return 0
  3084. }
  3085. n := len(s) * wire.SizeFixed64()
  3086. return tagsize + wire.SizeBytes(n)
  3087. }
  3088. // appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
  3089. func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3090. s := *p.Int64Slice()
  3091. if len(s) == 0 {
  3092. return b, nil
  3093. }
  3094. b = wire.AppendVarint(b, wiretag)
  3095. n := len(s) * wire.SizeFixed64()
  3096. b = wire.AppendVarint(b, uint64(n))
  3097. for _, v := range s {
  3098. b = wire.AppendFixed64(b, uint64(v))
  3099. }
  3100. return b, nil
  3101. }
  3102. var coderSfixed64PackedSlice = pointerCoderFuncs{
  3103. size: sizeSfixed64PackedSlice,
  3104. marshal: appendSfixed64PackedSlice,
  3105. unmarshal: consumeSfixed64Slice,
  3106. }
  3107. // sizeSfixed64Value returns the size of wire encoding a int64 value as a Sfixed64.
  3108. func sizeSfixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  3109. return tagsize + wire.SizeFixed64()
  3110. }
  3111. // appendSfixed64Value encodes a int64 value as a Sfixed64.
  3112. func appendSfixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3113. b = wire.AppendVarint(b, wiretag)
  3114. b = wire.AppendFixed64(b, uint64(v.Int()))
  3115. return b, nil
  3116. }
  3117. // consumeSfixed64Value decodes a int64 value as a Sfixed64.
  3118. func consumeSfixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  3119. if wtyp != wire.Fixed64Type {
  3120. return protoreflect.Value{}, 0, errUnknown
  3121. }
  3122. v, n := wire.ConsumeFixed64(b)
  3123. if n < 0 {
  3124. return protoreflect.Value{}, 0, wire.ParseError(n)
  3125. }
  3126. return protoreflect.ValueOfInt64(int64(v)), n, nil
  3127. }
  3128. var coderSfixed64Value = valueCoderFuncs{
  3129. size: sizeSfixed64Value,
  3130. marshal: appendSfixed64Value,
  3131. unmarshal: consumeSfixed64Value,
  3132. }
  3133. // sizeSfixed64SliceValue returns the size of wire encoding a []int64 value as a repeated Sfixed64.
  3134. func sizeSfixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3135. list := listv.List()
  3136. size = list.Len() * (tagsize + wire.SizeFixed64())
  3137. return size
  3138. }
  3139. // appendSfixed64SliceValue encodes a []int64 value as a repeated Sfixed64.
  3140. func appendSfixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3141. list := listv.List()
  3142. for i, llen := 0, list.Len(); i < llen; i++ {
  3143. v := list.Get(i)
  3144. b = wire.AppendVarint(b, wiretag)
  3145. b = wire.AppendFixed64(b, uint64(v.Int()))
  3146. }
  3147. return b, nil
  3148. }
  3149. // consumeSfixed64SliceValue wire decodes a []int64 value as a repeated Sfixed64.
  3150. func consumeSfixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  3151. list := listv.List()
  3152. if wtyp == wire.BytesType {
  3153. b, n = wire.ConsumeBytes(b)
  3154. if n < 0 {
  3155. return protoreflect.Value{}, 0, wire.ParseError(n)
  3156. }
  3157. for len(b) > 0 {
  3158. v, n := wire.ConsumeFixed64(b)
  3159. if n < 0 {
  3160. return protoreflect.Value{}, 0, wire.ParseError(n)
  3161. }
  3162. list.Append(protoreflect.ValueOfInt64(int64(v)))
  3163. b = b[n:]
  3164. }
  3165. return listv, n, nil
  3166. }
  3167. if wtyp != wire.Fixed64Type {
  3168. return protoreflect.Value{}, 0, errUnknown
  3169. }
  3170. v, n := wire.ConsumeFixed64(b)
  3171. if n < 0 {
  3172. return protoreflect.Value{}, 0, wire.ParseError(n)
  3173. }
  3174. list.Append(protoreflect.ValueOfInt64(int64(v)))
  3175. return listv, n, nil
  3176. }
  3177. var coderSfixed64SliceValue = valueCoderFuncs{
  3178. size: sizeSfixed64SliceValue,
  3179. marshal: appendSfixed64SliceValue,
  3180. unmarshal: consumeSfixed64SliceValue,
  3181. }
  3182. // sizeSfixed64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sfixed64.
  3183. func sizeSfixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3184. list := listv.List()
  3185. n := list.Len() * wire.SizeFixed64()
  3186. return tagsize + wire.SizeBytes(n)
  3187. }
  3188. // appendSfixed64PackedSliceValue encodes a []int64 value as a packed repeated Sfixed64.
  3189. func appendSfixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3190. list := listv.List()
  3191. llen := list.Len()
  3192. if llen == 0 {
  3193. return b, nil
  3194. }
  3195. b = wire.AppendVarint(b, wiretag)
  3196. n := llen * wire.SizeFixed64()
  3197. b = wire.AppendVarint(b, uint64(n))
  3198. for i := 0; i < llen; i++ {
  3199. v := list.Get(i)
  3200. b = wire.AppendFixed64(b, uint64(v.Int()))
  3201. }
  3202. return b, nil
  3203. }
  3204. var coderSfixed64PackedSliceValue = valueCoderFuncs{
  3205. size: sizeSfixed64PackedSliceValue,
  3206. marshal: appendSfixed64PackedSliceValue,
  3207. unmarshal: consumeSfixed64SliceValue,
  3208. }
  3209. // sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
  3210. func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
  3211. return tagsize + wire.SizeFixed64()
  3212. }
  3213. // appendFixed64 wire encodes a uint64 pointer as a Fixed64.
  3214. func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3215. v := *p.Uint64()
  3216. b = wire.AppendVarint(b, wiretag)
  3217. b = wire.AppendFixed64(b, v)
  3218. return b, nil
  3219. }
  3220. // consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
  3221. func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3222. if wtyp != wire.Fixed64Type {
  3223. return 0, errUnknown
  3224. }
  3225. v, n := wire.ConsumeFixed64(b)
  3226. if n < 0 {
  3227. return 0, wire.ParseError(n)
  3228. }
  3229. *p.Uint64() = v
  3230. return n, nil
  3231. }
  3232. var coderFixed64 = pointerCoderFuncs{
  3233. size: sizeFixed64,
  3234. marshal: appendFixed64,
  3235. unmarshal: consumeFixed64,
  3236. }
  3237. // sizeFixed64NoZero returns the size of wire encoding a uint64 pointer as a Fixed64.
  3238. // The zero value is not encoded.
  3239. func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  3240. v := *p.Uint64()
  3241. if v == 0 {
  3242. return 0
  3243. }
  3244. return tagsize + wire.SizeFixed64()
  3245. }
  3246. // appendFixed64NoZero wire encodes a uint64 pointer as a Fixed64.
  3247. // The zero value is not encoded.
  3248. func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3249. v := *p.Uint64()
  3250. if v == 0 {
  3251. return b, nil
  3252. }
  3253. b = wire.AppendVarint(b, wiretag)
  3254. b = wire.AppendFixed64(b, v)
  3255. return b, nil
  3256. }
  3257. var coderFixed64NoZero = pointerCoderFuncs{
  3258. size: sizeFixed64NoZero,
  3259. marshal: appendFixed64NoZero,
  3260. unmarshal: consumeFixed64,
  3261. }
  3262. // sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
  3263. // It panics if the pointer is nil.
  3264. func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  3265. return tagsize + wire.SizeFixed64()
  3266. }
  3267. // appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
  3268. // It panics if the pointer is nil.
  3269. func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3270. v := **p.Uint64Ptr()
  3271. b = wire.AppendVarint(b, wiretag)
  3272. b = wire.AppendFixed64(b, v)
  3273. return b, nil
  3274. }
  3275. // consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
  3276. func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3277. if wtyp != wire.Fixed64Type {
  3278. return 0, errUnknown
  3279. }
  3280. v, n := wire.ConsumeFixed64(b)
  3281. if n < 0 {
  3282. return 0, wire.ParseError(n)
  3283. }
  3284. vp := p.Uint64Ptr()
  3285. if *vp == nil {
  3286. *vp = new(uint64)
  3287. }
  3288. **vp = v
  3289. return n, nil
  3290. }
  3291. var coderFixed64Ptr = pointerCoderFuncs{
  3292. size: sizeFixed64Ptr,
  3293. marshal: appendFixed64Ptr,
  3294. unmarshal: consumeFixed64Ptr,
  3295. }
  3296. // sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
  3297. func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3298. s := *p.Uint64Slice()
  3299. size = len(s) * (tagsize + wire.SizeFixed64())
  3300. return size
  3301. }
  3302. // appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
  3303. func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3304. s := *p.Uint64Slice()
  3305. for _, v := range s {
  3306. b = wire.AppendVarint(b, wiretag)
  3307. b = wire.AppendFixed64(b, v)
  3308. }
  3309. return b, nil
  3310. }
  3311. // consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
  3312. func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3313. sp := p.Uint64Slice()
  3314. if wtyp == wire.BytesType {
  3315. s := *sp
  3316. b, n = wire.ConsumeBytes(b)
  3317. if n < 0 {
  3318. return 0, wire.ParseError(n)
  3319. }
  3320. for len(b) > 0 {
  3321. v, n := wire.ConsumeFixed64(b)
  3322. if n < 0 {
  3323. return 0, wire.ParseError(n)
  3324. }
  3325. s = append(s, v)
  3326. b = b[n:]
  3327. }
  3328. *sp = s
  3329. return n, nil
  3330. }
  3331. if wtyp != wire.Fixed64Type {
  3332. return 0, errUnknown
  3333. }
  3334. v, n := wire.ConsumeFixed64(b)
  3335. if n < 0 {
  3336. return 0, wire.ParseError(n)
  3337. }
  3338. *sp = append(*sp, v)
  3339. return n, nil
  3340. }
  3341. var coderFixed64Slice = pointerCoderFuncs{
  3342. size: sizeFixed64Slice,
  3343. marshal: appendFixed64Slice,
  3344. unmarshal: consumeFixed64Slice,
  3345. }
  3346. // sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
  3347. func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3348. s := *p.Uint64Slice()
  3349. if len(s) == 0 {
  3350. return 0
  3351. }
  3352. n := len(s) * wire.SizeFixed64()
  3353. return tagsize + wire.SizeBytes(n)
  3354. }
  3355. // appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
  3356. func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3357. s := *p.Uint64Slice()
  3358. if len(s) == 0 {
  3359. return b, nil
  3360. }
  3361. b = wire.AppendVarint(b, wiretag)
  3362. n := len(s) * wire.SizeFixed64()
  3363. b = wire.AppendVarint(b, uint64(n))
  3364. for _, v := range s {
  3365. b = wire.AppendFixed64(b, v)
  3366. }
  3367. return b, nil
  3368. }
  3369. var coderFixed64PackedSlice = pointerCoderFuncs{
  3370. size: sizeFixed64PackedSlice,
  3371. marshal: appendFixed64PackedSlice,
  3372. unmarshal: consumeFixed64Slice,
  3373. }
  3374. // sizeFixed64Value returns the size of wire encoding a uint64 value as a Fixed64.
  3375. func sizeFixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  3376. return tagsize + wire.SizeFixed64()
  3377. }
  3378. // appendFixed64Value encodes a uint64 value as a Fixed64.
  3379. func appendFixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3380. b = wire.AppendVarint(b, wiretag)
  3381. b = wire.AppendFixed64(b, v.Uint())
  3382. return b, nil
  3383. }
  3384. // consumeFixed64Value decodes a uint64 value as a Fixed64.
  3385. func consumeFixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  3386. if wtyp != wire.Fixed64Type {
  3387. return protoreflect.Value{}, 0, errUnknown
  3388. }
  3389. v, n := wire.ConsumeFixed64(b)
  3390. if n < 0 {
  3391. return protoreflect.Value{}, 0, wire.ParseError(n)
  3392. }
  3393. return protoreflect.ValueOfUint64(v), n, nil
  3394. }
  3395. var coderFixed64Value = valueCoderFuncs{
  3396. size: sizeFixed64Value,
  3397. marshal: appendFixed64Value,
  3398. unmarshal: consumeFixed64Value,
  3399. }
  3400. // sizeFixed64SliceValue returns the size of wire encoding a []uint64 value as a repeated Fixed64.
  3401. func sizeFixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3402. list := listv.List()
  3403. size = list.Len() * (tagsize + wire.SizeFixed64())
  3404. return size
  3405. }
  3406. // appendFixed64SliceValue encodes a []uint64 value as a repeated Fixed64.
  3407. func appendFixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3408. list := listv.List()
  3409. for i, llen := 0, list.Len(); i < llen; i++ {
  3410. v := list.Get(i)
  3411. b = wire.AppendVarint(b, wiretag)
  3412. b = wire.AppendFixed64(b, v.Uint())
  3413. }
  3414. return b, nil
  3415. }
  3416. // consumeFixed64SliceValue wire decodes a []uint64 value as a repeated Fixed64.
  3417. func consumeFixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  3418. list := listv.List()
  3419. if wtyp == wire.BytesType {
  3420. b, n = wire.ConsumeBytes(b)
  3421. if n < 0 {
  3422. return protoreflect.Value{}, 0, wire.ParseError(n)
  3423. }
  3424. for len(b) > 0 {
  3425. v, n := wire.ConsumeFixed64(b)
  3426. if n < 0 {
  3427. return protoreflect.Value{}, 0, wire.ParseError(n)
  3428. }
  3429. list.Append(protoreflect.ValueOfUint64(v))
  3430. b = b[n:]
  3431. }
  3432. return listv, n, nil
  3433. }
  3434. if wtyp != wire.Fixed64Type {
  3435. return protoreflect.Value{}, 0, errUnknown
  3436. }
  3437. v, n := wire.ConsumeFixed64(b)
  3438. if n < 0 {
  3439. return protoreflect.Value{}, 0, wire.ParseError(n)
  3440. }
  3441. list.Append(protoreflect.ValueOfUint64(v))
  3442. return listv, n, nil
  3443. }
  3444. var coderFixed64SliceValue = valueCoderFuncs{
  3445. size: sizeFixed64SliceValue,
  3446. marshal: appendFixed64SliceValue,
  3447. unmarshal: consumeFixed64SliceValue,
  3448. }
  3449. // sizeFixed64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Fixed64.
  3450. func sizeFixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3451. list := listv.List()
  3452. n := list.Len() * wire.SizeFixed64()
  3453. return tagsize + wire.SizeBytes(n)
  3454. }
  3455. // appendFixed64PackedSliceValue encodes a []uint64 value as a packed repeated Fixed64.
  3456. func appendFixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3457. list := listv.List()
  3458. llen := list.Len()
  3459. if llen == 0 {
  3460. return b, nil
  3461. }
  3462. b = wire.AppendVarint(b, wiretag)
  3463. n := llen * wire.SizeFixed64()
  3464. b = wire.AppendVarint(b, uint64(n))
  3465. for i := 0; i < llen; i++ {
  3466. v := list.Get(i)
  3467. b = wire.AppendFixed64(b, v.Uint())
  3468. }
  3469. return b, nil
  3470. }
  3471. var coderFixed64PackedSliceValue = valueCoderFuncs{
  3472. size: sizeFixed64PackedSliceValue,
  3473. marshal: appendFixed64PackedSliceValue,
  3474. unmarshal: consumeFixed64SliceValue,
  3475. }
  3476. // sizeDouble returns the size of wire encoding a float64 pointer as a Double.
  3477. func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
  3478. return tagsize + wire.SizeFixed64()
  3479. }
  3480. // appendDouble wire encodes a float64 pointer as a Double.
  3481. func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3482. v := *p.Float64()
  3483. b = wire.AppendVarint(b, wiretag)
  3484. b = wire.AppendFixed64(b, math.Float64bits(v))
  3485. return b, nil
  3486. }
  3487. // consumeDouble wire decodes a float64 pointer as a Double.
  3488. func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3489. if wtyp != wire.Fixed64Type {
  3490. return 0, errUnknown
  3491. }
  3492. v, n := wire.ConsumeFixed64(b)
  3493. if n < 0 {
  3494. return 0, wire.ParseError(n)
  3495. }
  3496. *p.Float64() = math.Float64frombits(v)
  3497. return n, nil
  3498. }
  3499. var coderDouble = pointerCoderFuncs{
  3500. size: sizeDouble,
  3501. marshal: appendDouble,
  3502. unmarshal: consumeDouble,
  3503. }
  3504. // sizeDoubleNoZero returns the size of wire encoding a float64 pointer as a Double.
  3505. // The zero value is not encoded.
  3506. func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  3507. v := *p.Float64()
  3508. if v == 0 && !math.Signbit(float64(v)) {
  3509. return 0
  3510. }
  3511. return tagsize + wire.SizeFixed64()
  3512. }
  3513. // appendDoubleNoZero wire encodes a float64 pointer as a Double.
  3514. // The zero value is not encoded.
  3515. func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3516. v := *p.Float64()
  3517. if v == 0 && !math.Signbit(float64(v)) {
  3518. return b, nil
  3519. }
  3520. b = wire.AppendVarint(b, wiretag)
  3521. b = wire.AppendFixed64(b, math.Float64bits(v))
  3522. return b, nil
  3523. }
  3524. var coderDoubleNoZero = pointerCoderFuncs{
  3525. size: sizeDoubleNoZero,
  3526. marshal: appendDoubleNoZero,
  3527. unmarshal: consumeDouble,
  3528. }
  3529. // sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
  3530. // It panics if the pointer is nil.
  3531. func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  3532. return tagsize + wire.SizeFixed64()
  3533. }
  3534. // appendDoublePtr wire encodes a *float64 pointer as a Double.
  3535. // It panics if the pointer is nil.
  3536. func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3537. v := **p.Float64Ptr()
  3538. b = wire.AppendVarint(b, wiretag)
  3539. b = wire.AppendFixed64(b, math.Float64bits(v))
  3540. return b, nil
  3541. }
  3542. // consumeDoublePtr wire decodes a *float64 pointer as a Double.
  3543. func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3544. if wtyp != wire.Fixed64Type {
  3545. return 0, errUnknown
  3546. }
  3547. v, n := wire.ConsumeFixed64(b)
  3548. if n < 0 {
  3549. return 0, wire.ParseError(n)
  3550. }
  3551. vp := p.Float64Ptr()
  3552. if *vp == nil {
  3553. *vp = new(float64)
  3554. }
  3555. **vp = math.Float64frombits(v)
  3556. return n, nil
  3557. }
  3558. var coderDoublePtr = pointerCoderFuncs{
  3559. size: sizeDoublePtr,
  3560. marshal: appendDoublePtr,
  3561. unmarshal: consumeDoublePtr,
  3562. }
  3563. // sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
  3564. func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3565. s := *p.Float64Slice()
  3566. size = len(s) * (tagsize + wire.SizeFixed64())
  3567. return size
  3568. }
  3569. // appendDoubleSlice encodes a []float64 pointer as a repeated Double.
  3570. func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3571. s := *p.Float64Slice()
  3572. for _, v := range s {
  3573. b = wire.AppendVarint(b, wiretag)
  3574. b = wire.AppendFixed64(b, math.Float64bits(v))
  3575. }
  3576. return b, nil
  3577. }
  3578. // consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
  3579. func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3580. sp := p.Float64Slice()
  3581. if wtyp == wire.BytesType {
  3582. s := *sp
  3583. b, n = wire.ConsumeBytes(b)
  3584. if n < 0 {
  3585. return 0, wire.ParseError(n)
  3586. }
  3587. for len(b) > 0 {
  3588. v, n := wire.ConsumeFixed64(b)
  3589. if n < 0 {
  3590. return 0, wire.ParseError(n)
  3591. }
  3592. s = append(s, math.Float64frombits(v))
  3593. b = b[n:]
  3594. }
  3595. *sp = s
  3596. return n, nil
  3597. }
  3598. if wtyp != wire.Fixed64Type {
  3599. return 0, errUnknown
  3600. }
  3601. v, n := wire.ConsumeFixed64(b)
  3602. if n < 0 {
  3603. return 0, wire.ParseError(n)
  3604. }
  3605. *sp = append(*sp, math.Float64frombits(v))
  3606. return n, nil
  3607. }
  3608. var coderDoubleSlice = pointerCoderFuncs{
  3609. size: sizeDoubleSlice,
  3610. marshal: appendDoubleSlice,
  3611. unmarshal: consumeDoubleSlice,
  3612. }
  3613. // sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
  3614. func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3615. s := *p.Float64Slice()
  3616. if len(s) == 0 {
  3617. return 0
  3618. }
  3619. n := len(s) * wire.SizeFixed64()
  3620. return tagsize + wire.SizeBytes(n)
  3621. }
  3622. // appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
  3623. func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3624. s := *p.Float64Slice()
  3625. if len(s) == 0 {
  3626. return b, nil
  3627. }
  3628. b = wire.AppendVarint(b, wiretag)
  3629. n := len(s) * wire.SizeFixed64()
  3630. b = wire.AppendVarint(b, uint64(n))
  3631. for _, v := range s {
  3632. b = wire.AppendFixed64(b, math.Float64bits(v))
  3633. }
  3634. return b, nil
  3635. }
  3636. var coderDoublePackedSlice = pointerCoderFuncs{
  3637. size: sizeDoublePackedSlice,
  3638. marshal: appendDoublePackedSlice,
  3639. unmarshal: consumeDoubleSlice,
  3640. }
  3641. // sizeDoubleValue returns the size of wire encoding a float64 value as a Double.
  3642. func sizeDoubleValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  3643. return tagsize + wire.SizeFixed64()
  3644. }
  3645. // appendDoubleValue encodes a float64 value as a Double.
  3646. func appendDoubleValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3647. b = wire.AppendVarint(b, wiretag)
  3648. b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
  3649. return b, nil
  3650. }
  3651. // consumeDoubleValue decodes a float64 value as a Double.
  3652. func consumeDoubleValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  3653. if wtyp != wire.Fixed64Type {
  3654. return protoreflect.Value{}, 0, errUnknown
  3655. }
  3656. v, n := wire.ConsumeFixed64(b)
  3657. if n < 0 {
  3658. return protoreflect.Value{}, 0, wire.ParseError(n)
  3659. }
  3660. return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
  3661. }
  3662. var coderDoubleValue = valueCoderFuncs{
  3663. size: sizeDoubleValue,
  3664. marshal: appendDoubleValue,
  3665. unmarshal: consumeDoubleValue,
  3666. }
  3667. // sizeDoubleSliceValue returns the size of wire encoding a []float64 value as a repeated Double.
  3668. func sizeDoubleSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3669. list := listv.List()
  3670. size = list.Len() * (tagsize + wire.SizeFixed64())
  3671. return size
  3672. }
  3673. // appendDoubleSliceValue encodes a []float64 value as a repeated Double.
  3674. func appendDoubleSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3675. list := listv.List()
  3676. for i, llen := 0, list.Len(); i < llen; i++ {
  3677. v := list.Get(i)
  3678. b = wire.AppendVarint(b, wiretag)
  3679. b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
  3680. }
  3681. return b, nil
  3682. }
  3683. // consumeDoubleSliceValue wire decodes a []float64 value as a repeated Double.
  3684. func consumeDoubleSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  3685. list := listv.List()
  3686. if wtyp == wire.BytesType {
  3687. b, n = wire.ConsumeBytes(b)
  3688. if n < 0 {
  3689. return protoreflect.Value{}, 0, wire.ParseError(n)
  3690. }
  3691. for len(b) > 0 {
  3692. v, n := wire.ConsumeFixed64(b)
  3693. if n < 0 {
  3694. return protoreflect.Value{}, 0, wire.ParseError(n)
  3695. }
  3696. list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
  3697. b = b[n:]
  3698. }
  3699. return listv, n, nil
  3700. }
  3701. if wtyp != wire.Fixed64Type {
  3702. return protoreflect.Value{}, 0, errUnknown
  3703. }
  3704. v, n := wire.ConsumeFixed64(b)
  3705. if n < 0 {
  3706. return protoreflect.Value{}, 0, wire.ParseError(n)
  3707. }
  3708. list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
  3709. return listv, n, nil
  3710. }
  3711. var coderDoubleSliceValue = valueCoderFuncs{
  3712. size: sizeDoubleSliceValue,
  3713. marshal: appendDoubleSliceValue,
  3714. unmarshal: consumeDoubleSliceValue,
  3715. }
  3716. // sizeDoublePackedSliceValue returns the size of wire encoding a []float64 value as a packed repeated Double.
  3717. func sizeDoublePackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  3718. list := listv.List()
  3719. n := list.Len() * wire.SizeFixed64()
  3720. return tagsize + wire.SizeBytes(n)
  3721. }
  3722. // appendDoublePackedSliceValue encodes a []float64 value as a packed repeated Double.
  3723. func appendDoublePackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3724. list := listv.List()
  3725. llen := list.Len()
  3726. if llen == 0 {
  3727. return b, nil
  3728. }
  3729. b = wire.AppendVarint(b, wiretag)
  3730. n := llen * wire.SizeFixed64()
  3731. b = wire.AppendVarint(b, uint64(n))
  3732. for i := 0; i < llen; i++ {
  3733. v := list.Get(i)
  3734. b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
  3735. }
  3736. return b, nil
  3737. }
  3738. var coderDoublePackedSliceValue = valueCoderFuncs{
  3739. size: sizeDoublePackedSliceValue,
  3740. marshal: appendDoublePackedSliceValue,
  3741. unmarshal: consumeDoubleSliceValue,
  3742. }
  3743. // sizeString returns the size of wire encoding a string pointer as a String.
  3744. func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
  3745. v := *p.String()
  3746. return tagsize + wire.SizeBytes(len(v))
  3747. }
  3748. // appendString wire encodes a string pointer as a String.
  3749. func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3750. v := *p.String()
  3751. b = wire.AppendVarint(b, wiretag)
  3752. b = wire.AppendString(b, v)
  3753. return b, nil
  3754. }
  3755. // consumeString wire decodes a string pointer as a String.
  3756. func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3757. if wtyp != wire.BytesType {
  3758. return 0, errUnknown
  3759. }
  3760. v, n := wire.ConsumeString(b)
  3761. if n < 0 {
  3762. return 0, wire.ParseError(n)
  3763. }
  3764. *p.String() = v
  3765. return n, nil
  3766. }
  3767. var coderString = pointerCoderFuncs{
  3768. size: sizeString,
  3769. marshal: appendString,
  3770. unmarshal: consumeString,
  3771. }
  3772. // appendStringValidateUTF8 wire encodes a string pointer as a String.
  3773. func appendStringValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3774. v := *p.String()
  3775. b = wire.AppendVarint(b, wiretag)
  3776. b = wire.AppendString(b, v)
  3777. if !utf8.ValidString(v) {
  3778. return b, errInvalidUTF8{}
  3779. }
  3780. return b, nil
  3781. }
  3782. // consumeStringValidateUTF8 wire decodes a string pointer as a String.
  3783. func consumeStringValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3784. if wtyp != wire.BytesType {
  3785. return 0, errUnknown
  3786. }
  3787. v, n := wire.ConsumeString(b)
  3788. if n < 0 {
  3789. return 0, wire.ParseError(n)
  3790. }
  3791. if !utf8.ValidString(v) {
  3792. return 0, errInvalidUTF8{}
  3793. }
  3794. *p.String() = v
  3795. return n, nil
  3796. }
  3797. var coderStringValidateUTF8 = pointerCoderFuncs{
  3798. size: sizeString,
  3799. marshal: appendStringValidateUTF8,
  3800. unmarshal: consumeStringValidateUTF8,
  3801. }
  3802. // sizeStringNoZero returns the size of wire encoding a string pointer as a String.
  3803. // The zero value is not encoded.
  3804. func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  3805. v := *p.String()
  3806. if len(v) == 0 {
  3807. return 0
  3808. }
  3809. return tagsize + wire.SizeBytes(len(v))
  3810. }
  3811. // appendStringNoZero wire encodes a string pointer as a String.
  3812. // The zero value is not encoded.
  3813. func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3814. v := *p.String()
  3815. if len(v) == 0 {
  3816. return b, nil
  3817. }
  3818. b = wire.AppendVarint(b, wiretag)
  3819. b = wire.AppendString(b, v)
  3820. return b, nil
  3821. }
  3822. var coderStringNoZero = pointerCoderFuncs{
  3823. size: sizeStringNoZero,
  3824. marshal: appendStringNoZero,
  3825. unmarshal: consumeString,
  3826. }
  3827. // appendStringNoZeroValidateUTF8 wire encodes a string pointer as a String.
  3828. // The zero value is not encoded.
  3829. func appendStringNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3830. v := *p.String()
  3831. if len(v) == 0 {
  3832. return b, nil
  3833. }
  3834. b = wire.AppendVarint(b, wiretag)
  3835. b = wire.AppendString(b, v)
  3836. if !utf8.ValidString(v) {
  3837. return b, errInvalidUTF8{}
  3838. }
  3839. return b, nil
  3840. }
  3841. var coderStringNoZeroValidateUTF8 = pointerCoderFuncs{
  3842. size: sizeStringNoZero,
  3843. marshal: appendStringNoZeroValidateUTF8,
  3844. unmarshal: consumeStringValidateUTF8,
  3845. }
  3846. // sizeStringPtr returns the size of wire encoding a *string pointer as a String.
  3847. // It panics if the pointer is nil.
  3848. func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  3849. v := **p.StringPtr()
  3850. return tagsize + wire.SizeBytes(len(v))
  3851. }
  3852. // appendStringPtr wire encodes a *string pointer as a String.
  3853. // It panics if the pointer is nil.
  3854. func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3855. v := **p.StringPtr()
  3856. b = wire.AppendVarint(b, wiretag)
  3857. b = wire.AppendString(b, v)
  3858. return b, nil
  3859. }
  3860. // consumeStringPtr wire decodes a *string pointer as a String.
  3861. func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3862. if wtyp != wire.BytesType {
  3863. return 0, errUnknown
  3864. }
  3865. v, n := wire.ConsumeString(b)
  3866. if n < 0 {
  3867. return 0, wire.ParseError(n)
  3868. }
  3869. vp := p.StringPtr()
  3870. if *vp == nil {
  3871. *vp = new(string)
  3872. }
  3873. **vp = v
  3874. return n, nil
  3875. }
  3876. var coderStringPtr = pointerCoderFuncs{
  3877. size: sizeStringPtr,
  3878. marshal: appendStringPtr,
  3879. unmarshal: consumeStringPtr,
  3880. }
  3881. // sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
  3882. func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  3883. s := *p.StringSlice()
  3884. for _, v := range s {
  3885. size += tagsize + wire.SizeBytes(len(v))
  3886. }
  3887. return size
  3888. }
  3889. // appendStringSlice encodes a []string pointer as a repeated String.
  3890. func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3891. s := *p.StringSlice()
  3892. for _, v := range s {
  3893. b = wire.AppendVarint(b, wiretag)
  3894. b = wire.AppendString(b, v)
  3895. }
  3896. return b, nil
  3897. }
  3898. // consumeStringSlice wire decodes a []string pointer as a repeated String.
  3899. func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3900. sp := p.StringSlice()
  3901. if wtyp != wire.BytesType {
  3902. return 0, errUnknown
  3903. }
  3904. v, n := wire.ConsumeString(b)
  3905. if n < 0 {
  3906. return 0, wire.ParseError(n)
  3907. }
  3908. *sp = append(*sp, v)
  3909. return n, nil
  3910. }
  3911. var coderStringSlice = pointerCoderFuncs{
  3912. size: sizeStringSlice,
  3913. marshal: appendStringSlice,
  3914. unmarshal: consumeStringSlice,
  3915. }
  3916. // appendStringSliceValidateUTF8 encodes a []string pointer as a repeated String.
  3917. func appendStringSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3918. s := *p.StringSlice()
  3919. for _, v := range s {
  3920. b = wire.AppendVarint(b, wiretag)
  3921. b = wire.AppendString(b, v)
  3922. if !utf8.ValidString(v) {
  3923. return b, errInvalidUTF8{}
  3924. }
  3925. }
  3926. return b, nil
  3927. }
  3928. // consumeStringSliceValidateUTF8 wire decodes a []string pointer as a repeated String.
  3929. func consumeStringSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  3930. sp := p.StringSlice()
  3931. if wtyp != wire.BytesType {
  3932. return 0, errUnknown
  3933. }
  3934. v, n := wire.ConsumeString(b)
  3935. if n < 0 {
  3936. return 0, wire.ParseError(n)
  3937. }
  3938. if !utf8.ValidString(v) {
  3939. return 0, errInvalidUTF8{}
  3940. }
  3941. *sp = append(*sp, v)
  3942. return n, nil
  3943. }
  3944. var coderStringSliceValidateUTF8 = pointerCoderFuncs{
  3945. size: sizeStringSlice,
  3946. marshal: appendStringSliceValidateUTF8,
  3947. unmarshal: consumeStringSliceValidateUTF8,
  3948. }
  3949. // sizeStringValue returns the size of wire encoding a string value as a String.
  3950. func sizeStringValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  3951. return tagsize + wire.SizeBytes(len(v.String()))
  3952. }
  3953. // appendStringValue encodes a string value as a String.
  3954. func appendStringValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3955. b = wire.AppendVarint(b, wiretag)
  3956. b = wire.AppendString(b, v.String())
  3957. return b, nil
  3958. }
  3959. // consumeStringValue decodes a string value as a String.
  3960. func consumeStringValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  3961. if wtyp != wire.BytesType {
  3962. return protoreflect.Value{}, 0, errUnknown
  3963. }
  3964. v, n := wire.ConsumeString(b)
  3965. if n < 0 {
  3966. return protoreflect.Value{}, 0, wire.ParseError(n)
  3967. }
  3968. return protoreflect.ValueOfString(string(v)), n, nil
  3969. }
  3970. var coderStringValue = valueCoderFuncs{
  3971. size: sizeStringValue,
  3972. marshal: appendStringValue,
  3973. unmarshal: consumeStringValue,
  3974. }
  3975. // appendStringValueValidateUTF8 encodes a string value as a String.
  3976. func appendStringValueValidateUTF8(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  3977. b = wire.AppendVarint(b, wiretag)
  3978. b = wire.AppendString(b, v.String())
  3979. if !utf8.ValidString(v.String()) {
  3980. return b, errInvalidUTF8{}
  3981. }
  3982. return b, nil
  3983. }
  3984. // consumeStringValueValidateUTF8 decodes a string value as a String.
  3985. func consumeStringValueValidateUTF8(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  3986. if wtyp != wire.BytesType {
  3987. return protoreflect.Value{}, 0, errUnknown
  3988. }
  3989. v, n := wire.ConsumeString(b)
  3990. if n < 0 {
  3991. return protoreflect.Value{}, 0, wire.ParseError(n)
  3992. }
  3993. if !utf8.ValidString(v) {
  3994. return protoreflect.Value{}, 0, errInvalidUTF8{}
  3995. }
  3996. return protoreflect.ValueOfString(string(v)), n, nil
  3997. }
  3998. var coderStringValueValidateUTF8 = valueCoderFuncs{
  3999. size: sizeStringValue,
  4000. marshal: appendStringValueValidateUTF8,
  4001. unmarshal: consumeStringValueValidateUTF8,
  4002. }
  4003. // sizeStringSliceValue returns the size of wire encoding a []string value as a repeated String.
  4004. func sizeStringSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  4005. list := listv.List()
  4006. for i, llen := 0, list.Len(); i < llen; i++ {
  4007. v := list.Get(i)
  4008. size += tagsize + wire.SizeBytes(len(v.String()))
  4009. }
  4010. return size
  4011. }
  4012. // appendStringSliceValue encodes a []string value as a repeated String.
  4013. func appendStringSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4014. list := listv.List()
  4015. for i, llen := 0, list.Len(); i < llen; i++ {
  4016. v := list.Get(i)
  4017. b = wire.AppendVarint(b, wiretag)
  4018. b = wire.AppendString(b, v.String())
  4019. }
  4020. return b, nil
  4021. }
  4022. // consumeStringSliceValue wire decodes a []string value as a repeated String.
  4023. func consumeStringSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  4024. list := listv.List()
  4025. if wtyp != wire.BytesType {
  4026. return protoreflect.Value{}, 0, errUnknown
  4027. }
  4028. v, n := wire.ConsumeString(b)
  4029. if n < 0 {
  4030. return protoreflect.Value{}, 0, wire.ParseError(n)
  4031. }
  4032. list.Append(protoreflect.ValueOfString(string(v)))
  4033. return listv, n, nil
  4034. }
  4035. var coderStringSliceValue = valueCoderFuncs{
  4036. size: sizeStringSliceValue,
  4037. marshal: appendStringSliceValue,
  4038. unmarshal: consumeStringSliceValue,
  4039. }
  4040. // sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
  4041. func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
  4042. v := *p.Bytes()
  4043. return tagsize + wire.SizeBytes(len(v))
  4044. }
  4045. // appendBytes wire encodes a []byte pointer as a Bytes.
  4046. func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4047. v := *p.Bytes()
  4048. b = wire.AppendVarint(b, wiretag)
  4049. b = wire.AppendBytes(b, v)
  4050. return b, nil
  4051. }
  4052. // consumeBytes wire decodes a []byte pointer as a Bytes.
  4053. func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4054. if wtyp != wire.BytesType {
  4055. return 0, errUnknown
  4056. }
  4057. v, n := wire.ConsumeBytes(b)
  4058. if n < 0 {
  4059. return 0, wire.ParseError(n)
  4060. }
  4061. *p.Bytes() = append(emptyBuf[:], v...)
  4062. return n, nil
  4063. }
  4064. var coderBytes = pointerCoderFuncs{
  4065. size: sizeBytes,
  4066. marshal: appendBytes,
  4067. unmarshal: consumeBytes,
  4068. }
  4069. // appendBytesValidateUTF8 wire encodes a []byte pointer as a Bytes.
  4070. func appendBytesValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4071. v := *p.Bytes()
  4072. b = wire.AppendVarint(b, wiretag)
  4073. b = wire.AppendBytes(b, v)
  4074. if !utf8.Valid(v) {
  4075. return b, errInvalidUTF8{}
  4076. }
  4077. return b, nil
  4078. }
  4079. // consumeBytesValidateUTF8 wire decodes a []byte pointer as a Bytes.
  4080. func consumeBytesValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4081. if wtyp != wire.BytesType {
  4082. return 0, errUnknown
  4083. }
  4084. v, n := wire.ConsumeBytes(b)
  4085. if n < 0 {
  4086. return 0, wire.ParseError(n)
  4087. }
  4088. if !utf8.Valid(v) {
  4089. return 0, errInvalidUTF8{}
  4090. }
  4091. *p.Bytes() = append(emptyBuf[:], v...)
  4092. return n, nil
  4093. }
  4094. var coderBytesValidateUTF8 = pointerCoderFuncs{
  4095. size: sizeBytes,
  4096. marshal: appendBytesValidateUTF8,
  4097. unmarshal: consumeBytesValidateUTF8,
  4098. }
  4099. // sizeBytesNoZero returns the size of wire encoding a []byte pointer as a Bytes.
  4100. // The zero value is not encoded.
  4101. func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  4102. v := *p.Bytes()
  4103. if len(v) == 0 {
  4104. return 0
  4105. }
  4106. return tagsize + wire.SizeBytes(len(v))
  4107. }
  4108. // appendBytesNoZero wire encodes a []byte pointer as a Bytes.
  4109. // The zero value is not encoded.
  4110. func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4111. v := *p.Bytes()
  4112. if len(v) == 0 {
  4113. return b, nil
  4114. }
  4115. b = wire.AppendVarint(b, wiretag)
  4116. b = wire.AppendBytes(b, v)
  4117. return b, nil
  4118. }
  4119. // consumeBytesNoZero wire decodes a []byte pointer as a Bytes.
  4120. // The zero value is not decoded.
  4121. func consumeBytesNoZero(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4122. if wtyp != wire.BytesType {
  4123. return 0, errUnknown
  4124. }
  4125. v, n := wire.ConsumeBytes(b)
  4126. if n < 0 {
  4127. return 0, wire.ParseError(n)
  4128. }
  4129. *p.Bytes() = append(([]byte)(nil), v...)
  4130. return n, nil
  4131. }
  4132. var coderBytesNoZero = pointerCoderFuncs{
  4133. size: sizeBytesNoZero,
  4134. marshal: appendBytesNoZero,
  4135. unmarshal: consumeBytesNoZero,
  4136. }
  4137. // appendBytesNoZeroValidateUTF8 wire encodes a []byte pointer as a Bytes.
  4138. // The zero value is not encoded.
  4139. func appendBytesNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4140. v := *p.Bytes()
  4141. if len(v) == 0 {
  4142. return b, nil
  4143. }
  4144. b = wire.AppendVarint(b, wiretag)
  4145. b = wire.AppendBytes(b, v)
  4146. if !utf8.Valid(v) {
  4147. return b, errInvalidUTF8{}
  4148. }
  4149. return b, nil
  4150. }
  4151. // consumeBytesNoZeroValidateUTF8 wire decodes a []byte pointer as a Bytes.
  4152. func consumeBytesNoZeroValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4153. if wtyp != wire.BytesType {
  4154. return 0, errUnknown
  4155. }
  4156. v, n := wire.ConsumeBytes(b)
  4157. if n < 0 {
  4158. return 0, wire.ParseError(n)
  4159. }
  4160. if !utf8.Valid(v) {
  4161. return 0, errInvalidUTF8{}
  4162. }
  4163. *p.Bytes() = append(([]byte)(nil), v...)
  4164. return n, nil
  4165. }
  4166. var coderBytesNoZeroValidateUTF8 = pointerCoderFuncs{
  4167. size: sizeBytesNoZero,
  4168. marshal: appendBytesNoZeroValidateUTF8,
  4169. unmarshal: consumeBytesNoZeroValidateUTF8,
  4170. }
  4171. // sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
  4172. func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  4173. s := *p.BytesSlice()
  4174. for _, v := range s {
  4175. size += tagsize + wire.SizeBytes(len(v))
  4176. }
  4177. return size
  4178. }
  4179. // appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
  4180. func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4181. s := *p.BytesSlice()
  4182. for _, v := range s {
  4183. b = wire.AppendVarint(b, wiretag)
  4184. b = wire.AppendBytes(b, v)
  4185. }
  4186. return b, nil
  4187. }
  4188. // consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
  4189. func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4190. sp := p.BytesSlice()
  4191. if wtyp != wire.BytesType {
  4192. return 0, errUnknown
  4193. }
  4194. v, n := wire.ConsumeBytes(b)
  4195. if n < 0 {
  4196. return 0, wire.ParseError(n)
  4197. }
  4198. *sp = append(*sp, append(emptyBuf[:], v...))
  4199. return n, nil
  4200. }
  4201. var coderBytesSlice = pointerCoderFuncs{
  4202. size: sizeBytesSlice,
  4203. marshal: appendBytesSlice,
  4204. unmarshal: consumeBytesSlice,
  4205. }
  4206. // appendBytesSliceValidateUTF8 encodes a [][]byte pointer as a repeated Bytes.
  4207. func appendBytesSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4208. s := *p.BytesSlice()
  4209. for _, v := range s {
  4210. b = wire.AppendVarint(b, wiretag)
  4211. b = wire.AppendBytes(b, v)
  4212. if !utf8.Valid(v) {
  4213. return b, errInvalidUTF8{}
  4214. }
  4215. }
  4216. return b, nil
  4217. }
  4218. // consumeBytesSliceValidateUTF8 wire decodes a [][]byte pointer as a repeated Bytes.
  4219. func consumeBytesSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
  4220. sp := p.BytesSlice()
  4221. if wtyp != wire.BytesType {
  4222. return 0, errUnknown
  4223. }
  4224. v, n := wire.ConsumeBytes(b)
  4225. if n < 0 {
  4226. return 0, wire.ParseError(n)
  4227. }
  4228. if !utf8.Valid(v) {
  4229. return 0, errInvalidUTF8{}
  4230. }
  4231. *sp = append(*sp, append(emptyBuf[:], v...))
  4232. return n, nil
  4233. }
  4234. var coderBytesSliceValidateUTF8 = pointerCoderFuncs{
  4235. size: sizeBytesSlice,
  4236. marshal: appendBytesSliceValidateUTF8,
  4237. unmarshal: consumeBytesSliceValidateUTF8,
  4238. }
  4239. // sizeBytesValue returns the size of wire encoding a []byte value as a Bytes.
  4240. func sizeBytesValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
  4241. return tagsize + wire.SizeBytes(len(v.Bytes()))
  4242. }
  4243. // appendBytesValue encodes a []byte value as a Bytes.
  4244. func appendBytesValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4245. b = wire.AppendVarint(b, wiretag)
  4246. b = wire.AppendBytes(b, v.Bytes())
  4247. return b, nil
  4248. }
  4249. // consumeBytesValue decodes a []byte value as a Bytes.
  4250. func consumeBytesValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
  4251. if wtyp != wire.BytesType {
  4252. return protoreflect.Value{}, 0, errUnknown
  4253. }
  4254. v, n := wire.ConsumeBytes(b)
  4255. if n < 0 {
  4256. return protoreflect.Value{}, 0, wire.ParseError(n)
  4257. }
  4258. return protoreflect.ValueOfBytes(append(([]byte)(nil), v...)), n, nil
  4259. }
  4260. var coderBytesValue = valueCoderFuncs{
  4261. size: sizeBytesValue,
  4262. marshal: appendBytesValue,
  4263. unmarshal: consumeBytesValue,
  4264. }
  4265. // sizeBytesSliceValue returns the size of wire encoding a [][]byte value as a repeated Bytes.
  4266. func sizeBytesSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
  4267. list := listv.List()
  4268. for i, llen := 0, list.Len(); i < llen; i++ {
  4269. v := list.Get(i)
  4270. size += tagsize + wire.SizeBytes(len(v.Bytes()))
  4271. }
  4272. return size
  4273. }
  4274. // appendBytesSliceValue encodes a [][]byte value as a repeated Bytes.
  4275. func appendBytesSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
  4276. list := listv.List()
  4277. for i, llen := 0, list.Len(); i < llen; i++ {
  4278. v := list.Get(i)
  4279. b = wire.AppendVarint(b, wiretag)
  4280. b = wire.AppendBytes(b, v.Bytes())
  4281. }
  4282. return b, nil
  4283. }
  4284. // consumeBytesSliceValue wire decodes a [][]byte value as a repeated Bytes.
  4285. func consumeBytesSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
  4286. list := listv.List()
  4287. if wtyp != wire.BytesType {
  4288. return protoreflect.Value{}, 0, errUnknown
  4289. }
  4290. v, n := wire.ConsumeBytes(b)
  4291. if n < 0 {
  4292. return protoreflect.Value{}, 0, wire.ParseError(n)
  4293. }
  4294. list.Append(protoreflect.ValueOfBytes(append(([]byte)(nil), v...)))
  4295. return listv, n, nil
  4296. }
  4297. var coderBytesSliceValue = valueCoderFuncs{
  4298. size: sizeBytesSliceValue,
  4299. marshal: appendBytesSliceValue,
  4300. unmarshal: consumeBytesSliceValue,
  4301. }
  4302. // We append to an empty array rather than a nil []byte to get non-nil zero-length byte slices.
  4303. var emptyBuf [0]byte
  4304. var wireTypes = map[protoreflect.Kind]wire.Type{
  4305. protoreflect.BoolKind: wire.VarintType,
  4306. protoreflect.EnumKind: wire.VarintType,
  4307. protoreflect.Int32Kind: wire.VarintType,
  4308. protoreflect.Sint32Kind: wire.VarintType,
  4309. protoreflect.Uint32Kind: wire.VarintType,
  4310. protoreflect.Int64Kind: wire.VarintType,
  4311. protoreflect.Sint64Kind: wire.VarintType,
  4312. protoreflect.Uint64Kind: wire.VarintType,
  4313. protoreflect.Sfixed32Kind: wire.Fixed32Type,
  4314. protoreflect.Fixed32Kind: wire.Fixed32Type,
  4315. protoreflect.FloatKind: wire.Fixed32Type,
  4316. protoreflect.Sfixed64Kind: wire.Fixed64Type,
  4317. protoreflect.Fixed64Kind: wire.Fixed64Type,
  4318. protoreflect.DoubleKind: wire.Fixed64Type,
  4319. protoreflect.StringKind: wire.BytesType,
  4320. protoreflect.BytesKind: wire.BytesType,
  4321. protoreflect.MessageKind: wire.BytesType,
  4322. protoreflect.GroupKind: wire.StartGroupType,
  4323. }