Skip to content

Commit ab1ebfe

Browse files
committed
Inspector session wrapObject wrapper
1 parent f3a9e3d commit ab1ebfe

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/engines/v8/v8.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,31 @@ pub const Inspector = struct {
719719
pub fn send(self: Inspector, env: Env, msg: []const u8) void {
720720
return self.session.dispatchProtocolMessage(env.isolate, msg);
721721
}
722+
723+
// inspector's wrapObject for use in resolveNode. We may extending the interface here to include:
724+
// backendNodeId, objectGroup, executionContextId. For a complete resolveNode implementation at this level.
725+
// node_ptr is expected to be a sub-type of *parser.Node
726+
pub fn wrapObject(self: Inspector, env: *Env, node_ptr: anytype) !v8.RemoteObject {
727+
// Find or bind Native and JS objects together, if it does not already exist
728+
// NOTE: We're not using env.addObject(..) as it registers a named variable at global scope
729+
const T_refl = comptime gen.getType(@TypeOf(node_ptr));
730+
const js_object = try setNativeObject(
731+
env.nat_ctx.alloc,
732+
&env.nat_ctx,
733+
T_refl,
734+
T_refl.value.underT(),
735+
node_ptr,
736+
null,
737+
env.isolate,
738+
env.js_ctx.?,
739+
);
740+
const js_value = js_object.toValue();
741+
742+
// Temporary defaults for which we do not know yet what they are for
743+
const group_name = "AGroupName";
744+
const generate_preview = false;
745+
return self.session.wrapObject(env.isolate, env.js_ctx.?, js_value, group_name, generate_preview);
746+
}
722747
};
723748

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

0 commit comments

Comments
 (0)