codec_gen.go 128 KB

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