Skip to content

Commit

Permalink
Don't include objc headers in exception.m
Browse files Browse the repository at this point in the history
To fix cross compile issues (and also, it's faster to call objc_retain directly instead of using a selector)
  • Loading branch information
madsmtm committed Jun 1, 2021
1 parent c86ad3a commit a94f0dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions extern/exception.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <objc/objc.h>
#include <objc/NSObject.h>
// Always available in Objective-C
// See https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain
id objc_retain(id value);

void RustObjCExceptionThrow(id exception) {
@throw exception;
Expand All @@ -9,12 +10,12 @@ int RustObjCExceptionTryCatch(void (*try)(void *), void *context, id *error) {
@try {
try(context);
if (error) {
*error = nil;
*error = (id)0; // nil
}
return 0;
} @catch (id exception) {
if (error) {
*error = [exception retain];
*error = objc_retain(exception);
}
return 1;
}
Expand Down

0 comments on commit a94f0dc

Please sign in to comment.