Skip to content

Commit

Permalink
Merge pull request #11 from tigercat2000/use-unwind
Browse files Browse the repository at this point in the history
Use C-unwind in bindgen, mandatory as of rust 1.81
  • Loading branch information
tigercat2000 authored Sep 7, 2024
2 parents 7cf278a + 64e0e57 commit 30cd47b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/byondapi-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn extract_args(a: &syn::FnArg) -> &syn::PatType {
#[allow(clippy::test_attr_in_doctest)]
/// Macro for generating byond binds
/// Usage:
/// ```
/// ```ignore
/// use byondapi::prelude::*;
/// #[byondapi::bind]
/// fn example() {Ok(ByondValue::null())}
Expand All @@ -23,7 +23,7 @@ fn extract_args(a: &syn::FnArg) -> &syn::PatType {
///
/// ```
/// Then generate the bindings.dm file with
/// ```
/// ```ignore
/// #[test]
/// fn generate_binds() {
/// byondapi::byondapi_macros::generate_bindings(env!("CARGO_CRATE_NAME"));
Expand Down
4 changes: 2 additions & 2 deletions crates/byondapi-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "byondapi"
version = "0.4.8"
version = "0.4.9"
authors = ["tigercat2000 <[email protected]>"]
edition = "2021"
description = "Idiomatic Rust bindings for BYONDAPI"
Expand All @@ -13,7 +13,7 @@ exclude = [".vscode/*"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
byondapi-sys = { path = "../byondapi-sys", version = "0.11.1" }
byondapi-sys = { path = "../byondapi-sys", version = "0.11.2" }
byondapi-macros = { path = "../byondapi-macros", version = "0.1.2" }
libloading = "0.8.4"
inventory = "0.3.15"
Expand Down
4 changes: 3 additions & 1 deletion crates/byondapi-rs/src/threadsync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ struct CallbackData<F: FnOnce() -> ByondValue + Send> {
callback: Option<F>,
}

extern "C" fn trampoline<F: FnOnce() -> ByondValue + Send>(data: *mut c_void) -> CByondValue {
extern "C-unwind" fn trampoline<F: FnOnce() -> ByondValue + Send>(
data: *mut c_void,
) -> CByondValue {
let data = unsafe { Box::from_raw(data as *mut CallbackData<F>) };
(data.callback.unwrap())().into_inner()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/byondapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "byondapi-sys"
version = "0.11.1"
version = "0.11.2"
authors = ["tigercat2000 <[email protected]>"]
edition = "2021"
description = "Raw bindgen bindings for byondapi"
Expand Down
3 changes: 2 additions & 1 deletion crates/byondapi-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bindgen::callbacks::ParseCallbacks;
use bindgen::{callbacks::ParseCallbacks, Abi};
use std::path::{Path, PathBuf};

fn main() {
Expand Down Expand Up @@ -55,6 +55,7 @@ fn generate_all() {
.header(wrapper.to_string_lossy())
.dynamic_library_name("ByondApi")
.dynamic_link_require_all(true)
.override_abi(Abi::CUnwind, "Byond.*")
// Also make headers included by main header dependencies of the build
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.parse_callbacks(Box::new(DoxygenCallbacks));
Expand Down

0 comments on commit 30cd47b

Please sign in to comment.