mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
bind: fix field accessors for Go implemented Java classes
The go_seq_to_refnum function handles its argument object as a Java object if it doesn't implement Seq.Proxy. Java classes implemented in Go does not implement Seq.Proxy, but when passing "this" references to Go, instances must be treated as a Go object. Use go_seq_to_refnum_go everywhere "this" is passed to Go, which fixes field accessors and simplifies the method call case. Change-Id: I3d01c63d7b2081e6344ece431f5e5021a9dd7662 Reviewed-on: https://go-review.googlesource.com/31171 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
+3
-9
@@ -889,7 +889,7 @@ func (g *JavaGen) genJNIField(o *types.TypeName, f *types.Var) {
|
||||
g.Printf("JNIEXPORT void JNICALL\n")
|
||||
g.Printf("Java_%s_%s_set%s(JNIEnv *env, jobject this, %s v) {\n", g.jniPkgName(), o.Name(), f.Name(), g.jniType(f.Type()))
|
||||
g.Indent()
|
||||
g.Printf("int32_t o = go_seq_to_refnum(env, this);\n")
|
||||
g.Printf("int32_t o = go_seq_to_refnum_go(env, this);\n")
|
||||
g.genJavaToC("v", f.Type(), modeRetained)
|
||||
g.Printf("proxy%s_%s_%s_Set(o, _v);\n", g.pkgPrefix, o.Name(), f.Name())
|
||||
g.genRelease("v", f.Type(), modeRetained)
|
||||
@@ -900,7 +900,7 @@ func (g *JavaGen) genJNIField(o *types.TypeName, f *types.Var) {
|
||||
g.Printf("JNIEXPORT %s JNICALL\n", g.jniType(f.Type()))
|
||||
g.Printf("Java_%s_%s_get%s(JNIEnv *env, jobject this) {\n", g.jniPkgName(), o.Name(), f.Name())
|
||||
g.Indent()
|
||||
g.Printf("int32_t o = go_seq_to_refnum(env, this);\n")
|
||||
g.Printf("int32_t o = go_seq_to_refnum_go(env, this);\n")
|
||||
g.Printf("%s r0 = ", g.cgoType(f.Type()))
|
||||
g.Printf("proxy%s_%s_%s_Get(o);\n", g.pkgPrefix, o.Name(), f.Name())
|
||||
g.genCToJava("_r0", "r0", f.Type(), modeRetained)
|
||||
@@ -996,13 +996,7 @@ func (g *JavaGen) genJNIFuncBody(o *types.Func, sName string, jm *java.Func, isj
|
||||
sig := o.Type().(*types.Signature)
|
||||
res := sig.Results()
|
||||
if sName != "" {
|
||||
if isjava {
|
||||
// We need the Go object backing this GoObject. Use
|
||||
// the _go variant (here only) to get the Go refnum.
|
||||
g.Printf("int32_t o = go_seq_to_refnum_go(env, __this__);\n")
|
||||
} else {
|
||||
g.Printf("int32_t o = go_seq_to_refnum(env, __this__);\n")
|
||||
}
|
||||
g.Printf("int32_t o = go_seq_to_refnum_go(env, __this__);\n")
|
||||
}
|
||||
params := sig.Params()
|
||||
first := 0
|
||||
|
||||
Reference in New Issue
Block a user