summaryrefslogtreecommitdiff
path: root/ext/ffi/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ffi/lib.rs')
-rw-r--r--ext/ffi/lib.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs
index feb879aba..eddfed039 100644
--- a/ext/ffi/lib.rs
+++ b/ext/ffi/lib.rs
@@ -673,12 +673,11 @@ impl From<&NativeType> for fast_api::Type {
NativeType::F32 => fast_api::Type::Float32,
NativeType::F64 => fast_api::Type::Float64,
NativeType::Void => fast_api::Type::Void,
- NativeType::Function
- | NativeType::Pointer
- | NativeType::I64
+ NativeType::I64
| NativeType::ISize
| NativeType::U64
- | NativeType::USize => {
+ | NativeType::USize => fast_api::Type::Uint64,
+ NativeType::Function | NativeType::Pointer => {
panic!("Cannot be fast api")
}
}
@@ -686,7 +685,7 @@ impl From<&NativeType> for fast_api::Type {
}
#[cfg(not(target_os = "windows"))]
-fn is_fast_api(rv: NativeType) -> bool {
+fn is_fast_api_rv(rv: NativeType) -> bool {
!matches!(
rv,
NativeType::Function
@@ -698,6 +697,11 @@ fn is_fast_api(rv: NativeType) -> bool {
)
}
+#[cfg(not(target_os = "windows"))]
+fn is_fast_api_arg(rv: NativeType) -> bool {
+ !matches!(rv, NativeType::Function | NativeType::Pointer)
+}
+
// Create a JavaScript function for synchronous FFI call to
// the given symbol.
fn make_sync_fn<'s>(
@@ -714,8 +718,8 @@ fn make_sync_fn<'s>(
let mut fast_allocations: Option<*mut ()> = None;
#[cfg(not(target_os = "windows"))]
if !sym.can_callback
- && !sym.parameter_types.iter().any(|t| !is_fast_api(*t))
- && is_fast_api(sym.result_type)
+ && !sym.parameter_types.iter().any(|t| !is_fast_api_arg(*t))
+ && is_fast_api_rv(sym.result_type)
{
let ret = fast_api::Type::from(&sym.result_type);