From a94f0dcfd547de3e3fe0f7af0ad1d727571880d0 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Jun 2021 16:11:19 +0200 Subject: [PATCH] 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) --- extern/exception.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extern/exception.m b/extern/exception.m index 700439e..52b47e3 100644 --- a/extern/exception.m +++ b/extern/exception.m @@ -1,5 +1,6 @@ -#include -#include +// 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; @@ -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; }