2
0
mirror of synced 2025-02-23 23:08:14 +00:00
mobile/bind/testdata/structs.objc.m.golden
Elias Naur 6a96d4c7cf bind: make the default name prefix empty on ObjC
Since generated names now have their package names prefixed, the
extra prefix, "Go", is both confusing and counter-productive to
making the generated ObjC code look like any other native code.

Change the default to the empty prefix, while preserving support
for an explicit prefix if needed.

This is a backwards incompatible change; to keep the old behaviour,
specify "-prefix Go" to the gobind or gomobile command.

While we're here, fix the Ivy example for the recent change in
error returns.

Change-Id: I7fef4a92a18ddadee972ccf359652e3b31624f33
Reviewed-on: https://go-review.googlesource.com/34643
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-12-24 13:37:27 +00:00

192 lines
4.0 KiB
Plaintext

// Objective-C API for talking to structs Go package.
// gobind -lang=objc structs
//
// File is generated by gobind. Do not edit.
#include <Foundation/Foundation.h>
#include "seq.h"
#include "_cgo_export.h"
#include "Structs.objc.h"
@implementation StructsS {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (double)x {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double r0 = proxystructs_S_X_Get(refnum);
double _r0 = (double)r0;
return _r0;
}
- (void)setX:(double)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double _v = (double)v;
proxystructs_S_X_Set(refnum, _v);
}
- (double)y {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double r0 = proxystructs_S_Y_Get(refnum);
double _r0 = (double)r0;
return _r0;
}
- (void)setY:(double)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double _v = (double)v;
proxystructs_S_Y_Set(refnum, _v);
}
- (StructsS*)identity:(NSError**)error {
int32_t refnum = go_seq_go_to_refnum(self._ref);
struct proxystructs_S_Identity_return res = proxystructs_S_Identity(refnum);
StructsS* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
}
}
Universeerror* _error = nil;
GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
if (_error_ref != NULL) {
_error = _error_ref.obj;
if (_error == nil) {
_error = [[Universeerror alloc] initWithRef:_error_ref];
}
}
if (_error != nil && error != nil) {
*error = _error;
}
if (_error != nil) {
return nil;
}
return _ret0_;
}
- (double)sum {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double r0 = proxystructs_S_Sum(refnum);
double _ret0_ = (double)r0;
return _ret0_;
}
@end
@implementation StructsS2 {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (void)m {
int32_t refnum = go_seq_go_to_refnum(self._ref);
proxystructs_S2_M(refnum);
}
- (NSString*)string {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring r0 = proxystructs_S2_String(refnum);
NSString *_ret0_ = go_seq_to_objc_string(r0);
return _ret0_;
}
@end
@implementation StructsI {
}
- (instancetype)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (void)m {
int32_t refnum = go_seq_go_to_refnum(self._ref);
proxystructs_I_M(refnum);
}
@end
StructsS* StructsIdentity(StructsS* s) {
int32_t _s;
if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
_s = go_seq_go_to_refnum(s_proxy._ref);
} else {
_s = go_seq_to_refnum(s);
}
int32_t r0 = proxystructs__Identity(_s);
StructsS* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
StructsS* StructsIdentityWithError(StructsS* s, NSError** error) {
int32_t _s;
if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
_s = go_seq_go_to_refnum(s_proxy._ref);
} else {
_s = go_seq_to_refnum(s);
}
struct proxystructs__IdentityWithError_return res = proxystructs__IdentityWithError(_s);
StructsS* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
}
}
Universeerror* _error = nil;
GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
if (_error_ref != NULL) {
_error = _error_ref.obj;
if (_error == nil) {
_error = [[Universeerror alloc] initWithRef:_error_ref];
}
}
if (_error != nil && error != nil) {
*error = _error;
}
if (_error != nil) {
return nil;
}
return _ret0_;
}
void cproxystructs_I_M(int32_t refnum) {
@autoreleasepool {
StructsI* o = go_seq_objc_from_refnum(refnum);
[o m];
}
}
__attribute__((constructor)) static void init() {
init_seq();
}