summaryrefslogtreecommitdiffstats
path: root/third_party/rust/objc_exception/extern
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/objc_exception/extern')
-rw-r--r--third_party/rust/objc_exception/extern/exception.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/third_party/rust/objc_exception/extern/exception.m b/third_party/rust/objc_exception/extern/exception.m
new file mode 100644
index 0000000000..700439ecf7
--- /dev/null
+++ b/third_party/rust/objc_exception/extern/exception.m
@@ -0,0 +1,21 @@
+#include <objc/objc.h>
+#include <objc/NSObject.h>
+
+void RustObjCExceptionThrow(id exception) {
+ @throw exception;
+}
+
+int RustObjCExceptionTryCatch(void (*try)(void *), void *context, id *error) {
+ @try {
+ try(context);
+ if (error) {
+ *error = nil;
+ }
+ return 0;
+ } @catch (id exception) {
+ if (error) {
+ *error = [exception retain];
+ }
+ return 1;
+ }
+}