forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ops): defer mut ref for ops2 scope (denoland#21)
Allows returning from functions that take a HandleScope
- Loading branch information
Showing
17 changed files
with
146 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#[allow(non_camel_case_types)] | ||
pub struct op_void_with_result { | ||
_unconstructable: ::std::marker::PhantomData<()>, | ||
} | ||
impl deno_core::_ops::Op for op_void_with_result { | ||
const NAME: &'static str = stringify!(op_void_with_result); | ||
const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl { | ||
name: stringify!(op_void_with_result), | ||
v8_fn_ptr: Self::v8_fn_ptr as _, | ||
enabled: true, | ||
fast_fn: None, | ||
is_async: false, | ||
is_unstable: false, | ||
is_v8: false, | ||
arg_count: 1usize as u8, | ||
}; | ||
} | ||
impl op_void_with_result { | ||
pub const fn name() -> &'static str { | ||
stringify!(op_void_with_result) | ||
} | ||
pub const fn decl() -> deno_core::_ops::OpDecl { | ||
deno_core::_ops::OpDecl { | ||
name: stringify!(op_void_with_result), | ||
v8_fn_ptr: Self::v8_fn_ptr as _, | ||
enabled: true, | ||
fast_fn: None, | ||
is_async: false, | ||
is_unstable: false, | ||
is_v8: false, | ||
arg_count: 1usize as u8, | ||
} | ||
} | ||
extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { | ||
let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; | ||
let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { | ||
&*info | ||
}); | ||
let arg0 = &mut scope; | ||
let result = Self::call(arg0); | ||
match result { | ||
Ok(result) => {} | ||
Err(err) => { | ||
let opctx = unsafe { | ||
&*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()) | ||
.value() as *const deno_core::_ops::OpCtx) | ||
}; | ||
let opstate = ::std::cell::RefCell::borrow(&*opctx.state); | ||
let exception = deno_core::error::to_v8_error( | ||
&mut scope, | ||
opstate.get_error_class_fn, | ||
&err, | ||
); | ||
scope.throw_exception(exception); | ||
return; | ||
} | ||
}; | ||
} | ||
#[inline(always)] | ||
pub fn call(scope: &mut v8::HandleScope) -> Result<(), AnyError> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
#[op2] | ||
pub fn op_void_with_result(scope: &mut v8::HandleScope) -> Result<(), AnyError> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.