github.com/RomiChan/protobuf@v0.1.1-0.20230204044148-2ed269a2e54d/proto/required_codec.go (about) 1 // Code generated by gen/gen_decode.go. DO NOT EDIT. 2 3 package proto 4 5 import ( 6 "math" 7 "unsafe" 8 ) 9 10 var boolRequiredCodec = codec{size: sizeOfBoolRequired, encode: encodeBoolRequired, decode: decodeBool} 11 12 func sizeOfBoolRequired(p unsafe.Pointer, f *structField) int { 13 return 1 + int(f.tagsize) 14 } 15 func encodeBoolRequired(b []byte, p unsafe.Pointer, f *structField) []byte { 16 b = appendVarint(b, f.wiretag) 17 if *(*bool)(p) { 18 b = append(b, 1) 19 } else { 20 b = append(b, 0) 21 } 22 return b 23 } 24 25 var stringRequiredCodec = codec{size: sizeOfStringRequired, encode: encodeStringRequired, decode: decodeString} 26 27 func sizeOfStringRequired(p unsafe.Pointer, f *structField) int { 28 v := *(*string)(p) 29 return sizeOfVarlen(len(v)) + f.tagsize 30 } 31 func encodeStringRequired(b []byte, p unsafe.Pointer, f *structField) []byte { 32 v := *(*string)(p) 33 b = appendVarint(b, f.wiretag) 34 b = appendVarint(b, uint64(len(v))) 35 b = append(b, v...) 36 return b 37 } 38 39 var float32RequiredCodec = codec{size: sizeOfFloat32Required, encode: encodeFloat32Required, decode: decodeFloat32} 40 41 func sizeOfFloat32Required(p unsafe.Pointer, f *structField) int { 42 return 4 + int(f.tagsize) 43 } 44 func encodeFloat32Required(b []byte, p unsafe.Pointer, f *structField) []byte { 45 v := *(*float32)(p) 46 b = appendVarint(b, f.wiretag) 47 b = encodeLE32(b, math.Float32bits(v)) 48 return b 49 } 50 51 var float64RequiredCodec = codec{size: sizeOfFloat64Required, encode: encodeFloat64Required, decode: decodeFloat64} 52 53 func sizeOfFloat64Required(p unsafe.Pointer, f *structField) int { 54 return 8 + int(f.tagsize) 55 } 56 func encodeFloat64Required(b []byte, p unsafe.Pointer, f *structField) []byte { 57 v := *(*float64)(p) 58 b = appendVarint(b, f.wiretag) 59 b = encodeLE64(b, math.Float64bits(v)) 60 return b 61 } 62 63 var int32RequiredCodec = codec{size: sizeOfInt32Required, encode: encodeInt32Required, decode: decodeInt32} 64 65 func sizeOfInt32Required(p unsafe.Pointer, f *structField) int { 66 v := *(*int32)(p) 67 return sizeOfVarint(uint64(v)) + f.tagsize 68 } 69 func encodeInt32Required(b []byte, p unsafe.Pointer, f *structField) []byte { 70 v := *(*int32)(p) 71 b = appendVarint(b, f.wiretag) 72 b = appendVarint(b, uint64(v)) 73 return b 74 } 75 76 var int64RequiredCodec = codec{size: sizeOfInt64Required, encode: encodeInt64Required, decode: decodeInt64} 77 78 func sizeOfInt64Required(p unsafe.Pointer, f *structField) int { 79 v := *(*int64)(p) 80 return sizeOfVarint(uint64(v)) + f.tagsize 81 } 82 func encodeInt64Required(b []byte, p unsafe.Pointer, f *structField) []byte { 83 v := *(*int64)(p) 84 b = appendVarint(b, f.wiretag) 85 b = appendVarint(b, uint64(v)) 86 return b 87 } 88 89 var uint32RequiredCodec = codec{size: sizeOfUint32Required, encode: encodeUint32Required, decode: decodeUint32} 90 91 func sizeOfUint32Required(p unsafe.Pointer, f *structField) int { 92 v := *(*uint32)(p) 93 return sizeOfVarint(uint64(v)) + f.tagsize 94 } 95 func encodeUint32Required(b []byte, p unsafe.Pointer, f *structField) []byte { 96 v := *(*uint32)(p) 97 b = appendVarint(b, f.wiretag) 98 b = appendVarint(b, uint64(v)) 99 return b 100 } 101 102 var fixed32RequiredCodec = codec{size: sizeOfFixed32Required, encode: encodeFixed32Required, decode: decodeFixed32} 103 104 func sizeOfFixed32Required(p unsafe.Pointer, f *structField) int { 105 return 4 + f.tagsize 106 } 107 func encodeFixed32Required(b []byte, p unsafe.Pointer, f *structField) []byte { 108 v := *(*uint32)(p) 109 b = appendVarint(b, f.wiretag) 110 b = encodeLE32(b, v) 111 return b 112 } 113 114 var uint64RequiredCodec = codec{size: sizeOfUint64Required, encode: encodeUint64Required, decode: decodeUint64} 115 116 func sizeOfUint64Required(p unsafe.Pointer, f *structField) int { 117 v := *(*uint64)(p) 118 return sizeOfVarint(v) + f.tagsize 119 } 120 func encodeUint64Required(b []byte, p unsafe.Pointer, f *structField) []byte { 121 v := *(*uint64)(p) 122 b = appendVarint(b, f.wiretag) 123 b = appendVarint(b, v) 124 return b 125 } 126 127 var fixed64RequiredCodec = codec{size: sizeOfFixed64Required, encode: encodeFixed64Required, decode: decodeFixed64} 128 129 func sizeOfFixed64Required(p unsafe.Pointer, f *structField) int { 130 return 8 + f.tagsize 131 } 132 func encodeFixed64Required(b []byte, p unsafe.Pointer, f *structField) []byte { 133 v := *(*uint64)(p) 134 b = appendVarint(b, f.wiretag) 135 b = encodeLE64(b, v) 136 return b 137 } 138 139 var zigzag32RequiredCodec = codec{size: sizeOfZigzag32Required, encode: encodeZigzag32Required, decode: decodeZigzag32} 140 141 func sizeOfZigzag32Required(p unsafe.Pointer, f *structField) int { 142 v := *(*int32)(p) 143 return sizeOfVarint(encodeZigZag64(int64(v))) + f.tagsize 144 } 145 func encodeZigzag32Required(b []byte, p unsafe.Pointer, f *structField) []byte { 146 v := *(*int32)(p) 147 b = appendVarint(b, f.wiretag) 148 b = appendVarint(b, encodeZigZag64(int64(v))) 149 return b 150 } 151 152 var zigzag64RequiredCodec = codec{size: sizeOfZigzag64Required, encode: encodeZigzag64Required, decode: decodeZigzag64} 153 154 func sizeOfZigzag64Required(p unsafe.Pointer, f *structField) int { 155 v := *(*int64)(p) 156 return sizeOfVarint(encodeZigZag64(v)) + f.tagsize 157 } 158 func encodeZigzag64Required(b []byte, p unsafe.Pointer, f *structField) []byte { 159 v := *(*int64)(p) 160 b = appendVarint(b, f.wiretag) 161 b = appendVarint(b, encodeZigZag64(v)) 162 return b 163 }