codec_gen.go 109 KB

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