| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817 |
- // Copyright 2018 The Go Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style.
- // license that can be found in the LICENSE file.
- // Code generated by generate-types. DO NOT EDIT.
- package impl
- import (
- "math"
- "unicode/utf8"
- "google.golang.org/protobuf/internal/encoding/wire"
- "google.golang.org/protobuf/reflect/protoreflect"
- )
- // sizeBool returns the size of wire encoding a bool pointer as a Bool.
- func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Bool()
- return tagsize + wire.SizeVarint(wire.EncodeBool(v))
- }
- // appendBool wire encodes a bool pointer as a Bool.
- func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bool()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v))
- return b, nil
- }
- // consumeBool wire decodes a bool pointer as a Bool.
- func consumeBool(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Bool() = wire.DecodeBool(v)
- return n, nil
- }
- var coderBool = pointerCoderFuncs{
- size: sizeBool,
- marshal: appendBool,
- unmarshal: consumeBool,
- }
- // sizeBoolNoZero returns the size of wire encoding a bool pointer as a Bool.
- // The zero value is not encoded.
- func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Bool()
- if v == false {
- return 0
- }
- return tagsize + wire.SizeVarint(wire.EncodeBool(v))
- }
- // appendBoolNoZero wire encodes a bool pointer as a Bool.
- // The zero value is not encoded.
- func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bool()
- if v == false {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v))
- return b, nil
- }
- var coderBoolNoZero = pointerCoderFuncs{
- size: sizeBoolNoZero,
- marshal: appendBoolNoZero,
- unmarshal: consumeBool,
- }
- // sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
- // It panics if the pointer is nil.
- func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.BoolPtr()
- return tagsize + wire.SizeVarint(wire.EncodeBool(v))
- }
- // appendBoolPtr wire encodes a *bool pointer as a Bool.
- // It panics if the pointer is nil.
- func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.BoolPtr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v))
- return b, nil
- }
- // consumeBoolPtr wire decodes a *bool pointer as a Bool.
- func consumeBoolPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.BoolPtr()
- if *vp == nil {
- *vp = new(bool)
- }
- **vp = wire.DecodeBool(v)
- return n, nil
- }
- var coderBoolPtr = pointerCoderFuncs{
- size: sizeBoolPtr,
- marshal: appendBoolPtr,
- unmarshal: consumeBoolPtr,
- }
- // sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
- func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.BoolSlice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
- }
- return size
- }
- // appendBoolSlice encodes a []bool pointer as a repeated Bool.
- func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.BoolSlice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v))
- }
- return b, nil
- }
- // consumeBoolSlice wire decodes a []bool pointer as a repeated Bool.
- func consumeBoolSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.BoolSlice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, wire.DecodeBool(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, wire.DecodeBool(v))
- return n, nil
- }
- var coderBoolSlice = pointerCoderFuncs{
- size: sizeBoolSlice,
- marshal: appendBoolSlice,
- unmarshal: consumeBoolSlice,
- }
- // sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
- func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.BoolSlice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeBool(v))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
- func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.BoolSlice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeBool(v))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, wire.EncodeBool(v))
- }
- return b, nil
- }
- var coderBoolPackedSlice = pointerCoderFuncs{
- size: sizeBoolPackedSlice,
- marshal: appendBoolPackedSlice,
- unmarshal: consumeBoolSlice,
- }
- // sizeBoolValue returns the size of wire encoding a bool value as a Bool.
- func sizeBoolValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
- }
- // appendBoolValue encodes a bool value as a Bool.
- func appendBoolValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
- return b, nil
- }
- // consumeBoolValue decodes a bool value as a Bool.
- func consumeBoolValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfBool(wire.DecodeBool(v)), n, nil
- }
- var coderBoolValue = valueCoderFuncs{
- size: sizeBoolValue,
- marshal: appendBoolValue,
- unmarshal: consumeBoolValue,
- }
- // sizeBoolSliceValue returns the size of wire encoding a []bool value as a repeated Bool.
- func sizeBoolSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(wire.EncodeBool(v.Bool()))
- }
- return size
- }
- // appendBoolSliceValue encodes a []bool value as a repeated Bool.
- func appendBoolSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
- }
- return b, nil
- }
- // consumeBoolSliceValue wire decodes a []bool value as a repeated Bool.
- func consumeBoolSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfBool(wire.DecodeBool(v)))
- return listv, n, nil
- }
- var coderBoolSliceValue = valueCoderFuncs{
- size: sizeBoolSliceValue,
- marshal: appendBoolSliceValue,
- unmarshal: consumeBoolSliceValue,
- }
- // sizeBoolPackedSliceValue returns the size of wire encoding a []bool value as a packed repeated Bool.
- func sizeBoolPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendBoolPackedSliceValue encodes a []bool value as a packed repeated Bool.
- func appendBoolPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeBool(v.Bool()))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wire.EncodeBool(v.Bool()))
- }
- return b, nil
- }
- var coderBoolPackedSliceValue = valueCoderFuncs{
- size: sizeBoolPackedSliceValue,
- marshal: appendBoolPackedSliceValue,
- unmarshal: consumeBoolSliceValue,
- }
- // sizeEnumValue returns the size of wire encoding a value as a Enum.
- func sizeEnumValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(uint64(v.Enum()))
- }
- // appendEnumValue encodes a value as a Enum.
- func appendEnumValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v.Enum()))
- return b, nil
- }
- // consumeEnumValue decodes a value as a Enum.
- func consumeEnumValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
- }
- var coderEnumValue = valueCoderFuncs{
- size: sizeEnumValue,
- marshal: appendEnumValue,
- unmarshal: consumeEnumValue,
- }
- // sizeEnumSliceValue returns the size of wire encoding a [] value as a repeated Enum.
- func sizeEnumSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(uint64(v.Enum()))
- }
- return size
- }
- // appendEnumSliceValue encodes a [] value as a repeated Enum.
- func appendEnumSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v.Enum()))
- }
- return b, nil
- }
- // consumeEnumSliceValue wire decodes a [] value as a repeated Enum.
- func consumeEnumSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
- return listv, n, nil
- }
- var coderEnumSliceValue = valueCoderFuncs{
- size: sizeEnumSliceValue,
- marshal: appendEnumSliceValue,
- unmarshal: consumeEnumSliceValue,
- }
- // sizeEnumPackedSliceValue returns the size of wire encoding a [] value as a packed repeated Enum.
- func sizeEnumPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(v.Enum()))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendEnumPackedSliceValue encodes a [] value as a packed repeated Enum.
- func appendEnumPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(v.Enum()))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, uint64(v.Enum()))
- }
- return b, nil
- }
- var coderEnumPackedSliceValue = valueCoderFuncs{
- size: sizeEnumPackedSliceValue,
- marshal: appendEnumPackedSliceValue,
- unmarshal: consumeEnumSliceValue,
- }
- // sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
- func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int32()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt32 wire encodes a int32 pointer as a Int32.
- func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeInt32 wire decodes a int32 pointer as a Int32.
- func consumeInt32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int32() = int32(v)
- return n, nil
- }
- var coderInt32 = pointerCoderFuncs{
- size: sizeInt32,
- marshal: appendInt32,
- unmarshal: consumeInt32,
- }
- // sizeInt32NoZero returns the size of wire encoding a int32 pointer as a Int32.
- // The zero value is not encoded.
- func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int32()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt32NoZero wire encodes a int32 pointer as a Int32.
- // The zero value is not encoded.
- func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- var coderInt32NoZero = pointerCoderFuncs{
- size: sizeInt32NoZero,
- marshal: appendInt32NoZero,
- unmarshal: consumeInt32,
- }
- // sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
- // It panics if the pointer is nil.
- func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Int32Ptr()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt32Ptr wire encodes a *int32 pointer as a Int32.
- // It panics if the pointer is nil.
- func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeInt32Ptr wire decodes a *int32 pointer as a Int32.
- func consumeInt32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int32Ptr()
- if *vp == nil {
- *vp = new(int32)
- }
- **vp = int32(v)
- return n, nil
- }
- var coderInt32Ptr = pointerCoderFuncs{
- size: sizeInt32Ptr,
- marshal: appendInt32Ptr,
- unmarshal: consumeInt32Ptr,
- }
- // sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
- func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(uint64(v))
- }
- return size
- }
- // appendInt32Slice encodes a []int32 pointer as a repeated Int32.
- func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- // consumeInt32Slice wire decodes a []int32 pointer as a repeated Int32.
- func consumeInt32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, int32(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, int32(v))
- return n, nil
- }
- var coderInt32Slice = pointerCoderFuncs{
- size: sizeInt32Slice,
- marshal: appendInt32Slice,
- unmarshal: consumeInt32Slice,
- }
- // sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
- func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
- func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- var coderInt32PackedSlice = pointerCoderFuncs{
- size: sizeInt32PackedSlice,
- marshal: appendInt32PackedSlice,
- unmarshal: consumeInt32Slice,
- }
- // sizeInt32Value returns the size of wire encoding a int32 value as a Int32.
- func sizeInt32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(uint64(int32(v.Int())))
- }
- // appendInt32Value encodes a int32 value as a Int32.
- func appendInt32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(int32(v.Int())))
- return b, nil
- }
- // consumeInt32Value decodes a int32 value as a Int32.
- func consumeInt32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt32(int32(v)), n, nil
- }
- var coderInt32Value = valueCoderFuncs{
- size: sizeInt32Value,
- marshal: appendInt32Value,
- unmarshal: consumeInt32Value,
- }
- // sizeInt32SliceValue returns the size of wire encoding a []int32 value as a repeated Int32.
- func sizeInt32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(uint64(int32(v.Int())))
- }
- return size
- }
- // appendInt32SliceValue encodes a []int32 value as a repeated Int32.
- func appendInt32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(int32(v.Int())))
- }
- return b, nil
- }
- // consumeInt32SliceValue wire decodes a []int32 value as a repeated Int32.
- func consumeInt32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(v)))
- return listv, n, nil
- }
- var coderInt32SliceValue = valueCoderFuncs{
- size: sizeInt32SliceValue,
- marshal: appendInt32SliceValue,
- unmarshal: consumeInt32SliceValue,
- }
- // sizeInt32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Int32.
- func sizeInt32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(int32(v.Int())))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendInt32PackedSliceValue encodes a []int32 value as a packed repeated Int32.
- func appendInt32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(int32(v.Int())))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, uint64(int32(v.Int())))
- }
- return b, nil
- }
- var coderInt32PackedSliceValue = valueCoderFuncs{
- size: sizeInt32PackedSliceValue,
- marshal: appendInt32PackedSliceValue,
- unmarshal: consumeInt32SliceValue,
- }
- // sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
- func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int32()
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- // appendSint32 wire encodes a int32 pointer as a Sint32.
- func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
- return b, nil
- }
- // consumeSint32 wire decodes a int32 pointer as a Sint32.
- func consumeSint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int32() = int32(wire.DecodeZigZag(v & math.MaxUint32))
- return n, nil
- }
- var coderSint32 = pointerCoderFuncs{
- size: sizeSint32,
- marshal: appendSint32,
- unmarshal: consumeSint32,
- }
- // sizeSint32NoZero returns the size of wire encoding a int32 pointer as a Sint32.
- // The zero value is not encoded.
- func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int32()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- // appendSint32NoZero wire encodes a int32 pointer as a Sint32.
- // The zero value is not encoded.
- func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
- return b, nil
- }
- var coderSint32NoZero = pointerCoderFuncs{
- size: sizeSint32NoZero,
- marshal: appendSint32NoZero,
- unmarshal: consumeSint32,
- }
- // sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
- // It panics if the pointer is nil.
- func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Int32Ptr()
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- // appendSint32Ptr wire encodes a *int32 pointer as a Sint32.
- // It panics if the pointer is nil.
- func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
- return b, nil
- }
- // consumeSint32Ptr wire decodes a *int32 pointer as a Sint32.
- func consumeSint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int32Ptr()
- if *vp == nil {
- *vp = new(int32)
- }
- **vp = int32(wire.DecodeZigZag(v & math.MaxUint32))
- return n, nil
- }
- var coderSint32Ptr = pointerCoderFuncs{
- size: sizeSint32Ptr,
- marshal: appendSint32Ptr,
- unmarshal: consumeSint32Ptr,
- }
- // sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
- func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- return size
- }
- // appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
- func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
- }
- return b, nil
- }
- // consumeSint32Slice wire decodes a []int32 pointer as a repeated Sint32.
- func consumeSint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, int32(wire.DecodeZigZag(v&math.MaxUint32)))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, int32(wire.DecodeZigZag(v&math.MaxUint32)))
- return n, nil
- }
- var coderSint32Slice = pointerCoderFuncs{
- size: sizeSint32Slice,
- marshal: appendSint32Slice,
- unmarshal: consumeSint32Slice,
- }
- // sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
- func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
- func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
- }
- return b, nil
- }
- var coderSint32PackedSlice = pointerCoderFuncs{
- size: sizeSint32PackedSlice,
- marshal: appendSint32PackedSlice,
- unmarshal: consumeSint32Slice,
- }
- // sizeSint32Value returns the size of wire encoding a int32 value as a Sint32.
- func sizeSint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- // appendSint32Value encodes a int32 value as a Sint32.
- func appendSint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
- return b, nil
- }
- // consumeSint32Value decodes a int32 value as a Sint32.
- func consumeSint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))), n, nil
- }
- var coderSint32Value = valueCoderFuncs{
- size: sizeSint32Value,
- marshal: appendSint32Value,
- unmarshal: consumeSint32Value,
- }
- // sizeSint32SliceValue returns the size of wire encoding a []int32 value as a repeated Sint32.
- func sizeSint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- return size
- }
- // appendSint32SliceValue encodes a []int32 value as a repeated Sint32.
- func appendSint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- return b, nil
- }
- // consumeSint32SliceValue wire decodes a []int32 value as a repeated Sint32.
- func consumeSint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(wire.DecodeZigZag(v & math.MaxUint32))))
- return listv, n, nil
- }
- var coderSint32SliceValue = valueCoderFuncs{
- size: sizeSint32SliceValue,
- marshal: appendSint32SliceValue,
- unmarshal: consumeSint32SliceValue,
- }
- // sizeSint32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sint32.
- func sizeSint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendSint32PackedSliceValue encodes a []int32 value as a packed repeated Sint32.
- func appendSint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wire.EncodeZigZag(int64(int32(v.Int()))))
- }
- return b, nil
- }
- var coderSint32PackedSliceValue = valueCoderFuncs{
- size: sizeSint32PackedSliceValue,
- marshal: appendSint32PackedSliceValue,
- unmarshal: consumeSint32SliceValue,
- }
- // sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
- func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint32()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendUint32 wire encodes a uint32 pointer as a Uint32.
- func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeUint32 wire decodes a uint32 pointer as a Uint32.
- func consumeUint32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Uint32() = uint32(v)
- return n, nil
- }
- var coderUint32 = pointerCoderFuncs{
- size: sizeUint32,
- marshal: appendUint32,
- unmarshal: consumeUint32,
- }
- // sizeUint32NoZero returns the size of wire encoding a uint32 pointer as a Uint32.
- // The zero value is not encoded.
- func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint32()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendUint32NoZero wire encodes a uint32 pointer as a Uint32.
- // The zero value is not encoded.
- func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint32()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- var coderUint32NoZero = pointerCoderFuncs{
- size: sizeUint32NoZero,
- marshal: appendUint32NoZero,
- unmarshal: consumeUint32,
- }
- // sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
- // It panics if the pointer is nil.
- func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Uint32Ptr()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendUint32Ptr wire encodes a *uint32 pointer as a Uint32.
- // It panics if the pointer is nil.
- func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Uint32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeUint32Ptr wire decodes a *uint32 pointer as a Uint32.
- func consumeUint32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Uint32Ptr()
- if *vp == nil {
- *vp = new(uint32)
- }
- **vp = uint32(v)
- return n, nil
- }
- var coderUint32Ptr = pointerCoderFuncs{
- size: sizeUint32Ptr,
- marshal: appendUint32Ptr,
- unmarshal: consumeUint32Ptr,
- }
- // sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
- func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint32Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(uint64(v))
- }
- return size
- }
- // appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
- func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- // consumeUint32Slice wire decodes a []uint32 pointer as a repeated Uint32.
- func consumeUint32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Uint32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, uint32(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, uint32(v))
- return n, nil
- }
- var coderUint32Slice = pointerCoderFuncs{
- size: sizeUint32Slice,
- marshal: appendUint32Slice,
- unmarshal: consumeUint32Slice,
- }
- // sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
- func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
- func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- var coderUint32PackedSlice = pointerCoderFuncs{
- size: sizeUint32PackedSlice,
- marshal: appendUint32PackedSlice,
- unmarshal: consumeUint32Slice,
- }
- // sizeUint32Value returns the size of wire encoding a uint32 value as a Uint32.
- func sizeUint32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
- }
- // appendUint32Value encodes a uint32 value as a Uint32.
- func appendUint32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
- return b, nil
- }
- // consumeUint32Value decodes a uint32 value as a Uint32.
- func consumeUint32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfUint32(uint32(v)), n, nil
- }
- var coderUint32Value = valueCoderFuncs{
- size: sizeUint32Value,
- marshal: appendUint32Value,
- unmarshal: consumeUint32Value,
- }
- // sizeUint32SliceValue returns the size of wire encoding a []uint32 value as a repeated Uint32.
- func sizeUint32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(uint64(uint32(v.Uint())))
- }
- return size
- }
- // appendUint32SliceValue encodes a []uint32 value as a repeated Uint32.
- func appendUint32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
- }
- return b, nil
- }
- // consumeUint32SliceValue wire decodes a []uint32 value as a repeated Uint32.
- func consumeUint32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint32(uint32(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint32(uint32(v)))
- return listv, n, nil
- }
- var coderUint32SliceValue = valueCoderFuncs{
- size: sizeUint32SliceValue,
- marshal: appendUint32SliceValue,
- unmarshal: consumeUint32SliceValue,
- }
- // sizeUint32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Uint32.
- func sizeUint32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(uint32(v.Uint())))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendUint32PackedSliceValue encodes a []uint32 value as a packed repeated Uint32.
- func appendUint32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(uint32(v.Uint())))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, uint64(uint32(v.Uint())))
- }
- return b, nil
- }
- var coderUint32PackedSliceValue = valueCoderFuncs{
- size: sizeUint32PackedSliceValue,
- marshal: appendUint32PackedSliceValue,
- unmarshal: consumeUint32SliceValue,
- }
- // sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
- func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int64()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt64 wire encodes a int64 pointer as a Int64.
- func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeInt64 wire decodes a int64 pointer as a Int64.
- func consumeInt64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int64() = int64(v)
- return n, nil
- }
- var coderInt64 = pointerCoderFuncs{
- size: sizeInt64,
- marshal: appendInt64,
- unmarshal: consumeInt64,
- }
- // sizeInt64NoZero returns the size of wire encoding a int64 pointer as a Int64.
- // The zero value is not encoded.
- func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int64()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt64NoZero wire encodes a int64 pointer as a Int64.
- // The zero value is not encoded.
- func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- var coderInt64NoZero = pointerCoderFuncs{
- size: sizeInt64NoZero,
- marshal: appendInt64NoZero,
- unmarshal: consumeInt64,
- }
- // sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
- // It panics if the pointer is nil.
- func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Int64Ptr()
- return tagsize + wire.SizeVarint(uint64(v))
- }
- // appendInt64Ptr wire encodes a *int64 pointer as a Int64.
- // It panics if the pointer is nil.
- func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- return b, nil
- }
- // consumeInt64Ptr wire decodes a *int64 pointer as a Int64.
- func consumeInt64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int64Ptr()
- if *vp == nil {
- *vp = new(int64)
- }
- **vp = int64(v)
- return n, nil
- }
- var coderInt64Ptr = pointerCoderFuncs{
- size: sizeInt64Ptr,
- marshal: appendInt64Ptr,
- unmarshal: consumeInt64Ptr,
- }
- // sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
- func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(uint64(v))
- }
- return size
- }
- // appendInt64Slice encodes a []int64 pointer as a repeated Int64.
- func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- // consumeInt64Slice wire decodes a []int64 pointer as a repeated Int64.
- func consumeInt64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, int64(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, int64(v))
- return n, nil
- }
- var coderInt64Slice = pointerCoderFuncs{
- size: sizeInt64Slice,
- marshal: appendInt64Slice,
- unmarshal: consumeInt64Slice,
- }
- // sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
- func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
- func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(uint64(v))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, uint64(v))
- }
- return b, nil
- }
- var coderInt64PackedSlice = pointerCoderFuncs{
- size: sizeInt64PackedSlice,
- marshal: appendInt64PackedSlice,
- unmarshal: consumeInt64Slice,
- }
- // sizeInt64Value returns the size of wire encoding a int64 value as a Int64.
- func sizeInt64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(uint64(v.Int()))
- }
- // appendInt64Value encodes a int64 value as a Int64.
- func appendInt64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v.Int()))
- return b, nil
- }
- // consumeInt64Value decodes a int64 value as a Int64.
- func consumeInt64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt64(int64(v)), n, nil
- }
- var coderInt64Value = valueCoderFuncs{
- size: sizeInt64Value,
- marshal: appendInt64Value,
- unmarshal: consumeInt64Value,
- }
- // sizeInt64SliceValue returns the size of wire encoding a []int64 value as a repeated Int64.
- func sizeInt64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(uint64(v.Int()))
- }
- return size
- }
- // appendInt64SliceValue encodes a []int64 value as a repeated Int64.
- func appendInt64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, uint64(v.Int()))
- }
- return b, nil
- }
- // consumeInt64SliceValue wire decodes a []int64 value as a repeated Int64.
- func consumeInt64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(int64(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(int64(v)))
- return listv, n, nil
- }
- var coderInt64SliceValue = valueCoderFuncs{
- size: sizeInt64SliceValue,
- marshal: appendInt64SliceValue,
- unmarshal: consumeInt64SliceValue,
- }
- // sizeInt64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Int64.
- func sizeInt64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(v.Int()))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendInt64PackedSliceValue encodes a []int64 value as a packed repeated Int64.
- func appendInt64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(uint64(v.Int()))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, uint64(v.Int()))
- }
- return b, nil
- }
- var coderInt64PackedSliceValue = valueCoderFuncs{
- size: sizeInt64PackedSliceValue,
- marshal: appendInt64PackedSliceValue,
- unmarshal: consumeInt64SliceValue,
- }
- // sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
- func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int64()
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
- }
- // appendSint64 wire encodes a int64 pointer as a Sint64.
- func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v))
- return b, nil
- }
- // consumeSint64 wire decodes a int64 pointer as a Sint64.
- func consumeSint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int64() = wire.DecodeZigZag(v)
- return n, nil
- }
- var coderSint64 = pointerCoderFuncs{
- size: sizeSint64,
- marshal: appendSint64,
- unmarshal: consumeSint64,
- }
- // sizeSint64NoZero returns the size of wire encoding a int64 pointer as a Sint64.
- // The zero value is not encoded.
- func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int64()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
- }
- // appendSint64NoZero wire encodes a int64 pointer as a Sint64.
- // The zero value is not encoded.
- func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v))
- return b, nil
- }
- var coderSint64NoZero = pointerCoderFuncs{
- size: sizeSint64NoZero,
- marshal: appendSint64NoZero,
- unmarshal: consumeSint64,
- }
- // sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
- // It panics if the pointer is nil.
- func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Int64Ptr()
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
- }
- // appendSint64Ptr wire encodes a *int64 pointer as a Sint64.
- // It panics if the pointer is nil.
- func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v))
- return b, nil
- }
- // consumeSint64Ptr wire decodes a *int64 pointer as a Sint64.
- func consumeSint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int64Ptr()
- if *vp == nil {
- *vp = new(int64)
- }
- **vp = wire.DecodeZigZag(v)
- return n, nil
- }
- var coderSint64Ptr = pointerCoderFuncs{
- size: sizeSint64Ptr,
- marshal: appendSint64Ptr,
- unmarshal: consumeSint64Ptr,
- }
- // sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
- func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
- }
- return size
- }
- // appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
- func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v))
- }
- return b, nil
- }
- // consumeSint64Slice wire decodes a []int64 pointer as a repeated Sint64.
- func consumeSint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, wire.DecodeZigZag(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, wire.DecodeZigZag(v))
- return n, nil
- }
- var coderSint64Slice = pointerCoderFuncs{
- size: sizeSint64Slice,
- marshal: appendSint64Slice,
- unmarshal: consumeSint64Slice,
- }
- // sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
- func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeZigZag(v))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
- func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(wire.EncodeZigZag(v))
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, wire.EncodeZigZag(v))
- }
- return b, nil
- }
- var coderSint64PackedSlice = pointerCoderFuncs{
- size: sizeSint64PackedSlice,
- marshal: appendSint64PackedSlice,
- unmarshal: consumeSint64Slice,
- }
- // sizeSint64Value returns the size of wire encoding a int64 value as a Sint64.
- func sizeSint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
- }
- // appendSint64Value encodes a int64 value as a Sint64.
- func appendSint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
- return b, nil
- }
- // consumeSint64Value decodes a int64 value as a Sint64.
- func consumeSint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt64(wire.DecodeZigZag(v)), n, nil
- }
- var coderSint64Value = valueCoderFuncs{
- size: sizeSint64Value,
- marshal: appendSint64Value,
- unmarshal: consumeSint64Value,
- }
- // sizeSint64SliceValue returns the size of wire encoding a []int64 value as a repeated Sint64.
- func sizeSint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v.Int()))
- }
- return size
- }
- // appendSint64SliceValue encodes a []int64 value as a repeated Sint64.
- func appendSint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
- }
- return b, nil
- }
- // consumeSint64SliceValue wire decodes a []int64 value as a repeated Sint64.
- func consumeSint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(wire.DecodeZigZag(v)))
- return listv, n, nil
- }
- var coderSint64SliceValue = valueCoderFuncs{
- size: sizeSint64SliceValue,
- marshal: appendSint64SliceValue,
- unmarshal: consumeSint64SliceValue,
- }
- // sizeSint64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sint64.
- func sizeSint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendSint64PackedSliceValue encodes a []int64 value as a packed repeated Sint64.
- func appendSint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(wire.EncodeZigZag(v.Int()))
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wire.EncodeZigZag(v.Int()))
- }
- return b, nil
- }
- var coderSint64PackedSliceValue = valueCoderFuncs{
- size: sizeSint64PackedSliceValue,
- marshal: appendSint64PackedSliceValue,
- unmarshal: consumeSint64SliceValue,
- }
- // sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
- func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint64()
- return tagsize + wire.SizeVarint(v)
- }
- // appendUint64 wire encodes a uint64 pointer as a Uint64.
- func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v)
- return b, nil
- }
- // consumeUint64 wire decodes a uint64 pointer as a Uint64.
- func consumeUint64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Uint64() = v
- return n, nil
- }
- var coderUint64 = pointerCoderFuncs{
- size: sizeUint64,
- marshal: appendUint64,
- unmarshal: consumeUint64,
- }
- // sizeUint64NoZero returns the size of wire encoding a uint64 pointer as a Uint64.
- // The zero value is not encoded.
- func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint64()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeVarint(v)
- }
- // appendUint64NoZero wire encodes a uint64 pointer as a Uint64.
- // The zero value is not encoded.
- func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint64()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v)
- return b, nil
- }
- var coderUint64NoZero = pointerCoderFuncs{
- size: sizeUint64NoZero,
- marshal: appendUint64NoZero,
- unmarshal: consumeUint64,
- }
- // sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
- // It panics if the pointer is nil.
- func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.Uint64Ptr()
- return tagsize + wire.SizeVarint(v)
- }
- // appendUint64Ptr wire encodes a *uint64 pointer as a Uint64.
- // It panics if the pointer is nil.
- func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Uint64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v)
- return b, nil
- }
- // consumeUint64Ptr wire decodes a *uint64 pointer as a Uint64.
- func consumeUint64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Uint64Ptr()
- if *vp == nil {
- *vp = new(uint64)
- }
- **vp = v
- return n, nil
- }
- var coderUint64Ptr = pointerCoderFuncs{
- size: sizeUint64Ptr,
- marshal: appendUint64Ptr,
- unmarshal: consumeUint64Ptr,
- }
- // sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
- func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint64Slice()
- for _, v := range s {
- size += tagsize + wire.SizeVarint(v)
- }
- return size
- }
- // appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
- func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v)
- }
- return b, nil
- }
- // consumeUint64Slice wire decodes a []uint64 pointer as a repeated Uint64.
- func consumeUint64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Uint64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, v)
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.VarintType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, v)
- return n, nil
- }
- var coderUint64Slice = pointerCoderFuncs{
- size: sizeUint64Slice,
- marshal: appendUint64Slice,
- unmarshal: consumeUint64Slice,
- }
- // sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
- func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(v)
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
- func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for _, v := range s {
- n += wire.SizeVarint(v)
- }
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendVarint(b, v)
- }
- return b, nil
- }
- var coderUint64PackedSlice = pointerCoderFuncs{
- size: sizeUint64PackedSlice,
- marshal: appendUint64PackedSlice,
- unmarshal: consumeUint64Slice,
- }
- // sizeUint64Value returns the size of wire encoding a uint64 value as a Uint64.
- func sizeUint64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeVarint(v.Uint())
- }
- // appendUint64Value encodes a uint64 value as a Uint64.
- func appendUint64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v.Uint())
- return b, nil
- }
- // consumeUint64Value decodes a uint64 value as a Uint64.
- func consumeUint64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfUint64(v), n, nil
- }
- var coderUint64Value = valueCoderFuncs{
- size: sizeUint64Value,
- marshal: appendUint64Value,
- unmarshal: consumeUint64Value,
- }
- // sizeUint64SliceValue returns the size of wire encoding a []uint64 value as a repeated Uint64.
- func sizeUint64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeVarint(v.Uint())
- }
- return size
- }
- // appendUint64SliceValue encodes a []uint64 value as a repeated Uint64.
- func appendUint64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendVarint(b, v.Uint())
- }
- return b, nil
- }
- // consumeUint64SliceValue wire decodes a []uint64 value as a repeated Uint64.
- func consumeUint64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint64(v))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.VarintType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeVarint(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint64(v))
- return listv, n, nil
- }
- var coderUint64SliceValue = valueCoderFuncs{
- size: sizeUint64SliceValue,
- marshal: appendUint64SliceValue,
- unmarshal: consumeUint64SliceValue,
- }
- // sizeUint64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Uint64.
- func sizeUint64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := 0
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(v.Uint())
- }
- return tagsize + wire.SizeBytes(n)
- }
- // appendUint64PackedSliceValue encodes a []uint64 value as a packed repeated Uint64.
- func appendUint64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := 0
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- n += wire.SizeVarint(v.Uint())
- }
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, v.Uint())
- }
- return b, nil
- }
- var coderUint64PackedSliceValue = valueCoderFuncs{
- size: sizeUint64PackedSliceValue,
- marshal: appendUint64PackedSliceValue,
- unmarshal: consumeUint64SliceValue,
- }
- // sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
- func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
- func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v))
- return b, nil
- }
- // consumeSfixed32 wire decodes a int32 pointer as a Sfixed32.
- func consumeSfixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int32() = int32(v)
- return n, nil
- }
- var coderSfixed32 = pointerCoderFuncs{
- size: sizeSfixed32,
- marshal: appendSfixed32,
- unmarshal: consumeSfixed32,
- }
- // sizeSfixed32NoZero returns the size of wire encoding a int32 pointer as a Sfixed32.
- // The zero value is not encoded.
- func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int32()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeFixed32()
- }
- // appendSfixed32NoZero wire encodes a int32 pointer as a Sfixed32.
- // The zero value is not encoded.
- func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int32()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v))
- return b, nil
- }
- var coderSfixed32NoZero = pointerCoderFuncs{
- size: sizeSfixed32NoZero,
- marshal: appendSfixed32NoZero,
- unmarshal: consumeSfixed32,
- }
- // sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
- // It panics if the pointer is nil.
- func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendSfixed32Ptr wire encodes a *int32 pointer as a Sfixed32.
- // It panics if the pointer is nil.
- func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v))
- return b, nil
- }
- // consumeSfixed32Ptr wire decodes a *int32 pointer as a Sfixed32.
- func consumeSfixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int32Ptr()
- if *vp == nil {
- *vp = new(int32)
- }
- **vp = int32(v)
- return n, nil
- }
- var coderSfixed32Ptr = pointerCoderFuncs{
- size: sizeSfixed32Ptr,
- marshal: appendSfixed32Ptr,
- unmarshal: consumeSfixed32Ptr,
- }
- // sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
- func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- size = len(s) * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
- func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v))
- }
- return b, nil
- }
- // consumeSfixed32Slice wire decodes a []int32 pointer as a repeated Sfixed32.
- func consumeSfixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, int32(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, int32(v))
- return n, nil
- }
- var coderSfixed32Slice = pointerCoderFuncs{
- size: sizeSfixed32Slice,
- marshal: appendSfixed32Slice,
- unmarshal: consumeSfixed32Slice,
- }
- // sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
- func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
- func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed32(b, uint32(v))
- }
- return b, nil
- }
- var coderSfixed32PackedSlice = pointerCoderFuncs{
- size: sizeSfixed32PackedSlice,
- marshal: appendSfixed32PackedSlice,
- unmarshal: consumeSfixed32Slice,
- }
- // sizeSfixed32Value returns the size of wire encoding a int32 value as a Sfixed32.
- func sizeSfixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed32()
- }
- // appendSfixed32Value encodes a int32 value as a Sfixed32.
- func appendSfixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v.Int()))
- return b, nil
- }
- // consumeSfixed32Value decodes a int32 value as a Sfixed32.
- func consumeSfixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt32(int32(v)), n, nil
- }
- var coderSfixed32Value = valueCoderFuncs{
- size: sizeSfixed32Value,
- marshal: appendSfixed32Value,
- unmarshal: consumeSfixed32Value,
- }
- // sizeSfixed32SliceValue returns the size of wire encoding a []int32 value as a repeated Sfixed32.
- func sizeSfixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendSfixed32SliceValue encodes a []int32 value as a repeated Sfixed32.
- func appendSfixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v.Int()))
- }
- return b, nil
- }
- // consumeSfixed32SliceValue wire decodes a []int32 value as a repeated Sfixed32.
- func consumeSfixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt32(int32(v)))
- return listv, n, nil
- }
- var coderSfixed32SliceValue = valueCoderFuncs{
- size: sizeSfixed32SliceValue,
- marshal: appendSfixed32SliceValue,
- unmarshal: consumeSfixed32SliceValue,
- }
- // sizeSfixed32PackedSliceValue returns the size of wire encoding a []int32 value as a packed repeated Sfixed32.
- func sizeSfixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendSfixed32PackedSliceValue encodes a []int32 value as a packed repeated Sfixed32.
- func appendSfixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed32(b, uint32(v.Int()))
- }
- return b, nil
- }
- var coderSfixed32PackedSliceValue = valueCoderFuncs{
- size: sizeSfixed32PackedSliceValue,
- marshal: appendSfixed32PackedSliceValue,
- unmarshal: consumeSfixed32SliceValue,
- }
- // sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
- func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendFixed32 wire encodes a uint32 pointer as a Fixed32.
- func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, v)
- return b, nil
- }
- // consumeFixed32 wire decodes a uint32 pointer as a Fixed32.
- func consumeFixed32(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Uint32() = v
- return n, nil
- }
- var coderFixed32 = pointerCoderFuncs{
- size: sizeFixed32,
- marshal: appendFixed32,
- unmarshal: consumeFixed32,
- }
- // sizeFixed32NoZero returns the size of wire encoding a uint32 pointer as a Fixed32.
- // The zero value is not encoded.
- func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint32()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeFixed32()
- }
- // appendFixed32NoZero wire encodes a uint32 pointer as a Fixed32.
- // The zero value is not encoded.
- func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint32()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, v)
- return b, nil
- }
- var coderFixed32NoZero = pointerCoderFuncs{
- size: sizeFixed32NoZero,
- marshal: appendFixed32NoZero,
- unmarshal: consumeFixed32,
- }
- // sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
- // It panics if the pointer is nil.
- func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendFixed32Ptr wire encodes a *uint32 pointer as a Fixed32.
- // It panics if the pointer is nil.
- func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Uint32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, v)
- return b, nil
- }
- // consumeFixed32Ptr wire decodes a *uint32 pointer as a Fixed32.
- func consumeFixed32Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Uint32Ptr()
- if *vp == nil {
- *vp = new(uint32)
- }
- **vp = v
- return n, nil
- }
- var coderFixed32Ptr = pointerCoderFuncs{
- size: sizeFixed32Ptr,
- marshal: appendFixed32Ptr,
- unmarshal: consumeFixed32Ptr,
- }
- // sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
- func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint32Slice()
- size = len(s) * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
- func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, v)
- }
- return b, nil
- }
- // consumeFixed32Slice wire decodes a []uint32 pointer as a repeated Fixed32.
- func consumeFixed32Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Uint32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, v)
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, v)
- return n, nil
- }
- var coderFixed32Slice = pointerCoderFuncs{
- size: sizeFixed32Slice,
- marshal: appendFixed32Slice,
- unmarshal: consumeFixed32Slice,
- }
- // sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
- func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint32Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
- func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed32(b, v)
- }
- return b, nil
- }
- var coderFixed32PackedSlice = pointerCoderFuncs{
- size: sizeFixed32PackedSlice,
- marshal: appendFixed32PackedSlice,
- unmarshal: consumeFixed32Slice,
- }
- // sizeFixed32Value returns the size of wire encoding a uint32 value as a Fixed32.
- func sizeFixed32Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed32()
- }
- // appendFixed32Value encodes a uint32 value as a Fixed32.
- func appendFixed32Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v.Uint()))
- return b, nil
- }
- // consumeFixed32Value decodes a uint32 value as a Fixed32.
- func consumeFixed32Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfUint32(uint32(v)), n, nil
- }
- var coderFixed32Value = valueCoderFuncs{
- size: sizeFixed32Value,
- marshal: appendFixed32Value,
- unmarshal: consumeFixed32Value,
- }
- // sizeFixed32SliceValue returns the size of wire encoding a []uint32 value as a repeated Fixed32.
- func sizeFixed32SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendFixed32SliceValue encodes a []uint32 value as a repeated Fixed32.
- func appendFixed32SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, uint32(v.Uint()))
- }
- return b, nil
- }
- // consumeFixed32SliceValue wire decodes a []uint32 value as a repeated Fixed32.
- func consumeFixed32SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint32(uint32(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint32(uint32(v)))
- return listv, n, nil
- }
- var coderFixed32SliceValue = valueCoderFuncs{
- size: sizeFixed32SliceValue,
- marshal: appendFixed32SliceValue,
- unmarshal: consumeFixed32SliceValue,
- }
- // sizeFixed32PackedSliceValue returns the size of wire encoding a []uint32 value as a packed repeated Fixed32.
- func sizeFixed32PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFixed32PackedSliceValue encodes a []uint32 value as a packed repeated Fixed32.
- func appendFixed32PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed32(b, uint32(v.Uint()))
- }
- return b, nil
- }
- var coderFixed32PackedSliceValue = valueCoderFuncs{
- size: sizeFixed32PackedSliceValue,
- marshal: appendFixed32PackedSliceValue,
- unmarshal: consumeFixed32SliceValue,
- }
- // sizeFloat returns the size of wire encoding a float32 pointer as a Float.
- func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendFloat wire encodes a float32 pointer as a Float.
- func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Float32()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(v))
- return b, nil
- }
- // consumeFloat wire decodes a float32 pointer as a Float.
- func consumeFloat(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Float32() = math.Float32frombits(v)
- return n, nil
- }
- var coderFloat = pointerCoderFuncs{
- size: sizeFloat,
- marshal: appendFloat,
- unmarshal: consumeFloat,
- }
- // sizeFloatNoZero returns the size of wire encoding a float32 pointer as a Float.
- // The zero value is not encoded.
- func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Float32()
- if v == 0 && !math.Signbit(float64(v)) {
- return 0
- }
- return tagsize + wire.SizeFixed32()
- }
- // appendFloatNoZero wire encodes a float32 pointer as a Float.
- // The zero value is not encoded.
- func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Float32()
- if v == 0 && !math.Signbit(float64(v)) {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(v))
- return b, nil
- }
- var coderFloatNoZero = pointerCoderFuncs{
- size: sizeFloatNoZero,
- marshal: appendFloatNoZero,
- unmarshal: consumeFloat,
- }
- // sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
- // It panics if the pointer is nil.
- func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed32()
- }
- // appendFloatPtr wire encodes a *float32 pointer as a Float.
- // It panics if the pointer is nil.
- func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Float32Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(v))
- return b, nil
- }
- // consumeFloatPtr wire decodes a *float32 pointer as a Float.
- func consumeFloatPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Float32Ptr()
- if *vp == nil {
- *vp = new(float32)
- }
- **vp = math.Float32frombits(v)
- return n, nil
- }
- var coderFloatPtr = pointerCoderFuncs{
- size: sizeFloatPtr,
- marshal: appendFloatPtr,
- unmarshal: consumeFloatPtr,
- }
- // sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
- func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Float32Slice()
- size = len(s) * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendFloatSlice encodes a []float32 pointer as a repeated Float.
- func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Float32Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(v))
- }
- return b, nil
- }
- // consumeFloatSlice wire decodes a []float32 pointer as a repeated Float.
- func consumeFloatSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Float32Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, math.Float32frombits(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed32Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, math.Float32frombits(v))
- return n, nil
- }
- var coderFloatSlice = pointerCoderFuncs{
- size: sizeFloatSlice,
- marshal: appendFloatSlice,
- unmarshal: consumeFloatSlice,
- }
- // sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
- func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Float32Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
- func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Float32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed32(b, math.Float32bits(v))
- }
- return b, nil
- }
- var coderFloatPackedSlice = pointerCoderFuncs{
- size: sizeFloatPackedSlice,
- marshal: appendFloatPackedSlice,
- unmarshal: consumeFloatSlice,
- }
- // sizeFloatValue returns the size of wire encoding a float32 value as a Float.
- func sizeFloatValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed32()
- }
- // appendFloatValue encodes a float32 value as a Float.
- func appendFloatValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
- return b, nil
- }
- // consumeFloatValue decodes a float32 value as a Float.
- func consumeFloatValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
- }
- var coderFloatValue = valueCoderFuncs{
- size: sizeFloatValue,
- marshal: appendFloatValue,
- unmarshal: consumeFloatValue,
- }
- // sizeFloatSliceValue returns the size of wire encoding a []float32 value as a repeated Float.
- func sizeFloatSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed32())
- return size
- }
- // appendFloatSliceValue encodes a []float32 value as a repeated Float.
- func appendFloatSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
- }
- return b, nil
- }
- // consumeFloatSliceValue wire decodes a []float32 value as a repeated Float.
- func consumeFloatSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed32Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed32(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
- return listv, n, nil
- }
- var coderFloatSliceValue = valueCoderFuncs{
- size: sizeFloatSliceValue,
- marshal: appendFloatSliceValue,
- unmarshal: consumeFloatSliceValue,
- }
- // sizeFloatPackedSliceValue returns the size of wire encoding a []float32 value as a packed repeated Float.
- func sizeFloatPackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed32()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFloatPackedSliceValue encodes a []float32 value as a packed repeated Float.
- func appendFloatPackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed32()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed32(b, math.Float32bits(float32(v.Float())))
- }
- return b, nil
- }
- var coderFloatPackedSliceValue = valueCoderFuncs{
- size: sizeFloatPackedSliceValue,
- marshal: appendFloatPackedSliceValue,
- unmarshal: consumeFloatSliceValue,
- }
- // sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
- func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
- func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v))
- return b, nil
- }
- // consumeSfixed64 wire decodes a int64 pointer as a Sfixed64.
- func consumeSfixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Int64() = int64(v)
- return n, nil
- }
- var coderSfixed64 = pointerCoderFuncs{
- size: sizeSfixed64,
- marshal: appendSfixed64,
- unmarshal: consumeSfixed64,
- }
- // sizeSfixed64NoZero returns the size of wire encoding a int64 pointer as a Sfixed64.
- // The zero value is not encoded.
- func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Int64()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeFixed64()
- }
- // appendSfixed64NoZero wire encodes a int64 pointer as a Sfixed64.
- // The zero value is not encoded.
- func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Int64()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v))
- return b, nil
- }
- var coderSfixed64NoZero = pointerCoderFuncs{
- size: sizeSfixed64NoZero,
- marshal: appendSfixed64NoZero,
- unmarshal: consumeSfixed64,
- }
- // sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
- // It panics if the pointer is nil.
- func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendSfixed64Ptr wire encodes a *int64 pointer as a Sfixed64.
- // It panics if the pointer is nil.
- func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Int64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v))
- return b, nil
- }
- // consumeSfixed64Ptr wire decodes a *int64 pointer as a Sfixed64.
- func consumeSfixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Int64Ptr()
- if *vp == nil {
- *vp = new(int64)
- }
- **vp = int64(v)
- return n, nil
- }
- var coderSfixed64Ptr = pointerCoderFuncs{
- size: sizeSfixed64Ptr,
- marshal: appendSfixed64Ptr,
- unmarshal: consumeSfixed64Ptr,
- }
- // sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
- func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- size = len(s) * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
- func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v))
- }
- return b, nil
- }
- // consumeSfixed64Slice wire decodes a []int64 pointer as a repeated Sfixed64.
- func consumeSfixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Int64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, int64(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, int64(v))
- return n, nil
- }
- var coderSfixed64Slice = pointerCoderFuncs{
- size: sizeSfixed64Slice,
- marshal: appendSfixed64Slice,
- unmarshal: consumeSfixed64Slice,
- }
- // sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
- func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
- func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Int64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed64(b, uint64(v))
- }
- return b, nil
- }
- var coderSfixed64PackedSlice = pointerCoderFuncs{
- size: sizeSfixed64PackedSlice,
- marshal: appendSfixed64PackedSlice,
- unmarshal: consumeSfixed64Slice,
- }
- // sizeSfixed64Value returns the size of wire encoding a int64 value as a Sfixed64.
- func sizeSfixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed64()
- }
- // appendSfixed64Value encodes a int64 value as a Sfixed64.
- func appendSfixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v.Int()))
- return b, nil
- }
- // consumeSfixed64Value decodes a int64 value as a Sfixed64.
- func consumeSfixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfInt64(int64(v)), n, nil
- }
- var coderSfixed64Value = valueCoderFuncs{
- size: sizeSfixed64Value,
- marshal: appendSfixed64Value,
- unmarshal: consumeSfixed64Value,
- }
- // sizeSfixed64SliceValue returns the size of wire encoding a []int64 value as a repeated Sfixed64.
- func sizeSfixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendSfixed64SliceValue encodes a []int64 value as a repeated Sfixed64.
- func appendSfixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, uint64(v.Int()))
- }
- return b, nil
- }
- // consumeSfixed64SliceValue wire decodes a []int64 value as a repeated Sfixed64.
- func consumeSfixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(int64(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfInt64(int64(v)))
- return listv, n, nil
- }
- var coderSfixed64SliceValue = valueCoderFuncs{
- size: sizeSfixed64SliceValue,
- marshal: appendSfixed64SliceValue,
- unmarshal: consumeSfixed64SliceValue,
- }
- // sizeSfixed64PackedSliceValue returns the size of wire encoding a []int64 value as a packed repeated Sfixed64.
- func sizeSfixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendSfixed64PackedSliceValue encodes a []int64 value as a packed repeated Sfixed64.
- func appendSfixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed64(b, uint64(v.Int()))
- }
- return b, nil
- }
- var coderSfixed64PackedSliceValue = valueCoderFuncs{
- size: sizeSfixed64PackedSliceValue,
- marshal: appendSfixed64PackedSliceValue,
- unmarshal: consumeSfixed64SliceValue,
- }
- // sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
- func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendFixed64 wire encodes a uint64 pointer as a Fixed64.
- func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v)
- return b, nil
- }
- // consumeFixed64 wire decodes a uint64 pointer as a Fixed64.
- func consumeFixed64(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Uint64() = v
- return n, nil
- }
- var coderFixed64 = pointerCoderFuncs{
- size: sizeFixed64,
- marshal: appendFixed64,
- unmarshal: consumeFixed64,
- }
- // sizeFixed64NoZero returns the size of wire encoding a uint64 pointer as a Fixed64.
- // The zero value is not encoded.
- func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Uint64()
- if v == 0 {
- return 0
- }
- return tagsize + wire.SizeFixed64()
- }
- // appendFixed64NoZero wire encodes a uint64 pointer as a Fixed64.
- // The zero value is not encoded.
- func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Uint64()
- if v == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v)
- return b, nil
- }
- var coderFixed64NoZero = pointerCoderFuncs{
- size: sizeFixed64NoZero,
- marshal: appendFixed64NoZero,
- unmarshal: consumeFixed64,
- }
- // sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
- // It panics if the pointer is nil.
- func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendFixed64Ptr wire encodes a *uint64 pointer as a Fixed64.
- // It panics if the pointer is nil.
- func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Uint64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v)
- return b, nil
- }
- // consumeFixed64Ptr wire decodes a *uint64 pointer as a Fixed64.
- func consumeFixed64Ptr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Uint64Ptr()
- if *vp == nil {
- *vp = new(uint64)
- }
- **vp = v
- return n, nil
- }
- var coderFixed64Ptr = pointerCoderFuncs{
- size: sizeFixed64Ptr,
- marshal: appendFixed64Ptr,
- unmarshal: consumeFixed64Ptr,
- }
- // sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
- func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint64Slice()
- size = len(s) * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
- func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v)
- }
- return b, nil
- }
- // consumeFixed64Slice wire decodes a []uint64 pointer as a repeated Fixed64.
- func consumeFixed64Slice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Uint64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, v)
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, v)
- return n, nil
- }
- var coderFixed64Slice = pointerCoderFuncs{
- size: sizeFixed64Slice,
- marshal: appendFixed64Slice,
- unmarshal: consumeFixed64Slice,
- }
- // sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
- func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Uint64Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
- func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Uint64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed64(b, v)
- }
- return b, nil
- }
- var coderFixed64PackedSlice = pointerCoderFuncs{
- size: sizeFixed64PackedSlice,
- marshal: appendFixed64PackedSlice,
- unmarshal: consumeFixed64Slice,
- }
- // sizeFixed64Value returns the size of wire encoding a uint64 value as a Fixed64.
- func sizeFixed64Value(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed64()
- }
- // appendFixed64Value encodes a uint64 value as a Fixed64.
- func appendFixed64Value(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v.Uint())
- return b, nil
- }
- // consumeFixed64Value decodes a uint64 value as a Fixed64.
- func consumeFixed64Value(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfUint64(v), n, nil
- }
- var coderFixed64Value = valueCoderFuncs{
- size: sizeFixed64Value,
- marshal: appendFixed64Value,
- unmarshal: consumeFixed64Value,
- }
- // sizeFixed64SliceValue returns the size of wire encoding a []uint64 value as a repeated Fixed64.
- func sizeFixed64SliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendFixed64SliceValue encodes a []uint64 value as a repeated Fixed64.
- func appendFixed64SliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, v.Uint())
- }
- return b, nil
- }
- // consumeFixed64SliceValue wire decodes a []uint64 value as a repeated Fixed64.
- func consumeFixed64SliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint64(v))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfUint64(v))
- return listv, n, nil
- }
- var coderFixed64SliceValue = valueCoderFuncs{
- size: sizeFixed64SliceValue,
- marshal: appendFixed64SliceValue,
- unmarshal: consumeFixed64SliceValue,
- }
- // sizeFixed64PackedSliceValue returns the size of wire encoding a []uint64 value as a packed repeated Fixed64.
- func sizeFixed64PackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendFixed64PackedSliceValue encodes a []uint64 value as a packed repeated Fixed64.
- func appendFixed64PackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed64(b, v.Uint())
- }
- return b, nil
- }
- var coderFixed64PackedSliceValue = valueCoderFuncs{
- size: sizeFixed64PackedSliceValue,
- marshal: appendFixed64PackedSliceValue,
- unmarshal: consumeFixed64SliceValue,
- }
- // sizeDouble returns the size of wire encoding a float64 pointer as a Double.
- func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendDouble wire encodes a float64 pointer as a Double.
- func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Float64()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v))
- return b, nil
- }
- // consumeDouble wire decodes a float64 pointer as a Double.
- func consumeDouble(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Float64() = math.Float64frombits(v)
- return n, nil
- }
- var coderDouble = pointerCoderFuncs{
- size: sizeDouble,
- marshal: appendDouble,
- unmarshal: consumeDouble,
- }
- // sizeDoubleNoZero returns the size of wire encoding a float64 pointer as a Double.
- // The zero value is not encoded.
- func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Float64()
- if v == 0 && !math.Signbit(float64(v)) {
- return 0
- }
- return tagsize + wire.SizeFixed64()
- }
- // appendDoubleNoZero wire encodes a float64 pointer as a Double.
- // The zero value is not encoded.
- func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Float64()
- if v == 0 && !math.Signbit(float64(v)) {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v))
- return b, nil
- }
- var coderDoubleNoZero = pointerCoderFuncs{
- size: sizeDoubleNoZero,
- marshal: appendDoubleNoZero,
- unmarshal: consumeDouble,
- }
- // sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
- // It panics if the pointer is nil.
- func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
- return tagsize + wire.SizeFixed64()
- }
- // appendDoublePtr wire encodes a *float64 pointer as a Double.
- // It panics if the pointer is nil.
- func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.Float64Ptr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v))
- return b, nil
- }
- // consumeDoublePtr wire decodes a *float64 pointer as a Double.
- func consumeDoublePtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.Float64Ptr()
- if *vp == nil {
- *vp = new(float64)
- }
- **vp = math.Float64frombits(v)
- return n, nil
- }
- var coderDoublePtr = pointerCoderFuncs{
- size: sizeDoublePtr,
- marshal: appendDoublePtr,
- unmarshal: consumeDoublePtr,
- }
- // sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
- func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Float64Slice()
- size = len(s) * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendDoubleSlice encodes a []float64 pointer as a repeated Double.
- func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Float64Slice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v))
- }
- return b, nil
- }
- // consumeDoubleSlice wire decodes a []float64 pointer as a repeated Double.
- func consumeDoubleSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.Float64Slice()
- if wtyp == wire.BytesType {
- s := *sp
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- s = append(s, math.Float64frombits(v))
- b = b[n:]
- }
- *sp = s
- return n, nil
- }
- if wtyp != wire.Fixed64Type {
- return 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, math.Float64frombits(v))
- return n, nil
- }
- var coderDoubleSlice = pointerCoderFuncs{
- size: sizeDoubleSlice,
- marshal: appendDoubleSlice,
- unmarshal: consumeDoubleSlice,
- }
- // sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
- func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.Float64Slice()
- if len(s) == 0 {
- return 0
- }
- n := len(s) * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
- func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.Float64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := len(s) * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for _, v := range s {
- b = wire.AppendFixed64(b, math.Float64bits(v))
- }
- return b, nil
- }
- var coderDoublePackedSlice = pointerCoderFuncs{
- size: sizeDoublePackedSlice,
- marshal: appendDoublePackedSlice,
- unmarshal: consumeDoubleSlice,
- }
- // sizeDoubleValue returns the size of wire encoding a float64 value as a Double.
- func sizeDoubleValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeFixed64()
- }
- // appendDoubleValue encodes a float64 value as a Double.
- func appendDoubleValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
- return b, nil
- }
- // consumeDoubleValue decodes a float64 value as a Double.
- func consumeDoubleValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
- }
- var coderDoubleValue = valueCoderFuncs{
- size: sizeDoubleValue,
- marshal: appendDoubleValue,
- unmarshal: consumeDoubleValue,
- }
- // sizeDoubleSliceValue returns the size of wire encoding a []float64 value as a repeated Double.
- func sizeDoubleSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- size = list.Len() * (tagsize + wire.SizeFixed64())
- return size
- }
- // appendDoubleSliceValue encodes a []float64 value as a repeated Double.
- func appendDoubleSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
- }
- return b, nil
- }
- // consumeDoubleSliceValue wire decodes a []float64 value as a repeated Double.
- func consumeDoubleSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp == wire.BytesType {
- b, n = wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- for len(b) > 0 {
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
- b = b[n:]
- }
- return listv, n, nil
- }
- if wtyp != wire.Fixed64Type {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeFixed64(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
- return listv, n, nil
- }
- var coderDoubleSliceValue = valueCoderFuncs{
- size: sizeDoubleSliceValue,
- marshal: appendDoubleSliceValue,
- unmarshal: consumeDoubleSliceValue,
- }
- // sizeDoublePackedSliceValue returns the size of wire encoding a []float64 value as a packed repeated Double.
- func sizeDoublePackedSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- n := list.Len() * wire.SizeFixed64()
- return tagsize + wire.SizeBytes(n)
- }
- // appendDoublePackedSliceValue encodes a []float64 value as a packed repeated Double.
- func appendDoublePackedSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- llen := list.Len()
- if llen == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- n := llen * wire.SizeFixed64()
- b = wire.AppendVarint(b, uint64(n))
- for i := 0; i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendFixed64(b, math.Float64bits(v.Float()))
- }
- return b, nil
- }
- var coderDoublePackedSliceValue = valueCoderFuncs{
- size: sizeDoublePackedSliceValue,
- marshal: appendDoublePackedSliceValue,
- unmarshal: consumeDoubleSliceValue,
- }
- // sizeString returns the size of wire encoding a string pointer as a String.
- func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.String()
- return tagsize + wire.SizeBytes(len(v))
- }
- // appendString wire encodes a string pointer as a String.
- func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.String()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- return b, nil
- }
- // consumeString wire decodes a string pointer as a String.
- func consumeString(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.String() = v
- return n, nil
- }
- var coderString = pointerCoderFuncs{
- size: sizeString,
- marshal: appendString,
- unmarshal: consumeString,
- }
- // appendStringValidateUTF8 wire encodes a string pointer as a String.
- func appendStringValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.String()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- if !utf8.ValidString(v) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- // consumeStringValidateUTF8 wire decodes a string pointer as a String.
- func consumeStringValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- if !utf8.ValidString(v) {
- return 0, errInvalidUTF8{}
- }
- *p.String() = v
- return n, nil
- }
- var coderStringValidateUTF8 = pointerCoderFuncs{
- size: sizeString,
- marshal: appendStringValidateUTF8,
- unmarshal: consumeStringValidateUTF8,
- }
- // sizeStringNoZero returns the size of wire encoding a string pointer as a String.
- // The zero value is not encoded.
- func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.String()
- if len(v) == 0 {
- return 0
- }
- return tagsize + wire.SizeBytes(len(v))
- }
- // appendStringNoZero wire encodes a string pointer as a String.
- // The zero value is not encoded.
- func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.String()
- if len(v) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- return b, nil
- }
- var coderStringNoZero = pointerCoderFuncs{
- size: sizeStringNoZero,
- marshal: appendStringNoZero,
- unmarshal: consumeString,
- }
- // appendStringNoZeroValidateUTF8 wire encodes a string pointer as a String.
- // The zero value is not encoded.
- func appendStringNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.String()
- if len(v) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- if !utf8.ValidString(v) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- var coderStringNoZeroValidateUTF8 = pointerCoderFuncs{
- size: sizeStringNoZero,
- marshal: appendStringNoZeroValidateUTF8,
- unmarshal: consumeStringValidateUTF8,
- }
- // sizeStringPtr returns the size of wire encoding a *string pointer as a String.
- // It panics if the pointer is nil.
- func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := **p.StringPtr()
- return tagsize + wire.SizeBytes(len(v))
- }
- // appendStringPtr wire encodes a *string pointer as a String.
- // It panics if the pointer is nil.
- func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := **p.StringPtr()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- return b, nil
- }
- // consumeStringPtr wire decodes a *string pointer as a String.
- func consumeStringPtr(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- vp := p.StringPtr()
- if *vp == nil {
- *vp = new(string)
- }
- **vp = v
- return n, nil
- }
- var coderStringPtr = pointerCoderFuncs{
- size: sizeStringPtr,
- marshal: appendStringPtr,
- unmarshal: consumeStringPtr,
- }
- // sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
- func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.StringSlice()
- for _, v := range s {
- size += tagsize + wire.SizeBytes(len(v))
- }
- return size
- }
- // appendStringSlice encodes a []string pointer as a repeated String.
- func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.StringSlice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- }
- return b, nil
- }
- // consumeStringSlice wire decodes a []string pointer as a repeated String.
- func consumeStringSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.StringSlice()
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, v)
- return n, nil
- }
- var coderStringSlice = pointerCoderFuncs{
- size: sizeStringSlice,
- marshal: appendStringSlice,
- unmarshal: consumeStringSlice,
- }
- // appendStringSliceValidateUTF8 encodes a []string pointer as a repeated String.
- func appendStringSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.StringSlice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v)
- if !utf8.ValidString(v) {
- return b, errInvalidUTF8{}
- }
- }
- return b, nil
- }
- // consumeStringSliceValidateUTF8 wire decodes a []string pointer as a repeated String.
- func consumeStringSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.StringSlice()
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- if !utf8.ValidString(v) {
- return 0, errInvalidUTF8{}
- }
- *sp = append(*sp, v)
- return n, nil
- }
- var coderStringSliceValidateUTF8 = pointerCoderFuncs{
- size: sizeStringSlice,
- marshal: appendStringSliceValidateUTF8,
- unmarshal: consumeStringSliceValidateUTF8,
- }
- // sizeStringValue returns the size of wire encoding a string value as a String.
- func sizeStringValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeBytes(len(v.String()))
- }
- // appendStringValue encodes a string value as a String.
- func appendStringValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v.String())
- return b, nil
- }
- // consumeStringValue decodes a string value as a String.
- func consumeStringValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfString(string(v)), n, nil
- }
- var coderStringValue = valueCoderFuncs{
- size: sizeStringValue,
- marshal: appendStringValue,
- unmarshal: consumeStringValue,
- }
- // appendStringValueValidateUTF8 encodes a string value as a String.
- func appendStringValueValidateUTF8(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v.String())
- if !utf8.ValidString(v.String()) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- // consumeStringValueValidateUTF8 decodes a string value as a String.
- func consumeStringValueValidateUTF8(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- if !utf8.ValidString(v) {
- return protoreflect.Value{}, 0, errInvalidUTF8{}
- }
- return protoreflect.ValueOfString(string(v)), n, nil
- }
- var coderStringValueValidateUTF8 = valueCoderFuncs{
- size: sizeStringValue,
- marshal: appendStringValueValidateUTF8,
- unmarshal: consumeStringValueValidateUTF8,
- }
- // sizeStringSliceValue returns the size of wire encoding a []string value as a repeated String.
- func sizeStringSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeBytes(len(v.String()))
- }
- return size
- }
- // appendStringSliceValue encodes a []string value as a repeated String.
- func appendStringSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendString(b, v.String())
- }
- return b, nil
- }
- // consumeStringSliceValue wire decodes a []string value as a repeated String.
- func consumeStringSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeString(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfString(string(v)))
- return listv, n, nil
- }
- var coderStringSliceValue = valueCoderFuncs{
- size: sizeStringSliceValue,
- marshal: appendStringSliceValue,
- unmarshal: consumeStringSliceValue,
- }
- // sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
- func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Bytes()
- return tagsize + wire.SizeBytes(len(v))
- }
- // appendBytes wire encodes a []byte pointer as a Bytes.
- func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bytes()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- return b, nil
- }
- // consumeBytes wire decodes a []byte pointer as a Bytes.
- func consumeBytes(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Bytes() = append(emptyBuf[:], v...)
- return n, nil
- }
- var coderBytes = pointerCoderFuncs{
- size: sizeBytes,
- marshal: appendBytes,
- unmarshal: consumeBytes,
- }
- // appendBytesValidateUTF8 wire encodes a []byte pointer as a Bytes.
- func appendBytesValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bytes()
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- if !utf8.Valid(v) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- // consumeBytesValidateUTF8 wire decodes a []byte pointer as a Bytes.
- func consumeBytesValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- if !utf8.Valid(v) {
- return 0, errInvalidUTF8{}
- }
- *p.Bytes() = append(emptyBuf[:], v...)
- return n, nil
- }
- var coderBytesValidateUTF8 = pointerCoderFuncs{
- size: sizeBytes,
- marshal: appendBytesValidateUTF8,
- unmarshal: consumeBytesValidateUTF8,
- }
- // sizeBytesNoZero returns the size of wire encoding a []byte pointer as a Bytes.
- // The zero value is not encoded.
- func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
- v := *p.Bytes()
- if len(v) == 0 {
- return 0
- }
- return tagsize + wire.SizeBytes(len(v))
- }
- // appendBytesNoZero wire encodes a []byte pointer as a Bytes.
- // The zero value is not encoded.
- func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bytes()
- if len(v) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- return b, nil
- }
- // consumeBytesNoZero wire decodes a []byte pointer as a Bytes.
- // The zero value is not decoded.
- func consumeBytesNoZero(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *p.Bytes() = append(([]byte)(nil), v...)
- return n, nil
- }
- var coderBytesNoZero = pointerCoderFuncs{
- size: sizeBytesNoZero,
- marshal: appendBytesNoZero,
- unmarshal: consumeBytesNoZero,
- }
- // appendBytesNoZeroValidateUTF8 wire encodes a []byte pointer as a Bytes.
- // The zero value is not encoded.
- func appendBytesNoZeroValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- v := *p.Bytes()
- if len(v) == 0 {
- return b, nil
- }
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- if !utf8.Valid(v) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- // consumeBytesNoZeroValidateUTF8 wire decodes a []byte pointer as a Bytes.
- func consumeBytesNoZeroValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- if !utf8.Valid(v) {
- return 0, errInvalidUTF8{}
- }
- *p.Bytes() = append(([]byte)(nil), v...)
- return n, nil
- }
- var coderBytesNoZeroValidateUTF8 = pointerCoderFuncs{
- size: sizeBytesNoZero,
- marshal: appendBytesNoZeroValidateUTF8,
- unmarshal: consumeBytesNoZeroValidateUTF8,
- }
- // sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
- func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
- s := *p.BytesSlice()
- for _, v := range s {
- size += tagsize + wire.SizeBytes(len(v))
- }
- return size
- }
- // appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
- func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.BytesSlice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- }
- return b, nil
- }
- // consumeBytesSlice wire decodes a [][]byte pointer as a repeated Bytes.
- func consumeBytesSlice(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.BytesSlice()
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- *sp = append(*sp, append(emptyBuf[:], v...))
- return n, nil
- }
- var coderBytesSlice = pointerCoderFuncs{
- size: sizeBytesSlice,
- marshal: appendBytesSlice,
- unmarshal: consumeBytesSlice,
- }
- // appendBytesSliceValidateUTF8 encodes a [][]byte pointer as a repeated Bytes.
- func appendBytesSliceValidateUTF8(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
- s := *p.BytesSlice()
- for _, v := range s {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v)
- if !utf8.Valid(v) {
- return b, errInvalidUTF8{}
- }
- }
- return b, nil
- }
- // consumeBytesSliceValidateUTF8 wire decodes a [][]byte pointer as a repeated Bytes.
- func consumeBytesSliceValidateUTF8(b []byte, p pointer, wtyp wire.Type, _ unmarshalOptions) (n int, err error) {
- sp := p.BytesSlice()
- if wtyp != wire.BytesType {
- return 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return 0, wire.ParseError(n)
- }
- if !utf8.Valid(v) {
- return 0, errInvalidUTF8{}
- }
- *sp = append(*sp, append(emptyBuf[:], v...))
- return n, nil
- }
- var coderBytesSliceValidateUTF8 = pointerCoderFuncs{
- size: sizeBytesSlice,
- marshal: appendBytesSliceValidateUTF8,
- unmarshal: consumeBytesSliceValidateUTF8,
- }
- // sizeBytesValue returns the size of wire encoding a []byte value as a Bytes.
- func sizeBytesValue(v protoreflect.Value, tagsize int, _ marshalOptions) int {
- return tagsize + wire.SizeBytes(len(v.Bytes()))
- }
- // appendBytesValue encodes a []byte value as a Bytes.
- func appendBytesValue(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v.Bytes())
- return b, nil
- }
- // consumeBytesValue decodes a []byte value as a Bytes.
- func consumeBytesValue(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- return protoreflect.ValueOfBytes(append(([]byte)(nil), v...)), n, nil
- }
- var coderBytesValue = valueCoderFuncs{
- size: sizeBytesValue,
- marshal: appendBytesValue,
- unmarshal: consumeBytesValue,
- }
- // appendBytesValueValidateUTF8 encodes a []byte value as a Bytes.
- func appendBytesValueValidateUTF8(b []byte, v protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v.Bytes())
- if !utf8.Valid(v.Bytes()) {
- return b, errInvalidUTF8{}
- }
- return b, nil
- }
- // consumeBytesValueValidateUTF8 decodes a []byte value as a Bytes.
- func consumeBytesValueValidateUTF8(b []byte, _ protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (protoreflect.Value, int, error) {
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- if !utf8.Valid(v) {
- return protoreflect.Value{}, 0, errInvalidUTF8{}
- }
- return protoreflect.ValueOfBytes(append(([]byte)(nil), v...)), n, nil
- }
- var coderBytesValueValidateUTF8 = valueCoderFuncs{
- size: sizeBytesValue,
- marshal: appendBytesValueValidateUTF8,
- unmarshal: consumeBytesValueValidateUTF8,
- }
- // sizeBytesSliceValue returns the size of wire encoding a [][]byte value as a repeated Bytes.
- func sizeBytesSliceValue(listv protoreflect.Value, tagsize int, _ marshalOptions) (size int) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- size += tagsize + wire.SizeBytes(len(v.Bytes()))
- }
- return size
- }
- // appendBytesSliceValue encodes a [][]byte value as a repeated Bytes.
- func appendBytesSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, _ marshalOptions) ([]byte, error) {
- list := listv.List()
- for i, llen := 0, list.Len(); i < llen; i++ {
- v := list.Get(i)
- b = wire.AppendVarint(b, wiretag)
- b = wire.AppendBytes(b, v.Bytes())
- }
- return b, nil
- }
- // consumeBytesSliceValue wire decodes a [][]byte value as a repeated Bytes.
- func consumeBytesSliceValue(b []byte, listv protoreflect.Value, _ wire.Number, wtyp wire.Type, _ unmarshalOptions) (_ protoreflect.Value, n int, err error) {
- list := listv.List()
- if wtyp != wire.BytesType {
- return protoreflect.Value{}, 0, errUnknown
- }
- v, n := wire.ConsumeBytes(b)
- if n < 0 {
- return protoreflect.Value{}, 0, wire.ParseError(n)
- }
- list.Append(protoreflect.ValueOfBytes(append(([]byte)(nil), v...)))
- return listv, n, nil
- }
- var coderBytesSliceValue = valueCoderFuncs{
- size: sizeBytesSliceValue,
- marshal: appendBytesSliceValue,
- unmarshal: consumeBytesSliceValue,
- }
- // We append to an empty array rather than a nil []byte to get non-nil zero-length byte slices.
- var emptyBuf [0]byte
- var wireTypes = map[protoreflect.Kind]wire.Type{
- protoreflect.BoolKind: wire.VarintType,
- protoreflect.EnumKind: wire.VarintType,
- protoreflect.Int32Kind: wire.VarintType,
- protoreflect.Sint32Kind: wire.VarintType,
- protoreflect.Uint32Kind: wire.VarintType,
- protoreflect.Int64Kind: wire.VarintType,
- protoreflect.Sint64Kind: wire.VarintType,
- protoreflect.Uint64Kind: wire.VarintType,
- protoreflect.Sfixed32Kind: wire.Fixed32Type,
- protoreflect.Fixed32Kind: wire.Fixed32Type,
- protoreflect.FloatKind: wire.Fixed32Type,
- protoreflect.Sfixed64Kind: wire.Fixed64Type,
- protoreflect.Fixed64Kind: wire.Fixed64Type,
- protoreflect.DoubleKind: wire.Fixed64Type,
- protoreflect.StringKind: wire.BytesType,
- protoreflect.BytesKind: wire.BytesType,
- protoreflect.MessageKind: wire.BytesType,
- protoreflect.GroupKind: wire.StartGroupType,
- }
|