From 6ca68cab65bfb7eb41feb2b02a732cc2289fbf9c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 5 Oct 2024 03:37:24 -0700 Subject: [PATCH] Update JSType (#14373) --- src/bun.js/ConsoleObject.zig | 17 +++++--- src/bun.js/base.zig | 2 +- src/bun.js/bindings/bindings.zig | 65 ++++++++++++++++--------------- src/bun.js/bindings/headers.zig | 8 ++-- src/bun.js/test/pretty_format.zig | 8 ++-- 5 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index b58cee7c92..8ad8ec525a 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -1138,13 +1138,18 @@ pub const Formatter = struct { .Symbol => .Symbol, .BooleanObject => .Boolean, .JSFunction => .Function, - .JSWeakMap, JSValue.JSType.JSMap => .Map, - .JSMapIterator => .MapIterator, - .JSSetIterator => .SetIterator, - .JSWeakSet, JSValue.JSType.JSSet => .Set, + .WeakMap, JSValue.JSType.Map => .Map, + .MapIterator => .MapIterator, + .SetIterator => .SetIterator, + .WeakSet, JSValue.JSType.Set => .Set, .JSDate => .JSON, .JSPromise => .Promise, + .WrapForValidIterator, + .RegExpStringIterator, + .JSArrayIterator, + .Iterator, + .IteratorHelper, .Object, .FinalObject, .ModuleNamespaceObject, @@ -2433,7 +2438,7 @@ pub const Formatter = struct { this.quote_strings = true; defer this.quote_strings = prev_quote_strings; - const map_name = if (value.jsType() == .JSWeakMap) "WeakMap" else "Map"; + const map_name = if (value.jsType() == .WeakMap) "WeakMap" else "Map"; if (length == 0) { return writer.print("{s} {{}}", .{map_name}); @@ -2541,7 +2546,7 @@ pub const Formatter = struct { this.writeIndent(Writer, writer_) catch {}; } - const set_name = if (value.jsType() == .JSWeakSet) "WeakSet" else "Set"; + const set_name = if (value.jsType() == .WeakSet) "WeakSet" else "Set"; if (length == 0) { return writer.print("{s} {{}}", .{set_name}); diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 5eeb82f129..d479887025 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -877,7 +877,7 @@ pub const DOMEffect = struct { JSMapFields, JSSetFields, JSWeakMapFields, - JSWeakSetFields, + WeakSetFields, JSInternalFields, InternalState, CatchLocals, diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 05d33b594a..ed9adccbe2 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -3628,7 +3628,7 @@ pub const JSMap = opaque { } pub fn fromJS(value: JSValue) ?*JSMap { - if (value.jsTypeLoose() == .JSMap) { + if (value.jsTypeLoose() == .Map) { return bun.cast(*JSMap, value.asEncoded().asPtr.?); } @@ -3728,26 +3728,27 @@ pub const JSValue = enum(JSValueReprInt) { RegExpObject = 60, JSDate = 61, ProxyObject = 62, - JSGenerator = 63, - JSAsyncGenerator = 64, + Generator = 63, + AsyncGenerator = 64, JSArrayIterator = 65, - JSIterator = 66, - JSMapIterator = 67, - JSSetIterator = 68, - JSStringIterator = 69, - JSWrapForValidIterator = 70, - JSRegExpStringIterator = 71, - JSPromise = 72, - JSMap = 73, - JSSet = 74, - JSWeakMap = 75, - JSWeakSet = 76, - WebAssemblyModule = 77, - WebAssemblyInstance = 78, - WebAssemblyGCObject = 79, - StringObject = 80, - DerivedStringObject = 81, - InternalFieldTuple = 82, + Iterator = 66, + IteratorHelper = 67, + MapIterator = 68, + SetIterator = 69, + StringIterator = 70, + WrapForValidIterator = 71, + RegExpStringIterator = 72, + JSPromise = 73, + Map = 74, + Set = 75, + WeakMap = 76, + WeakSet = 77, + WebAssemblyModule = 78, + WebAssemblyInstance = 79, + WebAssemblyGCObject = 80, + StringObject = 81, + DerivedStringObject = 82, + InternalFieldTuple = 83, MaxJS = 0b11111111, Event = 0b11101111, @@ -3785,18 +3786,20 @@ pub const JSValue = enum(JSValueReprInt) { .Int8Array, .InternalFunction, .JSArrayIterator, - .JSAsyncGenerator, + .AsyncGenerator, .JSDate, .JSFunction, - .JSGenerator, - .JSMap, - .JSMapIterator, + .Generator, + .Map, + .MapIterator, .JSPromise, - .JSSet, - .JSSetIterator, - .JSStringIterator, - .JSWeakMap, - .JSWeakSet, + .Set, + .SetIterator, + .IteratorHelper, + .Iterator, + .StringIterator, + .WeakMap, + .WeakSet, .ModuleNamespaceObject, .NumberObject, .Object, @@ -3946,14 +3949,14 @@ pub const JSValue = enum(JSValueReprInt) { pub inline fn isSet(this: JSType) bool { return switch (this) { - .JSSet, .JSWeakSet => true, + .Set, .WeakSet => true, else => false, }; } pub inline fn isMap(this: JSType) bool { return switch (this) { - .JSMap, .JSWeakMap => true, + .Map, .WeakMap => true, else => false, }; } diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 3b64ff6905..ec358ceb3e 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -187,10 +187,10 @@ pub extern fn JSC__JSGlobalObject__reload(arg0: *bindings.JSGlobalObject) void; pub extern fn JSC__JSGlobalObject__startRemoteInspector(arg0: *bindings.JSGlobalObject, arg1: [*c]u8, arg2: u16) bool; pub extern fn JSC__JSGlobalObject__vm(arg0: *bindings.JSGlobalObject) *bindings.VM; pub extern fn JSC__JSMap__create(arg0: *bindings.JSGlobalObject) JSC__JSValue; -pub extern fn JSC__JSMap__get_(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue; -pub extern fn JSC__JSMap__has(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool; -pub extern fn JSC__JSMap__remove(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool; -pub extern fn JSC__JSMap__set(arg0: ?*bindings.JSMap, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void; +pub extern fn JSC__JSMap__get_(arg0: ?*bindings.Map, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) JSC__JSValue; +pub extern fn JSC__JSMap__has(arg0: ?*bindings.Map, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool; +pub extern fn JSC__JSMap__remove(arg0: ?*bindings.Map, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) bool; +pub extern fn JSC__JSMap__set(arg0: ?*bindings.Map, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue) void; pub extern fn JSC__JSValue___then(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue, ArgFn3: ?bun.JSC.JSHostFunctionPtr, ArgFn4: ?bun.JSC.JSHostFunctionPtr) void; pub extern fn JSC__JSValue__asArrayBuffer_(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, arg2: ?*Bun__ArrayBuffer) bool; pub extern fn JSC__JSValue__asBigIntCompare(JSValue0: JSC__JSValue, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) u8; diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index 501709db4f..c1a838ce1b 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -463,8 +463,8 @@ pub const JestPrettyFormat = struct { .Symbol => .Symbol, .BooleanObject => .Boolean, .JSFunction => .Function, - .JSWeakMap, .JSMap => .Map, - .JSWeakSet, .JSSet => .Set, + .WeakMap, .Map => .Map, + .WeakSet, .Set => .Set, .JSDate => .JSON, .JSPromise => .Promise, .Object, @@ -1317,7 +1317,7 @@ pub const JestPrettyFormat = struct { this.quote_strings = true; defer this.quote_strings = prev_quote_strings; - const map_name = if (value.jsType() == .JSWeakMap) "WeakMap" else "Map"; + const map_name = if (value.jsType() == .WeakMap) "WeakMap" else "Map"; if (length == 0) { return writer.print("{s} {{}}", .{map_name}); @@ -1347,7 +1347,7 @@ pub const JestPrettyFormat = struct { this.writeIndent(Writer, writer_) catch {}; - const set_name = if (value.jsType() == .JSWeakSet) "WeakSet" else "Set"; + const set_name = if (value.jsType() == .WeakSet) "WeakSet" else "Set"; if (length == 0) { return writer.print("{s} {{}}", .{set_name});