X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=cmd%2Fbinapi-generator%2Fobjects.go;h=2d5321df180b580270ee03bc2e0e78ddbe863469;hb=ef471318d66dd2832df4dc929d312f7cd5f7009a;hp=8f5e8ef1526f4b263a318831506c15adafc884fd;hpb=df781c9bcf64ba93d0ab7ce62573d93c2bf93d4e;p=govpp.git diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go index 8f5e8ef..2d5321d 100644 --- a/cmd/binapi-generator/objects.go +++ b/cmd/binapi-generator/objects.go @@ -1,15 +1,19 @@ package main +import "fmt" + // Package represents collection of objects parsed from VPP binary API JSON data type Package struct { - APIVersion string - Services []Service - Enums []Enum - Aliases []Alias - Types []Type - Unions []Union - Messages []Message - RefMap map[string]string + Name string + Version string + CRC string + Services []Service + Enums []Enum + Aliases []Alias + Types []Type + Unions []Union + Messages []Message + RefMap map[string]string } // Service represents VPP binary API service @@ -85,3 +89,44 @@ const ( eventMessage // VPP event message otherMessage // other VPP message ) + +// printPackage prints all loaded objects for package +func printPackage(pkg *Package) { + logf("package: %s %s (%s)", pkg.Name, pkg.Version, pkg.CRC) + if len(pkg.Enums) > 0 { + logf(" %d enums:", len(pkg.Enums)) + for _, enum := range pkg.Enums { + logf(" - %s: %+v", enum.Name, enum) + } + } + if len(pkg.Unions) > 0 { + logf(" %d unions:", len(pkg.Unions)) + for _, union := range pkg.Unions { + logf(" - %s: %+v", union.Name, union) + } + } + if len(pkg.Types) > 0 { + logf(" %d types:", len(pkg.Types)) + for _, typ := range pkg.Types { + logf(" - %s (%d fields): %+v", typ.Name, len(typ.Fields), typ) + } + } + if len(pkg.Messages) > 0 { + logf(" %d messages:", len(pkg.Messages)) + for _, msg := range pkg.Messages { + logf(" - %s (%d fields) %s", msg.Name, len(msg.Fields), msg.CRC) + } + } + if len(pkg.Services) > 0 { + logf(" %d services:", len(pkg.Services)) + for _, svc := range pkg.Services { + var info string + if svc.Stream { + info = "(STREAM)" + } else if len(svc.Events) > 0 { + info = fmt.Sprintf("(EVENTS: %v)", svc.Events) + } + logf(" - %s: %q -> %q %s", svc.Name, svc.RequestType, svc.ReplyType, info) + } + } +}