xgbgen: make request function signatures shorter
This commit is contained in:
parent
3e9ed4eac6
commit
7051829581
|
@ -247,9 +247,23 @@ func (r *Request) ParamNames() string {
|
||||||
|
|
||||||
func (r *Request) ParamNameTypes() string {
|
func (r *Request) ParamNameTypes() string {
|
||||||
nameTypes := make([]string, 0, len(r.Fields))
|
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 {
|
for _, field := range r.Fields {
|
||||||
switch f := field.(type) {
|
switch f := field.(type) {
|
||||||
case *ValueField:
|
case *ValueField:
|
||||||
|
flushChunk()
|
||||||
nameTypes = append(nameTypes,
|
nameTypes = append(nameTypes,
|
||||||
fmt.Sprintf("%s %s", f.MaskName, f.MaskType.SrcName()))
|
fmt.Sprintf("%s %s", f.MaskName, f.MaskType.SrcName()))
|
||||||
nameTypes = append(nameTypes,
|
nameTypes = append(nameTypes,
|
||||||
|
@ -261,9 +275,14 @@ func (r *Request) ParamNameTypes() string {
|
||||||
case *RequiredStartAlign:
|
case *RequiredStartAlign:
|
||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
nameTypes = append(nameTypes,
|
curType := field.SrcType()
|
||||||
fmt.Sprintf("%s %s", field.SrcName(), field.SrcType()))
|
if curType != chunkType {
|
||||||
|
flushChunk()
|
||||||
|
}
|
||||||
|
chunk = append(chunk, field.SrcName())
|
||||||
|
chunkType = curType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
flushChunk()
|
||||||
return strings.Join(nameTypes, ", ")
|
return strings.Join(nameTypes, ", ")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue