|
|
|
@ -1,9 +1,6 @@
|
|
|
|
// Package tape implements Table Pair Encoding.
|
|
|
|
// Package tape implements Table Pair Encoding.
|
|
|
|
package tape
|
|
|
|
package tape
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: in math/rand: uint is capitalized like Uint, we need to replicate that
|
|
|
|
|
|
|
|
// here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
|
|
// encoding and decoding functions must not make any allocations
|
|
|
|
// encoding and decoding functions must not make any allocations
|
|
|
|
@ -31,8 +28,8 @@ type Int16 interface { ~uint16 | ~int16 }
|
|
|
|
type Int32 interface { ~uint32 | ~int32 }
|
|
|
|
type Int32 interface { ~uint32 | ~int32 }
|
|
|
|
// Int64 is any 64-bit integer.
|
|
|
|
// Int64 is any 64-bit integer.
|
|
|
|
type Int64 interface { ~uint64 | ~int64 }
|
|
|
|
type Int64 interface { ~uint64 | ~int64 }
|
|
|
|
// UInt is any unsigned integer.
|
|
|
|
// Uint is any unsigned integer.
|
|
|
|
type UInt interface { ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }
|
|
|
|
type Uint interface { ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }
|
|
|
|
// String is any string.
|
|
|
|
// String is any string.
|
|
|
|
type String interface { ~string | ~[]uint8 }
|
|
|
|
type String interface { ~string | ~[]uint8 }
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,7 +107,7 @@ func EncodeI64[T Int64](buffer []byte, value T) (n int, err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// DecodeGBEU decodes an 8 to 64 bit growing integer into the given buffer.
|
|
|
|
// DecodeGBEU decodes an 8 to 64 bit growing integer into the given buffer.
|
|
|
|
func DecodeGBEU[T UInt](data []byte) (value T, n int, err error) {
|
|
|
|
func DecodeGBEU[T Uint](data []byte) (value T, n int, err error) {
|
|
|
|
var fullValue uint64
|
|
|
|
var fullValue uint64
|
|
|
|
for _, chunk := range data {
|
|
|
|
for _, chunk := range data {
|
|
|
|
fullValue *= 0x80
|
|
|
|
fullValue *= 0x80
|
|
|