Always specify function ABI
This commit is contained in:
parent
db4f2c0720
commit
56f748910e
|
@ -360,7 +360,7 @@ pub(crate) fn register_view_class() -> *const Class {
|
|||
let superclass = class!(NSView);
|
||||
let mut decl = ClassDecl::new("RSTView", superclass).unwrap();
|
||||
|
||||
decl.add_method(sel!(isFlipped), enforce_normalcy as extern fn(&Object, _) -> BOOL);
|
||||
decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL);
|
||||
|
||||
decl.add_ivar::<id>(BACKGROUND_COLOR);
|
||||
|
||||
|
@ -384,12 +384,12 @@ pub(crate) fn register_view_class_with_delegate<T: ViewDelegate>(instance: &T) -
|
|||
|
||||
decl.add_method(
|
||||
sel!(isFlipped),
|
||||
enforce_normalcy as extern fn(&Object, _) -> BOOL
|
||||
enforce_normalcy as extern "C" fn(&Object, _) -> BOOL
|
||||
);
|
||||
|
||||
decl.add_method(
|
||||
sel!(draggingEntered:),
|
||||
dragging_entered::<T> as extern fn (&mut Object, _, _) -> NSUInteger
|
||||
dragging_entered::<T> as extern "C" fn (&mut Object, _, _) -> NSUInteger
|
||||
);
|
||||
})
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ to the Rust `ViewDelegate` implementation.
|
|||
The methods we're setting up can range from simple to complex - take `isFlipped`:
|
||||
|
||||
``` rust
|
||||
extern fn is_flipped(_: &Object, _: Sel) -> BOOL {
|
||||
extern "C" fn is_flipped(_: &Object, _: Sel) -> BOOL {
|
||||
return YES;
|
||||
}
|
||||
```
|
||||
|
@ -409,7 +409,7 @@ extern fn is_flipped(_: &Object, _: Sel) -> BOOL {
|
|||
Here, we just want to tell `NSView` to use top,left as the origin point, so we need to respond `YES` in this subclass method.
|
||||
|
||||
``` rust
|
||||
extern fn dragging_entered<T: ViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
||||
extern "C" fn dragging_entered<T: ViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
||||
let view = utils::load::<T>(this, VIEW_DELEGATE_PTR);
|
||||
view.dragging_entered(DragInfo {
|
||||
info: unsafe { Id::from_ptr(info) }
|
||||
|
|
|
@ -49,15 +49,15 @@ macro_rules! method_decl_impl {
|
|||
}
|
||||
);
|
||||
($($t:ident),*) => (
|
||||
method_decl_impl!(-T, R, extern fn(&T, Sel $(, $t)*) -> R, $($t),*);
|
||||
method_decl_impl!(-T, R, extern fn(&mut T, Sel $(, $t)*) -> R, $($t),*);
|
||||
method_decl_impl!(-T, R, extern "C" fn(&T, Sel $(, $t)*) -> R, $($t),*);
|
||||
method_decl_impl!(-T, R, extern "C" fn(&mut T, Sel $(, $t)*) -> R, $($t),*);
|
||||
);
|
||||
}
|
||||
|
||||
method_decl_impl!();
|
||||
method_decl_impl!(A);
|
||||
|
||||
extern fn get_bundle_id(this: &Object, s: Sel, v: id) -> id {
|
||||
extern "C" fn get_bundle_id(this: &Object, s: Sel, v: id) -> id {
|
||||
unsafe {
|
||||
let bundle = class!(NSBundle);
|
||||
let main_bundle: id = msg_send![bundle, mainBundle];
|
||||
|
@ -95,6 +95,6 @@ unsafe fn swizzle_bundle_id<F>(bundle_id: &str, func: F) where F: MethodImplemen
|
|||
|
||||
pub fn set_bundle_id(bundle_id: &str) {
|
||||
unsafe {
|
||||
swizzle_bundle_id(bundle_id, get_bundle_id as extern fn(&Object, _, _) -> id);
|
||||
swizzle_bundle_id(bundle_id, get_bundle_id as extern "C" fn(&Object, _, _) -> id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ pub(crate) fn register_image_view_class() -> *const Class {
|
|||
let superclass = class!(NSImageView);
|
||||
let decl = ClassDecl::new("RSTImageView", superclass).unwrap();
|
||||
|
||||
//decl.add_method(sel!(isFlipped), enforce_normalcy as extern fn(&Object, _) -> BOOL);
|
||||
//decl.add_method(sel!(isFlipped), enforce_normalcy as extern "C" fn(&Object, _) -> BOOL);
|
||||
|
||||
VIEW_CLASS = decl.register();
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ extern "C" fn menu_needs_update<T: ListViewDelegate>(this: &Object, _: Sel, menu
|
|||
/// The other less obvious way is to subclass and override the `shouldSelectRow:` method; here, we
|
||||
/// simply assume things are selectable and call our delegate as if things were selected. This may
|
||||
/// need to change in the future, but it works well enough for now.
|
||||
extern fn select_row<T: ListViewDelegate>(
|
||||
extern "C" fn select_row<T: ListViewDelegate>(
|
||||
this: &Object,
|
||||
_: Sel,
|
||||
_table_view: id,
|
||||
|
|
|
@ -69,7 +69,7 @@ pub(crate) fn register_app_delegate_class<T: AppDelegate>() -> *const Class {
|
|||
);
|
||||
/*decl.add_method(
|
||||
sel!(application:didDiscardSceneSessions:),
|
||||
did_discard_scene_sessions::<T> as extern fn(&Object, _, _, id)
|
||||
did_discard_scene_sessions::<T> as extern "C" fn(&Object, _, _, id)
|
||||
);*/
|
||||
|
||||
DELEGATE_CLASS = decl.register();
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::view::{VIEW_DELEGATE_PTR, ViewDelegate};
|
|||
use crate::utils::{load, as_bool};
|
||||
|
||||
/// Called when the view controller receives a `viewWillAppear:` message.
|
||||
extern fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(UIViewController)), viewWillAppear:animated];
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ extern fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewDidAppear:` message.
|
||||
extern fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(UIViewController)), viewDidAppear:animated];
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ extern fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL)
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewWillDisappear:` message.
|
||||
extern fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(UIViewController)), viewWillDisappear:animated];
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ extern fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: B
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewDidDisappear:` message.
|
||||
extern fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel, animated: BOOL) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(UIViewController)), viewDidDisappear:animated];
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ pub(crate) fn register_view_controller_class<T: ViewDelegate + 'static>() -> *co
|
|||
|
||||
decl.add_ivar::<usize>(VIEW_DELEGATE_PTR);
|
||||
|
||||
decl.add_method(sel!(viewWillAppear:), will_appear::<T> as extern fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewDidAppear:), did_appear::<T> as extern fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewWillDisappear:), will_disappear::<T> as extern fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewDidDisappear:), did_disappear::<T> as extern fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewWillAppear:), will_appear::<T> as extern "C" fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewDidAppear:), did_appear::<T> as extern "C" fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewWillDisappear:), will_disappear::<T> as extern "C" fn(&mut Object, _, BOOL));
|
||||
decl.add_method(sel!(viewDidDisappear:), did_disappear::<T> as extern "C" fn(&mut Object, _, BOOL));
|
||||
|
||||
VIEW_CLASS = decl.register();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::view::{VIEW_DELEGATE_PTR, ViewDelegate};
|
|||
use crate::utils::load;
|
||||
|
||||
/// Called when the view controller receives a `viewWillAppear` message.
|
||||
extern fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
extern "C" fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(NSViewController)), viewWillAppear];
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ extern fn will_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewDidAppear` message.
|
||||
extern fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
extern "C" fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(NSViewController)), viewDidAppear];
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ extern fn did_appear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewWillDisappear` message.
|
||||
extern fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
extern "C" fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(NSViewController)), viewWillDisappear];
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ extern fn will_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
|||
}
|
||||
|
||||
/// Called when the view controller receives a `viewDidDisappear` message.
|
||||
extern fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
extern "C" fn did_disappear<T: ViewDelegate>(this: &mut Object, _: Sel) {
|
||||
unsafe {
|
||||
let _: () = msg_send![super(this, class!(NSViewController)), viewDidDisappear];
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ pub(crate) fn register_view_controller_class<T: ViewDelegate + 'static>(instance
|
|||
load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe {
|
||||
decl.add_ivar::<usize>(VIEW_DELEGATE_PTR);
|
||||
|
||||
decl.add_method(sel!(viewWillAppear), will_appear::<T> as extern fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewDidAppear), did_appear::<T> as extern fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewWillDisappear), will_disappear::<T> as extern fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewDidDisappear), did_disappear::<T> as extern fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewWillAppear), will_appear::<T> as extern "C" fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewDidAppear), did_appear::<T> as extern "C" fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewWillDisappear), will_disappear::<T> as extern "C" fn(&mut Object, _));
|
||||
decl.add_method(sel!(viewDidDisappear), did_disappear::<T> as extern "C" fn(&mut Object, _));
|
||||
})
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ use objc::{class, msg_send, sel, sel_impl};
|
|||
use crate::foundation::{id, nil, YES, NO};
|
||||
use crate::webview::traits::WebViewController;
|
||||
|
||||
extern fn download_delegate(this: &Object, _: Sel) -> id {
|
||||
extern "C" fn download_delegate(this: &Object, _: Sel) -> id {
|
||||
println!("YO!");
|
||||
unsafe {
|
||||
NSString::alloc(nil).init_str("")
|
||||
|
@ -34,7 +34,7 @@ pub fn register_process_pool() -> *const Object {
|
|||
let mut decl = ClassDecl::new("RSTWebViewProcessPool", superclass).unwrap();
|
||||
|
||||
//decl.add_ivar::<id>(DOWNLOAD_DELEGATE_PTR);
|
||||
decl.add_method(sel!(_downloadDelegate), download_delegate as extern fn(&Object, _) -> id);
|
||||
decl.add_method(sel!(_downloadDelegate), download_delegate as extern "C" fn(&Object, _) -> id);
|
||||
|
||||
//PROCESS_POOL = decl.register();
|
||||
PROCESS_POOL = msg_send![decl.register(), new];
|
||||
|
|
Loading…
Reference in a new issue