diff options
author | 2023-01-12 12:56:54 -0800 | |
---|---|---|
committer | 2023-01-12 13:11:05 -0800 | |
commit | c2b7cadd4f1c431f95bd423b31a9beb7ceee07e8 (patch) | |
tree | fd50ed09a950aae55245c8f20110875e36f42016 | |
parent | 1a4685213b2eec3e5a817b4825c86a5ac8a25b31 (diff) | |
download | bun-c2b7cadd4f1c431f95bd423b31a9beb7ceee07e8.tar.gz bun-c2b7cadd4f1c431f95bd423b31a9beb7ceee07e8.tar.zst bun-c2b7cadd4f1c431f95bd423b31a9beb7ceee07e8.zip |
[bindings] Make `isObject` align with `JSC::isObjectType`
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index b70dd5b54..1bee13fc0 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2484,10 +2484,8 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn isObject(this: JSType) bool { - return switch (this) { - .Object, .FinalObject => true, - else => false, - }; + // inline constexpr bool isObjectType(JSType type) { return type >= ObjectType; } + return @enumToInt(this) >= @enumToInt(JSType.Object); } pub fn isFunction(this: JSType) bool { @@ -2663,7 +2661,7 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn isInstanceOf(this: JSValue, global: *JSGlobalObject, constructor: JSValue) bool { - if (this.isEmptyOrUndefinedOrNull()) + if (!this.isCell()) return false; return JSC.C.JSValueIsInstanceOfConstructor(global, this.asObjectRef(), constructor.asObjectRef(), null); @@ -3112,8 +3110,8 @@ pub const JSValue = enum(JSValueReprInt) { pub fn isCustomGetterSetter(this: JSValue) bool { return cppFn("isCustomGetterSetter", .{this}); } - pub fn isObject(this: JSValue) bool { - return cppFn("isObject", .{this}); + pub inline fn isObject(this: JSValue) bool { + return this.isCell() and this.jsType().isObject(); } pub fn isClass(this: JSValue, global: *JSGlobalObject) bool { |