mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
feat(ops): support v8::FastApiCallbackOptions
(#15721)
This commit is contained in:
parent
cbd8307710
commit
805ce6fdf7
5 changed files with 72 additions and 11 deletions
11
ops/tests/01_fast_callback_options.rs
Normal file
11
ops/tests/01_fast_callback_options.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use deno_core::v8::fast_api::FastApiCallbackOptions;
|
||||
use deno_ops::op;
|
||||
|
||||
#[op(fast)]
|
||||
fn op_fallback(options: Option<&mut FastApiCallbackOptions>) {
|
||||
if let Some(options) = options {
|
||||
options.fallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -17,6 +17,13 @@ fn op_u16_arg(a: u16, b: u16) {
|
|||
//
|
||||
}
|
||||
|
||||
use deno_core::v8::fast_api::FastApiCallbackOptions;
|
||||
|
||||
#[op(fast)]
|
||||
fn op_callback_options(options: &mut FastApiCallbackOptions) {
|
||||
// fast callback options must be an Option.
|
||||
}
|
||||
|
||||
#[op(fast)]
|
||||
async fn op_async_fn(a: i32, b: i32) -> i32 {
|
||||
a + b
|
||||
|
|
|
@ -23,9 +23,25 @@ error: custom attribute panicked
|
|||
= help: message: op cannot be a fast api. enforced by #[op(fast)]
|
||||
|
||||
error: custom attribute panicked
|
||||
--> tests/compile_fail/unsupported.rs:20:1
|
||||
--> tests/compile_fail/unsupported.rs:22:1
|
||||
|
|
||||
20 | #[op(fast)]
|
||||
22 | #[op(fast)]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: message: op cannot be a fast api. enforced by #[op(fast)]
|
||||
|
||||
error: custom attribute panicked
|
||||
--> tests/compile_fail/unsupported.rs:27:1
|
||||
|
|
||||
27 | #[op(fast)]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: message: async op cannot be a fast api. enforced by #[op(fast)]
|
||||
|
||||
warning: unused import: `deno_core::v8::fast_api::FastApiCallbackOptions`
|
||||
--> tests/compile_fail/unsupported.rs:20:5
|
||||
|
|
||||
20 | use deno_core::v8::fast_api::FastApiCallbackOptions;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
fn op_macro() {
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/compile_fail/*.rs");
|
||||
t.pass("tests/01_fast_callback_options.rs");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue