diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2023-02-28 08:26:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 08:26:48 +0200 |
commit | 4835098cf7ad2dd0641c14a2adf44ce233ba286c (patch) | |
tree | d84626d2e7e95c8276d289422ef6f18bc49b910e /ops/optimizer.rs | |
parent | 7c090b1b14e6b5000dbbed434525387c414ca62c (diff) |
fix(ext/ffi): Remove deno_core::OpState qualifiers, fix ops returning pointer defaults (#17959)
Diffstat (limited to 'ops/optimizer.rs')
-rw-r--r-- | ops/optimizer.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ops/optimizer.rs b/ops/optimizer.rs index a3ccd51b3..115011008 100644 --- a/ops/optimizer.rs +++ b/ops/optimizer.rs @@ -217,8 +217,8 @@ fn get_fast_scalar(s: &str) -> Option<FastValue> { "bool" => Some(FastValue::Bool), "u32" => Some(FastValue::U32), "i32" => Some(FastValue::I32), - "u64" => Some(FastValue::U64), - "i64" => Some(FastValue::I64), + "u64" | "usize" => Some(FastValue::U64), + "i64" | "isize" => Some(FastValue::I64), "f32" => Some(FastValue::F32), "f64" => Some(FastValue::F64), "* const c_void" | "* mut c_void" => Some(FastValue::Pointer), @@ -254,6 +254,16 @@ pub(crate) enum FastValue { Float64Array, } +impl FastValue { + pub fn default_value(&self) -> Quote { + match self { + FastValue::Pointer => q!({ ::std::ptr::null_mut() }), + FastValue::Void => q!({}), + _ => q!({ Default::default() }), + } + } +} + impl Default for FastValue { fn default() -> Self { Self::Void |