// Objective-C API for talking to golang.org/x/mobile/bind/objc/testpkg Go package. // gobind -lang=objc golang.org/x/mobile/bind/objc/testpkg // // File is generated by gobind. Do not edit. #include "GoTestpkg.h" #include #include "seq.h" #include "_cgo_export.h" static NSString* errDomain = @"go.golang.org/x/mobile/bind/objc/testpkg"; @protocol goSeqRefInterface -(GoSeqRef*) _ref; @end @class GoTestpkgI; @class GoTestpkgNullTest; @class GoTestpkgZ; @interface GoTestpkgI : NSObject { } @property(strong, readonly) id _ref; - (id)initWithRef:(id)ref; - (BOOL)error:(BOOL)triggerError error:(NSError**)error; - (BOOL)stringError:(NSString*)s ret0_:(NSString**)ret0_ error:(NSError**)error; - (int64_t)times:(int32_t)v; @end @interface GoTestpkgNullTest : NSObject { } @property(strong, readonly) id _ref; - (id)initWithRef:(id)ref; - (id)null; @end @interface GoTestpkgZ : NSObject { } @property(strong, readonly) id _ref; - (id)initWithRef:(id)ref; @end @implementation GoTestpkgNode { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (NSString*)v { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring r0 = proxytestpkg_Node_V_Get(refnum); NSString *_r0 = go_seq_to_objc_string(r0); return _r0; } - (void)setV:(NSString*)v { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring _v = go_seq_from_objc_string(v); proxytestpkg_Node_V_Set(refnum, _v); } - (NSString*)err { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring r0 = proxytestpkg_Node_Err_Get(refnum); NSString *_r0 = go_seq_to_objc_string(r0); return _r0; } - (void)setErr:(NSString*)v { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring _v = go_seq_from_objc_string(v); proxytestpkg_Node_Err_Set(refnum, _v); } @end @implementation GoTestpkgNullFieldStruct { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (GoTestpkgS*)f { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t r0 = proxytestpkg_NullFieldStruct_F_Get(refnum); GoTestpkgS* _r0 = nil; GoSeqRef* _r0_ref = go_seq_from_refnum(r0); if (_r0_ref != NULL) { _r0 = _r0_ref.obj; if (_r0 == nil) { _r0 = [[GoTestpkgS alloc] initWithRef:_r0_ref]; } } return _r0; } - (void)setF:(GoTestpkgS*)v { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t _v; if ([(id)(v) isKindOfClass:[GoTestpkgS class]]) { id v_proxy = (id)(v); _v = go_seq_go_to_refnum(v_proxy._ref); } else { _v = go_seq_to_refnum(v); } proxytestpkg_NullFieldStruct_F_Set(refnum, _v); } @end @implementation GoTestpkgS { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (double)x { int32_t refnum = go_seq_go_to_refnum(self._ref); double r0 = proxytestpkg_S_X_Get(refnum); double _r0 = (double)r0; return _r0; } - (void)setX:(double)v { int32_t refnum = go_seq_go_to_refnum(self._ref); double _v = (double)v; proxytestpkg_S_X_Set(refnum, _v); } - (double)y { int32_t refnum = go_seq_go_to_refnum(self._ref); double r0 = proxytestpkg_S_Y_Get(refnum); double _r0 = (double)r0; return _r0; } - (void)setY:(double)v { int32_t refnum = go_seq_go_to_refnum(self._ref); double _v = (double)v; proxytestpkg_S_Y_Set(refnum, _v); } - (double)sum { int32_t refnum = go_seq_go_to_refnum(self._ref); double r0 = proxytestpkg_S_Sum(refnum); double _ret0_ = (double)r0; return _ret0_; } - (NSString*)tryTwoStrings:(NSString*)first second:(NSString*)second { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring _first = go_seq_from_objc_string(first); nstring _second = go_seq_from_objc_string(second); nstring r0 = proxytestpkg_S_TryTwoStrings(refnum, _first, _second); NSString *_ret0_ = go_seq_to_objc_string(r0); return _ret0_; } @end @implementation GoTestpkgStructThatStartsWithLetterBeforeZ { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (id)value { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t r0 = proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Get(refnum); id _r0 = nil; GoSeqRef* _r0_ref = go_seq_from_refnum(r0); if (_r0_ref != NULL) { _r0 = _r0_ref.obj; if (_r0 == nil) { _r0 = [[GoTestpkgZ alloc] initWithRef:_r0_ref]; } } return _r0; } - (void)setValue:(id)v { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t _v; if ([(id)(v) isKindOfClass:[GoTestpkgZ class]]) { id v_proxy = (id)(v); _v = go_seq_go_to_refnum(v_proxy._ref); } else { _v = go_seq_to_refnum(v); } proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Set(refnum, _v); } @end @implementation GoTestpkgI { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (BOOL)error:(BOOL)triggerError error:(NSError**)error { int32_t refnum = go_seq_go_to_refnum(self._ref); char _triggerError = (char)triggerError; nstring r0 = proxytestpkg_I_Error(refnum, _triggerError); NSString *_error = go_seq_to_objc_string(r0); 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); } - (BOOL)stringError:(NSString*)s ret0_:(NSString**)ret0_ error:(NSError**)error { int32_t refnum = go_seq_go_to_refnum(self._ref); nstring _s = go_seq_from_objc_string(s); struct proxytestpkg_I_StringError_return res = proxytestpkg_I_StringError(refnum, _s); 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); } - (int64_t)times:(int32_t)v { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t _v = (int32_t)v; int64_t r0 = proxytestpkg_I_Times(refnum, _v); int64_t _ret0_ = (int64_t)r0; return _ret0_; } @end @implementation GoTestpkgNullTest { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } - (id)null { int32_t refnum = go_seq_go_to_refnum(self._ref); int32_t r0 = proxytestpkg_NullTest_Null(refnum); id _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgNullTest alloc] initWithRef:_ret0__ref]; } } return _ret0_; } @end @implementation GoTestpkgZ { } - (id)initWithRef:(id)ref { self = [super init]; if (self) { __ref = ref; } return self; } @end const BOOL GoTestpkgABool = YES; const double GoTestpkgAFloat = 0.12345; NSString* const GoTestpkgALongString = @"LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString"; NSString* const GoTestpkgAString = @"a string"; const int64_t GoTestpkgAnInt = 7LL; const double GoTestpkgLog2E = 1.4426950408889634; const float GoTestpkgMaxFloat32 = 3.4028234663852886e+38; const double GoTestpkgMaxFloat64 = 1.7976931348623157e+308; const int32_t GoTestpkgMaxInt32 = 2147483647; const int64_t GoTestpkgMaxInt64 = 9223372036854775807LL; const int32_t GoTestpkgMinInt32 = -2147483648; const int64_t GoTestpkgMinInt64 = -9223372036854775807LL-1; const float GoTestpkgSmallestNonzeroFloat32 = 0; const double GoTestpkgSmallestNonzeroFloat64 = 5e-324; @implementation GoTestpkg + (void) setIntVar:(int)v { nint _v = (nint)v; var_settestpkg_IntVar(_v); } + (int) intVar { nint r0 = var_gettestpkg_IntVar(); int _r0 = (int)r0; return _r0; } + (void) setInterfaceVar:(id)v { int32_t _v; if ([(id)(v) isKindOfClass:[GoTestpkgI class]]) { id v_proxy = (id)(v); _v = go_seq_go_to_refnum(v_proxy._ref); } else { _v = go_seq_to_refnum(v); } var_settestpkg_InterfaceVar(_v); } + (id) interfaceVar { int32_t r0 = var_gettestpkg_InterfaceVar(); id _r0 = nil; GoSeqRef* _r0_ref = go_seq_from_refnum(r0); if (_r0_ref != NULL) { _r0 = _r0_ref.obj; if (_r0 == nil) { _r0 = [[GoTestpkgI alloc] initWithRef:_r0_ref]; } } return _r0; } + (void) setStringVar:(NSString*)v { nstring _v = go_seq_from_objc_string(v); var_settestpkg_StringVar(_v); } + (NSString*) stringVar { nstring r0 = var_gettestpkg_StringVar(); NSString *_r0 = go_seq_to_objc_string(r0); return _r0; } + (void) setStructVar:(GoTestpkgNode*)v { int32_t _v; if ([(id)(v) isKindOfClass:[GoTestpkgNode class]]) { id v_proxy = (id)(v); _v = go_seq_go_to_refnum(v_proxy._ref); } else { _v = go_seq_to_refnum(v); } var_settestpkg_StructVar(_v); } + (GoTestpkgNode*) structVar { int32_t r0 = var_gettestpkg_StructVar(); GoTestpkgNode* _r0 = nil; GoSeqRef* _r0_ref = go_seq_from_refnum(r0); if (_r0_ref != NULL) { _r0 = _r0_ref.obj; if (_r0 == nil) { _r0 = [[GoTestpkgNode alloc] initWithRef:_r0_ref]; } } return _r0; } @end NSData* GoTestpkgBytesAppend(NSData* a, NSData* b) { nbyteslice _a = go_seq_from_objc_bytearray(a, 0); nbyteslice _b = go_seq_from_objc_bytearray(b, 0); nbyteslice r0 = proxytestpkg__BytesAppend(_a, _b); if (![a isKindOfClass:[NSMutableData class]]) { free(_a.ptr); } if (![b isKindOfClass:[NSMutableData class]]) { free(_b.ptr); } NSData *_ret0_ = go_seq_to_objc_bytearray(r0, 1); return _ret0_; } BOOL GoTestpkgCallIError(id i, BOOL triggerError, NSError** error) { int32_t _i; if ([(id)(i) isKindOfClass:[GoTestpkgI class]]) { id i_proxy = (id)(i); _i = go_seq_go_to_refnum(i_proxy._ref); } else { _i = go_seq_to_refnum(i); } char _triggerError = (char)triggerError; nstring r0 = proxytestpkg__CallIError(_i, _triggerError); NSString *_error = go_seq_to_objc_string(r0); 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); } BOOL GoTestpkgCallIStringError(id i, NSString* s, NSString** ret0_, NSError** error) { int32_t _i; if ([(id)(i) isKindOfClass:[GoTestpkgI class]]) { id i_proxy = (id)(i); _i = go_seq_go_to_refnum(i_proxy._ref); } else { _i = go_seq_to_refnum(i); } nstring _s = go_seq_from_objc_string(s); struct proxytestpkg__CallIStringError_return res = proxytestpkg__CallIStringError(_i, _s); 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); } double GoTestpkgCallSSum(GoTestpkgS* s) { int32_t _s; if ([(id)(s) isKindOfClass:[GoTestpkgS class]]) { id s_proxy = (id)(s); _s = go_seq_go_to_refnum(s_proxy._ref); } else { _s = go_seq_to_refnum(s); } double r0 = proxytestpkg__CallSSum(_s); double _ret0_ = (double)r0; return _ret0_; } BOOL GoTestpkgCallWithNull(id p0, id nuller) { int32_t _p0; if ([(id)(p0) isKindOfClass:[GoTestpkgNullTest class]]) { id p0_proxy = (id)(p0); _p0 = go_seq_go_to_refnum(p0_proxy._ref); } else { _p0 = go_seq_to_refnum(p0); } int32_t _nuller; if ([(id)(nuller) isKindOfClass:[GoTestpkgNullTest class]]) { id nuller_proxy = (id)(nuller); _nuller = go_seq_go_to_refnum(nuller_proxy._ref); } else { _nuller = go_seq_to_refnum(nuller); } char r0 = proxytestpkg__CallWithNull(_p0, _nuller); BOOL _ret0_ = r0 ? YES : NO; return _ret0_; } int GoTestpkgCollectS(int want, int timeoutSec) { nint _want = (nint)want; nint _timeoutSec = (nint)timeoutSec; nint r0 = proxytestpkg__CollectS(_want, _timeoutSec); int _ret0_ = (int)r0; return _ret0_; } NSString* GoTestpkgEcho(NSString* s) { nstring _s = go_seq_from_objc_string(s); nstring r0 = proxytestpkg__Echo(_s); NSString *_ret0_ = go_seq_to_objc_string(r0); return _ret0_; } void GoTestpkgGC() { proxytestpkg__GC(); } NSString* GoTestpkgHello(NSString* s) { nstring _s = go_seq_from_objc_string(s); nstring r0 = proxytestpkg__Hello(_s); NSString *_ret0_ = go_seq_to_objc_string(r0); return _ret0_; } void GoTestpkgHi() { proxytestpkg__Hi(); } void GoTestpkgInt(int32_t x) { int32_t _x = (int32_t)x; proxytestpkg__Int(_x); } int64_t GoTestpkgMultiply(int32_t idx, int32_t val) { int32_t _idx = (int32_t)idx; int32_t _val = (int32_t)val; int64_t r0 = proxytestpkg__Multiply(_idx, _val); int64_t _ret0_ = (int64_t)r0; return _ret0_; } id GoTestpkgNewI() { int32_t r0 = proxytestpkg__NewI(); id _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgI alloc] initWithRef:_ret0__ref]; } } return _ret0_; } GoTestpkgNode* GoTestpkgNewNode(NSString* name) { nstring _name = go_seq_from_objc_string(name); int32_t r0 = proxytestpkg__NewNode(_name); GoTestpkgNode* _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgNode alloc] initWithRef:_ret0__ref]; } } return _ret0_; } GoTestpkgNullFieldStruct* GoTestpkgNewNullFieldStruct() { int32_t r0 = proxytestpkg__NewNullFieldStruct(); GoTestpkgNullFieldStruct* _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgNullFieldStruct alloc] initWithRef:_ret0__ref]; } } return _ret0_; } id GoTestpkgNewNullInterface() { int32_t r0 = proxytestpkg__NewNullInterface(); id _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgI alloc] initWithRef:_ret0__ref]; } } return _ret0_; } GoTestpkgS* GoTestpkgNewNullStruct() { int32_t r0 = proxytestpkg__NewNullStruct(); GoTestpkgS* _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgS alloc] initWithRef:_ret0__ref]; } } return _ret0_; } GoTestpkgS* GoTestpkgNewS(double x, double y) { double _x = (double)x; double _y = (double)y; int32_t r0 = proxytestpkg__NewS(_x, _y); GoTestpkgS* _ret0_ = nil; GoSeqRef* _ret0__ref = go_seq_from_refnum(r0); if (_ret0__ref != NULL) { _ret0_ = _ret0__ref.obj; if (_ret0_ == nil) { _ret0_ = [[GoTestpkgS alloc] initWithRef:_ret0__ref]; } } return _ret0_; } BOOL GoTestpkgReadIntoByteArray(NSData* s, int* ret0_, NSError** error) { nbyteslice _s = go_seq_from_objc_bytearray(s, 0); struct proxytestpkg__ReadIntoByteArray_return res = proxytestpkg__ReadIntoByteArray(_s); if (![s isKindOfClass:[NSMutableData class]]) { free(_s.ptr); } int _ret0_ = (int)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); } void GoTestpkgRegisterI(int32_t idx, id i) { int32_t _idx = (int32_t)idx; int32_t _i; if ([(id)(i) isKindOfClass:[GoTestpkgI class]]) { id i_proxy = (id)(i); _i = go_seq_go_to_refnum(i_proxy._ref); } else { _i = go_seq_to_refnum(i); } proxytestpkg__RegisterI(_idx, _i); } BOOL GoTestpkgReturnsError(BOOL b, NSString** ret0_, NSError** error) { char _b = (char)b; struct proxytestpkg__ReturnsError_return res = proxytestpkg__ReturnsError(_b); 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); } NSString* GoTestpkgStringDup(NSString* s) { nstring _s = go_seq_from_objc_string(s); nstring r0 = proxytestpkg__StringDup(_s); NSString *_ret0_ = go_seq_to_objc_string(r0); return _ret0_; } int64_t GoTestpkgSum(int64_t x, int64_t y) { int64_t _x = (int64_t)x; int64_t _y = (int64_t)y; int64_t r0 = proxytestpkg__Sum(_x, _y); int64_t _ret0_ = (int64_t)r0; return _ret0_; } void GoTestpkgUnregisterI(int32_t idx) { int32_t _idx = (int32_t)idx; proxytestpkg__UnregisterI(_idx); } nstring cproxytestpkg_I_Error(int32_t refnum, char triggerError) { id o = go_seq_objc_from_refnum(refnum); BOOL _triggerError = triggerError ? YES : NO; NSError* error = nil; BOOL returnVal = [o error:_triggerError error:&error]; 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); return _error_str; } struct cproxytestpkg_I_StringError_return cproxytestpkg_I_StringError(int32_t refnum, nstring s) { id o = go_seq_objc_from_refnum(refnum); NSString *_s = go_seq_to_objc_string(s); NSString* ret0_; NSError* error = nil; BOOL returnVal = [o stringError:_s ret0_:&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); cproxytestpkg_I_StringError_return _sres = { _ret0_, _error_str }; return _sres; } int64_t cproxytestpkg_I_Times(int32_t refnum, int32_t v) { id o = go_seq_objc_from_refnum(refnum); int32_t _v = (int32_t)v; int64_t returnVal = [o times:_v]; int64_t _returnVal = (int64_t)returnVal; return _returnVal; } int32_t cproxytestpkg_NullTest_Null(int32_t refnum) { id o = go_seq_objc_from_refnum(refnum); id returnVal = [o null]; int32_t _returnVal; if ([(id)(returnVal) isKindOfClass:[GoTestpkgNullTest class]]) { id returnVal_proxy = (id)(returnVal); _returnVal = go_seq_go_to_refnum(returnVal_proxy._ref); } else { _returnVal = go_seq_to_refnum(returnVal); } return _returnVal; } __attribute__((constructor)) static void init() { init_seq(); }