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.out4
-rw-r--r--ops/op2/test_cases/sync/smi.out4
-rw-r--r--ops/op2/test_cases/sync/string_cow.out75
-rw-r--r--ops/op2/test_cases/sync/string_cow.rs4
-rw-r--r--ops/op2/test_cases/sync/string_option_return.out53
-rw-r--r--ops/op2/test_cases/sync/string_option_return.rs5
-rw-r--r--ops/op2/test_cases/sync/string_owned.out73
-rw-r--r--ops/op2/test_cases/sync/string_owned.rs4
-rw-r--r--ops/op2/test_cases/sync/string_ref.out75
-rw-r--r--ops/op2/test_cases/sync/string_ref.rs4
-rw-r--r--ops/op2/test_cases/sync/string_return.out49
-rw-r--r--ops/op2/test_cases/sync/string_return.rs5
12 files changed, 353 insertions, 2 deletions
diff --git a/ops/op2/test_cases/sync/add.out b/ops/op2/test_cases/sync/add.out
index c8f77ab92..a73f032aa 100644
--- a/ops/op2/test_cases/sync/add.out
+++ b/ops/op2/test_cases/sync/add.out
@@ -52,7 +52,9 @@ impl op_add {
arg0: u32,
arg1: u32,
) -> u32 {
- let result = Self::call(arg0 as _, arg1 as _);
+ let arg0 = arg0 as _;
+ let arg1 = arg1 as _;
+ let result = Self::call(arg0, arg1);
result
}
extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
diff --git a/ops/op2/test_cases/sync/smi.out b/ops/op2/test_cases/sync/smi.out
index 85db2576e..24b81ae47 100644
--- a/ops/op2/test_cases/sync/smi.out
+++ b/ops/op2/test_cases/sync/smi.out
@@ -52,7 +52,9 @@ impl op_add {
arg0: i32,
arg1: u32,
) -> u32 {
- let result = Self::call(arg0 as _, arg1 as _);
+ let arg0 = arg0 as _;
+ let arg1 = arg1 as _;
+ let result = Self::call(arg0, arg1);
result
}
extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
diff --git a/ops/op2/test_cases/sync/string_cow.out b/ops/op2/test_cases/sync/string_cow.out
new file mode 100644
index 000000000..7d388e598
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_cow.out
@@ -0,0 +1,75 @@
+#[allow(non_camel_case_types)]
+struct op_string_cow {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_string_cow {
+ const NAME: &'static str = stringify!(op_string_cow);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_string_cow),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ };
+}
+impl op_string_cow {
+ pub const fn name() -> &'static str {
+ stringify!(op_string_cow)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_string_cow),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ }
+ }
+ fn v8_fn_ptr_fast(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ arg0: *mut deno_core::v8::fast_api::FastApiOneByteString,
+ ) -> u32 {
+ let mut arg0_temp: [::std::mem::MaybeUninit<u8>; 1024] = [::std::mem::MaybeUninit::uninit(); 1024];
+ let arg0 = deno_core::_ops::to_str_ptr(unsafe { &mut *arg0 }, &mut arg0_temp);
+ let result = Self::call(arg0);
+ result
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
+ let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
+ &*info
+ });
+ let arg0 = args.get(0usize as i32);
+ let mut arg0_temp: [::std::mem::MaybeUninit<u8>; 1024] = [::std::mem::MaybeUninit::uninit(); 1024];
+ let arg0 = deno_core::_ops::to_str(scope, &arg0, &mut arg0_temp);
+ let result = Self::call(arg0);
+ rv.set_uint32(result as u32);
+ }
+ #[inline(always)]
+ fn call(s: Cow<str>) -> u32 {}
+}
diff --git a/ops/op2/test_cases/sync/string_cow.rs b/ops/op2/test_cases/sync/string_cow.rs
new file mode 100644
index 000000000..ed4dfca82
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_cow.rs
@@ -0,0 +1,4 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2(fast)]
+fn op_string_cow(#[string] s: Cow<str>) -> u32 {}
diff --git a/ops/op2/test_cases/sync/string_option_return.out b/ops/op2/test_cases/sync/string_option_return.out
new file mode 100644
index 000000000..6143ac217
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_option_return.out
@@ -0,0 +1,53 @@
+#[allow(non_camel_case_types)]
+pub struct op_string_return {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_string_return {
+ const NAME: &'static str = stringify!(op_string_return);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_string_return),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ fast_fn: None,
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 0usize as u8,
+ };
+}
+impl op_string_return {
+ pub const fn name() -> &'static str {
+ stringify!(op_string_return)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_string_return),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ fast_fn: None,
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 0usize as u8,
+ }
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
+ let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let result = Self::call();
+ if let Some(result) = result {
+ if result.is_empty() {
+ rv.set_empty_string();
+ } else {
+ let temp = deno_core::v8::String::new(scope, &result).unwrap();
+ rv.set(temp.into());
+ }
+ } else {
+ rv.set_null();
+ }
+ }
+ #[inline(always)]
+ pub fn call() -> Option<String> {}
+}
diff --git a/ops/op2/test_cases/sync/string_option_return.rs b/ops/op2/test_cases/sync/string_option_return.rs
new file mode 100644
index 000000000..932836d2f
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_option_return.rs
@@ -0,0 +1,5 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2]
+#[string]
+pub fn op_string_return() -> Option<String> {}
diff --git a/ops/op2/test_cases/sync/string_owned.out b/ops/op2/test_cases/sync/string_owned.out
new file mode 100644
index 000000000..7418a311c
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_owned.out
@@ -0,0 +1,73 @@
+#[allow(non_camel_case_types)]
+struct op_string_owned {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_string_owned {
+ const NAME: &'static str = stringify!(op_string_owned);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_string_owned),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ };
+}
+impl op_string_owned {
+ pub const fn name() -> &'static str {
+ stringify!(op_string_owned)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_string_owned),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ }
+ }
+ fn v8_fn_ptr_fast(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ arg0: *mut deno_core::v8::fast_api::FastApiOneByteString,
+ ) -> u32 {
+ let arg0 = deno_core::_ops::to_string_ptr(unsafe { &mut *arg0 });
+ let result = Self::call(arg0);
+ result
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
+ let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
+ &*info
+ });
+ let arg0 = args.get(0usize as i32);
+ let arg0 = arg0.to_rust_string_lossy(scope);
+ let result = Self::call(arg0);
+ rv.set_uint32(result as u32);
+ }
+ #[inline(always)]
+ fn call(s: String) -> u32 {}
+}
diff --git a/ops/op2/test_cases/sync/string_owned.rs b/ops/op2/test_cases/sync/string_owned.rs
new file mode 100644
index 000000000..b81d7ece9
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_owned.rs
@@ -0,0 +1,4 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2(fast)]
+fn op_string_owned(#[string] s: String) -> u32 {}
diff --git a/ops/op2/test_cases/sync/string_ref.out b/ops/op2/test_cases/sync/string_ref.out
new file mode 100644
index 000000000..1b853fccc
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_ref.out
@@ -0,0 +1,75 @@
+#[allow(non_camel_case_types)]
+struct op_string_owned {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_string_owned {
+ const NAME: &'static str = stringify!(op_string_owned);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_string_owned),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ };
+}
+impl op_string_owned {
+ pub const fn name() -> &'static str {
+ stringify!(op_string_owned)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_string_owned),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ 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::SeqOneByteString],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 1usize as u8,
+ }
+ }
+ fn v8_fn_ptr_fast(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ arg0: *mut deno_core::v8::fast_api::FastApiOneByteString,
+ ) -> u32 {
+ let mut arg0_temp: [::std::mem::MaybeUninit<u8>; 1024] = [::std::mem::MaybeUninit::uninit(); 1024];
+ let arg0 = &deno_core::_ops::to_str_ptr(unsafe { &mut *arg0 }, &mut arg0_temp);
+ let result = Self::call(arg0);
+ result
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
+ let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe {
+ &*info
+ });
+ let arg0 = args.get(0usize as i32);
+ let mut arg0_temp: [::std::mem::MaybeUninit<u8>; 1024] = [::std::mem::MaybeUninit::uninit(); 1024];
+ let arg0 = &deno_core::_ops::to_str(scope, &arg0, &mut arg0_temp);
+ let result = Self::call(arg0);
+ rv.set_uint32(result as u32);
+ }
+ #[inline(always)]
+ fn call(s: &str) -> u32 {}
+}
diff --git a/ops/op2/test_cases/sync/string_ref.rs b/ops/op2/test_cases/sync/string_ref.rs
new file mode 100644
index 000000000..a7efa9f0c
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_ref.rs
@@ -0,0 +1,4 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2(fast)]
+fn op_string_owned(#[string] s: &str) -> u32 {}
diff --git a/ops/op2/test_cases/sync/string_return.out b/ops/op2/test_cases/sync/string_return.out
new file mode 100644
index 000000000..5e68b9314
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_return.out
@@ -0,0 +1,49 @@
+#[allow(non_camel_case_types)]
+pub struct op_string_return {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_string_return {
+ const NAME: &'static str = stringify!(op_string_return);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_string_return),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ fast_fn: None,
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 0usize as u8,
+ };
+}
+impl op_string_return {
+ pub const fn name() -> &'static str {
+ stringify!(op_string_return)
+ }
+ pub const fn decl() -> deno_core::_ops::OpDecl {
+ deno_core::_ops::OpDecl {
+ name: stringify!(op_string_return),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ fast_fn: None,
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 0usize as u8,
+ }
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
+ let scope = &mut unsafe { deno_core::v8::CallbackScope::new(&*info) };
+ let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
+ &*info
+ });
+ let result = Self::call();
+ if result.is_empty() {
+ rv.set_empty_string();
+ } else {
+ let temp = deno_core::v8::String::new(scope, &result).unwrap();
+ rv.set(temp.into());
+ }
+ }
+ #[inline(always)]
+ pub fn call() -> String {}
+}
diff --git a/ops/op2/test_cases/sync/string_return.rs b/ops/op2/test_cases/sync/string_return.rs
new file mode 100644
index 000000000..667b68a14
--- /dev/null
+++ b/ops/op2/test_cases/sync/string_return.rs
@@ -0,0 +1,5 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+#[op2]
+#[string]
+pub fn op_string_return() -> String {}