diff options
author | 2022-03-16 08:48:58 -0700 | |
---|---|---|
committer | 2022-03-16 08:49:16 -0700 | |
commit | 89fb624c5be2ac64a01570fff106f7f5e386473a (patch) | |
tree | 6dbd3487abe637eaa356f40039cae1acbce81595 | |
parent | 6bcaa337511928521a2ec82e4703f331194e79ff (diff) | |
download | bun-89fb624c5be2ac64a01570fff106f7f5e386473a.tar.gz bun-89fb624c5be2ac64a01570fff106f7f5e386473a.tar.zst bun-89fb624c5be2ac64a01570fff106f7f5e386473a.zip |
Fix crash from checking if something is an object when it is undefinedbun-v0.0.72
-rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 14 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers-cpp.h | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.h | 5 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.zig | 3 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index ed83e6e14..438c64967 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -1865,6 +1865,9 @@ pub const JSValue = enum(u64) { } pub fn as(value: JSValue, comptime ZigType: type) ?*ZigType { + if (value.isUndefinedOrNull()) + return null; + return JSC.GetJSPrivateData(ZigType, value.asObjectRef()); } @@ -1977,13 +1980,16 @@ pub const JSValue = enum(u64) { } pub fn isUndefined(this: JSValue) bool { - return cppFn("isUndefined", .{this}); + return @enumToInt(this) == 0xa; } pub fn isNull(this: JSValue) bool { - return cppFn("isNull", .{this}); + return @enumToInt(this) == 0x2; } pub fn isUndefinedOrNull(this: JSValue) bool { - return cppFn("isUndefinedOrNull", .{this}); + return switch (@enumToInt(this)) { + 0xa, 0x2 => true, + else => false, + }; } pub fn isBoolean(this: JSValue) bool { return cppFn("isBoolean", .{this}); @@ -2285,7 +2291,7 @@ pub const JSValue = enum(u64) { return @intToPtr(*anyopaque, @enumToInt(this)); } - pub const Extern = [_][]const u8{ "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" }; + pub const Extern = [_][]const u8{ "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" }; }; extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void; diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index c40eb5c36..3c71807ab 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1647432636 +//-- AUTOGENERATED FILE -- 1647445628 // clang-format off #pragma once diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index d4560f9ac..ba6fee8dc 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format: off -//-- AUTOGENERATED FILE -- 1647432636 +//-- AUTOGENERATED FILE -- 1647445628 #pragma once #include <stddef.h> @@ -467,7 +467,6 @@ CPP_DECL bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isInt32(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isIterable(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL bool JSC__JSValue__isNull(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isNumber(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isObject(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0); @@ -476,8 +475,6 @@ CPP_DECL bool JSC__JSValue__isString(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isTerminationException(JSC__JSValue JSValue0, JSC__VM* arg1); CPP_DECL bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0); -CPP_DECL bool JSC__JSValue__isUndefined(JSC__JSValue JSValue0); -CPP_DECL bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0); CPP_DECL JSC__JSValue JSC__JSValue__jsBoolean(bool arg0); CPP_DECL JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0); CPP_DECL JSC__JSValue JSC__JSValue__jsNull(); diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig index 992313209..c1ebc75f3 100644 --- a/src/javascript/jsc/bindings/headers.zig +++ b/src/javascript/jsc/bindings/headers.zig @@ -315,7 +315,6 @@ pub extern fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isInt32(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isIterable(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bool; -pub extern fn JSC__JSValue__isNull(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isNumber(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isObject(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isPrimitive(JSValue0: JSC__JSValue) bool; @@ -324,8 +323,6 @@ pub extern fn JSC__JSValue__isString(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isSymbol(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isTerminationException(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool; pub extern fn JSC__JSValue__isUInt32AsAnyInt(JSValue0: JSC__JSValue) bool; -pub extern fn JSC__JSValue__isUndefined(JSValue0: JSC__JSValue) bool; -pub extern fn JSC__JSValue__isUndefinedOrNull(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__jsBoolean(arg0: bool) JSC__JSValue; pub extern fn JSC__JSValue__jsDoubleNumber(arg0: f64) JSC__JSValue; pub extern fn JSC__JSValue__jsNull(...) JSC__JSValue; |