aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-09-30 10:48:09 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-30 17:34:26 +0200
commit7051829581b426a410a3817921564d950f839768 (patch)
tree432ef5a666349a87f94e95197495a88869849ca2 /nexgb/xgbgen
parent3e9ed4eac6a953b2616bcf129b515a857271acdc (diff)
downloadhaven-7051829581b426a410a3817921564d950f839768.tar.gz
haven-7051829581b426a410a3817921564d950f839768.tar.xz
haven-7051829581b426a410a3817921564d950f839768.zip
xgbgen: make request function signatures shorter
Diffstat (limited to 'nexgb/xgbgen')
-rw-r--r--nexgb/xgbgen/go_request_reply.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go
index 1c0ce14..90dddb4 100644
--- a/nexgb/xgbgen/go_request_reply.go
+++ b/nexgb/xgbgen/go_request_reply.go
@@ -247,9 +247,23 @@ func (r *Request) ParamNames() string {
func (r *Request) ParamNameTypes() string {
nameTypes := make([]string, 0, len(r.Fields))
+
+ chunk := make([]string, 0)
+ chunkType := ""
+ flushChunk := func() {
+ if len(chunk) > 0 {
+ nameTypes = append(nameTypes, chunk[:len(chunk)-1]...)
+ nameTypes = append(nameTypes,
+ fmt.Sprintf("%s %s", chunk[len(chunk)-1], chunkType))
+ }
+ chunk = nil
+ chunkType = ""
+ }
+
for _, field := range r.Fields {
switch f := field.(type) {
case *ValueField:
+ flushChunk()
nameTypes = append(nameTypes,
fmt.Sprintf("%s %s", f.MaskName, f.MaskType.SrcName()))
nameTypes = append(nameTypes,
@@ -261,9 +275,14 @@ func (r *Request) ParamNameTypes() string {
case *RequiredStartAlign:
continue
default:
- nameTypes = append(nameTypes,
- fmt.Sprintf("%s %s", field.SrcName(), field.SrcType()))
+ curType := field.SrcType()
+ if curType != chunkType {
+ flushChunk()
+ }
+ chunk = append(chunk, field.SrcName())
+ chunkType = curType
}
}
+ flushChunk()
return strings.Join(nameTypes, ", ")
}