Skip to content

Commit

Permalink
convert to blockfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Oct 30, 2024
1 parent ba17baa commit 49db926
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions cmd/qdiimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,29 +325,25 @@ func gen(outputName string, obj types.Object, iface *types.Interface) error {
}
})

var retVars []Code
for k := 0; k < sig.Results().Len(); k++ {
retVars = append(retVars, Id(fmt.Sprintf("r%d", k)))
}

if sig.Results().Len() == 0 {
fgroup.Add(call)
} else {
fgroup.Add(ListFunc(func(fgroup *Group) {
for k := 0; k < sig.Results().Len(); k++ {
fgroup.Id(fmt.Sprintf("r%d", k))
}
}).Op(":=").Add(call))
fgroup.List(retVars...).Op(":=").Add(call)
}

fgroup.If(Op("!").Id("qctx").Dot("isNotSupported")).
BlockFunc(func(rgroup *Group) {
rgroup.Id("d").Dot("addCallMethod").Call(Id("methodName"))
rgroup.ReturnFunc(func(retgroup *Group) {
if sig.Results().Len() == 0 {
return
}
retgroup.ListFunc(func(retlgroup *Group) {
for k := 0; k < sig.Results().Len(); k++ {
retlgroup.Id(fmt.Sprintf("r%d", k))
}
})
})
if sig.Results().Len() == 0 {
rgroup.Return()
} else {
rgroup.Return(List(retVars...))
}
})
})

Expand Down

0 comments on commit 49db926

Please sign in to comment.