0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-24 00:00:06 -05:00

Add binding for Isolate::get_entered_or_microtask_context() (#245)

A test will be added later.
This commit is contained in:
Bert Belder 2020-01-22 23:34:02 +01:00
parent 2286052468
commit 5e55cc5a5c
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
2 changed files with 19 additions and 0 deletions

View file

@ -114,6 +114,10 @@ v8::Context* v8__Isolate__GetCurrentContext(v8::Isolate* isolate) {
return local_to_ptr(isolate->GetCurrentContext());
}
v8::Context* v8__Isolate__GetEnteredOrMicrotaskContext(v8::Isolate* isolate) {
return local_to_ptr(isolate->GetEnteredOrMicrotaskContext());
}
void v8__Isolate__SetData(v8::Isolate* isolate, uint32_t slot, void* data) {
isolate->SetData(slot, data);
}

View file

@ -73,6 +73,9 @@ extern "C" {
fn v8__Isolate__Enter(this: *mut Isolate);
fn v8__Isolate__Exit(this: *mut Isolate);
fn v8__Isolate__GetCurrentContext(this: *mut Isolate) -> *mut Context;
fn v8__Isolate__GetEnteredOrMicrotaskContext(
this: *mut Isolate,
) -> *mut Context;
fn v8__Isolate__SetCaptureStackTraceForUncaughtExceptions(
this: *mut Isolate,
caputre: bool,
@ -197,6 +200,18 @@ impl Isolate {
unsafe { Local::from_raw(v8__Isolate__GetCurrentContext(self)).unwrap() }
}
/// Returns either the last context entered through V8's C++ API, or the
/// context of the currently running microtask while processing microtasks.
/// If a context is entered while executing a microtask, that context is
/// returned.
pub fn get_entered_or_microtask_context<'sc>(
&mut self,
) -> Local<'sc, Context> {
unsafe {
Local::from_raw(v8__Isolate__GetEnteredOrMicrotaskContext(self)).unwrap()
}
}
/// Tells V8 to capture current stack trace when uncaught exception occurs
/// and report it to the message listeners. The option is off by default.
pub fn set_capture_stack_trace_for_uncaught_exceptions(