2
0
mirror of synced 2025-02-24 07:18:15 +00:00
mobile/bind/testdata/vars.objc.m.golden
Elias Naur 1c49d29d1c bind,cmd: accept ObjC wrapper types in bound packages
Accept ObjC API wrapper types as arguments and return values from
bound Go package functions and methods. Also, allow Go structs
to extend ObjC classes and implement ObjC protocols as well as override
and implement methods.

This is the third and final part of the implementation of the golang/go#17102
proposal.

Fixes golang/go#17102

Change-Id: I601d90fb6d22b8d6f8b7d5fe0130daa1a4dd4734
Reviewed-on: https://go-review.googlesource.com/29175
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-17 10:37:16 +00:00

201 lines
3.5 KiB
Plaintext

// Objective-C API for talking to vars Go package.
// gobind -lang=objc vars
//
// File is generated by gobind. Do not edit.
#include <Foundation/Foundation.h>
#include "seq.h"
#include "_cgo_export.h"
#include "GoVars.h"
@implementation GoVarsS {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
@end
@implementation GoVarsI {
}
- (instancetype)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
@end
@implementation GoVars
+ (void) setABool:(BOOL)v {
char _v = (char)v;
var_setvars_ABool(_v);
}
+ (BOOL) aBool {
char r0 = var_getvars_ABool();
BOOL _r0 = r0 ? YES : NO;
return _r0;
}
+ (void) setAFloat:(double)v {
double _v = (double)v;
var_setvars_AFloat(_v);
}
+ (double) aFloat {
double r0 = var_getvars_AFloat();
double _r0 = (double)r0;
return _r0;
}
+ (void) setAFloat32:(float)v {
float _v = (float)v;
var_setvars_AFloat32(_v);
}
+ (float) aFloat32 {
float r0 = var_getvars_AFloat32();
float _r0 = (float)r0;
return _r0;
}
+ (void) setAFloat64:(double)v {
double _v = (double)v;
var_setvars_AFloat64(_v);
}
+ (double) aFloat64 {
double r0 = var_getvars_AFloat64();
double _r0 = (double)r0;
return _r0;
}
+ (void) setAString:(NSString*)v {
nstring _v = go_seq_from_objc_string(v);
var_setvars_AString(_v);
}
+ (NSString*) aString {
nstring r0 = var_getvars_AString();
NSString *_r0 = go_seq_to_objc_string(r0);
return _r0;
}
+ (void) setAStructPtr:(GoVarsS*)v {
int32_t _v;
if ([v conformsToProtocol:@protocol(goSeqRefInterface)]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
var_setvars_AStructPtr(_v);
}
+ (GoVarsS*) aStructPtr {
int32_t r0 = var_getvars_AStructPtr();
GoVarsS* _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoVarsS alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
+ (void) setAnInt:(long)v {
nint _v = (nint)v;
var_setvars_AnInt(_v);
}
+ (long) anInt {
nint r0 = var_getvars_AnInt();
long _r0 = (long)r0;
return _r0;
}
+ (void) setAnInt16:(int16_t)v {
int16_t _v = (int16_t)v;
var_setvars_AnInt16(_v);
}
+ (int16_t) anInt16 {
int16_t r0 = var_getvars_AnInt16();
int16_t _r0 = (int16_t)r0;
return _r0;
}
+ (void) setAnInt32:(int32_t)v {
int32_t _v = (int32_t)v;
var_setvars_AnInt32(_v);
}
+ (int32_t) anInt32 {
int32_t r0 = var_getvars_AnInt32();
int32_t _r0 = (int32_t)r0;
return _r0;
}
+ (void) setAnInt64:(int64_t)v {
int64_t _v = (int64_t)v;
var_setvars_AnInt64(_v);
}
+ (int64_t) anInt64 {
int64_t r0 = var_getvars_AnInt64();
int64_t _r0 = (int64_t)r0;
return _r0;
}
+ (void) setAnInt8:(int8_t)v {
int8_t _v = (int8_t)v;
var_setvars_AnInt8(_v);
}
+ (int8_t) anInt8 {
int8_t r0 = var_getvars_AnInt8();
int8_t _r0 = (int8_t)r0;
return _r0;
}
+ (void) setAnInterface:(id<GoVarsI>)v {
int32_t _v;
if ([v conformsToProtocol:@protocol(goSeqRefInterface)]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
var_setvars_AnInterface(_v);
}
+ (id<GoVarsI>) anInterface {
int32_t r0 = var_getvars_AnInterface();
GoVarsI* _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoVarsI alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
@end
__attribute__((constructor)) static void init() {
init_seq();
}