Change func out-type from struct to bare type

This commit is contained in:
Nigel Tao committed 2018-07-29 10:02:06 +10:00
1 parent af7b15bc17
commit 9919d78245
19 files changed
+236 -239

No files matched your search

+11 -12
View File
@@ -296,21 +296,20 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
}
// TODO: look at n.Asserts().
fmt.Fprintf(out, "pub func %s.%s%s(", n.Receiver().Str(&h.tm), n.FuncName().Str(&h.tm), effect)
for i, param := range [2]*a.Struct{n.In(), n.Out()} {
for i, field := range n.In().Fields() {
field := field.AsField()
if i > 0 {
fmt.Fprintf(out, ")(")
}
for j, field := range param.Fields() {
field := field.AsField()
if j > 0 {
fmt.Fprintf(out, ", ")
}
// TODO: what happens if the XType is from another
// package?
fmt.Fprintf(out, "%s %s", field.Name().Str(&h.tm), field.XType().Str(&h.tm))
fmt.Fprintf(out, ", ")
}
// TODO: what happens if the XType is from another package?
// Similarly for the out-param.
fmt.Fprintf(out, "%s %s", field.Name().Str(&h.tm), field.XType().Str(&h.tm))
}
fmt.Fprintf(out, ") { }\n")
fmt.Fprintf(out, ") ")
if o := n.Out(); o != nil {
fmt.Fprintf(out, "%s", o.Str(&h.tm))
}
fmt.Fprintf(out, " { }\n")
case a.KStatus:
n := n.AsStatus()