sizes.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package flatbuffers
  2. import (
  3. "unsafe"
  4. )
  5. const (
  6. // See http://golang.org/ref/spec#Numeric_types
  7. // SizeUint8 is the byte size of a uint8.
  8. SizeUint8 = 1
  9. // SizeUint16 is the byte size of a uint16.
  10. SizeUint16 = 2
  11. // SizeUint32 is the byte size of a uint32.
  12. SizeUint32 = 4
  13. // SizeUint64 is the byte size of a uint64.
  14. SizeUint64 = 8
  15. // SizeInt8 is the byte size of a int8.
  16. SizeInt8 = 1
  17. // SizeInt16 is the byte size of a int16.
  18. SizeInt16 = 2
  19. // SizeInt32 is the byte size of a int32.
  20. SizeInt32 = 4
  21. // SizeInt64 is the byte size of a int64.
  22. SizeInt64 = 8
  23. // SizeFloat32 is the byte size of a float32.
  24. SizeFloat32 = 4
  25. // SizeFloat64 is the byte size of a float64.
  26. SizeFloat64 = 8
  27. // SizeByte is the byte size of a byte.
  28. // The `byte` type is aliased (by Go definition) to uint8.
  29. SizeByte = 1
  30. // SizeBool is the byte size of a bool.
  31. // The `bool` type is aliased (by flatbuffers convention) to uint8.
  32. SizeBool = 1
  33. // SizeSOffsetT is the byte size of an SOffsetT.
  34. // The `SOffsetT` type is aliased (by flatbuffers convention) to int32.
  35. SizeSOffsetT = 4
  36. // SizeUOffsetT is the byte size of an UOffsetT.
  37. // The `UOffsetT` type is aliased (by flatbuffers convention) to uint32.
  38. SizeUOffsetT = 4
  39. // SizeVOffsetT is the byte size of an VOffsetT.
  40. // The `VOffsetT` type is aliased (by flatbuffers convention) to uint16.
  41. SizeVOffsetT = 2
  42. )
  43. // byteSliceToString converts a []byte to string without a heap allocation.
  44. func byteSliceToString(b []byte) string {
  45. return *(*string)(unsafe.Pointer(&b))
  46. }