Skip to content

Commit a94f0dc

Browse files
committed
Don't include objc headers in exception.m
To fix cross compile issues (and also, it's faster to call objc_retain directly instead of using a selector)
1 parent c86ad3a commit a94f0dc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

extern/exception.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#include <objc/objc.h>
2-
#include <objc/NSObject.h>
1+
// Always available in Objective-C
2+
// See https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain
3+
id objc_retain(id value);
34

45
void RustObjCExceptionThrow(id exception) {
56
@throw exception;
@@ -9,12 +10,12 @@ int RustObjCExceptionTryCatch(void (*try)(void *), void *context, id *error) {
910
@try {
1011
try(context);
1112
if (error) {
12-
*error = nil;
13+
*error = (id)0; // nil
1314
}
1415
return 0;
1516
} @catch (id exception) {
1617
if (error) {
17-
*error = [exception retain];
18+
*error = objc_retain(exception);
1819
}
1920
return 1;
2021
}

0 commit comments

Comments
 (0)