summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2018-10-03 05:14:40 -0700
committerOndrej Fabry <ofabry@cisco.com>2018-10-03 05:14:40 -0700
commit62d19032621c7db801b313a1e19e787cfb1fbc3e (patch)
treed2181b6b09f8cbbaf32a4dff72e9d64675a243bb /cmd
parent0f731471ab258d9e01658f0ab70f8317fd0fb89c (diff)
Omit message factory and line numbers from generated output
Change-Id: Ie48cc0a641242625daf55caf00ab630e78aa86b7 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/binapi-generator/generate.go25
1 files changed, 5 insertions, 20 deletions
diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go
index 73bcd2a..7cfe338 100644
--- a/cmd/binapi-generator/generate.go
+++ b/cmd/binapi-generator/generate.go
@@ -171,23 +171,19 @@ func generatePackage(ctx *context, w *bufio.Writer) error {
// generateHeader writes generated package header into w
func generateHeader(ctx *context, w io.Writer) {
fmt.Fprintln(w, "// Code generated by GoVPP binapi-generator. DO NOT EDIT.")
- fmt.Fprintf(w, "// source: %s\n", ctx.inputFile)
+ fmt.Fprintf(w, "// source: %s\n", ctx.inputFile)
fmt.Fprintln(w)
fmt.Fprintln(w, "/*")
- fmt.Fprintf(w, "Package %s is a generated VPP binary API of the '%s' VPP module.\n", ctx.packageName, ctx.moduleName)
+ fmt.Fprintf(w, " Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx.moduleName)
fmt.Fprintln(w)
- fmt.Fprintln(w, "It is generated from this file:")
- fmt.Fprintf(w, "\t%s\n", filepath.Base(ctx.inputFile))
- fmt.Fprintln(w)
- fmt.Fprintln(w, "It contains these VPP binary API objects:")
-
+ fmt.Fprintln(w, " It contains following objects:")
var printObjNum = func(obj string, num int) {
if num > 0 {
if num > 1 {
obj += "s"
}
- fmt.Fprintf(w, "\t%d %s\n", num, obj)
+ fmt.Fprintf(w, "\t%3d %s\n", num, obj)
}
}
printObjNum("message", len(ctx.packageData.Messages))
@@ -195,7 +191,7 @@ func generateHeader(ctx *context, w io.Writer) {
printObjNum("enum", len(ctx.packageData.Enums))
printObjNum("union", len(ctx.packageData.Unions))
printObjNum("service", len(ctx.packageData.Services))
-
+ fmt.Fprintln(w)
fmt.Fprintln(w, "*/")
fmt.Fprintf(w, "package %s\n", ctx.packageName)
fmt.Fprintln(w)
@@ -242,7 +238,6 @@ func generateComment(ctx *context, w io.Writer, goName string, vppName string, o
// If no other non-whitespace character then we are at the message header.
if trimmed := strings.TrimSpace(line); trimmed == objTitle {
objFound = true
- fmt.Fprintf(w, "// Generated from '%s', line %d:\n", filepath.Base(ctx.inputFile), ctx.inputLine)
fmt.Fprintln(w, "//")
}
} else {
@@ -463,9 +458,6 @@ func generateMessage(ctx *context, w io.Writer, msg *Message) {
// generate message type getter method
generateMessageTypeGetter(w, name, msgType)
-
- // generate message factory
- generateMessageFactory(w, name)
}
// generateField writes generated code for the field into w
@@ -556,10 +548,3 @@ func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageTy
}
fmt.Fprintln(w, "}")
}
-
-// generateMessageFactory generates message factory for the generated message into the provider writer
-func generateMessageFactory(w io.Writer, structName string) {
- fmt.Fprintln(w, "func New"+structName+"() api.Message {")
- fmt.Fprintln(w, "\treturn &"+structName+"{}")
- fmt.Fprintln(w, "}")
-}