Skip to content

Commit 1afd9fb

Browse files
Merge pull request #34 from lightpanda-io/isolate-data
expose Isolate.SetData and Isolate.GetData
2 parents f4f09f2 + c3d2abc commit 1afd9fb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/binding.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ void v8__Isolate__GetHeapStatistics(
257257
self->GetHeapStatistics(stats);
258258
}
259259

260+
void* v8__Isolate__GetData(v8::Isolate* self, int idx) {
261+
return self->GetData(idx);
262+
}
263+
264+
void v8__Isolate__SetData(v8::Isolate* self, int idx, void* val) {
265+
self->SetData(idx, val);
266+
}
267+
260268
size_t v8__HeapStatistics__SIZEOF() {
261269
return sizeof(v8::HeapStatistics);
262270
}

src/binding.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ void v8__Isolate__GetHeapStatistics(
188188
Isolate* self,
189189
HeapStatistics* stats);
190190
usize v8__HeapStatistics__SIZEOF();
191+
void* v8__Isolate__GetData(Isolate* self, int idx);
192+
void v8__Isolate__SetData(Isolate* self, int idx, void* val);
191193

192194
typedef struct StartupData {
193195
const char* data;

src/v8.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ pub const Isolate = struct {
413413
pub fn initExternal(self: Self, val: ?*anyopaque) External {
414414
return External.init(self, val);
415415
}
416+
417+
pub fn setData(self: Self, idx: u32, val: *anyopaque) void {
418+
return c.v8__Isolate__SetData(self.handle, @as(c_int, @intCast(idx)), val);
419+
}
420+
421+
pub fn getData(self: Self, idx: u32) ?*anyopaque {
422+
return c.v8__Isolate__GetData(self.handle, @as(c_int, @intCast(idx)));
423+
}
416424
};
417425

418426
pub const HandleScope = struct {

0 commit comments

Comments
 (0)