mobile/bind: allow bound packages to refer to imported bound packages

Multiple packages are already supported, but only as if each packages
were bound in isolation. This CL lets a bound package refer to other
bound packages in its exported functions, types and fields.

In Java, the JNI class jclass and constructor jmethodID are exported
so other packages can construct proxies of other packages' interfaces.

In ObjC, the class @interface declarations are moved from the package
.m file to its .h file to allow other packages to constructs its
interface proxies.

Add a supporting test package, secondpkg, and add Java and ObjC tests
for the new cross package functionality. Also add simplepkg for
testing corner cases where the generated Go file must not include its
bound package.

While we're here, stop generating Go proxy types for struct types;
only Go interfaces can be implemented in the foreign language.

Change-Id: Icbfa739c893703867d38a9100ed0928fbd7a660d
Reviewed-on: https://go-review.googlesource.com/20575
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Elias Naur
2016-03-12 06:23:01 +00:00
parent 31eac4e11d
commit 7df33f4a5c
51 changed files with 601 additions and 333 deletions
+7 -8
View File
@@ -6,17 +6,16 @@
#include <android/log.h>
#include <stdint.h>
#include "seq.h"
#include "structs.h"
#include "_cgo_export.h"
#include "structs.h"
static jclass proxy_class_structs_I;
static jmethodID proxy_class_structs_I_cons;
jclass proxy_class_structs_I;
jmethodID proxy_class_structs_I_cons;
static jmethodID mid_I_M;
static jclass proxy_class_structs_S;
static jmethodID proxy_class_structs_S_cons;
static jclass proxy_class_structs_S2;
static jmethodID proxy_class_structs_S2_cons;
jclass proxy_class_structs_S;
jmethodID proxy_class_structs_S_cons;
jclass proxy_class_structs_S2;
jmethodID proxy_class_structs_S2_cons;
JNIEXPORT void JNICALL
Java_go_structs_Structs_init(JNIEnv *env, jclass _unused) {