@@ -13,16 +13,19 @@ extern {
13
13
context : * mut c_void , error : * mut * mut c_void ) -> c_int ;
14
14
}
15
15
16
+ /// An opaque type representing any Objective-C object thrown as an exception.
17
+ pub enum Exception { }
18
+
16
19
/// Throws an Objective-C exception.
17
20
/// The argument must be a pointer to an Objective-C object.
18
21
///
19
22
/// Unsafe because this unwinds from Objective-C.
20
- pub unsafe fn throw ( exception : * mut c_void ) -> ! {
21
- RustObjCExceptionThrow ( exception) ;
23
+ pub unsafe fn throw ( exception : * mut Exception ) -> ! {
24
+ RustObjCExceptionThrow ( exception as * mut _ ) ;
22
25
unreachable ! ( ) ;
23
26
}
24
27
25
- unsafe fn try_no_ret < F > ( closure : F ) -> Result < ( ) , * mut c_void >
28
+ unsafe fn try_no_ret < F > ( closure : F ) -> Result < ( ) , * mut Exception >
26
29
where F : FnOnce ( ) {
27
30
extern fn try_objc_execute_closure < F > ( closure : & mut Option < F > )
28
31
where F : FnOnce ( ) {
@@ -42,7 +45,7 @@ unsafe fn try_no_ret<F>(closure: F) -> Result<(), *mut c_void>
42
45
if success == 0 {
43
46
Ok ( ( ) )
44
47
} else {
45
- Err ( exception)
48
+ Err ( exception as * mut _ )
46
49
}
47
50
}
48
51
@@ -55,7 +58,7 @@ unsafe fn try_no_ret<F>(closure: F) -> Result<(), *mut c_void>
55
58
///
56
59
/// Unsafe because this encourages unwinding through the closure from
57
60
/// Objective-C, which is not safe.
58
- pub unsafe fn try < F , R > ( closure : F ) -> Result < R , * mut c_void >
61
+ pub unsafe fn try < F , R > ( closure : F ) -> Result < R , * mut Exception >
59
62
where F : FnOnce ( ) -> R {
60
63
let mut value = None ;
61
64
let result = {
0 commit comments