encode_gen.go 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style.
  3. // license that can be found in the LICENSE file.
  4. // Code generated by generate-types. DO NOT EDIT.
  5. package impl
  6. import (
  7. "math"
  8. "google.golang.org/protobuf/internal/encoding/wire"
  9. "google.golang.org/protobuf/reflect/protoreflect"
  10. )
  11. // sizeBool returns the size of wire encoding a bool pointer as a Bool.
  12. func sizeBool(p pointer, tagsize int, _ marshalOptions) (size int) {
  13. v := *p.Bool()
  14. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  15. }
  16. // appendBool wire encodes a bool pointer as a Bool.
  17. func appendBool(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  18. v := *p.Bool()
  19. b = wire.AppendVarint(b, wiretag)
  20. b = wire.AppendVarint(b, wire.EncodeBool(v))
  21. return b, nil
  22. }
  23. var coderBool = pointerCoderFuncs{
  24. size: sizeBool,
  25. marshal: appendBool,
  26. }
  27. // sizeBool returns the size of wire encoding a bool pointer as a Bool.
  28. // The zero value is not encoded.
  29. func sizeBoolNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  30. v := *p.Bool()
  31. if v == false {
  32. return 0
  33. }
  34. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  35. }
  36. // appendBool wire encodes a bool pointer as a Bool.
  37. // The zero value is not encoded.
  38. func appendBoolNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  39. v := *p.Bool()
  40. if v == false {
  41. return b, nil
  42. }
  43. b = wire.AppendVarint(b, wiretag)
  44. b = wire.AppendVarint(b, wire.EncodeBool(v))
  45. return b, nil
  46. }
  47. var coderBoolNoZero = pointerCoderFuncs{
  48. size: sizeBoolNoZero,
  49. marshal: appendBoolNoZero,
  50. }
  51. // sizeBoolPtr returns the size of wire encoding a *bool pointer as a Bool.
  52. // It panics if the pointer is nil.
  53. func sizeBoolPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  54. v := **p.BoolPtr()
  55. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  56. }
  57. // appendBool wire encodes a *bool pointer as a Bool.
  58. // It panics if the pointer is nil.
  59. func appendBoolPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  60. v := **p.BoolPtr()
  61. b = wire.AppendVarint(b, wiretag)
  62. b = wire.AppendVarint(b, wire.EncodeBool(v))
  63. return b, nil
  64. }
  65. var coderBoolPtr = pointerCoderFuncs{
  66. size: sizeBoolPtr,
  67. marshal: appendBoolPtr,
  68. }
  69. // sizeBoolSlice returns the size of wire encoding a []bool pointer as a repeated Bool.
  70. func sizeBoolSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  71. s := *p.BoolSlice()
  72. for _, v := range s {
  73. size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
  74. }
  75. return size
  76. }
  77. // appendBoolSlice encodes a []bool pointer as a repeated Bool.
  78. func appendBoolSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  79. s := *p.BoolSlice()
  80. for _, v := range s {
  81. b = wire.AppendVarint(b, wiretag)
  82. b = wire.AppendVarint(b, wire.EncodeBool(v))
  83. }
  84. return b, nil
  85. }
  86. var coderBoolSlice = pointerCoderFuncs{
  87. size: sizeBoolSlice,
  88. marshal: appendBoolSlice,
  89. }
  90. // sizeBoolPackedSlice returns the size of wire encoding a []bool pointer as a packed repeated Bool.
  91. func sizeBoolPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  92. s := *p.BoolSlice()
  93. if len(s) == 0 {
  94. return 0
  95. }
  96. n := 0
  97. for _, v := range s {
  98. n += wire.SizeVarint(wire.EncodeBool(v))
  99. }
  100. return tagsize + wire.SizeBytes(n)
  101. }
  102. // appendBoolPackedSlice encodes a []bool pointer as a packed repeated Bool.
  103. func appendBoolPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  104. s := *p.BoolSlice()
  105. if len(s) == 0 {
  106. return b, nil
  107. }
  108. b = wire.AppendVarint(b, wiretag)
  109. n := 0
  110. for _, v := range s {
  111. n += wire.SizeVarint(wire.EncodeBool(v))
  112. }
  113. b = wire.AppendVarint(b, uint64(n))
  114. for _, v := range s {
  115. b = wire.AppendVarint(b, wire.EncodeBool(v))
  116. }
  117. return b, nil
  118. }
  119. var coderBoolPackedSlice = pointerCoderFuncs{
  120. size: sizeBoolPackedSlice,
  121. marshal: appendBoolPackedSlice,
  122. }
  123. // sizeBoolIface returns the size of wire encoding a bool value as a Bool.
  124. func sizeBoolIface(ival interface{}, tagsize int, _ marshalOptions) int {
  125. v := ival.(bool)
  126. return tagsize + wire.SizeVarint(wire.EncodeBool(v))
  127. }
  128. // appendBoolIface encodes a bool value as a Bool.
  129. func appendBoolIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  130. v := ival.(bool)
  131. b = wire.AppendVarint(b, wiretag)
  132. b = wire.AppendVarint(b, wire.EncodeBool(v))
  133. return b, nil
  134. }
  135. var coderBoolIface = ifaceCoderFuncs{
  136. size: sizeBoolIface,
  137. marshal: appendBoolIface,
  138. }
  139. // sizeBoolSliceIface returns the size of wire encoding a []bool value as a repeated Bool.
  140. func sizeBoolSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  141. s := *ival.(*[]bool)
  142. for _, v := range s {
  143. size += tagsize + wire.SizeVarint(wire.EncodeBool(v))
  144. }
  145. return size
  146. }
  147. // appendBoolSliceIface encodes a []bool value as a repeated Bool.
  148. func appendBoolSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  149. s := *ival.(*[]bool)
  150. for _, v := range s {
  151. b = wire.AppendVarint(b, wiretag)
  152. b = wire.AppendVarint(b, wire.EncodeBool(v))
  153. }
  154. return b, nil
  155. }
  156. var coderBoolSliceIface = ifaceCoderFuncs{
  157. size: sizeBoolSliceIface,
  158. marshal: appendBoolSliceIface,
  159. }
  160. // sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
  161. func sizeInt32(p pointer, tagsize int, _ marshalOptions) (size int) {
  162. v := *p.Int32()
  163. return tagsize + wire.SizeVarint(uint64(v))
  164. }
  165. // appendInt32 wire encodes a int32 pointer as a Int32.
  166. func appendInt32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  167. v := *p.Int32()
  168. b = wire.AppendVarint(b, wiretag)
  169. b = wire.AppendVarint(b, uint64(v))
  170. return b, nil
  171. }
  172. var coderInt32 = pointerCoderFuncs{
  173. size: sizeInt32,
  174. marshal: appendInt32,
  175. }
  176. // sizeInt32 returns the size of wire encoding a int32 pointer as a Int32.
  177. // The zero value is not encoded.
  178. func sizeInt32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  179. v := *p.Int32()
  180. if v == 0 {
  181. return 0
  182. }
  183. return tagsize + wire.SizeVarint(uint64(v))
  184. }
  185. // appendInt32 wire encodes a int32 pointer as a Int32.
  186. // The zero value is not encoded.
  187. func appendInt32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  188. v := *p.Int32()
  189. if v == 0 {
  190. return b, nil
  191. }
  192. b = wire.AppendVarint(b, wiretag)
  193. b = wire.AppendVarint(b, uint64(v))
  194. return b, nil
  195. }
  196. var coderInt32NoZero = pointerCoderFuncs{
  197. size: sizeInt32NoZero,
  198. marshal: appendInt32NoZero,
  199. }
  200. // sizeInt32Ptr returns the size of wire encoding a *int32 pointer as a Int32.
  201. // It panics if the pointer is nil.
  202. func sizeInt32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  203. v := **p.Int32Ptr()
  204. return tagsize + wire.SizeVarint(uint64(v))
  205. }
  206. // appendInt32 wire encodes a *int32 pointer as a Int32.
  207. // It panics if the pointer is nil.
  208. func appendInt32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  209. v := **p.Int32Ptr()
  210. b = wire.AppendVarint(b, wiretag)
  211. b = wire.AppendVarint(b, uint64(v))
  212. return b, nil
  213. }
  214. var coderInt32Ptr = pointerCoderFuncs{
  215. size: sizeInt32Ptr,
  216. marshal: appendInt32Ptr,
  217. }
  218. // sizeInt32Slice returns the size of wire encoding a []int32 pointer as a repeated Int32.
  219. func sizeInt32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  220. s := *p.Int32Slice()
  221. for _, v := range s {
  222. size += tagsize + wire.SizeVarint(uint64(v))
  223. }
  224. return size
  225. }
  226. // appendInt32Slice encodes a []int32 pointer as a repeated Int32.
  227. func appendInt32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  228. s := *p.Int32Slice()
  229. for _, v := range s {
  230. b = wire.AppendVarint(b, wiretag)
  231. b = wire.AppendVarint(b, uint64(v))
  232. }
  233. return b, nil
  234. }
  235. var coderInt32Slice = pointerCoderFuncs{
  236. size: sizeInt32Slice,
  237. marshal: appendInt32Slice,
  238. }
  239. // sizeInt32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Int32.
  240. func sizeInt32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  241. s := *p.Int32Slice()
  242. if len(s) == 0 {
  243. return 0
  244. }
  245. n := 0
  246. for _, v := range s {
  247. n += wire.SizeVarint(uint64(v))
  248. }
  249. return tagsize + wire.SizeBytes(n)
  250. }
  251. // appendInt32PackedSlice encodes a []int32 pointer as a packed repeated Int32.
  252. func appendInt32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  253. s := *p.Int32Slice()
  254. if len(s) == 0 {
  255. return b, nil
  256. }
  257. b = wire.AppendVarint(b, wiretag)
  258. n := 0
  259. for _, v := range s {
  260. n += wire.SizeVarint(uint64(v))
  261. }
  262. b = wire.AppendVarint(b, uint64(n))
  263. for _, v := range s {
  264. b = wire.AppendVarint(b, uint64(v))
  265. }
  266. return b, nil
  267. }
  268. var coderInt32PackedSlice = pointerCoderFuncs{
  269. size: sizeInt32PackedSlice,
  270. marshal: appendInt32PackedSlice,
  271. }
  272. // sizeInt32Iface returns the size of wire encoding a int32 value as a Int32.
  273. func sizeInt32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  274. v := ival.(int32)
  275. return tagsize + wire.SizeVarint(uint64(v))
  276. }
  277. // appendInt32Iface encodes a int32 value as a Int32.
  278. func appendInt32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  279. v := ival.(int32)
  280. b = wire.AppendVarint(b, wiretag)
  281. b = wire.AppendVarint(b, uint64(v))
  282. return b, nil
  283. }
  284. var coderInt32Iface = ifaceCoderFuncs{
  285. size: sizeInt32Iface,
  286. marshal: appendInt32Iface,
  287. }
  288. // sizeInt32SliceIface returns the size of wire encoding a []int32 value as a repeated Int32.
  289. func sizeInt32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  290. s := *ival.(*[]int32)
  291. for _, v := range s {
  292. size += tagsize + wire.SizeVarint(uint64(v))
  293. }
  294. return size
  295. }
  296. // appendInt32SliceIface encodes a []int32 value as a repeated Int32.
  297. func appendInt32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  298. s := *ival.(*[]int32)
  299. for _, v := range s {
  300. b = wire.AppendVarint(b, wiretag)
  301. b = wire.AppendVarint(b, uint64(v))
  302. }
  303. return b, nil
  304. }
  305. var coderInt32SliceIface = ifaceCoderFuncs{
  306. size: sizeInt32SliceIface,
  307. marshal: appendInt32SliceIface,
  308. }
  309. // sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
  310. func sizeSint32(p pointer, tagsize int, _ marshalOptions) (size int) {
  311. v := *p.Int32()
  312. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  313. }
  314. // appendSint32 wire encodes a int32 pointer as a Sint32.
  315. func appendSint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  316. v := *p.Int32()
  317. b = wire.AppendVarint(b, wiretag)
  318. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  319. return b, nil
  320. }
  321. var coderSint32 = pointerCoderFuncs{
  322. size: sizeSint32,
  323. marshal: appendSint32,
  324. }
  325. // sizeSint32 returns the size of wire encoding a int32 pointer as a Sint32.
  326. // The zero value is not encoded.
  327. func sizeSint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  328. v := *p.Int32()
  329. if v == 0 {
  330. return 0
  331. }
  332. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  333. }
  334. // appendSint32 wire encodes a int32 pointer as a Sint32.
  335. // The zero value is not encoded.
  336. func appendSint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  337. v := *p.Int32()
  338. if v == 0 {
  339. return b, nil
  340. }
  341. b = wire.AppendVarint(b, wiretag)
  342. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  343. return b, nil
  344. }
  345. var coderSint32NoZero = pointerCoderFuncs{
  346. size: sizeSint32NoZero,
  347. marshal: appendSint32NoZero,
  348. }
  349. // sizeSint32Ptr returns the size of wire encoding a *int32 pointer as a Sint32.
  350. // It panics if the pointer is nil.
  351. func sizeSint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  352. v := **p.Int32Ptr()
  353. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  354. }
  355. // appendSint32 wire encodes a *int32 pointer as a Sint32.
  356. // It panics if the pointer is nil.
  357. func appendSint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  358. v := **p.Int32Ptr()
  359. b = wire.AppendVarint(b, wiretag)
  360. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  361. return b, nil
  362. }
  363. var coderSint32Ptr = pointerCoderFuncs{
  364. size: sizeSint32Ptr,
  365. marshal: appendSint32Ptr,
  366. }
  367. // sizeSint32Slice returns the size of wire encoding a []int32 pointer as a repeated Sint32.
  368. func sizeSint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  369. s := *p.Int32Slice()
  370. for _, v := range s {
  371. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  372. }
  373. return size
  374. }
  375. // appendSint32Slice encodes a []int32 pointer as a repeated Sint32.
  376. func appendSint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  377. s := *p.Int32Slice()
  378. for _, v := range s {
  379. b = wire.AppendVarint(b, wiretag)
  380. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  381. }
  382. return b, nil
  383. }
  384. var coderSint32Slice = pointerCoderFuncs{
  385. size: sizeSint32Slice,
  386. marshal: appendSint32Slice,
  387. }
  388. // sizeSint32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sint32.
  389. func sizeSint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  390. s := *p.Int32Slice()
  391. if len(s) == 0 {
  392. return 0
  393. }
  394. n := 0
  395. for _, v := range s {
  396. n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  397. }
  398. return tagsize + wire.SizeBytes(n)
  399. }
  400. // appendSint32PackedSlice encodes a []int32 pointer as a packed repeated Sint32.
  401. func appendSint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  402. s := *p.Int32Slice()
  403. if len(s) == 0 {
  404. return b, nil
  405. }
  406. b = wire.AppendVarint(b, wiretag)
  407. n := 0
  408. for _, v := range s {
  409. n += wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  410. }
  411. b = wire.AppendVarint(b, uint64(n))
  412. for _, v := range s {
  413. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  414. }
  415. return b, nil
  416. }
  417. var coderSint32PackedSlice = pointerCoderFuncs{
  418. size: sizeSint32PackedSlice,
  419. marshal: appendSint32PackedSlice,
  420. }
  421. // sizeSint32Iface returns the size of wire encoding a int32 value as a Sint32.
  422. func sizeSint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  423. v := ival.(int32)
  424. return tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  425. }
  426. // appendSint32Iface encodes a int32 value as a Sint32.
  427. func appendSint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  428. v := ival.(int32)
  429. b = wire.AppendVarint(b, wiretag)
  430. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  431. return b, nil
  432. }
  433. var coderSint32Iface = ifaceCoderFuncs{
  434. size: sizeSint32Iface,
  435. marshal: appendSint32Iface,
  436. }
  437. // sizeSint32SliceIface returns the size of wire encoding a []int32 value as a repeated Sint32.
  438. func sizeSint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  439. s := *ival.(*[]int32)
  440. for _, v := range s {
  441. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(int64(v)))
  442. }
  443. return size
  444. }
  445. // appendSint32SliceIface encodes a []int32 value as a repeated Sint32.
  446. func appendSint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  447. s := *ival.(*[]int32)
  448. for _, v := range s {
  449. b = wire.AppendVarint(b, wiretag)
  450. b = wire.AppendVarint(b, wire.EncodeZigZag(int64(v)))
  451. }
  452. return b, nil
  453. }
  454. var coderSint32SliceIface = ifaceCoderFuncs{
  455. size: sizeSint32SliceIface,
  456. marshal: appendSint32SliceIface,
  457. }
  458. // sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
  459. func sizeUint32(p pointer, tagsize int, _ marshalOptions) (size int) {
  460. v := *p.Uint32()
  461. return tagsize + wire.SizeVarint(uint64(v))
  462. }
  463. // appendUint32 wire encodes a uint32 pointer as a Uint32.
  464. func appendUint32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  465. v := *p.Uint32()
  466. b = wire.AppendVarint(b, wiretag)
  467. b = wire.AppendVarint(b, uint64(v))
  468. return b, nil
  469. }
  470. var coderUint32 = pointerCoderFuncs{
  471. size: sizeUint32,
  472. marshal: appendUint32,
  473. }
  474. // sizeUint32 returns the size of wire encoding a uint32 pointer as a Uint32.
  475. // The zero value is not encoded.
  476. func sizeUint32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  477. v := *p.Uint32()
  478. if v == 0 {
  479. return 0
  480. }
  481. return tagsize + wire.SizeVarint(uint64(v))
  482. }
  483. // appendUint32 wire encodes a uint32 pointer as a Uint32.
  484. // The zero value is not encoded.
  485. func appendUint32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  486. v := *p.Uint32()
  487. if v == 0 {
  488. return b, nil
  489. }
  490. b = wire.AppendVarint(b, wiretag)
  491. b = wire.AppendVarint(b, uint64(v))
  492. return b, nil
  493. }
  494. var coderUint32NoZero = pointerCoderFuncs{
  495. size: sizeUint32NoZero,
  496. marshal: appendUint32NoZero,
  497. }
  498. // sizeUint32Ptr returns the size of wire encoding a *uint32 pointer as a Uint32.
  499. // It panics if the pointer is nil.
  500. func sizeUint32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  501. v := **p.Uint32Ptr()
  502. return tagsize + wire.SizeVarint(uint64(v))
  503. }
  504. // appendUint32 wire encodes a *uint32 pointer as a Uint32.
  505. // It panics if the pointer is nil.
  506. func appendUint32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  507. v := **p.Uint32Ptr()
  508. b = wire.AppendVarint(b, wiretag)
  509. b = wire.AppendVarint(b, uint64(v))
  510. return b, nil
  511. }
  512. var coderUint32Ptr = pointerCoderFuncs{
  513. size: sizeUint32Ptr,
  514. marshal: appendUint32Ptr,
  515. }
  516. // sizeUint32Slice returns the size of wire encoding a []uint32 pointer as a repeated Uint32.
  517. func sizeUint32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  518. s := *p.Uint32Slice()
  519. for _, v := range s {
  520. size += tagsize + wire.SizeVarint(uint64(v))
  521. }
  522. return size
  523. }
  524. // appendUint32Slice encodes a []uint32 pointer as a repeated Uint32.
  525. func appendUint32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  526. s := *p.Uint32Slice()
  527. for _, v := range s {
  528. b = wire.AppendVarint(b, wiretag)
  529. b = wire.AppendVarint(b, uint64(v))
  530. }
  531. return b, nil
  532. }
  533. var coderUint32Slice = pointerCoderFuncs{
  534. size: sizeUint32Slice,
  535. marshal: appendUint32Slice,
  536. }
  537. // sizeUint32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Uint32.
  538. func sizeUint32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  539. s := *p.Uint32Slice()
  540. if len(s) == 0 {
  541. return 0
  542. }
  543. n := 0
  544. for _, v := range s {
  545. n += wire.SizeVarint(uint64(v))
  546. }
  547. return tagsize + wire.SizeBytes(n)
  548. }
  549. // appendUint32PackedSlice encodes a []uint32 pointer as a packed repeated Uint32.
  550. func appendUint32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  551. s := *p.Uint32Slice()
  552. if len(s) == 0 {
  553. return b, nil
  554. }
  555. b = wire.AppendVarint(b, wiretag)
  556. n := 0
  557. for _, v := range s {
  558. n += wire.SizeVarint(uint64(v))
  559. }
  560. b = wire.AppendVarint(b, uint64(n))
  561. for _, v := range s {
  562. b = wire.AppendVarint(b, uint64(v))
  563. }
  564. return b, nil
  565. }
  566. var coderUint32PackedSlice = pointerCoderFuncs{
  567. size: sizeUint32PackedSlice,
  568. marshal: appendUint32PackedSlice,
  569. }
  570. // sizeUint32Iface returns the size of wire encoding a uint32 value as a Uint32.
  571. func sizeUint32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  572. v := ival.(uint32)
  573. return tagsize + wire.SizeVarint(uint64(v))
  574. }
  575. // appendUint32Iface encodes a uint32 value as a Uint32.
  576. func appendUint32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  577. v := ival.(uint32)
  578. b = wire.AppendVarint(b, wiretag)
  579. b = wire.AppendVarint(b, uint64(v))
  580. return b, nil
  581. }
  582. var coderUint32Iface = ifaceCoderFuncs{
  583. size: sizeUint32Iface,
  584. marshal: appendUint32Iface,
  585. }
  586. // sizeUint32SliceIface returns the size of wire encoding a []uint32 value as a repeated Uint32.
  587. func sizeUint32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  588. s := *ival.(*[]uint32)
  589. for _, v := range s {
  590. size += tagsize + wire.SizeVarint(uint64(v))
  591. }
  592. return size
  593. }
  594. // appendUint32SliceIface encodes a []uint32 value as a repeated Uint32.
  595. func appendUint32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  596. s := *ival.(*[]uint32)
  597. for _, v := range s {
  598. b = wire.AppendVarint(b, wiretag)
  599. b = wire.AppendVarint(b, uint64(v))
  600. }
  601. return b, nil
  602. }
  603. var coderUint32SliceIface = ifaceCoderFuncs{
  604. size: sizeUint32SliceIface,
  605. marshal: appendUint32SliceIface,
  606. }
  607. // sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
  608. func sizeInt64(p pointer, tagsize int, _ marshalOptions) (size int) {
  609. v := *p.Int64()
  610. return tagsize + wire.SizeVarint(uint64(v))
  611. }
  612. // appendInt64 wire encodes a int64 pointer as a Int64.
  613. func appendInt64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  614. v := *p.Int64()
  615. b = wire.AppendVarint(b, wiretag)
  616. b = wire.AppendVarint(b, uint64(v))
  617. return b, nil
  618. }
  619. var coderInt64 = pointerCoderFuncs{
  620. size: sizeInt64,
  621. marshal: appendInt64,
  622. }
  623. // sizeInt64 returns the size of wire encoding a int64 pointer as a Int64.
  624. // The zero value is not encoded.
  625. func sizeInt64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  626. v := *p.Int64()
  627. if v == 0 {
  628. return 0
  629. }
  630. return tagsize + wire.SizeVarint(uint64(v))
  631. }
  632. // appendInt64 wire encodes a int64 pointer as a Int64.
  633. // The zero value is not encoded.
  634. func appendInt64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  635. v := *p.Int64()
  636. if v == 0 {
  637. return b, nil
  638. }
  639. b = wire.AppendVarint(b, wiretag)
  640. b = wire.AppendVarint(b, uint64(v))
  641. return b, nil
  642. }
  643. var coderInt64NoZero = pointerCoderFuncs{
  644. size: sizeInt64NoZero,
  645. marshal: appendInt64NoZero,
  646. }
  647. // sizeInt64Ptr returns the size of wire encoding a *int64 pointer as a Int64.
  648. // It panics if the pointer is nil.
  649. func sizeInt64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  650. v := **p.Int64Ptr()
  651. return tagsize + wire.SizeVarint(uint64(v))
  652. }
  653. // appendInt64 wire encodes a *int64 pointer as a Int64.
  654. // It panics if the pointer is nil.
  655. func appendInt64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  656. v := **p.Int64Ptr()
  657. b = wire.AppendVarint(b, wiretag)
  658. b = wire.AppendVarint(b, uint64(v))
  659. return b, nil
  660. }
  661. var coderInt64Ptr = pointerCoderFuncs{
  662. size: sizeInt64Ptr,
  663. marshal: appendInt64Ptr,
  664. }
  665. // sizeInt64Slice returns the size of wire encoding a []int64 pointer as a repeated Int64.
  666. func sizeInt64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  667. s := *p.Int64Slice()
  668. for _, v := range s {
  669. size += tagsize + wire.SizeVarint(uint64(v))
  670. }
  671. return size
  672. }
  673. // appendInt64Slice encodes a []int64 pointer as a repeated Int64.
  674. func appendInt64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  675. s := *p.Int64Slice()
  676. for _, v := range s {
  677. b = wire.AppendVarint(b, wiretag)
  678. b = wire.AppendVarint(b, uint64(v))
  679. }
  680. return b, nil
  681. }
  682. var coderInt64Slice = pointerCoderFuncs{
  683. size: sizeInt64Slice,
  684. marshal: appendInt64Slice,
  685. }
  686. // sizeInt64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Int64.
  687. func sizeInt64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  688. s := *p.Int64Slice()
  689. if len(s) == 0 {
  690. return 0
  691. }
  692. n := 0
  693. for _, v := range s {
  694. n += wire.SizeVarint(uint64(v))
  695. }
  696. return tagsize + wire.SizeBytes(n)
  697. }
  698. // appendInt64PackedSlice encodes a []int64 pointer as a packed repeated Int64.
  699. func appendInt64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  700. s := *p.Int64Slice()
  701. if len(s) == 0 {
  702. return b, nil
  703. }
  704. b = wire.AppendVarint(b, wiretag)
  705. n := 0
  706. for _, v := range s {
  707. n += wire.SizeVarint(uint64(v))
  708. }
  709. b = wire.AppendVarint(b, uint64(n))
  710. for _, v := range s {
  711. b = wire.AppendVarint(b, uint64(v))
  712. }
  713. return b, nil
  714. }
  715. var coderInt64PackedSlice = pointerCoderFuncs{
  716. size: sizeInt64PackedSlice,
  717. marshal: appendInt64PackedSlice,
  718. }
  719. // sizeInt64Iface returns the size of wire encoding a int64 value as a Int64.
  720. func sizeInt64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  721. v := ival.(int64)
  722. return tagsize + wire.SizeVarint(uint64(v))
  723. }
  724. // appendInt64Iface encodes a int64 value as a Int64.
  725. func appendInt64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  726. v := ival.(int64)
  727. b = wire.AppendVarint(b, wiretag)
  728. b = wire.AppendVarint(b, uint64(v))
  729. return b, nil
  730. }
  731. var coderInt64Iface = ifaceCoderFuncs{
  732. size: sizeInt64Iface,
  733. marshal: appendInt64Iface,
  734. }
  735. // sizeInt64SliceIface returns the size of wire encoding a []int64 value as a repeated Int64.
  736. func sizeInt64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  737. s := *ival.(*[]int64)
  738. for _, v := range s {
  739. size += tagsize + wire.SizeVarint(uint64(v))
  740. }
  741. return size
  742. }
  743. // appendInt64SliceIface encodes a []int64 value as a repeated Int64.
  744. func appendInt64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  745. s := *ival.(*[]int64)
  746. for _, v := range s {
  747. b = wire.AppendVarint(b, wiretag)
  748. b = wire.AppendVarint(b, uint64(v))
  749. }
  750. return b, nil
  751. }
  752. var coderInt64SliceIface = ifaceCoderFuncs{
  753. size: sizeInt64SliceIface,
  754. marshal: appendInt64SliceIface,
  755. }
  756. // sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
  757. func sizeSint64(p pointer, tagsize int, _ marshalOptions) (size int) {
  758. v := *p.Int64()
  759. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  760. }
  761. // appendSint64 wire encodes a int64 pointer as a Sint64.
  762. func appendSint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  763. v := *p.Int64()
  764. b = wire.AppendVarint(b, wiretag)
  765. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  766. return b, nil
  767. }
  768. var coderSint64 = pointerCoderFuncs{
  769. size: sizeSint64,
  770. marshal: appendSint64,
  771. }
  772. // sizeSint64 returns the size of wire encoding a int64 pointer as a Sint64.
  773. // The zero value is not encoded.
  774. func sizeSint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  775. v := *p.Int64()
  776. if v == 0 {
  777. return 0
  778. }
  779. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  780. }
  781. // appendSint64 wire encodes a int64 pointer as a Sint64.
  782. // The zero value is not encoded.
  783. func appendSint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  784. v := *p.Int64()
  785. if v == 0 {
  786. return b, nil
  787. }
  788. b = wire.AppendVarint(b, wiretag)
  789. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  790. return b, nil
  791. }
  792. var coderSint64NoZero = pointerCoderFuncs{
  793. size: sizeSint64NoZero,
  794. marshal: appendSint64NoZero,
  795. }
  796. // sizeSint64Ptr returns the size of wire encoding a *int64 pointer as a Sint64.
  797. // It panics if the pointer is nil.
  798. func sizeSint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  799. v := **p.Int64Ptr()
  800. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  801. }
  802. // appendSint64 wire encodes a *int64 pointer as a Sint64.
  803. // It panics if the pointer is nil.
  804. func appendSint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  805. v := **p.Int64Ptr()
  806. b = wire.AppendVarint(b, wiretag)
  807. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  808. return b, nil
  809. }
  810. var coderSint64Ptr = pointerCoderFuncs{
  811. size: sizeSint64Ptr,
  812. marshal: appendSint64Ptr,
  813. }
  814. // sizeSint64Slice returns the size of wire encoding a []int64 pointer as a repeated Sint64.
  815. func sizeSint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  816. s := *p.Int64Slice()
  817. for _, v := range s {
  818. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  819. }
  820. return size
  821. }
  822. // appendSint64Slice encodes a []int64 pointer as a repeated Sint64.
  823. func appendSint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  824. s := *p.Int64Slice()
  825. for _, v := range s {
  826. b = wire.AppendVarint(b, wiretag)
  827. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  828. }
  829. return b, nil
  830. }
  831. var coderSint64Slice = pointerCoderFuncs{
  832. size: sizeSint64Slice,
  833. marshal: appendSint64Slice,
  834. }
  835. // sizeSint64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sint64.
  836. func sizeSint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  837. s := *p.Int64Slice()
  838. if len(s) == 0 {
  839. return 0
  840. }
  841. n := 0
  842. for _, v := range s {
  843. n += wire.SizeVarint(wire.EncodeZigZag(v))
  844. }
  845. return tagsize + wire.SizeBytes(n)
  846. }
  847. // appendSint64PackedSlice encodes a []int64 pointer as a packed repeated Sint64.
  848. func appendSint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  849. s := *p.Int64Slice()
  850. if len(s) == 0 {
  851. return b, nil
  852. }
  853. b = wire.AppendVarint(b, wiretag)
  854. n := 0
  855. for _, v := range s {
  856. n += wire.SizeVarint(wire.EncodeZigZag(v))
  857. }
  858. b = wire.AppendVarint(b, uint64(n))
  859. for _, v := range s {
  860. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  861. }
  862. return b, nil
  863. }
  864. var coderSint64PackedSlice = pointerCoderFuncs{
  865. size: sizeSint64PackedSlice,
  866. marshal: appendSint64PackedSlice,
  867. }
  868. // sizeSint64Iface returns the size of wire encoding a int64 value as a Sint64.
  869. func sizeSint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  870. v := ival.(int64)
  871. return tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  872. }
  873. // appendSint64Iface encodes a int64 value as a Sint64.
  874. func appendSint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  875. v := ival.(int64)
  876. b = wire.AppendVarint(b, wiretag)
  877. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  878. return b, nil
  879. }
  880. var coderSint64Iface = ifaceCoderFuncs{
  881. size: sizeSint64Iface,
  882. marshal: appendSint64Iface,
  883. }
  884. // sizeSint64SliceIface returns the size of wire encoding a []int64 value as a repeated Sint64.
  885. func sizeSint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  886. s := *ival.(*[]int64)
  887. for _, v := range s {
  888. size += tagsize + wire.SizeVarint(wire.EncodeZigZag(v))
  889. }
  890. return size
  891. }
  892. // appendSint64SliceIface encodes a []int64 value as a repeated Sint64.
  893. func appendSint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  894. s := *ival.(*[]int64)
  895. for _, v := range s {
  896. b = wire.AppendVarint(b, wiretag)
  897. b = wire.AppendVarint(b, wire.EncodeZigZag(v))
  898. }
  899. return b, nil
  900. }
  901. var coderSint64SliceIface = ifaceCoderFuncs{
  902. size: sizeSint64SliceIface,
  903. marshal: appendSint64SliceIface,
  904. }
  905. // sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
  906. func sizeUint64(p pointer, tagsize int, _ marshalOptions) (size int) {
  907. v := *p.Uint64()
  908. return tagsize + wire.SizeVarint(v)
  909. }
  910. // appendUint64 wire encodes a uint64 pointer as a Uint64.
  911. func appendUint64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  912. v := *p.Uint64()
  913. b = wire.AppendVarint(b, wiretag)
  914. b = wire.AppendVarint(b, v)
  915. return b, nil
  916. }
  917. var coderUint64 = pointerCoderFuncs{
  918. size: sizeUint64,
  919. marshal: appendUint64,
  920. }
  921. // sizeUint64 returns the size of wire encoding a uint64 pointer as a Uint64.
  922. // The zero value is not encoded.
  923. func sizeUint64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  924. v := *p.Uint64()
  925. if v == 0 {
  926. return 0
  927. }
  928. return tagsize + wire.SizeVarint(v)
  929. }
  930. // appendUint64 wire encodes a uint64 pointer as a Uint64.
  931. // The zero value is not encoded.
  932. func appendUint64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  933. v := *p.Uint64()
  934. if v == 0 {
  935. return b, nil
  936. }
  937. b = wire.AppendVarint(b, wiretag)
  938. b = wire.AppendVarint(b, v)
  939. return b, nil
  940. }
  941. var coderUint64NoZero = pointerCoderFuncs{
  942. size: sizeUint64NoZero,
  943. marshal: appendUint64NoZero,
  944. }
  945. // sizeUint64Ptr returns the size of wire encoding a *uint64 pointer as a Uint64.
  946. // It panics if the pointer is nil.
  947. func sizeUint64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  948. v := **p.Uint64Ptr()
  949. return tagsize + wire.SizeVarint(v)
  950. }
  951. // appendUint64 wire encodes a *uint64 pointer as a Uint64.
  952. // It panics if the pointer is nil.
  953. func appendUint64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  954. v := **p.Uint64Ptr()
  955. b = wire.AppendVarint(b, wiretag)
  956. b = wire.AppendVarint(b, v)
  957. return b, nil
  958. }
  959. var coderUint64Ptr = pointerCoderFuncs{
  960. size: sizeUint64Ptr,
  961. marshal: appendUint64Ptr,
  962. }
  963. // sizeUint64Slice returns the size of wire encoding a []uint64 pointer as a repeated Uint64.
  964. func sizeUint64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  965. s := *p.Uint64Slice()
  966. for _, v := range s {
  967. size += tagsize + wire.SizeVarint(v)
  968. }
  969. return size
  970. }
  971. // appendUint64Slice encodes a []uint64 pointer as a repeated Uint64.
  972. func appendUint64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  973. s := *p.Uint64Slice()
  974. for _, v := range s {
  975. b = wire.AppendVarint(b, wiretag)
  976. b = wire.AppendVarint(b, v)
  977. }
  978. return b, nil
  979. }
  980. var coderUint64Slice = pointerCoderFuncs{
  981. size: sizeUint64Slice,
  982. marshal: appendUint64Slice,
  983. }
  984. // sizeUint64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Uint64.
  985. func sizeUint64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  986. s := *p.Uint64Slice()
  987. if len(s) == 0 {
  988. return 0
  989. }
  990. n := 0
  991. for _, v := range s {
  992. n += wire.SizeVarint(v)
  993. }
  994. return tagsize + wire.SizeBytes(n)
  995. }
  996. // appendUint64PackedSlice encodes a []uint64 pointer as a packed repeated Uint64.
  997. func appendUint64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  998. s := *p.Uint64Slice()
  999. if len(s) == 0 {
  1000. return b, nil
  1001. }
  1002. b = wire.AppendVarint(b, wiretag)
  1003. n := 0
  1004. for _, v := range s {
  1005. n += wire.SizeVarint(v)
  1006. }
  1007. b = wire.AppendVarint(b, uint64(n))
  1008. for _, v := range s {
  1009. b = wire.AppendVarint(b, v)
  1010. }
  1011. return b, nil
  1012. }
  1013. var coderUint64PackedSlice = pointerCoderFuncs{
  1014. size: sizeUint64PackedSlice,
  1015. marshal: appendUint64PackedSlice,
  1016. }
  1017. // sizeUint64Iface returns the size of wire encoding a uint64 value as a Uint64.
  1018. func sizeUint64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  1019. v := ival.(uint64)
  1020. return tagsize + wire.SizeVarint(v)
  1021. }
  1022. // appendUint64Iface encodes a uint64 value as a Uint64.
  1023. func appendUint64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1024. v := ival.(uint64)
  1025. b = wire.AppendVarint(b, wiretag)
  1026. b = wire.AppendVarint(b, v)
  1027. return b, nil
  1028. }
  1029. var coderUint64Iface = ifaceCoderFuncs{
  1030. size: sizeUint64Iface,
  1031. marshal: appendUint64Iface,
  1032. }
  1033. // sizeUint64SliceIface returns the size of wire encoding a []uint64 value as a repeated Uint64.
  1034. func sizeUint64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1035. s := *ival.(*[]uint64)
  1036. for _, v := range s {
  1037. size += tagsize + wire.SizeVarint(v)
  1038. }
  1039. return size
  1040. }
  1041. // appendUint64SliceIface encodes a []uint64 value as a repeated Uint64.
  1042. func appendUint64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1043. s := *ival.(*[]uint64)
  1044. for _, v := range s {
  1045. b = wire.AppendVarint(b, wiretag)
  1046. b = wire.AppendVarint(b, v)
  1047. }
  1048. return b, nil
  1049. }
  1050. var coderUint64SliceIface = ifaceCoderFuncs{
  1051. size: sizeUint64SliceIface,
  1052. marshal: appendUint64SliceIface,
  1053. }
  1054. // sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
  1055. func sizeSfixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
  1056. return tagsize + wire.SizeFixed32()
  1057. }
  1058. // appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
  1059. func appendSfixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1060. v := *p.Int32()
  1061. b = wire.AppendVarint(b, wiretag)
  1062. b = wire.AppendFixed32(b, uint32(v))
  1063. return b, nil
  1064. }
  1065. var coderSfixed32 = pointerCoderFuncs{
  1066. size: sizeSfixed32,
  1067. marshal: appendSfixed32,
  1068. }
  1069. // sizeSfixed32 returns the size of wire encoding a int32 pointer as a Sfixed32.
  1070. // The zero value is not encoded.
  1071. func sizeSfixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1072. v := *p.Int32()
  1073. if v == 0 {
  1074. return 0
  1075. }
  1076. return tagsize + wire.SizeFixed32()
  1077. }
  1078. // appendSfixed32 wire encodes a int32 pointer as a Sfixed32.
  1079. // The zero value is not encoded.
  1080. func appendSfixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1081. v := *p.Int32()
  1082. if v == 0 {
  1083. return b, nil
  1084. }
  1085. b = wire.AppendVarint(b, wiretag)
  1086. b = wire.AppendFixed32(b, uint32(v))
  1087. return b, nil
  1088. }
  1089. var coderSfixed32NoZero = pointerCoderFuncs{
  1090. size: sizeSfixed32NoZero,
  1091. marshal: appendSfixed32NoZero,
  1092. }
  1093. // sizeSfixed32Ptr returns the size of wire encoding a *int32 pointer as a Sfixed32.
  1094. // It panics if the pointer is nil.
  1095. func sizeSfixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1096. return tagsize + wire.SizeFixed32()
  1097. }
  1098. // appendSfixed32 wire encodes a *int32 pointer as a Sfixed32.
  1099. // It panics if the pointer is nil.
  1100. func appendSfixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1101. v := **p.Int32Ptr()
  1102. b = wire.AppendVarint(b, wiretag)
  1103. b = wire.AppendFixed32(b, uint32(v))
  1104. return b, nil
  1105. }
  1106. var coderSfixed32Ptr = pointerCoderFuncs{
  1107. size: sizeSfixed32Ptr,
  1108. marshal: appendSfixed32Ptr,
  1109. }
  1110. // sizeSfixed32Slice returns the size of wire encoding a []int32 pointer as a repeated Sfixed32.
  1111. func sizeSfixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1112. s := *p.Int32Slice()
  1113. size = len(s) * (tagsize + wire.SizeFixed32())
  1114. return size
  1115. }
  1116. // appendSfixed32Slice encodes a []int32 pointer as a repeated Sfixed32.
  1117. func appendSfixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1118. s := *p.Int32Slice()
  1119. for _, v := range s {
  1120. b = wire.AppendVarint(b, wiretag)
  1121. b = wire.AppendFixed32(b, uint32(v))
  1122. }
  1123. return b, nil
  1124. }
  1125. var coderSfixed32Slice = pointerCoderFuncs{
  1126. size: sizeSfixed32Slice,
  1127. marshal: appendSfixed32Slice,
  1128. }
  1129. // sizeSfixed32PackedSlice returns the size of wire encoding a []int32 pointer as a packed repeated Sfixed32.
  1130. func sizeSfixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1131. s := *p.Int32Slice()
  1132. if len(s) == 0 {
  1133. return 0
  1134. }
  1135. n := len(s) * wire.SizeFixed32()
  1136. return tagsize + wire.SizeBytes(n)
  1137. }
  1138. // appendSfixed32PackedSlice encodes a []int32 pointer as a packed repeated Sfixed32.
  1139. func appendSfixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1140. s := *p.Int32Slice()
  1141. if len(s) == 0 {
  1142. return b, nil
  1143. }
  1144. b = wire.AppendVarint(b, wiretag)
  1145. n := len(s) * wire.SizeFixed32()
  1146. b = wire.AppendVarint(b, uint64(n))
  1147. for _, v := range s {
  1148. b = wire.AppendFixed32(b, uint32(v))
  1149. }
  1150. return b, nil
  1151. }
  1152. var coderSfixed32PackedSlice = pointerCoderFuncs{
  1153. size: sizeSfixed32PackedSlice,
  1154. marshal: appendSfixed32PackedSlice,
  1155. }
  1156. // sizeSfixed32Iface returns the size of wire encoding a int32 value as a Sfixed32.
  1157. func sizeSfixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  1158. return tagsize + wire.SizeFixed32()
  1159. }
  1160. // appendSfixed32Iface encodes a int32 value as a Sfixed32.
  1161. func appendSfixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1162. v := ival.(int32)
  1163. b = wire.AppendVarint(b, wiretag)
  1164. b = wire.AppendFixed32(b, uint32(v))
  1165. return b, nil
  1166. }
  1167. var coderSfixed32Iface = ifaceCoderFuncs{
  1168. size: sizeSfixed32Iface,
  1169. marshal: appendSfixed32Iface,
  1170. }
  1171. // sizeSfixed32SliceIface returns the size of wire encoding a []int32 value as a repeated Sfixed32.
  1172. func sizeSfixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1173. s := *ival.(*[]int32)
  1174. size = len(s) * (tagsize + wire.SizeFixed32())
  1175. return size
  1176. }
  1177. // appendSfixed32SliceIface encodes a []int32 value as a repeated Sfixed32.
  1178. func appendSfixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1179. s := *ival.(*[]int32)
  1180. for _, v := range s {
  1181. b = wire.AppendVarint(b, wiretag)
  1182. b = wire.AppendFixed32(b, uint32(v))
  1183. }
  1184. return b, nil
  1185. }
  1186. var coderSfixed32SliceIface = ifaceCoderFuncs{
  1187. size: sizeSfixed32SliceIface,
  1188. marshal: appendSfixed32SliceIface,
  1189. }
  1190. // sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
  1191. func sizeFixed32(p pointer, tagsize int, _ marshalOptions) (size int) {
  1192. return tagsize + wire.SizeFixed32()
  1193. }
  1194. // appendFixed32 wire encodes a uint32 pointer as a Fixed32.
  1195. func appendFixed32(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1196. v := *p.Uint32()
  1197. b = wire.AppendVarint(b, wiretag)
  1198. b = wire.AppendFixed32(b, v)
  1199. return b, nil
  1200. }
  1201. var coderFixed32 = pointerCoderFuncs{
  1202. size: sizeFixed32,
  1203. marshal: appendFixed32,
  1204. }
  1205. // sizeFixed32 returns the size of wire encoding a uint32 pointer as a Fixed32.
  1206. // The zero value is not encoded.
  1207. func sizeFixed32NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1208. v := *p.Uint32()
  1209. if v == 0 {
  1210. return 0
  1211. }
  1212. return tagsize + wire.SizeFixed32()
  1213. }
  1214. // appendFixed32 wire encodes a uint32 pointer as a Fixed32.
  1215. // The zero value is not encoded.
  1216. func appendFixed32NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1217. v := *p.Uint32()
  1218. if v == 0 {
  1219. return b, nil
  1220. }
  1221. b = wire.AppendVarint(b, wiretag)
  1222. b = wire.AppendFixed32(b, v)
  1223. return b, nil
  1224. }
  1225. var coderFixed32NoZero = pointerCoderFuncs{
  1226. size: sizeFixed32NoZero,
  1227. marshal: appendFixed32NoZero,
  1228. }
  1229. // sizeFixed32Ptr returns the size of wire encoding a *uint32 pointer as a Fixed32.
  1230. // It panics if the pointer is nil.
  1231. func sizeFixed32Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1232. return tagsize + wire.SizeFixed32()
  1233. }
  1234. // appendFixed32 wire encodes a *uint32 pointer as a Fixed32.
  1235. // It panics if the pointer is nil.
  1236. func appendFixed32Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1237. v := **p.Uint32Ptr()
  1238. b = wire.AppendVarint(b, wiretag)
  1239. b = wire.AppendFixed32(b, v)
  1240. return b, nil
  1241. }
  1242. var coderFixed32Ptr = pointerCoderFuncs{
  1243. size: sizeFixed32Ptr,
  1244. marshal: appendFixed32Ptr,
  1245. }
  1246. // sizeFixed32Slice returns the size of wire encoding a []uint32 pointer as a repeated Fixed32.
  1247. func sizeFixed32Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1248. s := *p.Uint32Slice()
  1249. size = len(s) * (tagsize + wire.SizeFixed32())
  1250. return size
  1251. }
  1252. // appendFixed32Slice encodes a []uint32 pointer as a repeated Fixed32.
  1253. func appendFixed32Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1254. s := *p.Uint32Slice()
  1255. for _, v := range s {
  1256. b = wire.AppendVarint(b, wiretag)
  1257. b = wire.AppendFixed32(b, v)
  1258. }
  1259. return b, nil
  1260. }
  1261. var coderFixed32Slice = pointerCoderFuncs{
  1262. size: sizeFixed32Slice,
  1263. marshal: appendFixed32Slice,
  1264. }
  1265. // sizeFixed32PackedSlice returns the size of wire encoding a []uint32 pointer as a packed repeated Fixed32.
  1266. func sizeFixed32PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1267. s := *p.Uint32Slice()
  1268. if len(s) == 0 {
  1269. return 0
  1270. }
  1271. n := len(s) * wire.SizeFixed32()
  1272. return tagsize + wire.SizeBytes(n)
  1273. }
  1274. // appendFixed32PackedSlice encodes a []uint32 pointer as a packed repeated Fixed32.
  1275. func appendFixed32PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1276. s := *p.Uint32Slice()
  1277. if len(s) == 0 {
  1278. return b, nil
  1279. }
  1280. b = wire.AppendVarint(b, wiretag)
  1281. n := len(s) * wire.SizeFixed32()
  1282. b = wire.AppendVarint(b, uint64(n))
  1283. for _, v := range s {
  1284. b = wire.AppendFixed32(b, v)
  1285. }
  1286. return b, nil
  1287. }
  1288. var coderFixed32PackedSlice = pointerCoderFuncs{
  1289. size: sizeFixed32PackedSlice,
  1290. marshal: appendFixed32PackedSlice,
  1291. }
  1292. // sizeFixed32Iface returns the size of wire encoding a uint32 value as a Fixed32.
  1293. func sizeFixed32Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  1294. return tagsize + wire.SizeFixed32()
  1295. }
  1296. // appendFixed32Iface encodes a uint32 value as a Fixed32.
  1297. func appendFixed32Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1298. v := ival.(uint32)
  1299. b = wire.AppendVarint(b, wiretag)
  1300. b = wire.AppendFixed32(b, v)
  1301. return b, nil
  1302. }
  1303. var coderFixed32Iface = ifaceCoderFuncs{
  1304. size: sizeFixed32Iface,
  1305. marshal: appendFixed32Iface,
  1306. }
  1307. // sizeFixed32SliceIface returns the size of wire encoding a []uint32 value as a repeated Fixed32.
  1308. func sizeFixed32SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1309. s := *ival.(*[]uint32)
  1310. size = len(s) * (tagsize + wire.SizeFixed32())
  1311. return size
  1312. }
  1313. // appendFixed32SliceIface encodes a []uint32 value as a repeated Fixed32.
  1314. func appendFixed32SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1315. s := *ival.(*[]uint32)
  1316. for _, v := range s {
  1317. b = wire.AppendVarint(b, wiretag)
  1318. b = wire.AppendFixed32(b, v)
  1319. }
  1320. return b, nil
  1321. }
  1322. var coderFixed32SliceIface = ifaceCoderFuncs{
  1323. size: sizeFixed32SliceIface,
  1324. marshal: appendFixed32SliceIface,
  1325. }
  1326. // sizeFloat returns the size of wire encoding a float32 pointer as a Float.
  1327. func sizeFloat(p pointer, tagsize int, _ marshalOptions) (size int) {
  1328. return tagsize + wire.SizeFixed32()
  1329. }
  1330. // appendFloat wire encodes a float32 pointer as a Float.
  1331. func appendFloat(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1332. v := *p.Float32()
  1333. b = wire.AppendVarint(b, wiretag)
  1334. b = wire.AppendFixed32(b, math.Float32bits(v))
  1335. return b, nil
  1336. }
  1337. var coderFloat = pointerCoderFuncs{
  1338. size: sizeFloat,
  1339. marshal: appendFloat,
  1340. }
  1341. // sizeFloat returns the size of wire encoding a float32 pointer as a Float.
  1342. // The zero value is not encoded.
  1343. func sizeFloatNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1344. v := *p.Float32()
  1345. if v == 0 && !math.Signbit(float64(v)) {
  1346. return 0
  1347. }
  1348. return tagsize + wire.SizeFixed32()
  1349. }
  1350. // appendFloat wire encodes a float32 pointer as a Float.
  1351. // The zero value is not encoded.
  1352. func appendFloatNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1353. v := *p.Float32()
  1354. if v == 0 && !math.Signbit(float64(v)) {
  1355. return b, nil
  1356. }
  1357. b = wire.AppendVarint(b, wiretag)
  1358. b = wire.AppendFixed32(b, math.Float32bits(v))
  1359. return b, nil
  1360. }
  1361. var coderFloatNoZero = pointerCoderFuncs{
  1362. size: sizeFloatNoZero,
  1363. marshal: appendFloatNoZero,
  1364. }
  1365. // sizeFloatPtr returns the size of wire encoding a *float32 pointer as a Float.
  1366. // It panics if the pointer is nil.
  1367. func sizeFloatPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1368. return tagsize + wire.SizeFixed32()
  1369. }
  1370. // appendFloat wire encodes a *float32 pointer as a Float.
  1371. // It panics if the pointer is nil.
  1372. func appendFloatPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1373. v := **p.Float32Ptr()
  1374. b = wire.AppendVarint(b, wiretag)
  1375. b = wire.AppendFixed32(b, math.Float32bits(v))
  1376. return b, nil
  1377. }
  1378. var coderFloatPtr = pointerCoderFuncs{
  1379. size: sizeFloatPtr,
  1380. marshal: appendFloatPtr,
  1381. }
  1382. // sizeFloatSlice returns the size of wire encoding a []float32 pointer as a repeated Float.
  1383. func sizeFloatSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1384. s := *p.Float32Slice()
  1385. size = len(s) * (tagsize + wire.SizeFixed32())
  1386. return size
  1387. }
  1388. // appendFloatSlice encodes a []float32 pointer as a repeated Float.
  1389. func appendFloatSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1390. s := *p.Float32Slice()
  1391. for _, v := range s {
  1392. b = wire.AppendVarint(b, wiretag)
  1393. b = wire.AppendFixed32(b, math.Float32bits(v))
  1394. }
  1395. return b, nil
  1396. }
  1397. var coderFloatSlice = pointerCoderFuncs{
  1398. size: sizeFloatSlice,
  1399. marshal: appendFloatSlice,
  1400. }
  1401. // sizeFloatPackedSlice returns the size of wire encoding a []float32 pointer as a packed repeated Float.
  1402. func sizeFloatPackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1403. s := *p.Float32Slice()
  1404. if len(s) == 0 {
  1405. return 0
  1406. }
  1407. n := len(s) * wire.SizeFixed32()
  1408. return tagsize + wire.SizeBytes(n)
  1409. }
  1410. // appendFloatPackedSlice encodes a []float32 pointer as a packed repeated Float.
  1411. func appendFloatPackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1412. s := *p.Float32Slice()
  1413. if len(s) == 0 {
  1414. return b, nil
  1415. }
  1416. b = wire.AppendVarint(b, wiretag)
  1417. n := len(s) * wire.SizeFixed32()
  1418. b = wire.AppendVarint(b, uint64(n))
  1419. for _, v := range s {
  1420. b = wire.AppendFixed32(b, math.Float32bits(v))
  1421. }
  1422. return b, nil
  1423. }
  1424. var coderFloatPackedSlice = pointerCoderFuncs{
  1425. size: sizeFloatPackedSlice,
  1426. marshal: appendFloatPackedSlice,
  1427. }
  1428. // sizeFloatIface returns the size of wire encoding a float32 value as a Float.
  1429. func sizeFloatIface(ival interface{}, tagsize int, _ marshalOptions) int {
  1430. return tagsize + wire.SizeFixed32()
  1431. }
  1432. // appendFloatIface encodes a float32 value as a Float.
  1433. func appendFloatIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1434. v := ival.(float32)
  1435. b = wire.AppendVarint(b, wiretag)
  1436. b = wire.AppendFixed32(b, math.Float32bits(v))
  1437. return b, nil
  1438. }
  1439. var coderFloatIface = ifaceCoderFuncs{
  1440. size: sizeFloatIface,
  1441. marshal: appendFloatIface,
  1442. }
  1443. // sizeFloatSliceIface returns the size of wire encoding a []float32 value as a repeated Float.
  1444. func sizeFloatSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1445. s := *ival.(*[]float32)
  1446. size = len(s) * (tagsize + wire.SizeFixed32())
  1447. return size
  1448. }
  1449. // appendFloatSliceIface encodes a []float32 value as a repeated Float.
  1450. func appendFloatSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1451. s := *ival.(*[]float32)
  1452. for _, v := range s {
  1453. b = wire.AppendVarint(b, wiretag)
  1454. b = wire.AppendFixed32(b, math.Float32bits(v))
  1455. }
  1456. return b, nil
  1457. }
  1458. var coderFloatSliceIface = ifaceCoderFuncs{
  1459. size: sizeFloatSliceIface,
  1460. marshal: appendFloatSliceIface,
  1461. }
  1462. // sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
  1463. func sizeSfixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
  1464. return tagsize + wire.SizeFixed64()
  1465. }
  1466. // appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
  1467. func appendSfixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1468. v := *p.Int64()
  1469. b = wire.AppendVarint(b, wiretag)
  1470. b = wire.AppendFixed64(b, uint64(v))
  1471. return b, nil
  1472. }
  1473. var coderSfixed64 = pointerCoderFuncs{
  1474. size: sizeSfixed64,
  1475. marshal: appendSfixed64,
  1476. }
  1477. // sizeSfixed64 returns the size of wire encoding a int64 pointer as a Sfixed64.
  1478. // The zero value is not encoded.
  1479. func sizeSfixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1480. v := *p.Int64()
  1481. if v == 0 {
  1482. return 0
  1483. }
  1484. return tagsize + wire.SizeFixed64()
  1485. }
  1486. // appendSfixed64 wire encodes a int64 pointer as a Sfixed64.
  1487. // The zero value is not encoded.
  1488. func appendSfixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1489. v := *p.Int64()
  1490. if v == 0 {
  1491. return b, nil
  1492. }
  1493. b = wire.AppendVarint(b, wiretag)
  1494. b = wire.AppendFixed64(b, uint64(v))
  1495. return b, nil
  1496. }
  1497. var coderSfixed64NoZero = pointerCoderFuncs{
  1498. size: sizeSfixed64NoZero,
  1499. marshal: appendSfixed64NoZero,
  1500. }
  1501. // sizeSfixed64Ptr returns the size of wire encoding a *int64 pointer as a Sfixed64.
  1502. // It panics if the pointer is nil.
  1503. func sizeSfixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1504. return tagsize + wire.SizeFixed64()
  1505. }
  1506. // appendSfixed64 wire encodes a *int64 pointer as a Sfixed64.
  1507. // It panics if the pointer is nil.
  1508. func appendSfixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1509. v := **p.Int64Ptr()
  1510. b = wire.AppendVarint(b, wiretag)
  1511. b = wire.AppendFixed64(b, uint64(v))
  1512. return b, nil
  1513. }
  1514. var coderSfixed64Ptr = pointerCoderFuncs{
  1515. size: sizeSfixed64Ptr,
  1516. marshal: appendSfixed64Ptr,
  1517. }
  1518. // sizeSfixed64Slice returns the size of wire encoding a []int64 pointer as a repeated Sfixed64.
  1519. func sizeSfixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1520. s := *p.Int64Slice()
  1521. size = len(s) * (tagsize + wire.SizeFixed64())
  1522. return size
  1523. }
  1524. // appendSfixed64Slice encodes a []int64 pointer as a repeated Sfixed64.
  1525. func appendSfixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1526. s := *p.Int64Slice()
  1527. for _, v := range s {
  1528. b = wire.AppendVarint(b, wiretag)
  1529. b = wire.AppendFixed64(b, uint64(v))
  1530. }
  1531. return b, nil
  1532. }
  1533. var coderSfixed64Slice = pointerCoderFuncs{
  1534. size: sizeSfixed64Slice,
  1535. marshal: appendSfixed64Slice,
  1536. }
  1537. // sizeSfixed64PackedSlice returns the size of wire encoding a []int64 pointer as a packed repeated Sfixed64.
  1538. func sizeSfixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1539. s := *p.Int64Slice()
  1540. if len(s) == 0 {
  1541. return 0
  1542. }
  1543. n := len(s) * wire.SizeFixed64()
  1544. return tagsize + wire.SizeBytes(n)
  1545. }
  1546. // appendSfixed64PackedSlice encodes a []int64 pointer as a packed repeated Sfixed64.
  1547. func appendSfixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1548. s := *p.Int64Slice()
  1549. if len(s) == 0 {
  1550. return b, nil
  1551. }
  1552. b = wire.AppendVarint(b, wiretag)
  1553. n := len(s) * wire.SizeFixed64()
  1554. b = wire.AppendVarint(b, uint64(n))
  1555. for _, v := range s {
  1556. b = wire.AppendFixed64(b, uint64(v))
  1557. }
  1558. return b, nil
  1559. }
  1560. var coderSfixed64PackedSlice = pointerCoderFuncs{
  1561. size: sizeSfixed64PackedSlice,
  1562. marshal: appendSfixed64PackedSlice,
  1563. }
  1564. // sizeSfixed64Iface returns the size of wire encoding a int64 value as a Sfixed64.
  1565. func sizeSfixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  1566. return tagsize + wire.SizeFixed64()
  1567. }
  1568. // appendSfixed64Iface encodes a int64 value as a Sfixed64.
  1569. func appendSfixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1570. v := ival.(int64)
  1571. b = wire.AppendVarint(b, wiretag)
  1572. b = wire.AppendFixed64(b, uint64(v))
  1573. return b, nil
  1574. }
  1575. var coderSfixed64Iface = ifaceCoderFuncs{
  1576. size: sizeSfixed64Iface,
  1577. marshal: appendSfixed64Iface,
  1578. }
  1579. // sizeSfixed64SliceIface returns the size of wire encoding a []int64 value as a repeated Sfixed64.
  1580. func sizeSfixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1581. s := *ival.(*[]int64)
  1582. size = len(s) * (tagsize + wire.SizeFixed64())
  1583. return size
  1584. }
  1585. // appendSfixed64SliceIface encodes a []int64 value as a repeated Sfixed64.
  1586. func appendSfixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1587. s := *ival.(*[]int64)
  1588. for _, v := range s {
  1589. b = wire.AppendVarint(b, wiretag)
  1590. b = wire.AppendFixed64(b, uint64(v))
  1591. }
  1592. return b, nil
  1593. }
  1594. var coderSfixed64SliceIface = ifaceCoderFuncs{
  1595. size: sizeSfixed64SliceIface,
  1596. marshal: appendSfixed64SliceIface,
  1597. }
  1598. // sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
  1599. func sizeFixed64(p pointer, tagsize int, _ marshalOptions) (size int) {
  1600. return tagsize + wire.SizeFixed64()
  1601. }
  1602. // appendFixed64 wire encodes a uint64 pointer as a Fixed64.
  1603. func appendFixed64(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1604. v := *p.Uint64()
  1605. b = wire.AppendVarint(b, wiretag)
  1606. b = wire.AppendFixed64(b, v)
  1607. return b, nil
  1608. }
  1609. var coderFixed64 = pointerCoderFuncs{
  1610. size: sizeFixed64,
  1611. marshal: appendFixed64,
  1612. }
  1613. // sizeFixed64 returns the size of wire encoding a uint64 pointer as a Fixed64.
  1614. // The zero value is not encoded.
  1615. func sizeFixed64NoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1616. v := *p.Uint64()
  1617. if v == 0 {
  1618. return 0
  1619. }
  1620. return tagsize + wire.SizeFixed64()
  1621. }
  1622. // appendFixed64 wire encodes a uint64 pointer as a Fixed64.
  1623. // The zero value is not encoded.
  1624. func appendFixed64NoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1625. v := *p.Uint64()
  1626. if v == 0 {
  1627. return b, nil
  1628. }
  1629. b = wire.AppendVarint(b, wiretag)
  1630. b = wire.AppendFixed64(b, v)
  1631. return b, nil
  1632. }
  1633. var coderFixed64NoZero = pointerCoderFuncs{
  1634. size: sizeFixed64NoZero,
  1635. marshal: appendFixed64NoZero,
  1636. }
  1637. // sizeFixed64Ptr returns the size of wire encoding a *uint64 pointer as a Fixed64.
  1638. // It panics if the pointer is nil.
  1639. func sizeFixed64Ptr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1640. return tagsize + wire.SizeFixed64()
  1641. }
  1642. // appendFixed64 wire encodes a *uint64 pointer as a Fixed64.
  1643. // It panics if the pointer is nil.
  1644. func appendFixed64Ptr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1645. v := **p.Uint64Ptr()
  1646. b = wire.AppendVarint(b, wiretag)
  1647. b = wire.AppendFixed64(b, v)
  1648. return b, nil
  1649. }
  1650. var coderFixed64Ptr = pointerCoderFuncs{
  1651. size: sizeFixed64Ptr,
  1652. marshal: appendFixed64Ptr,
  1653. }
  1654. // sizeFixed64Slice returns the size of wire encoding a []uint64 pointer as a repeated Fixed64.
  1655. func sizeFixed64Slice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1656. s := *p.Uint64Slice()
  1657. size = len(s) * (tagsize + wire.SizeFixed64())
  1658. return size
  1659. }
  1660. // appendFixed64Slice encodes a []uint64 pointer as a repeated Fixed64.
  1661. func appendFixed64Slice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1662. s := *p.Uint64Slice()
  1663. for _, v := range s {
  1664. b = wire.AppendVarint(b, wiretag)
  1665. b = wire.AppendFixed64(b, v)
  1666. }
  1667. return b, nil
  1668. }
  1669. var coderFixed64Slice = pointerCoderFuncs{
  1670. size: sizeFixed64Slice,
  1671. marshal: appendFixed64Slice,
  1672. }
  1673. // sizeFixed64PackedSlice returns the size of wire encoding a []uint64 pointer as a packed repeated Fixed64.
  1674. func sizeFixed64PackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1675. s := *p.Uint64Slice()
  1676. if len(s) == 0 {
  1677. return 0
  1678. }
  1679. n := len(s) * wire.SizeFixed64()
  1680. return tagsize + wire.SizeBytes(n)
  1681. }
  1682. // appendFixed64PackedSlice encodes a []uint64 pointer as a packed repeated Fixed64.
  1683. func appendFixed64PackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1684. s := *p.Uint64Slice()
  1685. if len(s) == 0 {
  1686. return b, nil
  1687. }
  1688. b = wire.AppendVarint(b, wiretag)
  1689. n := len(s) * wire.SizeFixed64()
  1690. b = wire.AppendVarint(b, uint64(n))
  1691. for _, v := range s {
  1692. b = wire.AppendFixed64(b, v)
  1693. }
  1694. return b, nil
  1695. }
  1696. var coderFixed64PackedSlice = pointerCoderFuncs{
  1697. size: sizeFixed64PackedSlice,
  1698. marshal: appendFixed64PackedSlice,
  1699. }
  1700. // sizeFixed64Iface returns the size of wire encoding a uint64 value as a Fixed64.
  1701. func sizeFixed64Iface(ival interface{}, tagsize int, _ marshalOptions) int {
  1702. return tagsize + wire.SizeFixed64()
  1703. }
  1704. // appendFixed64Iface encodes a uint64 value as a Fixed64.
  1705. func appendFixed64Iface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1706. v := ival.(uint64)
  1707. b = wire.AppendVarint(b, wiretag)
  1708. b = wire.AppendFixed64(b, v)
  1709. return b, nil
  1710. }
  1711. var coderFixed64Iface = ifaceCoderFuncs{
  1712. size: sizeFixed64Iface,
  1713. marshal: appendFixed64Iface,
  1714. }
  1715. // sizeFixed64SliceIface returns the size of wire encoding a []uint64 value as a repeated Fixed64.
  1716. func sizeFixed64SliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1717. s := *ival.(*[]uint64)
  1718. size = len(s) * (tagsize + wire.SizeFixed64())
  1719. return size
  1720. }
  1721. // appendFixed64SliceIface encodes a []uint64 value as a repeated Fixed64.
  1722. func appendFixed64SliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1723. s := *ival.(*[]uint64)
  1724. for _, v := range s {
  1725. b = wire.AppendVarint(b, wiretag)
  1726. b = wire.AppendFixed64(b, v)
  1727. }
  1728. return b, nil
  1729. }
  1730. var coderFixed64SliceIface = ifaceCoderFuncs{
  1731. size: sizeFixed64SliceIface,
  1732. marshal: appendFixed64SliceIface,
  1733. }
  1734. // sizeDouble returns the size of wire encoding a float64 pointer as a Double.
  1735. func sizeDouble(p pointer, tagsize int, _ marshalOptions) (size int) {
  1736. return tagsize + wire.SizeFixed64()
  1737. }
  1738. // appendDouble wire encodes a float64 pointer as a Double.
  1739. func appendDouble(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1740. v := *p.Float64()
  1741. b = wire.AppendVarint(b, wiretag)
  1742. b = wire.AppendFixed64(b, math.Float64bits(v))
  1743. return b, nil
  1744. }
  1745. var coderDouble = pointerCoderFuncs{
  1746. size: sizeDouble,
  1747. marshal: appendDouble,
  1748. }
  1749. // sizeDouble returns the size of wire encoding a float64 pointer as a Double.
  1750. // The zero value is not encoded.
  1751. func sizeDoubleNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1752. v := *p.Float64()
  1753. if v == 0 && !math.Signbit(float64(v)) {
  1754. return 0
  1755. }
  1756. return tagsize + wire.SizeFixed64()
  1757. }
  1758. // appendDouble wire encodes a float64 pointer as a Double.
  1759. // The zero value is not encoded.
  1760. func appendDoubleNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1761. v := *p.Float64()
  1762. if v == 0 && !math.Signbit(float64(v)) {
  1763. return b, nil
  1764. }
  1765. b = wire.AppendVarint(b, wiretag)
  1766. b = wire.AppendFixed64(b, math.Float64bits(v))
  1767. return b, nil
  1768. }
  1769. var coderDoubleNoZero = pointerCoderFuncs{
  1770. size: sizeDoubleNoZero,
  1771. marshal: appendDoubleNoZero,
  1772. }
  1773. // sizeDoublePtr returns the size of wire encoding a *float64 pointer as a Double.
  1774. // It panics if the pointer is nil.
  1775. func sizeDoublePtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1776. return tagsize + wire.SizeFixed64()
  1777. }
  1778. // appendDouble wire encodes a *float64 pointer as a Double.
  1779. // It panics if the pointer is nil.
  1780. func appendDoublePtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1781. v := **p.Float64Ptr()
  1782. b = wire.AppendVarint(b, wiretag)
  1783. b = wire.AppendFixed64(b, math.Float64bits(v))
  1784. return b, nil
  1785. }
  1786. var coderDoublePtr = pointerCoderFuncs{
  1787. size: sizeDoublePtr,
  1788. marshal: appendDoublePtr,
  1789. }
  1790. // sizeDoubleSlice returns the size of wire encoding a []float64 pointer as a repeated Double.
  1791. func sizeDoubleSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1792. s := *p.Float64Slice()
  1793. size = len(s) * (tagsize + wire.SizeFixed64())
  1794. return size
  1795. }
  1796. // appendDoubleSlice encodes a []float64 pointer as a repeated Double.
  1797. func appendDoubleSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1798. s := *p.Float64Slice()
  1799. for _, v := range s {
  1800. b = wire.AppendVarint(b, wiretag)
  1801. b = wire.AppendFixed64(b, math.Float64bits(v))
  1802. }
  1803. return b, nil
  1804. }
  1805. var coderDoubleSlice = pointerCoderFuncs{
  1806. size: sizeDoubleSlice,
  1807. marshal: appendDoubleSlice,
  1808. }
  1809. // sizeDoublePackedSlice returns the size of wire encoding a []float64 pointer as a packed repeated Double.
  1810. func sizeDoublePackedSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1811. s := *p.Float64Slice()
  1812. if len(s) == 0 {
  1813. return 0
  1814. }
  1815. n := len(s) * wire.SizeFixed64()
  1816. return tagsize + wire.SizeBytes(n)
  1817. }
  1818. // appendDoublePackedSlice encodes a []float64 pointer as a packed repeated Double.
  1819. func appendDoublePackedSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1820. s := *p.Float64Slice()
  1821. if len(s) == 0 {
  1822. return b, nil
  1823. }
  1824. b = wire.AppendVarint(b, wiretag)
  1825. n := len(s) * wire.SizeFixed64()
  1826. b = wire.AppendVarint(b, uint64(n))
  1827. for _, v := range s {
  1828. b = wire.AppendFixed64(b, math.Float64bits(v))
  1829. }
  1830. return b, nil
  1831. }
  1832. var coderDoublePackedSlice = pointerCoderFuncs{
  1833. size: sizeDoublePackedSlice,
  1834. marshal: appendDoublePackedSlice,
  1835. }
  1836. // sizeDoubleIface returns the size of wire encoding a float64 value as a Double.
  1837. func sizeDoubleIface(ival interface{}, tagsize int, _ marshalOptions) int {
  1838. return tagsize + wire.SizeFixed64()
  1839. }
  1840. // appendDoubleIface encodes a float64 value as a Double.
  1841. func appendDoubleIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1842. v := ival.(float64)
  1843. b = wire.AppendVarint(b, wiretag)
  1844. b = wire.AppendFixed64(b, math.Float64bits(v))
  1845. return b, nil
  1846. }
  1847. var coderDoubleIface = ifaceCoderFuncs{
  1848. size: sizeDoubleIface,
  1849. marshal: appendDoubleIface,
  1850. }
  1851. // sizeDoubleSliceIface returns the size of wire encoding a []float64 value as a repeated Double.
  1852. func sizeDoubleSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1853. s := *ival.(*[]float64)
  1854. size = len(s) * (tagsize + wire.SizeFixed64())
  1855. return size
  1856. }
  1857. // appendDoubleSliceIface encodes a []float64 value as a repeated Double.
  1858. func appendDoubleSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1859. s := *ival.(*[]float64)
  1860. for _, v := range s {
  1861. b = wire.AppendVarint(b, wiretag)
  1862. b = wire.AppendFixed64(b, math.Float64bits(v))
  1863. }
  1864. return b, nil
  1865. }
  1866. var coderDoubleSliceIface = ifaceCoderFuncs{
  1867. size: sizeDoubleSliceIface,
  1868. marshal: appendDoubleSliceIface,
  1869. }
  1870. // sizeString returns the size of wire encoding a string pointer as a String.
  1871. func sizeString(p pointer, tagsize int, _ marshalOptions) (size int) {
  1872. v := *p.String()
  1873. return tagsize + wire.SizeBytes(len(v))
  1874. }
  1875. // appendString wire encodes a string pointer as a String.
  1876. func appendString(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1877. v := *p.String()
  1878. b = wire.AppendVarint(b, wiretag)
  1879. b = wire.AppendString(b, v)
  1880. return b, nil
  1881. }
  1882. var coderString = pointerCoderFuncs{
  1883. size: sizeString,
  1884. marshal: appendString,
  1885. }
  1886. // sizeString returns the size of wire encoding a string pointer as a String.
  1887. // The zero value is not encoded.
  1888. func sizeStringNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  1889. v := *p.String()
  1890. if len(v) == 0 {
  1891. return 0
  1892. }
  1893. return tagsize + wire.SizeBytes(len(v))
  1894. }
  1895. // appendString wire encodes a string pointer as a String.
  1896. // The zero value is not encoded.
  1897. func appendStringNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1898. v := *p.String()
  1899. if len(v) == 0 {
  1900. return b, nil
  1901. }
  1902. b = wire.AppendVarint(b, wiretag)
  1903. b = wire.AppendString(b, v)
  1904. return b, nil
  1905. }
  1906. var coderStringNoZero = pointerCoderFuncs{
  1907. size: sizeStringNoZero,
  1908. marshal: appendStringNoZero,
  1909. }
  1910. // sizeStringPtr returns the size of wire encoding a *string pointer as a String.
  1911. // It panics if the pointer is nil.
  1912. func sizeStringPtr(p pointer, tagsize int, _ marshalOptions) (size int) {
  1913. v := **p.StringPtr()
  1914. return tagsize + wire.SizeBytes(len(v))
  1915. }
  1916. // appendString wire encodes a *string pointer as a String.
  1917. // It panics if the pointer is nil.
  1918. func appendStringPtr(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1919. v := **p.StringPtr()
  1920. b = wire.AppendVarint(b, wiretag)
  1921. b = wire.AppendString(b, v)
  1922. return b, nil
  1923. }
  1924. var coderStringPtr = pointerCoderFuncs{
  1925. size: sizeStringPtr,
  1926. marshal: appendStringPtr,
  1927. }
  1928. // sizeStringSlice returns the size of wire encoding a []string pointer as a repeated String.
  1929. func sizeStringSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  1930. s := *p.StringSlice()
  1931. for _, v := range s {
  1932. size += tagsize + wire.SizeBytes(len(v))
  1933. }
  1934. return size
  1935. }
  1936. // appendStringSlice encodes a []string pointer as a repeated String.
  1937. func appendStringSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1938. s := *p.StringSlice()
  1939. for _, v := range s {
  1940. b = wire.AppendVarint(b, wiretag)
  1941. b = wire.AppendString(b, v)
  1942. }
  1943. return b, nil
  1944. }
  1945. var coderStringSlice = pointerCoderFuncs{
  1946. size: sizeStringSlice,
  1947. marshal: appendStringSlice,
  1948. }
  1949. // sizeStringIface returns the size of wire encoding a string value as a String.
  1950. func sizeStringIface(ival interface{}, tagsize int, _ marshalOptions) int {
  1951. v := ival.(string)
  1952. return tagsize + wire.SizeBytes(len(v))
  1953. }
  1954. // appendStringIface encodes a string value as a String.
  1955. func appendStringIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1956. v := ival.(string)
  1957. b = wire.AppendVarint(b, wiretag)
  1958. b = wire.AppendString(b, v)
  1959. return b, nil
  1960. }
  1961. var coderStringIface = ifaceCoderFuncs{
  1962. size: sizeStringIface,
  1963. marshal: appendStringIface,
  1964. }
  1965. // sizeStringSliceIface returns the size of wire encoding a []string value as a repeated String.
  1966. func sizeStringSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  1967. s := *ival.(*[]string)
  1968. for _, v := range s {
  1969. size += tagsize + wire.SizeBytes(len(v))
  1970. }
  1971. return size
  1972. }
  1973. // appendStringSliceIface encodes a []string value as a repeated String.
  1974. func appendStringSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1975. s := *ival.(*[]string)
  1976. for _, v := range s {
  1977. b = wire.AppendVarint(b, wiretag)
  1978. b = wire.AppendString(b, v)
  1979. }
  1980. return b, nil
  1981. }
  1982. var coderStringSliceIface = ifaceCoderFuncs{
  1983. size: sizeStringSliceIface,
  1984. marshal: appendStringSliceIface,
  1985. }
  1986. // sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
  1987. func sizeBytes(p pointer, tagsize int, _ marshalOptions) (size int) {
  1988. v := *p.Bytes()
  1989. return tagsize + wire.SizeBytes(len(v))
  1990. }
  1991. // appendBytes wire encodes a []byte pointer as a Bytes.
  1992. func appendBytes(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  1993. v := *p.Bytes()
  1994. b = wire.AppendVarint(b, wiretag)
  1995. b = wire.AppendBytes(b, v)
  1996. return b, nil
  1997. }
  1998. var coderBytes = pointerCoderFuncs{
  1999. size: sizeBytes,
  2000. marshal: appendBytes,
  2001. }
  2002. // sizeBytes returns the size of wire encoding a []byte pointer as a Bytes.
  2003. // The zero value is not encoded.
  2004. func sizeBytesNoZero(p pointer, tagsize int, _ marshalOptions) (size int) {
  2005. v := *p.Bytes()
  2006. if len(v) == 0 {
  2007. return 0
  2008. }
  2009. return tagsize + wire.SizeBytes(len(v))
  2010. }
  2011. // appendBytes wire encodes a []byte pointer as a Bytes.
  2012. // The zero value is not encoded.
  2013. func appendBytesNoZero(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2014. v := *p.Bytes()
  2015. if len(v) == 0 {
  2016. return b, nil
  2017. }
  2018. b = wire.AppendVarint(b, wiretag)
  2019. b = wire.AppendBytes(b, v)
  2020. return b, nil
  2021. }
  2022. var coderBytesNoZero = pointerCoderFuncs{
  2023. size: sizeBytesNoZero,
  2024. marshal: appendBytesNoZero,
  2025. }
  2026. // sizeBytesSlice returns the size of wire encoding a [][]byte pointer as a repeated Bytes.
  2027. func sizeBytesSlice(p pointer, tagsize int, _ marshalOptions) (size int) {
  2028. s := *p.BytesSlice()
  2029. for _, v := range s {
  2030. size += tagsize + wire.SizeBytes(len(v))
  2031. }
  2032. return size
  2033. }
  2034. // appendBytesSlice encodes a [][]byte pointer as a repeated Bytes.
  2035. func appendBytesSlice(b []byte, p pointer, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2036. s := *p.BytesSlice()
  2037. for _, v := range s {
  2038. b = wire.AppendVarint(b, wiretag)
  2039. b = wire.AppendBytes(b, v)
  2040. }
  2041. return b, nil
  2042. }
  2043. var coderBytesSlice = pointerCoderFuncs{
  2044. size: sizeBytesSlice,
  2045. marshal: appendBytesSlice,
  2046. }
  2047. // sizeBytesIface returns the size of wire encoding a []byte value as a Bytes.
  2048. func sizeBytesIface(ival interface{}, tagsize int, _ marshalOptions) int {
  2049. v := ival.([]byte)
  2050. return tagsize + wire.SizeBytes(len(v))
  2051. }
  2052. // appendBytesIface encodes a []byte value as a Bytes.
  2053. func appendBytesIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2054. v := ival.([]byte)
  2055. b = wire.AppendVarint(b, wiretag)
  2056. b = wire.AppendBytes(b, v)
  2057. return b, nil
  2058. }
  2059. var coderBytesIface = ifaceCoderFuncs{
  2060. size: sizeBytesIface,
  2061. marshal: appendBytesIface,
  2062. }
  2063. // sizeBytesSliceIface returns the size of wire encoding a [][]byte value as a repeated Bytes.
  2064. func sizeBytesSliceIface(ival interface{}, tagsize int, _ marshalOptions) (size int) {
  2065. s := *ival.(*[][]byte)
  2066. for _, v := range s {
  2067. size += tagsize + wire.SizeBytes(len(v))
  2068. }
  2069. return size
  2070. }
  2071. // appendBytesSliceIface encodes a [][]byte value as a repeated Bytes.
  2072. func appendBytesSliceIface(b []byte, ival interface{}, wiretag uint64, _ marshalOptions) ([]byte, error) {
  2073. s := *ival.(*[][]byte)
  2074. for _, v := range s {
  2075. b = wire.AppendVarint(b, wiretag)
  2076. b = wire.AppendBytes(b, v)
  2077. }
  2078. return b, nil
  2079. }
  2080. var coderBytesSliceIface = ifaceCoderFuncs{
  2081. size: sizeBytesSliceIface,
  2082. marshal: appendBytesSliceIface,
  2083. }
  2084. var wireTypes = map[protoreflect.Kind]wire.Type{
  2085. protoreflect.BoolKind: wire.VarintType,
  2086. protoreflect.EnumKind: wire.VarintType,
  2087. protoreflect.Int32Kind: wire.VarintType,
  2088. protoreflect.Sint32Kind: wire.VarintType,
  2089. protoreflect.Uint32Kind: wire.VarintType,
  2090. protoreflect.Int64Kind: wire.VarintType,
  2091. protoreflect.Sint64Kind: wire.VarintType,
  2092. protoreflect.Uint64Kind: wire.VarintType,
  2093. protoreflect.Sfixed32Kind: wire.Fixed32Type,
  2094. protoreflect.Fixed32Kind: wire.Fixed32Type,
  2095. protoreflect.FloatKind: wire.Fixed32Type,
  2096. protoreflect.Sfixed64Kind: wire.Fixed64Type,
  2097. protoreflect.Fixed64Kind: wire.Fixed64Type,
  2098. protoreflect.DoubleKind: wire.Fixed64Type,
  2099. protoreflect.StringKind: wire.BytesType,
  2100. protoreflect.BytesKind: wire.BytesType,
  2101. protoreflect.MessageKind: wire.BytesType,
  2102. protoreflect.GroupKind: wire.StartGroupType,
  2103. }