github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/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 "GoStructs.h"
     7  #include <Foundation/Foundation.h>
     8  #include "seq.h"
     9  
    10  static NSString* errDomain = @"go.structs";
    11  
    12  @protocol goSeqRefInterface
    13  -(GoSeqRef*) ref;
    14  @end
    15  
    16  #define _DESCRIPTOR_ "structs"
    17  
    18  #define _CALL_Identity_ 1
    19  #define _CALL_IdentityWithError_ 2
    20  
    21  #define _GO_structs_S_DESCRIPTOR_ "go.structs.S"
    22  #define _GO_structs_S_FIELD_X_GET_ (0x00f)
    23  #define _GO_structs_S_FIELD_X_SET_ (0x01f)
    24  #define _GO_structs_S_FIELD_Y_GET_ (0x10f)
    25  #define _GO_structs_S_FIELD_Y_SET_ (0x11f)
    26  #define _GO_structs_S_Identity_ (0x00c)
    27  #define _GO_structs_S_Sum_ (0x10c)
    28  
    29  @implementation GoStructsS {
    30  }
    31  
    32  - (id)initWithRef:(id)ref {
    33  	self = [super init];
    34  	if (self) { _ref = ref; }
    35  	return self;
    36  }
    37  
    38  - (double)X {
    39  	GoSeq in_ = {};
    40  	GoSeq out_ = {};
    41  	go_seq_writeRef(&in_, self.ref);
    42  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_FIELD_X_GET_, &in_, &out_);
    43  	double ret_ = go_seq_readFloat64(&out_);
    44  	go_seq_free(&in_);
    45  	go_seq_free(&out_);
    46  	return ret_;
    47  }
    48  
    49  - (void)setX:(double)v {
    50  	GoSeq in_ = {};
    51  	GoSeq out_ = {};
    52  	go_seq_writeRef(&in_, self.ref);
    53  	go_seq_writeFloat64(&in_, v);
    54  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_FIELD_X_SET_, &in_, &out_);
    55  	go_seq_free(&in_);
    56  	go_seq_free(&out_);
    57  }
    58  
    59  - (double)Y {
    60  	GoSeq in_ = {};
    61  	GoSeq out_ = {};
    62  	go_seq_writeRef(&in_, self.ref);
    63  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_FIELD_Y_GET_, &in_, &out_);
    64  	double ret_ = go_seq_readFloat64(&out_);
    65  	go_seq_free(&in_);
    66  	go_seq_free(&out_);
    67  	return ret_;
    68  }
    69  
    70  - (void)setY:(double)v {
    71  	GoSeq in_ = {};
    72  	GoSeq out_ = {};
    73  	go_seq_writeRef(&in_, self.ref);
    74  	go_seq_writeFloat64(&in_, v);
    75  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_FIELD_Y_SET_, &in_, &out_);
    76  	go_seq_free(&in_);
    77  	go_seq_free(&out_);
    78  }
    79  
    80  - (BOOL)Identity:(GoStructsS**)ret0_ error:(NSError**)error {
    81  	GoSeq in_ = {};
    82  	GoSeq out_ = {};
    83  	go_seq_writeRef(&in_, self.ref);
    84  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_Identity_, &in_, &out_);
    85  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
    86  	if (ret0_ != NULL) {
    87  		*ret0_ = ret0__ref.obj;
    88  		if (*ret0_ == NULL) {
    89  			*ret0_ = [[GoStructsS alloc] initWithRef:ret0__ref];
    90  		}
    91  	}
    92  	NSString* _error = go_seq_readUTF8(&out_);
    93  	if ([_error length] != 0 && error != nil) {
    94  		NSMutableDictionary* details = [NSMutableDictionary dictionary];
    95  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
    96  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
    97  	}
    98  	go_seq_free(&in_);
    99  	go_seq_free(&out_);
   100  	return ([_error length] == 0);
   101  }
   102  
   103  - (double)Sum {
   104  	GoSeq in_ = {};
   105  	GoSeq out_ = {};
   106  	go_seq_writeRef(&in_, self.ref);
   107  	go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_Sum_, &in_, &out_);
   108  	double ret0_ = go_seq_readFloat64(&out_);
   109  	go_seq_free(&in_);
   110  	go_seq_free(&out_);
   111  	return ret0_;
   112  }
   113  
   114  @end
   115  
   116  GoStructsS* GoStructsIdentity(GoStructsS* s) {
   117  	GoSeq in_ = {};
   118  	GoSeq out_ = {};
   119  	if ([(id<NSObject>)(s) isKindOfClass:[GoStructsS class]]) {
   120  		id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
   121  		go_seq_writeRef(&in_, s_proxy.ref);
   122  	} else {
   123  		go_seq_writeObjcRef(&in_, s);
   124  	}
   125  	go_seq_send(_DESCRIPTOR_, _CALL_Identity_, &in_, &out_);
   126  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   127  	GoStructsS* ret0_ = ret0__ref.obj;
   128  	if (ret0_ == NULL) {
   129  		ret0_ = [[GoStructsS alloc] initWithRef:ret0__ref];
   130  	}
   131  	go_seq_free(&in_);
   132  	go_seq_free(&out_);
   133  	return ret0_;
   134  }
   135  
   136  BOOL GoStructsIdentityWithError(GoStructsS* s, GoStructsS** ret0_, NSError** error) {
   137  	GoSeq in_ = {};
   138  	GoSeq out_ = {};
   139  	if ([(id<NSObject>)(s) isKindOfClass:[GoStructsS class]]) {
   140  		id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
   141  		go_seq_writeRef(&in_, s_proxy.ref);
   142  	} else {
   143  		go_seq_writeObjcRef(&in_, s);
   144  	}
   145  	go_seq_send(_DESCRIPTOR_, _CALL_IdentityWithError_, &in_, &out_);
   146  	GoSeqRef* ret0__ref = go_seq_readRef(&out_);
   147  	if (ret0_ != NULL) {
   148  		*ret0_ = ret0__ref.obj;
   149  		if (*ret0_ == NULL) {
   150  			*ret0_ = [[GoStructsS alloc] initWithRef:ret0__ref];
   151  		}
   152  	}
   153  	NSString* _error = go_seq_readUTF8(&out_);
   154  	if ([_error length] != 0 && error != nil) {
   155  		NSMutableDictionary* details = [NSMutableDictionary dictionary];
   156  		[details setValue:_error forKey:NSLocalizedDescriptionKey];
   157  		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
   158  	}
   159  	go_seq_free(&in_);
   160  	go_seq_free(&out_);
   161  	return ([_error length] == 0);
   162  }
   163