diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 22a1b09..ee3b68a 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -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::(BACKGROUND_COLOR); @@ -384,12 +384,12 @@ pub(crate) fn register_view_class_with_delegate(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:: as extern fn (&mut Object, _, _) -> NSUInteger + dragging_entered:: 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(this: &mut Object, _: Sel, info: id) -> NSUInteger { +extern "C" fn dragging_entered(this: &mut Object, _: Sel, info: id) -> NSUInteger { let view = utils::load::(this, VIEW_DELEGATE_PTR); view.dragging_entered(DragInfo { info: unsafe { Id::from_ptr(info) } diff --git a/src/bundle.rs b/src/bundle.rs index 184e7ef..5be1e11 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -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(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); } } diff --git a/src/image/appkit.rs b/src/image/appkit.rs index ff581c8..0dceb69 100644 --- a/src/image/appkit.rs +++ b/src/image/appkit.rs @@ -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(); }); diff --git a/src/listview/appkit.rs b/src/listview/appkit.rs index 371da30..f2c0391 100644 --- a/src/listview/appkit.rs +++ b/src/listview/appkit.rs @@ -79,7 +79,7 @@ extern "C" fn menu_needs_update(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( +extern "C" fn select_row( this: &Object, _: Sel, _table_view: id, diff --git a/src/uikit/app/delegate.rs b/src/uikit/app/delegate.rs index fadccae..aba45ed 100644 --- a/src/uikit/app/delegate.rs +++ b/src/uikit/app/delegate.rs @@ -69,7 +69,7 @@ pub(crate) fn register_app_delegate_class() -> *const Class { ); /*decl.add_method( sel!(application:didDiscardSceneSessions:), - did_discard_scene_sessions:: as extern fn(&Object, _, _, id) + did_discard_scene_sessions:: as extern "C" fn(&Object, _, _, id) );*/ DELEGATE_CLASS = decl.register(); diff --git a/src/view/splitviewcontroller/ios.rs b/src/view/splitviewcontroller/ios.rs index 3db20a5..fe2ab7b 100644 --- a/src/view/splitviewcontroller/ios.rs +++ b/src/view/splitviewcontroller/ios.rs @@ -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(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn will_appear(this: &mut Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewWillAppear:animated]; } @@ -20,7 +20,7 @@ extern fn will_appear(this: &mut Object, _: Sel, animated: BOOL } /// Called when the view controller receives a `viewDidAppear:` message. -extern fn did_appear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn did_appear(this: &mut Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewDidAppear:animated]; } @@ -30,7 +30,7 @@ extern fn did_appear(this: &mut Object, _: Sel, animated: BOOL) } /// Called when the view controller receives a `viewWillDisappear:` message. -extern fn will_disappear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn will_disappear(this: &mut Object, _: Sel, animated: BOOL) { unsafe { let _: () = msg_send![super(this, class!(UIViewController)), viewWillDisappear:animated]; } @@ -40,7 +40,7 @@ extern fn will_disappear(this: &mut Object, _: Sel, animated: B } /// Called when the view controller receives a `viewDidDisappear:` message. -extern fn did_disappear(this: &mut Object, _: Sel, animated: BOOL) { +extern "C" fn did_disappear(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() -> *co decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear:), will_appear:: as extern fn(&mut Object, _, BOOL)); - decl.add_method(sel!(viewDidAppear:), did_appear:: as extern fn(&mut Object, _, BOOL)); - decl.add_method(sel!(viewWillDisappear:), will_disappear:: as extern fn(&mut Object, _, BOOL)); - decl.add_method(sel!(viewDidDisappear:), did_disappear:: as extern fn(&mut Object, _, BOOL)); + decl.add_method(sel!(viewWillAppear:), will_appear:: as extern "C" fn(&mut Object, _, BOOL)); + decl.add_method(sel!(viewDidAppear:), did_appear:: as extern "C" fn(&mut Object, _, BOOL)); + decl.add_method(sel!(viewWillDisappear:), will_disappear:: as extern "C" fn(&mut Object, _, BOOL)); + decl.add_method(sel!(viewDidDisappear:), did_disappear:: as extern "C" fn(&mut Object, _, BOOL)); VIEW_CLASS = decl.register(); }); diff --git a/src/view/splitviewcontroller/macos.rs b/src/view/splitviewcontroller/macos.rs index 32a29eb..d175abf 100644 --- a/src/view/splitviewcontroller/macos.rs +++ b/src/view/splitviewcontroller/macos.rs @@ -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(this: &mut Object, _: Sel) { +extern "C" fn will_appear(this: &mut Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewWillAppear]; } @@ -21,7 +21,7 @@ extern fn will_appear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewDidAppear` message. -extern fn did_appear(this: &mut Object, _: Sel) { +extern "C" fn did_appear(this: &mut Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewDidAppear]; } @@ -31,7 +31,7 @@ extern fn did_appear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewWillDisappear` message. -extern fn will_disappear(this: &mut Object, _: Sel) { +extern "C" fn will_disappear(this: &mut Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewWillDisappear]; } @@ -41,7 +41,7 @@ extern fn will_disappear(this: &mut Object, _: Sel) { } /// Called when the view controller receives a `viewDidDisappear` message. -extern fn did_disappear(this: &mut Object, _: Sel) { +extern "C" fn did_disappear(this: &mut Object, _: Sel) { unsafe { let _: () = msg_send![super(this, class!(NSViewController)), viewDidDisappear]; } @@ -55,9 +55,9 @@ pub(crate) fn register_view_controller_class(instance load_or_register_class("NSViewController", instance.subclass_name(), |decl| unsafe { decl.add_ivar::(VIEW_DELEGATE_PTR); - decl.add_method(sel!(viewWillAppear), will_appear:: as extern fn(&mut Object, _)); - decl.add_method(sel!(viewDidAppear), did_appear:: as extern fn(&mut Object, _)); - decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern fn(&mut Object, _)); - decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern fn(&mut Object, _)); + decl.add_method(sel!(viewWillAppear), will_appear:: as extern "C" fn(&mut Object, _)); + decl.add_method(sel!(viewDidAppear), did_appear:: as extern "C" fn(&mut Object, _)); + decl.add_method(sel!(viewWillDisappear), will_disappear:: as extern "C" fn(&mut Object, _)); + decl.add_method(sel!(viewDidDisappear), did_disappear:: as extern "C" fn(&mut Object, _)); }) } diff --git a/src/webview/process_pool.rs b/src/webview/process_pool.rs index 9f27c82..8b5c630 100644 --- a/src/webview/process_pool.rs +++ b/src/webview/process_pool.rs @@ -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::(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];