Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v8::Context::set_embedder_data #1443

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/binding.cc
Expand Up @@ -1853,6 +1853,11 @@ void v8__Context__SetAlignedPointerInEmbedderData(v8::Context& self, int index,
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,
size_t index) {
return maybe_local_to_ptr(
Expand Down
9 changes: 9 additions & 0 deletions src/context.rs
Expand Up @@ -37,6 +37,11 @@ extern "C" {
index: int,
value: *mut c_void,
);
fn v8__Context__SetEmbedderData(
this: *const Context,
slot: int,
data: *const Value,
);
fn v8__Context__FromSnapshot(
isolate: *mut Isolate,
context_snapshot_index: usize,
Expand Down Expand Up @@ -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)]
pub fn get_aligned_pointer_from_embedder_data(
&self,
Expand Down