diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index c76d9f893..f82e00913 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -32,12 +32,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Install Rust temporarily pinned to 1.83 (https://github.com/posit-dev/ark/issues/678) - uses: dtolnay/rust-toolchain@1.83 - - - name: Report Rust version - run: rustc --version - - name: Compile ARK env: ARK_BUILD_TYPE: ${{ matrix.flavor }} diff --git a/crates/ark/src/browser.rs b/crates/ark/src/browser.rs index c89080fa4..37cd7f521 100644 --- a/crates/ark/src/browser.rs +++ b/crates/ark/src/browser.rs @@ -16,7 +16,7 @@ use crate::help::message::ShowHelpUrlParams; use crate::interface::RMain; #[harp::register] -pub unsafe extern "C" fn ps_browse_url(url: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_browse_url(url: SEXP) -> anyhow::Result { ps_browse_url_impl(url).or_else(|err| { log::error!("Failed to browse url due to: {err}"); Ok(Rf_ScalarLogical(0)) diff --git a/crates/ark/src/connections/r_connection.rs b/crates/ark/src/connections/r_connection.rs index f9c671bba..09fc2bac2 100644 --- a/crates/ark/src/connections/r_connection.rs +++ b/crates/ark/src/connections/r_connection.rs @@ -297,7 +297,7 @@ impl RConnection { } #[harp::register] -pub unsafe extern "C" fn ps_connection_opened( +pub unsafe extern "C-unwind" fn ps_connection_opened( name: SEXP, host: SEXP, r#type: SEXP, @@ -333,7 +333,7 @@ pub unsafe extern "C" fn ps_connection_opened( } #[harp::register] -pub unsafe extern "C" fn ps_connection_closed(id: SEXP) -> Result { +pub unsafe extern "C-unwind" fn ps_connection_closed(id: SEXP) -> Result { let main = RMain::get(); let id_ = RObject::view(id).to::()?; @@ -344,7 +344,7 @@ pub unsafe extern "C" fn ps_connection_closed(id: SEXP) -> Result Result { +pub unsafe extern "C-unwind" fn ps_connection_updated(id: SEXP) -> Result { let main = RMain::get(); let comm_id: String = RObject::view(id).to::()?; diff --git a/crates/ark/src/data_explorer/r_data_explorer.rs b/crates/ark/src/data_explorer/r_data_explorer.rs index e5de0be05..7d3a854cf 100644 --- a/crates/ark/src/data_explorer/r_data_explorer.rs +++ b/crates/ark/src/data_explorer/r_data_explorer.rs @@ -1088,7 +1088,7 @@ fn table_info_or_bail(x: SEXP) -> anyhow::Result { /// environment; optional. /// - `env`: The environment containing the R object; optional. #[harp::register] -pub unsafe extern "C" fn ps_view_data_frame( +pub unsafe extern "C-unwind" fn ps_view_data_frame( x: SEXP, title: SEXP, var: SEXP, diff --git a/crates/ark/src/errors.rs b/crates/ark/src/errors.rs index f1ccb1217..ba36a76b2 100644 --- a/crates/ark/src/errors.rs +++ b/crates/ark/src/errors.rs @@ -20,7 +20,7 @@ use stdext::unwrap; use crate::interface::RMain; #[harp::register] -unsafe extern "C" fn ps_record_error(evalue: SEXP, traceback: SEXP) -> anyhow::Result { +unsafe extern "C-unwind" fn ps_record_error(evalue: SEXP, traceback: SEXP) -> anyhow::Result { let main = RMain::get_mut(); // Convert to `RObject` for access to `try_from()` / `try_into()` methods. @@ -45,7 +45,7 @@ unsafe extern "C" fn ps_record_error(evalue: SEXP, traceback: SEXP) -> anyhow::R } #[harp::register] -unsafe extern "C" fn ps_format_traceback(calls: SEXP) -> anyhow::Result { +unsafe extern "C-unwind" fn ps_format_traceback(calls: SEXP) -> anyhow::Result { Ok(r_format_traceback(calls.into())?.sexp) } @@ -62,7 +62,7 @@ pub unsafe fn initialize() { } #[harp::register] -unsafe extern "C" fn ps_rust_backtrace() -> anyhow::Result { +unsafe extern "C-unwind" fn ps_rust_backtrace() -> anyhow::Result { let trace = std::backtrace::Backtrace::force_capture(); let trace = format!("{trace}"); Ok(*RObject::from(trace)) diff --git a/crates/ark/src/interface.rs b/crates/ark/src/interface.rs index 4d010fc23..73e31652a 100644 --- a/crates/ark/src/interface.rs +++ b/crates/ark/src/interface.rs @@ -1973,7 +1973,7 @@ pub(crate) fn console_inputs() -> anyhow::Result { // global `RMain` singleton. #[no_mangle] -pub extern "C" fn r_read_console( +pub extern "C-unwind" fn r_read_console( prompt: *const c_char, buf: *mut c_uchar, buflen: c_int, @@ -2018,30 +2018,30 @@ fn new_cstring(x: String) -> CString { } #[no_mangle] -pub extern "C" fn r_write_console(buf: *const c_char, buflen: i32, otype: i32) { +pub extern "C-unwind" fn r_write_console(buf: *const c_char, buflen: i32, otype: i32) { RMain::write_console(buf, buflen, otype); } #[no_mangle] -pub extern "C" fn r_show_message(buf: *const c_char) { +pub extern "C-unwind" fn r_show_message(buf: *const c_char) { let main = RMain::get(); main.show_message(buf); } #[no_mangle] -pub extern "C" fn r_busy(which: i32) { +pub extern "C-unwind" fn r_busy(which: i32) { let main = RMain::get_mut(); main.busy(which); } #[no_mangle] -pub extern "C" fn r_suicide(buf: *const c_char) { +pub extern "C-unwind" fn r_suicide(buf: *const c_char) { let msg = unsafe { CStr::from_ptr(buf) }; panic!("Suicide: {}", msg.to_str().unwrap()); } #[no_mangle] -pub unsafe extern "C" fn r_polled_events() { +pub unsafe extern "C-unwind" fn r_polled_events() { let main = RMain::get_mut(); main.polled_events(); } @@ -2049,7 +2049,7 @@ pub unsafe extern "C" fn r_polled_events() { // This hook is called like a user onLoad hook but for every package to be // loaded in the session #[harp::register] -unsafe extern "C" fn ps_onload_hook(pkg: SEXP, _path: SEXP) -> anyhow::Result { +unsafe extern "C-unwind" fn ps_onload_hook(pkg: SEXP, _path: SEXP) -> anyhow::Result { // NOTE: `_path` might be NULL for a compat reason, see comments on the R side let pkg: String = RObject::view(pkg).try_into()?; diff --git a/crates/ark/src/json.rs b/crates/ark/src/json.rs index 2c7bab911..0961ee604 100644 --- a/crates/ark/src/json.rs +++ b/crates/ark/src/json.rs @@ -10,7 +10,7 @@ use libr::SEXP; /// Convenience method to convert a JSON object to a string #[harp::register] -pub unsafe extern "C" fn ps_to_json(obj: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_to_json(obj: SEXP) -> anyhow::Result { let obj = RObject::view(obj); // Convert the object to a JSON value; this is the core serialization step diff --git a/crates/ark/src/lsp/util.rs b/crates/ark/src/lsp/util.rs index 679305651..5140e4bd1 100644 --- a/crates/ark/src/lsp/util.rs +++ b/crates/ark/src/lsp/util.rs @@ -14,7 +14,7 @@ use libr::SEXP; /// Shows a message in the Positron frontend #[harp::register] -pub unsafe extern "C" fn ps_log_error(message: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_log_error(message: SEXP) -> anyhow::Result { let message = RObject::view(message).to::(); if let Ok(message) = message { log::error!("{}", message); @@ -24,7 +24,7 @@ pub unsafe extern "C" fn ps_log_error(message: SEXP) -> anyhow::Result { } #[harp::register] -pub unsafe extern "C" fn ps_object_id(object: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_object_id(object: SEXP) -> anyhow::Result { let value = format!("{:p}", object); return Ok(Rf_mkString(value.as_ptr() as *const c_char)); } diff --git a/crates/ark/src/modules_utils.rs b/crates/ark/src/modules_utils.rs index 81b02b7f9..fd85a9d6a 100644 --- a/crates/ark/src/modules_utils.rs +++ b/crates/ark/src/modules_utils.rs @@ -1,13 +1,13 @@ use libr::SEXP; #[harp::register] -pub unsafe extern "C" fn ark_node_poke_cdr(node: SEXP, cdr: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ark_node_poke_cdr(node: SEXP, cdr: SEXP) -> anyhow::Result { libr::SETCDR(node, cdr); return Ok(harp::r_null()); } #[harp::register] -pub unsafe extern "C" fn ps_deep_sleep(secs: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_deep_sleep(secs: SEXP) -> anyhow::Result { let secs = libr::Rf_asInteger(secs); let secs = std::time::Duration::from_secs(secs as u64); std::thread::sleep(secs); diff --git a/crates/ark/src/plots/graphics_device.rs b/crates/ark/src/plots/graphics_device.rs index fa81a6b96..117ec50ab 100644 --- a/crates/ark/src/plots/graphics_device.rs +++ b/crates/ark/src/plots/graphics_device.rs @@ -77,11 +77,11 @@ pub(crate) fn init_graphics_device() { #[derive(Debug, Default)] #[allow(non_snake_case)] struct DeviceCallbacks { - pub activate: Cell>, - pub deactivate: Cell>, - pub holdflush: Cell i32>>, - pub mode: Cell>, - pub newPage: Cell>, + pub activate: Cell>, + pub deactivate: Cell>, + pub holdflush: Cell i32>>, + pub mode: Cell>, + pub newPage: Cell>, } #[derive(Default)] @@ -473,7 +473,7 @@ pub unsafe fn on_did_execute_request( // NOTE: May be called when rendering a plot to file, since this is done by // copying the graphics display list to a new plot device, and then closing that device. -unsafe extern "C" fn gd_activate(dev: pDevDesc) { +unsafe extern "C-unwind" fn gd_activate(dev: pDevDesc) { log::trace!("gd_activate"); DEVICE_CONTEXT.with_borrow(|cell| { @@ -485,7 +485,7 @@ unsafe extern "C" fn gd_activate(dev: pDevDesc) { // NOTE: May be called when rendering a plot to file, since this is done by // copying the graphics display list to a new plot device, and then closing that device. -unsafe extern "C" fn gd_deactivate(dev: pDevDesc) { +unsafe extern "C-unwind" fn gd_deactivate(dev: pDevDesc) { log::trace!("gd_deactivate"); DEVICE_CONTEXT.with_borrow(|cell| { @@ -495,7 +495,7 @@ unsafe extern "C" fn gd_deactivate(dev: pDevDesc) { }); } -unsafe extern "C" fn gd_hold_flush(dev: pDevDesc, mut holdflush: i32) -> i32 { +unsafe extern "C-unwind" fn gd_hold_flush(dev: pDevDesc, mut holdflush: i32) -> i32 { log::trace!("gd_hold_flush"); DEVICE_CONTEXT.with_borrow(|cell| { @@ -511,7 +511,7 @@ unsafe extern "C" fn gd_hold_flush(dev: pDevDesc, mut holdflush: i32) -> i32 { // mode = 0, graphics off // mode = 1, graphics on // mode = 2, graphical input on (ignored by most drivers) -unsafe extern "C" fn gd_mode(mode: i32, dev: pDevDesc) { +unsafe extern "C-unwind" fn gd_mode(mode: i32, dev: pDevDesc) { log::trace!("gd_mode: {mode}"); DEVICE_CONTEXT.with_borrow(|cell| { @@ -522,7 +522,7 @@ unsafe extern "C" fn gd_mode(mode: i32, dev: pDevDesc) { }); } -unsafe extern "C" fn gd_new_page(dd: pGEcontext, dev: pDevDesc) { +unsafe extern "C-unwind" fn gd_new_page(dd: pGEcontext, dev: pDevDesc) { log::trace!("gd_new_page"); DEVICE_CONTEXT.with_borrow(|cell| { @@ -590,7 +590,7 @@ unsafe fn ps_graphics_device_impl() -> anyhow::Result { } #[harp::register] -unsafe extern "C" fn ps_graphics_device() -> anyhow::Result { +unsafe extern "C-unwind" fn ps_graphics_device() -> anyhow::Result { ps_graphics_device_impl().or_else(|err| { log::error!("{}", err); Ok(R_NilValue) @@ -598,7 +598,7 @@ unsafe extern "C" fn ps_graphics_device() -> anyhow::Result { } #[harp::register] -unsafe extern "C" fn ps_graphics_event(_name: SEXP) -> anyhow::Result { +unsafe extern "C-unwind" fn ps_graphics_event(_name: SEXP) -> anyhow::Result { let id = unwrap!(DEVICE_CONTEXT.with_borrow(|cell| cell._id.borrow().clone()), None => { return Ok(Rf_ScalarLogical(0)); }); diff --git a/crates/ark/src/reticulate.rs b/crates/ark/src/reticulate.rs index c3fb09b83..8b3703a3f 100644 --- a/crates/ark/src/reticulate.rs +++ b/crates/ark/src/reticulate.rs @@ -85,7 +85,7 @@ impl ReticulateService { // Further actions that reticulate can ask the front-end can be requested through // the comm_id that is returned by this function. #[harp::register] -pub unsafe extern "C" fn ps_reticulate_open(input: SEXP) -> Result { +pub unsafe extern "C-unwind" fn ps_reticulate_open(input: SEXP) -> Result { let main = RMain::get(); let input: RObject = input.try_into()?; diff --git a/crates/ark/src/srcref.rs b/crates/ark/src/srcref.rs index afca088b6..21c7857ad 100644 --- a/crates/ark/src/srcref.rs +++ b/crates/ark/src/srcref.rs @@ -32,7 +32,7 @@ pub(crate) fn resource_loaded_namespaces() -> anyhow::Result<()> { } #[harp::register] -unsafe extern "C" fn ps_ns_populate_srcref(ns_name: SEXP) -> anyhow::Result { +unsafe extern "C-unwind" fn ps_ns_populate_srcref(ns_name: SEXP) -> anyhow::Result { let ns_name: String = RObject::view(ns_name).try_into()?; futures::executor::block_on(ns_populate_srcref(ns_name))?; Ok(harp::r_null()) @@ -183,6 +183,6 @@ fn generate_source( } #[harp::register] -pub extern "C" fn ark_zap_srcref(x: SEXP) -> anyhow::Result { +pub extern "C-unwind" fn ark_zap_srcref(x: SEXP) -> anyhow::Result { Ok(harp::attrib::zap_srcref(x).sexp) } diff --git a/crates/ark/src/sys/unix/signals.rs b/crates/ark/src/sys/unix/signals.rs index 7b8ac4599..333dfa3a6 100644 --- a/crates/ark/src/sys/unix/signals.rs +++ b/crates/ark/src/sys/unix/signals.rs @@ -64,6 +64,13 @@ pub fn set_interrupts_pending(pending: bool) { } } +/// Unix interrupt handler +/// +/// # Safety +/// +/// Note that this can't be `"C-unwind"` because [SigHandler::Handler] takes a `"C"` +/// function, so make absolute sure that the contents of this function can't Rust panic or +/// C longjmp. pub extern "C" fn handle_interrupt(_signal: libc::c_int) { set_interrupts_pending(true); } diff --git a/crates/ark/src/sys/windows/interface.rs b/crates/ark/src/sys/windows/interface.rs index bcef63561..afa168d3d 100644 --- a/crates/ark/src/sys/windows/interface.rs +++ b/crates/ark/src/sys/windows/interface.rs @@ -180,12 +180,12 @@ fn get_user_home() -> String { } #[no_mangle] -extern "C" fn r_callback() { +extern "C-unwind" fn r_callback() { // Do nothing! } #[no_mangle] -extern "C" fn r_yes_no_cancel(question: *const c_char) -> c_int { +extern "C-unwind" fn r_yes_no_cancel(question: *const c_char) -> c_int { // This seems to only be used on Windows during R's default `CleanUp` when // `SA_SAVEASK` is used. We should replace `Cleanup` with our own version // that resolves `SA_SAVEASK`, changes `saveact` to the resolved value, diff --git a/crates/ark/src/traps.rs b/crates/ark/src/traps.rs index 106aaea4e..3fa5e94d5 100644 --- a/crates/ark/src/traps.rs +++ b/crates/ark/src/traps.rs @@ -22,7 +22,7 @@ // and set this up now. pub use crate::sys::traps::register_trap_handlers; -pub extern "C" fn backtrace_handler(signum: libc::c_int) { +pub extern "C-unwind" fn backtrace_handler(signum: libc::c_int) { // Prevent infloop into the handler unsafe { libc::signal(signum, libc::SIG_DFL); diff --git a/crates/ark/src/ui/events.rs b/crates/ark/src/ui/events.rs index b49c3ac4e..674b47960 100644 --- a/crates/ark/src/ui/events.rs +++ b/crates/ark/src/ui/events.rs @@ -20,7 +20,7 @@ use libr::SEXP; use crate::interface::RMain; #[harp::register] -pub unsafe extern "C" fn ps_ui_show_message(message: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_show_message(message: SEXP) -> anyhow::Result { let params = ShowMessageParams { message: RObject::view(message).try_into()?, }; @@ -37,7 +37,7 @@ pub unsafe extern "C" fn ps_ui_show_message(message: SEXP) -> anyhow::Result anyhow::Result { @@ -58,7 +58,7 @@ pub unsafe extern "C" fn ps_ui_open_workspace( } #[harp::register] -pub unsafe extern "C" fn ps_ui_navigate_to_file( +pub unsafe extern "C-unwind" fn ps_ui_navigate_to_file( file: SEXP, _line: SEXP, _column: SEXP, @@ -81,7 +81,7 @@ pub unsafe extern "C" fn ps_ui_navigate_to_file( } #[harp::register] -pub unsafe extern "C" fn ps_ui_set_selection_ranges(ranges: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_set_selection_ranges(ranges: SEXP) -> anyhow::Result { let selections = ps_ui_robj_as_ranges(ranges)?; let params = SetEditorSelectionsParams { selections }; @@ -97,7 +97,7 @@ pub unsafe extern "C" fn ps_ui_set_selection_ranges(ranges: SEXP) -> anyhow::Res } #[harp::register] -pub unsafe extern "C" fn ps_ui_show_url(url: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_show_url(url: SEXP) -> anyhow::Result { let params = ShowUrlParams { url: RObject::view(url).try_into()?, }; diff --git a/crates/ark/src/ui/methods.rs b/crates/ark/src/ui/methods.rs index 309828b86..13b63215b 100644 --- a/crates/ark/src/ui/methods.rs +++ b/crates/ark/src/ui/methods.rs @@ -22,14 +22,14 @@ use crate::interface::RMain; use crate::ui::events::ps_ui_robj_as_ranges; #[harp::register] -pub unsafe extern "C" fn ps_ui_last_active_editor_context() -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_last_active_editor_context() -> anyhow::Result { let main = RMain::get(); let out = main.call_frontend_method(UiFrontendRequest::LastActiveEditorContext)?; Ok(out.sexp) } #[harp::register] -pub unsafe extern "C" fn ps_ui_modify_editor_selections( +pub unsafe extern "C-unwind" fn ps_ui_modify_editor_selections( ranges: SEXP, values: SEXP, ) -> anyhow::Result { @@ -48,14 +48,17 @@ pub unsafe extern "C" fn ps_ui_modify_editor_selections( } #[harp::register] -pub unsafe extern "C" fn ps_ui_workspace_folder() -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_workspace_folder() -> anyhow::Result { let main = RMain::get(); let out = main.call_frontend_method(UiFrontendRequest::WorkspaceFolder)?; Ok(out.sexp) } #[harp::register] -pub unsafe extern "C" fn ps_ui_show_dialog(title: SEXP, message: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_show_dialog( + title: SEXP, + message: SEXP, +) -> anyhow::Result { let params = ShowDialogParams { title: RObject::view(title).try_into()?, message: RObject::view(message).try_into()?, @@ -67,7 +70,7 @@ pub unsafe extern "C" fn ps_ui_show_dialog(title: SEXP, message: SEXP) -> anyhow } #[harp::register] -pub unsafe extern "C" fn ps_ui_show_question( +pub unsafe extern "C-unwind" fn ps_ui_show_question( title: SEXP, message: SEXP, ok_button_title: SEXP, @@ -94,7 +97,7 @@ pub unsafe extern "C" fn ps_ui_show_question( } #[harp::register] -pub unsafe extern "C" fn ps_ui_new_document( +pub unsafe extern "C-unwind" fn ps_ui_new_document( contents: SEXP, language_id: SEXP, ) -> anyhow::Result { @@ -109,7 +112,7 @@ pub unsafe extern "C" fn ps_ui_new_document( } #[harp::register] -pub unsafe extern "C" fn ps_ui_execute_command(command: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_execute_command(command: SEXP) -> anyhow::Result { let params = ExecuteCommandParams { command: RObject::view(command).try_into()?, }; @@ -120,7 +123,10 @@ pub unsafe extern "C" fn ps_ui_execute_command(command: SEXP) -> anyhow::Result< } #[harp::register] -pub unsafe extern "C" fn ps_ui_execute_code(code: SEXP, focus: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_execute_code( + code: SEXP, + focus: SEXP, +) -> anyhow::Result { let params = ExecuteCodeParams { language_id: String::from("r"), code: RObject::view(code).try_into()?, @@ -134,7 +140,9 @@ pub unsafe extern "C" fn ps_ui_execute_code(code: SEXP, focus: SEXP) -> anyhow:: } #[harp::register] -pub unsafe extern "C" fn ps_ui_evaluate_when_clause(when_clause: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_evaluate_when_clause( + when_clause: SEXP, +) -> anyhow::Result { let params = EvaluateWhenClauseParams { when_clause: RObject::view(when_clause).try_into()?, }; @@ -145,7 +153,7 @@ pub unsafe extern "C" fn ps_ui_evaluate_when_clause(when_clause: SEXP) -> anyhow } #[harp::register] -pub unsafe extern "C" fn ps_ui_debug_sleep(ms: SEXP) -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ui_debug_sleep(ms: SEXP) -> anyhow::Result { let params = DebugSleepParams { ms: RObject::view(ms).try_into()?, }; diff --git a/crates/ark/src/version.rs b/crates/ark/src/version.rs index f464acbb1..53a17ff0b 100644 --- a/crates/ark/src/version.rs +++ b/crates/ark/src/version.rs @@ -71,7 +71,7 @@ pub fn detect_r() -> anyhow::Result { } #[harp::register] -pub unsafe extern "C" fn ps_ark_version() -> anyhow::Result { +pub unsafe extern "C-unwind" fn ps_ark_version() -> anyhow::Result { let mut info = HashMap::::new(); // Set the version info in the map info.insert( diff --git a/crates/ark/src/viewer.rs b/crates/ark/src/viewer.rs index 66a05f018..6906071af 100644 --- a/crates/ark/src/viewer.rs +++ b/crates/ark/src/viewer.rs @@ -49,7 +49,7 @@ fn emit_html_output_jupyter( } #[harp::register] -pub unsafe extern "C" fn ps_html_viewer( +pub unsafe extern "C-unwind" fn ps_html_viewer( url: SEXP, label: SEXP, height: SEXP, diff --git a/crates/harp/harp-macros/src/lib.rs b/crates/harp/harp-macros/src/lib.rs index f414740f0..880c185e6 100644 --- a/crates/harp/harp-macros/src/lib.rs +++ b/crates/harp/harp-macros/src/lib.rs @@ -106,7 +106,7 @@ pub fn register(_attr: TokenStream, item: TokenStream) -> TokenStream { // Get metadata about the function being registered. let mut function: syn::ItemFn = syn::parse(item).unwrap(); - // Make sure the function is 'extern "C"'. + // Make sure the function is 'extern "C-unwind"'. let abi = match function.sig.abi { Some(ref abi) => abi, None => invalid_extern(function.sig), @@ -118,7 +118,7 @@ pub fn register(_attr: TokenStream, item: TokenStream) -> TokenStream { }; let name = name.to_token_stream().to_string(); - if name != "\"C\"" { + if name != "\"C-unwind\"" { invalid_extern(function.sig); } diff --git a/crates/harp/src/environment.rs b/crates/harp/src/environment.rs index 238a5f507..4a10fa043 100644 --- a/crates/harp/src/environment.rs +++ b/crates/harp/src/environment.rs @@ -262,7 +262,7 @@ unsafe impl Send for REnvs {} unsafe impl Sync for REnvs {} #[harp::register] -pub extern "C" fn ark_env_unlock(env: SEXP) -> crate::error::Result { +pub extern "C-unwind" fn ark_env_unlock(env: SEXP) -> crate::error::Result { unsafe { crate::check_env(env)?; Environment::view(env).unlock(); diff --git a/crates/harp/src/exec.rs b/crates/harp/src/exec.rs index facb8e66b..d1bb1cdd9 100644 --- a/crates/harp/src/exec.rs +++ b/crates/harp/src/exec.rs @@ -186,7 +186,7 @@ where }; let payload = &mut callback_data as *mut _ as *mut c_void; - extern "C" fn callback<'env, F, T>(payload: *mut c_void) -> SEXP + extern "C-unwind" fn callback<'env, F, T>(payload: *mut c_void) -> SEXP where F: FnOnce() -> T, F: 'env, @@ -202,7 +202,7 @@ where harp::r_null() } - extern "C" fn handler<'env, F, T>(err: SEXP, payload: *mut c_void) -> SEXP + extern "C-unwind" fn handler<'env, F, T>(err: SEXP, payload: *mut c_void) -> SEXP where F: FnOnce() -> T, F: 'env, @@ -328,7 +328,7 @@ where }; let payload = &mut callback_data as *mut _ as *mut c_void; - extern "C" fn callback<'env, F, T>(args: *mut c_void) + extern "C-unwind" fn callback<'env, F, T>(args: *mut c_void) where F: FnOnce() -> T, F: 'env, diff --git a/crates/harp/src/sys/unix/polled_events.rs b/crates/harp/src/sys/unix/polled_events.rs index 17402eb96..8f0f538aa 100644 --- a/crates/harp/src/sys/unix/polled_events.rs +++ b/crates/harp/src/sys/unix/polled_events.rs @@ -6,16 +6,16 @@ // pub struct RLocalPolledEventsSuspended { - _raii: crate::raii::RLocal>, + _raii: crate::raii::RLocal>, } #[no_mangle] -extern "C" fn r_polled_events_disabled() {} +extern "C-unwind" fn r_polled_events_disabled() {} impl RLocalPolledEventsSuspended { pub fn new(value: bool) -> Self { let new_value = if value { - Some(r_polled_events_disabled as unsafe extern "C" fn()) + Some(r_polled_events_disabled as unsafe extern "C-unwind" fn()) } else { None }; diff --git a/crates/harp/src/utils.rs b/crates/harp/src/utils.rs index 57e21fe4a..35662ed57 100644 --- a/crates/harp/src/utils.rs +++ b/crates/harp/src/utils.rs @@ -50,7 +50,7 @@ static RE_SYNTACTIC_IDENTIFIER: Lazy = Lazy::new(|| Regex::new(r"^[\p{L}\p{Nl}.][\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}.]*$").unwrap()); #[harp::register] -pub extern "C" fn harp_log_trace(msg: SEXP) -> crate::error::Result { +pub extern "C-unwind" fn harp_log_trace(msg: SEXP) -> crate::error::Result { let msg = String::try_from(RObject::view(msg))?; log::trace!("{msg}"); @@ -58,7 +58,7 @@ pub extern "C" fn harp_log_trace(msg: SEXP) -> crate::error::Result { } #[harp::register] -pub extern "C" fn harp_log_warning(msg: SEXP) -> crate::error::Result { +pub extern "C-unwind" fn harp_log_warning(msg: SEXP) -> crate::error::Result { let msg = String::try_from(RObject::view(msg))?; log::warn!("{msg}"); @@ -66,7 +66,7 @@ pub extern "C" fn harp_log_warning(msg: SEXP) -> crate::error::Result { } #[harp::register] -pub extern "C" fn harp_log_error(msg: SEXP) -> crate::error::Result { +pub extern "C-unwind" fn harp_log_error(msg: SEXP) -> crate::error::Result { let msg = String::try_from(RObject::view(msg))?; log::error!("{msg}"); diff --git a/crates/libr/src/functions.rs b/crates/libr/src/functions.rs index d94c1f622..b2f283286 100644 --- a/crates/libr/src/functions.rs +++ b/crates/libr/src/functions.rs @@ -17,7 +17,7 @@ macro_rules! generate { $( paste::paste! { $(#[cfg($cfg)])* - static mut [<$name _opt>]: Option $ret)*> = None; + static mut [<$name _opt>]: Option $ret)*> = None; } )+ diff --git a/crates/libr/src/functions_variadic.rs b/crates/libr/src/functions_variadic.rs index a5b0fc8fd..5893d9593 100644 --- a/crates/libr/src/functions_variadic.rs +++ b/crates/libr/src/functions_variadic.rs @@ -19,7 +19,7 @@ macro_rules! generate { $( paste::paste! { $(#[cfg($cfg)])* - static mut [<$name _opt>]: Option $ret)*> = None; + static mut [<$name _opt>]: Option $ret)*> = None; } )+ diff --git a/crates/libr/src/graphics.rs b/crates/libr/src/graphics.rs index e2eef9227..295313a5e 100644 --- a/crates/libr/src/graphics.rs +++ b/crates/libr/src/graphics.rs @@ -168,17 +168,26 @@ pub struct DevDescVersion13 { pub canGenKeybd: Rboolean, pub canGenIdle: Rboolean, pub gettingEvent: Rboolean, - pub activate: Option, - pub circle: Option, - pub clip: Option, - pub close: Option, - pub deactivate: Option, - pub locator: Option Rboolean>, + pub activate: Option, + pub circle: + Option, + pub clip: Option, + pub close: Option, + pub deactivate: Option, + pub locator: + Option Rboolean>, pub line: Option< - unsafe extern "C" fn(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x1: f64, + y1: f64, + x2: f64, + y2: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub metricInfo: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( c: std::ffi::c_int, gc: pGEcontext, ascent: *mut f64, @@ -187,10 +196,10 @@ pub struct DevDescVersion13 { dd: pDevDesc, ), >, - pub mode: Option, - pub newPage: Option, + pub mode: Option, + pub newPage: Option, pub polygon: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -199,7 +208,7 @@ pub struct DevDescVersion13 { ), >, pub polyline: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -208,10 +217,17 @@ pub struct DevDescVersion13 { ), >, pub rect: Option< - unsafe extern "C" fn(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x0: f64, + y0: f64, + x1: f64, + y1: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub path: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: *mut f64, y: *mut f64, npoly: std::ffi::c_int, @@ -222,7 +238,7 @@ pub struct DevDescVersion13 { ), >, pub raster: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( raster: *mut std::ffi::c_uint, w: std::ffi::c_int, h: std::ffi::c_int, @@ -236,9 +252,9 @@ pub struct DevDescVersion13 { dd: pDevDesc, ), >, - pub cap: Option SEXP>, + pub cap: Option SEXP>, pub size: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( left: *mut f64, right: *mut f64, bottom: *mut f64, @@ -247,10 +263,14 @@ pub struct DevDescVersion13 { ), >, pub strWidth: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub text: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -260,12 +280,13 @@ pub struct DevDescVersion13 { dd: pDevDesc, ), >, - pub onExit: Option, - pub getEvent: Option SEXP>, - pub newFrameConfirm: Option Rboolean>, + pub onExit: Option, + pub getEvent: + Option SEXP>, + pub newFrameConfirm: Option Rboolean>, pub hasTextUTF8: Rboolean, pub textUTF8: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -276,14 +297,19 @@ pub struct DevDescVersion13 { ), >, pub strWidthUTF8: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub wantSymbolUTF8: Rboolean, pub useRotatedTextInContour: Rboolean, pub eventEnv: SEXP, - pub eventHelper: Option, - pub holdflush: - Option std::ffi::c_int>, + pub eventHelper: Option, + pub holdflush: Option< + unsafe extern "C-unwind" fn(dd: pDevDesc, level: std::ffi::c_int) -> std::ffi::c_int, + >, pub haveTransparency: std::ffi::c_int, pub haveTransparentBg: std::ffi::c_int, pub haveRaster: std::ffi::c_int, @@ -327,17 +353,26 @@ pub struct DevDescVersion14 { pub canGenKeybd: Rboolean, pub canGenIdle: Rboolean, pub gettingEvent: Rboolean, - pub activate: Option, - pub circle: Option, - pub clip: Option, - pub close: Option, - pub deactivate: Option, - pub locator: Option Rboolean>, + pub activate: Option, + pub circle: + Option, + pub clip: Option, + pub close: Option, + pub deactivate: Option, + pub locator: + Option Rboolean>, pub line: Option< - unsafe extern "C" fn(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x1: f64, + y1: f64, + x2: f64, + y2: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub metricInfo: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( c: std::ffi::c_int, gc: pGEcontext, ascent: *mut f64, @@ -346,10 +381,10 @@ pub struct DevDescVersion14 { dd: pDevDesc, ), >, - pub mode: Option, - pub newPage: Option, + pub mode: Option, + pub newPage: Option, pub polygon: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -358,7 +393,7 @@ pub struct DevDescVersion14 { ), >, pub polyline: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -367,10 +402,17 @@ pub struct DevDescVersion14 { ), >, pub rect: Option< - unsafe extern "C" fn(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x0: f64, + y0: f64, + x1: f64, + y1: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub path: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: *mut f64, y: *mut f64, npoly: std::ffi::c_int, @@ -381,7 +423,7 @@ pub struct DevDescVersion14 { ), >, pub raster: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( raster: *mut std::ffi::c_uint, w: std::ffi::c_int, h: std::ffi::c_int, @@ -395,9 +437,9 @@ pub struct DevDescVersion14 { dd: pDevDesc, ), >, - pub cap: Option SEXP>, + pub cap: Option SEXP>, pub size: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( left: *mut f64, right: *mut f64, bottom: *mut f64, @@ -406,10 +448,14 @@ pub struct DevDescVersion14 { ), >, pub strWidth: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub text: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -419,12 +465,13 @@ pub struct DevDescVersion14 { dd: pDevDesc, ), >, - pub onExit: Option, - pub getEvent: Option SEXP>, - pub newFrameConfirm: Option Rboolean>, + pub onExit: Option, + pub getEvent: + Option SEXP>, + pub newFrameConfirm: Option Rboolean>, pub hasTextUTF8: Rboolean, pub textUTF8: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -435,25 +482,31 @@ pub struct DevDescVersion14 { ), >, pub strWidthUTF8: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub wantSymbolUTF8: Rboolean, pub useRotatedTextInContour: Rboolean, pub eventEnv: SEXP, - pub eventHelper: Option, - pub holdflush: - Option std::ffi::c_int>, + pub eventHelper: Option, + pub holdflush: Option< + unsafe extern "C-unwind" fn(dd: pDevDesc, level: std::ffi::c_int) -> std::ffi::c_int, + >, pub haveTransparency: std::ffi::c_int, pub haveTransparentBg: std::ffi::c_int, pub haveRaster: std::ffi::c_int, pub haveCapture: std::ffi::c_int, pub haveLocator: std::ffi::c_int, - pub setPattern: Option SEXP>, - pub releasePattern: Option, - pub setClipPath: Option SEXP>, - pub releaseClipPath: Option, - pub setMask: Option SEXP>, - pub releaseMask: Option, + pub setPattern: Option SEXP>, + pub releasePattern: Option, + pub setClipPath: + Option SEXP>, + pub releaseClipPath: Option, + pub setMask: Option SEXP>, + pub releaseMask: Option, pub deviceVersion: std::ffi::c_int, pub deviceClip: Rboolean, pub reserved: [std::ffi::c_char; 64usize], @@ -494,17 +547,26 @@ pub struct DevDescVersion15 { pub canGenKeybd: Rboolean, pub canGenIdle: Rboolean, pub gettingEvent: Rboolean, - pub activate: Option, - pub circle: Option, - pub clip: Option, - pub close: Option, - pub deactivate: Option, - pub locator: Option Rboolean>, + pub activate: Option, + pub circle: + Option, + pub clip: Option, + pub close: Option, + pub deactivate: Option, + pub locator: + Option Rboolean>, pub line: Option< - unsafe extern "C" fn(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x1: f64, + y1: f64, + x2: f64, + y2: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub metricInfo: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( c: std::ffi::c_int, gc: pGEcontext, ascent: *mut f64, @@ -513,10 +575,10 @@ pub struct DevDescVersion15 { dd: pDevDesc, ), >, - pub mode: Option, - pub newPage: Option, + pub mode: Option, + pub newPage: Option, pub polygon: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -525,7 +587,7 @@ pub struct DevDescVersion15 { ), >, pub polyline: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -534,10 +596,17 @@ pub struct DevDescVersion15 { ), >, pub rect: Option< - unsafe extern "C" fn(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x0: f64, + y0: f64, + x1: f64, + y1: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub path: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: *mut f64, y: *mut f64, npoly: std::ffi::c_int, @@ -548,7 +617,7 @@ pub struct DevDescVersion15 { ), >, pub raster: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( raster: *mut std::ffi::c_uint, w: std::ffi::c_int, h: std::ffi::c_int, @@ -562,9 +631,9 @@ pub struct DevDescVersion15 { dd: pDevDesc, ), >, - pub cap: Option SEXP>, + pub cap: Option SEXP>, pub size: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( left: *mut f64, right: *mut f64, bottom: *mut f64, @@ -573,10 +642,14 @@ pub struct DevDescVersion15 { ), >, pub strWidth: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub text: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -586,12 +659,13 @@ pub struct DevDescVersion15 { dd: pDevDesc, ), >, - pub onExit: Option, - pub getEvent: Option SEXP>, - pub newFrameConfirm: Option Rboolean>, + pub onExit: Option, + pub getEvent: + Option SEXP>, + pub newFrameConfirm: Option Rboolean>, pub hasTextUTF8: Rboolean, pub textUTF8: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -602,45 +676,61 @@ pub struct DevDescVersion15 { ), >, pub strWidthUTF8: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub wantSymbolUTF8: Rboolean, pub useRotatedTextInContour: Rboolean, pub eventEnv: SEXP, - pub eventHelper: Option, - pub holdflush: - Option std::ffi::c_int>, + pub eventHelper: Option, + pub holdflush: Option< + unsafe extern "C-unwind" fn(dd: pDevDesc, level: std::ffi::c_int) -> std::ffi::c_int, + >, pub haveTransparency: std::ffi::c_int, pub haveTransparentBg: std::ffi::c_int, pub haveRaster: std::ffi::c_int, pub haveCapture: std::ffi::c_int, pub haveLocator: std::ffi::c_int, - pub setPattern: Option SEXP>, - pub releasePattern: Option, - pub setClipPath: Option SEXP>, - pub releaseClipPath: Option, - pub setMask: Option SEXP>, - pub releaseMask: Option, + pub setPattern: Option SEXP>, + pub releasePattern: Option, + pub setClipPath: + Option SEXP>, + pub releaseClipPath: Option, + pub setMask: Option SEXP>, + pub releaseMask: Option, pub deviceVersion: std::ffi::c_int, pub deviceClip: Rboolean, pub defineGroup: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( source: SEXP, op: std::ffi::c_int, destination: SEXP, dd: pDevDesc, ) -> SEXP, >, - pub useGroup: Option, - pub releaseGroup: Option, - pub stroke: Option, + pub useGroup: Option, + pub releaseGroup: Option, + pub stroke: Option, pub fill: Option< - unsafe extern "C" fn(path: SEXP, rule: std::ffi::c_int, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + path: SEXP, + rule: std::ffi::c_int, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub fillStroke: Option< - unsafe extern "C" fn(path: SEXP, rule: std::ffi::c_int, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + path: SEXP, + rule: std::ffi::c_int, + gc: pGEcontext, + dd: pDevDesc, + ), >, - pub capabilities: Option SEXP>, + pub capabilities: Option SEXP>, pub reserved: [std::ffi::c_char; 64usize], } pub type pDevDescVersion15 = *mut DevDescVersion15; @@ -679,17 +769,26 @@ pub struct DevDescVersion16 { pub canGenKeybd: Rboolean, pub canGenIdle: Rboolean, pub gettingEvent: Rboolean, - pub activate: Option, - pub circle: Option, - pub clip: Option, - pub close: Option, - pub deactivate: Option, - pub locator: Option Rboolean>, + pub activate: Option, + pub circle: + Option, + pub clip: Option, + pub close: Option, + pub deactivate: Option, + pub locator: + Option Rboolean>, pub line: Option< - unsafe extern "C" fn(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x1: f64, + y1: f64, + x2: f64, + y2: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub metricInfo: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( c: std::ffi::c_int, gc: pGEcontext, ascent: *mut f64, @@ -698,10 +797,10 @@ pub struct DevDescVersion16 { dd: pDevDesc, ), >, - pub mode: Option, - pub newPage: Option, + pub mode: Option, + pub newPage: Option, pub polygon: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -710,7 +809,7 @@ pub struct DevDescVersion16 { ), >, pub polyline: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, x: *mut f64, y: *mut f64, @@ -719,10 +818,17 @@ pub struct DevDescVersion16 { ), >, pub rect: Option< - unsafe extern "C" fn(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + x0: f64, + y0: f64, + x1: f64, + y1: f64, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub path: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: *mut f64, y: *mut f64, npoly: std::ffi::c_int, @@ -733,7 +839,7 @@ pub struct DevDescVersion16 { ), >, pub raster: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( raster: *mut std::ffi::c_uint, w: std::ffi::c_int, h: std::ffi::c_int, @@ -747,9 +853,9 @@ pub struct DevDescVersion16 { dd: pDevDesc, ), >, - pub cap: Option SEXP>, + pub cap: Option SEXP>, pub size: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( left: *mut f64, right: *mut f64, bottom: *mut f64, @@ -758,10 +864,14 @@ pub struct DevDescVersion16 { ), >, pub strWidth: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub text: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -771,12 +881,13 @@ pub struct DevDescVersion16 { dd: pDevDesc, ), >, - pub onExit: Option, - pub getEvent: Option SEXP>, - pub newFrameConfirm: Option Rboolean>, + pub onExit: Option, + pub getEvent: + Option SEXP>, + pub newFrameConfirm: Option Rboolean>, pub hasTextUTF8: Rboolean, pub textUTF8: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( x: f64, y: f64, str: *const std::ffi::c_char, @@ -787,47 +898,63 @@ pub struct DevDescVersion16 { ), >, pub strWidthUTF8: Option< - unsafe extern "C" fn(str: *const std::ffi::c_char, gc: pGEcontext, dd: pDevDesc) -> f64, + unsafe extern "C-unwind" fn( + str: *const std::ffi::c_char, + gc: pGEcontext, + dd: pDevDesc, + ) -> f64, >, pub wantSymbolUTF8: Rboolean, pub useRotatedTextInContour: Rboolean, pub eventEnv: SEXP, - pub eventHelper: Option, - pub holdflush: - Option std::ffi::c_int>, + pub eventHelper: Option, + pub holdflush: Option< + unsafe extern "C-unwind" fn(dd: pDevDesc, level: std::ffi::c_int) -> std::ffi::c_int, + >, pub haveTransparency: std::ffi::c_int, pub haveTransparentBg: std::ffi::c_int, pub haveRaster: std::ffi::c_int, pub haveCapture: std::ffi::c_int, pub haveLocator: std::ffi::c_int, - pub setPattern: Option SEXP>, - pub releasePattern: Option, - pub setClipPath: Option SEXP>, - pub releaseClipPath: Option, - pub setMask: Option SEXP>, - pub releaseMask: Option, + pub setPattern: Option SEXP>, + pub releasePattern: Option, + pub setClipPath: + Option SEXP>, + pub releaseClipPath: Option, + pub setMask: Option SEXP>, + pub releaseMask: Option, pub deviceVersion: std::ffi::c_int, pub deviceClip: Rboolean, pub defineGroup: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( source: SEXP, op: std::ffi::c_int, destination: SEXP, dd: pDevDesc, ) -> SEXP, >, - pub useGroup: Option, - pub releaseGroup: Option, - pub stroke: Option, + pub useGroup: Option, + pub releaseGroup: Option, + pub stroke: Option, pub fill: Option< - unsafe extern "C" fn(path: SEXP, rule: std::ffi::c_int, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + path: SEXP, + rule: std::ffi::c_int, + gc: pGEcontext, + dd: pDevDesc, + ), >, pub fillStroke: Option< - unsafe extern "C" fn(path: SEXP, rule: std::ffi::c_int, gc: pGEcontext, dd: pDevDesc), + unsafe extern "C-unwind" fn( + path: SEXP, + rule: std::ffi::c_int, + gc: pGEcontext, + dd: pDevDesc, + ), >, - pub capabilities: Option SEXP>, + pub capabilities: Option SEXP>, pub glyph: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( n: std::ffi::c_int, glyphs: *mut std::ffi::c_int, x: *mut f64, diff --git a/crates/libr/src/r.rs b/crates/libr/src/r.rs index 5c5923dbd..3e2185156 100644 --- a/crates/libr/src/r.rs +++ b/crates/libr/src/r.rs @@ -83,14 +83,14 @@ functions::generate! { pub fn R_RunPendingFinalizers(); pub fn R_ToplevelExec( - fun: Option, + fun: Option, data: *mut std::ffi::c_void ) -> Rboolean; pub fn R_withCallingErrorHandler( - body: Option SEXP>, + body: Option SEXP>, bdata: *mut std::ffi::c_void, - handler: Option SEXP>, + handler: Option SEXP>, hdata: *mut std::ffi::c_void ) -> SEXP; @@ -694,16 +694,16 @@ mutable_globals::generate! { pub static mut R_wait_usec: i32; #[cfg(target_family = "unix")] - pub static mut R_PolledEvents: Option; + pub static mut R_PolledEvents: Option; #[cfg(target_family = "unix")] pub static mut ptr_R_WriteConsole: Option< - unsafe extern "C" fn(arg1: *const std::ffi::c_char, arg2: std::ffi::c_int), + unsafe extern "C-unwind" fn(arg1: *const std::ffi::c_char, arg2: std::ffi::c_int), >; #[cfg(target_family = "unix")] pub static mut ptr_R_WriteConsoleEx: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( arg1: *const std::ffi::c_char, arg2: std::ffi::c_int, arg3: std::ffi::c_int, @@ -712,7 +712,7 @@ mutable_globals::generate! { #[cfg(target_family = "unix")] pub static mut ptr_R_ReadConsole: Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( arg1: *const std::ffi::c_char, arg2: *mut std::ffi::c_uchar, arg3: std::ffi::c_int, @@ -721,13 +721,13 @@ mutable_globals::generate! { >; #[cfg(target_family = "unix")] - pub static mut ptr_R_ShowMessage: Option; + pub static mut ptr_R_ShowMessage: Option; #[cfg(target_family = "unix")] - pub static mut ptr_R_Busy: Option; + pub static mut ptr_R_Busy: Option; #[cfg(target_family = "unix")] - pub static mut ptr_R_Suicide: Option; + pub static mut ptr_R_Suicide: Option; // ----------------------------------------------------------------------------------- // Windows diff --git a/crates/libr/src/sys/windows/types.rs b/crates/libr/src/sys/windows/types.rs index c9c7b1523..4a69ee8dc 100644 --- a/crates/libr/src/sys/windows/types.rs +++ b/crates/libr/src/sys/windows/types.rs @@ -147,7 +147,7 @@ pub struct structRstart { #[doc = "HOME"] pub home: *mut ::std::os::raw::c_char, pub ReadConsole: ::std::option::Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( arg1: *const ::std::os::raw::c_char, arg2: *mut ::std::os::raw::c_uchar, arg3: ::std::os::raw::c_int, @@ -155,21 +155,24 @@ pub struct structRstart { ) -> ::std::os::raw::c_int, >, pub WriteConsole: ::std::option::Option< - unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char, arg2: ::std::os::raw::c_int), + unsafe extern "C-unwind" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ), >, #[doc = "ProcessEvents under Unix"] - pub CallBack: ::std::option::Option, + pub CallBack: ::std::option::Option, pub ShowMessage: - ::std::option::Option, + ::std::option::Option, pub YesNoCancel: ::std::option::Option< - unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + unsafe extern "C-unwind" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, >, #[doc = "Return value here is expected to be 1 for Yes, -1 for No and\n0 for Cancel: symbolic constants in graphapp.h"] - pub Busy: ::std::option::Option, + pub Busy: ::std::option::Option, pub CharacterMode: UImode, #[doc = "The following field has been added in R 2.5.0"] pub WriteConsoleEx: ::std::option::Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( arg1: *const ::std::os::raw::c_char, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, @@ -179,16 +182,17 @@ pub struct structRstart { pub EmitEmbeddedUTF8: Rboolean, #[doc = "The following fields have been added in R 4.2.0 and are only\navailable with RstarVersion 1."] pub CleanUp: ::std::option::Option< - unsafe extern "C" fn( + unsafe extern "C-unwind" fn( arg1: SA_TYPE, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ), >, - pub ClearerrConsole: ::std::option::Option, - pub FlushConsole: ::std::option::Option, - pub ResetConsole: ::std::option::Option, - pub Suicide: ::std::option::Option, + pub ClearerrConsole: ::std::option::Option, + pub FlushConsole: ::std::option::Option, + pub ResetConsole: ::std::option::Option, + pub Suicide: + ::std::option::Option, } impl structRstart { #[inline] diff --git a/crates/libr/src/types.rs b/crates/libr/src/types.rs index 7680c9107..eb0b98ed6 100644 --- a/crates/libr/src/types.rs +++ b/crates/libr/src/types.rs @@ -81,7 +81,7 @@ pub const ParseStatus_PARSE_INCOMPLETE: ParseStatus = 2; pub const ParseStatus_PARSE_ERROR: ParseStatus = 3; pub const ParseStatus_PARSE_EOF: ParseStatus = 4; -pub type DL_FUNC = Option *mut std::ffi::c_void>; +pub type DL_FUNC = Option *mut std::ffi::c_void>; pub type R_NativePrimitiveArgType = std::ffi::c_uint; #[repr(C)]