X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=binapigen%2Ftypes.go;h=96ae870bd6e9a05fce6446226cf9e91075ec621f;hp=0dbbeb13923663a76ef2d5d8fc823dcdbf24a9a6;hb=c7ae74a95d1bd6fefcbb061f5f045c60c11e32fc;hpb=df67791c6ffc96331f75aec7d3addfe2efca7739 diff --git a/binapigen/types.go b/binapigen/types.go index 0dbbeb1..96ae870 100644 --- a/binapigen/types.go +++ b/binapigen/types.go @@ -15,6 +15,7 @@ package binapigen import ( + "fmt" "strings" "github.com/sirupsen/logrus" @@ -213,14 +214,23 @@ func getActualType(file *File, typ string) (actual string) { return typ } -// convertToGoType translates the VPP binary API type into Go type +// convertToGoType translates the VPP binary API type into Go type. +// Imported types are with import prefix. func convertToGoType(file *File, binapiType string) (typ string) { if t, ok := binapiTypes[binapiType]; ok { // basic types typ = t } else if r, ok := file.refmap[binapiType]; ok { // specific types (enums/types/unions) + var prefix string typ = camelCaseName(r) + // look in imports using name and type name eventually + if imp, ok := file.imports[typ]; ok { + prefix = fmt.Sprintf("%s.", imp) + } else if imp, ok := file.imports[fromApiType(binapiType)]; ok { + prefix = fmt.Sprintf("%s.", imp) + } + typ = fmt.Sprintf("%s%s", prefix, typ) } else { switch binapiType { case "bool", "string":