summaryrefslogtreecommitdiff
path: root/ops/op2/test_cases
diff options
context:
space:
mode:
Diffstat (limited to 'ops/op2/test_cases')
-rw-r--r--ops/op2/test_cases/sync/add_options.out16
-rw-r--r--ops/op2/test_cases/sync/result_primitive.out50
-rw-r--r--ops/op2/test_cases/sync/result_primitive.rs4
-rw-r--r--ops/op2/test_cases/sync/result_void.out45
-rw-r--r--ops/op2/test_cases/sync/result_void.rs4
5 files changed, 110 insertions, 9 deletions
diff --git a/ops/op2/test_cases/sync/add_options.out b/ops/op2/test_cases/sync/add_options.out
index 682a77309..ca1da8fbe 100644
--- a/ops/op2/test_cases/sync/add_options.out
+++ b/ops/op2/test_cases/sync/add_options.out
@@ -4,8 +4,8 @@ impl op_test_add_option {
pub const fn name() -> &'static str {
stringify!(op_test_add_option)
}
- pub const fn decl() -> crate::deno_core::_ops::OpDecl {
- crate::deno_core::_ops::OpDecl {
+ pub const fn decl() -> crate::_ops::OpDecl {
+ crate::_ops::OpDecl {
name: stringify!(op_test_add_option),
v8_fn_ptr: Self::slow_function as _,
enabled: true,
@@ -16,22 +16,20 @@ impl op_test_add_option {
arg_count: 2usize as u8,
}
}
- pub extern "C" fn slow_function(
- info: *const crate::deno_core::v8::FunctionCallbackInfo,
- ) {
- let mut rv = crate::deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ pub extern "C" fn slow_function(info: *const crate::v8::FunctionCallbackInfo) {
+ let mut rv = crate::v8::ReturnValue::from_function_callback_info(unsafe {
&*info
});
- let args = crate::deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
+ let args = crate::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
&*info
});
let arg0 = args.get(0usize as i32);
- let arg0 = crate::deno_core::_ops::to_u32(&arg0) as _;
+ let arg0 = crate::_ops::to_u32(&arg0) as _;
let arg1 = args.get(1usize as i32);
let arg1 = if arg1.is_null_or_undefined() {
None
} else {
- let arg1 = crate::deno_core::_ops::to_u32(&arg1) as _;
+ let arg1 = crate::_ops::to_u32(&arg1) as _;
Some(arg1)
};
let result = Self::call(arg0, arg1);
diff --git a/ops/op2/test_cases/sync/result_primitive.out b/ops/op2/test_cases/sync/result_primitive.out
new file mode 100644
index 000000000..a8ac50174
--- /dev/null
+++ b/ops/op2/test_cases/sync/result_primitive.out
@@ -0,0 +1,50 @@
+#[allow(non_camel_case_types)]
+pub struct op_u32_with_result {}
+impl op_u32_with_result {
+ pub const fn name() -> &'static str {
+ stringify!(op_u32_with_result)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_u32_with_result),
+ v8_fn_ptr: Self::slow_function as _,
+ enabled: true,
+ fast_fn: None,
+ 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) {
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let result = Self::call();
+ match result {
+ Ok(result) => {
+ rv.set_uint32(result as u32);
+ }
+ 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 opctx = unsafe {
+ &*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data())
+ .value() as *const deno_core::_ops::OpCtx)
+ };
+ 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;
+ }
+ };
+ }
+ #[inline(always)]
+ pub fn call() -> Result<u32, AnyError> {}
+}
diff --git a/ops/op2/test_cases/sync/result_primitive.rs b/ops/op2/test_cases/sync/result_primitive.rs
new file mode 100644
index 000000000..6f68fa228
--- /dev/null
+++ b/ops/op2/test_cases/sync/result_primitive.rs
@@ -0,0 +1,4 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2]
+pub fn op_u32_with_result() -> Result<u32, AnyError> {}
diff --git a/ops/op2/test_cases/sync/result_void.out b/ops/op2/test_cases/sync/result_void.out
new file mode 100644
index 000000000..74c0c66a6
--- /dev/null
+++ b/ops/op2/test_cases/sync/result_void.out
@@ -0,0 +1,45 @@
+#[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,
+ fast_fn: None,
+ 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) {
+ 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 opctx = unsafe {
+ &*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data())
+ .value() as *const deno_core::_ops::OpCtx)
+ };
+ 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;
+ }
+ };
+ }
+ #[inline(always)]
+ pub fn call() -> Result<(), AnyError> {}
+}
diff --git a/ops/op2/test_cases/sync/result_void.rs b/ops/op2/test_cases/sync/result_void.rs
new file mode 100644
index 000000000..41256e8c4
--- /dev/null
+++ b/ops/op2/test_cases/sync/result_void.rs
@@ -0,0 +1,4 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2]
+pub fn op_void_with_result() -> Result<(), AnyError> {}