0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

Add v8::Context::set_embedder_data

This commit is contained in:
Divy Srivastava 2024-03-18 18:09:53 +05:30
parent 89fbf2a051
commit 2bca1d89bf
2 changed files with 14 additions and 0 deletions

View file

@ -1853,6 +1853,11 @@ void v8__Context__SetAlignedPointerInEmbedderData(v8::Context& self, int index,
ptr_to_local(&self)->SetAlignedPointerInEmbedderData(index, value); ptr_to_local(&self)->SetAlignedPointerInEmbedderData(index, value);
} }
void v8__Context__SetEmbedderData(v8::Context& self, int index,
const v8::Value* value) {
ptr_to_local(&self)->SetEmbedderData(index, ptr_to_local(value));
}
const v8::Data* v8__Context__GetDataFromSnapshotOnce(v8::Context& self, const v8::Data* v8__Context__GetDataFromSnapshotOnce(v8::Context& self,
size_t index) { size_t index) {
return maybe_local_to_ptr( return maybe_local_to_ptr(

View file

@ -37,6 +37,11 @@ extern "C" {
index: int, index: int,
value: *mut c_void, value: *mut c_void,
); );
fn v8__Context__SetEmbedderData(
this: *const Context,
slot: int,
data: *const Value,
);
fn v8__Context__FromSnapshot( fn v8__Context__FromSnapshot(
isolate: *mut Isolate, isolate: *mut Isolate,
context_snapshot_index: usize, context_snapshot_index: usize,
@ -329,6 +334,10 @@ impl Context {
) )
} }
pub fn set_embedder_data(&self, slot: i32, data: Local<Value>) {
unsafe { v8__Context__SetEmbedderData(self, slot, &*data) }
}
#[inline(always)] #[inline(always)]
pub fn get_aligned_pointer_from_embedder_data( pub fn get_aligned_pointer_from_embedder_data(
&self, &self,