bind: support reference types as struct fields.

Reference types here mean pointers to struct types and
exported interface types. Previously, gobind generated invalid
go/java sources.

Change-Id: Icd666ebbb8edb70c613311798d602fd88cb4479c
Reviewed-on: https://go-review.googlesource.com/9997
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Hyang-Ah (Hana) Kim
2015-05-14 19:48:46 +00:00
committed by Hyang-Ah Hana Kim
parent 536b3a3197
commit b658bfdf39
5 changed files with 45 additions and 8 deletions
+6 -3
View File
@@ -76,7 +76,11 @@ public void call(int code, go.Seq in, go.Seq out) {
g.Printf("Seq out = new Seq();\n")
g.Printf("in.writeRef(ref);\n")
g.Printf("Seq.send(DESCRIPTOR, FIELD_%s_GET, in, out);\n", f.Name())
g.Printf("return out.read%s;\n", seqRead(f.Type()))
if seqType(f.Type()) == "Ref" {
g.Printf("return new %s(out.read%s);\n", g.javaType(f.Type()), seqRead(f.Type()))
} else {
g.Printf("return out.read%s;\n", seqRead(f.Type()))
}
g.Outdent()
g.Printf("}\n\n")
@@ -88,9 +92,8 @@ public void call(int code, go.Seq in, go.Seq out) {
g.Printf("in.write%s;\n", seqWrite(f.Type(), "v"))
g.Printf("Seq.send(DESCRIPTOR, FIELD_%s_SET, in, out);\n", f.Name())
g.Outdent()
g.Printf("}\n")
g.Printf("}\n\n")
}
g.Printf("\n")
for _, m := range methods {
g.genFunc(m, true)