mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
next arg handling iteration, by passing in pointers
This commit is contained in:
parent
6278b6d3a4
commit
8f7c08d090
18
go.go
18
go.go
@ -274,11 +274,14 @@ func renderTSRPCServiceProxies(services map[string]*Service, fullPackageName str
|
|||||||
if len(method.Args) > 0 {
|
if len(method.Args) > 0 {
|
||||||
|
|
||||||
args := []string{}
|
args := []string{}
|
||||||
|
argsDecls := []string{}
|
||||||
|
|
||||||
skipArgI := 0
|
skipArgI := 0
|
||||||
|
|
||||||
for argI, arg := range method.Args {
|
for argI, arg := range method.Args {
|
||||||
|
|
||||||
|
argName := "arg_" + arg.Name //strconv.Itoa(argI)
|
||||||
|
|
||||||
if argI == 0 && arg.Value.isHTTPResponseWriter() {
|
if argI == 0 && arg.Value.isHTTPResponseWriter() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -287,17 +290,14 @@ func renderTSRPCServiceProxies(services map[string]*Service, fullPackageName str
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, arg.Value.emptyLiteral(aliases))
|
argsDecls = append(argsDecls, argName+" := "+arg.Value.emptyLiteral(aliases))
|
||||||
switch arg.Value.GoScalarType {
|
args = append(args, "&"+argName)
|
||||||
case "int", "int8", "int16", "int32", "int64",
|
callArgs = append(callArgs, argName)
|
||||||
"uint", "uint8", "uint16", "uint32", "uint64":
|
|
||||||
callArgs = append(callArgs, fmt.Sprint(arg.Value.GoScalarType+"(args[", skipArgI, "].(float64))"))
|
|
||||||
default:
|
|
||||||
// assert
|
|
||||||
callArgs = append(callArgs, fmt.Sprint("args[", skipArgI, "].("+arg.Value.goType(aliases, fullPackageName)+")"))
|
|
||||||
}
|
|
||||||
skipArgI++
|
skipArgI++
|
||||||
}
|
}
|
||||||
|
for _, argDecl := range argsDecls {
|
||||||
|
g.l(argDecl)
|
||||||
|
}
|
||||||
g.l("args = []interface{}{" + strings.Join(args, ", ") + "}")
|
g.l("args = []interface{}{" + strings.Join(args, ", ") + "}")
|
||||||
g.l("err := gotsrpc.LoadArgs(&args, callStats, r)")
|
g.l("err := gotsrpc.LoadArgs(&args, callStats, r)")
|
||||||
g.l("if err != nil {")
|
g.l("if err != nil {")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user