Gobind uses strings for passing errors across the language barrier. However, since Gobind doesn't have a concept of a nil string, it can't separate an empty native string from a nil string. In turn, that means that empty errors, exceptions or NSError * with an empty description are treated as no error. With ObjC, empty errors are replaced with a default string to workaround the issue, while with Java empty errors are silently ignored. Fix this by replacing strings with actual error objects, wrapping the Go error, Java Throwable or ObjC NSError *, and letting the existing bind machinery take care of passing the references across. It's a large change for a small corner case, but I believe objects are a better fit for exception that strings. Error objects also naturally leads to future additions, for example accessing the exception class name or chained exception. Change-Id: Ie03b47cafcb231ad1e12a80195693fa7459c6265 Reviewed-on: https://go-review.googlesource.com/24100 Reviewed-by: David Crawshaw <crawshaw@golang.org>
136 lines
2.5 KiB
Plaintext
136 lines
2.5 KiB
Plaintext
// Objective-C API for talking to interfaces Go package.
|
|
// gobind -lang=objc interfaces
|
|
//
|
|
// File is generated by gobind. Do not edit.
|
|
|
|
#ifndef __GoInterfaces_H__
|
|
#define __GoInterfaces_H__
|
|
|
|
#include <Foundation/Foundation.h>
|
|
#include "GoUniverse.h"
|
|
|
|
@protocol GoInterfacesError;
|
|
@class GoInterfacesError;
|
|
@protocol GoInterfacesI;
|
|
@class GoInterfacesI;
|
|
@protocol GoInterfacesI1;
|
|
@protocol GoInterfacesI2;
|
|
@protocol GoInterfacesI3;
|
|
@class GoInterfacesI3;
|
|
@protocol GoInterfacesLargerI;
|
|
@class GoInterfacesLargerI;
|
|
@protocol GoInterfacesSameI;
|
|
@class GoInterfacesSameI;
|
|
@protocol GoInterfacesWithParam;
|
|
@class GoInterfacesWithParam;
|
|
|
|
@protocol GoInterfacesError
|
|
- (BOOL)err:(NSError**)error;
|
|
@end
|
|
|
|
@protocol GoInterfacesI
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@interface GoInterfacesI1 : NSObject {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (void)j;
|
|
@end
|
|
|
|
@interface GoInterfacesI2 : NSObject {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (void)g;
|
|
@end
|
|
|
|
@protocol GoInterfacesI3
|
|
- (GoInterfacesI1*)f;
|
|
@end
|
|
|
|
@protocol GoInterfacesLargerI
|
|
- (void)anotherFunc;
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@protocol GoInterfacesSameI
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@protocol GoInterfacesWithParam
|
|
- (void)hasParam:(BOOL)p0;
|
|
@end
|
|
|
|
FOUNDATION_EXPORT int32_t GoInterfacesAdd3(id<GoInterfacesI> r);
|
|
|
|
FOUNDATION_EXPORT BOOL GoInterfacesCallErr(id<GoInterfacesError> e, NSError** error);
|
|
|
|
FOUNDATION_EXPORT id<GoInterfacesI> GoInterfacesSeven();
|
|
|
|
@class GoInterfacesError;
|
|
|
|
@class GoInterfacesI;
|
|
|
|
@class GoInterfacesI3;
|
|
|
|
@class GoInterfacesLargerI;
|
|
|
|
@class GoInterfacesSameI;
|
|
|
|
@class GoInterfacesWithParam;
|
|
|
|
@interface GoInterfacesError : NSObject <GoInterfacesError> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (BOOL)err:(NSError**)error;
|
|
@end
|
|
|
|
@interface GoInterfacesI : NSObject <GoInterfacesI> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@interface GoInterfacesI3 : NSObject <GoInterfacesI3> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (GoInterfacesI1*)f;
|
|
@end
|
|
|
|
@interface GoInterfacesLargerI : NSObject <GoInterfacesLargerI> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (void)anotherFunc;
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@interface GoInterfacesSameI : NSObject <GoInterfacesSameI> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (int32_t)rand;
|
|
@end
|
|
|
|
@interface GoInterfacesWithParam : NSObject <GoInterfacesWithParam> {
|
|
}
|
|
@property(strong, readonly) id _ref;
|
|
|
|
- (id)initWithRef:(id)ref;
|
|
- (void)hasParam:(BOOL)p0;
|
|
@end
|
|
|
|
#endif
|