diff options
-rw-r--r-- | src/ir/function.rs | 4 | ||||
-rw-r--r-- | tests/expectations/tests/objc_property_fnptr.rs | 35 | ||||
-rw-r--r-- | tests/headers/objc_property_fnptr.h | 8 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/ir/function.rs b/src/ir/function.rs index 23503b05..01689734 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -284,7 +284,9 @@ impl FunctionSig { let ty_ret_type = if cursor.kind() == CXCursor_ObjCInstanceMethodDecl || cursor.kind() == CXCursor_ObjCClassMethodDecl { - try!(cursor.ret_type().ok_or(ParseError::Continue)) + try!(ty.ret_type() + .or_else(|| cursor.ret_type()) + .ok_or(ParseError::Continue)) } else { try!(ty.ret_type().ok_or(ParseError::Continue)) }; diff --git a/tests/expectations/tests/objc_property_fnptr.rs b/tests/expectations/tests/objc_property_fnptr.rs new file mode 100644 index 00000000..044f25d1 --- /dev/null +++ b/tests/expectations/tests/objc_property_fnptr.rs @@ -0,0 +1,35 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + +#![cfg(target_os="macos")] + +#[macro_use] +extern crate objc; +#[allow(non_camel_case_types)] +pub type id = *mut objc::runtime::Object; +pub trait Foo { + unsafe fn func(self) + -> ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>; + unsafe fn setFunc_(self, + func: + ::std::option::Option<unsafe extern "C" fn() + -> + ::std::os::raw::c_int>); +} +impl Foo for id { + unsafe fn func(self) + -> + ::std::option::Option<unsafe extern "C" fn() + -> ::std::os::raw::c_int> { + msg_send!(self , func) + } + unsafe fn setFunc_(self, + func: + ::std::option::Option<unsafe extern "C" fn() + -> + ::std::os::raw::c_int>) { + msg_send!(self , setFunc:func ) + } +} diff --git a/tests/headers/objc_property_fnptr.h b/tests/headers/objc_property_fnptr.h new file mode 100644 index 00000000..8312ba4a --- /dev/null +++ b/tests/headers/objc_property_fnptr.h @@ -0,0 +1,8 @@ +// bindgen-flags: --objc-extern-crate -- -x objective-c +// bindgen-osx-only + +@interface Foo +// FIXME: We are not generating valid code for this +// but at least we should not die +@property int (*func)(char, short, float); +@end |