diff --git a/lib/binding_rust/ffi.rs b/lib/binding_rust/ffi.rs index 001458ee..9168de1b 100644 --- a/lib/binding_rust/ffi.rs +++ b/lib/binding_rust/ffi.rs @@ -8,7 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs")); #[cfg(not(feature = "bindgen"))] include!("./bindings.rs"); -#[cfg(not(windows))] +#[cfg(any(unix, target_os = "wasi"))] extern "C" { pub(crate) fn _ts_dup(fd: std::os::raw::c_int) -> std::os::raw::c_int; } diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 68d294d1..3ec3b6b0 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -3,7 +3,7 @@ pub mod ffi; mod util; -#[cfg(not(windows))] +#[cfg(any(unix, target_os = "wasi"))] use std::os::fd::AsRawFd; #[cfg(windows)] use std::os::windows::io::AsRawHandle; @@ -533,10 +533,10 @@ impl Parser { #[doc(alias = "ts_parser_print_dot_graphs")] pub fn print_dot_graphs( &mut self, - #[cfg(not(windows))] file: &impl AsRawFd, + #[cfg(any(unix, target_os = "wasi"))] file: &impl AsRawFd, #[cfg(windows)] file: &impl AsRawHandle, ) { - #[cfg(not(windows))] + #[cfg(any(unix, target_os = "wasi"))] { let fd = file.as_raw_fd(); unsafe { @@ -942,10 +942,10 @@ impl Tree { #[doc(alias = "ts_tree_print_dot_graph")] pub fn print_dot_graph( &self, - #[cfg(not(windows))] file: &impl AsRawFd, + #[cfg(any(unix, target_os = "wasi"))] file: &impl AsRawFd, #[cfg(windows)] file: &impl AsRawHandle, ) { - #[cfg(not(windows))] + #[cfg(any(unix, target_os = "wasi"))] { let fd = file.as_raw_fd(); unsafe { ffi::ts_tree_print_dot_graph(self.0.as_ptr(), fd) }