github.com/cyrilou242/gomobile-java@v0.0.0-20220215185836-09daef25a210/bind/testdata/structs.objc.m.golden (about)

     1  // Objective-C API for talking to structs Go package.
     2  //   gobind -lang=objc structs
     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 "Structs.objc.h"
    10  
    11  
    12  @implementation StructsS {
    13  }
    14  
    15  - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
    16  	self = [super init];
    17  	if (self) { __ref = ref; }
    18  	return self;
    19  }
    20  
    21  - (nonnull instancetype)init {
    22  	self = [super init];
    23  	if (self) {
    24  		__ref = go_seq_from_refnum(new_structs_S());
    25  	}
    26  	return self;
    27  }
    28  
    29  - (double)x {
    30  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    31  	double r0 = proxystructs_S_X_Get(refnum);
    32  	double _r0 = (double)r0;
    33  	return _r0;
    34  }
    35  
    36  - (void)setX:(double)v {
    37  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    38  	double _v = (double)v;
    39  	proxystructs_S_X_Set(refnum, _v);
    40  }
    41  
    42  - (double)y {
    43  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    44  	double r0 = proxystructs_S_Y_Get(refnum);
    45  	double _r0 = (double)r0;
    46  	return _r0;
    47  }
    48  
    49  - (void)setY:(double)v {
    50  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    51  	double _v = (double)v;
    52  	proxystructs_S_Y_Set(refnum, _v);
    53  }
    54  
    55  - (StructsS* _Nullable)identity:(NSError* _Nullable* _Nullable)error {
    56  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    57  	struct proxystructs_S_Identity_return res = proxystructs_S_Identity(refnum);
    58  	StructsS* _ret0_ = nil;
    59  	GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
    60  	if (_ret0__ref != NULL) {
    61  		_ret0_ = _ret0__ref.obj;
    62  		if (_ret0_ == nil) {
    63  			_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
    64  		}
    65  	}
    66  	Universeerror* _error = nil;
    67  	GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
    68  	if (_error_ref != NULL) {
    69  		_error = _error_ref.obj;
    70  		if (_error == nil) {
    71  			_error = [[Universeerror alloc] initWithRef:_error_ref];
    72  		}
    73  	}
    74  	if (_error != nil && error != nil) {
    75  		*error = _error;
    76  	}
    77  	if (_error != nil) {
    78  		return nil;
    79  	}
    80  	return _ret0_;
    81  }
    82  
    83  - (double)sum {
    84  	int32_t refnum = go_seq_go_to_refnum(self._ref);
    85  	double r0 = proxystructs_S_Sum(refnum);
    86  	double _ret0_ = (double)r0;
    87  	return _ret0_;
    88  }
    89  
    90  @end
    91  
    92  
    93  
    94  @implementation StructsS2 {
    95  }
    96  
    97  - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
    98  	self = [super init];
    99  	if (self) { __ref = ref; }
   100  	return self;
   101  }
   102  
   103  - (nonnull instancetype)init {
   104  	self = [super init];
   105  	if (self) {
   106  		__ref = go_seq_from_refnum(new_structs_S2());
   107  	}
   108  	return self;
   109  }
   110  
   111  - (void)m {
   112  	int32_t refnum = go_seq_go_to_refnum(self._ref);
   113  	proxystructs_S2_M(refnum);
   114  }
   115  
   116  - (NSString* _Nonnull)string {
   117  	int32_t refnum = go_seq_go_to_refnum(self._ref);
   118  	nstring r0 = proxystructs_S2_String(refnum);
   119  	NSString *_ret0_ = go_seq_to_objc_string(r0);
   120  	return _ret0_;
   121  }
   122  
   123  @end
   124  
   125  
   126  
   127  @implementation StructsStructs {
   128  }
   129  
   130  - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
   131  	self = [super init];
   132  	if (self) { __ref = ref; }
   133  	return self;
   134  }
   135  
   136  - (nonnull instancetype)init {
   137  	self = [super init];
   138  	if (self) {
   139  		__ref = go_seq_from_refnum(new_structs_Structs());
   140  	}
   141  	return self;
   142  }
   143  
   144  - (void)m {
   145  	int32_t refnum = go_seq_go_to_refnum(self._ref);
   146  	proxystructs_Structs_M(refnum);
   147  }
   148  
   149  @end
   150  
   151  
   152  @implementation StructsI {
   153  }
   154  
   155  - (nonnull instancetype)initWithRef:(id)ref {
   156  	self = [super init];
   157  	if (self) { __ref = ref; }
   158  	return self;
   159  }
   160  
   161  - (void)m {
   162  	int32_t refnum = go_seq_go_to_refnum(self._ref);
   163  	proxystructs_I_M(refnum);
   164  }
   165  
   166  @end
   167  
   168  
   169  
   170  StructsS* _Nullable StructsIdentity(StructsS* _Nullable s) {
   171  	int32_t _s;
   172  	if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
   173  		id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
   174  		_s = go_seq_go_to_refnum(s_proxy._ref);
   175  	} else {
   176  		_s = go_seq_to_refnum(s);
   177  	}
   178  	int32_t r0 = proxystructs__Identity(_s);
   179  	StructsS* _ret0_ = nil;
   180  	GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
   181  	if (_ret0__ref != NULL) {
   182  		_ret0_ = _ret0__ref.obj;
   183  		if (_ret0_ == nil) {
   184  			_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
   185  		}
   186  	}
   187  	return _ret0_;
   188  }
   189  
   190  StructsS* _Nullable StructsIdentityWithError(StructsS* _Nullable s, NSError* _Nullable* _Nullable error) {
   191  	int32_t _s;
   192  	if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
   193  		id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
   194  		_s = go_seq_go_to_refnum(s_proxy._ref);
   195  	} else {
   196  		_s = go_seq_to_refnum(s);
   197  	}
   198  	struct proxystructs__IdentityWithError_return res = proxystructs__IdentityWithError(_s);
   199  	StructsS* _ret0_ = nil;
   200  	GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
   201  	if (_ret0__ref != NULL) {
   202  		_ret0_ = _ret0__ref.obj;
   203  		if (_ret0_ == nil) {
   204  			_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
   205  		}
   206  	}
   207  	Universeerror* _error = nil;
   208  	GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
   209  	if (_error_ref != NULL) {
   210  		_error = _error_ref.obj;
   211  		if (_error == nil) {
   212  			_error = [[Universeerror alloc] initWithRef:_error_ref];
   213  		}
   214  	}
   215  	if (_error != nil && error != nil) {
   216  		*error = _error;
   217  	}
   218  	if (_error != nil) {
   219  		return nil;
   220  	}
   221  	return _ret0_;
   222  }
   223  
   224  void cproxystructs_I_M(int32_t refnum) {
   225  	@autoreleasepool {
   226  		StructsI* o = go_seq_objc_from_refnum(refnum);
   227  		[o m];
   228  	}
   229  }
   230  
   231  __attribute__((constructor)) static void init() {
   232  	init_seq();
   233  }