mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-24 15:19:31 -05:00
feat: add Context::get_extras_binding_object (#975)
This commit is contained in:
parent
9b1bb41d86
commit
5f90045ad0
3 changed files with 27 additions and 0 deletions
|
@ -1602,6 +1602,10 @@ const v8::Data* v8__Context__GetDataFromSnapshotOnce(v8::Context& self,
|
||||||
ptr_to_local(&self)->GetDataFromSnapshotOnce<v8::Data>(index));
|
ptr_to_local(&self)->GetDataFromSnapshotOnce<v8::Data>(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const v8::Object* v8__Context__GetExtrasBindingObject(v8::Context& self) {
|
||||||
|
return local_to_ptr(ptr_to_local(&self)->GetExtrasBindingObject());
|
||||||
|
}
|
||||||
|
|
||||||
void v8__Context__SetPromiseHooks(v8::Context& self, v8::Function& init_hook,
|
void v8__Context__SetPromiseHooks(v8::Context& self, v8::Function& init_hook,
|
||||||
v8::Function& before_hook,
|
v8::Function& before_hook,
|
||||||
v8::Function& after_hook,
|
v8::Function& after_hook,
|
||||||
|
|
|
@ -25,6 +25,8 @@ extern "C" {
|
||||||
) -> *const Context;
|
) -> *const Context;
|
||||||
fn v8__Context__GetIsolate(this: *const Context) -> *mut Isolate;
|
fn v8__Context__GetIsolate(this: *const Context) -> *mut Isolate;
|
||||||
fn v8__Context__Global(this: *const Context) -> *const Object;
|
fn v8__Context__Global(this: *const Context) -> *const Object;
|
||||||
|
fn v8__Context__GetExtrasBindingObject(this: *const Context)
|
||||||
|
-> *const Object;
|
||||||
fn v8__Context__SetPromiseHooks(
|
fn v8__Context__SetPromiseHooks(
|
||||||
this: *const Context,
|
this: *const Context,
|
||||||
init_hook: *const Function,
|
init_hook: *const Function,
|
||||||
|
@ -71,6 +73,14 @@ impl Context {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_extras_binding_object<'s>(
|
||||||
|
&self,
|
||||||
|
scope: &mut HandleScope<'s, ()>,
|
||||||
|
) -> Local<'s, Object> {
|
||||||
|
unsafe { scope.cast_local(|_| v8__Context__GetExtrasBindingObject(self)) }
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the global proxy object.
|
/// Returns the global proxy object.
|
||||||
///
|
///
|
||||||
/// Global proxy object is a thin wrapper whose prototype points to actual
|
/// Global proxy object is a thin wrapper whose prototype points to actual
|
||||||
|
|
|
@ -2582,6 +2582,19 @@ fn promise_hook() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn context_get_extras_binding_object() {
|
||||||
|
let _setup_guard = setup();
|
||||||
|
let isolate = &mut v8::Isolate::new(Default::default());
|
||||||
|
{
|
||||||
|
let scope = &mut v8::HandleScope::new(isolate);
|
||||||
|
let context = v8::Context::new(scope);
|
||||||
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
|
let extras_binding = context.get_extras_binding_object(scope);
|
||||||
|
assert!(extras_binding.is_object());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn context_promise_hooks() {
|
fn context_promise_hooks() {
|
||||||
let _setup_guard = setup();
|
let _setup_guard = setup();
|
||||||
|
|
Loading…
Reference in a new issue