github.com/coming-chat/gomobile@v0.0.0-20220601074111-56995f7d7aba/bind/testdata/issue12403.objc.m.golden (about) 1 // Objective-C API for talking to issue12403 Go package. 2 // gobind -lang=objc issue12403 3 // 4 // File is generated by gobind. Do not edit. 5 6 #include <Foundation/Foundation.h> 7 #include "seq.h" 8 #include "_cgo_export.h" 9 #include "Issue12403.objc.h" 10 11 @implementation Issue12403Parsable { 12 } 13 14 - (nonnull instancetype)initWithRef:(id)ref { 15 self = [super init]; 16 if (self) { __ref = ref; } 17 return self; 18 } 19 20 - (NSString* _Nonnull)fromJSON:(NSString* _Nullable)jstr { 21 int32_t refnum = go_seq_go_to_refnum(self._ref); 22 nstring _jstr = go_seq_from_objc_string(jstr); 23 nstring r0 = proxyissue12403_Parsable_FromJSON(refnum, _jstr); 24 NSString *_ret0_ = go_seq_to_objc_string(r0); 25 return _ret0_; 26 } 27 28 - (NSString* _Nonnull)toJSON:(NSError* _Nullable* _Nullable)error { 29 int32_t refnum = go_seq_go_to_refnum(self._ref); 30 struct proxyissue12403_Parsable_ToJSON_return res = proxyissue12403_Parsable_ToJSON(refnum); 31 NSString *_ret0_ = go_seq_to_objc_string(res.r0); 32 Universeerror* _error = nil; 33 GoSeqRef* _error_ref = go_seq_from_refnum(res.r1); 34 if (_error_ref != NULL) { 35 _error = _error_ref.obj; 36 if (_error == nil) { 37 _error = [[Universeerror alloc] initWithRef:_error_ref]; 38 } 39 } 40 if (_error != nil && error != nil) { 41 *error = _error; 42 } 43 if (_error != nil) { 44 return nil; 45 } 46 return _ret0_; 47 } 48 49 @end 50 51 52 53 nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) { 54 @autoreleasepool { 55 Issue12403Parsable* o = go_seq_objc_from_refnum(refnum); 56 NSString *_jstr = go_seq_to_objc_string(jstr); 57 NSString* _Nonnull ret0_; 58 ret0_ = [o fromJSON:_jstr]; 59 nstring _ret0_ = go_seq_from_objc_string(ret0_); 60 return _ret0_; 61 } 62 } 63 64 struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) { 65 @autoreleasepool { 66 Issue12403Parsable* o = go_seq_objc_from_refnum(refnum); 67 NSString* _Nonnull ret0_; 68 NSError* error = nil; 69 ret0_ = [o toJSON:&error]; 70 nstring _ret0_ = go_seq_from_objc_string(ret0_); 71 NSError *_error = nil; 72 if (error != nil) { 73 _error = error; 74 } 75 int32_t __error; 76 if ([_error conformsToProtocol:@protocol(goSeqRefInterface)]) { 77 id<goSeqRefInterface> _error_proxy = (id<goSeqRefInterface>)(_error); 78 __error = go_seq_go_to_refnum(_error_proxy._ref); 79 } else { 80 __error = go_seq_to_refnum(_error); 81 } 82 cproxyissue12403_Parsable_ToJSON_return _sres = { 83 _ret0_, __error 84 }; 85 return _sres; 86 } 87 } 88 89 __attribute__((constructor)) static void init() { 90 init_seq(); 91 }