fix(ext/ffi): Remove deno_core::OpState qualifiers, fix ops returning pointer defaults (#17959)

This commit is contained in:
Aapo Alasuutari 2023-02-28 08:26:48 +02:00 committed by GitHub
parent 7c090b1b14
commit 4835098cf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 52 deletions

View file

@ -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