mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 15:04:33 -05:00
v8::Context::from_snapshot()
This commit is contained in:
parent
bc41fd3b0d
commit
90cd7401de
2 changed files with 25 additions and 0 deletions
|
@ -1682,6 +1682,13 @@ void v8__Context__SetPromiseHooks(v8::Context& self, v8::Function& init_hook,
|
|||
ptr_to_local(&after_hook), ptr_to_local(&resolve_hook));
|
||||
}
|
||||
|
||||
const v8::Context* v8__Context__FromSnapshot(v8::Isolate* isolate,
|
||||
size_t context_snapshot_index) {
|
||||
v8::MaybeLocal<v8::Context> maybe_local = v8::Context::FromSnapshot(
|
||||
isolate, context_snapshot_index);
|
||||
return maybe_local_to_ptr(maybe_local);
|
||||
}
|
||||
|
||||
const v8::String* v8__Message__Get(const v8::Message& self) {
|
||||
return local_to_ptr(self.Get());
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ extern "C" {
|
|||
index: c_int,
|
||||
value: *mut c_void,
|
||||
);
|
||||
fn v8__Context__FromSnapshot(
|
||||
isolate: *mut Isolate,
|
||||
context_snapshot_index: usize,
|
||||
) -> *const Context;
|
||||
}
|
||||
|
||||
impl Context {
|
||||
|
@ -302,6 +306,20 @@ impl Context {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new context from a (non-default) context snapshot. There
|
||||
/// is no way to provide a global object template since we do not create
|
||||
/// a new global object from template, but we can reuse a global object.
|
||||
pub fn from_snapshot<'a>(
|
||||
scope: &'a mut HandleScope,
|
||||
context_snapshot_index: usize,
|
||||
) -> Option<Local<'a, Context>> {
|
||||
unsafe {
|
||||
scope.cast_local(|sd| {
|
||||
v8__Context__FromSnapshot(sd.get_isolate_mut(), context_snapshot_index)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContextAnnex {
|
||||
|
|
Loading…
Reference in a new issue