github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/bind/objc/testpkg/objc_testpkg/reference/GoTestpkg.m (about)

     1  // Objective-C API for talking to github.com/c-darwin/mobile/bind/objc/testpkg Go package.
     2  //   gobind -lang=objc github.com/c-darwin/mobile/bind/objc/testpkg
     3  //
     4  // File is generated by gobind. Do not edit.
     5  
     6  #include "GoTestpkg.h"
     7  #include <Foundation/Foundation.h>
     8  #include "seq.h"
     9  
    10  static NSString *errDomain = @"go.github.com/c-darwin/mobile/bind/objc/testpkg";
    11  
    12  #define _DESCRIPTOR_ "testpkg"
    13  
    14  #define _CALL_BytesAppend_ 1
    15  #define _CALL_CallI_ 2
    16  #define _CALL_CallSSum_ 3
    17  #define _CALL_CollectS_ 4
    18  #define _CALL_Hello_ 5
    19  #define _CALL_Hi_ 6
    20  #define _CALL_Int_ 7
    21  #define _CALL_NewS_ 8
    22  #define _CALL_ReturnsError_ 9
    23  #define _CALL_Sum_ 10
    24  
    25  #define _GO_testpkg_S_DESCRIPTOR_ "go.testpkg.S"
    26  #define _GO_testpkg_S_FIELD_X_GET_ (0x00f)
    27  #define _GO_testpkg_S_FIELD_X_SET_ (0x01f)
    28  #define _GO_testpkg_S_FIELD_Y_GET_ (0x10f)
    29  #define _GO_testpkg_S_FIELD_Y_SET_ (0x11f)
    30  #define _GO_testpkg_S_Sum_ (0x00c)
    31  
    32  #define _GO_testpkg_I_DESCRIPTOR_ "go.testpkg.I"
    33  #define _GO_testpkg_I_Fn_ 0x10a
    34  
    35  @implementation GoTestpkgI {
    36  }
    37  @synthesize delegate = _delegate;
    38  @synthesize ref = _ref;
    39  
    40  - (id)init {
    41  	self = [super init];
    42  	if (self) {
    43  		_delegate = self;
    44  		_ref = [GoSeqRef newForObject:self];
    45  	}
    46  	return self;
    47  }
    48  
    49  - (void)call:(int)code in:(void *)in out:(void *)out {
    50  	GoSeq* inseq = (GoSeq*)in;
    51  	GoSeq* outseq = (GoSeq*)out;
    52  	switch (code) {
    53  	case _GO_testpkg_I_Fn_:
    54  		{
    55  			int32_t v = go_seq_readInt32(inseq);
    56  			[_delegate Fn:v];
    57  			return;
    58  		}
    59  	default:
    60  	        NSLog(@"unknown code %s:%d", _GO_testpkg_I_DESCRIPTOR_, code);
    61  	}
    62  }
    63  
    64  @end
    65  
    66  @implementation GoTestpkgS {
    67  }
    68  
    69  - (id)initWithRef:(id)ref {
    70  	self = [super init];
    71  	if (self) { _ref = ref; }
    72  	return self;
    73  }
    74  
    75  - (double)X {
    76  	GoSeq in_ = {};
    77  	GoSeq out_ = {};
    78  	go_seq_writeRef(&in_, self.ref);
    79  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_X_GET_, &in_, &out_);
    80  	double ret_ = go_seq_readFloat64(&out_);
    81  	go_seq_free(&in_);
    82  	go_seq_free(&out_);
    83  	return ret_;
    84  }
    85  
    86  - (void)setX:(double)v {
    87  	GoSeq in_ = {};
    88  	GoSeq out_ = {};
    89  	go_seq_writeRef(&in_, self.ref);
    90  	go_seq_writeFloat64(&in_, v);
    91  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_X_SET_, &in_, &out_);
    92  	go_seq_free(&in_);
    93  	go_seq_free(&out_);
    94  }
    95  
    96  - (double)Y {
    97  	GoSeq in_ = {};
    98  	GoSeq out_ = {};
    99  	go_seq_writeRef(&in_, self.ref);
   100  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_Y_GET_, &in_, &out_);
   101  	double ret_ = go_seq_readFloat64(&out_);
   102  	go_seq_free(&in_);
   103  	go_seq_free(&out_);
   104  	return ret_;
   105  }
   106  
   107  - (void)setY:(double)v {
   108  	GoSeq in_ = {};
   109  	GoSeq out_ = {};
   110  	go_seq_writeRef(&in_, self.ref);
   111  	go_seq_writeFloat64(&in_, v);
   112  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_Y_SET_, &in_, &out_);
   113  	go_seq_free(&in_);
   114  	go_seq_free(&out_);
   115  }
   116  
   117  - (double)Sum {
   118  	GoSeq in_ = {};
   119  	GoSeq out_ = {};
   120  	go_seq_writeRef(&in_, self.ref);
   121  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_Sum_, &in_, &out_);
   122  	double ret0_ = go_seq_readFloat64(&out_);
   123  	go_seq_free(&in_);
   124  	go_seq_free(&out_);
   125  	return ret0_;
   126  }
   127  
   128  @end
   129  
   130  NSData* GoTestpkgBytesAppend(NSData* a, NSData* b) {
   131  	GoSeq in_ = {};
   132  	GoSeq out_ = {};
   133  	go_seq_writeByteArray(&in_, a);
   134  	go_seq_writeByteArray(&in_, b);
   135  	go_seq_send(_DESCRIPTOR_, _CALL_BytesAppend_, &in_, &out_);
   136  	NSData* ret0_ = go_seq_readByteArray(&out_);
   137  	go_seq_free(&in_);
   138  	go_seq_free(&out_);
   139  	return ret0_;
   140  }
   141  
   142  void GoTestpkgCallI(GoTestpkgI* i, int32_t v) {
   143  	GoSeq in_ = {};
   144  	GoSeq out_ = {};
   145  	go_seq_writeRef(&in_, i.ref);
   146  	go_seq_writeInt32(&in_, v);
   147  	go_seq_send(_DESCRIPTOR_, _CALL_CallI_, &in_, &out_);
   148  	return;
   149  }
   150  
   151  double GoTestpkgCallSSum(GoTestpkgS* s) {
   152  	GoSeq in_ = {};
   153  	GoSeq out_ = {};
   154  	go_seq_writeRef(&in_, s.ref);
   155  	go_seq_send(_DESCRIPTOR_, _CALL_CallSSum_, &in_, &out_);
   156  	double ret0_ = go_seq_readFloat64(&out_);
   157  	go_seq_free(&in_);
   158  	go_seq_free(&out_);
   159  	return ret0_;
   160  }
   161  
   162  int GoTestpkgCollectS(int want, int timeoutSec) {
   163  	GoSeq in_ = {};
   164  	GoSeq out_ = {};
   165  	go_seq_writeInt(&in_, want);
   166  	go_seq_writeInt(&in_, timeoutSec);
   167  	go_seq_send(_DESCRIPTOR_, _CALL_CollectS_, &in_, &out_);
   168  	int ret0_ = go_seq_readInt(&out_);
   169  	go_seq_free(&in_);
   170  	go_seq_free(&out_);
   171  	return ret0_;
   172  }
   173  
   174  NSString* GoTestpkgHello(NSString* s) {
   175  	GoSeq in_ = {};
   176  	GoSeq out_ = {};
   177  	go_seq_writeUTF8(&in_, s);
   178  	go_seq_send(_DESCRIPTOR_, _CALL_Hello_, &in_, &out_);
   179  	NSString* ret0_ = go_seq_readUTF8(&out_);
   180  	go_seq_free(&in_);
   181  	go_seq_free(&out_);
   182  	return ret0_;
   183  }
   184  
   185  void GoTestpkgHi() {
   186  	GoSeq in_ = {};
   187  	GoSeq out_ = {};
   188  	go_seq_send(_DESCRIPTOR_, _CALL_Hi_, &in_, &out_);
   189  	go_seq_free(&in_);
   190  	go_seq_free(&out_);
   191  }
   192  
   193  void GoTestpkgInt(int32_t x) {
   194  	GoSeq in_ = {};
   195  	GoSeq out_ = {};
   196  	go_seq_writeInt32(&in_, x);
   197  	go_seq_send(_DESCRIPTOR_, _CALL_Int_, &in_, &out_);
   198  	go_seq_free(&in_);
   199  	go_seq_free(&out_);
   200  }
   201  
   202  GoTestpkgS* GoTestpkgNewS(double x, double y) {
   203  	GoSeq in_ = {};
   204  	GoSeq out_ = {};
   205  	go_seq_writeFloat64(&in_, x);
   206  	go_seq_writeFloat64(&in_, y);
   207  	go_seq_send(_DESCRIPTOR_, _CALL_NewS_, &in_, &out_);
   208  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   209  	GoTestpkgS* ret0_ = ret0__ref.obj;
   210  	if (ret0_ == NULL) {
   211  		ret0_ = [[GoTestpkgS alloc] initWithRef:ret0__ref];
   212  	}
   213  	go_seq_free(&in_);
   214  	go_seq_free(&out_);
   215  	return ret0_;
   216  }
   217  
   218  BOOL GoTestpkgReturnsError(BOOL b, NSString** ret0_, NSError** error) {
   219  	GoSeq in_ = {};
   220  	GoSeq out_ = {};
   221  	go_seq_writeBool(&in_, b);
   222  	go_seq_send(_DESCRIPTOR_, _CALL_ReturnsError_, &in_, &out_);
   223  	NSString* ret0__val = go_seq_readUTF8(&out_);
   224  	if (ret0_ != NULL) {
   225  		*ret0_ = ret0__val;
   226  	}
   227  	NSString* _error = go_seq_readUTF8(&out_);
   228  	if ([_error length] != 0 && error != nil) {
   229  		NSMutableDictionary *details = [NSMutableDictionary dictionary];
   230  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
   231  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
   232  	}
   233  	go_seq_free(&in_);
   234  	go_seq_free(&out_);
   235  	return ([_error length] == 0);
   236  }
   237  
   238  int64_t GoTestpkgSum(int64_t x, int64_t y) {
   239  	GoSeq in_ = {};
   240  	GoSeq out_ = {};
   241  	go_seq_writeInt64(&in_, x);
   242  	go_seq_writeInt64(&in_, y);
   243  	go_seq_send(_DESCRIPTOR_, _CALL_Sum_, &in_, &out_);
   244  	int64_t ret0_ = go_seq_readInt64(&out_);
   245  	go_seq_free(&in_);
   246  	go_seq_free(&out_);
   247  	return ret0_;
   248  }
   249