File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ edition = "2018"
6
6
7
7
description = " Rust interface for Objective-C's throw and try/catch statements."
8
8
keywords = [" objective-c" , " osx" , " ios" ]
9
+ categories = [" development-tools::ffi" , " no-std" ]
9
10
repository = " http://github.com/SSheldon/rust-objc-exception"
10
11
documentation = " http://ssheldon.github.io/rust-objc/objc_exception/"
11
12
license = " MIT"
Original file line number Diff line number Diff line change 2
2
// See https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain
3
3
id objc_retain (id value);
4
4
5
- int RustObjCExceptionTryCatch (void (*try)(void *), void *context, id *error) {
5
+ // We return `unsigned char`, since it is guaranteed to be an `u8` on all platforms
6
+ unsigned char RustObjCExceptionTryCatch (void (*try)(void *), void *context, id *error) {
6
7
@try {
7
8
try (context);
8
9
if (error) {
Original file line number Diff line number Diff line change 1
1
//! Rust interface for Objective-C's `@throw` and `@try`/`@catch` statements.
2
2
3
- use std:: mem;
4
- use std:: os:: raw:: { c_int, c_void} ;
5
- use std:: ptr;
3
+ #![ no_std]
4
+
5
+ #[ cfg( test) ]
6
+ extern crate alloc;
7
+
8
+ use core:: ffi:: c_void;
9
+ use core:: mem;
10
+ use core:: ptr;
6
11
7
12
#[ link( name = "objc" , kind = "dylib" ) ]
8
13
// TODO: "C-unwind"
@@ -20,7 +25,7 @@ extern "C" {
20
25
r#try : extern "C" fn ( * mut c_void ) ,
21
26
context : * mut c_void ,
22
27
error : * mut * mut c_void ,
23
- ) -> c_int ;
28
+ ) -> u8 ; // std::os::raw::c_uchar
24
29
}
25
30
26
31
/// An opaque type representing any Objective-C object thrown as an exception.
@@ -100,8 +105,10 @@ where
100
105
101
106
#[ cfg( test) ]
102
107
mod tests {
108
+ use alloc:: string:: ToString ;
109
+ use core:: ptr;
110
+
103
111
use super :: { r#try, throw} ;
104
- use std:: ptr;
105
112
106
113
#[ test]
107
114
fn test_try ( ) {
You can’t perform that action at this time.
0 commit comments