2
0
mirror of synced 2025-02-23 14:58:12 +00:00

mobile/bind: convert iOS tests to XCTestCase

Replace test.bash with go test that builds and run the bind tests
through the XCode testing framework.

Running on the iOS emulator unmasked a bug where autorelease pools
were not in place for Go calls into ObjC, leaking autoreleased
objects. Fix that by adding autoreleasepool blocks to the tracker
finalizer callback and to every generated ObjC proxy.

Will not run on the emulator without CL 19206.

Change-Id: I6a775f9995f3b8ea50272982069d033e41ddcb7b
Reviewed-on: https://go-review.googlesource.com/20255
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur 2016-03-06 09:28:58 +01:00
parent 75a1c3da13
commit 4da9347475
18 changed files with 940 additions and 2042 deletions

View File

@ -729,6 +729,8 @@ func (g *objcGen) genInterfaceMethodProxy(obj *types.TypeName, m *types.Func) {
s := g.funcSummary(m)
g.genInterfaceMethodSignature(m, oName, false)
g.Indent()
g.Printf("@autoreleasepool {\n")
g.Indent()
g.Printf("%s o = go_seq_objc_from_refnum(refnum);\n", g.objcType(obj.Type()))
for _, p := range s.params {
g.genRead("_"+p.name, p.name, p.typ, modeTransient)
@ -793,6 +795,8 @@ func (g *objcGen) genInterfaceMethodProxy(obj *types.TypeName, m *types.Func) {
}
}
g.Outdent()
g.Printf("}\n")
g.Outdent()
g.Printf("}\n\n")
}

View File

@ -5,161 +5,8 @@
// +build ignore
#import <Foundation/Foundation.h>
#import "GoTestpkg.h"
#define ERROR(...) \
do { \
NSLog(__VA_ARGS__); \
err = 1; \
} while (0);
static int err = 0;
void testConst() {
if (![GoTestpkgAString isEqualToString:@"a string"]) {
ERROR(@"GoTestpkgAString = %@, want 'a string'", GoTestpkgAString);
}
if (GoTestpkgAnInt != 7) {
ERROR(@"GoTestpkgAnInt = %lld, want 7", GoTestpkgAnInt);
}
if (ABS(GoTestpkgAFloat - 0.12345) > 0.0001) {
ERROR(@"GoTestpkgAFloat = %f, want 0.12345", GoTestpkgAFloat);
}
if (GoTestpkgABool != YES) {
ERROR(@"GoTestpkgABool = %@, want YES", GoTestpkgAFloat ? @"YES" : @"NO");
}
if (GoTestpkgMinInt32 != INT32_MIN) {
ERROR(@"GoTestpkgMinInt32 = %d, want %d", GoTestpkgMinInt32, INT32_MIN);
}
if (GoTestpkgMaxInt32 != INT32_MAX) {
ERROR(@"GoTestpkgMaxInt32 = %d, want %d", GoTestpkgMaxInt32, INT32_MAX);
}
if (GoTestpkgMinInt64 != INT64_MIN) {
ERROR(@"GoTestpkgMinInt64 = %lld, want %lld", GoTestpkgMinInt64, INT64_MIN);
}
if (GoTestpkgMaxInt64 != INT64_MAX) {
ERROR(@"GoTestpkgMaxInt64 = %lld, want %lld", GoTestpkgMaxInt64, INT64_MAX);
}
if (ABS(GoTestpkgSmallestNonzeroFloat64 -
4.940656458412465441765687928682213723651e-324) > 1e-323) {
ERROR(@"GoTestpkgSmallestNonzeroFloat64 = %f, want %f",
GoTestpkgSmallestNonzeroFloat64,
4.940656458412465441765687928682213723651e-324);
}
if (ABS(GoTestpkgMaxFloat64 -
1.797693134862315708145274237317043567981e+308) > 0.0001) {
ERROR(@"GoTestpkgMaxFloat64 = %f, want %f", GoTestpkgMaxFloat64,
1.797693134862315708145274237317043567981e+308);
}
if (ABS(GoTestpkgSmallestNonzeroFloat32 -
1.401298464324817070923729583289916131280e-45) > 1e-44) {
ERROR(@"GoTestpkgSmallestNonzeroFloat32 = %f, want %f",
GoTestpkgSmallestNonzeroFloat32,
1.401298464324817070923729583289916131280e-45);
}
if (ABS(GoTestpkgMaxFloat32 - 3.40282346638528859811704183484516925440e+38) >
0.0001) {
ERROR(@"GoTestpkgMaxFloat32 = %f, want %f", GoTestpkgMaxFloat32,
3.40282346638528859811704183484516925440e+38);
}
if (ABS(GoTestpkgLog2E -
1 / 0.693147180559945309417232121458176568075500134360255254120680009) >
0.0001) {
ERROR(
@"GoTestpkgLog2E = %f, want %f", GoTestpkgLog2E,
1 / 0.693147180559945309417232121458176568075500134360255254120680009);
}
}
void testHello(NSString *input) {
NSString *got = GoTestpkgHello(input);
NSString *want = [NSString stringWithFormat:@"Hello, %@!", input];
if (!got) {
ERROR(@"GoTestpkgHello(%@)= NULL, want %@", input, want);
return;
}
if (![got isEqualToString:want]) {
ERROR(@"want %@\nGoTestpkgHello(%@)= %@", want, input, got);
}
}
void testString() {
NSString *input = @"";
NSString *got = GoTestpkgEcho(input);
if (!got || ![got isEqualToString:input]) {
ERROR(@"want %@\nGoTestpkgEcho(%@)= %@", input, input, got);
}
input = @"FOO";
got = GoTestpkgEcho(input);
if (!got || ![got isEqualToString:input]) {
ERROR(@"want %@\nGoTestpkgEcho(%@)= %@", input, input, got);
}
}
void testBytesAppend(NSString *a, NSString *b) {
NSData *data_a = [a dataUsingEncoding:NSUTF8StringEncoding];
NSData *data_b = [b dataUsingEncoding:NSUTF8StringEncoding];
NSData *gotData = GoTestpkgBytesAppend(data_a, data_b);
NSString *got =
[[NSString alloc] initWithData:gotData encoding:NSUTF8StringEncoding];
NSString *want = [a stringByAppendingString:b];
if (![got isEqualToString:want]) {
ERROR(@"want %@\nGoTestpkgBytesAppend(%@, %@) = %@", want, a, b, got);
}
}
void testReturnsError() {
NSString *value;
NSError *error;
GoTestpkgReturnsError(TRUE, &value, &error);
NSString *got = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
NSString *want = @"Error";
if (![got isEqualToString:want]) {
ERROR(@"want %@\nGoTestpkgReturnsError(TRUE) = (%@, %@)", want, value, got);
}
}
void testStruct() {
GoTestpkgS *s = GoTestpkgNewS(10.0, 100.0);
if (!s) {
ERROR(@"GoTestpkgNewS returned NULL");
}
double x = [s x];
double y = [s y];
double sum = [s sum];
if (x != 10.0 || y != 100.0 || sum != 110.0) {
ERROR(@"GoTestpkgS(10.0, 100.0).X=%f Y=%f SUM=%f; want 10, 100, 110", x, y,
sum);
}
double sum2 = GoTestpkgCallSSum(s);
if (sum != sum2) {
ERROR(@"GoTestpkgCallSSum(s)=%f; want %f as returned by s.Sum", sum2, sum);
}
[s setX:7];
[s setY:70];
x = [s x];
y = [s y];
sum = [s sum];
if (x != 7 || y != 70 || sum != 77) {
ERROR(@"GoTestpkgS(7, 70).X=%f Y=%f SUM=%f; want 7, 70, 77", x, y, sum);
}
NSString *first = @"trytwotested";
NSString *second = @"test";
NSString *got = [s tryTwoStrings:first second:second];
NSString *want = [first stringByAppendingString:second];
if (![got isEqualToString:want]) {
ERROR(@"GoTestpkgS_TryTwoStrings(%@, %@)= %@; want %@", first, second, got,
want);
}
GoTestpkgGC();
}
#import <XCTest/XCTest.h>
#import "testpkg/Testpkg.h"
// Objective-C implementation of testpkg.I.
@interface Number : NSObject <GoTestpkgI> {
@ -182,159 +29,36 @@ static int numI = 0;
- (BOOL)stringError:(NSString *)s
ret0_:(NSString **)ret0_
error:(NSError **)error {
if ([s isEqualTo:@"number"]) {
if (ret0_ != NULL) {
*ret0_ = @"OK";
}
return true;
}
return false;
if ([s isEqualToString:@"number"]) {
if (ret0_ != NULL) {
*ret0_ = @"OK";
}
return true;
}
return false;
}
- (BOOL)error:(BOOL)triggerError error:(NSError **)error {
if (!triggerError) {
return YES;
}
if (error != NULL) {
*error = [NSError errorWithDomain:@"SeqTest" code:1 userInfo:NULL];
}
return NO;
if (!triggerError) {
return YES;
}
if (error != NULL) {
*error = [NSError errorWithDomain:@"SeqTest" code:1 userInfo:NULL];
}
return NO;
}
- (int64_t)times:(int32_t)v {
return v * value;
return v * value;
}
- (void)dealloc {
if (self.value == 0) {
numI++;
}
if (self.value == 0) {
numI++;
}
}
@end
void testInterface() {
// Test Go object implementing testpkg.I is handled correctly.
id<GoTestpkgI> goObj = GoTestpkgNewI();
int64_t got = [goObj times:10];
if (got != 100) {
ERROR(@"GoTestpkgNewI().times(10) = %lld; want %d", got, 100);
}
int32_t key = -1;
GoTestpkgRegisterI(key, goObj);
int64_t got2 = GoTestpkgMultiply(key, 10);
if (got != got2) {
ERROR(@"GoTestpkgMultiply(10 * 10) = %lld; want %lld", got2, got);
}
GoTestpkgUnregisterI(key);
// Test Objective-C objects implementing testpkg.I is handled correctly.
@autoreleasepool {
for (int32_t i = 0; i < 10; i++) {
Number *num = [[Number alloc] init];
num.value = i;
GoTestpkgRegisterI(i, num);
}
GoTestpkgGC();
}
// Registered Objective-C objects are pinned on Go side which must
// prevent deallocation from Objective-C.
for (int32_t i = 0; i < 10; i++) {
int64_t got = GoTestpkgMultiply(i, 2);
if (got != i * 2) {
ERROR(@"GoTestpkgMultiply(%d, 2) = %lld; want %d", i, got, i * 2);
return;
}
GoTestpkgUnregisterI(i);
GoTestpkgGC();
}
// Unregistered all Objective-C objects.
}
void testIssue12307() {
Number *num = [[Number alloc] init];
num.value = 1024;
NSError *error;
if (GoTestpkgCallIError(num, YES, &error) == YES) {
ERROR(@"GoTestpkgCallIError(Number, YES) succeeded; want error");
}
NSError *error2;
if (GoTestpkgCallIError(num, NO, &error2) == NO) {
ERROR(@"GoTestpkgCallIError(Number, NO) failed(%@); want success", error2);
}
}
void testIssue12403() {
Number *num = [[Number alloc] init];
num.value = 1024;
NSString *ret;
NSError *error;
if (GoTestpkgCallIStringError(num, @"alphabet", &ret, &error) == YES) {
ERROR(
@"GoTestpkgCallIStringError(Number, 'alphabet') succeeded; want error");
}
NSError *error2;
if (GoTestpkgCallIStringError(num, @"number", &ret, &error2) == NO) {
ERROR(
@"GoTestpkgCallIStringError(Number, 'number') failed(%@); want success",
error2);
} else if (![ret isEqualTo:@"OK"]) {
ERROR(@"GoTestpkgCallIStringError(Number, 'number') returned unexpected "
@"results %@",
ret);
}
}
void testVar() {
NSString *s = GoTestpkg.stringVar;
if (![s isEqualToString:@"a string var"]) {
ERROR(@"GoTestpkg.StringVar = %@, want 'a string var'", s);
}
s = @"a new string var";
GoTestpkg.stringVar = s;
NSString *s2 = GoTestpkg.stringVar;
if (![s2 isEqualToString:s]) {
ERROR(@"GoTestpkg.stringVar = %@, want %@", s2, s);
}
int64_t i = GoTestpkg.intVar;
if (i != 77) {
ERROR(@"GoTestpkg.intVar = %lld, want 77", i);
}
GoTestpkg.intVar = 777;
i = GoTestpkg.intVar;
if (i != 777) {
ERROR(@"GoTestpkg.intVar = %lld, want 777", i);
}
[GoTestpkg setIntVar:7777];
i = [GoTestpkg intVar];
if (i != 7777) {
ERROR(@"GoTestpkg.intVar = %lld, want 7777", i);
}
GoTestpkgNode *n0 = GoTestpkg.structVar;
if (![n0.v isEqualToString:@"a struct var"]) {
ERROR(@"GoTestpkg.structVar = %@, want 'a struct var'", n0.v);
}
GoTestpkgNode *n1 = GoTestpkgNewNode(@"a new struct var");
GoTestpkg.structVar = n1;
GoTestpkgNode *n2 = GoTestpkg.structVar;
if (![n2.v isEqualToString:@"a new struct var"]) {
ERROR(@"GoTestpkg.StructVar = %@, want 'a new struct var'", n2.v);
}
Number *num = [[Number alloc] init];
num.value = 12345;
GoTestpkg.interfaceVar = num;
id<GoTestpkgI> iface = GoTestpkg.interfaceVar;
int64_t x = [iface times:10];
int64_t y = [num times:10];
if (x != y) {
ERROR(@"GoTestpkg.InterfaceVar Times 10 = %lld, want %lld", x, y);
}
}
// Objective-C implementation of testpkg.NullTest.
@interface NullTest : NSObject <GoTestpkgNullTest> {
}
@ -350,135 +74,278 @@ void testVar() {
}
@end
void testNullReferences() {
NullTest *t = [[NullTest alloc] init];
BOOL res = GoTestpkgCallWithNull(nil, t);
if (!res) {
ERROR(@"GoTestpkg.CallWithNull failed");
}
id<GoTestpkgI> i = GoTestpkgNewNullInterface();
if (i != nil) {
ERROR(@"NewNullInterface() returned %p; expected nil", i);
}
GoTestpkgS *s = GoTestpkgNewNullStruct();
if (s != nil) {
ERROR(@"NewNullStruct() returned %p; expected nil", s);
}
@interface tests : XCTestCase
@end
@implementation tests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
void testByteArrayRead() {
NSData *arr = [NSMutableData dataWithLength:8];
int n;
BOOL success = GoTestpkgReadIntoByteArray(arr, &n, nil);
if (!success) {
ERROR(@"ReadIntoByteArray failed");
}
if (n != 8) {
ERROR(@"ReadIntoByteArray wrote %d bytes, expected %d", n, 8);
}
const uint8_t *b = [arr bytes];
for (int i = 0; i < [arr length]; i++) {
if (b[i] != i) {
ERROR(@"ReadIntoByteArray wrote %d at %d; expected %d", b[i], i, i);
}
}
// Test that immutable data cannot be changed from Go
const uint8_t buf[] = {42};
arr = [NSData dataWithBytes:buf length:1];
success = GoTestpkgReadIntoByteArray(arr, &n, nil);
if (!success) {
ERROR(@"ReadIntoByteArray failed");
}
if (n != 1) {
ERROR(@"ReadIntoByteArray wrote %d bytes, expected %d", n, 8);
}
b = [arr bytes];
if (b[0] != 42) {
ERROR(@"ReadIntoByteArray wrote to an immutable NSData; expected no change");
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
void testNilField() {
GoTestpkgNullFieldStruct *s = GoTestpkgNewNullFieldStruct();
if ([s f] != nil) {
ERROR(@"NullFieldStruct has non-nil field; expected nil");
}
}
void testStringDup(NSString *want) {
NSString *got = GoTestpkgStringDup(want);
if (![want isEqualToString:got]) {
ERROR(@"StringDup returned %@; expected %@", got, want)
}
}
void testUnicodeStrings() {
testStringDup(@"abcxyz09{}");
testStringDup(@"Hello, 世界");
testStringDup(@"\uffff\U00010000\U00010001\U00012345\U0010ffff");
}
// Invokes functions and object methods defined in Testpkg.h.
//
// TODO(hyangah): apply testing framework (e.g. XCTestCase)
// and test through xcodebuild.
int main(void) {
@autoreleasepool {
- (void)testBasics {
GoTestpkgHi();
GoTestpkgInt(42);
}
- (void)testSum {
int64_t sum = GoTestpkgSum(31, 21);
if (sum != 52) {
ERROR(@"GoTestpkgSum(31, 21) = %lld, want 52\n", sum);
}
XCTAssertEqual(sum, 52, @"GoTestpkgSum(31, 21) = %lld, want 52\n", sum);
}
testHello(@"세계"); // korean, utf-8, world.
testString();
- (void)testHello:(NSString *)input {
NSString *got = GoTestpkgHello(input);
NSString *want = [NSString stringWithFormat:@"Hello, %@!", input];
XCTAssertEqualObjects(got, want, @"want %@\nGoTestpkgHello(%@)= %@", want, input, got);
}
- (void)testHellos {
[self testHello:@"세계"]; // korean, utf-8, world.
unichar t[] = {
0xD83D, 0xDCA9,
}; // utf-16, pile of poo.
testHello([NSString stringWithCharacters:t length:2]);
testBytesAppend(@"Foo", @"Bar");
@autoreleasepool {
testStruct();
}
int numS = GoTestpkgCollectS(
1, 10); // within 10 seconds, collect the S used in testStruct.
if (numS != 1) {
ERROR(@"%d S objects were collected; S used in testStruct is supposed to "
@"be collected.",
numS);
}
@autoreleasepool {
testInterface();
}
if (numI != 1) {
ERROR(@"%d I objects were collected; I used in testInterface is supposed "
@"to be collected.",
numI);
}
testConst();
testIssue12307();
testVar();
testNullReferences();
testByteArrayRead();
testNilField();
testUnicodeStrings();
}
fprintf(stderr, "%s\n", err ? "FAIL" : "PASS");
return err;
[self testHello:[NSString stringWithCharacters:t length:2]];
}
- (void)testString {
NSString *input = @"";
NSString *got = GoTestpkgEcho(input);
XCTAssertEqualObjects(got, input, @"want %@\nGoTestpkgEcho(%@)= %@", input, input, got);
input = @"FOO";
got = GoTestpkgEcho(input);
XCTAssertEqualObjects(got, input, @"want %@\nGoTestpkgEcho(%@)= %@", input, input, got);
}
- (void)testStruct {
GoTestpkgS *s = GoTestpkgNewS(10.0, 100.0);
XCTAssertNotNil(s, @"GoTestpkgNewS returned NULL");
double x = [s x];
double y = [s y];
double sum = [s sum];
XCTAssertTrue(x == 10.0 && y == 100.0 && sum == 110.0,
@"GoTestpkgS(10.0, 100.0).X=%f Y=%f SUM=%f; want 10, 100, 110", x, y, sum);
double sum2 = GoTestpkgCallSSum(s);
XCTAssertEqual(sum, sum2, @"GoTestpkgCallSSum(s)=%f; want %f as returned by s.Sum", sum2, sum);
[s setX:7];
[s setY:70];
x = [s x];
y = [s y];
sum = [s sum];
XCTAssertTrue(x == 7 && y == 70 && sum == 77,
@"GoTestpkgS(7, 70).X=%f Y=%f SUM=%f; want 7, 70, 77", x, y, sum);
NSString *first = @"trytwotested";
NSString *second = @"test";
NSString *got = [s tryTwoStrings:first second:second];
NSString *want = [first stringByAppendingString:second];
XCTAssertEqualObjects(got, want, @"GoTestpkgS_TryTwoStrings(%@, %@)= %@; want %@", first, second, got, want);
}
- (void)testCollectS {
@autoreleasepool {
[self testStruct];
}
GoTestpkgGC();
int numS = GoTestpkgCollectS(
1, 10); // within 10 seconds, collect the S used in testStruct.
XCTAssertEqual(numS, 1, @"%d S objects were collected; S used in testStruct is supposed to "
@"be collected.",
numS);
}
- (void)testBytesAppend {
NSString *a = @"Foo";
NSString *b = @"Bar";
NSData *data_a = [a dataUsingEncoding:NSUTF8StringEncoding];
NSData *data_b = [b dataUsingEncoding:NSUTF8StringEncoding];
NSData *gotData = GoTestpkgBytesAppend(data_a, data_b);
NSString *got = [[NSString alloc] initWithData:gotData encoding:NSUTF8StringEncoding];
NSString *want = [a stringByAppendingString:b];
XCTAssertEqualObjects(got, want, @"want %@\nGoTestpkgBytesAppend(%@, %@) = %@", want, a, b, got);
}
- (void)testInterface {
// Test Go object implementing testpkg.I is handled correctly.
id<GoTestpkgI> goObj = GoTestpkgNewI();
int64_t got = [goObj times:10];
XCTAssertEqual(got, 100, @"GoTestpkgNewI().times(10) = %lld; want %d", got, 100);
int32_t key = -1;
GoTestpkgRegisterI(key, goObj);
int64_t got2 = GoTestpkgMultiply(key, 10);
XCTAssertEqual(got, got2, @"GoTestpkgMultiply(10 * 10) = %lld; want %lld", got2, got);
GoTestpkgUnregisterI(key);
// Test Objective-C objects implementing testpkg.I is handled correctly.
@autoreleasepool {
for (int32_t i = 0; i < 10; i++) {
Number *num = [[Number alloc] init];
num.value = i;
GoTestpkgRegisterI(i, num);
}
GoTestpkgGC();
}
// Registered Objective-C objects are pinned on Go side which must
// prevent deallocation from Objective-C.
for (int32_t i = 0; i < 10; i++) {
int64_t got = GoTestpkgMultiply(i, 2);
XCTAssertEqual(got, i * 2,@"GoTestpkgMultiply(%d, 2) = %lld; want %d", i, got, i * 2);
GoTestpkgUnregisterI(i);
GoTestpkgGC();
}
// Unregistered all Objective-C objects.
}
- (void)testCollectI {
@autoreleasepool {
[self testInterface];
}
XCTAssertEqual(numI, 1, @"%d I objects were collected; I used in testInterface is supposed "
@"to be collected.", numI);
}
- (void)testConst {
XCTAssertEqualObjects(GoTestpkgAString, @"a string", @"GoTestpkgAString = %@, want 'a string'", GoTestpkgAString);
XCTAssertEqual(GoTestpkgAnInt, 7, @"GoTestpkgAnInt = %lld, want 7", GoTestpkgAnInt);
XCTAssertTrue(ABS(GoTestpkgAFloat - 0.12345) < 0.0001, @"GoTestpkgAFloat = %f, want 0.12345", GoTestpkgAFloat);
XCTAssertTrue(GoTestpkgABool == YES, @"GoTestpkgABool = %@, want YES", GoTestpkgAFloat ? @"YES" : @"NO");
XCTAssertEqual(GoTestpkgMinInt32, INT32_MIN, @"GoTestpkgMinInt32 = %d, want %d", GoTestpkgMinInt32, INT32_MIN);
XCTAssertEqual(GoTestpkgMaxInt32, INT32_MAX, @"GoTestpkgMaxInt32 = %d, want %d", GoTestpkgMaxInt32, INT32_MAX);
XCTAssertEqual(GoTestpkgMinInt64, INT64_MIN, @"GoTestpkgMinInt64 = %lld, want %lld", GoTestpkgMinInt64, INT64_MIN);
XCTAssertEqual(GoTestpkgMaxInt64, INT64_MAX, @"GoTestpkgMaxInt64 = %lld, want %lld", GoTestpkgMaxInt64, INT64_MAX);
XCTAssertTrue(ABS(GoTestpkgSmallestNonzeroFloat64 -
4.940656458412465441765687928682213723651e-324) < 1e-323, @"GoTestpkgSmallestNonzeroFloat64 = %f, want %f",
GoTestpkgSmallestNonzeroFloat64,
4.940656458412465441765687928682213723651e-324);
XCTAssertTrue(ABS(GoTestpkgMaxFloat64 -
1.797693134862315708145274237317043567981e+308) < 0.0001, @"GoTestpkgMaxFloat64 = %f, want %f", GoTestpkgMaxFloat64,
1.797693134862315708145274237317043567981e+308);
XCTAssertTrue(ABS(GoTestpkgSmallestNonzeroFloat32 -
1.401298464324817070923729583289916131280e-45) < 1e-44, @"GoTestpkgSmallestNonzeroFloat32 = %f, want %f",
GoTestpkgSmallestNonzeroFloat32,
1.401298464324817070923729583289916131280e-45);
XCTAssertTrue(ABS(GoTestpkgMaxFloat32 - 3.40282346638528859811704183484516925440e+38) < 0.0001,
@"GoTestpkgMaxFloat32 = %f, want %f", GoTestpkgMaxFloat32, 3.40282346638528859811704183484516925440e+38);
XCTAssertTrue(ABS(GoTestpkgLog2E - 1 / 0.693147180559945309417232121458176568075500134360255254120680009) < 0.0001,
@"GoTestpkgLog2E = %f, want %f", GoTestpkgLog2E, 1 / 0.693147180559945309417232121458176568075500134360255254120680009);
}
- (void)testIssue12307 {
Number *num = [[Number alloc] init];
num.value = 1024;
NSError *error;
XCTAssertFalse(GoTestpkgCallIError(num, YES, &error), @"GoTestpkgCallIError(Number, YES) succeeded; want error");
NSError *error2;
XCTAssertTrue(GoTestpkgCallIError(num, NO, &error2), @"GoTestpkgCallIError(Number, NO) failed(%@); want success", error2);
}
- (void)testVar {
NSString *s = GoTestpkg.stringVar;
XCTAssertEqualObjects(s, @"a string var", @"GoTestpkg.StringVar = %@, want 'a string var'", s);
s = @"a new string var";
GoTestpkg.stringVar = s;
NSString *s2 = GoTestpkg.stringVar;
XCTAssertEqualObjects(s2, s, @"GoTestpkg.stringVar = %@, want %@", s2, s);
int64_t i = GoTestpkg.intVar;
XCTAssertEqual(i, 77, @"GoTestpkg.intVar = %lld, want 77", i);
GoTestpkg.intVar = 777;
i = GoTestpkg.intVar;
XCTAssertEqual(i, 777, @"GoTestpkg.intVar = %lld, want 777", i);
[GoTestpkg setIntVar:7777];
i = [GoTestpkg intVar];
XCTAssertEqual(i, 7777, @"GoTestpkg.intVar = %lld, want 7777", i);
GoTestpkgNode *n0 = GoTestpkg.structVar;
XCTAssertEqualObjects(n0.v, @"a struct var", @"GoTestpkg.structVar = %@, want 'a struct var'", n0.v);
GoTestpkgNode *n1 = GoTestpkgNewNode(@"a new struct var");
GoTestpkg.structVar = n1;
GoTestpkgNode *n2 = GoTestpkg.structVar;
XCTAssertEqualObjects(n2.v, @"a new struct var", @"GoTestpkg.StructVar = %@, want 'a new struct var'", n2.v);
Number *num = [[Number alloc] init];
num.value = 12345;
GoTestpkg.interfaceVar = num;
id<GoTestpkgI> iface = GoTestpkg.interfaceVar;
int64_t x = [iface times:10];
int64_t y = [num times:10];
XCTAssertEqual(x, y, @"GoTestpkg.InterfaceVar Times 10 = %lld, want %lld", x, y);
}
- (void)testIssue12403 {
Number *num = [[Number alloc] init];
num.value = 1024;
NSString *ret;
NSError *error;
XCTAssertFalse(GoTestpkgCallIStringError(num, @"alphabet", &ret, &error), @"GoTestpkgCallIStringError(Number, 'alphabet') succeeded; want error");
NSError *error2;
XCTAssertTrue(GoTestpkgCallIStringError(num, @"number", &ret, &error2), @"GoTestpkgCallIStringError(Number, 'number') failed(%@); want success", error2);
XCTAssertEqualObjects(ret, @"OK", @"GoTestpkgCallIStringError(Number, 'number') returned unexpected results %@", ret);
}
- (void)testStringDup:(NSString *)want {
NSString *got = GoTestpkgStringDup(want);
XCTAssertEqualObjects(want, got, @"StringDup returned %@; expected %@", got, want);
}
- (void)testUnicodeStrings {
[self testStringDup:@"abcxyz09{}"];
[self testStringDup:@"Hello, 世界"];
[self testStringDup:@"\uffff\U00010000\U00010001\U00012345\U0010ffff"];
}
- (void)testByteArrayRead {
NSData *arr = [NSMutableData dataWithLength:8];
int n;
XCTAssertTrue(GoTestpkgReadIntoByteArray(arr, &n, nil), @"ReadIntoByteArray failed");
XCTAssertEqual(n, 8, @"ReadIntoByteArray wrote %d bytes, expected %d", n, 8);
const uint8_t *b = [arr bytes];
for (int i = 0; i < [arr length]; i++) {
XCTAssertEqual(b[i], i, @"ReadIntoByteArray wrote %d at %d; expected %d", b[i], i, i);
}
// Test that immutable data cannot be changed from Go
const uint8_t buf[] = {42};
arr = [NSData dataWithBytes:buf length:1];
XCTAssertTrue(GoTestpkgReadIntoByteArray(arr, &n, nil), @"ReadIntoByteArray failed");
XCTAssertEqual(n, 1, @"ReadIntoByteArray wrote %d bytes, expected %d", n, 8);
b = [arr bytes];
XCTAssertEqual(b[0], 42, @"ReadIntoByteArray wrote to an immutable NSData; expected no change");
}
- (void)testNilField {
GoTestpkgNullFieldStruct *s = GoTestpkgNewNullFieldStruct();
XCTAssertNil([s f], @"NullFieldStruct has non-nil field; expected nil");
}
- (void)testNullReferences {
NullTest *t = [[NullTest alloc] init];
XCTAssertTrue(GoTestpkgCallWithNull(nil, t), @"GoTestpkg.CallWithNull failed");
id<GoTestpkgI> i = GoTestpkgNewNullInterface();
XCTAssertNil(i, @"NewNullInterface() returned %p; expected nil", i);
GoTestpkgS *s = GoTestpkgNewNullStruct();
XCTAssertNil(s, @"NewNullStruct() returned %p; expected nil", s);
}
- (void)testReturnsError {
NSString *value;
NSError *error;
GoTestpkgReturnsError(TRUE, &value, &error);
NSString *got = [error.userInfo valueForKey:NSLocalizedDescriptionKey];
NSString *want = @"Error";
XCTAssertEqualObjects(got, want, @"want %@\nGoTestpkgReturnsError(TRUE) = (%@, %@)", want, value, got);
}
@end

View File

@ -103,7 +103,9 @@ static RefTracker *tracker = NULL;
void init_seq() { tracker = [[RefTracker alloc] init]; }
void go_seq_dec_ref(int32_t refnum) {
[tracker dec:refnum];
@autoreleasepool {
[tracker dec:refnum];
}
}
NSData *go_seq_to_objc_bytearray(nbyteslice s, int copy) {

99
bind/objc/seq_test.go Normal file
View File

@ -0,0 +1,99 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objc
import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
var destination = flag.String("device", "platform=iOS Simulator,name=iPhone 6s Plus", "Specify the -destination flag to xcodebuild")
// TestObjcSeqTest runs ObjC test SeqTest.m.
// This requires the xcode command lines tools.
func TestObjcSeqTest(t *testing.T) {
runTest(t, "golang.org/x/mobile/bind/objc/testpkg", "xcodetest", "SeqTest.m")
}
func runTest(t *testing.T, pkgName, project, testfile string) {
if _, err := run("which xcodebuild"); err != nil {
t.Skip("command xcodebuild not found, skipping")
}
if _, err := run("which gomobile"); err != nil {
_, err := run("go install golang.org/x/mobile/cmd/gomobile")
if err != nil {
t.Skip("gomobile not available, skipping")
}
}
// TODO(hyangah): gomobile init if necessary.
cwd, err := os.Getwd()
if err != nil {
t.Fatalf("failed pwd: %v", err)
}
tmpdir, err := ioutil.TempDir("", "bind-objc-seq-test-")
if err != nil {
t.Fatalf("failed to prepare temp dir: %v", err)
}
defer os.RemoveAll(tmpdir)
t.Logf("tmpdir = %s", tmpdir)
if buf, err := exec.Command("cp", "-a", project, tmpdir).CombinedOutput(); err != nil {
t.Logf("%s", buf)
t.Fatalf("failed to copy %s to tmp dir: %v", project, err)
}
if err := cp(filepath.Join(tmpdir, testfile), testfile); err != nil {
t.Fatalf("failed to copy %s: %v", testfile, err)
}
if err := os.Chdir(filepath.Join(tmpdir, project)); err != nil {
t.Fatalf("failed chdir: %v", err)
}
defer os.Chdir(cwd)
buf, err := run("gomobile bind -target=ios " + pkgName)
if err != nil {
t.Logf("%s", buf)
t.Fatalf("failed to run gomobile bind: %v", err)
}
cmd := exec.Command("xcodebuild", "test", "-scheme", "xcodetest", "-destination", *destination)
if buf, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", buf)
t.Errorf("failed to run xcodebuild: %v", err)
}
}
func run(cmd string) ([]byte, error) {
c := strings.Split(cmd, " ")
return exec.Command(c[0], c[1:]...).CombinedOutput()
}
func cp(dst, src string) error {
r, err := os.Open(src)
if err != nil {
return fmt.Errorf("failed to read source: %v", err)
}
defer r.Close()
w, err := os.Create(dst)
if err != nil {
return fmt.Errorf("failed to open destination: %v", err)
}
_, err = io.Copy(w, r)
cerr := w.Close()
if err != nil {
return err
}
return cerr
}

View File

@ -1,34 +0,0 @@
#!/usr/bin/env bash
# Copyright 2015 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# This is a script to compile and run SeqTest.
set -e
export GOARCH=amd64
export GOOS=darwin # TODO: arm, arm64.
export CGO_ENABLED=1
WORK=`mktemp -d /tmp/objctest.XXXXX`
function cleanup() {
rm -rf ${WORK}
}
trap cleanup EXIT
(cd testpkg; go generate)
cp ./seq.h ./testpkg/go_testpkg
cp ./seq_darwin.m.support ./testpkg/go_testpkg/seq_darwin.m
cp ./seq_darwin.go.support ./testpkg/go_testpkg/seq_darwin.go
cp ../seq.go.support ./testpkg/go_testpkg/seq.go
go build -x -v -buildmode=c-archive -ldflags="$ccargs" -o=${WORK}/libgo.a test_main.go
cp testpkg/go_testpkg/GoTestpkg.h ${WORK}/
cp ./SeqTest.m ${WORK}/
ccargs="-Wl,-no_pie -framework Foundation -fobjc-arc"
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o ${WORK}/a.out ${WORK}/libgo.a ${WORK}/SeqTest.m
${WORK}/a.out

View File

@ -1,18 +0,0 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// Dummy main used by test.bash to build testpkg.
package main
import "C"
import (
_ "golang.org/x/mobile/bind/objc/testpkg/go_testpkg"
)
func main() {
panic("not called in a c-archive")
}

View File

@ -1,155 +0,0 @@
// Objective-C API for talking to golang.org/x/mobile/bind/objc/testpkg Go package.
// gobind -lang=objc golang.org/x/mobile/bind/objc/testpkg
//
// File is generated by gobind. Do not edit.
#ifndef __GoTestpkg_H__
#define __GoTestpkg_H__
#include <Foundation/Foundation.h>
@class GoTestpkgNode;
@class GoTestpkgNullFieldStruct;
@class GoTestpkgS;
@class GoTestpkgStructThatStartsWithLetterBeforeZ;
@protocol GoTestpkgI;
@class GoTestpkgI;
@protocol GoTestpkgNullTest;
@class GoTestpkgNullTest;
@protocol GoTestpkgZ;
@class GoTestpkgZ;
@interface GoTestpkgNode : NSObject {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (NSString*)v;
- (void)setV:(NSString*)v;
- (NSString*)err;
- (void)setErr:(NSString*)v;
@end
@interface GoTestpkgNullFieldStruct : NSObject {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (GoTestpkgS*)f;
- (void)setF:(GoTestpkgS*)v;
@end
@interface GoTestpkgS : NSObject {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (double)x;
- (void)setX:(double)v;
- (double)y;
- (void)setY:(double)v;
- (double)sum;
- (NSString*)tryTwoStrings:(NSString*)first second:(NSString*)second;
@end
@interface GoTestpkgStructThatStartsWithLetterBeforeZ : NSObject {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (id<GoTestpkgZ>)value;
- (void)setValue:(id<GoTestpkgZ>)v;
@end
@protocol GoTestpkgI
- (BOOL)error:(BOOL)triggerError error:(NSError**)error;
- (BOOL)stringError:(NSString*)s ret0_:(NSString**)ret0_ error:(NSError**)error;
- (int64_t)times:(int32_t)v;
@end
@protocol GoTestpkgNullTest
- (id<GoTestpkgNullTest>)null;
@end
@protocol GoTestpkgZ
@end
FOUNDATION_EXPORT const BOOL GoTestpkgABool;
FOUNDATION_EXPORT const double GoTestpkgAFloat;
FOUNDATION_EXPORT NSString* const GoTestpkgALongString;
FOUNDATION_EXPORT NSString* const GoTestpkgAString;
FOUNDATION_EXPORT const int64_t GoTestpkgAnInt;
FOUNDATION_EXPORT const double GoTestpkgLog2E;
FOUNDATION_EXPORT const float GoTestpkgMaxFloat32;
FOUNDATION_EXPORT const double GoTestpkgMaxFloat64;
FOUNDATION_EXPORT const int32_t GoTestpkgMaxInt32;
FOUNDATION_EXPORT const int64_t GoTestpkgMaxInt64;
FOUNDATION_EXPORT const int32_t GoTestpkgMinInt32;
FOUNDATION_EXPORT const int64_t GoTestpkgMinInt64;
FOUNDATION_EXPORT const float GoTestpkgSmallestNonzeroFloat32;
FOUNDATION_EXPORT const double GoTestpkgSmallestNonzeroFloat64;
@interface GoTestpkg : NSObject
+ (int) intVar;
+ (void) setIntVar:(int)v;
+ (id<GoTestpkgI>) interfaceVar;
+ (void) setInterfaceVar:(id<GoTestpkgI>)v;
+ (NSString*) stringVar;
+ (void) setStringVar:(NSString*)v;
+ (GoTestpkgNode*) structVar;
+ (void) setStructVar:(GoTestpkgNode*)v;
@end
FOUNDATION_EXPORT NSData* GoTestpkgBytesAppend(NSData* a, NSData* b);
FOUNDATION_EXPORT BOOL GoTestpkgCallIError(id<GoTestpkgI> i, BOOL triggerError, NSError** error);
FOUNDATION_EXPORT BOOL GoTestpkgCallIStringError(id<GoTestpkgI> i, NSString* s, NSString** ret0_, NSError** error);
FOUNDATION_EXPORT double GoTestpkgCallSSum(GoTestpkgS* s);
FOUNDATION_EXPORT BOOL GoTestpkgCallWithNull(id<GoTestpkgNullTest> p0, id<GoTestpkgNullTest> nuller);
FOUNDATION_EXPORT int GoTestpkgCollectS(int want, int timeoutSec);
FOUNDATION_EXPORT NSString* GoTestpkgEcho(NSString* s);
FOUNDATION_EXPORT void GoTestpkgGC();
FOUNDATION_EXPORT NSString* GoTestpkgHello(NSString* s);
FOUNDATION_EXPORT void GoTestpkgHi();
FOUNDATION_EXPORT void GoTestpkgInt(int32_t x);
FOUNDATION_EXPORT int64_t GoTestpkgMultiply(int32_t idx, int32_t val);
FOUNDATION_EXPORT id<GoTestpkgI> GoTestpkgNewI();
FOUNDATION_EXPORT GoTestpkgNode* GoTestpkgNewNode(NSString* name);
FOUNDATION_EXPORT GoTestpkgNullFieldStruct* GoTestpkgNewNullFieldStruct();
FOUNDATION_EXPORT id<GoTestpkgI> GoTestpkgNewNullInterface();
FOUNDATION_EXPORT GoTestpkgS* GoTestpkgNewNullStruct();
FOUNDATION_EXPORT GoTestpkgS* GoTestpkgNewS(double x, double y);
FOUNDATION_EXPORT BOOL GoTestpkgReadIntoByteArray(NSData* s, int* ret0_, NSError** error);
FOUNDATION_EXPORT void GoTestpkgRegisterI(int32_t idx, id<GoTestpkgI> i);
FOUNDATION_EXPORT BOOL GoTestpkgReturnsError(BOOL b, NSString** ret0_, NSError** error);
FOUNDATION_EXPORT NSString* GoTestpkgStringDup(NSString* s);
FOUNDATION_EXPORT int64_t GoTestpkgSum(int64_t x, int64_t y);
FOUNDATION_EXPORT void GoTestpkgUnregisterI(int32_t idx);
#endif

View File

@ -1,725 +0,0 @@
// Objective-C API for talking to golang.org/x/mobile/bind/objc/testpkg Go package.
// gobind -lang=objc golang.org/x/mobile/bind/objc/testpkg
//
// File is generated by gobind. Do not edit.
#include "GoTestpkg.h"
#include <Foundation/Foundation.h>
#include "seq.h"
#include "_cgo_export.h"
static NSString* errDomain = @"go.golang.org/x/mobile/bind/objc/testpkg";
@protocol goSeqRefInterface
-(GoSeqRef*) _ref;
@end
@class GoTestpkgI;
@class GoTestpkgNullTest;
@class GoTestpkgZ;
@interface GoTestpkgI : NSObject <GoTestpkgI> {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (BOOL)error:(BOOL)triggerError error:(NSError**)error;
- (BOOL)stringError:(NSString*)s ret0_:(NSString**)ret0_ error:(NSError**)error;
- (int64_t)times:(int32_t)v;
@end
@interface GoTestpkgNullTest : NSObject <GoTestpkgNullTest> {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
- (id<GoTestpkgNullTest>)null;
@end
@interface GoTestpkgZ : NSObject <GoTestpkgZ> {
}
@property(strong, readonly) id _ref;
- (id)initWithRef:(id)ref;
@end
@implementation GoTestpkgNode {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (NSString*)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring r0 = proxytestpkg_Node_V_Get(refnum);
NSString *_r0 = go_seq_to_objc_string(r0);
return _r0;
}
- (void)setV:(NSString*)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring _v = go_seq_from_objc_string(v);
proxytestpkg_Node_V_Set(refnum, _v);
}
- (NSString*)err {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring r0 = proxytestpkg_Node_Err_Get(refnum);
NSString *_r0 = go_seq_to_objc_string(r0);
return _r0;
}
- (void)setErr:(NSString*)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring _v = go_seq_from_objc_string(v);
proxytestpkg_Node_Err_Set(refnum, _v);
}
@end
@implementation GoTestpkgNullFieldStruct {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (GoTestpkgS*)f {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t r0 = proxytestpkg_NullFieldStruct_F_Get(refnum);
GoTestpkgS* _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoTestpkgS alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
- (void)setF:(GoTestpkgS*)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t _v;
if ([(id<NSObject>)(v) isKindOfClass:[GoTestpkgS class]]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
proxytestpkg_NullFieldStruct_F_Set(refnum, _v);
}
@end
@implementation GoTestpkgS {
}
- (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 = proxytestpkg_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;
proxytestpkg_S_X_Set(refnum, _v);
}
- (double)y {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double r0 = proxytestpkg_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;
proxytestpkg_S_Y_Set(refnum, _v);
}
- (double)sum {
int32_t refnum = go_seq_go_to_refnum(self._ref);
double r0 = proxytestpkg_S_Sum(refnum);
double _ret0_ = (double)r0;
return _ret0_;
}
- (NSString*)tryTwoStrings:(NSString*)first second:(NSString*)second {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring _first = go_seq_from_objc_string(first);
nstring _second = go_seq_from_objc_string(second);
nstring r0 = proxytestpkg_S_TryTwoStrings(refnum, _first, _second);
NSString *_ret0_ = go_seq_to_objc_string(r0);
return _ret0_;
}
@end
@implementation GoTestpkgStructThatStartsWithLetterBeforeZ {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (id<GoTestpkgZ>)value {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t r0 = proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Get(refnum);
id<GoTestpkgZ> _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoTestpkgZ alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
- (void)setValue:(id<GoTestpkgZ>)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t _v;
if ([(id<NSObject>)(v) isKindOfClass:[GoTestpkgZ class]]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Set(refnum, _v);
}
@end
@implementation GoTestpkgI {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (BOOL)error:(BOOL)triggerError error:(NSError**)error {
int32_t refnum = go_seq_go_to_refnum(self._ref);
char _triggerError = (char)triggerError;
nstring r0 = proxytestpkg_I_Error(refnum, _triggerError);
NSString *_error = go_seq_to_objc_string(r0);
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
- (BOOL)stringError:(NSString*)s ret0_:(NSString**)ret0_ error:(NSError**)error {
int32_t refnum = go_seq_go_to_refnum(self._ref);
nstring _s = go_seq_from_objc_string(s);
struct proxytestpkg_I_StringError_return res = proxytestpkg_I_StringError(refnum, _s);
NSString *_ret0_ = go_seq_to_objc_string(res.r0);
NSString *_error = go_seq_to_objc_string(res.r1);
*ret0_ = _ret0_;
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
- (int64_t)times:(int32_t)v {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t _v = (int32_t)v;
int64_t r0 = proxytestpkg_I_Times(refnum, _v);
int64_t _ret0_ = (int64_t)r0;
return _ret0_;
}
@end
@implementation GoTestpkgNullTest {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
- (id<GoTestpkgNullTest>)null {
int32_t refnum = go_seq_go_to_refnum(self._ref);
int32_t r0 = proxytestpkg_NullTest_Null(refnum);
id<GoTestpkgNullTest> _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgNullTest alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
@end
@implementation GoTestpkgZ {
}
- (id)initWithRef:(id)ref {
self = [super init];
if (self) { __ref = ref; }
return self;
}
@end
const BOOL GoTestpkgABool = YES;
const double GoTestpkgAFloat = 0.12345;
NSString* const GoTestpkgALongString = @"LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString,LongString";
NSString* const GoTestpkgAString = @"a string";
const int64_t GoTestpkgAnInt = 7LL;
const double GoTestpkgLog2E = 1.4426950408889634;
const float GoTestpkgMaxFloat32 = 3.4028234663852886e+38;
const double GoTestpkgMaxFloat64 = 1.7976931348623157e+308;
const int32_t GoTestpkgMaxInt32 = 2147483647;
const int64_t GoTestpkgMaxInt64 = 9223372036854775807LL;
const int32_t GoTestpkgMinInt32 = -2147483648;
const int64_t GoTestpkgMinInt64 = -9223372036854775807LL-1;
const float GoTestpkgSmallestNonzeroFloat32 = 0;
const double GoTestpkgSmallestNonzeroFloat64 = 5e-324;
@implementation GoTestpkg
+ (void) setIntVar:(int)v {
nint _v = (nint)v;
var_settestpkg_IntVar(_v);
}
+ (int) intVar {
nint r0 = var_gettestpkg_IntVar();
int _r0 = (int)r0;
return _r0;
}
+ (void) setInterfaceVar:(id<GoTestpkgI>)v {
int32_t _v;
if ([(id<NSObject>)(v) isKindOfClass:[GoTestpkgI class]]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
var_settestpkg_InterfaceVar(_v);
}
+ (id<GoTestpkgI>) interfaceVar {
int32_t r0 = var_gettestpkg_InterfaceVar();
id<GoTestpkgI> _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoTestpkgI alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
+ (void) setStringVar:(NSString*)v {
nstring _v = go_seq_from_objc_string(v);
var_settestpkg_StringVar(_v);
}
+ (NSString*) stringVar {
nstring r0 = var_gettestpkg_StringVar();
NSString *_r0 = go_seq_to_objc_string(r0);
return _r0;
}
+ (void) setStructVar:(GoTestpkgNode*)v {
int32_t _v;
if ([(id<NSObject>)(v) isKindOfClass:[GoTestpkgNode class]]) {
id<goSeqRefInterface> v_proxy = (id<goSeqRefInterface>)(v);
_v = go_seq_go_to_refnum(v_proxy._ref);
} else {
_v = go_seq_to_refnum(v);
}
var_settestpkg_StructVar(_v);
}
+ (GoTestpkgNode*) structVar {
int32_t r0 = var_gettestpkg_StructVar();
GoTestpkgNode* _r0 = nil;
GoSeqRef* _r0_ref = go_seq_from_refnum(r0);
if (_r0_ref != NULL) {
_r0 = _r0_ref.obj;
if (_r0 == nil) {
_r0 = [[GoTestpkgNode alloc] initWithRef:_r0_ref];
}
}
return _r0;
}
@end
NSData* GoTestpkgBytesAppend(NSData* a, NSData* b) {
nbyteslice _a = go_seq_from_objc_bytearray(a, 0);
nbyteslice _b = go_seq_from_objc_bytearray(b, 0);
nbyteslice r0 = proxytestpkg__BytesAppend(_a, _b);
if (![a isKindOfClass:[NSMutableData class]]) {
free(_a.ptr);
}
if (![b isKindOfClass:[NSMutableData class]]) {
free(_b.ptr);
}
NSData *_ret0_ = go_seq_to_objc_bytearray(r0, 1);
return _ret0_;
}
BOOL GoTestpkgCallIError(id<GoTestpkgI> i, BOOL triggerError, NSError** error) {
int32_t _i;
if ([(id<NSObject>)(i) isKindOfClass:[GoTestpkgI class]]) {
id<goSeqRefInterface> i_proxy = (id<goSeqRefInterface>)(i);
_i = go_seq_go_to_refnum(i_proxy._ref);
} else {
_i = go_seq_to_refnum(i);
}
char _triggerError = (char)triggerError;
nstring r0 = proxytestpkg__CallIError(_i, _triggerError);
NSString *_error = go_seq_to_objc_string(r0);
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
BOOL GoTestpkgCallIStringError(id<GoTestpkgI> i, NSString* s, NSString** ret0_, NSError** error) {
int32_t _i;
if ([(id<NSObject>)(i) isKindOfClass:[GoTestpkgI class]]) {
id<goSeqRefInterface> i_proxy = (id<goSeqRefInterface>)(i);
_i = go_seq_go_to_refnum(i_proxy._ref);
} else {
_i = go_seq_to_refnum(i);
}
nstring _s = go_seq_from_objc_string(s);
struct proxytestpkg__CallIStringError_return res = proxytestpkg__CallIStringError(_i, _s);
NSString *_ret0_ = go_seq_to_objc_string(res.r0);
NSString *_error = go_seq_to_objc_string(res.r1);
*ret0_ = _ret0_;
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
double GoTestpkgCallSSum(GoTestpkgS* s) {
int32_t _s;
if ([(id<NSObject>)(s) isKindOfClass:[GoTestpkgS class]]) {
id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
_s = go_seq_go_to_refnum(s_proxy._ref);
} else {
_s = go_seq_to_refnum(s);
}
double r0 = proxytestpkg__CallSSum(_s);
double _ret0_ = (double)r0;
return _ret0_;
}
BOOL GoTestpkgCallWithNull(id<GoTestpkgNullTest> p0, id<GoTestpkgNullTest> nuller) {
int32_t _p0;
if ([(id<NSObject>)(p0) isKindOfClass:[GoTestpkgNullTest class]]) {
id<goSeqRefInterface> p0_proxy = (id<goSeqRefInterface>)(p0);
_p0 = go_seq_go_to_refnum(p0_proxy._ref);
} else {
_p0 = go_seq_to_refnum(p0);
}
int32_t _nuller;
if ([(id<NSObject>)(nuller) isKindOfClass:[GoTestpkgNullTest class]]) {
id<goSeqRefInterface> nuller_proxy = (id<goSeqRefInterface>)(nuller);
_nuller = go_seq_go_to_refnum(nuller_proxy._ref);
} else {
_nuller = go_seq_to_refnum(nuller);
}
char r0 = proxytestpkg__CallWithNull(_p0, _nuller);
BOOL _ret0_ = r0 ? YES : NO;
return _ret0_;
}
int GoTestpkgCollectS(int want, int timeoutSec) {
nint _want = (nint)want;
nint _timeoutSec = (nint)timeoutSec;
nint r0 = proxytestpkg__CollectS(_want, _timeoutSec);
int _ret0_ = (int)r0;
return _ret0_;
}
NSString* GoTestpkgEcho(NSString* s) {
nstring _s = go_seq_from_objc_string(s);
nstring r0 = proxytestpkg__Echo(_s);
NSString *_ret0_ = go_seq_to_objc_string(r0);
return _ret0_;
}
void GoTestpkgGC() {
proxytestpkg__GC();
}
NSString* GoTestpkgHello(NSString* s) {
nstring _s = go_seq_from_objc_string(s);
nstring r0 = proxytestpkg__Hello(_s);
NSString *_ret0_ = go_seq_to_objc_string(r0);
return _ret0_;
}
void GoTestpkgHi() {
proxytestpkg__Hi();
}
void GoTestpkgInt(int32_t x) {
int32_t _x = (int32_t)x;
proxytestpkg__Int(_x);
}
int64_t GoTestpkgMultiply(int32_t idx, int32_t val) {
int32_t _idx = (int32_t)idx;
int32_t _val = (int32_t)val;
int64_t r0 = proxytestpkg__Multiply(_idx, _val);
int64_t _ret0_ = (int64_t)r0;
return _ret0_;
}
id<GoTestpkgI> GoTestpkgNewI() {
int32_t r0 = proxytestpkg__NewI();
id<GoTestpkgI> _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgI alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
GoTestpkgNode* GoTestpkgNewNode(NSString* name) {
nstring _name = go_seq_from_objc_string(name);
int32_t r0 = proxytestpkg__NewNode(_name);
GoTestpkgNode* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgNode alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
GoTestpkgNullFieldStruct* GoTestpkgNewNullFieldStruct() {
int32_t r0 = proxytestpkg__NewNullFieldStruct();
GoTestpkgNullFieldStruct* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgNullFieldStruct alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
id<GoTestpkgI> GoTestpkgNewNullInterface() {
int32_t r0 = proxytestpkg__NewNullInterface();
id<GoTestpkgI> _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgI alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
GoTestpkgS* GoTestpkgNewNullStruct() {
int32_t r0 = proxytestpkg__NewNullStruct();
GoTestpkgS* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgS alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
GoTestpkgS* GoTestpkgNewS(double x, double y) {
double _x = (double)x;
double _y = (double)y;
int32_t r0 = proxytestpkg__NewS(_x, _y);
GoTestpkgS* _ret0_ = nil;
GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
if (_ret0__ref != NULL) {
_ret0_ = _ret0__ref.obj;
if (_ret0_ == nil) {
_ret0_ = [[GoTestpkgS alloc] initWithRef:_ret0__ref];
}
}
return _ret0_;
}
BOOL GoTestpkgReadIntoByteArray(NSData* s, int* ret0_, NSError** error) {
nbyteslice _s = go_seq_from_objc_bytearray(s, 0);
struct proxytestpkg__ReadIntoByteArray_return res = proxytestpkg__ReadIntoByteArray(_s);
if (![s isKindOfClass:[NSMutableData class]]) {
free(_s.ptr);
}
int _ret0_ = (int)res.r0;
NSString *_error = go_seq_to_objc_string(res.r1);
*ret0_ = _ret0_;
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
void GoTestpkgRegisterI(int32_t idx, id<GoTestpkgI> i) {
int32_t _idx = (int32_t)idx;
int32_t _i;
if ([(id<NSObject>)(i) isKindOfClass:[GoTestpkgI class]]) {
id<goSeqRefInterface> i_proxy = (id<goSeqRefInterface>)(i);
_i = go_seq_go_to_refnum(i_proxy._ref);
} else {
_i = go_seq_to_refnum(i);
}
proxytestpkg__RegisterI(_idx, _i);
}
BOOL GoTestpkgReturnsError(BOOL b, NSString** ret0_, NSError** error) {
char _b = (char)b;
struct proxytestpkg__ReturnsError_return res = proxytestpkg__ReturnsError(_b);
NSString *_ret0_ = go_seq_to_objc_string(res.r0);
NSString *_error = go_seq_to_objc_string(res.r1);
*ret0_ = _ret0_;
if ([_error length] != 0 && error != nil) {
NSMutableDictionary* details = [NSMutableDictionary dictionary];
[details setValue:_error forKey:NSLocalizedDescriptionKey];
*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
}
return ([_error length] == 0);
}
NSString* GoTestpkgStringDup(NSString* s) {
nstring _s = go_seq_from_objc_string(s);
nstring r0 = proxytestpkg__StringDup(_s);
NSString *_ret0_ = go_seq_to_objc_string(r0);
return _ret0_;
}
int64_t GoTestpkgSum(int64_t x, int64_t y) {
int64_t _x = (int64_t)x;
int64_t _y = (int64_t)y;
int64_t r0 = proxytestpkg__Sum(_x, _y);
int64_t _ret0_ = (int64_t)r0;
return _ret0_;
}
void GoTestpkgUnregisterI(int32_t idx) {
int32_t _idx = (int32_t)idx;
proxytestpkg__UnregisterI(_idx);
}
nstring cproxytestpkg_I_Error(int32_t refnum, char triggerError) {
id<GoTestpkgI> o = go_seq_objc_from_refnum(refnum);
BOOL _triggerError = triggerError ? YES : NO;
NSError* error = nil;
BOOL returnVal = [o error:_triggerError error:&error];
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
}
}
nstring _error_str = go_seq_from_objc_string(error_str);
return _error_str;
}
struct cproxytestpkg_I_StringError_return cproxytestpkg_I_StringError(int32_t refnum, nstring s) {
id<GoTestpkgI> o = go_seq_objc_from_refnum(refnum);
NSString *_s = go_seq_to_objc_string(s);
NSString* ret0_;
NSError* error = nil;
BOOL returnVal = [o stringError:_s ret0_:&ret0_ error:&error];
nstring _ret0_ = go_seq_from_objc_string(ret0_);
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
}
}
nstring _error_str = go_seq_from_objc_string(error_str);
cproxytestpkg_I_StringError_return _sres = {
_ret0_, _error_str
};
return _sres;
}
int64_t cproxytestpkg_I_Times(int32_t refnum, int32_t v) {
id<GoTestpkgI> o = go_seq_objc_from_refnum(refnum);
int32_t _v = (int32_t)v;
int64_t returnVal = [o times:_v];
int64_t _returnVal = (int64_t)returnVal;
return _returnVal;
}
int32_t cproxytestpkg_NullTest_Null(int32_t refnum) {
id<GoTestpkgNullTest> o = go_seq_objc_from_refnum(refnum);
id<GoTestpkgNullTest> returnVal = [o null];
int32_t _returnVal;
if ([(id<NSObject>)(returnVal) isKindOfClass:[GoTestpkgNullTest class]]) {
id<goSeqRefInterface> returnVal_proxy = (id<goSeqRefInterface>)(returnVal);
_returnVal = go_seq_go_to_refnum(returnVal_proxy._ref);
} else {
_returnVal = go_seq_to_refnum(returnVal);
}
return _returnVal;
}
__attribute__((constructor)) static void init() {
init_seq();
}

View File

@ -1,608 +0,0 @@
// Package gomobile_bind is an autogenerated binder stub for package testpkg.
// gobind -lang=go golang.org/x/mobile/bind/objc/testpkg
//
// File is generated by gobind. Do not edit.
package gomobile_bind
/*
#include <stdlib.h>
#include <stdint.h>
#include "seq.h"
#include "testpkg.h"
*/
import "C"
import (
"golang.org/x/mobile/bind/objc/testpkg"
_seq "golang.org/x/mobile/bind/seq"
)
// suppress the error if seq ends up unused
var _ = _seq.FromRefNum
type proxyNode _seq.Ref
//export proxytestpkg_Node_V_Set
func proxytestpkg_Node_V_Set(refnum C.int32_t, v C.nstring) {
ref := _seq.FromRefNum(int32(refnum))
_v := decodeString(v, false)
ref.Get().(*testpkg.Node).V = _v
}
//export proxytestpkg_Node_V_Get
func proxytestpkg_Node_V_Get(refnum C.int32_t) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.Node).V
_v := encodeString(v, true)
return _v
}
//export proxytestpkg_Node_Err_Set
func proxytestpkg_Node_Err_Set(refnum C.int32_t, v C.nstring) {
ref := _seq.FromRefNum(int32(refnum))
_v_str := decodeString(v, false)
_v := toError(_v_str)
ref.Get().(*testpkg.Node).Err = _v
}
//export proxytestpkg_Node_Err_Get
func proxytestpkg_Node_Err_Get(refnum C.int32_t) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.Node).Err
var _v_str string
if v == nil {
_v_str = ""
} else {
_v_str = v.Error()
}
_v := encodeString(_v_str, true)
return _v
}
type proxyNullFieldStruct _seq.Ref
//export proxytestpkg_NullFieldStruct_F_Set
func proxytestpkg_NullFieldStruct_F_Set(refnum C.int32_t, v C.int32_t) {
ref := _seq.FromRefNum(int32(refnum))
// Must be a Go object
_v_ref := _seq.FromRefNum(int32(v))
_v := _v_ref.Get().(*testpkg.S)
ref.Get().(*testpkg.NullFieldStruct).F = _v
}
//export proxytestpkg_NullFieldStruct_F_Get
func proxytestpkg_NullFieldStruct_F_Get(refnum C.int32_t) C.int32_t {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.NullFieldStruct).F
var _v C.int32_t = _seq.NullRefNum
if v != nil {
_v = C.int32_t(_seq.ToRefNum(v))
}
return _v
}
type proxyS _seq.Ref
//export proxytestpkg_S_X_Set
func proxytestpkg_S_X_Set(refnum C.int32_t, v C.double) {
ref := _seq.FromRefNum(int32(refnum))
_v := float64(v)
ref.Get().(*testpkg.S).X = _v
}
//export proxytestpkg_S_X_Get
func proxytestpkg_S_X_Get(refnum C.int32_t) C.double {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.S).X
_v := C.double(v)
return _v
}
//export proxytestpkg_S_Y_Set
func proxytestpkg_S_Y_Set(refnum C.int32_t, v C.double) {
ref := _seq.FromRefNum(int32(refnum))
_v := float64(v)
ref.Get().(*testpkg.S).Y = _v
}
//export proxytestpkg_S_Y_Get
func proxytestpkg_S_Y_Get(refnum C.int32_t) C.double {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.S).Y
_v := C.double(v)
return _v
}
//export proxytestpkg_S_Sum
func proxytestpkg_S_Sum(refnum C.int32_t) C.double {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.S)
res_0 := v.Sum()
_res_0 := C.double(res_0)
return _res_0
}
//export proxytestpkg_S_TryTwoStrings
func proxytestpkg_S_TryTwoStrings(refnum C.int32_t, param_first C.nstring, param_second C.nstring) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.S)
_param_first := decodeString(param_first, false)
_param_second := decodeString(param_second, false)
res_0 := v.TryTwoStrings(_param_first, _param_second)
_res_0 := encodeString(res_0, true)
return _res_0
}
type proxyStructThatStartsWithLetterBeforeZ _seq.Ref
//export proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Set
func proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Set(refnum C.int32_t, v C.int32_t) {
ref := _seq.FromRefNum(int32(refnum))
var _v testpkg.Z
_v_ref := _seq.FromRefNum(int32(v))
if _v_ref != nil {
if _v_ref.Num < 0 { // go object
_v = _v_ref.Get().(testpkg.Z)
} else { // foreign object
_v = (*proxytestpkg_Z)(_v_ref)
}
}
ref.Get().(*testpkg.StructThatStartsWithLetterBeforeZ).Value = _v
}
//export proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Get
func proxytestpkg_StructThatStartsWithLetterBeforeZ_Value_Get(refnum C.int32_t) C.int32_t {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(*testpkg.StructThatStartsWithLetterBeforeZ).Value
var _v C.int32_t = _seq.NullRefNum
if v != nil {
_v = C.int32_t(_seq.ToRefNum(v))
}
return _v
}
//export proxytestpkg_I_Error
func proxytestpkg_I_Error(refnum C.int32_t, param_triggerError C.char) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(testpkg.I)
_param_triggerError := param_triggerError != 0
res_0 := v.Error(_param_triggerError)
var _res_0_str string
if res_0 == nil {
_res_0_str = ""
} else {
_res_0_str = res_0.Error()
}
_res_0 := encodeString(_res_0_str, true)
return _res_0
}
//export proxytestpkg_I_StringError
func proxytestpkg_I_StringError(refnum C.int32_t, param_s C.nstring) (C.nstring, C.nstring) {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(testpkg.I)
_param_s := decodeString(param_s, false)
res_0, res_1 := v.StringError(_param_s)
_res_0 := encodeString(res_0, true)
var _res_1_str string
if res_1 == nil {
_res_1_str = ""
} else {
_res_1_str = res_1.Error()
}
_res_1 := encodeString(_res_1_str, true)
return _res_0, _res_1
}
//export proxytestpkg_I_Times
func proxytestpkg_I_Times(refnum C.int32_t, param_v C.int32_t) C.int64_t {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(testpkg.I)
_param_v := int32(param_v)
res_0 := v.Times(_param_v)
_res_0 := C.int64_t(res_0)
return _res_0
}
type proxytestpkg_I _seq.Ref
func (p *proxytestpkg_I) Error(param_triggerError bool) error {
var _param_triggerError C.char = 0
if param_triggerError {
_param_triggerError = 1
}
res := C.cproxytestpkg_I_Error(C.int32_t(p.Num), _param_triggerError)
_res_str := decodeString(res, true)
_res := toError(_res_str)
return _res
}
func (p *proxytestpkg_I) StringError(param_s string) (string, error) {
_param_s := encodeString(param_s, false)
res := C.cproxytestpkg_I_StringError(C.int32_t(p.Num), _param_s)
res_0 := decodeString(res.r0, true)
res_1_str := decodeString(res.r1, true)
res_1 := toError(res_1_str)
return res_0, res_1
}
func (p *proxytestpkg_I) Times(param_v int32) int64 {
_param_v := C.int32_t(param_v)
res := C.cproxytestpkg_I_Times(C.int32_t(p.Num), _param_v)
_res := int64(res)
return _res
}
//export proxytestpkg_NullTest_Null
func proxytestpkg_NullTest_Null(refnum C.int32_t) C.int32_t {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(testpkg.NullTest)
res_0 := v.Null()
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
type proxytestpkg_NullTest _seq.Ref
func (p *proxytestpkg_NullTest) Null() testpkg.NullTest {
res := C.cproxytestpkg_NullTest_Null(C.int32_t(p.Num))
var _res testpkg.NullTest
_res_ref := _seq.FromRefNum(int32(res))
if _res_ref != nil {
if _res_ref.Num < 0 { // go object
_res = _res_ref.Get().(testpkg.NullTest)
} else { // foreign object
_res = (*proxytestpkg_NullTest)(_res_ref)
}
}
return _res
}
type proxytestpkg_Z _seq.Ref
//export var_settestpkg_IntVar
func var_settestpkg_IntVar(v C.nint) {
_v := int(v)
testpkg.IntVar = _v
}
//export var_gettestpkg_IntVar
func var_gettestpkg_IntVar() C.nint {
v := testpkg.IntVar
_v := C.nint(v)
return _v
}
//export var_settestpkg_InterfaceVar
func var_settestpkg_InterfaceVar(v C.int32_t) {
var _v testpkg.I
_v_ref := _seq.FromRefNum(int32(v))
if _v_ref != nil {
if _v_ref.Num < 0 { // go object
_v = _v_ref.Get().(testpkg.I)
} else { // foreign object
_v = (*proxytestpkg_I)(_v_ref)
}
}
testpkg.InterfaceVar = _v
}
//export var_gettestpkg_InterfaceVar
func var_gettestpkg_InterfaceVar() C.int32_t {
v := testpkg.InterfaceVar
var _v C.int32_t = _seq.NullRefNum
if v != nil {
_v = C.int32_t(_seq.ToRefNum(v))
}
return _v
}
//export var_settestpkg_StringVar
func var_settestpkg_StringVar(v C.nstring) {
_v := decodeString(v, false)
testpkg.StringVar = _v
}
//export var_gettestpkg_StringVar
func var_gettestpkg_StringVar() C.nstring {
v := testpkg.StringVar
_v := encodeString(v, true)
return _v
}
//export var_settestpkg_StructVar
func var_settestpkg_StructVar(v C.int32_t) {
// Must be a Go object
_v_ref := _seq.FromRefNum(int32(v))
_v := _v_ref.Get().(*testpkg.Node)
testpkg.StructVar = _v
}
//export var_gettestpkg_StructVar
func var_gettestpkg_StructVar() C.int32_t {
v := testpkg.StructVar
var _v C.int32_t = _seq.NullRefNum
if v != nil {
_v = C.int32_t(_seq.ToRefNum(v))
}
return _v
}
//export proxytestpkg__BytesAppend
func proxytestpkg__BytesAppend(param_a C.nbyteslice, param_b C.nbyteslice) C.nbyteslice {
_param_a := toSlice(param_a, false)
_param_b := toSlice(param_b, false)
res_0 := testpkg.BytesAppend(_param_a, _param_b)
_res_0 := fromSlice(res_0, true)
return _res_0
}
//export proxytestpkg__CallIError
func proxytestpkg__CallIError(param_i C.int32_t, param_triggerError C.char) C.nstring {
var _param_i testpkg.I
_param_i_ref := _seq.FromRefNum(int32(param_i))
if _param_i_ref != nil {
if _param_i_ref.Num < 0 { // go object
_param_i = _param_i_ref.Get().(testpkg.I)
} else { // foreign object
_param_i = (*proxytestpkg_I)(_param_i_ref)
}
}
_param_triggerError := param_triggerError != 0
res_0 := testpkg.CallIError(_param_i, _param_triggerError)
var _res_0_str string
if res_0 == nil {
_res_0_str = ""
} else {
_res_0_str = res_0.Error()
}
_res_0 := encodeString(_res_0_str, true)
return _res_0
}
//export proxytestpkg__CallIStringError
func proxytestpkg__CallIStringError(param_i C.int32_t, param_s C.nstring) (C.nstring, C.nstring) {
var _param_i testpkg.I
_param_i_ref := _seq.FromRefNum(int32(param_i))
if _param_i_ref != nil {
if _param_i_ref.Num < 0 { // go object
_param_i = _param_i_ref.Get().(testpkg.I)
} else { // foreign object
_param_i = (*proxytestpkg_I)(_param_i_ref)
}
}
_param_s := decodeString(param_s, false)
res_0, res_1 := testpkg.CallIStringError(_param_i, _param_s)
_res_0 := encodeString(res_0, true)
var _res_1_str string
if res_1 == nil {
_res_1_str = ""
} else {
_res_1_str = res_1.Error()
}
_res_1 := encodeString(_res_1_str, true)
return _res_0, _res_1
}
//export proxytestpkg__CallSSum
func proxytestpkg__CallSSum(param_s C.int32_t) C.double {
// Must be a Go object
_param_s_ref := _seq.FromRefNum(int32(param_s))
_param_s := _param_s_ref.Get().(*testpkg.S)
res_0 := testpkg.CallSSum(_param_s)
_res_0 := C.double(res_0)
return _res_0
}
//export proxytestpkg__CallWithNull
func proxytestpkg__CallWithNull(param_p0 C.int32_t, param_nuller C.int32_t) C.char {
var _param_p0 testpkg.NullTest
_param_p0_ref := _seq.FromRefNum(int32(param_p0))
if _param_p0_ref != nil {
if _param_p0_ref.Num < 0 { // go object
_param_p0 = _param_p0_ref.Get().(testpkg.NullTest)
} else { // foreign object
_param_p0 = (*proxytestpkg_NullTest)(_param_p0_ref)
}
}
var _param_nuller testpkg.NullTest
_param_nuller_ref := _seq.FromRefNum(int32(param_nuller))
if _param_nuller_ref != nil {
if _param_nuller_ref.Num < 0 { // go object
_param_nuller = _param_nuller_ref.Get().(testpkg.NullTest)
} else { // foreign object
_param_nuller = (*proxytestpkg_NullTest)(_param_nuller_ref)
}
}
res_0 := testpkg.CallWithNull(_param_p0, _param_nuller)
var _res_0 C.char = 0
if res_0 {
_res_0 = 1
}
return _res_0
}
//export proxytestpkg__CollectS
func proxytestpkg__CollectS(param_want C.nint, param_timeoutSec C.nint) C.nint {
_param_want := int(param_want)
_param_timeoutSec := int(param_timeoutSec)
res_0 := testpkg.CollectS(_param_want, _param_timeoutSec)
_res_0 := C.nint(res_0)
return _res_0
}
//export proxytestpkg__Echo
func proxytestpkg__Echo(param_s C.nstring) C.nstring {
_param_s := decodeString(param_s, false)
res_0 := testpkg.Echo(_param_s)
_res_0 := encodeString(res_0, true)
return _res_0
}
//export proxytestpkg__GC
func proxytestpkg__GC() {
testpkg.GC()
}
//export proxytestpkg__Hello
func proxytestpkg__Hello(param_s C.nstring) C.nstring {
_param_s := decodeString(param_s, false)
res_0 := testpkg.Hello(_param_s)
_res_0 := encodeString(res_0, true)
return _res_0
}
//export proxytestpkg__Hi
func proxytestpkg__Hi() {
testpkg.Hi()
}
//export proxytestpkg__Int
func proxytestpkg__Int(param_x C.int32_t) {
_param_x := int32(param_x)
testpkg.Int(_param_x)
}
//export proxytestpkg__Multiply
func proxytestpkg__Multiply(param_idx C.int32_t, param_val C.int32_t) C.int64_t {
_param_idx := int32(param_idx)
_param_val := int32(param_val)
res_0 := testpkg.Multiply(_param_idx, _param_val)
_res_0 := C.int64_t(res_0)
return _res_0
}
//export proxytestpkg__NewI
func proxytestpkg__NewI() C.int32_t {
res_0 := testpkg.NewI()
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__NewNode
func proxytestpkg__NewNode(param_name C.nstring) C.int32_t {
_param_name := decodeString(param_name, false)
res_0 := testpkg.NewNode(_param_name)
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__NewNullFieldStruct
func proxytestpkg__NewNullFieldStruct() C.int32_t {
res_0 := testpkg.NewNullFieldStruct()
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__NewNullInterface
func proxytestpkg__NewNullInterface() C.int32_t {
res_0 := testpkg.NewNullInterface()
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__NewNullStruct
func proxytestpkg__NewNullStruct() C.int32_t {
res_0 := testpkg.NewNullStruct()
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__NewS
func proxytestpkg__NewS(param_x C.double, param_y C.double) C.int32_t {
_param_x := float64(param_x)
_param_y := float64(param_y)
res_0 := testpkg.NewS(_param_x, _param_y)
var _res_0 C.int32_t = _seq.NullRefNum
if res_0 != nil {
_res_0 = C.int32_t(_seq.ToRefNum(res_0))
}
return _res_0
}
//export proxytestpkg__ReadIntoByteArray
func proxytestpkg__ReadIntoByteArray(param_s C.nbyteslice) (C.nint, C.nstring) {
_param_s := toSlice(param_s, false)
res_0, res_1 := testpkg.ReadIntoByteArray(_param_s)
_res_0 := C.nint(res_0)
var _res_1_str string
if res_1 == nil {
_res_1_str = ""
} else {
_res_1_str = res_1.Error()
}
_res_1 := encodeString(_res_1_str, true)
return _res_0, _res_1
}
//export proxytestpkg__RegisterI
func proxytestpkg__RegisterI(param_idx C.int32_t, param_i C.int32_t) {
_param_idx := int32(param_idx)
var _param_i testpkg.I
_param_i_ref := _seq.FromRefNum(int32(param_i))
if _param_i_ref != nil {
if _param_i_ref.Num < 0 { // go object
_param_i = _param_i_ref.Get().(testpkg.I)
} else { // foreign object
_param_i = (*proxytestpkg_I)(_param_i_ref)
}
}
testpkg.RegisterI(_param_idx, _param_i)
}
//export proxytestpkg__ReturnsError
func proxytestpkg__ReturnsError(param_b C.char) (C.nstring, C.nstring) {
_param_b := param_b != 0
res_0, res_1 := testpkg.ReturnsError(_param_b)
_res_0 := encodeString(res_0, true)
var _res_1_str string
if res_1 == nil {
_res_1_str = ""
} else {
_res_1_str = res_1.Error()
}
_res_1 := encodeString(_res_1_str, true)
return _res_0, _res_1
}
//export proxytestpkg__StringDup
func proxytestpkg__StringDup(param_s C.nstring) C.nstring {
_param_s := decodeString(param_s, false)
res_0 := testpkg.StringDup(_param_s)
_res_0 := encodeString(res_0, true)
return _res_0
}
//export proxytestpkg__Sum
func proxytestpkg__Sum(param_x C.int64_t, param_y C.int64_t) C.int64_t {
_param_x := int64(param_x)
_param_y := int64(param_y)
res_0 := testpkg.Sum(_param_x, _param_y)
_res_0 := C.int64_t(res_0)
return _res_0
}
//export proxytestpkg__UnregisterI
func proxytestpkg__UnregisterI(param_idx C.int32_t) {
_param_idx := int32(param_idx)
testpkg.UnregisterI(_param_idx)
}

View File

@ -1,23 +0,0 @@
// Objective-C API for talking to golang.org/x/mobile/bind/objc/testpkg Go package.
// gobind -lang=objc golang.org/x/mobile/bind/objc/testpkg
//
// File is generated by gobind. Do not edit.
#ifndef __testpkg_H__
#define __testpkg_H__
#include <stdint.h>
#include <objc/objc.h>
nstring cproxytestpkg_I_Error(int32_t refnum, char triggerError);
typedef struct cproxytestpkg_I_StringError_return {
nstring r0;
nstring r1;
} cproxytestpkg_I_StringError_return;
struct cproxytestpkg_I_StringError_return cproxytestpkg_I_StringError(int32_t refnum, nstring s);
int64_t cproxytestpkg_I_Times(int32_t refnum, int32_t v);
int32_t cproxytestpkg_NullTest_Null(int32_t refnum);
#endif

View File

@ -0,0 +1,295 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
641ECD4C1C8C20D000971615 /* SeqTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 641ECD4B1C8C20D000971615 /* SeqTest.m */; };
641ECD551C8C380400971615 /* Testpkg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 641ECD4D1C8C20FD00971615 /* Testpkg.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
641ECD3D1C8C20BB00971615 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 641ECD1B1C8C20BB00971615 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 641ECD221C8C20BB00971615;
remoteInfo = xcodetest;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
641ECD371C8C20BB00971615 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
641ECD421C8C20BB00971615 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
641ECD4B1C8C20D000971615 /* SeqTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SeqTest.m; path = ../../SeqTest.m; sourceTree = "<group>"; };
641ECD4D1C8C20FD00971615 /* Testpkg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Testpkg.framework; sourceTree = SOURCE_ROOT; };
641ECD4F1C8C356C00971615 /* xcodetestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = xcodetestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
641ECD391C8C20BB00971615 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
641ECD551C8C380400971615 /* Testpkg.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
641ECD1A1C8C20BB00971615 = {
isa = PBXGroup;
children = (
641ECD251C8C20BB00971615 /* xcodetest */,
641ECD3F1C8C20BB00971615 /* xcodetestTests */,
641ECD501C8C356C00971615 /* Products */,
);
sourceTree = "<group>";
};
641ECD251C8C20BB00971615 /* xcodetest */ = {
isa = PBXGroup;
children = (
641ECD371C8C20BB00971615 /* Info.plist */,
);
path = xcodetest;
sourceTree = "<group>";
};
641ECD3F1C8C20BB00971615 /* xcodetestTests */ = {
isa = PBXGroup;
children = (
641ECD4D1C8C20FD00971615 /* Testpkg.framework */,
641ECD4B1C8C20D000971615 /* SeqTest.m */,
641ECD421C8C20BB00971615 /* Info.plist */,
);
path = xcodetestTests;
sourceTree = "<group>";
};
641ECD501C8C356C00971615 /* Products */ = {
isa = PBXGroup;
children = (
641ECD4F1C8C356C00971615 /* xcodetestTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
641ECD3B1C8C20BB00971615 /* xcodetestTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 641ECD481C8C20BB00971615 /* Build configuration list for PBXNativeTarget "xcodetestTests" */;
buildPhases = (
641ECD391C8C20BB00971615 /* Frameworks */,
641ECD381C8C20BB00971615 /* Sources */,
641ECD3A1C8C20BB00971615 /* Resources */,
);
buildRules = (
);
dependencies = (
641ECD3E1C8C20BB00971615 /* PBXTargetDependency */,
);
name = xcodetestTests;
productName = xcodetestTests;
productReference = 641ECD4F1C8C356C00971615 /* xcodetestTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
641ECD1B1C8C20BB00971615 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = golang.org;
TargetAttributes = {
641ECD3B1C8C20BB00971615 = {
CreatedOnToolsVersion = 7.2.1;
TestTargetID = 641ECD221C8C20BB00971615;
};
};
};
buildConfigurationList = 641ECD1E1C8C20BB00971615 /* Build configuration list for PBXProject "xcodetest" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 641ECD1A1C8C20BB00971615;
productRefGroup = 641ECD501C8C356C00971615 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
641ECD3B1C8C20BB00971615 /* xcodetestTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
641ECD3A1C8C20BB00971615 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
641ECD381C8C20BB00971615 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
641ECD4C1C8C20D000971615 /* SeqTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
641ECD3E1C8C20BB00971615 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
targetProxy = 641ECD3D1C8C20BB00971615 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
641ECD431C8C20BB00971615 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
641ECD441C8C20BB00971615 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
641ECD511C8C362D00971615 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = xcodetestTests;
};
name = Debug;
};
641ECD521C8C362D00971615 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
PRODUCT_NAME = xcodetestTests;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
641ECD1E1C8C20BB00971615 /* Build configuration list for PBXProject "xcodetest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
641ECD431C8C20BB00971615 /* Debug */,
641ECD441C8C20BB00971615 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
641ECD481C8C20BB00971615 /* Build configuration list for PBXNativeTarget "xcodetestTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
641ECD511C8C362D00971615 /* Debug */,
641ECD521C8C362D00971615 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 641ECD1B1C8C20BB00971615 /* Project object */;
}

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641ECD221C8C20BB00971615"
BuildableName = "xcodetest.app"
BlueprintName = "xcodetest"
ReferencedContainer = "container:xcodetest.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641ECD3B1C8C20BB00971615"
BuildableName = "xcodetestTests.xctest"
BlueprintName = "xcodetestTests"
ReferencedContainer = "container:xcodetest.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641ECD221C8C20BB00971615"
BuildableName = "xcodetest.app"
BlueprintName = "xcodetest"
ReferencedContainer = "container:xcodetest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641ECD221C8C20BB00971615"
BuildableName = "xcodetest.app"
BlueprintName = "xcodetest"
ReferencedContainer = "container:xcodetest.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641ECD221C8C20BB00971615"
BuildableName = "xcodetest.app"
BlueprintName = "xcodetest"
ReferencedContainer = "container:xcodetest.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -221,54 +221,66 @@ id<GoInterfacesI> GoInterfacesSeven() {
}
nstring cproxyinterfaces_Error_Err(int32_t refnum) {
id<GoInterfacesError> o = go_seq_objc_from_refnum(refnum);
NSError* error = nil;
BOOL returnVal = [o err:&error];
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
@autoreleasepool {
id<GoInterfacesError> o = go_seq_objc_from_refnum(refnum);
NSError* error = nil;
BOOL returnVal = [o err:&error];
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
}
}
nstring _error_str = go_seq_from_objc_string(error_str);
return _error_str;
}
nstring _error_str = go_seq_from_objc_string(error_str);
return _error_str;
}
int32_t cproxyinterfaces_I_Rand(int32_t refnum) {
id<GoInterfacesI> o = go_seq_objc_from_refnum(refnum);
int32_t returnVal = [o rand];
int32_t _returnVal = (int32_t)returnVal;
return _returnVal;
@autoreleasepool {
id<GoInterfacesI> o = go_seq_objc_from_refnum(refnum);
int32_t returnVal = [o rand];
int32_t _returnVal = (int32_t)returnVal;
return _returnVal;
}
}
void cproxyinterfaces_I1_J(int32_t refnum) {
GoInterfacesI1* o = go_seq_objc_from_refnum(refnum);
[o j];
@autoreleasepool {
GoInterfacesI1* o = go_seq_objc_from_refnum(refnum);
[o j];
}
}
void cproxyinterfaces_I2_G(int32_t refnum) {
GoInterfacesI2* o = go_seq_objc_from_refnum(refnum);
[o g];
@autoreleasepool {
GoInterfacesI2* o = go_seq_objc_from_refnum(refnum);
[o g];
}
}
int32_t cproxyinterfaces_I3_F(int32_t refnum) {
id<GoInterfacesI3> o = go_seq_objc_from_refnum(refnum);
GoInterfacesI1* returnVal = [o f];
int32_t _returnVal;
if ([(id<NSObject>)(returnVal) isKindOfClass:[GoInterfacesI1 class]]) {
id<goSeqRefInterface> returnVal_proxy = (id<goSeqRefInterface>)(returnVal);
_returnVal = go_seq_go_to_refnum(returnVal_proxy._ref);
} else {
_returnVal = go_seq_to_refnum(returnVal);
@autoreleasepool {
id<GoInterfacesI3> o = go_seq_objc_from_refnum(refnum);
GoInterfacesI1* returnVal = [o f];
int32_t _returnVal;
if ([(id<NSObject>)(returnVal) isKindOfClass:[GoInterfacesI1 class]]) {
id<goSeqRefInterface> returnVal_proxy = (id<goSeqRefInterface>)(returnVal);
_returnVal = go_seq_go_to_refnum(returnVal_proxy._ref);
} else {
_returnVal = go_seq_to_refnum(returnVal);
}
return _returnVal;
}
return _returnVal;
}
void cproxyinterfaces_WithParam_HasParam(int32_t refnum, char p0) {
id<GoInterfacesWithParam> o = go_seq_objc_from_refnum(refnum);
BOOL _p0 = p0 ? YES : NO;
[o hasParam:_p0];
@autoreleasepool {
id<GoInterfacesWithParam> o = go_seq_objc_from_refnum(refnum);
BOOL _p0 = p0 ? YES : NO;
[o hasParam:_p0];
}
}
__attribute__((constructor)) static void init() {

View File

@ -84,24 +84,28 @@ static NSString* errDomain = @"go.issue10788";
void cproxyissue10788_TestInterface_DoSomeWork(int32_t refnum, int32_t s) {
id<GoIssue10788TestInterface> o = go_seq_objc_from_refnum(refnum);
GoIssue10788TestStruct* _s = nil;
GoSeqRef* _s_ref = go_seq_from_refnum(s);
if (_s_ref != NULL) {
_s = _s_ref.obj;
if (_s == nil) {
_s = [[GoIssue10788TestStruct alloc] initWithRef:_s_ref];
@autoreleasepool {
id<GoIssue10788TestInterface> o = go_seq_objc_from_refnum(refnum);
GoIssue10788TestStruct* _s = nil;
GoSeqRef* _s_ref = go_seq_from_refnum(s);
if (_s_ref != NULL) {
_s = _s_ref.obj;
if (_s == nil) {
_s = [[GoIssue10788TestStruct alloc] initWithRef:_s_ref];
}
}
[o doSomeWork:_s];
}
[o doSomeWork:_s];
}
void cproxyissue10788_TestInterface_MultipleUnnamedParams(int32_t refnum, nint p0, nstring p1, int64_t p2) {
id<GoIssue10788TestInterface> o = go_seq_objc_from_refnum(refnum);
int _p0 = (int)p0;
NSString *_p1 = go_seq_to_objc_string(p1);
int64_t _p2 = (int64_t)p2;
[o multipleUnnamedParams:_p0 p1:_p1 p2:_p2];
@autoreleasepool {
id<GoIssue10788TestInterface> o = go_seq_objc_from_refnum(refnum);
int _p0 = (int)p0;
NSString *_p1 = go_seq_to_objc_string(p1);
int64_t _p2 = (int64_t)p2;
[o multipleUnnamedParams:_p0 p1:_p1 p2:_p2];
}
}
__attribute__((constructor)) static void init() {

View File

@ -61,31 +61,35 @@ static NSString* errDomain = @"go.issue12403";
nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
NSString *_jstr = go_seq_to_objc_string(jstr);
NSString* returnVal = [o fromJSON:_jstr];
nstring _returnVal = go_seq_from_objc_string(returnVal);
return _returnVal;
@autoreleasepool {
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
NSString *_jstr = go_seq_to_objc_string(jstr);
NSString* returnVal = [o fromJSON:_jstr];
nstring _returnVal = go_seq_from_objc_string(returnVal);
return _returnVal;
}
}
struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
NSString* ret0_;
NSError* error = nil;
BOOL returnVal = [o toJSON:&ret0_ error:&error];
nstring _ret0_ = go_seq_from_objc_string(ret0_);
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
@autoreleasepool {
id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
NSString* ret0_;
NSError* error = nil;
BOOL returnVal = [o toJSON:&ret0_ error:&error];
nstring _ret0_ = go_seq_from_objc_string(ret0_);
NSString *error_str = nil;
if (!returnVal) {
error_str = [error localizedDescription];
if (error_str == nil || error_str.length == 0) {
error_str = @"gobind: unknown error";
}
}
nstring _error_str = go_seq_from_objc_string(error_str);
cproxyissue12403_Parsable_ToJSON_return _sres = {
_ret0_, _error_str
};
return _sres;
}
nstring _error_str = go_seq_from_objc_string(error_str);
cproxyissue12403_Parsable_ToJSON_return _sres = {
_ret0_, _error_str
};
return _sres;
}
__attribute__((constructor)) static void init() {

View File

@ -173,8 +173,10 @@ BOOL GoStructsIdentityWithError(GoStructsS* s, GoStructsS** ret0_, NSError** err
}
void cproxystructs_I_M(int32_t refnum) {
id<GoStructsI> o = go_seq_objc_from_refnum(refnum);
[o m];
@autoreleasepool {
id<GoStructsI> o = go_seq_objc_from_refnum(refnum);
[o m];
}
}
__attribute__((constructor)) static void init() {