diff --git a/bind/gengo.go b/bind/gengo.go index 1b8ac3c..f4467fe 100644 --- a/bind/gengo.go +++ b/bind/gengo.go @@ -24,6 +24,7 @@ func (g *goGen) errorf(format string, args ...interface{}) { } const goPreamble = `// Package go_%s is an autogenerated binder stub for package %s. +// gobind -lang=go %s // // File is generated by gobind. Do not edit. package go_%s @@ -37,7 +38,7 @@ import ( func (g *goGen) genPreamble() { n := g.pkg.Name() - g.Printf(goPreamble, n, n, n, g.pkg.Path()) + g.Printf(goPreamble, n, n, g.pkg.Path(), n, g.pkg.Path()) } func (g *goGen) genFuncBody(o *types.Func, selectorLHS string) { diff --git a/bind/genjava.go b/bind/genjava.go index 23238e9..6e462cd 100644 --- a/bind/genjava.go +++ b/bind/genjava.go @@ -478,6 +478,7 @@ func (g *javaGen) errorf(format string, args ...interface{}) { } const javaPreamble = `// Java Package %s is a proxy for talking to a Go program. +// gobind -lang=java %s // // File is generated by gobind. Do not edit. package go.%s; @@ -487,7 +488,7 @@ import go.Seq; ` func (g *javaGen) gen() error { - g.Printf(javaPreamble, g.pkg.Name(), g.pkg.Name()) + g.Printf(javaPreamble, g.pkg.Name(), g.pkg.Path(), g.pkg.Name()) firstRune, size := utf8.DecodeRuneInString(g.pkg.Name()) className := string(unicode.ToUpper(firstRune)) + g.pkg.Name()[size:] diff --git a/bind/java/testpkg/Testpkg.java b/bind/java/testpkg/Testpkg.java index e50f800..0435faa 100644 --- a/bind/java/testpkg/Testpkg.java +++ b/bind/java/testpkg/Testpkg.java @@ -1,13 +1,15 @@ // Java Package testpkg is a proxy for talking to a Go program. +// gobind -lang=java code.google.com/p/go.mobile/bind/java/testpkg // // File is generated by gobind. Do not edit. -// Or do, I'm a comment, not a cop. package go.testpkg; import go.Seq; -public final class Testpkg { - public long Add(long x, long y) { +public abstract class Testpkg { + private Testpkg() {} // uninstantiable + + public static long Add(long x, long y) { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); long _result; @@ -18,14 +20,14 @@ public final class Testpkg { return _result; } - public void Call(I i) { + public static void Call(I i) { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); _in.writeRef(i.ref()); Seq.send(DESCRIPTOR, CALL_Call, _in, _out); } - public void GC() { + public static void GC() { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); Seq.send(DESCRIPTOR, CALL_GC, _in, _out); @@ -47,7 +49,6 @@ public final class Testpkg { public void call(int code, go.Seq in, go.Seq out) { switch (code) { case Proxy.CALL_F: { - // TODO(crawshaw): handle catching a Exception this.F(); return; } @@ -73,21 +74,22 @@ public final class Testpkg { public void F() { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); + _in.writeRef(ref); Seq.send(DESCRIPTOR, CALL_F, _in, _out); } - static final int CALL_F = 0x0a01; + static final int CALL_F = 0x10a; } } - public void Keep(I i) { + public static void Keep(I i) { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); _in.writeRef(i.ref()); Seq.send(DESCRIPTOR, CALL_Keep, _in, _out); } - public S New() { + public static S New() { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); S _result; @@ -96,7 +98,7 @@ public final class Testpkg { return _result; } - public long NumSCollected() { + public static long NumSCollected() { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); long _result; @@ -107,7 +109,7 @@ public final class Testpkg { public static final class S implements go.Seq.Object { private static final String DESCRIPTOR = "go.testpkg.S"; - private static final int CALL_F = 0x0c00; + private static final int CALL_F = 0x00c; private go.Seq.Ref ref; @@ -116,7 +118,7 @@ public final class Testpkg { public go.Seq.Ref ref() { return ref; } public void call(int code, go.Seq in, go.Seq out) { - throw new RuntimeException("cycle: cannot call concrete proxy"); + throw new RuntimeException("internal error: cycle: cannot call concrete proxy"); } @@ -140,7 +142,6 @@ public final class Testpkg { } @Override public String toString() { - // TODO(crawshaw): use String() string if it is defined. StringBuilder b = new StringBuilder(); b.append("S").append("{"); return b.append("}").toString(); @@ -155,6 +156,4 @@ public final class Testpkg { private static final int CALL_New = 5; private static final int CALL_NumSCollected = 6; private static final String DESCRIPTOR = "testpkg"; - - public static Testpkg instance = new Testpkg(); } diff --git a/bind/java/testpkg/go_testpkg/go_testpkg.go b/bind/java/testpkg/go_testpkg/go_testpkg.go index 03f7e1d..8cb9a60 100644 --- a/bind/java/testpkg/go_testpkg/go_testpkg.go +++ b/bind/java/testpkg/go_testpkg/go_testpkg.go @@ -1,7 +1,7 @@ // Package go_testpkg is an autogenerated binder stub for package testpkg. +// gobind -lang=go code.google.com/p/go.mobile/bind/java/testpkg // // File is generated by gobind. Do not edit. -// Or do, I'm a comment, not a cop. package go_testpkg import ( @@ -13,7 +13,6 @@ func proxy_Add(out, in *seq.Buffer) { param_x := in.ReadInt() param_y := in.ReadInt() res := testpkg.Add(param_x, param_y) - // TODO out.WriteNoException(); out.WriteInt(res) } @@ -26,24 +25,21 @@ func proxy_Call(out, in *seq.Buffer) { param_i = (*proxyI)(param_i_ref) } testpkg.Call(param_i) - // TODO out.WriteNoException(); } func proxy_GC(out, in *seq.Buffer) { testpkg.GC() - // TODO out.WriteNoException(); } const ( proxyIDescriptor = "go.testpkg.I" - proxyIFCode = 0x0a01 + proxyIFCode = 0x10a ) type proxyI seq.Ref func (p *proxyI) F() { out := new(seq.Buffer) - //out.WriteRef((*seq.Ref)(p)) seq.Transact((*seq.Ref)(p), proxyIFCode, out) } @@ -56,24 +52,21 @@ func proxy_Keep(out, in *seq.Buffer) { param_i = (*proxyI)(param_i_ref) } testpkg.Keep(param_i) - // TODO out.WriteNoException(); } func proxy_New(out, in *seq.Buffer) { res := testpkg.New() - // TODO out.WriteNoException(); out.WriteGoRef(res) } func proxy_NumSCollected(out, in *seq.Buffer) { res := testpkg.NumSCollected() - // TODO out.WriteNoException(); out.WriteInt(res) } const ( proxySDescriptor = "go.testpkg.S" - proxySFCode = 0x0c00 + proxySFCode = 0x00c ) type proxyS seq.Ref @@ -82,7 +75,6 @@ func proxySF(out, in *seq.Buffer) { ref := in.ReadRef() v := ref.Get().(*testpkg.S) v.F() - // TODO out.WriteNoException(); } func init() { diff --git a/bind/testdata/basictypes.go.golden b/bind/testdata/basictypes.go.golden index 32a4f10..b24898b 100644 --- a/bind/testdata/basictypes.go.golden +++ b/bind/testdata/basictypes.go.golden @@ -1,11 +1,12 @@ // Package go_basictypes is an autogenerated binder stub for package basictypes. +// gobind -lang=go basictypes // // File is generated by gobind. Do not edit. package go_basictypes import ( "basictypes" - "code.google.com/p/go.mobile/bind/seq" + "golang.org/x/mobile/bind/seq" ) func proxy_Error(out, in *seq.Buffer) { diff --git a/bind/testdata/basictypes.java.golden b/bind/testdata/basictypes.java.golden index 675512a..56ede5d 100644 --- a/bind/testdata/basictypes.java.golden +++ b/bind/testdata/basictypes.java.golden @@ -1,4 +1,5 @@ // Java Package basictypes is a proxy for talking to a Go program. +// gobind -lang=java basictypes // // File is generated by gobind. Do not edit. package go.basictypes; diff --git a/bind/testdata/interfaces.go.golden b/bind/testdata/interfaces.go.golden index 73e6327..e72cdcc 100644 --- a/bind/testdata/interfaces.go.golden +++ b/bind/testdata/interfaces.go.golden @@ -1,10 +1,11 @@ // Package go_interfaces is an autogenerated binder stub for package interfaces. +// gobind -lang=go interfaces // // File is generated by gobind. Do not edit. package go_interfaces import ( - "code.google.com/p/go.mobile/bind/seq" + "golang.org/x/mobile/bind/seq" "interfaces" ) diff --git a/bind/testdata/interfaces.java.golden b/bind/testdata/interfaces.java.golden index 45afaa4..9d0a72d 100644 --- a/bind/testdata/interfaces.java.golden +++ b/bind/testdata/interfaces.java.golden @@ -1,4 +1,5 @@ // Java Package interfaces is a proxy for talking to a Go program. +// gobind -lang=java interfaces // // File is generated by gobind. Do not edit. package go.interfaces; diff --git a/bind/testdata/structs.go.golden b/bind/testdata/structs.go.golden index 7e879fa..b32ec0d 100644 --- a/bind/testdata/structs.go.golden +++ b/bind/testdata/structs.go.golden @@ -1,10 +1,11 @@ // Package go_structs is an autogenerated binder stub for package structs. +// gobind -lang=go structs // // File is generated by gobind. Do not edit. package go_structs import ( - "code.google.com/p/go.mobile/bind/seq" + "golang.org/x/mobile/bind/seq" "structs" ) diff --git a/bind/testdata/structs.java.golden b/bind/testdata/structs.java.golden index 9cd0777..ced08fe 100644 --- a/bind/testdata/structs.java.golden +++ b/bind/testdata/structs.java.golden @@ -1,4 +1,5 @@ // Java Package structs is a proxy for talking to a Go program. +// gobind -lang=java structs // // File is generated by gobind. Do not edit. package go.structs; diff --git a/example/libhello/hi/go_hi/go_hi.go b/example/libhello/hi/go_hi/go_hi.go index 295f96a..b3cb80b 100644 --- a/example/libhello/hi/go_hi/go_hi.go +++ b/example/libhello/hi/go_hi/go_hi.go @@ -1,4 +1,5 @@ // Package go_hi is an autogenerated binder stub for package hi. +// gobind -lang=go code.google.com/p/go.mobile/example/libhello/hi // // File is generated by gobind. Do not edit. package go_hi