summaryrefslogtreecommitdiffstats
path: root/cmd/binapi-generator/objects.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/binapi-generator/objects.go')
-rw-r--r--cmd/binapi-generator/objects.go90
1 files changed, 46 insertions, 44 deletions
diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go
index 97318cb..4b424f5 100644
--- a/cmd/binapi-generator/objects.go
+++ b/cmd/binapi-generator/objects.go
@@ -1,34 +1,48 @@
package main
-import "strings"
+import (
+ "strings"
+)
// Package represents collection of objects parsed from VPP binary API JSON data
type Package struct {
APIVersion string
+ Services []Service
Enums []Enum
- Unions []Union
- Types []Type
Aliases []Alias
+ Types []Type
+ Unions []Union
Messages []Message
- Services []Service
RefMap map[string]string
}
-// MessageType represents the type of a VPP message
-type MessageType int
+// Service represents VPP binary API service
+type Service struct {
+ Name string
+ RequestType string
+ ReplyType string
+ Stream bool
+ Events []string
+}
-const (
- requestMessage MessageType = iota // VPP request message
- replyMessage // VPP reply message
- eventMessage // VPP event message
- otherMessage // other VPP message
-)
+// Enum represents VPP binary API enum
+type Enum struct {
+ Name string
+ Type string
+ Entries []EnumEntry
+}
-// Message represents VPP binary API message
-type Message struct {
+// EnumEntry represents VPP binary API enum entry
+type EnumEntry struct {
+ Name string
+ Value interface{}
+}
+
+// Alias represents VPP binary API alias
+type Alias struct {
Name string
- CRC string
- Fields []Field
+ Type string
+ Length int
}
// Type represents VPP binary API type
@@ -38,20 +52,30 @@ type Type struct {
Fields []Field
}
-// Alias represents VPP binary API alias
-type Alias struct {
+// Union represents VPP binary API union
+type Union struct {
Name string
- Type string
- Length int
+ CRC string
+ Fields []Field
}
-// Union represents VPP binary API union
-type Union struct {
+// Message represents VPP binary API message
+type Message struct {
Name string
CRC string
Fields []Field
}
+// MessageType represents the type of a VPP message
+type MessageType int
+
+const (
+ requestMessage MessageType = iota // VPP request message
+ replyMessage // VPP reply message
+ eventMessage // VPP event message
+ otherMessage // other VPP message
+)
+
// Field represents VPP binary API object field
type Field struct {
Name string
@@ -64,28 +88,6 @@ func (f *Field) IsArray() bool {
return f.Length > 0 || f.SizeFrom != ""
}
-// Enum represents VPP binary API enum
-type Enum struct {
- Name string
- Type string
- Entries []EnumEntry
-}
-
-// EnumEntry represents VPP binary API enum entry
-type EnumEntry struct {
- Name string
- Value interface{}
-}
-
-// Service represents VPP binary API service
-type Service struct {
- Name string
- RequestType string
- ReplyType string
- Stream bool
- Events []string
-}
-
func (s Service) MethodName() string {
reqTyp := camelCaseName(s.RequestType)