feat(ops): support v8::FastApiCallbackOptions (#15721)

This commit is contained in:
Divy Srivastava 2022-09-01 15:53:06 +05:30 committed by GitHub
parent cbd8307710
commit 805ce6fdf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 11 deletions

View 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() {}

View file

@ -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

View file

@ -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

View file

@ -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");
}