-type Kind int
-
-const (
- _ = iota
- Uint8Kind
- Int8Kind
- Uint16Kind
- Int16Kind
- Uint32Kind
- Int32Kind
- Uint64Kind
- Int64Kind
- Float64Kind
- BoolKind
- StringKind
- EnumKind
- AliasKind
- StructKind
- UnionKind
- MessageKind
-)
-
-// toApiType returns name that is used as type reference in VPP binary API
-func toApiType(name string) string {
- return defineApiPrefix + name + defineApiSuffix
-}
-
-func fromApiType(typ string) string {
- name := typ
- name = strings.TrimPrefix(name, defineApiPrefix)
- name = strings.TrimSuffix(name, defineApiSuffix)
- return name
-}
-
-func getSizeOfType(module *File, typ *Struct) (size int) {
- for _, field := range typ.Fields {
- enum := getEnumByRef(module, field.Type)
- if enum != nil {
- size += getSizeOfBinapiTypeLength(enum.Type, field.Length)
- continue
- }
- size += getSizeOfBinapiTypeLength(field.Type, field.Length)
- }
- return size
-}
-
-func getEnumByRef(file *File, ref string) *Enum {
- for _, typ := range file.Enums {
- if ref == toApiType(typ.Name) {
- return typ
- }
- }
- return nil
-}
-
-func getTypeByRef(file *File, ref string) *Struct {
- for _, typ := range file.Structs {
- if ref == toApiType(typ.Name) {
- return typ
- }
- }
- return nil
-}
-
-func getAliasByRef(file *File, ref string) *Alias {
- for _, alias := range file.Aliases {
- if ref == toApiType(alias.Name) {
- return alias
- }
- }
- return nil
-}
-
-func getUnionByRef(file *File, ref string) *Union {
- for _, union := range file.Unions {
- if ref == toApiType(union.Name) {
- return union
- }
- }
- return nil
-}
-
-func getBinapiTypeSize(binapiType string) (size int) {
- typName := BaseTypeNames[binapiType]
- return BaseTypeSizes[typName]
-}
-
-// binapiTypes is a set of types used VPP binary API for translation to Go types
-var binapiTypes = map[string]string{
- "u8": "uint8",
- "i8": "int8",
- "u16": "uint16",
- "i16": "int16",
- "u32": "uint32",
- "i32": "int32",
- "u64": "uint64",
- "i64": "int64",
- "f64": "float64",
-}
-var BaseTypesGo = map[BaseType]string{