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>
87 lines
2.4 KiB
Plaintext
87 lines
2.4 KiB
Plaintext
// Objective-C API for talking to issue12403 Go package.
|
|
// gobind -lang=objc issue12403
|
|
//
|
|
// File is generated by gobind. Do not edit.
|
|
|
|
#include <Foundation/Foundation.h>
|
|
#include "seq.h"
|
|
#include "_cgo_export.h"
|
|
#include "GoIssue12403.h"
|
|
|
|
static NSString* errDomain = @"go.issue12403";
|
|
|
|
@protocol goSeqRefInterface
|
|
-(GoSeqRef*) _ref;
|
|
@end
|
|
|
|
@implementation GoIssue12403Parsable {
|
|
}
|
|
|
|
- (id)initWithRef:(id)ref {
|
|
self = [super init];
|
|
if (self) { __ref = ref; }
|
|
return self;
|
|
}
|
|
|
|
- (NSString*)fromJSON:(NSString*)jstr {
|
|
int32_t refnum = go_seq_go_to_refnum(self._ref);
|
|
nstring _jstr = go_seq_from_objc_string(jstr);
|
|
nstring r0 = proxyissue12403_Parsable_FromJSON(refnum, _jstr);
|
|
NSString *_ret0_ = go_seq_to_objc_string(r0);
|
|
return _ret0_;
|
|
}
|
|
|
|
- (BOOL)toJSON:(NSString**)ret0_ error:(NSError**)error {
|
|
int32_t refnum = go_seq_go_to_refnum(self._ref);
|
|
struct proxyissue12403_Parsable_ToJSON_return res = proxyissue12403_Parsable_ToJSON(refnum);
|
|
NSString *_ret0_ = go_seq_to_objc_string(res.r0);
|
|
NSString *_error = go_seq_to_objc_string(res.r1);
|
|
*ret0_ = _ret0_;
|
|
if ([_error length] != 0 && error != nil) {
|
|
NSMutableDictionary* details = [NSMutableDictionary dictionary];
|
|
[details setValue:_error forKey:NSLocalizedDescriptionKey];
|
|
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
|
|
}
|
|
return ([_error length] == 0);
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
|
|
@autoreleasepool {
|
|
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
|
|
NSString *_jstr = go_seq_to_objc_string(jstr);
|
|
NSString* returnVal = [o fromJSON:_jstr];
|
|
nstring _returnVal = go_seq_from_objc_string(returnVal);
|
|
return _returnVal;
|
|
}
|
|
}
|
|
|
|
struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
|
|
@autoreleasepool {
|
|
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
|
|
NSString* ret0_;
|
|
NSError* error = nil;
|
|
BOOL returnVal = [o toJSON:&ret0_ error:&error];
|
|
nstring _ret0_ = go_seq_from_objc_string(ret0_);
|
|
NSString *error_str = nil;
|
|
if (!returnVal) {
|
|
error_str = [error localizedDescription];
|
|
if (error_str == nil || error_str.length == 0) {
|
|
error_str = @"gobind: unknown error";
|
|
}
|
|
}
|
|
nstring _error_str = go_seq_from_objc_string(error_str);
|
|
cproxyissue12403_Parsable_ToJSON_return _sres = {
|
|
_ret0_, _error_str
|
|
};
|
|
return _sres;
|
|
}
|
|
}
|
|
|
|
__attribute__((constructor)) static void init() {
|
|
init_seq();
|
|
}
|