Skip to content

Commit 696cc72

Browse files
committed
getValueByObjectId
1 parent 9b87782 commit 696cc72

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/engines/v8/v8.zig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ pub const JSValue = struct {
625625
return error.JSValueTypeNotHandled;
626626
};
627627
}
628+
629+
pub fn externalEntry(self: JSValue) ?*ExternalEntry {
630+
return getExternalEntry(self.value);
631+
}
628632
};
629633

630634
pub const TryCatch = struct {
@@ -750,6 +754,18 @@ pub const Inspector = struct {
750754
const generatePreview = false; // We do not want to expose this as a parameter for now
751755
return self.session.wrapObject(env.isolate, env.js_ctx.?, jsValue, groupName, generatePreview);
752756
}
757+
758+
pub fn getValueByObjectId(self: Inspector, allocator: std.mem.Allocator, objectId: []const u8) !JSValue {
759+
const result = try self.session.unwrapObject(allocator, objectId);
760+
const unwrapped = switch (result) {
761+
.err => |err| {
762+
log.err("Unable to unwrap object {s}: {s}", .{ objectId, if (err) |e| e else "No error message" });
763+
return error.UnwrapObjectFailed;
764+
},
765+
.ok => |value| value,
766+
};
767+
return .{ .value = unwrapped.value }; // The values context and groupId are not used here
768+
}
753769
};
754770

755771
// When we return a Zig instance to V8, we wrap it in a v8.Object. That wrapping

0 commit comments

Comments
 (0)