github.com/RomiChan/protobuf@v0.1.1-0.20230204044148-2ed269a2e54d/proto/option_codec.go (about) 1 // Code generated by gen/option/main.go. DO NOT EDIT. 2 3 package proto 4 5 import "unsafe" 6 7 var boolOptionCodec = codec{ 8 size: sizeOfBoolOption, 9 encode: encodeBoolOption, 10 decode: decodeBoolOption, 11 } 12 13 func sizeOfBoolOption(p unsafe.Pointer, f *structField) int { 14 o := (*Option[bool])(p) 15 if o.IsSome() { 16 return sizeOfBoolRequired(o.unsafePointer(), f) 17 } 18 return 0 19 } 20 21 func encodeBoolOption(b []byte, p unsafe.Pointer, f *structField) []byte { 22 o := (*Option[bool])(p) 23 if o.IsSome() { 24 return encodeBoolRequired(b, o.unsafePointer(), f) 25 } 26 return b 27 } 28 29 func decodeBoolOption(b []byte, p unsafe.Pointer) (int, error) { 30 v := (*Option[bool])(p) 31 v.some = true 32 return decodeBool(b, v.unsafePointer()) 33 } 34 35 var stringOptionCodec = codec{ 36 size: sizeOfStringOption, 37 encode: encodeStringOption, 38 decode: decodeStringOption, 39 } 40 41 func sizeOfStringOption(p unsafe.Pointer, f *structField) int { 42 o := (*Option[string])(p) 43 if o.IsSome() { 44 return sizeOfStringRequired(o.unsafePointer(), f) 45 } 46 return 0 47 } 48 49 func encodeStringOption(b []byte, p unsafe.Pointer, f *structField) []byte { 50 o := (*Option[string])(p) 51 if o.IsSome() { 52 return encodeStringRequired(b, o.unsafePointer(), f) 53 } 54 return b 55 } 56 57 func decodeStringOption(b []byte, p unsafe.Pointer) (int, error) { 58 v := (*Option[string])(p) 59 v.some = true 60 return decodeString(b, v.unsafePointer()) 61 } 62 63 var int32OptionCodec = codec{ 64 size: sizeOfInt32Option, 65 encode: encodeInt32Option, 66 decode: decodeInt32Option, 67 } 68 69 func sizeOfInt32Option(p unsafe.Pointer, f *structField) int { 70 o := (*Option[int32])(p) 71 if o.IsSome() { 72 return sizeOfInt32Required(o.unsafePointer(), f) 73 } 74 return 0 75 } 76 77 func encodeInt32Option(b []byte, p unsafe.Pointer, f *structField) []byte { 78 o := (*Option[int32])(p) 79 if o.IsSome() { 80 return encodeInt32Required(b, o.unsafePointer(), f) 81 } 82 return b 83 } 84 85 func decodeInt32Option(b []byte, p unsafe.Pointer) (int, error) { 86 v := (*Option[int32])(p) 87 v.some = true 88 return decodeInt32(b, v.unsafePointer()) 89 } 90 91 var uint32OptionCodec = codec{ 92 size: sizeOfUint32Option, 93 encode: encodeUint32Option, 94 decode: decodeUint32Option, 95 } 96 97 func sizeOfUint32Option(p unsafe.Pointer, f *structField) int { 98 o := (*Option[uint32])(p) 99 if o.IsSome() { 100 return sizeOfUint32Required(o.unsafePointer(), f) 101 } 102 return 0 103 } 104 105 func encodeUint32Option(b []byte, p unsafe.Pointer, f *structField) []byte { 106 o := (*Option[uint32])(p) 107 if o.IsSome() { 108 return encodeUint32Required(b, o.unsafePointer(), f) 109 } 110 return b 111 } 112 113 func decodeUint32Option(b []byte, p unsafe.Pointer) (int, error) { 114 v := (*Option[uint32])(p) 115 v.some = true 116 return decodeUint32(b, v.unsafePointer()) 117 } 118 119 var int64OptionCodec = codec{ 120 size: sizeOfInt64Option, 121 encode: encodeInt64Option, 122 decode: decodeInt64Option, 123 } 124 125 func sizeOfInt64Option(p unsafe.Pointer, f *structField) int { 126 o := (*Option[int64])(p) 127 if o.IsSome() { 128 return sizeOfInt64Required(o.unsafePointer(), f) 129 } 130 return 0 131 } 132 133 func encodeInt64Option(b []byte, p unsafe.Pointer, f *structField) []byte { 134 o := (*Option[int64])(p) 135 if o.IsSome() { 136 return encodeInt64Required(b, o.unsafePointer(), f) 137 } 138 return b 139 } 140 141 func decodeInt64Option(b []byte, p unsafe.Pointer) (int, error) { 142 v := (*Option[int64])(p) 143 v.some = true 144 return decodeInt64(b, v.unsafePointer()) 145 } 146 147 var uint64OptionCodec = codec{ 148 size: sizeOfUint64Option, 149 encode: encodeUint64Option, 150 decode: decodeUint64Option, 151 } 152 153 func sizeOfUint64Option(p unsafe.Pointer, f *structField) int { 154 o := (*Option[uint64])(p) 155 if o.IsSome() { 156 return sizeOfUint64Required(o.unsafePointer(), f) 157 } 158 return 0 159 } 160 161 func encodeUint64Option(b []byte, p unsafe.Pointer, f *structField) []byte { 162 o := (*Option[uint64])(p) 163 if o.IsSome() { 164 return encodeUint64Required(b, o.unsafePointer(), f) 165 } 166 return b 167 } 168 169 func decodeUint64Option(b []byte, p unsafe.Pointer) (int, error) { 170 v := (*Option[uint64])(p) 171 v.some = true 172 return decodeUint64(b, v.unsafePointer()) 173 } 174 175 var zigzag32OptionCodec = codec{ 176 size: sizeOfZigzag32Option, 177 encode: encodeZigzag32Option, 178 decode: decodeZigzag32Option, 179 } 180 181 func sizeOfZigzag32Option(p unsafe.Pointer, f *structField) int { 182 o := (*Option[int32])(p) 183 if o.IsSome() { 184 return sizeOfZigzag32Required(o.unsafePointer(), f) 185 } 186 return 0 187 } 188 189 func encodeZigzag32Option(b []byte, p unsafe.Pointer, f *structField) []byte { 190 o := (*Option[int32])(p) 191 if o.IsSome() { 192 return encodeZigzag32Required(b, o.unsafePointer(), f) 193 } 194 return b 195 } 196 197 func decodeZigzag32Option(b []byte, p unsafe.Pointer) (int, error) { 198 v := (*Option[int32])(p) 199 v.some = true 200 return decodeZigzag32(b, v.unsafePointer()) 201 } 202 203 var zigzag64OptionCodec = codec{ 204 size: sizeOfZigzag64Option, 205 encode: encodeZigzag64Option, 206 decode: decodeZigzag64Option, 207 } 208 209 func sizeOfZigzag64Option(p unsafe.Pointer, f *structField) int { 210 o := (*Option[int64])(p) 211 if o.IsSome() { 212 return sizeOfZigzag64Required(o.unsafePointer(), f) 213 } 214 return 0 215 } 216 217 func encodeZigzag64Option(b []byte, p unsafe.Pointer, f *structField) []byte { 218 o := (*Option[int64])(p) 219 if o.IsSome() { 220 return encodeZigzag64Required(b, o.unsafePointer(), f) 221 } 222 return b 223 } 224 225 func decodeZigzag64Option(b []byte, p unsafe.Pointer) (int, error) { 226 v := (*Option[int64])(p) 227 v.some = true 228 return decodeZigzag64(b, v.unsafePointer()) 229 } 230 231 var fixed32OptionCodec = codec{ 232 size: sizeOfFixed32Option, 233 encode: encodeFixed32Option, 234 decode: decodeFixed32Option, 235 } 236 237 func sizeOfFixed32Option(p unsafe.Pointer, f *structField) int { 238 o := (*Option[uint32])(p) 239 if o.IsSome() { 240 return sizeOfFixed32Required(o.unsafePointer(), f) 241 } 242 return 0 243 } 244 245 func encodeFixed32Option(b []byte, p unsafe.Pointer, f *structField) []byte { 246 o := (*Option[uint32])(p) 247 if o.IsSome() { 248 return encodeFixed32Required(b, o.unsafePointer(), f) 249 } 250 return b 251 } 252 253 func decodeFixed32Option(b []byte, p unsafe.Pointer) (int, error) { 254 v := (*Option[uint32])(p) 255 v.some = true 256 return decodeFixed32(b, v.unsafePointer()) 257 } 258 259 var fixed64OptionCodec = codec{ 260 size: sizeOfFixed64Option, 261 encode: encodeFixed64Option, 262 decode: decodeFixed64Option, 263 } 264 265 func sizeOfFixed64Option(p unsafe.Pointer, f *structField) int { 266 o := (*Option[uint64])(p) 267 if o.IsSome() { 268 return sizeOfFixed64Required(o.unsafePointer(), f) 269 } 270 return 0 271 } 272 273 func encodeFixed64Option(b []byte, p unsafe.Pointer, f *structField) []byte { 274 o := (*Option[uint64])(p) 275 if o.IsSome() { 276 return encodeFixed64Required(b, o.unsafePointer(), f) 277 } 278 return b 279 } 280 281 func decodeFixed64Option(b []byte, p unsafe.Pointer) (int, error) { 282 v := (*Option[uint64])(p) 283 v.some = true 284 return decodeFixed64(b, v.unsafePointer()) 285 } 286 287 var float32OptionCodec = codec{ 288 size: sizeOfFloat32Option, 289 encode: encodeFloat32Option, 290 decode: decodeFloat32Option, 291 } 292 293 func sizeOfFloat32Option(p unsafe.Pointer, f *structField) int { 294 o := (*Option[float32])(p) 295 if o.IsSome() { 296 return sizeOfFloat32Required(o.unsafePointer(), f) 297 } 298 return 0 299 } 300 301 func encodeFloat32Option(b []byte, p unsafe.Pointer, f *structField) []byte { 302 o := (*Option[float32])(p) 303 if o.IsSome() { 304 return encodeFloat32Required(b, o.unsafePointer(), f) 305 } 306 return b 307 } 308 309 func decodeFloat32Option(b []byte, p unsafe.Pointer) (int, error) { 310 v := (*Option[float32])(p) 311 v.some = true 312 return decodeFloat32(b, v.unsafePointer()) 313 } 314 315 var float64OptionCodec = codec{ 316 size: sizeOfFloat64Option, 317 encode: encodeFloat64Option, 318 decode: decodeFloat64Option, 319 } 320 321 func sizeOfFloat64Option(p unsafe.Pointer, f *structField) int { 322 o := (*Option[float64])(p) 323 if o.IsSome() { 324 return sizeOfFloat64Required(o.unsafePointer(), f) 325 } 326 return 0 327 } 328 329 func encodeFloat64Option(b []byte, p unsafe.Pointer, f *structField) []byte { 330 o := (*Option[float64])(p) 331 if o.IsSome() { 332 return encodeFloat64Required(b, o.unsafePointer(), f) 333 } 334 return b 335 } 336 337 func decodeFloat64Option(b []byte, p unsafe.Pointer) (int, error) { 338 v := (*Option[float64])(p) 339 v.some = true 340 return decodeFloat64(b, v.unsafePointer()) 341 }