Skip to content

Commit 432e3c3

Browse files
authored
Merge pull request #1118 from lightpanda-io/inspector_linking
Make sure inspector implementation is always exported
2 parents a60d06a + a4b13a8 commit 432e3c3

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

src/browser/js/Inspector.zig

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,7 @@ const NoopInspector = struct {
111111
pub fn onInspectorEvent(_: *anyopaque, _: []const u8) void {}
112112
};
113113

114-
// This is called from V8. Whenever the v8 inspector has to describe a value
115-
// it'll call this function to gets its [optional] subtype - which, from V8's
116-
// point of view, is an arbitrary string.
117-
pub export fn v8_inspector__Client__IMPL__valueSubtype(
118-
_: *v8.c.InspectorClientImpl,
119-
c_value: *const v8.C_Value,
120-
) callconv(.c) [*c]const u8 {
121-
const external_entry = getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
122-
return if (external_entry.subtype) |st| @tagName(st) else null;
123-
}
124-
125-
// Same as valueSubType above, but for the optional description field.
126-
// From what I can tell, some drivers _need_ the description field to be
127-
// present, even if it's empty. So if we have a subType for the value, we'll
128-
// put an empty description.
129-
pub export fn v8_inspector__Client__IMPL__descriptionForValueSubtype(
130-
_: *v8.c.InspectorClientImpl,
131-
v8_context: *const v8.C_Context,
132-
c_value: *const v8.C_Value,
133-
) callconv(.c) [*c]const u8 {
134-
_ = v8_context;
135-
136-
// We _must_ include a non-null description in order for the subtype value
137-
// to be included. Besides that, I don't know if the value has any meaning
138-
const external_entry = getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
139-
return if (external_entry.subtype == null) null else "";
140-
}
141-
142-
fn getTaggedAnyOpaque(value: v8.Value) ?*js.TaggedAnyOpaque {
114+
pub fn getTaggedAnyOpaque(value: v8.Value) ?*js.TaggedAnyOpaque {
143115
if (value.isObject() == false) {
144116
return null;
145117
}

src/browser/js/js.zig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,3 +562,34 @@ fn debugValueToString(arena: Allocator, js_obj: v8.Object, isolate: v8.Isolate,
562562
}
563563
return arr.items;
564564
}
565+
566+
// These are here, and not in Inspector.zig, because Inspector.zig isn't always
567+
// included (e.g. in the wpt build).
568+
569+
// This is called from V8. Whenever the v8 inspector has to describe a value
570+
// it'll call this function to gets its [optional] subtype - which, from V8's
571+
// point of view, is an arbitrary string.
572+
pub export fn v8_inspector__Client__IMPL__valueSubtype(
573+
_: *v8.c.InspectorClientImpl,
574+
c_value: *const v8.C_Value,
575+
) callconv(.c) [*c]const u8 {
576+
const external_entry = Inspector.getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
577+
return if (external_entry.subtype) |st| @tagName(st) else null;
578+
}
579+
580+
// Same as valueSubType above, but for the optional description field.
581+
// From what I can tell, some drivers _need_ the description field to be
582+
// present, even if it's empty. So if we have a subType for the value, we'll
583+
// put an empty description.
584+
pub export fn v8_inspector__Client__IMPL__descriptionForValueSubtype(
585+
_: *v8.c.InspectorClientImpl,
586+
v8_context: *const v8.C_Context,
587+
c_value: *const v8.C_Value,
588+
) callconv(.c) [*c]const u8 {
589+
_ = v8_context;
590+
591+
// We _must_ include a non-null description in order for the subtype value
592+
// to be included. Besides that, I don't know if the value has any meaning
593+
const external_entry = Inspector.getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
594+
return if (external_entry.subtype == null) null else "";
595+
}

0 commit comments

Comments
 (0)