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 {
|
||||
|
||||
args := []string{}
|
||||
argsDecls := []string{}
|
||||
|
||||
skipArgI := 0
|
||||
|
||||
for argI, arg := range method.Args {
|
||||
|
||||
argName := "arg_" + arg.Name //strconv.Itoa(argI)
|
||||
|
||||
if argI == 0 && arg.Value.isHTTPResponseWriter() {
|
||||
continue
|
||||
}
|
||||
@ -287,17 +290,14 @@ func renderTSRPCServiceProxies(services map[string]*Service, fullPackageName str
|
||||
continue
|
||||
}
|
||||
|
||||
args = append(args, arg.Value.emptyLiteral(aliases))
|
||||
switch arg.Value.GoScalarType {
|
||||
case "int", "int8", "int16", "int32", "int64",
|
||||
"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)+")"))
|
||||
}
|
||||
argsDecls = append(argsDecls, argName+" := "+arg.Value.emptyLiteral(aliases))
|
||||
args = append(args, "&"+argName)
|
||||
callArgs = append(callArgs, argName)
|
||||
skipArgI++
|
||||
}
|
||||
for _, argDecl := range argsDecls {
|
||||
g.l(argDecl)
|
||||
}
|
||||
g.l("args = []interface{}{" + strings.Join(args, ", ") + "}")
|
||||
g.l("err := gotsrpc.LoadArgs(&args, callStats, r)")
|
||||
g.l("if err != nil {")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user