Add various generator improvements
[govpp.git] / examples / binapi / vpe / vpe.ba.go
similarity index 67%
rename from examples/bin_api/vpe/vpe.ba.go
rename to examples/binapi/vpe/vpe.ba.go
index 486f1a0..25707fc 100644 (file)
@@ -1,37 +1,43 @@
 // Code generated by GoVPP binapi-generator. DO NOT EDIT.
-//  source: vpe.api.json
+// source: /usr/share/vpp/api/core/vpe.api.json
 
 /*
- Package vpe is a generated from VPP binary API module 'vpe'.
+Package vpe is a generated from VPP binary API module 'vpe'.
 
- It contains following objects:
-         9 services
+ The vpe module consists of:
          1 type
         18 messages
+         9 services
 */
 package vpe
 
 import api "git.fd.io/govpp.git/api"
-import struc "github.com/lunixbochs/struc"
 import bytes "bytes"
+import context "context"
+import strconv "strconv"
+import struc "github.com/lunixbochs/struc"
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = api.RegisterMessage
-var _ = struc.Pack
 var _ = bytes.NewBuffer
+var _ = context.Background
+var _ = strconv.Itoa
+var _ = struc.Pack
 
-// Services represents VPP binary API services:
-type Services interface {
-       AddNodeNext(*AddNodeNext) (*AddNodeNextReply, error)
-       Cli(*Cli) (*CliReply, error)
-       CliInband(*CliInband) (*CliInbandReply, error)
-       ControlPing(*ControlPing) (*ControlPingReply, error)
-       GetNextIndex(*GetNextIndex) (*GetNextIndexReply, error)
-       GetNodeGraph(*GetNodeGraph) (*GetNodeGraphReply, error)
-       GetNodeIndex(*GetNodeIndex) (*GetNodeIndexReply, error)
-       ShowThreads(*ShowThreads) (*ShowThreadsReply, error)
-       ShowVersion(*ShowVersion) (*ShowVersionReply, error)
-}
+// 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.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package
+
+const (
+       // ModuleName is the name of this module.
+       ModuleName = "vpe"
+       // APIVersion is the API version of this module.
+       APIVersion = "1.1.0"
+       // VersionCrc is the CRC of this module.
+       VersionCrc = 0x2cc8d629
+)
 
 /* Types */
 
@@ -360,23 +366,128 @@ func init() {
        api.RegisterMessage((*ShowVersionReply)(nil), "vpe.ShowVersionReply")
 }
 
-var Messages = []api.Message{
-       (*AddNodeNext)(nil),
-       (*AddNodeNextReply)(nil),
-       (*Cli)(nil),
-       (*CliInband)(nil),
-       (*CliInbandReply)(nil),
-       (*CliReply)(nil),
-       (*ControlPing)(nil),
-       (*ControlPingReply)(nil),
-       (*GetNextIndex)(nil),
-       (*GetNextIndexReply)(nil),
-       (*GetNodeGraph)(nil),
-       (*GetNodeGraphReply)(nil),
-       (*GetNodeIndex)(nil),
-       (*GetNodeIndexReply)(nil),
-       (*ShowThreads)(nil),
-       (*ShowThreadsReply)(nil),
-       (*ShowVersion)(nil),
-       (*ShowVersionReply)(nil),
+// Messages returns list of all messages in this module.
+func AllMessages() []api.Message {
+       return []api.Message{
+               (*AddNodeNext)(nil),
+               (*AddNodeNextReply)(nil),
+               (*Cli)(nil),
+               (*CliInband)(nil),
+               (*CliInbandReply)(nil),
+               (*CliReply)(nil),
+               (*ControlPing)(nil),
+               (*ControlPingReply)(nil),
+               (*GetNextIndex)(nil),
+               (*GetNextIndexReply)(nil),
+               (*GetNodeGraph)(nil),
+               (*GetNodeGraphReply)(nil),
+               (*GetNodeIndex)(nil),
+               (*GetNodeIndexReply)(nil),
+               (*ShowThreads)(nil),
+               (*ShowThreadsReply)(nil),
+               (*ShowVersion)(nil),
+               (*ShowVersionReply)(nil),
+       }
+}
+
+// Service represents services in VPP binary API.
+type Service interface {
+       AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error)
+       Cli(ctx context.Context, in *Cli) (*CliReply, error)
+       CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error)
+       ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error)
+       GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error)
+       GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error)
+       GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error)
+       ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error)
+       ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error)
+}
+
+type service struct {
+       ch api.Channel
+}
+
+func NewService(ch api.Channel) Service {
+       return &service{ch}
+}
+
+func (c *service) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) {
+       out := new(AddNodeNextReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) Cli(ctx context.Context, in *Cli) (*CliReply, error) {
+       out := new(CliReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) {
+       out := new(CliInbandReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) {
+       out := new(ControlPingReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) {
+       out := new(GetNextIndexReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) {
+       out := new(GetNodeGraphReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) {
+       out := new(GetNodeIndexReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error) {
+       out := new(ShowThreadsReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
+}
+
+func (c *service) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) {
+       out := new(ShowVersionReply)
+       err := c.ch.SendRequest(in).ReceiveReply(out)
+       if err != nil {
+               return nil, err
+       }
+       return out, nil
 }