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/generator_state.rs | |
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/generator_state.rs')
-rw-r--r-- | ops/op2/generator_state.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ops/op2/generator_state.rs b/ops/op2/generator_state.rs new file mode 100644 index 000000000..741d4f7f3 --- /dev/null +++ b/ops/op2/generator_state.rs @@ -0,0 +1,32 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +use proc_macro2::Ident; +use proc_macro2::TokenStream; + +pub struct GeneratorState { + /// The path to the `deno_core` crate (either `deno_core` or `crate`, the latter used if the op is `(core)`). + pub deno_core: TokenStream, + + /// Identifiers for each of the arguments of the original function + pub args: Vec<Ident>, + /// The new identifier for the original function's contents. + pub call: Ident, + /// The result of the `call` function + pub result: Ident, + + /// The `v8::CallbackScope` used if necessary for the function. + pub scope: Ident, + /// The `v8::FunctionCallbackInfo` used to pass args into the slow function. + pub info: Ident, + /// The `v8::FunctionCallbackArguments` used to pass args into the slow function. + pub fn_args: Ident, + /// The `v8::ReturnValue` used in the slow function + pub retval: Ident, + /// The "slow" function (ie: the one that isn't a fastcall) + pub slow_function: Ident, + /// The "fast" function (ie: a fastcall) + pub fast_function: Ident, + + pub needs_args: bool, + pub needs_retval: bool, + pub needs_scope: bool, +} |