Skip to content

Commit a4b13a8

Browse files
committed
fix sloppiness
1 parent a6997a7 commit a4b13a8

File tree

2 files changed

+3
-44
lines changed

2 files changed

+3
-44
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: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ pub export fn v8_inspector__Client__IMPL__valueSubtype(
573573
_: *v8.c.InspectorClientImpl,
574574
c_value: *const v8.C_Value,
575575
) callconv(.c) [*c]const u8 {
576-
const external_entry = getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
576+
const external_entry = Inspector.getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
577577
return if (external_entry.subtype) |st| @tagName(st) else null;
578578
}
579579

@@ -590,19 +590,6 @@ pub export fn v8_inspector__Client__IMPL__descriptionForValueSubtype(
590590

591591
// We _must_ include a non-null description in order for the subtype value
592592
// to be included. Besides that, I don't know if the value has any meaning
593-
const external_entry = getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
593+
const external_entry = Inspector.getTaggedAnyOpaque(.{ .handle = c_value }) orelse return null;
594594
return if (external_entry.subtype == null) null else "";
595595
}
596-
597-
fn getTaggedAnyOpaque(value: v8.Value) ?*TaggedAnyOpaque {
598-
if (value.isObject() == false) {
599-
return null;
600-
}
601-
const obj = value.castTo(v8.Object);
602-
if (obj.internalFieldCount() == 0) {
603-
return null;
604-
}
605-
606-
const external_data = obj.getInternalField(0).castTo(v8.External).get().?;
607-
return @ptrCast(@alignCast(external_data));
608-
}

0 commit comments

Comments
 (0)