diff options
| author | Matt Mastracci <matthew@mastracci.com> | 2023-06-29 10:23:14 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-29 10:23:14 -0600 |
| commit | fbb69329343c9985c26181e6297e6556c46d381d (patch) | |
| tree | ee428c94727bdfdf9040a4944bd66981b4cd07fb /ops/op2/test_cases/sync/doc_comment.out | |
| parent | 98df69fd4cbe3687e2ff3519fbd6bff4e5f3101f (diff) | |
refactor(ops): op2 support for generics (#19636)
Implementation of generics for `#[op2]`, along with some refactoring to
improve the ergonomics of ops with generics parameters:
- The ops have generics on the struct rather than the associated
methods, which allows us to trait-ify ops (impossible when they are on
the methods)
- The decl() method can become a trait-associated const field which
unlocks future optimizations
Callers of ops need to switch from:
`op_net_connect_tcp::call::<TestPermission>(conn_state, ip_addr)` to
`op_net_connect_tcp::<TestPermission>::call(conn_state, ip_addr)`.
Diffstat (limited to 'ops/op2/test_cases/sync/doc_comment.out')
| -rw-r--r-- | ops/op2/test_cases/sync/doc_comment.out | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/ops/op2/test_cases/sync/doc_comment.out b/ops/op2/test_cases/sync/doc_comment.out index e9f063102..d7e8005d9 100644 --- a/ops/op2/test_cases/sync/doc_comment.out +++ b/ops/op2/test_cases/sync/doc_comment.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -pub struct op_has_doc_comment {} +pub struct op_has_doc_comment { + _unconstructable: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_has_doc_comment { + const NAME: &'static str = stringify!(op_has_doc_comment); + const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl { + name: stringify!(op_has_doc_comment), + 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], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + }; +} impl op_has_doc_comment { pub const fn name() -> &'static str { stringify!(op_has_doc_comment) @@ -7,7 +30,7 @@ impl op_has_doc_comment { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_has_doc_comment), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_has_doc_comment { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value], CType::Void, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,12 +47,12 @@ impl op_has_doc_comment { arg_count: 0usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { let result = Self::call(); + result } - fn fast_function(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let result = Self::call(); - result } #[inline(always)] pub fn call() -> () {} |
