diff options
| author | Matt Mastracci <matthew@mastracci.com> | 2023-06-24 13:54:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 13:54:10 +0200 |
| commit | 65d9bfb53361bfce6dc594c6a9df92c017dea6cb (patch) | |
| tree | 63886c7225b52444165be3abd53c4e745ca77512 /ops/op2/test_cases/sync/add.out | |
| parent | 8d6dbda90ec0593f3f6e10c6696e320bdff7daa9 (diff) | |
refactor(ops): Adding op2 macro and implementing in a couple of places (#19534)
This is a new op system that will eventually replace `#[op]`.
Features
- More maintainable, generally less-coupled code
- More modern Rust proc-macro libraries
- Enforces correct `fast` labelling for fast ops, allowing for visual
scanning of fast ops
- Explicit marking of `#[string]`, `#[serde]` and `#[smi]` parameters.
This first version of op2 supports integer and Option<integer>
parameters only, and allows us to start working on converting ops and
adding features.
Diffstat (limited to 'ops/op2/test_cases/sync/add.out')
| -rw-r--r-- | ops/op2/test_cases/sync/add.out | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ops/op2/test_cases/sync/add.out b/ops/op2/test_cases/sync/add.out new file mode 100644 index 000000000..a7269c5cf --- /dev/null +++ b/ops/op2/test_cases/sync/add.out @@ -0,0 +1,54 @@ +#[allow(non_camel_case_types)] +struct op_add {} +impl op_add { + pub const fn name() -> &'static str { + stringify!(op_add) + } + pub const fn decl() -> deno_core::_ops::OpDecl { + deno_core::_ops::OpDecl { + name: stringify!(op_add), + v8_fn_ptr: Self::slow_function 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::Uint32, Type::Uint32], + CType::Uint32, + Self::fast_function as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 2usize 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 args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let arg0 = args.get(0usize as i32); + let arg0 = deno_core::_ops::to_u32(&arg0) as _; + let arg1 = args.get(1usize as i32); + let arg1 = deno_core::_ops::to_u32(&arg1) as _; + let result = Self::call(arg0, arg1); + rv.set_uint32(result as u32); + } + fn fast_function( + _: deno_core::v8::Local<deno_core::v8::Object>, + arg0: u32, + arg1: u32, + ) -> u32 { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + } + #[inline(always)] + fn call(a: u32, b: u32) -> u32 { + a + b + } +} |
