codec_gen.go 121 KB

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