aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go_request_reply.go
diff options
context:
space:
mode:
Diffstat (limited to 'nexgb/xgbgen/go_request_reply.go')
-rw-r--r--nexgb/xgbgen/go_request_reply.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go
index fead79a..1c0ce14 100644
--- a/nexgb/xgbgen/go_request_reply.go
+++ b/nexgb/xgbgen/go_request_reply.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "sort"
"strings"
)
@@ -12,6 +13,33 @@ func (r *Request) Define(c *Context) {
c.Putln("*xgb.Cookie")
c.Putln("}")
c.Putln("")
+
+ if r.Doc.Description != "" {
+ c.PutComment(r.Doc.Description)
+ c.Putln("//")
+ }
+
+ allErrors := make([]string, 0, len(r.Doc.Errors))
+ for kind := range r.Doc.Errors {
+ allErrors = append(allErrors, kind)
+ }
+ sort.Strings(allErrors)
+
+ undocErrors := make([]string, 0)
+ for _, kind := range allErrors {
+ if desc := r.Doc.Errors[kind]; desc == "" {
+ undocErrors = append(undocErrors, kind)
+ } else {
+ c.PutComment(fmt.Sprintf("May return a %s error if %s%s", kind,
+ strings.ToLower(desc[:1]), desc[1:]))
+ c.Putln("//")
+ }
+ }
+ if len(undocErrors) > 0 {
+ c.Putln("// May return %s errors.", strings.Join(undocErrors, ", "))
+ c.Putln("//")
+ }
+
if r.Reply != nil {
c.Putln("// %s sends a checked request.", r.SrcName())
c.Putln("// If an error occurs, it will be returned with the reply "+