2023-06-24 17:30:04 -04:00
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
pub struct op_void_with_result {}
|
|
|
|
impl op_void_with_result {
|
|
|
|
pub const fn name() -> &'static str {
|
|
|
|
stringify!(op_void_with_result)
|
|
|
|
}
|
|
|
|
pub const fn decl() -> deno_core::_ops::OpDecl {
|
|
|
|
deno_core::_ops::OpDecl {
|
|
|
|
name: stringify!(op_void_with_result),
|
|
|
|
v8_fn_ptr: Self::slow_function as _,
|
|
|
|
enabled: true,
|
2023-06-25 10:36:09 -04:00
|
|
|
fast_fn: Some({
|
|
|
|
use deno_core::v8::fast_api::Type;
|
|
|
|
use deno_core::v8::fast_api::CType;
|
|
|
|
deno_core::v8::fast_api::FastFunction::new(
|
|
|
|
&[Type::V8Value, Type::CallbackOptions],
|
|
|
|
CType::Void,
|
|
|
|
Self::fast_function as *const ::std::ffi::c_void,
|
|
|
|
)
|
|
|
|
}),
|
2023-06-24 17:30:04 -04:00
|
|
|
is_async: false,
|
|
|
|
is_unstable: false,
|
|
|
|
is_v8: false,
|
|
|
|
arg_count: 0usize as u8,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) {
|
2023-06-25 10:36:09 -04:00
|
|
|
let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
|
|
|
|
&*info
|
|
|
|
});
|
|
|
|
let opctx = unsafe {
|
|
|
|
&*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()).value()
|
|
|
|
as *const deno_core::_ops::OpCtx)
|
|
|
|
};
|
|
|
|
if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } {
|
|
|
|
let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
|
|
|
|
let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
|
|
|
|
&*info
|
|
|
|
});
|
|
|
|
let opstate = ::std::cell::RefCell::borrow(&*opctx.state);
|
|
|
|
let exception = deno_core::error::to_v8_error(
|
|
|
|
scope,
|
|
|
|
opstate.get_error_class_fn,
|
|
|
|
&err,
|
|
|
|
);
|
|
|
|
scope.throw_exception(exception);
|
|
|
|
return;
|
|
|
|
}
|
2023-06-24 17:30:04 -04:00
|
|
|
let result = Self::call();
|
|
|
|
match result {
|
|
|
|
Ok(result) => {}
|
|
|
|
Err(err) => {
|
|
|
|
let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
|
|
|
|
let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
|
|
|
|
&*info
|
|
|
|
});
|
|
|
|
let opstate = ::std::cell::RefCell::borrow(&*opctx.state);
|
|
|
|
let exception = deno_core::error::to_v8_error(
|
|
|
|
scope,
|
|
|
|
opstate.get_error_class_fn,
|
|
|
|
&err,
|
|
|
|
);
|
|
|
|
scope.throw_exception(exception);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-06-25 10:36:09 -04:00
|
|
|
fn fast_function(
|
|
|
|
_: deno_core::v8::Local<deno_core::v8::Object>,
|
|
|
|
fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions,
|
|
|
|
) -> () {
|
|
|
|
let fast_api_callback_options = unsafe { &mut *fast_api_callback_options };
|
|
|
|
let opctx = unsafe {
|
|
|
|
&*(deno_core::v8::Local::<
|
|
|
|
v8::External,
|
|
|
|
>::cast(unsafe { fast_api_callback_options.data.data })
|
|
|
|
.value() as *const deno_core::_ops::OpCtx)
|
|
|
|
};
|
|
|
|
let result = Self::call();
|
|
|
|
let result = match result {
|
|
|
|
Ok(result) => result,
|
|
|
|
Err(err) => {
|
|
|
|
unsafe {
|
|
|
|
opctx.unsafely_set_last_error_for_ops_only(err);
|
|
|
|
}
|
|
|
|
fast_api_callback_options.fallback = true;
|
|
|
|
return ::std::default::Default::default();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
result
|
|
|
|
}
|
2023-06-24 17:30:04 -04:00
|
|
|
#[inline(always)]
|
|
|
|
pub fn call() -> Result<(), AnyError> {}
|
|
|
|
}
|