From ca6003af1a7e1adb7d45879c2d5038bc05c2bb1a Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 2 Aug 2019 15:07:53 +0200 Subject: Migrate to modules, refactor Makefile and use Travis for CI - migrate to Go modules and remove vendor - refactor Makefile - add version package and store version - split extras from the rest - use travis for CI Change-Id: I81b35220653b0f7c9a0fcdd4c527d691ec1e96c1 Signed-off-by: Ondrej Fabry --- vendor/github.com/lunixbochs/struc/types.go | 136 ---------------------------- 1 file changed, 136 deletions(-) delete mode 100644 vendor/github.com/lunixbochs/struc/types.go (limited to 'vendor/github.com/lunixbochs/struc/types.go') diff --git a/vendor/github.com/lunixbochs/struc/types.go b/vendor/github.com/lunixbochs/struc/types.go deleted file mode 100644 index 6ca97f4..0000000 --- a/vendor/github.com/lunixbochs/struc/types.go +++ /dev/null @@ -1,136 +0,0 @@ -package struc - -import ( - "fmt" - "reflect" -) - -type Type int - -const ( - Invalid Type = iota - Pad - Bool - Int - Int8 - Uint8 - Int16 - Uint16 - Int32 - Uint32 - Int64 - Uint64 - Float32 - Float64 - String - Struct - Ptr - - SizeType - OffType - CustomType -) - -func (t Type) Resolve(options *Options) Type { - switch t { - case OffType: - switch options.PtrSize { - case 8: - return Int8 - case 16: - return Int16 - case 32: - return Int32 - case 64: - return Int64 - default: - panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize)) - } - case SizeType: - switch options.PtrSize { - case 8: - return Uint8 - case 16: - return Uint16 - case 32: - return Uint32 - case 64: - return Uint64 - default: - panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize)) - } - } - return t -} - -func (t Type) String() string { - return typeNames[t] -} - -func (t Type) Size() int { - switch t { - case SizeType, OffType: - panic("Size_t/Off_t types must be converted to another type using options.PtrSize") - case Pad, String, Int8, Uint8, Bool: - return 1 - case Int16, Uint16: - return 2 - case Int32, Uint32, Float32: - return 4 - case Int64, Uint64, Float64: - return 8 - default: - panic("Cannot resolve size of type:" + t.String()) - } -} - -var typeLookup = map[string]Type{ - "pad": Pad, - "bool": Bool, - "byte": Uint8, - "int8": Int8, - "uint8": Uint8, - "int16": Int16, - "uint16": Uint16, - "int32": Int32, - "uint32": Uint32, - "int64": Int64, - "uint64": Uint64, - "float32": Float32, - "float64": Float64, - - "size_t": SizeType, - "off_t": OffType, -} - -var typeNames = map[Type]string{ - CustomType: "Custom", -} - -func init() { - for name, enum := range typeLookup { - typeNames[enum] = name - } -} - -type Size_t uint64 -type Off_t int64 - -var reflectTypeMap = map[reflect.Kind]Type{ - reflect.Bool: Bool, - reflect.Int8: Int8, - reflect.Int16: Int16, - reflect.Int: Int32, - reflect.Int32: Int32, - reflect.Int64: Int64, - reflect.Uint8: Uint8, - reflect.Uint16: Uint16, - reflect.Uint: Uint32, - reflect.Uint32: Uint32, - reflect.Uint64: Uint64, - reflect.Float32: Float32, - reflect.Float64: Float64, - reflect.String: String, - reflect.Struct: Struct, - reflect.Ptr: Ptr, -} -- cgit 1.2.3-korg