github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/bind/objc/testpkg/objc_testpkg/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  @protocol goSeqRefInterface
    13  -(GoSeqRef*) ref;
    14  @end
    15  
    16  #define _DESCRIPTOR_ "testpkg"
    17  
    18  #define _CALL_BytesAppend_ 1
    19  #define _CALL_CallIError_ 2
    20  #define _CALL_CallSSum_ 3
    21  #define _CALL_CollectS_ 4
    22  #define _CALL_GC_ 5
    23  #define _CALL_Hello_ 6
    24  #define _CALL_Hi_ 7
    25  #define _CALL_Int_ 8
    26  #define _CALL_Multiply_ 9
    27  #define _CALL_NewI_ 10
    28  #define _CALL_NewNode_ 11
    29  #define _CALL_NewS_ 12
    30  #define _CALL_RegisterI_ 13
    31  #define _CALL_ReturnsError_ 14
    32  #define _CALL_Sum_ 15
    33  #define _CALL_UnregisterI_ 16
    34  
    35  #define _GO_testpkg_I_DESCRIPTOR_ "go.testpkg.I"
    36  #define _GO_testpkg_I_Error_ (0x10a)
    37  #define _GO_testpkg_I_Times_ (0x20a)
    38  
    39  @interface GoTestpkgI : NSObject <GoTestpkgI> {
    40  }
    41  @property(strong, readonly) id ref;
    42  
    43  - (id)initWithRef:(id)ref;
    44  - (BOOL)Error:(BOOL)triggerError error:(NSError**)error;
    45  - (int64_t)Times:(int32_t)v;
    46  @end
    47  
    48  @implementation GoTestpkgI {
    49  }
    50  
    51  - (id)initWithRef:(id)ref {
    52  	self = [super init];
    53  	if (self) { _ref = ref; }
    54  	return self;
    55  }
    56  
    57  - (BOOL)Error:(BOOL)triggerError error:(NSError**)error {
    58  	GoSeq in_ = {};
    59  	GoSeq out_ = {};
    60  	go_seq_writeRef(&in_, self.ref);
    61  	go_seq_writeBool(&in_, triggerError);
    62  	go_seq_send(_GO_testpkg_I_DESCRIPTOR_, _GO_testpkg_I_Error_, &in_, &out_);
    63  	NSString* _error = go_seq_readUTF8(&out_);
    64  	if ([_error length] != 0 && error != nil) {
    65  		NSMutableDictionary* details = [NSMutableDictionary dictionary];
    66  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
    67  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
    68  	}
    69  	go_seq_free(&in_);
    70  	go_seq_free(&out_);
    71  	return ([_error length] == 0);
    72  }
    73  
    74  - (int64_t)Times:(int32_t)v {
    75  	GoSeq in_ = {};
    76  	GoSeq out_ = {};
    77  	go_seq_writeRef(&in_, self.ref);
    78  	go_seq_writeInt32(&in_, v);
    79  	go_seq_send(_GO_testpkg_I_DESCRIPTOR_, _GO_testpkg_I_Times_, &in_, &out_);
    80  	int64_t ret0_ = go_seq_readInt64(&out_);
    81  	go_seq_free(&in_);
    82  	go_seq_free(&out_);
    83  	return ret0_;
    84  }
    85  
    86  @end
    87  
    88  static void proxyGoTestpkgI(id obj, int code, GoSeq* in, GoSeq* out) {
    89  	switch (code) {
    90  	case _GO_testpkg_I_Error_: {
    91  		id<GoTestpkgI> o = (id<GoTestpkgI>)(obj);
    92  		BOOL triggerError = go_seq_readBool(in);
    93  		NSError* error = NULL;
    94  		BOOL returnVal = [o Error:triggerError error:&error];
    95  		if (returnVal) {
    96  			go_seq_writeUTF8(out, NULL);
    97  		} else {
    98  			NSString* errorDesc = [error localizedDescription];
    99  			if (errorDesc == NULL || errorDesc.length == 0) {
   100  				errorDesc = @"gobind: unknown error";
   101  			}
   102  			go_seq_writeUTF8(out, errorDesc);
   103  		}
   104  	} break;
   105  	case _GO_testpkg_I_Times_: {
   106  		id<GoTestpkgI> o = (id<GoTestpkgI>)(obj);
   107  		int32_t v = go_seq_readInt32(in);
   108  		int64_t returnVal = [o Times:v];
   109  		go_seq_writeInt64(out, returnVal);
   110  	} break;
   111  	default:
   112  		NSLog(@"unknown code %x for _GO_testpkg_I_DESCRIPTOR_", code);
   113  	}
   114  }
   115  
   116  #define _GO_testpkg_Node_DESCRIPTOR_ "go.testpkg.Node"
   117  #define _GO_testpkg_Node_FIELD_V_GET_ (0x00f)
   118  #define _GO_testpkg_Node_FIELD_V_SET_ (0x01f)
   119  #define _GO_testpkg_Node_FIELD_Err_GET_ (0x10f)
   120  #define _GO_testpkg_Node_FIELD_Err_SET_ (0x11f)
   121  
   122  @implementation GoTestpkgNode {
   123  }
   124  
   125  - (id)initWithRef:(id)ref {
   126  	self = [super init];
   127  	if (self) { _ref = ref; }
   128  	return self;
   129  }
   130  
   131  - (NSString*)V {
   132  	GoSeq in_ = {};
   133  	GoSeq out_ = {};
   134  	go_seq_writeRef(&in_, self.ref);
   135  	go_seq_send(_GO_testpkg_Node_DESCRIPTOR_, _GO_testpkg_Node_FIELD_V_GET_, &in_, &out_);
   136  	NSString* ret_ = go_seq_readUTF8(&out_);
   137  	go_seq_free(&in_);
   138  	go_seq_free(&out_);
   139  	return ret_;
   140  }
   141  
   142  - (void)setV:(NSString*)v {
   143  	GoSeq in_ = {};
   144  	GoSeq out_ = {};
   145  	go_seq_writeRef(&in_, self.ref);
   146  	go_seq_writeUTF8(&in_, v);
   147  	go_seq_send(_GO_testpkg_Node_DESCRIPTOR_, _GO_testpkg_Node_FIELD_V_SET_, &in_, &out_);
   148  	go_seq_free(&in_);
   149  	go_seq_free(&out_);
   150  }
   151  
   152  - (NSString*)Err {
   153  	GoSeq in_ = {};
   154  	GoSeq out_ = {};
   155  	go_seq_writeRef(&in_, self.ref);
   156  	go_seq_send(_GO_testpkg_Node_DESCRIPTOR_, _GO_testpkg_Node_FIELD_Err_GET_, &in_, &out_);
   157  	NSString* ret_ = go_seq_readUTF8(&out_);
   158  	go_seq_free(&in_);
   159  	go_seq_free(&out_);
   160  	return ret_;
   161  }
   162  
   163  - (void)setErr:(NSString*)v {
   164  	GoSeq in_ = {};
   165  	GoSeq out_ = {};
   166  	go_seq_writeRef(&in_, self.ref);
   167  	go_seq_writeUTF8(&in_, v);
   168  	go_seq_send(_GO_testpkg_Node_DESCRIPTOR_, _GO_testpkg_Node_FIELD_Err_SET_, &in_, &out_);
   169  	go_seq_free(&in_);
   170  	go_seq_free(&out_);
   171  }
   172  
   173  @end
   174  
   175  #define _GO_testpkg_S_DESCRIPTOR_ "go.testpkg.S"
   176  #define _GO_testpkg_S_FIELD_X_GET_ (0x00f)
   177  #define _GO_testpkg_S_FIELD_X_SET_ (0x01f)
   178  #define _GO_testpkg_S_FIELD_Y_GET_ (0x10f)
   179  #define _GO_testpkg_S_FIELD_Y_SET_ (0x11f)
   180  #define _GO_testpkg_S_Sum_ (0x00c)
   181  #define _GO_testpkg_S_TryTwoStrings_ (0x10c)
   182  
   183  @implementation GoTestpkgS {
   184  }
   185  
   186  - (id)initWithRef:(id)ref {
   187  	self = [super init];
   188  	if (self) { _ref = ref; }
   189  	return self;
   190  }
   191  
   192  - (double)X {
   193  	GoSeq in_ = {};
   194  	GoSeq out_ = {};
   195  	go_seq_writeRef(&in_, self.ref);
   196  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_X_GET_, &in_, &out_);
   197  	double ret_ = go_seq_readFloat64(&out_);
   198  	go_seq_free(&in_);
   199  	go_seq_free(&out_);
   200  	return ret_;
   201  }
   202  
   203  - (void)setX:(double)v {
   204  	GoSeq in_ = {};
   205  	GoSeq out_ = {};
   206  	go_seq_writeRef(&in_, self.ref);
   207  	go_seq_writeFloat64(&in_, v);
   208  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_X_SET_, &in_, &out_);
   209  	go_seq_free(&in_);
   210  	go_seq_free(&out_);
   211  }
   212  
   213  - (double)Y {
   214  	GoSeq in_ = {};
   215  	GoSeq out_ = {};
   216  	go_seq_writeRef(&in_, self.ref);
   217  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_Y_GET_, &in_, &out_);
   218  	double ret_ = go_seq_readFloat64(&out_);
   219  	go_seq_free(&in_);
   220  	go_seq_free(&out_);
   221  	return ret_;
   222  }
   223  
   224  - (void)setY:(double)v {
   225  	GoSeq in_ = {};
   226  	GoSeq out_ = {};
   227  	go_seq_writeRef(&in_, self.ref);
   228  	go_seq_writeFloat64(&in_, v);
   229  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_FIELD_Y_SET_, &in_, &out_);
   230  	go_seq_free(&in_);
   231  	go_seq_free(&out_);
   232  }
   233  
   234  - (double)Sum {
   235  	GoSeq in_ = {};
   236  	GoSeq out_ = {};
   237  	go_seq_writeRef(&in_, self.ref);
   238  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_Sum_, &in_, &out_);
   239  	double ret0_ = go_seq_readFloat64(&out_);
   240  	go_seq_free(&in_);
   241  	go_seq_free(&out_);
   242  	return ret0_;
   243  }
   244  
   245  - (NSString*)TryTwoStrings:(NSString*)first second:(NSString*)second {
   246  	GoSeq in_ = {};
   247  	GoSeq out_ = {};
   248  	go_seq_writeRef(&in_, self.ref);
   249  	go_seq_writeUTF8(&in_, first);
   250  	go_seq_writeUTF8(&in_, second);
   251  	go_seq_send(_GO_testpkg_S_DESCRIPTOR_, _GO_testpkg_S_TryTwoStrings_, &in_, &out_);
   252  	NSString* ret0_ = go_seq_readUTF8(&out_);
   253  	go_seq_free(&in_);
   254  	go_seq_free(&out_);
   255  	return ret0_;
   256  }
   257  
   258  @end
   259  
   260  NSData* GoTestpkgBytesAppend(NSData* a, NSData* b) {
   261  	GoSeq in_ = {};
   262  	GoSeq out_ = {};
   263  	go_seq_writeByteArray(&in_, a);
   264  	go_seq_writeByteArray(&in_, b);
   265  	go_seq_send(_DESCRIPTOR_, _CALL_BytesAppend_, &in_, &out_);
   266  	NSData* ret0_ = go_seq_readByteArray(&out_);
   267  	go_seq_free(&in_);
   268  	go_seq_free(&out_);
   269  	return ret0_;
   270  }
   271  
   272  BOOL GoTestpkgCallIError(id<GoTestpkgI> i, BOOL triggerError, NSError** error) {
   273  	GoSeq in_ = {};
   274  	GoSeq out_ = {};
   275  	if ([(id<NSObject>)(i) isKindOfClass:[GoTestpkgI class]]) {
   276  		id<goSeqRefInterface> i_proxy = (id<goSeqRefInterface>)(i);
   277  		go_seq_writeRef(&in_, i_proxy.ref);
   278  	} else {
   279  		go_seq_writeObjcRef(&in_, i);
   280  	}
   281  	go_seq_writeBool(&in_, triggerError);
   282  	go_seq_send(_DESCRIPTOR_, _CALL_CallIError_, &in_, &out_);
   283  	NSString* _error = go_seq_readUTF8(&out_);
   284  	if ([_error length] != 0 && error != nil) {
   285  		NSMutableDictionary* details = [NSMutableDictionary dictionary];
   286  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
   287  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
   288  	}
   289  	go_seq_free(&in_);
   290  	go_seq_free(&out_);
   291  	return ([_error length] == 0);
   292  }
   293  
   294  double GoTestpkgCallSSum(GoTestpkgS* s) {
   295  	GoSeq in_ = {};
   296  	GoSeq out_ = {};
   297  	if ([(id<NSObject>)(s) isKindOfClass:[GoTestpkgS class]]) {
   298  		id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
   299  		go_seq_writeRef(&in_, s_proxy.ref);
   300  	} else {
   301  		go_seq_writeObjcRef(&in_, s);
   302  	}
   303  	go_seq_send(_DESCRIPTOR_, _CALL_CallSSum_, &in_, &out_);
   304  	double ret0_ = go_seq_readFloat64(&out_);
   305  	go_seq_free(&in_);
   306  	go_seq_free(&out_);
   307  	return ret0_;
   308  }
   309  
   310  int GoTestpkgCollectS(int want, int timeoutSec) {
   311  	GoSeq in_ = {};
   312  	GoSeq out_ = {};
   313  	go_seq_writeInt(&in_, want);
   314  	go_seq_writeInt(&in_, timeoutSec);
   315  	go_seq_send(_DESCRIPTOR_, _CALL_CollectS_, &in_, &out_);
   316  	int ret0_ = go_seq_readInt(&out_);
   317  	go_seq_free(&in_);
   318  	go_seq_free(&out_);
   319  	return ret0_;
   320  }
   321  
   322  void GoTestpkgGC() {
   323  	GoSeq in_ = {};
   324  	GoSeq out_ = {};
   325  	go_seq_send(_DESCRIPTOR_, _CALL_GC_, &in_, &out_);
   326  	go_seq_free(&in_);
   327  	go_seq_free(&out_);
   328  }
   329  
   330  NSString* GoTestpkgHello(NSString* s) {
   331  	GoSeq in_ = {};
   332  	GoSeq out_ = {};
   333  	go_seq_writeUTF8(&in_, s);
   334  	go_seq_send(_DESCRIPTOR_, _CALL_Hello_, &in_, &out_);
   335  	NSString* ret0_ = go_seq_readUTF8(&out_);
   336  	go_seq_free(&in_);
   337  	go_seq_free(&out_);
   338  	return ret0_;
   339  }
   340  
   341  void GoTestpkgHi() {
   342  	GoSeq in_ = {};
   343  	GoSeq out_ = {};
   344  	go_seq_send(_DESCRIPTOR_, _CALL_Hi_, &in_, &out_);
   345  	go_seq_free(&in_);
   346  	go_seq_free(&out_);
   347  }
   348  
   349  void GoTestpkgInt(int32_t x) {
   350  	GoSeq in_ = {};
   351  	GoSeq out_ = {};
   352  	go_seq_writeInt32(&in_, x);
   353  	go_seq_send(_DESCRIPTOR_, _CALL_Int_, &in_, &out_);
   354  	go_seq_free(&in_);
   355  	go_seq_free(&out_);
   356  }
   357  
   358  int64_t GoTestpkgMultiply(int32_t idx, int32_t val) {
   359  	GoSeq in_ = {};
   360  	GoSeq out_ = {};
   361  	go_seq_writeInt32(&in_, idx);
   362  	go_seq_writeInt32(&in_, val);
   363  	go_seq_send(_DESCRIPTOR_, _CALL_Multiply_, &in_, &out_);
   364  	int64_t ret0_ = go_seq_readInt64(&out_);
   365  	go_seq_free(&in_);
   366  	go_seq_free(&out_);
   367  	return ret0_;
   368  }
   369  
   370  id<GoTestpkgI> GoTestpkgNewI() {
   371  	GoSeq in_ = {};
   372  	GoSeq out_ = {};
   373  	go_seq_send(_DESCRIPTOR_, _CALL_NewI_, &in_, &out_);
   374  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   375  	id<GoTestpkgI> ret0_ = ret0__ref.obj;
   376  	if (ret0_ == NULL) {
   377  		ret0_ = [[GoTestpkgI alloc] initWithRef:ret0__ref];
   378  	}
   379  	go_seq_free(&in_);
   380  	go_seq_free(&out_);
   381  	return ret0_;
   382  }
   383  
   384  GoTestpkgNode* GoTestpkgNewNode(NSString* name) {
   385  	GoSeq in_ = {};
   386  	GoSeq out_ = {};
   387  	go_seq_writeUTF8(&in_, name);
   388  	go_seq_send(_DESCRIPTOR_, _CALL_NewNode_, &in_, &out_);
   389  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   390  	GoTestpkgNode* ret0_ = ret0__ref.obj;
   391  	if (ret0_ == NULL) {
   392  		ret0_ = [[GoTestpkgNode alloc] initWithRef:ret0__ref];
   393  	}
   394  	go_seq_free(&in_);
   395  	go_seq_free(&out_);
   396  	return ret0_;
   397  }
   398  
   399  GoTestpkgS* GoTestpkgNewS(double x, double y) {
   400  	GoSeq in_ = {};
   401  	GoSeq out_ = {};
   402  	go_seq_writeFloat64(&in_, x);
   403  	go_seq_writeFloat64(&in_, y);
   404  	go_seq_send(_DESCRIPTOR_, _CALL_NewS_, &in_, &out_);
   405  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   406  	GoTestpkgS* ret0_ = ret0__ref.obj;
   407  	if (ret0_ == NULL) {
   408  		ret0_ = [[GoTestpkgS alloc] initWithRef:ret0__ref];
   409  	}
   410  	go_seq_free(&in_);
   411  	go_seq_free(&out_);
   412  	return ret0_;
   413  }
   414  
   415  void GoTestpkgRegisterI(int32_t idx, id<GoTestpkgI> i) {
   416  	GoSeq in_ = {};
   417  	GoSeq out_ = {};
   418  	go_seq_writeInt32(&in_, idx);
   419  	if ([(id<NSObject>)(i) isKindOfClass:[GoTestpkgI class]]) {
   420  		id<goSeqRefInterface> i_proxy = (id<goSeqRefInterface>)(i);
   421  		go_seq_writeRef(&in_, i_proxy.ref);
   422  	} else {
   423  		go_seq_writeObjcRef(&in_, i);
   424  	}
   425  	go_seq_send(_DESCRIPTOR_, _CALL_RegisterI_, &in_, &out_);
   426  	go_seq_free(&in_);
   427  	go_seq_free(&out_);
   428  }
   429  
   430  BOOL GoTestpkgReturnsError(BOOL b, NSString** ret0_, NSError** error) {
   431  	GoSeq in_ = {};
   432  	GoSeq out_ = {};
   433  	go_seq_writeBool(&in_, b);
   434  	go_seq_send(_DESCRIPTOR_, _CALL_ReturnsError_, &in_, &out_);
   435  	NSString* ret0__val = go_seq_readUTF8(&out_);
   436  	if (ret0_ != NULL) {
   437  		*ret0_ = ret0__val;
   438  	}
   439  	NSString* _error = go_seq_readUTF8(&out_);
   440  	if ([_error length] != 0 && error != nil) {
   441  		NSMutableDictionary* details = [NSMutableDictionary dictionary];
   442  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
   443  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
   444  	}
   445  	go_seq_free(&in_);
   446  	go_seq_free(&out_);
   447  	return ([_error length] == 0);
   448  }
   449  
   450  int64_t GoTestpkgSum(int64_t x, int64_t y) {
   451  	GoSeq in_ = {};
   452  	GoSeq out_ = {};
   453  	go_seq_writeInt64(&in_, x);
   454  	go_seq_writeInt64(&in_, y);
   455  	go_seq_send(_DESCRIPTOR_, _CALL_Sum_, &in_, &out_);
   456  	int64_t ret0_ = go_seq_readInt64(&out_);
   457  	go_seq_free(&in_);
   458  	go_seq_free(&out_);
   459  	return ret0_;
   460  }
   461  
   462  void GoTestpkgUnregisterI(int32_t idx) {
   463  	GoSeq in_ = {};
   464  	GoSeq out_ = {};
   465  	go_seq_writeInt32(&in_, idx);
   466  	go_seq_send(_DESCRIPTOR_, _CALL_UnregisterI_, &in_, &out_);
   467  	go_seq_free(&in_);
   468  	go_seq_free(&out_);
   469  }
   470  
   471  __attribute__((constructor)) static void init() {
   472  	go_seq_register_proxy("go.testpkg.I", proxyGoTestpkgI);
   473  }