Improve binapi generator
[govpp.git] / binapi / fib_types / fib_types.ba.go
similarity index 70%
rename from examples/binapi/fib_types/fib_types.ba.go
rename to binapi/fib_types/fib_types.ba.go
index 9050e85..eb67597 100644 (file)
@@ -4,53 +4,27 @@
 //  VPP:              20.05-release
 // source: /usr/share/vpp/api/core/fib_types.api.json
 
-/*
-Package fib_types contains generated code for VPP API file fib_types.api (2.0.0).
-
-It consists of:
-         5 aliases
-         7 enums
-         9 types
-         1 union
-*/
+// Package fib_types contains generated bindings for API file fib_types.api.
+//
+// Contents:
+//   3 enums
+//   3 structs
+//
 package fib_types
 
 import (
-       "bytes"
-       "context"
-       "encoding/binary"
-       "fmt"
-       "io"
-       "math"
-       "net"
-       "strconv"
-       "strings"
-
        api "git.fd.io/govpp.git/api"
-       codec "git.fd.io/govpp.git/codec"
-       struc "github.com/lunixbochs/struc"
-
-       ip_types "git.fd.io/govpp.git/examples/binapi/ip_types"
+       ip_types "git.fd.io/govpp.git/binapi/ip_types"
+       "strconv"
 )
 
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the GoVPP api package it is being compiled against.
 // A compilation error at this line likely means your copy of the
 // GoVPP api package needs to be updated.
-const _ = api.GoVppAPIPackageIsVersion2 // please upgrade the GoVPP api package
-
-const (
-       // ModuleName is the name of this module.
-       ModuleName = "fib_types"
-       // APIVersion is the API version of this module.
-       APIVersion = "2.0.0"
-       // VersionCrc is the CRC of this module.
-       VersionCrc = 0xd6a5938
-)
-
-type AddressFamily = ip_types.AddressFamily
+const _ = api.GoVppAPIPackageIsVersion2
 
-// FibPathFlags represents VPP binary API enum 'fib_path_flags'.
+// FibPathFlags defines enum 'fib_path_flags'.
 type FibPathFlags uint32
 
 const (
@@ -80,10 +54,29 @@ func (x FibPathFlags) String() string {
        if ok {
                return s
        }
-       return "FibPathFlags(" + strconv.Itoa(int(x)) + ")"
+       str := func(n uint32) string {
+               s, ok := FibPathFlags_name[uint32(n)]
+               if ok {
+                       return s
+               }
+               return "FibPathFlags(" + strconv.Itoa(int(n)) + ")"
+       }
+       for i := uint32(0); i <= 32; i++ {
+               val := uint32(x)
+               if val&(1<<i) != 0 {
+                       if s != "" {
+                               s += "|"
+                       }
+                       s += str(1 << i)
+               }
+       }
+       if s == "" {
+               return str(uint32(x))
+       }
+       return s
 }
 
-// FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'.
+// FibPathNhProto defines enum 'fib_path_nh_proto'.
 type FibPathNhProto uint32
 
 const (
@@ -119,7 +112,7 @@ func (x FibPathNhProto) String() string {
        return "FibPathNhProto(" + strconv.Itoa(int(x)) + ")"
 }
 
-// FibPathType represents VPP binary API enum 'fib_path_type'.
+// FibPathType defines enum 'fib_path_type'.
 type FibPathType uint32
 
 const (
@@ -173,25 +166,7 @@ func (x FibPathType) String() string {
        return "FibPathType(" + strconv.Itoa(int(x)) + ")"
 }
 
-type IPDscp = ip_types.IPDscp
-
-type IPEcn = ip_types.IPEcn
-
-type IPProto = ip_types.IPProto
-
-type AddressWithPrefix = ip_types.AddressWithPrefix
-
-type IP4Address = ip_types.IP4Address
-
-type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix
-
-type IP6Address = ip_types.IP6Address
-
-type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix
-
-type Address = ip_types.Address
-
-// FibMplsLabel represents VPP binary API type 'fib_mpls_label'.
+// FibMplsLabel defines type 'fib_mpls_label'.
 type FibMplsLabel struct {
        IsUniform uint8  `binapi:"u8,name=is_uniform" json:"is_uniform,omitempty"`
        Label     uint32 `binapi:"u32,name=label" json:"label,omitempty"`
@@ -199,9 +174,7 @@ type FibMplsLabel struct {
        Exp       uint8  `binapi:"u8,name=exp" json:"exp,omitempty"`
 }
 
-func (*FibMplsLabel) GetTypeName() string { return "fib_mpls_label" }
-
-// FibPath represents VPP binary API type 'fib_path'.
+// FibPath defines type 'fib_path'.
 type FibPath struct {
        SwIfIndex  uint32           `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"`
        TableID    uint32           `binapi:"u32,name=table_id" json:"table_id,omitempty"`
@@ -213,43 +186,13 @@ type FibPath struct {
        Proto      FibPathNhProto   `binapi:"fib_path_nh_proto,name=proto" json:"proto,omitempty"`
        Nh         FibPathNh        `binapi:"fib_path_nh,name=nh" json:"nh,omitempty"`
        NLabels    uint8            `binapi:"u8,name=n_labels" json:"n_labels,omitempty"`
-       LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty" struc:"[16]FibMplsLabel"`
+       LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty"`
 }
 
-func (*FibPath) GetTypeName() string { return "fib_path" }
-
-// FibPathNh represents VPP binary API type 'fib_path_nh'.
+// FibPathNh defines type 'fib_path_nh'.
 type FibPathNh struct {
        Address            ip_types.AddressUnion `binapi:"address_union,name=address" json:"address,omitempty"`
        ViaLabel           uint32                `binapi:"u32,name=via_label" json:"via_label,omitempty"`
        ObjID              uint32                `binapi:"u32,name=obj_id" json:"obj_id,omitempty"`
        ClassifyTableIndex uint32                `binapi:"u32,name=classify_table_index" json:"classify_table_index,omitempty"`
 }
-
-func (*FibPathNh) GetTypeName() string { return "fib_path_nh" }
-
-type IP4Prefix = ip_types.IP4Prefix
-
-type IP6Prefix = ip_types.IP6Prefix
-
-type Mprefix = ip_types.Mprefix
-
-type Prefix = ip_types.Prefix
-
-type PrefixMatcher = ip_types.PrefixMatcher
-
-type AddressUnion = ip_types.AddressUnion
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = api.RegisterMessage
-var _ = codec.DecodeString
-var _ = bytes.NewBuffer
-var _ = context.Background
-var _ = io.Copy
-var _ = strconv.Itoa
-var _ = strings.Contains
-var _ = struc.Pack
-var _ = binary.BigEndian
-var _ = math.Float32bits
-var _ = net.ParseIP
-var _ = fmt.Errorf