diff --git a/misctools/cold-jsc-start.cpp b/misctools/cold-jsc-start.cpp index cc1a25c257..15f9789cbf 100644 --- a/misctools/cold-jsc-start.cpp +++ b/misctools/cold-jsc-start.cpp @@ -40,7 +40,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionWrite, (JSC::JSGlobalObject * globalObject, int32_t fd = STDOUT_FILENO; if (callframe->argumentCount() > 1) { fd = arg1.toInt32(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } else { toWriteArg = arg1; } @@ -53,7 +53,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionWrite, (JSC::JSGlobalObject * globalObject, } auto string = toWriteArg.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto utf8 = string.utf8(); auto length = utf8.length(); auto written = write(fd, utf8.data(), length); diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp index 46976c1f9b..43f5b4e47e 100644 --- a/src/bun.js/bindings/BunObject.cpp +++ b/src/bun.js/bindings/BunObject.cpp @@ -81,7 +81,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr auto array = JSC::jsDynamicCast(arrayValue); if (UNLIKELY(!array)) { throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t arrayLength = array->length(); @@ -111,7 +111,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr args.ensureCapacity(arrayLength); if (UNLIKELY(args.hasOverflowed())) { throwOutOfMemoryError(lexicalGlobalObject, throwScope); - return JSValue::encode({}); + return {}; } for (size_t i = 0; i < arrayLength; i++) { @@ -121,7 +121,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr if (auto* typedArray = JSC::jsDynamicCast(element)) { if (UNLIKELY(typedArray->isDetached())) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t current = typedArray->byteLength(); any_typed = true; @@ -134,7 +134,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr auto* impl = arrayBuffer->impl(); if (UNLIKELY(!impl)) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t current = impl->byteLength(); @@ -147,7 +147,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr byteLength += current; } else { throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s); - return JSValue::encode(jsUndefined()); + return {}; } } byteLength = std::min(byteLength, maxLength); @@ -159,7 +159,7 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Arr auto buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1); if (UNLIKELY(!buffer)) { throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t remain = byteLength; @@ -219,7 +219,7 @@ JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObje if (UNLIKELY(callFrame->argumentCount() < 1)) { throwTypeError(globalObject, throwScope, "Expected at least one argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto arrayValue = callFrame->uncheckedArgument(0); @@ -394,7 +394,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBunSleep, if (!millisecondsValue.isNumber()) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); JSC::throwTypeError(globalObject, scope, "sleep expects a number (milliseconds)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure()); @@ -443,7 +443,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, if (callFrame->argumentCount() < 2) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue arg1 = callFrame->uncheckedArgument(0); @@ -475,7 +475,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, J if (callFrame->argumentCount() < 2) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue subset = callFrame->uncheckedArgument(0); @@ -484,7 +484,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, J if (!subset.isObject() || !object.isObject()) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected 2 objects to match"_s); - return JSValue::encode(jsUndefined()); + return {}; } bool match = Bun__deepMatch(object, subset, globalObject, &scope, false, false); @@ -528,10 +528,10 @@ JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObj if (!domURL) { if (arg0.isString()) { url = WTF::URL(arg0.toWTFString(globalObject)); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } else { throwTypeError(globalObject, scope, "Argument must be a URL"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { url = domURL->href(); @@ -539,7 +539,7 @@ JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObj if (UNLIKELY(!url.protocolIsFile())) { throwTypeError(globalObject, scope, "Argument must be a file URL"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto fileSystemPath = url.fileSystemPath(); @@ -547,7 +547,7 @@ JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObj #if OS(WINDOWS) if (!isAbsolutePath(fileSystemPath)) { throwTypeError(globalObject, scope, "File URL path must be absolute"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } #endif diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp index 8570bce362..3f7386e7ba 100644 --- a/src/bun.js/bindings/BunPlugin.cpp +++ b/src/bun.js/bindings/BunPlugin.cpp @@ -50,11 +50,11 @@ static JSC::EncodedJSValue jsFunctionAppendOnLoadPluginBody(JSC::JSGlobalObject* if (callframe->argumentCount() < 2) { throwException(globalObject, scope, createError(globalObject, "onLoad() requires at least 2 arguments"_s)); - return JSValue::encode(jsUndefined()); + return {}; } auto* filterObject = callframe->uncheckedArgument(0).toObject(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); JSC::RegExpObject* filter = nullptr; if (JSValue filterValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "filter"_s))) { if (filterValue.isCell() && filterValue.asCell()->inherits()) @@ -63,28 +63,28 @@ static JSC::EncodedJSValue jsFunctionAppendOnLoadPluginBody(JSC::JSGlobalObject* if (!filter) { throwException(globalObject, scope, createError(globalObject, "onLoad() expects first argument to be an object with a filter RegExp"_s)); - return JSValue::encode(jsUndefined()); + return {}; } String namespaceString = String(); if (JSValue namespaceValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "namespace"_s))) { if (namespaceValue.isString()) { namespaceString = namespaceValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!isValidNamespaceString(namespaceString)) { throwException(globalObject, scope, createError(globalObject, "namespace can only contain letters, numbers, dashes, or underscores"_s)); - return JSValue::encode(jsUndefined()); + return {}; } } - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } auto func = callframe->uncheckedArgument(1); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!func.isCell() || !func.isCallable()) { throwException(globalObject, scope, createError(globalObject, "onLoad() expects second argument to be a function"_s)); - return JSValue::encode(jsUndefined()); + return {}; } plugin.append(vm, filter->regExp(), jsCast(func), namespaceString); @@ -100,7 +100,7 @@ static EncodedJSValue jsFunctionAppendVirtualModulePluginBody(JSC::JSGlobalObjec if (callframe->argumentCount() < 2) { throwException(globalObject, scope, createError(globalObject, "module() needs 2 arguments: a module ID and a function to call"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSValue moduleIdValue = callframe->uncheckedArgument(0); @@ -108,30 +108,30 @@ static EncodedJSValue jsFunctionAppendVirtualModulePluginBody(JSC::JSGlobalObjec if (!moduleIdValue.isString()) { throwException(globalObject, scope, createError(globalObject, "module() expects first argument to be a string for the module ID"_s)); - return JSValue::encode(jsUndefined()); + return {}; } if (!functionValue.isCallable()) { throwException(globalObject, scope, createError(globalObject, "module() expects second argument to be a function"_s)); - return JSValue::encode(jsUndefined()); + return {}; } String moduleId = moduleIdValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (moduleId.isEmpty()) { throwException(globalObject, scope, createError(globalObject, "virtual module cannot be blank"_s)); - return JSValue::encode(jsUndefined()); + return {}; } if (Bun::isBuiltinModule(moduleId)) { throwException(globalObject, scope, createError(globalObject, makeString("module() cannot be used to override builtin module \""_s, moduleId, "\""_s))); - return JSValue::encode(jsUndefined()); + return {}; } if (moduleId.startsWith("."_s)) { throwException(globalObject, scope, createError(globalObject, "virtual module cannot start with \".\""_s)); - return JSValue::encode(jsUndefined()); + return {}; } Zig::GlobalObject* global = defaultGlobalObject(globalObject); @@ -156,11 +156,11 @@ static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginBody(JSC::JSGlobalObje if (callframe->argumentCount() < 2) { throwException(globalObject, scope, createError(globalObject, "onResolve() requires at least 2 arguments"_s)); - return JSValue::encode(jsUndefined()); + return {}; } auto* filterObject = callframe->uncheckedArgument(0).toObject(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); JSC::RegExpObject* filter = nullptr; if (JSValue filterValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "filter"_s))) { if (filterValue.isCell() && filterValue.asCell()->inherits()) @@ -169,29 +169,29 @@ static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginBody(JSC::JSGlobalObje if (!filter) { throwException(globalObject, scope, createError(globalObject, "onResolve() expects first argument to be an object with a filter RegExp"_s)); - return JSValue::encode(jsUndefined()); + return {}; } String namespaceString = String(); if (JSValue namespaceValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "namespace"_s))) { if (namespaceValue.isString()) { namespaceString = namespaceValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!isValidNamespaceString(namespaceString)) { throwException(globalObject, scope, createError(globalObject, "namespace can only contain letters, numbers, dashes, or underscores"_s)); - return JSValue::encode(jsUndefined()); + return {}; } } - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } auto func = callframe->uncheckedArgument(1); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!func.isCell() || !func.isCallable()) { throwException(globalObject, scope, createError(globalObject, "onResolve() expects second argument to be a function"_s)); - return JSValue::encode(jsUndefined()); + return {}; } plugin.append(vm, filter->regExp(), jsCast(func), namespaceString); @@ -259,20 +259,22 @@ static inline JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObje auto throwScope = DECLARE_THROW_SCOPE(vm); if (callframe->argumentCount() < 1) { JSC::throwTypeError(globalObject, throwScope, "plugin needs at least one argument (an object)"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSObject* obj = callframe->uncheckedArgument(0).getObject(); if (!obj) { JSC::throwTypeError(globalObject, throwScope, "plugin needs an object as first argument"_s); + return {}; } RETURN_IF_EXCEPTION(throwScope, {}); JSC::JSValue setupFunctionValue = obj->getIfPropertyExists(globalObject, Identifier::fromString(vm, "setup"_s)); + RETURN_IF_EXCEPTION(throwScope, {}); if (!setupFunctionValue || setupFunctionValue.isUndefinedOrNull() || !setupFunctionValue.isCell() || !setupFunctionValue.isCallable()) { JSC::throwTypeError(globalObject, throwScope, "plugin needs a setup() function"_s); + return {}; } - RETURN_IF_EXCEPTION(throwScope, {}); if (JSValue targetValue = obj->getIfPropertyExists(globalObject, Identifier::fromString(vm, "target"_s))) { if (auto* targetJSString = targetValue.toStringOrNull(globalObject)) { @@ -323,7 +325,7 @@ static inline JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObje JSC::CallData callData = JSC::getCallData(function); JSValue result = call(globalObject, function, callData, JSC::jsUndefined(), args); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); if (auto* promise = JSC::jsDynamicCast(result)) { RELEASE_AND_RETURN(throwScope, JSValue::encode(promise)); @@ -566,7 +568,7 @@ extern "C" JSC_DEFINE_HOST_FUNCTION(JSMock__jsModuleMock, (JSC::JSGlobalObject * auto getJSValue = [&]() -> JSValue { auto scope = DECLARE_THROW_SCOPE(vm); JSValue result = mock->executeOnce(globalObject); - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (result && result.isObject()) { while (JSC::JSPromise* promise = jsDynamicCast(result)) { diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index e852e2d877..fb60334058 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -281,14 +281,14 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, auto argCount = callFrame->argumentCount(); if (argCount < 2) { JSC::throwTypeError(globalObject, scope, "dlopen requires 2 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSValue moduleValue = callFrame->uncheckedArgument(0); JSC::JSObject* moduleObject = jsDynamicCast(moduleValue); if (UNLIKELY(!moduleObject)) { JSC::throwTypeError(globalObject, scope, "dlopen requires an object as first argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue exports = moduleObject->getIfPropertyExists(globalObject, builtinNames(vm).exportsPublicName()); @@ -296,7 +296,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, if (UNLIKELY(!exports)) { JSC::throwTypeError(globalObject, scope, "dlopen requires an object with an exports property"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } globalObject->m_pendingNapiModuleAndExports[0].set(vm, globalObject, moduleObject); @@ -313,14 +313,14 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, WTF::String filename = callFrame->uncheckedArgument(1).toWTFString(globalObject); if (filename.isEmpty()) { JSC::throwTypeError(globalObject, scope, "dlopen requires a non-empty string as the second argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (filename.startsWith("file://"_s)) { WTF::URL fileURL = WTF::URL(filename); if (!fileURL.isValid() || !fileURL.protocolIsFile()) { JSC::throwTypeError(globalObject, scope, "invalid file: URL passed to dlopen"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } filename = fileURL.fileSystemPath(); @@ -361,7 +361,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, WTF::String msg = WTF::String::fromUTF8(dlerror()); #endif JSC::throwTypeError(globalObject, scope, msg); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (callCountAtStart != globalObject->napiModuleRegisterCallCount) { @@ -375,7 +375,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, if (resultValue && resultValue != strongModule.get()) { if (resultValue.isCell() && resultValue.getObject()->isErrorInstance()) { JSC::throwException(globalObject, scope, resultValue); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -405,7 +405,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, dlclose(handle); #endif JSC::throwTypeError(globalObject, scope, "symbol 'napi_register_module_v1' not found in native module. Is this a Node API (napi) module?"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } NapiHandleScope handleScope(globalObject); @@ -443,12 +443,12 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUmask, if (!numberValue.isNumber()) { throwTypeError(globalObject, throwScope, "The \"mask\" argument must be a number"_s); - return JSValue::encode({}); + return {}; } if (!numberValue.isAnyInt()) { throwNodeRangeError(globalObject, throwScope, "The \"mask\" argument must be an integer"_s); - return JSValue::encode({}); + return {}; } double number = numberValue.toNumber(globalObject); @@ -459,7 +459,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUmask, messageBuilder.append("The \"mask\" value must be in range [0, 4294967295]. Received value: "_s); messageBuilder.append(int52ToString(vm, newUmask, 10)->getString(globalObject)); throwNodeRangeError(globalObject, throwScope, messageBuilder.toString()); - return JSValue::encode({}); + return {}; } return JSC::JSValue::encode(JSC::jsNumber(umask(newUmask))); @@ -515,7 +515,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, Bun__setExitCode(bunVM(globalObject), exitCode); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { exitCode = Bun__getExitCode(bunVM(globalObject)); } @@ -536,7 +536,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_setUncaughtExceptionCaptureCallback, JSValue arg0 = callFrame->argument(0); if (!arg0.isCallable() && !arg0.isNull()) { throwTypeError(globalObject, throwScope, "The \"callback\" argument must be callable or null"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* zigGlobal = defaultGlobalObject(globalObject); jsCast(zigGlobal->processObject())->setUncaughtExceptionCaptureCallback(arg0); @@ -576,13 +576,13 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, JSArray* relativeArray = JSC::jsDynamicCast(arg0); if ((!relativeArray && !arg0.isUndefinedOrNull()) || relativeArray->length() < 2) { JSC::throwTypeError(globalObject, throwScope, "hrtime() argument must be an array or undefined"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue relativeSecondsValue = relativeArray->getIndexQuickly(0); JSValue relativeNanosecondsValue = relativeArray->getIndexQuickly(1); if (!relativeSecondsValue.isNumber() || !relativeNanosecondsValue.isNumber()) { JSC::throwTypeError(globalObject, throwScope, "hrtime() argument must be an array of 2 integers"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } int64_t relativeSeconds = JSC__JSValue__toInt64(JSC::JSValue::encode(relativeSecondsValue)); @@ -611,7 +611,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, if (UNLIKELY(!array)) { JSC::throwOutOfMemoryError(globalObject, throwScope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(array)); @@ -1078,10 +1078,10 @@ JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObj if (callFrame->argumentCount() < 1) { throwVMError(globalObject, scope, "Not enough arguments"_s); - return JSValue::encode(jsUndefined()); + return {}; } - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto* process = jsCast(globalObject->processObject()); @@ -2081,7 +2081,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functiongetgroups, (JSGlobalObject * globalObje auto throwScope = DECLARE_THROW_SCOPE(vm); if (ngroups == -1) { throwSystemError(throwScope, globalObject, "getgroups"_s, errno); - return JSValue::encode(jsUndefined()); + return {}; } gid_t egid = getegid(); @@ -2112,18 +2112,18 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionAssert, (JSGlobalObject * globalObject, JSValue arg0 = callFrame->argument(0); bool condition = arg0.toBoolean(globalObject); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); if (condition) { return JSValue::encode(jsUndefined()); } JSValue arg1 = callFrame->argument(1); String message = arg1.isUndefined() ? String() : arg1.toWTFString(globalObject); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); auto error = createError(globalObject, makeString("Assertion failed: "_s, message)); error->putDirect(vm, Identifier::fromString(vm, "code"_s), jsString(vm, makeString("ERR_ASSERTION"_s))); throwException(globalObject, throwScope, error); - return JSValue::encode(jsUndefined()); + return {}; } #define PROCESS_BINDING_NOT_IMPLEMENTED_ISSUE(str, issue) \ @@ -2208,7 +2208,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, (JSGlobalObject * jsGlobalObje // clang-format on throwScope.throwException(globalObject, createError(globalObject, makeString("No such module: "_s, moduleName))); - return JSValue::encode(jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObject, CallFrame* callFrame)) @@ -2222,7 +2222,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { exitCode = Bun__getExitCode(bunVM(globalObject)); } @@ -2340,13 +2340,13 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCpuUsage, struct rusage rusage; if (getrusage(RUSAGE_SELF, &rusage) != 0) { throwSystemError(throwScope, globalObject, "Failed to get CPU usage"_s, "getrusage"_s, errno); - return JSValue::encode(jsUndefined()); + return {}; } #else uv_rusage_t rusage; if (uv_getrusage(&rusage) != 0) { throwSystemError(throwScope, globalObject, "Failed to get CPU usage"_s, "uv_getrusage"_s, errno); - return JSValue::encode(jsUndefined()); + return {}; } #endif @@ -2514,7 +2514,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsage, size_t current_rss = 0; if (getRSS(¤t_rss) != 0) { throwSystemError(throwScope, globalObject, "Failed to get memory usage"_s, "memoryUsage"_s, errno); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSObject* result = JSC::constructEmptyObject(vm, process->memoryUsageStructure()); @@ -2557,7 +2557,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsageRSS, size_t current_rss = 0; if (getRSS(¤t_rss) != 0) { throwSystemError(throwScope, globalObject, "Failed to get memory usage"_s, "memoryUsage"_s, errno); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } RELEASE_AND_RETURN(throwScope, JSValue::encode(jsNumber(current_rss))); @@ -2570,27 +2570,27 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObje auto throwScope = DECLARE_THROW_SCOPE(vm); if (JSValue stdinValue = global->processObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "stdin"_s))) { - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); if (!stdinValue.isObject()) { throwTypeError(globalObject, throwScope, "stdin is not an object"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue resumeValue = stdinValue.getObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "resume"_s)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); if (!resumeValue.isUndefinedOrNull()) { auto resumeFunction = jsDynamicCast(resumeValue); if (UNLIKELY(!resumeFunction)) { throwTypeError(globalObject, throwScope, "stdin.resume is not a function"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto callData = getCallData(resumeFunction); MarkedArgumentBuffer args; JSC::call(globalObject, resumeFunction, callData, stdinValue, args); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } RELEASE_AND_RETURN(throwScope, JSValue::encode(stdinValue)); @@ -2899,7 +2899,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, RETURN_IF_EXCEPTION(scope, {}); if (pid < 0) { throwNodeRangeError(globalObject, scope, "pid must be a positive integer"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue signalValue = callFrame->argument(1); int signal = SIGTERM; @@ -2913,12 +2913,12 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, RETURN_IF_EXCEPTION(scope, {}); } else { throwNodeRangeError(globalObject, scope, "Unknown signal name"_s); - return JSValue::encode(jsUndefined()); + return {}; } RETURN_IF_EXCEPTION(scope, {}); } else if (!signalValue.isUndefinedOrNull()) { throwTypeError(globalObject, scope, "signal must be a string or number"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto global = jsCast(globalObject); @@ -2927,7 +2927,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, RETURN_IF_EXCEPTION(scope, {}); if (!_killFn.isCallable()) { throwTypeError(globalObject, scope, "process._kill is not a function"_s); - return JSValue::encode({}); + return {}; } JSC::MarkedArgumentBuffer args; diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 5fa1d281de..de4a1320f6 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -225,7 +225,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionLoadModule, (JSGlobalObject * lexicalGlobalOb if (!moduleObject->load(vm, globalObject, exception)) { throwException(globalObject, throwScope, exception.get()); exception.clear(); - return JSValue::encode({}); + return {}; } RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(true))); @@ -511,11 +511,11 @@ JSC_DEFINE_HOST_FUNCTION(functionCommonJSModuleRecord_compile, (JSGlobalObject * auto throwScope = DECLARE_THROW_SCOPE(vm); String sourceString = callframe->argument(0).toWTFString(globalObject); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode({})); + RETURN_IF_EXCEPTION(throwScope, {}); JSValue filenameValue = callframe->argument(1); String filenameString = filenameValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode({})); + RETURN_IF_EXCEPTION(throwScope, {}); String wrappedString = makeString( "(function(exports,require,module,__filename,__dirname){"_s, @@ -536,7 +536,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCommonJSModuleRecord_compile, (JSGlobalObject * #else JSValue dirnameValue = JSValue::decode(Bun__Path__dirname(globalObject, false, &encodedFilename, 1)); #endif - RETURN_IF_EXCEPTION(throwScope, JSValue::encode({})); + RETURN_IF_EXCEPTION(throwScope, {}); String dirnameString = dirnameValue.toWTFString(globalObject); @@ -552,7 +552,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCommonJSModuleRecord_compile, (JSGlobalObject * if (exception) { throwException(globalObject, throwScope, exception.get()); exception.clear(); - return JSValue::encode({}); + return {}; } return JSValue::encode(jsUndefined()); diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index 19d4cab324..74473f7bf1 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -62,7 +62,7 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj // not "requires" because "require" could be confusing JSC::throwTypeError(globalObject, scope, "require.resolve needs 1 argument (a string)"_s); scope.release(); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } default: { JSC::JSValue moduleName = callFrame->argument(0); @@ -93,7 +93,7 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj if (moduleName.isUndefinedOrNull()) { JSC::throwTypeError(globalObject, scope, "require.resolve expects a string"_s); scope.release(); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (callFrame->argumentCount() > 1) { @@ -107,7 +107,7 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj auto pathsArray = JSC::jsCast(pathsObject); if (pathsArray->length() > 0) { fromValue = pathsArray->getIndex(globalObject, 0); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); } } } @@ -115,7 +115,7 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj if (fromValue.isString()) { WTF::String str = fromValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); return doIt(str); } } @@ -191,7 +191,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObje if (moduleName.isUndefinedOrNull()) { JSC::throwTypeError(globalObject, scope, "expects a string"_s); scope.release(); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC__JSValue from = JSC::JSValue::encode(JSC::jsUndefined()); @@ -203,7 +203,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObje JSC::JSValue isESMValue = callFrame->argument(2); if (isESMValue.isBoolean()) { isESM = isESMValue.toBoolean(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); } } @@ -214,14 +214,14 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObje auto pathsArray = JSC::jsCast(pathsObject); if (pathsArray->length() > 0) { fromValue = pathsArray->getIndex(globalObject, 0); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); } } } } else if (fromValue.isBoolean()) { isESM = fromValue.toBoolean(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); fromValue = JSC::jsUndefined(); } @@ -238,7 +238,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObje if (UNLIKELY(!thisObject)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); JSC::throwTypeError(globalObject, scope, "import.meta.resolveSync must be bound to an import.meta object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto clientData = WebCore::clientData(vm); @@ -263,7 +263,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObje if (!JSC::JSValue::decode(result).isString()) { JSC::throwException(globalObject, scope, JSC::JSValue::decode(result)); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } scope.release(); @@ -285,10 +285,10 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlo if (moduleName.isUndefinedOrNull()) { JSC::throwTypeError(lexicalGlobalObject, scope, "expected module name as a string"_s); scope.release(); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); if (globalObject->onLoadPlugins.hasVirtualModules()) { if (moduleName.isString()) { @@ -331,7 +331,7 @@ extern "C" JSC::EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlo if (!JSC::JSValue::decode(result).isString()) { JSC::throwException(lexicalGlobalObject, scope, JSC::JSValue::decode(result)); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } scope.release(); @@ -349,7 +349,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, auto specifierValue = callFrame->argument(0); // 1. Set specifier to ? ToString(specifier). auto specifier = specifierValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); // Node.js allows a second argument for parent JSValue from = {}; @@ -363,7 +363,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, auto* pathsArray = JSC::jsCast(pathsObject); if (pathsArray->length() > 0) { fromValue = pathsArray->getIndex(globalObject, 0); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); } } } @@ -397,7 +397,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, // from.toWTFString() *should* always be the fast case, since above we check that it's a string. auto fromWTFString = from.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + RETURN_IF_EXCEPTION(scope, {}); // Try to resolve it to a relative file path. This path is not meant to throw module resolution errors. if (specifier.startsWith("./"_s) || specifier.startsWith("../"_s) || specifier.startsWith("/"_s) || specifier.startsWith("file://"_s) @@ -426,7 +426,7 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve, auto result = JSValue::decode(Bun__resolveSyncWithStrings(globalObject, &a, &b, true)); if (!result.isString()) { JSC::throwException(globalObject, scope, result); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto resultString = result.toWTFString(globalObject); diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index da9a2e7c99..8a0aea2c36 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -522,12 +522,12 @@ static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalOb JSC::JSValue decoded = JSC::JSValue::decode(result); if (UNLIKELY(!result)) { throwTypeError(lexicalGlobalObject, scope, "An error occurred while decoding the string"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (decoded.isCell() && decoded.getObject()->isErrorInstance()) { scope.throwException(lexicalGlobalObject, decoded); - return JSC::JSValue::encode(jsUndefined()); + return {}; } return result; } @@ -541,13 +541,13 @@ static inline JSC::EncodedJSValue constructBufferFromStringAndEncoding(JSC::JSGl auto* str = arg0.toString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (arg1 && arg1.isString()) { std::optional encoded = parseEnumeration(*lexicalGlobalObject, arg1); if (!encoded) { throwTypeError(lexicalGlobalObject, scope, "Invalid encoding"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } encoding = encoded.value(); @@ -596,7 +596,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocBody(JSC::JSG EnsureStillAliveScope arg2 = callFrame->uncheckedArgument(2); if (!arg2.value().isUndefined()) { encoding = parseEncoding(lexicalGlobalObject, scope, arg2.value()); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } } auto startPtr = uint8Array->typedVector() + start; @@ -605,18 +605,18 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocBody(JSC::JSG if (UNLIKELY(!Bun__Buffer_fill(&str, startPtr, end - start, encoding))) { throwTypeError(lexicalGlobalObject, scope, "Failed to decode value"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } } else if (auto* view = JSC::jsDynamicCast(value)) { if (UNLIKELY(view->isDetached())) { throwVMTypeError(lexicalGlobalObject, scope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t length = view->byteLength(); if (UNLIKELY(length == 0)) { throwTypeError(lexicalGlobalObject, scope, "Buffer cannot be empty"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } auto* start = uint8Array->typedVector(); @@ -640,7 +640,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocBody(JSC::JSG auto value_ = value.toInt32(lexicalGlobalObject) & 0xFF; auto value_uint8 = static_cast(value_); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); auto length = uint8Array->byteLength(); auto start = 0; @@ -673,7 +673,7 @@ static inline JSC::EncodedJSValue jsBufferByteLengthFromStringAndEncoding(JSC::J auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); if (!str) { throwTypeError(lexicalGlobalObject, scope, "byteLength() expects a string"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (auto length = Bun::byteLength(str, encoding)) { @@ -695,7 +695,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC if (UNLIKELY(callFrame->argumentCount() == 0)) { throwTypeError(lexicalGlobalObject, scope, "Not enough arguments"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } EnsureStillAliveScope arg0 = callFrame->argument(0); @@ -725,7 +725,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC } throwTypeError(lexicalGlobalObject, scope, "Invalid input, must be a string, Buffer, or ArrayBuffer"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) @@ -734,29 +734,29 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::J auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 2) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto castedThisValue = callFrame->uncheckedArgument(0); JSC::JSArrayBufferView* castedThis = JSC::jsDynamicCast(castedThisValue); if (UNLIKELY(!castedThis)) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Buffer (first argument)"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(castedThis->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array (first argument) is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto buffer = callFrame->uncheckedArgument(1); JSC::JSArrayBufferView* view = JSC::jsDynamicCast(buffer); if (UNLIKELY(!view)) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Buffer (2nd argument)"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array (second argument) is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t targetStart = 0; @@ -770,19 +770,19 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::J switch (callFrame->argumentCount()) { default: sourceEnd = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(5)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); FALLTHROUGH; case 5: sourceStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(4)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); FALLTHROUGH; case 4: targetEnd = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(3)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); FALLTHROUGH; case 3: targetStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(2)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); break; case 2: case 1: @@ -817,7 +817,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS auto array = JSC::jsDynamicCast(arrayValue); if (!array) { throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t arrayLength = array->length(); @@ -835,7 +835,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS args.ensureCapacity(arrayLength); if (UNLIKELY(args.hasOverflowed())) { throwOutOfMemoryError(lexicalGlobalObject, throwScope); - return JSValue::encode(jsUndefined()); + return {}; } for (unsigned i = 0; i < arrayLength; i++) { @@ -845,12 +845,12 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS auto* typedArray = JSC::jsDynamicCast(element); if (!typedArray) { throwTypeError(lexicalGlobalObject, throwScope, "Buffer.concat expects Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(typedArray->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto length = typedArray->length(); @@ -865,7 +865,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS if (!totalLengthValue.isUndefined()) { if (UNLIKELY(!totalLengthValue.isNumber())) { throwTypeError(lexicalGlobalObject, throwScope, "totalLength must be a valid number"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto totalLength = totalLengthValue.toTypedArrayIndex(lexicalGlobalObject, "totalLength must be a valid number"_s); @@ -888,7 +888,7 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS if (!outBuffer) { ASSERT(throwScope.exception()); - return JSValue::encode({}); + return {}; } size_t remain = byteLength; @@ -959,19 +959,19 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_compareBody(JSC::JSG auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSUint8Array* view = JSC::jsDynamicCast(callFrame->uncheckedArgument(0)); if (UNLIKELY(!view)) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t targetStart = 0; @@ -1007,22 +1007,22 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_compareBody(JSC::JSG if (!targetStartValue.isUndefined()) { targetStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(1)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!targetEndValue.isUndefined()) { targetEnd = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(2)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!sourceStartValue.isUndefined()) { sourceStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(3)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!sourceEndValue.isUndefined()) { sourceEnd = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(4)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } targetStart = std::min(targetStart, std::min(targetEnd, targetEndInit)); @@ -1046,20 +1046,20 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_copyBody(JSC::JSGlob if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto buffer = callFrame->uncheckedArgument(0); if (!buffer.isCell() || !JSC::isTypedView(buffer.asCell()->type())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSArrayBufferView* view = JSC::jsDynamicCast(buffer); if (UNLIKELY(!view || view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t targetStart = 0; @@ -1090,17 +1090,17 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_copyBody(JSC::JSGlob if (!targetStartValue.isUndefined()) { targetStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(1)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!sourceStartValue.isUndefined()) { sourceStart = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(2)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!sourceEndValue.isUndefined()) { sourceEnd = parseIndex(lexicalGlobalObject, throwScope, callFrame->uncheckedArgument(3)); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); } targetStart = std::min(targetStart, targetEnd); @@ -1126,19 +1126,19 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_equalsBody(JSC::JSGl auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto buffer = callFrame->uncheckedArgument(0); JSC::JSArrayBufferView* view = JSC::jsDynamicCast(buffer); if (UNLIKELY(!view)) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Buffer"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t a_length = castedThis->byteLength(); @@ -1197,17 +1197,17 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlob if (!encodingValue.isUndefined()) { encoding = parseEncoding(lexicalGlobalObject, scope, encodingValue); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } if (!offsetValue.isUndefined()) { start = parseIndex(lexicalGlobalObject, scope, offsetValue); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } if (!lengthValue.isUndefined()) { end = parseIndex(lexicalGlobalObject, scope, lengthValue); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } if (start >= end) { @@ -1216,7 +1216,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlob if (UNLIKELY(end > limit)) { throwNodeRangeError(lexicalGlobalObject, scope, "end out of range"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (value.isString()) { @@ -1228,7 +1228,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlob memset(startPtr, 0, end - start); } else if (UNLIKELY(!Bun__Buffer_fill(&str, startPtr, end - start, encoding))) { throwTypeError(lexicalGlobalObject, scope, "Failed to decode value"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } } else if (auto* view = JSC::jsDynamicCast(value)) { auto* startPtr = castedThis->typedVector() + start; @@ -1237,13 +1237,13 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlob if (UNLIKELY(view->isDetached())) { throwVMTypeError(lexicalGlobalObject, scope, "Uint8Array is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } size_t length = view->byteLength(); if (UNLIKELY(length == 0)) { throwTypeError(lexicalGlobalObject, scope, "Buffer cannot be empty"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } length = std::min(length, remain); @@ -1264,7 +1264,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlob auto value_ = value.toInt32(lexicalGlobalObject) & 0xFF; auto value_uint8 = static_cast(value_); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); auto startPtr = castedThis->typedVector() + start; auto endPtr = castedThis->typedVector() + end; @@ -1303,7 +1303,7 @@ static int64_t indexOf(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* auto scope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, scope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return -1; } auto value = callFrame->uncheckedArgument(0); @@ -1426,12 +1426,12 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap16Body(JSC::JSGl int64_t length = static_cast(castedThis->byteLength()); if (length % elemSize != 0) { throwNodeRangeError(lexicalGlobalObject, scope, "Buffer size must be a multiple of 16-bits"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(castedThis->isDetached())) { throwVMTypeError(lexicalGlobalObject, scope, "Buffer is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } uint8_t* typedVector = castedThis->typedVector(); @@ -1455,12 +1455,12 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap32Body(JSC::JSGl int64_t length = static_cast(castedThis->byteLength()); if (length % elemSize != 0) { throwNodeRangeError(lexicalGlobalObject, scope, "Buffer size must be a multiple of 32-bits"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(castedThis->isDetached())) { throwVMTypeError(lexicalGlobalObject, scope, "Buffer is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } uint8_t* typedVector = castedThis->typedVector(); @@ -1489,12 +1489,12 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap64Body(JSC::JSGl int64_t length = static_cast(castedThis->byteLength()); if (length % elemSize != 0) { throwNodeRangeError(lexicalGlobalObject, scope, "Buffer size must be a multiple of 64-bits"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(castedThis->isDetached())) { throwVMTypeError(lexicalGlobalObject, scope, "Buffer is detached"_s); - return JSValue::encode(jsUndefined()); + return {}; } uint8_t* typedVector = castedThis->typedVector(); @@ -1574,7 +1574,7 @@ static inline JSC::EncodedJSValue jsBufferToString(JSC::VM& vm, JSC::JSGlobalObj JSC::JSValue retValue = JSC::JSValue::decode(ret); if (UNLIKELY(!retValue.isString())) { scope.throwException(lexicalGlobalObject, retValue); - return JSC::JSValue::encode(jsUndefined()); + return {}; } RELEASE_AND_RETURN(scope, JSC::JSValue::encode(retValue)); @@ -1622,16 +1622,16 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS if (!arg1.isUndefined()) { encoding = parseEncoding(lexicalGlobalObject, scope, arg1); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } if (!arg2.isUndefined()) { int32_t istart = arg2.toInt32(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (istart < 0) { throwTypeError(lexicalGlobalObject, scope, "Start must be a positive integer"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } start = static_cast(istart); @@ -1640,7 +1640,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS if (!arg3.isUndefined()) { // length is end end = std::min(byteLength, static_cast(arg3.toInt32(lexicalGlobalObject))); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } return jsBufferToString(vm, lexicalGlobalObject, castedThis, start, end > start ? end - start : 0, encoding); @@ -1682,7 +1682,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_SliceWithEncoding(JS if (!(end <= length)) { throwNodeRangeError(lexicalGlobalObject, scope, "end out of range"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } return jsBufferToString(vm, lexicalGlobalObject, castedThis, start, end - start, encoding); @@ -1727,7 +1727,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeEncodingBody(JS if (UNLIKELY(offset > max)) { throwNodeRangeError(lexicalGlobalObject, scope, "offset is out of bounds"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (UNLIKELY(!parseArrayIndex(scope, lexicalGlobalObject, lengthValue, max, "length must be > 0"_s))) { @@ -1777,14 +1777,14 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlo if (UNLIKELY(callFrame->argumentCount() == 0)) { throwTypeError(lexicalGlobalObject, scope, "Not enough arguments"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } EnsureStillAliveScope arg0 = callFrame->argument(0); auto* str = arg0.value().toStringOrNull(lexicalGlobalObject); if (!str) { throwTypeError(lexicalGlobalObject, scope, "write() expects a string"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } JSValue offsetValue = jsUndefined(); @@ -1820,20 +1820,20 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlo // https://github.com/nodejs/node/blob/e676942f814915b2d24fc899bb42dc71ae6c8226/lib/buffer.js#L1056 encodingValue = offsetValue; setEncoding(); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN(scope, writeToBuffer(lexicalGlobalObject, castedThis, str, offset, length, encoding)); } if (UNLIKELY(!offsetValue.isNumber())) { throwTypeError(lexicalGlobalObject, scope, "Invalid offset"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } int32_t userOffset = offsetValue.toInt32(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (userOffset < 0 || userOffset > max) { throwNodeRangeError(lexicalGlobalObject, scope, "Offset is out of bounds"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } offset = static_cast(userOffset); uint32_t remaining = max - static_cast(userOffset); @@ -1844,13 +1844,13 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlo } else if (lengthValue.isString()) { encodingValue = lengthValue; setEncoding(); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); length = remaining; } else { setEncoding(); int32_t userLength = lengthValue.toInt32(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); length = std::min(static_cast(userLength), remaining); } @@ -1877,7 +1877,7 @@ extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Zig::GlobalObject* globalObjec if (UNLIKELY(!view)) { throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(jsUndefined()); + return {}; } return JSC::JSValue::encode(view); @@ -2340,13 +2340,13 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi if (UNLIKELY(!data)) { throwException(globalObject, throwScope, createRangeError(globalObject, "Buffer is detached"_s)); - return JSValue::encode({}); + return {}; } auto* uint8Array = createUninitializedBuffer(lexicalGlobalObject, byteLength); if (UNLIKELY(!uint8Array)) { ASSERT(throwScope.exception()); - return JSValue::encode({}); + return {}; } if (byteLength) { @@ -2368,7 +2368,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi if (UNLIKELY(!data)) { throwException(globalObject, throwScope, createRangeError(globalObject, "Buffer is detached"_s)); - return JSValue::encode({}); + return {}; } auto* uint8Array = createBuffer(lexicalGlobalObject, static_cast(data), byteLength); @@ -2385,7 +2385,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi offset = args.at(1).toTypedArrayIndex(globalObject, "byteOffset"_s); // TOOD: return Node.js error - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); if (argsCount > 2) { // If the length value is present but undefined, treat it as missing. @@ -2394,7 +2394,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi length = lengthValue.toTypedArrayIndex(globalObject, "length"_s); // TOOD: return Node.js error - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } } @@ -2404,7 +2404,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi if (buffer->isDetached()) { // TOOD: return Node.js error throwTypeError(globalObject, throwScope, "Buffer is detached"_s); - return JSValue::encode({}); + return {}; } if (!length) { @@ -2413,7 +2413,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi if (UNLIKELY(offset > byteLength)) { // TOOD: return Node.js error throwNodeRangeError(globalObject, throwScope, "byteOffset exceeds source ArrayBuffer byteLength"_s); - return JSValue::encode({}); + return {}; } } else { length = (byteLength - offset); diff --git a/src/bun.js/bindings/JSBufferList.cpp b/src/bun.js/bindings/JSBufferList.cpp index 4741b88afc..32c65f387d 100644 --- a/src/bun.js/bindings/JSBufferList.cpp +++ b/src/bun.js/bindings/JSBufferList.cpp @@ -264,7 +264,7 @@ static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_pushBody(JSC::JS auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto v = callFrame->uncheckedArgument(0); @@ -277,7 +277,7 @@ static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_unshiftBody(JSC: auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto v = callFrame->uncheckedArgument(0); @@ -309,13 +309,13 @@ static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_concatBody(JSC:: auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } int32_t n = callFrame->argument(0).toInt32(lexicalGlobalObject); if (UNLIKELY(n < 0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "n should be larger than or equal to 0"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(castedThis->concat(vm, lexicalGlobalObject, n))); } @@ -325,11 +325,11 @@ static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_joinBody(JSC::JS auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } JSString* s = callFrame->argument(0).toString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(castedThis->join(vm, lexicalGlobalObject, s))); } static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_consumeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) @@ -338,13 +338,13 @@ static inline JSC::EncodedJSValue jsBufferListPrototypeFunction_consumeBody(JSC: auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 2) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } int32_t n = callFrame->argument(0).toInt32(lexicalGlobalObject); if (UNLIKELY(n < 0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "n should be larger than or equal to 0"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } bool hasString = callFrame->argument(1).toBoolean(lexicalGlobalObject); RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(castedThis->consume(vm, lexicalGlobalObject, n, hasString))); diff --git a/src/bun.js/bindings/JSCTestingHelpers.cpp b/src/bun.js/bindings/JSCTestingHelpers.cpp index 67843ae049..5f64580d35 100644 --- a/src/bun.js/bindings/JSCTestingHelpers.cpp +++ b/src/bun.js/bindings/JSCTestingHelpers.cpp @@ -26,7 +26,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUTF16String, } throwTypeError(globalObject, scope, "Expected a string"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsLatin1String, @@ -46,7 +46,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsLatin1String, } throwTypeError(globalObject, scope, "Expected a string"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* globalObject) diff --git a/src/bun.js/bindings/JSStringDecoder.cpp b/src/bun.js/bindings/JSStringDecoder.cpp index 27969cb895..95200ce646 100644 --- a/src/bun.js/bindings/JSStringDecoder.cpp +++ b/src/bun.js/bindings/JSStringDecoder.cpp @@ -359,7 +359,7 @@ static inline JSC::EncodedJSValue jsStringDecoderPrototypeFunction_writeBody(JSC auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto buffer = callFrame->uncheckedArgument(0); @@ -374,7 +374,7 @@ static inline JSC::EncodedJSValue jsStringDecoderPrototypeFunction_writeBody(JSC } throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(castedThis->write(vm, lexicalGlobalObject, reinterpret_cast(view->vector()), view->byteLength()))); } @@ -390,7 +390,7 @@ static inline JSC::EncodedJSValue jsStringDecoderPrototypeFunction_endBody(JSC:: JSC::JSArrayBufferView* view = JSC::jsDynamicCast(buffer); if (UNLIKELY(!view || view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(castedThis->end(vm, lexicalGlobalObject, reinterpret_cast(view->vector()), view->byteLength()))); } @@ -400,14 +400,14 @@ static inline JSC::EncodedJSValue jsStringDecoderPrototypeFunction_textBody(JSC: auto throwScope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() < 2) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); - return JSValue::encode(jsUndefined()); + return {}; } auto buffer = callFrame->uncheckedArgument(0); JSC::JSArrayBufferView* view = JSC::jsDynamicCast(buffer); if (UNLIKELY(!view || view->isDetached())) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return JSValue::encode(jsUndefined()); + return {}; } int32_t offset = callFrame->uncheckedArgument(1).toInt32(lexicalGlobalObject); RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); diff --git a/src/bun.js/bindings/KeyObject.cpp b/src/bun.js/bindings/KeyObject.cpp index 901e325602..d16f379c52 100644 --- a/src/bun.js/bindings/KeyObject.cpp +++ b/src/bun.js/bindings/KeyObject.cpp @@ -330,37 +330,37 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (count < 1) { JSC::throwTypeError(globalObject, scope, "createPrivateKey requires 1 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* options = jsDynamicCast(callFrame->argument(0)); if (!options) { JSC::throwTypeError(globalObject, scope, "expected options to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue keyJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "key"_s))); if (keyJSValue.isUndefinedOrNull() || keyJSValue.isEmpty()) { JSC::throwTypeError(globalObject, scope, "key is required"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (!keyJSValue.isCell()) { JSC::throwTypeError(globalObject, scope, "key must be a Buffer, Array-like or object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue formatJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "format"_s))); if (formatJSValue.isUndefinedOrNull() || formatJSValue.isEmpty()) { JSC::throwTypeError(globalObject, scope, "format is required"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (!formatJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "format must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto format = formatJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); Zig::GlobalObject* zigGlobalObject = reinterpret_cast(globalObject); auto* structure = zigGlobalObject->JSCryptoKeyStructure(); @@ -396,7 +396,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo auto* jsBuffer = jsDynamicCast(keyJSValueCell); if (UNLIKELY(!jsBuffer)) { throwException(globalObject, scope, createTypeError(globalObject, "ERR_INVALID_ARG_TYPE: expected key to be Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto* buffer = jsBuffer->impl(); data = buffer->data(); @@ -407,86 +407,86 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (auto* keyObj = jsDynamicCast(keyJSValue)) { if (format != "jwk"_s) { JSC::throwTypeError(globalObject, scope, "format should be 'jwk' when key type is 'object'"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto jwk = WebCore::convertDictionary(*globalObject, keyJSValue); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (jwk.kty == "OKP"_s) { if (jwk.crv == "Ed25519"_s) { auto result = CryptoKeyOKP::importJwk(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::Ed25519, WTFMove(jwk), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() != CryptoKeyType::Private) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else if (jwk.crv == "X25519"_s) { auto result = CryptoKeyOKP::importJwk(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::X25519, WTFMove(jwk), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid X25519 private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() != CryptoKeyType::Private) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported OKP curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } else if (jwk.kty == "EC"_s) { auto result = CryptoKeyEC::importJwk(CryptoAlgorithmIdentifier::ECDSA, jwk.crv, WTFMove(jwk), true, jwk.usages); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() != CryptoKeyType::Private) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else if (jwk.kty == "RSA"_s) { auto result = CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier::RSA_OAEP, std::nullopt, WTFMove(jwk), true, jwk.usages); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid RSA private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() != CryptoKeyType::Private) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } JSC::throwTypeError(globalObject, scope, "The \"key\" property must be of type object"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } if (format == "jwk"_s) { JSC::throwTypeError(globalObject, scope, "The \"key\" property must be of type object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (UNLIKELY(!data) || UNLIKELY(!byteLength)) { throwException(globalObject, scope, createTypeError(globalObject, "ERR_INVALID_ARG_TYPE: expected key to be Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSValue passphraseJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "passphrase"_s))); KeyPassphrase passphrase(passphraseJSValue, globalObject, scope); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (format == "pem"_s) { ASSERT(data); @@ -495,7 +495,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key pem file"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto pKeyID = EVP_PKEY_id(pkey.get()); @@ -506,17 +506,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo size_t out_len = 0; if (!EVP_PKEY_get_raw_private_key(pkey.get(), nullptr, &out_len)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } Vector out(out_len); if (!EVP_PKEY_get_raw_private_key(pkey.get(), out.data(), &out_len) || out_len != out.size()) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto result = CryptoKeyOKP::create(CryptoAlgorithmIdentifier::Ed25519, pKeyID == EVP_PKEY_ED25519 ? CryptoKeyOKP::NamedCurve::Ed25519 : CryptoKeyOKP::NamedCurve::X25519, CryptoKeyType::Private, WTFMove(out), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -524,7 +524,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo EC_KEY* ec_key = EVP_PKEY_get1_EC_KEY(pkey.get()); if (UNLIKELY(ec_key == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -532,7 +532,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (curve_name == NID_undef) { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -544,14 +544,14 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo else { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } EC_KEY_free(ec_key); auto impl = CryptoKeyEC::create(CryptoAlgorithmIdentifier::ECDH, curve, CryptoKeyType::Private, WTFMove(pkey), true, CryptoKeyUsageSign); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } if (format == "der"_s) { @@ -560,10 +560,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (!typeJSValue.isUndefinedOrNull() && !typeJSValue.isEmpty()) { if (!typeJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "type must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } type = typeJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } if (type == "pkcs1"_s) { @@ -572,7 +572,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo auto pkey = EvpPKeyPtr(d2i_PrivateKey(EVP_PKEY_RSA, nullptr, &p, byteLength)); if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid use of PKCS#1 as private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto pKeyID = EVP_PKEY_id(pkey.get()); auto impl = CryptoKeyRSA::create(pKeyID == EVP_PKEY_RSA_PSS ? CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5 : CryptoAlgorithmIdentifier::RSA_OAEP, CryptoAlgorithmIdentifier::SHA_1, false, CryptoKeyType::Private, WTFMove(pkey), true, CryptoKeyUsageDecrypt); @@ -590,13 +590,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo auto* p8inf = d2i_PKCS8_PRIV_KEY_INFO_bio(bio.get(), nullptr); if (!p8inf) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid PKCS8 data"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } pkey = EvpPKeyPtr(EVP_PKCS82PKEY(p8inf)); } if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto pKeyID = EVP_PKEY_id(pkey.get()); @@ -607,7 +607,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo auto result = CryptoKeyOKP::importPkcs8(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::Ed25519, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -615,7 +615,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo auto result = CryptoKeyOKP::importPkcs8(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::X25519, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -623,7 +623,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo EC_KEY* ec_key = EVP_PKEY_get1_EC_KEY(pkey.get()); if (UNLIKELY(ec_key == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -631,7 +631,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (curve_name == NID_undef) { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -643,7 +643,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo else { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto result = CryptoKeyEC::platformImportPkcs8(CryptoAlgorithmIdentifier::ECDH, curve, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageSign); if (UNLIKELY(result == nullptr)) { @@ -652,13 +652,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo EC_KEY_free(ec_key); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } else if (type == "sec1"_s) { const unsigned char* p = reinterpret_cast(data); @@ -669,7 +669,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo EC_KEY* ec_key = EVP_PKEY_get1_EC_KEY(pkey.get()); if (UNLIKELY(ec_key == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -677,7 +677,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo if (curve_name == NID_undef) { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -689,23 +689,23 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo else { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } EC_KEY_free(ec_key); auto impl = CryptoKeyEC::create(CryptoAlgorithmIdentifier::ECDH, curve, CryptoKeyType::Private, WTFMove(pkey), true, CryptoKeyUsageSign); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1', 'pkcs8' or 'sec1'"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::throwTypeError(globalObject, scope, "format should be 'pem' or 'der'"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } static JSC::EncodedJSValue KeyObject__createRSAFromPrivate(JSC::JSGlobalObject* globalObject, EVP_PKEY* pkey, WebCore::CryptoAlgorithmIdentifier alg) @@ -717,12 +717,12 @@ static JSC::EncodedJSValue KeyObject__createRSAFromPrivate(JSC::JSGlobalObject* auto publicRSA = RSAPtr(RSAPublicKey_dup(rsa_key)); if (!publicRSA) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto publicPKey = EvpPKeyPtr(EVP_PKEY_new()); if (EVP_PKEY_set1_RSA(publicPKey.get(), publicRSA.get()) <= 0) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto impl = CryptoKeyRSA::create(alg, CryptoAlgorithmIdentifier::SHA_1, false, CryptoKeyType::Public, WTFMove(publicPKey), true, CryptoKeyUsageVerify); Zig::GlobalObject* zigGlobalObject = reinterpret_cast(globalObject); @@ -740,7 +740,7 @@ static JSC::EncodedJSValue KeyObject__createECFromPrivate(JSC::JSGlobalObject* g auto point = ECPointPtr(EC_POINT_dup(EC_KEY_get0_public_key(ec_key), EC_KEY_get0_group(ec_key))); if (!point) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private 1"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto curve = NID_undef; @@ -758,18 +758,18 @@ static JSC::EncodedJSValue KeyObject__createECFromPrivate(JSC::JSGlobalObject* g auto publicECKey = ECKeyPtr(EC_KEY_new_by_curve_name(curve)); if (!publicECKey) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private 2"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } // OPENSSL_EC_NAMED_CURVE needs to be set to export the key with the curve name, not with the curve parameters. EC_KEY_set_asn1_flag(publicECKey.get(), OPENSSL_EC_NAMED_CURVE); if (EC_KEY_set_public_key(publicECKey.get(), point.get()) <= 0) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private 3"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto publicPKey = EvpPKeyPtr(EVP_PKEY_new()); if (EVP_PKEY_set1_EC_KEY(publicPKey.get(), publicECKey.get()) <= 0) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private 4"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto impl = CryptoKeyEC::create(alg, namedCurve, CryptoKeyType::Public, WTFMove(publicPKey), true, CryptoKeyUsageVerify); @@ -794,7 +794,7 @@ static JSC::EncodedJSValue KeyObject__createOKPFromPrivate(JSC::JSGlobalObject* auto result = CryptoKeyOKP::create(alg, namedCurve, CryptoKeyType::Public, WTFMove(public_key), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Failed to create a public key from private"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); @@ -817,7 +817,7 @@ static JSC::EncodedJSValue KeyObject__createPublicFromPrivate(JSC::JSGlobalObjec EC_KEY* ec_key = EVP_PKEY_get1_EC_KEY(pkey); if (UNLIKELY(ec_key == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -825,7 +825,7 @@ static JSC::EncodedJSValue KeyObject__createPublicFromPrivate(JSC::JSGlobalObjec if (curve_name == NID_undef) { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -837,7 +837,7 @@ static JSC::EncodedJSValue KeyObject__createPublicFromPrivate(JSC::JSGlobalObjec else { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } EC_KEY_free(ec_key); return KeyObject__createECFromPrivate(globalObject, pkey, curve, CryptoAlgorithmIdentifier::ECDSA); @@ -845,17 +845,17 @@ static JSC::EncodedJSValue KeyObject__createPublicFromPrivate(JSC::JSGlobalObjec size_t out_len = 0; if (!EVP_PKEY_get_raw_private_key(pkey, nullptr, &out_len)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } Vector out(out_len); if (!EVP_PKEY_get_raw_private_key(pkey, out.data(), &out_len) || out_len != out.size()) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return KeyObject__createOKPFromPrivate(globalObject, out, pKeyID == EVP_PKEY_ED25519 ? CryptoKeyOKP::NamedCurve::Ed25519 : CryptoKeyOKP::NamedCurve::X25519, CryptoAlgorithmIdentifier::Ed25519); } else { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key type"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } @@ -870,17 +870,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (count < 1) { auto scope = DECLARE_THROW_SCOPE(vm); JSC::throwTypeError(globalObject, scope, "createPublicKey requires 1 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* options = jsDynamicCast(callFrame->argument(0)); if (!options) { JSC::throwTypeError(globalObject, scope, "expected options to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue keyJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "key"_s))); if (keyJSValue.isUndefinedOrNull() || keyJSValue.isEmpty()) { JSC::throwTypeError(globalObject, scope, "key is required"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } Zig::GlobalObject* zigGlobalObject = reinterpret_cast(globalObject); auto* structure = zigGlobalObject->JSCryptoKeyStructure(); @@ -892,7 +892,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto key_type = wrapped.type(); if (key_type != CryptoKeyType::Private) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Invalid key object type, expected private"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto id = wrapped.keyClass(); @@ -910,26 +910,26 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } default: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Invalid key object type, expected private"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } if (!keyJSValue.isCell()) { JSC::throwTypeError(globalObject, scope, "expected options to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue formatJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "format"_s))); if (formatJSValue.isUndefinedOrNull() || formatJSValue.isEmpty()) { JSC::throwTypeError(globalObject, scope, "format is required"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (!formatJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "format must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto format = formatJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto keyJSValueCell = keyJSValue.asCell(); auto type = keyJSValueCell->type(); @@ -960,7 +960,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (UNLIKELY(!jsBuffer)) { auto scope = DECLARE_THROW_SCOPE(vm); throwException(globalObject, scope, createTypeError(globalObject, "ERR_INVALID_ARG_TYPE: expected key to be Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto* buffer = jsBuffer->impl(); data = buffer->data(); @@ -971,16 +971,16 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (auto* keyObj = jsDynamicCast(keyJSValue)) { if (format != "jwk"_s) { JSC::throwTypeError(globalObject, scope, "format should be 'jwk' when key type is 'object'"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto jwk = WebCore::convertDictionary(*globalObject, keyJSValue); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (jwk.kty == "OKP"_s) { if (jwk.crv == "Ed25519"_s) { auto result = CryptoKeyOKP::importPublicJwk(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::Ed25519, WTFMove(jwk), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() == CryptoKeyType::Private) { @@ -991,7 +991,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto result = CryptoKeyOKP::importPublicJwk(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::X25519, WTFMove(jwk), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid X25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() == CryptoKeyType::Private) { @@ -1000,13 +1000,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported OKP curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } else if (jwk.kty == "EC"_s) { auto result = CryptoKeyEC::importJwk(CryptoAlgorithmIdentifier::ECDSA, jwk.crv, WTFMove(jwk), true, jwk.usages); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() == CryptoKeyType::Private) { @@ -1017,7 +1017,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto result = CryptoKeyRSA::importJwk(CryptoAlgorithmIdentifier::RSA_OAEP, std::nullopt, WTFMove(jwk), true, jwk.usages); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid RSA public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); if (impl->type() == CryptoKeyType::Private) { @@ -1026,7 +1026,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } } @@ -1034,12 +1034,12 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (format == "jwk"_s) { JSC::throwTypeError(globalObject, scope, "The \"key\" property must be of type object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (UNLIKELY(!data) || UNLIKELY(!byteLength)) { throwException(globalObject, scope, createTypeError(globalObject, "ERR_INVALID_ARG_TYPE: expected key to be Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (format == "pem"_s) { @@ -1049,11 +1049,11 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto bio = BIOPtr(BIO_new_mem_buf(const_cast((char*)data), byteLength)); JSValue passphraseJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "passphrase"_s))); KeyPassphrase passphrase(passphraseJSValue, globalObject, scope); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto pkey = EvpPKeyPtr(PEM_read_bio_PrivateKey(bio.get(), nullptr, PasswordCallback, &passphrase)); if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid PEM data"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return KeyObject__createPublicFromPrivate(globalObject, pkey.get()); } @@ -1072,7 +1072,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -1083,7 +1083,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -1094,7 +1094,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob OPENSSL_clear_free(pem.der_data, pem.der_len); } throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -1105,7 +1105,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -1120,7 +1120,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto result = CryptoKeyEC::platformImportSpki(CryptoAlgorithmIdentifier::ECDH, curve, Vector(std::span { (uint8_t*)pem.der_data, (size_t)pem.der_len }), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { @@ -1131,7 +1131,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -1140,7 +1140,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob OPENSSL_clear_free(pem.der_data, pem.der_len); } throwException(globalObject, scope, createTypeError(globalObject, "Unsupported public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } if (format == "der"_s) { @@ -1149,10 +1149,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (!typeJSValue.isUndefinedOrNull() && !typeJSValue.isEmpty()) { if (!typeJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "type must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } type = typeJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } if (type == "pkcs1"_s) { @@ -1165,7 +1165,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob pkey = EvpPKeyPtr(d2i_PrivateKey(EVP_PKEY_RSA, nullptr, &p, byteLength)); if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid PKCS#1"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto pKeyID = EVP_PKEY_id(pkey.get()); @@ -1181,7 +1181,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto pkey = EvpPKeyPtr(d2i_PUBKEY(nullptr, &ptr, byteLength)); if (!pkey) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto pKeyID = EVP_PKEY_id(pkey.get()); @@ -1192,7 +1192,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto result = CryptoKeyOKP::importSpki(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::Ed25519, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -1200,7 +1200,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob auto result = CryptoKeyOKP::importSpki(CryptoAlgorithmIdentifier::Ed25519, CryptoKeyOKP::NamedCurve::X25519, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid Ed25519 public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); @@ -1208,7 +1208,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob EC_KEY* ec_key = EVP_PKEY_get1_EC_KEY(pkey.get()); if (UNLIKELY(ec_key == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } const EC_GROUP* ec_group = EC_KEY_get0_group(ec_key); // Get the curve name @@ -1216,7 +1216,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob if (curve_name == NID_undef) { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unable to identify EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CryptoKeyEC::NamedCurve curve; if (curve_name == NID_X9_62_prime256v1) @@ -1228,7 +1228,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob else { EC_KEY_free(ec_key); throwException(globalObject, scope, createTypeError(globalObject, "Unsupported EC curve"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto result = CryptoKeyEC::platformImportSpki(CryptoAlgorithmIdentifier::ECDH, curve, Vector(std::span { (uint8_t*)data, byteLength }), true, CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { @@ -1236,21 +1236,21 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob } if (UNLIKELY(result == nullptr)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid EC public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto impl = result.releaseNonNull(); return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, WTFMove(impl))); } else { throwException(globalObject, scope, createTypeError(globalObject, "Unsupported public key"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1' or 'spki'"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::throwTypeError(globalObject, scope, "format should be 'pem' or 'der'"_s); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(KeyObject__createSecretKey, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) @@ -1263,7 +1263,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createSecretKey, (JSC::JSGlobalObject * lexi if (!bufferArg.isCell()) { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "ERR_INVALID_ARG_TYPE: expected Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto bufferArgCell = bufferArg.asCell(); @@ -1314,7 +1314,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createSecretKey, (JSC::JSGlobalObject * lexi } throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "ERR_INVALID_ARG_TYPE: expected Buffer or array-like object"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } static ExceptionOr> KeyObject__GetBuffer(JSValue bufferArg) @@ -1376,21 +1376,21 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J if (count < 3) { JSC::throwTypeError(globalObject, scope, "sign requires 3 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* key = jsDynamicCast(callFrame->argument(0)); if (!key) { // No JSCryptoKey instance JSC::throwTypeError(globalObject, scope, "expected CryptoKey as first argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue bufferArg = callFrame->uncheckedArgument(1); auto buffer = KeyObject__GetBuffer(bufferArg); if (buffer.hasException()) { JSC::throwTypeError(globalObject, scope, "expected Buffer or array-like object as second argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto vectorData = buffer.releaseReturnValue(); auto& wrapped = key->wrapped(); @@ -1403,15 +1403,15 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J customHash = true; if (!algorithm.isString()) { JSC::throwTypeError(globalObject, scope, "algorithm is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto algorithm_str = algorithm.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto identifier = CryptoAlgorithmRegistry::singleton().identifier(algorithm_str); if (UNLIKELY(!identifier)) { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (*identifier) { @@ -1426,7 +1426,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J } default: { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1466,10 +1466,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J if (!encoding.isUndefinedOrNull() && !encoding.isEmpty()) { if (!encoding.isString()) { JSC::throwTypeError(globalObject, scope, "dsaEncoding is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto encoding_str = encoding.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (encoding_str == "ieee-p1363"_s) { params.encoding = CryptoAlgorithmECDSAEncoding::IeeeP1363; @@ -1477,7 +1477,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J params.encoding = CryptoAlgorithmECDSAEncoding::DER; } else { JSC::throwTypeError(globalObject, scope, "invalid dsaEncoding"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1496,7 +1496,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J bool isRestrictedToHash = rsa.isRestrictedToHash(restrict_hash); if (isRestrictedToHash && hash != restrict_hash) { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (rsa.algorithmIdentifier()) { case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: { @@ -1518,7 +1518,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J if (!padding.isUndefinedOrNull() && !padding.isEmpty()) { if (!padding.isNumber()) { JSC::throwTypeError(globalObject, scope, "padding is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.padding = padding.toUInt32(globalObject); } @@ -1526,20 +1526,20 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J if (params.padding == RSA_PKCS1_PSS_PADDING) { if (count <= 5) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto saltLength = callFrame->argument(5); if (saltLength.isUndefinedOrNull() || saltLength.isEmpty() || !saltLength.isNumber()) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.saltLength = saltLength.toUInt32(globalObject); } else if (count > 5) { auto saltLength = callFrame->argument(5); if (!saltLength.isUndefinedOrNull() && !saltLength.isEmpty() && !saltLength.isNumber()) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.saltLength = saltLength.toUInt32(globalObject); params.padding = RSA_PKCS1_PSS_PADDING; // if saltLength is provided, padding must be RSA_PKCS1_PSS_PADDING @@ -1558,21 +1558,21 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Sign, (JSC::JSGlobalObject * globalObject, J } default: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Sign not supported for this key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } case CryptoKeyClass::AES: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Sign not supported for AES key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } case CryptoKeyClass::Raw: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Sign not supported for Raw key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } default: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Sign not supported for this key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1585,20 +1585,20 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, if (count < 4) { JSC::throwTypeError(globalObject, scope, "verify requires 4 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* key = jsDynamicCast(callFrame->argument(0)); if (!key) { // No JSCryptoKey instance JSC::throwTypeError(globalObject, scope, "expected CryptoKey as first argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue bufferArg = callFrame->uncheckedArgument(1); auto buffer = KeyObject__GetBuffer(bufferArg); if (buffer.hasException()) { JSC::throwTypeError(globalObject, scope, "expected data to be Buffer or array-like object as second argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto vectorData = buffer.releaseReturnValue(); @@ -1606,7 +1606,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, auto signatureBuffer = KeyObject__GetBuffer(signatureBufferArg); if (signatureBuffer.hasException()) { JSC::throwTypeError(globalObject, scope, "expected signature to be Buffer or array-like object as second argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto signatureData = signatureBuffer.releaseReturnValue(); @@ -1621,15 +1621,15 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, customHash = true; if (!algorithm.isString()) { JSC::throwTypeError(globalObject, scope, "algorithm is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto algorithm_str = algorithm.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto identifier = CryptoAlgorithmRegistry::singleton().identifier(algorithm_str); if (UNLIKELY(!identifier)) { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (*identifier) { @@ -1644,7 +1644,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, } default: { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1680,10 +1680,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, if (!encoding.isUndefinedOrNull() && !encoding.isEmpty()) { if (!encoding.isString()) { JSC::throwTypeError(globalObject, scope, "dsaEncoding is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto encoding_str = encoding.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (encoding_str == "ieee-p1363"_s) { params.encoding = CryptoAlgorithmECDSAEncoding::IeeeP1363; @@ -1691,7 +1691,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, params.encoding = CryptoAlgorithmECDSAEncoding::DER; } else { JSC::throwTypeError(globalObject, scope, "invalid dsaEncoding"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1708,7 +1708,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, bool isRestrictedToHash = rsa.isRestrictedToHash(restrict_hash); if (isRestrictedToHash && hash != restrict_hash) { JSC::throwTypeError(globalObject, scope, "digest not allowed"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (rsa.algorithmIdentifier()) { case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: { @@ -1728,7 +1728,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, if (!padding.isUndefinedOrNull() && !padding.isEmpty()) { if (!padding.isNumber()) { JSC::throwTypeError(globalObject, scope, "padding is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.padding = padding.toUInt32(globalObject); } @@ -1736,20 +1736,20 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, if (params.padding == RSA_PKCS1_PSS_PADDING) { if (count <= 6) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto saltLength = callFrame->argument(6); if (saltLength.isUndefinedOrNull() || saltLength.isEmpty() || !saltLength.isNumber()) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.saltLength = saltLength.toUInt32(globalObject); } else if (count > 6) { auto saltLength = callFrame->argument(6); if (!saltLength.isUndefinedOrNull() && !saltLength.isEmpty() && !saltLength.isNumber()) { JSC::throwTypeError(globalObject, scope, "saltLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } params.saltLength = saltLength.toUInt32(globalObject); params.padding = RSA_PKCS1_PSS_PADDING; // if saltLength is provided, padding must be RSA_PKCS1_PSS_PADDING @@ -1765,21 +1765,21 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Verify, (JSC::JSGlobalObject * globalObject, } default: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Verify not supported for RSA key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } case CryptoKeyClass::AES: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Verify not supported for AES key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } case CryptoKeyClass::Raw: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Verify not supported for Raw key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } default: { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE: Verify not supported for this key type"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -1793,14 +1793,14 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (count < 2) { JSC::throwTypeError(globalObject, scope, "exports requires 2 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* key = jsDynamicCast(callFrame->argument(0)); if (!key) { // No JSCryptoKey instance JSC::throwTypeError(globalObject, scope, "expected CryptoKey as first argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto& wrapped = key->wrapped(); @@ -1811,17 +1811,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject JSValue typeJSValue = options->getIfPropertyExists(globalObject, PropertyName(vm.propertyNames->type)); JSValue passphraseJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "passphrase"_s))); KeyPassphrase passphrase(passphraseJSValue, globalObject, scope); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (formatJSValue.isUndefinedOrNull() || formatJSValue.isEmpty()) { JSC::throwTypeError(globalObject, scope, "format is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto string = formatJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (string == "jwk"_s && passphrase.hasPassphrase()) { JSC::throwTypeError(globalObject, scope, "encryption is not supported for jwk format"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (id) { @@ -1858,7 +1858,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (string == "jwk"_s) { if (rsa.algorithmIdentifier() == CryptoAlgorithmIdentifier::RSA_PSS) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE: encryption is not supported for jwk format"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } const JsonWebKey& jwkValue = rsa.exportJwk(); Zig::GlobalObject* domGlobalObject = reinterpret_cast(globalObject); @@ -1869,15 +1869,15 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!typeJSValue.isUndefinedOrNull() && !typeJSValue.isEmpty()) { if (!typeJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "type must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } type = typeJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } if (type == "pkcs1"_s) { if (rsa.algorithmIdentifier() == CryptoAlgorithmIdentifier::RSA_PSS) { JSC::throwTypeError(globalObject, scope, "ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE: encryption is not supported for jwk format"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -1891,18 +1891,18 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (PEM_write_bio_RSAPublicKey(bio, rsa_ptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "spki"_s) { if (PEM_write_bio_PUBKEY(bio, rsaKey) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1' or 'spki'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { @@ -1910,23 +1910,23 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (i2d_RSAPublicKey_bio(bio, rsa_ptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "spki"_s) { if (i2d_PUBKEY_bio(bio, rsaKey) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1' or 'spki'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSValue cipherJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "cipher"_s))); @@ -1934,13 +1934,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject const EVP_CIPHER* cipher = nullptr; if (!cipherJSValue.isUndefinedOrNull() && !cipherJSValue.isEmpty() && cipherJSValue.isString()) { auto cipher_wtfstr = cipherJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!cipher_wtfstr.isNull()) { auto cipherOrError = cipher_wtfstr.tryGetUTF8(); if (!cipherOrError.has_value()) { JSC::throwTypeError(globalObject, scope, "invalid cipher name"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { auto value = cipherOrError.value(); auto cipher_str = value.data(); @@ -1954,7 +1954,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!cipher) { JSC::throwTypeError(globalObject, scope, "cipher is required when passphrase is specified"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -1963,41 +1963,41 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (PEM_write_bio_RSAPrivateKey(bio, rsa_ptr, cipher, (unsigned char*)passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "pkcs8"_s) { if (PEM_write_bio_PKCS8PrivateKey(bio, rsaKey, cipher, passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1' or 'pkcs8'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { if (type == "pkcs1"_s) { if (i2d_RSAPrivateKey_bio(bio, rsa_ptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "pkcs8"_s) { if (i2d_PKCS8PrivateKey_bio(bio, rsaKey, cipher, passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs1' or 'pkcs8'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2031,10 +2031,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!typeJSValue.isUndefinedOrNull() && !typeJSValue.isEmpty()) { if (!typeJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "type must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } type = typeJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } auto* bio = BIO_new(BIO_s_mem()); @@ -2047,12 +2047,12 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (PEM_write_bio_PUBKEY(bio, ecKey) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'spki'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { @@ -2060,17 +2060,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (i2d_PUBKEY_bio(bio, ecKey) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'spki'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSValue cipherJSValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "cipher"_s))); @@ -2078,13 +2078,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject const EVP_CIPHER* cipher = nullptr; if (!cipherJSValue.isUndefinedOrNull() && !cipherJSValue.isEmpty()) { auto cipher_wtfstr = cipherJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!cipher_wtfstr.isNull()) { auto cipherOrError = cipher_wtfstr.tryGetUTF8(); if (!cipherOrError.has_value()) { JSC::throwTypeError(globalObject, scope, "invalid cipher name"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { auto value = cipherOrError.value(); auto cipher_str = value.data(); @@ -2100,7 +2100,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!cipher) { JSC::throwTypeError(globalObject, scope, "cipher is required when passphrase is specified"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2109,41 +2109,41 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (PEM_write_bio_ECPrivateKey(bio, ec_ptr, cipher, (unsigned char*)passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "pkcs8"_s) { if (PEM_write_bio_PKCS8PrivateKey(bio, ecKey, cipher, passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'sec1' or 'pkcs8'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { if (type == "sec1"_s) { if (i2d_ECPrivateKey_bio(bio, ec_ptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (type == "pkcs8"_s) { if (i2d_PKCS8PrivateKey_bio(bio, ecKey, cipher, passphrase.data(), passphrase.length(), nullptr, nullptr) != 1) { JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'sec1' or 'pkcs8'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2177,10 +2177,10 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!typeJSValue.isUndefinedOrNull() && !typeJSValue.isEmpty()) { if (!typeJSValue.isString()) { JSC::throwTypeError(globalObject, scope, "type must be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } type = typeJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } auto keyData = okpKey.exportKey(); @@ -2195,14 +2195,14 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject const EVP_CIPHER* cipher = nullptr; if (!cipherJSValue.isUndefinedOrNull() && !cipherJSValue.isEmpty() && cipherJSValue.isString()) { auto cipher_wtfstr = cipherJSValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!cipher_wtfstr.isNull()) { auto cipherOrError = cipher_wtfstr.tryGetUTF8(); if (!cipherOrError.has_value()) { JSC::throwTypeError(globalObject, scope, "invalid cipher name"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { auto value = cipherOrError.value(); auto cipher_str = value.data(); @@ -2217,7 +2217,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject if (!cipher) { JSC::throwTypeError(globalObject, scope, "cipher is required when passphrase is specified"_s); BIO_free(bio); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2227,13 +2227,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs8'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { if (type == "pkcs8"_s) { @@ -2241,19 +2241,19 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject JSC::throwTypeError(globalObject, scope, "Failed to write private key"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'pkcs8'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { evpKey = EVP_PKEY_new_raw_public_key(okpKey.namedCurve() == CryptoKeyOKP::NamedCurve::X25519 ? EVP_PKEY_X25519 : EVP_PKEY_ED25519, nullptr, keyData.data(), keyData.size()); @@ -2263,13 +2263,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'spki'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else if (string == "der"_s) { @@ -2278,19 +2278,19 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject JSC::throwTypeError(globalObject, scope, "Failed to write public key"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "type should be 'spki'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } else { JSC::throwTypeError(globalObject, scope, "format expected to be 'der', 'pem' or 'jwk'"_s); BIO_free(bio); EVP_PKEY_free(evpKey); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2318,18 +2318,18 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Exports, (JSC::JSGlobalObject * globalObject } JSC::throwTypeError(globalObject, scope, "format is expected to be 'buffer'"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } default: { JSC::throwTypeError(globalObject, scope, "Invalid Operation"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } JSC::throwTypeError(globalObject, scope, "format is expected to be 'buffer' or 'jwk'"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } else { JSC::throwTypeError(globalObject, scope, "expected options to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } @@ -2441,7 +2441,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject_AsymmetricKeyDetails, (JSC::JSGlobalObject * if (ASN1_INTEGER_get_int64(&salt_length, params->saltLength) != 1) { auto scope = DECLARE_THROW_SCOPE(vm); throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Failed to get saltLenght"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "saltLength"_s)), jsNumber(salt_length), 0); @@ -2502,33 +2502,33 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * if (count < 1) { JSC::throwTypeError(lexicalGlobalObject, scope, "generateKeyPairSync requires 1 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto type = callFrame->argument(0); if (type.isUndefinedOrNull() || type.isEmpty() || !type.isString()) { JSC::throwTypeError(lexicalGlobalObject, scope, "type is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto type_str = type.toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); Zig::GlobalObject* zigGlobalObject = reinterpret_cast(lexicalGlobalObject); auto* structure = zigGlobalObject->JSCryptoKeyStructure(); if (type_str == "rsa"_s) { if (count == 1) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.modulusLength are required for rsa"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* options = jsDynamicCast(callFrame->argument(1)); if (options == nullptr) { JSC::throwTypeError(lexicalGlobalObject, scope, "options is expected to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto modulusLengthJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "modulusLength"_s))); if (!modulusLengthJS.isNumber()) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.modulusLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto publicExponentJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "publicExponent"_s))); uint32_t publicExponent = 0x10001; @@ -2536,7 +2536,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * publicExponent = publicExponentJS.toUInt32(lexicalGlobalObject); } else if (!publicExponentJS.isUndefinedOrNull() && !publicExponentJS.isEmpty()) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.publicExponent is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } uint8_t publicExponentArray[4]; @@ -2567,17 +2567,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * if (type_str == "rsa-pss"_s) { if (count == 1) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.modulusLength are required for rsa"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* options = jsDynamicCast(callFrame->argument(1)); if (options == nullptr) { JSC::throwTypeError(lexicalGlobalObject, scope, "options is expected to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto modulusLengthJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "modulusLength"_s))); if (!modulusLengthJS.isNumber()) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.modulusLength is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto publicExponentJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "publicExponent"_s))); uint32_t publicExponent = 0x10001; @@ -2585,7 +2585,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * publicExponent = publicExponentJS.toUInt32(lexicalGlobalObject); } else if (!publicExponentJS.isUndefinedOrNull() && !publicExponentJS.isEmpty()) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.publicExponent is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } uint8_t publicExponentArray[4]; publicExponentArray[0] = (uint8_t)(publicExponent >> 24); @@ -2611,16 +2611,16 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * if (!hashAlgoJS.isUndefinedOrNull() && !hashAlgoJS.isEmpty()) { if (!hashAlgoJS.isString()) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.hashAlgorithm is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } hasHash = true; auto hashAlgo = hashAlgoJS.toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto identifier = CryptoAlgorithmRegistry::singleton().identifier(hashAlgo); if (UNLIKELY(!identifier)) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.hashAlgorithm is invalid"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } switch (*identifier) { @@ -2635,7 +2635,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * } default: { JSC::throwTypeError(lexicalGlobalObject, scope, "options.hashAlgorithm is invalid"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } } } @@ -2653,20 +2653,20 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * } else if (type_str == "ec"_s) { if (count == 1) { JSC::throwTypeError(lexicalGlobalObject, scope, "options.namedCurve is required for ec"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto* options = jsDynamicCast(callFrame->argument(1)); if (options == nullptr) { JSC::throwTypeError(lexicalGlobalObject, scope, "options is expected to be a object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto namedCurveJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "namedCurve"_s))); if (namedCurveJS.isUndefinedOrNull() || namedCurveJS.isEmpty() || !namedCurveJS.isString()) { JSC::throwTypeError(lexicalGlobalObject, scope, "namedCurve is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto namedCurve = namedCurveJS.toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (namedCurve == "P-384"_s || namedCurve == "p384"_s || namedCurve == "secp384r1"_s) { namedCurve = "P-384"_s; } else if (namedCurve == "P-256"_s || namedCurve == "p256"_s || namedCurve == "prime256v1"_s) { @@ -2675,7 +2675,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * namedCurve = "P-521"_s; } else { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "curve not supported"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto result = CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier::ECDSA, namedCurve, true, CryptoKeyUsageSign | CryptoKeyUsageVerify); @@ -2712,7 +2712,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeyPairSync, (JSC::JSGlobalObject * return JSValue::encode(obj); } else { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "algorithm should be 'rsa', 'rsa-pss', 'ec', 'x25519' or 'ed25519'"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSValue::encode(JSC::jsUndefined()); } @@ -2723,17 +2723,17 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeySync, (JSC::JSGlobalObject * lexi auto scope = DECLARE_THROW_SCOPE(vm); if (count < 2) { JSC::throwTypeError(lexicalGlobalObject, scope, "generateKeySync requires 2 arguments"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto type = callFrame->argument(0); if (type.isUndefinedOrNull() || type.isEmpty() || !type.isString()) { JSC::throwTypeError(lexicalGlobalObject, scope, "type is expected to be a string"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto type_str = type.toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (type_str == "hmac"_s) { Zig::GlobalObject* zigGlobalObject = reinterpret_cast(lexicalGlobalObject); @@ -2742,13 +2742,13 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeySync, (JSC::JSGlobalObject * lexi auto length = callFrame->argument(1); if (!length.isNumber()) { JSC::throwTypeError(lexicalGlobalObject, scope, "length is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } lengthBits = length.toUInt32(lexicalGlobalObject); auto result = CryptoKeyHMAC::generate(lengthBits, WebCore::CryptoAlgorithmIdentifier::HMAC, true, CryptoKeyUsageSign | CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Invalid length"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, result.releaseNonNull())); } else if (type_str == "aes"_s) { @@ -2759,7 +2759,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeySync, (JSC::JSGlobalObject * lexi auto length = callFrame->argument(1); if (!length.isNumber()) { JSC::throwTypeError(lexicalGlobalObject, scope, "length is expected to be a number"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } lengthBits = length.toUInt32(lexicalGlobalObject); } @@ -2767,14 +2767,14 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__generateKeySync, (JSC::JSGlobalObject * lexi auto result = CryptoKeyAES::generate(WebCore::CryptoAlgorithmIdentifier::AES_CBC, lengthBits, true, CryptoKeyUsageSign | CryptoKeyUsageVerify); if (UNLIKELY(result == nullptr)) { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Invalid length"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } // TODO(@paperdave 2023-10-19): i removed WTFMove from result.releaseNonNull() as per MSVC compiler error. // We need to evaluate if that is the proper fix here. return JSC::JSValue::encode(JSCryptoKey::create(structure, zigGlobalObject, result.releaseNonNull())); } else { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "algorithm should be 'aes' or 'hmac'"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } } @@ -2899,7 +2899,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__Equals, (JSC::JSGlobalObject * lexicalGlobal auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "ERR_CRYPTO_UNSUPPORTED_OPERATION"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } return JSC::JSValue::encode(jsBoolean(ok == 1)); } @@ -2993,7 +2993,7 @@ static EncodedJSValue doAsymmetricCipher(JSGlobalObject* globalObject, CallFrame "expected string for oaepHash"_s); } auto oaepHashStr = jsOaepHash.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); auto oaepHashId = CryptoAlgorithmRegistry::singleton().identifier(oaepHashStr); if (UNLIKELY(!oaepHashId)) { @@ -3030,10 +3030,10 @@ static EncodedJSValue doAsymmetricCipher(JSGlobalObject* globalObject, CallFrame if (isTypedArrayTypeIncludingDataView(jsOaepLabelType)) { auto* jsBufferView = jsCast(jsOaepLabelCell); - oaepLabel = std::optional{jsBufferView->unsharedImpl()}; + oaepLabel = std::optional { jsBufferView->unsharedImpl() }; } else if (jsOaepLabelType == ArrayBufferType) { auto* jsBuffer = jsDynamicCast(jsOaepLabelCell); - oaepLabel = std::optional{jsBuffer->impl()}; + oaepLabel = std::optional { jsBuffer->impl() }; } else { return Bun::throwError(globalObject, scope, Bun::ErrorCode::ERR_INVALID_ARG_TYPE, "expected Buffer or array-like object for oaepLabel"_s); @@ -3066,7 +3066,7 @@ static EncodedJSValue doAsymmetricCipher(JSGlobalObject* globalObject, CallFrame } auto buffer = jsBuffer.releaseReturnValue(); - auto params = CryptoAlgorithmRsaOaepParams{}; + auto params = CryptoAlgorithmRsaOaepParams {}; params.label = oaepLabel; params.padding = padding; const auto& rsaKey = downcast(cryptoKey); @@ -3080,12 +3080,12 @@ static EncodedJSValue doAsymmetricCipher(JSGlobalObject* globalObject, CallFrame return JSValue::encode(WebCore::createBuffer(globalObject, outBuffer)); } -JSC_DEFINE_HOST_FUNCTION(KeyObject__publicEncrypt, (JSGlobalObject* globalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(KeyObject__publicEncrypt, (JSGlobalObject * globalObject, CallFrame* callFrame)) { return doAsymmetricCipher(globalObject, callFrame, true); } -JSC_DEFINE_HOST_FUNCTION(KeyObject__privateDecrypt, (JSGlobalObject* globalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(KeyObject__privateDecrypt, (JSGlobalObject * globalObject, CallFrame* callFrame)) { return doAsymmetricCipher(globalObject, callFrame, false); } diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 6d3d8b3e24..c1cd391b9b 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -888,13 +888,13 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionOnLoadObjectResultResolve, (JSC::JSGlobalObje scope.release(); promise->resolve(globalObject, result); pendingModule->internalField(2).set(vm, pendingModule, JSC::jsUndefined()); + return JSValue::encode(jsUndefined()); } else { throwException(globalObject, scope, result); auto retValue = JSValue::encode(promise->rejectWithCaughtException(globalObject, scope)); pendingModule->internalField(2).set(vm, pendingModule, JSC::jsUndefined()); return retValue; } - return JSValue::encode(jsUndefined()); } BUN_DEFINE_HOST_FUNCTION(jsFunctionOnLoadObjectResultReject, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) diff --git a/src/bun.js/bindings/NodeHTTP.cpp b/src/bun.js/bindings/NodeHTTP.cpp index 8a7b04ad5e..2ff078e67d 100644 --- a/src/bun.js/bindings/NodeHTTP.cpp +++ b/src/bun.js/bindings/NodeHTTP.cpp @@ -434,7 +434,7 @@ JSC_DEFINE_HOST_FUNCTION(jsHTTPSetHeader, (JSGlobalObject * globalObject, CallFr if (UNLIKELY(scope.exception())) return JSValue::encode(jsUndefined()); impl->set(name, item.getString(globalObject)); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } for (unsigned i = 1; i < length; ++i) { JSValue value = array->getIndex(globalObject, i); @@ -443,14 +443,14 @@ JSC_DEFINE_HOST_FUNCTION(jsHTTPSetHeader, (JSGlobalObject * globalObject, CallFr if (!value.isString()) continue; impl->append(name, value.getString(globalObject)); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } RELEASE_AND_RETURN(scope, JSValue::encode(jsUndefined())); return JSValue::encode(jsUndefined()); } impl->set(name, valueValue.getString(globalObject)); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(jsUndefined()); } } diff --git a/src/bun.js/bindings/NodeURL.cpp b/src/bun.js/bindings/NodeURL.cpp index a5fcdbc33e..e3886b5f09 100644 --- a/src/bun.js/bindings/NodeURL.cpp +++ b/src/bun.js/bindings/NodeURL.cpp @@ -11,7 +11,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToASCII, (JSC::JSGlobalObject * globalObject, J if (callFrame->argumentCount() < 1) { throwTypeError(globalObject, scope, "domainToASCII needs 1 argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto arg0 = callFrame->argument(0); @@ -21,7 +21,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToASCII, (JSC::JSGlobalObject * globalObject, J return JSC::JSValue::encode(jsNull()); if (!arg0.isString()) { throwTypeError(globalObject, scope, "the \"domain\" argument must be a string"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } auto domain = arg0.toWTFString(globalObject); @@ -69,7 +69,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToASCII, (JSC::JSGlobalObject * globalObject, J return JSC::JSValue::encode(JSC::jsString(vm, WTF::String(std::span { hostnameBuffer, static_cast(numCharactersConverted) }))); } throwTypeError(globalObject, scope, "domainToASCII failed"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(jsDomainToUnicode, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) @@ -79,7 +79,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToUnicode, (JSC::JSGlobalObject * globalObject, if (callFrame->argumentCount() < 1) { throwTypeError(globalObject, scope, "domainToUnicode needs 1 argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto arg0 = callFrame->argument(0); @@ -89,7 +89,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToUnicode, (JSC::JSGlobalObject * globalObject, return JSC::JSValue::encode(jsNull()); if (!arg0.isString()) { throwTypeError(globalObject, scope, "the \"domain\" argument must be a string"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } auto domain = arg0.toWTFString(globalObject); @@ -140,7 +140,7 @@ JSC_DEFINE_HOST_FUNCTION(jsDomainToUnicode, (JSC::JSGlobalObject * globalObject, return JSC::JSValue::encode(JSC::jsString(vm, WTF::String(std::span { hostnameBuffer, static_cast(numCharactersConverted) }))); } throwTypeError(globalObject, scope, "domainToUnicode failed"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue createNodeURLBinding(Zig::GlobalObject* globalObject) diff --git a/src/bun.js/bindings/NodeVM.cpp b/src/bun.js/bindings/NodeVM.cpp index b53f07ecc0..7f7dad886d 100644 --- a/src/bun.js/bindings/NodeVM.cpp +++ b/src/bun.js/bindings/NodeVM.cpp @@ -159,7 +159,7 @@ static JSC::EncodedJSValue runInContext(JSGlobalObject* globalObject, NodeVMScri auto returnedException = catchScope.exception(); catchScope.clearException(); JSC::throwException(globalObject, throwScope, returnedException); - return JSValue::encode({}); + return {}; } return JSValue::encode(result); @@ -196,7 +196,7 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInContext, (JSGlobalObject * globalObject, Cal if (UNLIKELY(!script)) { throwVMTypeError(globalObject, scope, "Script.prototype.runInContext can only be called on a Script object"_s); - return JSValue::encode({}); + return {}; } ArgList args(callFrame); @@ -204,7 +204,7 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInContext, (JSGlobalObject * globalObject, Cal JSValue contextArg = args.at(0); if (!UNLIKELY(contextArg.isObject())) { throwVMTypeError(globalObject, scope, "context parameter must be a contextified object"_s); - return JSValue::encode({}); + return {}; } JSObject* context = asObject(contextArg); @@ -212,19 +212,19 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInContext, (JSGlobalObject * globalObject, Cal JSValue scopeVal = zigGlobalObject->vmModuleContextMap()->get(context); if (UNLIKELY(scopeVal.isUndefined())) { throwVMTypeError(globalObject, scope, "context parameter must be a contextified object"_s); - return JSValue::encode({}); + return {}; } JSScope* jsScope = jsDynamicCast(scopeVal); if (UNLIKELY(!jsScope)) { throwVMTypeError(globalObject, scope, "context parameter must be a contextified object"_s); - return JSValue::encode({}); + return {}; } JSGlobalProxy* globalProxy = jsDynamicCast(context->getPrototypeDirect()); if (!globalProxy) { auto scope = DECLARE_THROW_SCOPE(vm); throwVMTypeError(globalObject, scope, "context parameter must be a contextified object"_s); - return JSValue::encode({}); + return {}; } return runInContext(globalProxy->target(), script, context, jsScope, args.at(1)); @@ -240,7 +240,7 @@ JSC_DEFINE_HOST_FUNCTION(vmModuleRunInNewContext, (JSGlobalObject * globalObject if (!sourceStringValue.isString()) { throwTypeError(globalObject, throwScope, "Script code must be a string"_s); - return JSValue::encode({}); + return {}; } auto sourceString = sourceStringValue.toWTFString(globalObject); @@ -251,7 +251,7 @@ JSC_DEFINE_HOST_FUNCTION(vmModuleRunInNewContext, (JSGlobalObject * globalObject if (UNLIKELY(!contextObjectValue || !contextObjectValue.isObject())) { throwTypeError(globalObject, throwScope, "Context must be an object"_s); - return JSValue::encode({}); + return {}; } // we don't care about options for now @@ -310,7 +310,7 @@ JSC_DEFINE_HOST_FUNCTION(vmModuleRunInThisContext, (JSGlobalObject * globalObjec if (!sourceStringValue.isString()) { throwTypeError(globalObject, throwScope, "Script code must be a string"_s); - return JSValue::encode({}); + return {}; } auto sourceString = sourceStringValue.toWTFString(globalObject); @@ -361,7 +361,7 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInNewContext, (JSGlobalObject * globalObject, if (!script) { throwTypeError(globalObject, scope, "Script.prototype.runInNewContext can only be called on a Script object"_s); - return JSValue::encode({}); + return {}; } if (!contextObjectValue || contextObjectValue.isUndefinedOrNull()) { @@ -370,7 +370,7 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInNewContext, (JSGlobalObject * globalObject, if (UNLIKELY(!contextObjectValue || !contextObjectValue.isObject())) { throwTypeError(globalObject, scope, "Context must be an object"_s); - return JSValue::encode({}); + return {}; } // we don't care about options for now diff --git a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp index de474f4f22..052863c900 100644 --- a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp +++ b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp @@ -206,13 +206,13 @@ JSC_DEFINE_HOST_FUNCTION(jsTTYSetMode, (JSC::JSGlobalObject * globalObject, Call if (callFrame->argumentCount() != 2) { throwTypeError(globalObject, scope, "Expected 2 arguments"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue fd = callFrame->argument(0); if (!fd.isNumber()) { throwTypeError(globalObject, scope, "fd must be a number"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue mode = callFrame->argument(1); @@ -234,20 +234,20 @@ JSC_DEFINE_HOST_FUNCTION(TTYWrap_functionSetMode, auto throwScope = DECLARE_THROW_SCOPE(vm); if (argCount == 0) { JSC::throwTypeError(globalObject, throwScope, "setRawMode requires 1 argument (a number)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } TTYWrapObject* ttyWrap = jsDynamicCast(callFrame->thisValue()); if (UNLIKELY(!ttyWrap)) { JSC::throwTypeError(globalObject, throwScope, "TTY.setRawMode expects a TTYWrapObject as this"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } int fd = ttyWrap->fd; JSValue mode = callFrame->argument(0); if (!mode.isNumber()) { throwTypeError(globalObject, throwScope, "mode must be a number"_s); - return JSValue::encode(jsUndefined()); + return {}; } #if OS(WINDOWS) @@ -271,20 +271,20 @@ JSC_DEFINE_HOST_FUNCTION(TTYWrap_functionGetWindowSize, auto throwScope = DECLARE_THROW_SCOPE(vm); if (argCount == 0) { JSC::throwTypeError(globalObject, throwScope, "getWindowSize requires 1 argument (an array)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } TTYWrapObject* ttyWrap = jsDynamicCast(callFrame->thisValue()); if (UNLIKELY(!ttyWrap)) { JSC::throwTypeError(globalObject, throwScope, "TTY.getWindowSize expects a TTYWrapObject as this"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } int fd = ttyWrap->fd; JSC::JSArray* array = jsDynamicCast(callFrame->uncheckedArgument(0)); if (!array || array->length() < 2) { JSC::throwTypeError(globalObject, throwScope, "getWindowSize expects an array"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } size_t width, height; @@ -306,7 +306,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionInternalGetWindowSize, auto throwScope = DECLARE_THROW_SCOPE(vm); if (argCount == 0) { JSC::throwTypeError(globalObject, throwScope, "getWindowSize requires 2 argument (a file descriptor)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } int fd = callFrame->uncheckedArgument(0).toInt32(globalObject); @@ -314,7 +314,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionInternalGetWindowSize, JSC::JSArray* array = jsDynamicCast(callFrame->uncheckedArgument(1)); if (!array || array->length() < 2) { JSC::throwTypeError(globalObject, throwScope, "getWindowSize requires 2 argument (an array)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } size_t width, height; @@ -420,26 +420,26 @@ public: if (!constructor) { throwTypeError(globalObject, scope, "TTYWrapConstructor::construct called with wrong 'this' value"_s); - return JSValue::encode(jsUndefined()); + return {}; } if (callframe->argumentCount() < 1) { throwTypeError(globalObject, scope, "Expected at least 1 argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue fd_value = callframe->argument(0); int32_t fd = fd_value.toInt32(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (fd < 0) { throwTypeError(globalObject, scope, "fd must be a positive number"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto prototypeValue = constructor->get(globalObject, vm.propertyNames->prototype); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!prototypeValue.isObject()) { throwTypeError(globalObject, scope, "TTYWrapConstructor prototype is not an object"_s); return {}; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index b6a34291eb..c1383d8c3c 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -856,11 +856,11 @@ JSC_DEFINE_HOST_FUNCTION(functionFulfillModuleSync, JSC::JSValue key = callFrame->argument(0); auto moduleKey = key.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (moduleKey.endsWith(".node"_s)) { throwException(globalObject, scope, createTypeError(globalObject, "To load Node-API modules, use require() or process.dlopen instead of importSync."_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto specifier = Bun::toString(moduleKey); @@ -1308,14 +1308,14 @@ JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask, auto scope = DECLARE_THROW_SCOPE(vm); if (callFrame->argumentCount() == 0) { JSC::throwTypeError(globalObject, scope, "queueMicrotask requires 1 argument (a function)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSValue job = callFrame->argument(0); if (!job.isObject() || !job.getObject()->isCallable()) { JSC::throwTypeError(globalObject, scope, "queueMicrotask expects a function"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } Zig::GlobalObject* global = JSC::jsCast(globalObject); @@ -1355,7 +1355,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeout, switch (argumentCount) { case 0: { JSC::throwTypeError(globalObject, scope, "setTimeout requires 1 argument (a function)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } case 1: case 2: { @@ -1372,7 +1372,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeout, if (UNLIKELY(!args)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } arguments = JSValue(args); @@ -1381,7 +1381,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeout, if (UNLIKELY(!job.isObject() || !job.getObject()->isCallable())) { JSC::throwTypeError(globalObject, scope, "setTimeout expects a function"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } #ifdef BUN_DEBUG @@ -1411,7 +1411,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetInterval, switch (argumentCount) { case 0: { JSC::throwTypeError(globalObject, scope, "setInterval requires 1 argument (a function)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } case 1: { num = jsNumber(0); @@ -1431,7 +1431,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetInterval, if (UNLIKELY(!args)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } arguments = JSValue(args); @@ -1440,7 +1440,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetInterval, if (UNLIKELY(!job.isObject() || !job.getObject()->isCallable())) { JSC::throwTypeError(globalObject, scope, "setInterval expects a function"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } #ifdef BUN_DEBUG @@ -1465,7 +1465,7 @@ JSC_DEFINE_HOST_FUNCTION(functionClearInterval, if (callFrame->argumentCount() == 0) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); JSC::throwTypeError(globalObject, scope, "clearInterval requires 1 argument (a number)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSValue num = callFrame->argument(0); @@ -1492,7 +1492,7 @@ JSC_DEFINE_HOST_FUNCTION(functionClearTimeout, if (callFrame->argumentCount() == 0) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); JSC::throwTypeError(globalObject, scope, "clearTimeout requires 1 argument (a number)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSValue num = callFrame->argument(0); @@ -1519,7 +1519,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStructuredClone, if (callFrame->argumentCount() == 0) { throwTypeError(globalObject, throwScope, "structuredClone requires 1 argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSValue value = callFrame->argument(0); @@ -1564,7 +1564,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, if (callFrame->argumentCount() == 0) { JSC::throwTypeError(globalObject, throwScope, "btoa requires 1 argument (a string)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSValue arg0 = callFrame->uncheckedArgument(0); @@ -1577,7 +1577,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, if (!encodedString.containsOnlyLatin1()) { throwException(globalObject, throwScope, createDOMException(globalObject, InvalidCharacterError)); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } // Reminder: btoa() is for Byte Strings @@ -1590,7 +1590,7 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, auto dest = WTF::String::createUninitialized(length, ptr); if (UNLIKELY(dest.isNull())) { throwOutOfMemoryError(globalObject, throwScope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } WTF::StringImpl::copyCharacters(ptr, encodedString.span16()); encodedString = WTFMove(dest); @@ -1614,7 +1614,7 @@ JSC_DEFINE_HOST_FUNCTION(functionATOB, if (callFrame->argumentCount() == 0) { JSC::throwTypeError(globalObject, throwScope, "atob requires 1 argument (a string)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } WTF::String encodedString = callFrame->uncheckedArgument(0).toWTFString(globalObject); @@ -1623,7 +1623,7 @@ JSC_DEFINE_HOST_FUNCTION(functionATOB, auto result = Bun::Base64::atob(encodedString); if (result.hasException()) { throwException(globalObject, throwScope, createDOMException(*globalObject, result.releaseException())); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } RELEASE_AND_RETURN(throwScope, JSValue::encode(jsString(vm, result.releaseReturnValue()))); @@ -1689,7 +1689,7 @@ extern "C" JSC__JSValue Bun__createArrayBufferForCopy(JSC::JSGlobalObject* globa if (UNLIKELY(!arrayBuffer)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (len > 0) @@ -1706,7 +1706,7 @@ extern "C" JSC__JSValue Bun__allocUint8ArrayForCopy(JSC::JSGlobalObject* globalO if (UNLIKELY(!array)) { JSC::throwOutOfMemoryError(globalObject, scope); - return encodedJSValue(); + return {}; } *ptr = array->vector(); @@ -1726,7 +1726,7 @@ extern "C" JSC__JSValue Bun__createUint8ArrayForCopy(JSC::JSGlobalObject* global if (UNLIKELY(!array)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } if (len > 0 && ptr != nullptr) @@ -1745,7 +1745,7 @@ JSC_DEFINE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer, if (UNLIKELY(!arrayBuffer)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSArrayBuffer::create(globalObject->vm(), globalObject->arrayBufferStructure(JSC::ArrayBufferSharingMode::Default), WTFMove(arrayBuffer)))); @@ -1786,15 +1786,15 @@ static inline JSC::EncodedJSValue jsFunctionAddEventListenerBody(JSC::JSGlobalOb return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventTarget"_s, "addEventListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto options = argument2.value().isUndefined() ? false : convert, IDLBoolean>>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto result = JSValue::encode(WebCore::toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addEventListenerForBindings(WTFMove(type), WTFMove(listener), WTFMove(options)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); return result; } @@ -1815,15 +1815,15 @@ static inline JSC::EncodedJSValue jsFunctionRemoveEventListenerBody(JSC::JSGloba return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventTarget"_s, "removeEventListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto options = argument2.value().isUndefined() ? false : convert, IDLBoolean>>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto result = JSValue::encode(WebCore::toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.removeEventListenerForBindings(WTFMove(type), WTFMove(listener), WTFMove(options)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); return result; } @@ -1844,7 +1844,7 @@ static inline JSC::EncodedJSValue jsFunctionDispatchEventBody(JSC::JSGlobalObjec return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto event = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "event"_s, "EventTarget"_s, "dispatchEvent"_s, "Event"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(WebCore::toJS(*lexicalGlobalObject, throwScope, impl.dispatchEventForBindings(*event)))); } @@ -2221,14 +2221,14 @@ static inline JSC__JSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig: if (UNLIKELY(!object)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected object"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSPromise* promise = JSC::jsDynamicCast(object); if (UNLIKELY(!promise)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected promise"_s); - return JSValue::encode(jsUndefined()); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(promise)); @@ -2267,14 +2267,14 @@ extern "C" JSC__JSValue ZigGlobalObject__readableStreamToBytes(Zig::GlobalObject if (UNLIKELY(!object)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected object"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSC::JSPromise* promise = JSC::jsDynamicCast(object); if (UNLIKELY(!promise)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected promise"_s); - return JSValue::encode(jsUndefined()); + return {}; } RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(promise)); @@ -2372,7 +2372,7 @@ JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToArrayBuffer, (JSGlobalObject * if (UNLIKELY(callFrame->argumentCount() < 1)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected at least one argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto readableStreamValue = callFrame->uncheckedArgument(0); @@ -2387,7 +2387,7 @@ JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToBytes, (JSGlobalObject * global if (UNLIKELY(callFrame->argumentCount() < 1)) { auto throwScope = DECLARE_THROW_SCOPE(vm); throwTypeError(globalObject, throwScope, "Expected at least one argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto readableStreamValue = callFrame->uncheckedArgument(0); @@ -2546,7 +2546,7 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncAppendStackTrace, (JSC::JSGlobalObj if (!source || !destination) { throwTypeError(lexicalGlobalObject, scope, "First & second argument must be an Error object"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (!destination->stackTrace()) { @@ -2571,12 +2571,12 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionDefaultErrorPrepareStackTrace, (JSGlobalObjec auto callSites = jsDynamicCast(callFrame->argument(1)); if (!errorObject) { throwTypeError(lexicalGlobalObject, scope, "First argument must be an Error object"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } JSValue result = formatStackTraceToJSValue(vm, globalObject, lexicalGlobalObject, errorObject, callSites, jsUndefined()); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode({})); + RETURN_IF_EXCEPTION(scope, {}); return JSC::JSValue::encode(result); } @@ -2648,7 +2648,7 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb } globalObject->formatStackTrace(vm, lexicalGlobalObject, errorObject, callSites, JSC::JSValue()); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode({})); + RETURN_IF_EXCEPTION(scope, {}); return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -3212,14 +3212,14 @@ JSC_DEFINE_HOST_FUNCTION(functionSetImmediate, auto argCount = callFrame->argumentCount(); if (argCount == 0) { JSC::throwTypeError(globalObject, scope, "setImmediate requires 1 argument (a function)"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto job = callFrame->argument(0); if (!job.isObject() || !job.getObject()->isCallable()) { JSC::throwTypeError(globalObject, scope, "setImmediate expects a function"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } JSC::JSValue arguments = {}; @@ -3238,7 +3238,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetImmediate, if (UNLIKELY(!args)) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } arguments = JSValue(args); diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index e8addc06b1..5ef057876a 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -257,21 +257,21 @@ extern "C" uint8_t AsymmetricMatcherConstructorType__fromJS(JSC__JSGlobalObject* } auto stringConstructorValue = globalObject->stringPrototype()->getIfPropertyExists(globalObject, vm.propertyNames->constructor); - RETURN_IF_EXCEPTION(scope, static_cast(AsymmetricMatcherConstructorType::none)); + RETURN_IF_EXCEPTION(scope, {}); if (stringConstructorValue == object) { return static_cast(AsymmetricMatcherConstructorType::String); } auto symbolConstructorValue = globalObject->symbolPrototype()->getIfPropertyExists(globalObject, vm.propertyNames->constructor); - RETURN_IF_EXCEPTION(scope, static_cast(AsymmetricMatcherConstructorType::none)); + RETURN_IF_EXCEPTION(scope, {}); if (symbolConstructorValue == object) { return static_cast(AsymmetricMatcherConstructorType::Symbol); } auto bigIntConstructorValue = globalObject->bigIntPrototype()->getIfPropertyExists(globalObject, vm.propertyNames->constructor); - RETURN_IF_EXCEPTION(scope, static_cast(AsymmetricMatcherConstructorType::none)); + RETURN_IF_EXCEPTION(scope, {}); if (bigIntConstructorValue == object) { return static_cast(AsymmetricMatcherConstructorType::BigInt); @@ -1831,7 +1831,7 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, result->putDirect(vm, clientData->builtinNames().errnoPublicName(), JSC::JSValue(err.errno_), JSC::PropertyAttribute::DontDelete | 0); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue())); + RETURN_IF_EXCEPTION(scope, {}); scope.release(); return JSC::JSValue::encode(JSC::JSValue(result)); @@ -1853,10 +1853,10 @@ bool JSC__JSValue__hasOwnPropertyValue(JSC__JSValue value, JSC__JSGlobalObject* auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); auto* object = JSC::jsCast(JSC::JSValue::decode(value)); auto propertyKey = JSC::JSValue::decode(ownKey).toPropertyKey(globalObject); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); const bool result = JSC::objectPrototypeHasOwnProperty(globalObject, object, propertyKey); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); return result; } @@ -1939,7 +1939,7 @@ double JSC__JSValue__getLengthIfPropertyExistsInternal(JSC__JSValue value, JSC__ if (auto* object = jsDynamicCast(cell)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); if (JSValue lengthValue = object->getIfPropertyExists(globalObject, globalObject->vm().propertyNames->length)) { - RETURN_IF_EXCEPTION(scope, 0); + RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN(scope, lengthValue.toNumber(globalObject)); } } @@ -2472,7 +2472,7 @@ extern "C" JSC::JSInternalPromise* JSModuleLoader__import(JSC::JSGlobalObject* g auto scope = DECLARE_THROW_SCOPE(vm); auto* promise = JSC::importModule(globalObject, JSC::Identifier::fromString(vm, moduleNameStr->toWTFString()), jsUndefined(), jsUndefined(), jsUndefined()); - RETURN_IF_EXCEPTION(scope, nullptr); + RETURN_IF_EXCEPTION(scope, {}); return promise; } @@ -2605,7 +2605,7 @@ JSC__JSValue JSC__JSValue__keys(JSC__JSGlobalObject* globalObject, JSC__JSValue auto scope = DECLARE_THROW_SCOPE(vm); JSC::JSObject* object = JSC::JSValue::decode(objectValue).toObject(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN(scope, JSValue::encode(ownPropertyKeys(globalObject, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude))); } @@ -2750,7 +2750,7 @@ JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* globalObject, if (!array) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue()); + return {}; } RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::JSValue(array))); @@ -2781,7 +2781,7 @@ JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject* glob } if (!array) { JSC::throwOutOfMemoryError(globalObject, scope); - return JSC::JSValue::encode(JSC::JSValue()); + return {}; } JSC::Structure* errorStructure = globalObject->errorStructure(JSC::ErrorType::AggregateError); @@ -3147,7 +3147,7 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC__JSPromise* promise, JSC__J globalObject->m_asyncContextData.get()->getInternalField(0), promise, value); - RETURN_IF_EXCEPTION(scope, void()); + RETURN_IF_EXCEPTION(scope, ); } } @@ -3389,7 +3389,7 @@ extern "C" void JSC__JSValue__putMayBeIndex(JSC__JSValue target, JSC__JSGlobalOb JSC::JSObject* object = JSC::JSValue::decode(target).asCell()->getObject(); object->putDirectMayBeIndex(globalObject, JSC::PropertyName(identifier), JSC::JSValue::decode(value)); - RETURN_IF_EXCEPTION(scope, void()); + RETURN_IF_EXCEPTION(scope, ); } bool JSC__JSValue__isClass(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) @@ -3846,12 +3846,12 @@ JSC__JSValue JSC__JSValue__getIfPropertyExistsFromPath(JSC__JSValue JSValue0, JS } JSString* propNameString = item.toString(globalObject); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); PropertyName propName = PropertyName(propNameString->toIdentifier(globalObject)); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); currProp = currProp.toObject(globalObject)->getIfPropertyExists(globalObject, propName); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); if (currProp.isEmpty()) { return false; } @@ -4000,10 +4000,10 @@ bool JSC__JSValue__stringIncludes(JSC__JSValue value, JSC__JSGlobalObject* globa auto scope = DECLARE_CATCH_SCOPE(vm); WTF::String stringToSearchIn = JSC::JSValue::decode(value).toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); WTF::String searchString = JSC::JSValue::decode(other).toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); return stringToSearchIn.find(searchString, 0) != WTF::notFound; } @@ -5224,7 +5224,7 @@ restart: iterating->methodTable()->getOwnPropertyNames(iterating, globalObject, properties, DontEnumPropertiesMode::Include); } - RETURN_IF_EXCEPTION(scope, void()); + RETURN_IF_EXCEPTION(scope, ); for (auto& property : properties) { if (UNLIKELY(property.isEmpty() || property.isNull())) continue; @@ -5436,7 +5436,7 @@ bool JSC__JSValue__isInstanceOf(JSC__JSValue JSValue0, JSC__JSGlobalObject* glob return false; bool result = jsConstructor->hasInstance(globalObject, jsValue); - RETURN_IF_EXCEPTION(scope, false); + RETURN_IF_EXCEPTION(scope, {}); return result; } diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 8c5ab8a0aa..a88b82845e 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -173,7 +173,7 @@ static inline JSC::JSValue jsBigIntFromSQLite(JSC::JSGlobalObject* globalObject, #define CHECK_THIS \ if (UNLIKELY(!castedThis)) { \ throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); \ - return JSValue::encode(jsUndefined()); \ + return {}; \ } #define DO_REBIND(param) \ @@ -184,13 +184,13 @@ static inline JSC::JSValue jsBigIntFromSQLite(JSC::JSGlobalObject* globalObject, } \ } else { \ throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Expected object or array"_s)); \ - return JSValue::encode(jsUndefined()); \ + return {}; \ } #define CHECK_PREPARED \ if (UNLIKELY(castedThis->stmt == nullptr || castedThis->version_db == nullptr)) { \ throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Statement has finalized"_s)); \ - return JSValue::encode(jsUndefined()); \ + return {}; \ } #define CHECK_PREPARED_JIT \ @@ -866,7 +866,7 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, SQLiteBindin const auto identifier = Identifier::fromString(vm, str); PropertySlot slot(target, PropertySlot::InternalMethodType::GetOwnProperty); if (!target->getOwnNonIndexPropertySlot(vm, &structure, identifier, slot)) { - return JSValue(); + return {}; } if (LIKELY(!slot.isTaintedByOpaqueObject())) { @@ -887,10 +887,10 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, SQLiteBindin continue; } } - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!rebindValue(globalObject, db, stmt, i + 1, value, scope, clone, safeIntegers)) { - return JSValue(); + return {}; } RETURN_IF_EXCEPTION(scope, {}); @@ -912,10 +912,10 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, SQLiteBindin } } - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!rebindValue(globalObject, db, stmt, i + 1, value, scope, clone, safeIntegers)) { - return JSValue(); + return {}; } RETURN_IF_EXCEPTION(scope, {}); @@ -938,10 +938,10 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, SQLiteBindin } } - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!rebindValue(globalObject, db, stmt, i + 1, value, scope, clone, safeIntegers)) { - return JSValue(); + return {}; } RETURN_IF_EXCEPTION(scope, {}); @@ -960,20 +960,20 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, SQLiteBindin } } - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); JSValue value; if (LIKELY(!slot.isTaintedByOpaqueObject())) value = slot.getValue(globalObject, property); else { value = target->get(globalObject, property); - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); } - RETURN_IF_EXCEPTION(scope, JSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!rebindValue(globalObject, db, stmt, i + 1, value, scope, clone, safeIntegers)) { - return JSValue(); + return {}; } RETURN_IF_EXCEPTION(scope, {}); @@ -1034,24 +1034,24 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetCustomSQLite, (JSC::JSGlobalObject * l JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (callFrame->argumentCount() < 1) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected 1 argument"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::JSValue sqliteStrValue = callFrame->argument(0); if (UNLIKELY(!sqliteStrValue.isString())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLite path"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } #if LAZY_LOAD_SQLITE if (sqlite3_handle) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "SQLite already loaded\nThis function can only be called before SQLite has been loaded and exactly once. SQLite auto-loads when the first time you open a Database."_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3_lib_path = sqliteStrValue.toWTFString(lexicalGlobalObject).utf8().data(); @@ -1059,7 +1059,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetCustomSQLite, (JSC::JSGlobalObject * l sqlite3_handle = nullptr; WTF::String msg = WTF::String::fromUTF8(dlerror()); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, msg)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } #endif @@ -1086,29 +1086,29 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (callFrame->argumentCount() < 1) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected 1 argument"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (UNLIKELY(!array)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected Uint8Array or Buffer"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (UNLIKELY(array->isDetached())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "TypedArray is detached"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } #if LAZY_LOAD_SQLITE if (UNLIKELY(lazyLoadSQLite() < 0)) { WTF::String msg = WTF::String::fromUTF8(dlerror()); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, msg)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } #endif initializeSQLite(); @@ -1117,12 +1117,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic void* ptr = array->vector(); if (UNLIKELY(ptr == nullptr || byteLength == 0)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "ArrayBuffer must not be empty"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } void* data = sqlite3_malloc64(byteLength); if (UNLIKELY(data == nullptr)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Failed to allocate memory"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (byteLength) { memcpy(data, ptr, byteLength); @@ -1131,7 +1131,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic sqlite3* db = nullptr; if (sqlite3_open_v2(":memory:", &db, DEFAULT_SQLITE_FLAGS, nullptr) != SQLITE_OK) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Failed to open SQLite"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int status = sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL); @@ -1147,13 +1147,13 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic if (status == SQLITE_BUSY) { sqlite3_free(data); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "SQLITE_BUSY"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (status != SQLITE_OK) { sqlite3_free(data); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, status == SQLITE_ERROR ? "unable to deserialize database"_s : sqliteString(sqlite3_errstr(status)))); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto count = databases().size(); @@ -1170,33 +1170,33 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSerialize, (JSC::JSGlobalObject * lexical JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } WTF::String attachedName = callFrame->argument(1).toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (attachedName.isEmpty()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected attached database name"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3_int64 length = -1; unsigned char* data = sqlite3_serialize(db, attachedName.utf8().data(), &length, 0); if (UNLIKELY(data == nullptr && length)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Out of memory"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } RELEASE_AND_RETURN(scope, JSBuffer__bufferFromPointerAndLengthAndDeinit(lexicalGlobalObject, reinterpret_cast(data), static_cast(length), data, sqlite_free_typed_array)); @@ -1211,19 +1211,19 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::JSValue extension = callFrame->argument(1); if (UNLIKELY(!extension.isString())) { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Expected string"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto extensionString = extension.toWTFString(lexicalGlobalObject); @@ -1232,12 +1232,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION")) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "This build of sqlite3 does not support dynamic extension loading"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto entryPointStr = callFrame->argumentCount() > 2 && callFrame->argument(2).isString() ? callFrame->argument(2).toWTFString(lexicalGlobalObject) : String(); @@ -1248,7 +1248,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje // TODO: can we disable loading extensions after this? if (rc != SQLITE_OK) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, error ? sqliteString(error) : String::fromUTF8(sqlite3_errmsg(db)))); - return JSValue::encode(JSC::jsUndefined()); + return {}; } RELEASE_AND_RETURN(scope, JSValue::encode(JSC::jsUndefined())); @@ -1271,24 +1271,24 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (callFrame->argumentCount() < 2) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected at least 2 arguments"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int32_t handle = callFrame->argument(0).toInt32(lexicalGlobalObject); if (databases().size() < handle) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::JSValue internalFlagsValue = callFrame->argument(1); @@ -1297,7 +1297,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l JSC::JSValue sqlValue = callFrame->argument(3); if (UNLIKELY(!sqlValue.isString())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQL string"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } EnsureStillAliveScope bindingsAliveScope = callFrame->argument(4); @@ -1305,7 +1305,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l auto sqlString = sqlValue.toWTFString(lexicalGlobalObject); if (UNLIKELY(sqlString.length() == 0)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "SQL string mustn't be blank"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } CString utf8; @@ -1381,7 +1381,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l } } else { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Expected bindings to be an object or array"_s)); - return JSValue::encode(jsUndefined()); + return {}; } didSetBindings = true; } @@ -1396,12 +1396,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l if (UNLIKELY(rc != SQLITE_OK && rc != SQLITE_DONE)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, db)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (!didExecuteAny) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Query contained no valid SQL statement; likely empty query."_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } if (auto* diff = JSC::jsDynamicCast(diffValue)) { @@ -1427,28 +1427,28 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementIsInTransactionFunction, (JSC::JSGlobalOb JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::JSValue dbNumber = callFrame->argument(0); if (!dbNumber.isNumber()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int32_t handle = dbNumber.toInt32(lexicalGlobalObject); if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } RELEASE_AND_RETURN(scope, JSValue::encode(jsBoolean(!sqlite3_get_autocommit(db)))); @@ -1463,7 +1463,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } JSC::JSValue dbNumber = callFrame->argument(0); @@ -1474,25 +1474,25 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO if (!dbNumber.isNumber() || !sqlValue.isString()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "SQLStatement requires a number and a string"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int32_t handle = dbNumber.toInt32(lexicalGlobalObject); if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } sqlite3* db = databases()[handle]->db; if (!db) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Cannot use a closed database"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto sqlString = sqlValue.toWTFString(lexicalGlobalObject); if (!sqlString.length()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid SQL statement"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } unsigned int flags = DEFAULT_SQLITE_PREPARE_FLAGS; @@ -1501,7 +1501,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO int prepareFlags = prepareFlagsValue.toInt32(lexicalGlobalObject); if (prepareFlags < 0 || prepareFlags > MAX_SQLITE_PREPARE_FLAG) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid prepare flags"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } flags = static_cast(prepareFlags); } @@ -1525,7 +1525,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO if (rc != SQLITE_OK) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, db)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int64_t memoryChange = sqlite_malloc_amount - currentMemoryUsage; @@ -1564,25 +1564,25 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje JSSQLStatementConstructor* constructor = jsDynamicCast(thisValue.getObject()); if (!constructor) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); - return JSValue::encode(jsUndefined()); + return {}; } if (callFrame->argumentCount() < 1) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected 1 argument"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSValue pathValue = callFrame->argument(0); if (!pathValue.isString()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected string"_s)); - return JSValue::encode(jsUndefined()); + return {}; } #if LAZY_LOAD_SQLITE if (UNLIKELY(lazyLoadSQLite() < 0)) { WTF::String msg = WTF::String::fromUTF8(dlerror()); throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, msg)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } #endif initializeSQLite(); @@ -1596,7 +1596,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje JSValue flags = callFrame->argument(1); if (!flags.isNumber()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected number"_s)); - return JSValue::encode(jsUndefined()); + return {}; } openFlags = flags.toInt32(lexicalGlobalObject); @@ -1609,8 +1609,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje if (statusCode != SQLITE_OK) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, db)); - - return JSValue::encode(jsUndefined()); + return {}; } sqlite3_extended_result_codes(db, 1); @@ -1646,26 +1645,26 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj if (!constructor) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); - return JSValue::encode(jsUndefined()); + return {}; } if (callFrame->argumentCount() < 1) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected 1 argument"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSValue dbNumber = callFrame->argument(0); JSValue throwOnError = callFrame->argument(1); if (!dbNumber.isNumber()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected number"_s)); - return JSValue::encode(jsUndefined()); + return {}; } int dbIndex = dbNumber.toInt32(lexicalGlobalObject); if (dbIndex < 0 || dbIndex >= databases().size()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(jsUndefined()); + return {}; } bool shouldThrowOnError = (throwOnError.isEmpty() || throwOnError.isUndefined()) ? false : throwOnError.toBoolean(lexicalGlobalObject); @@ -1681,7 +1680,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj int statusCode = shouldThrowOnError ? sqlite3_close(db) : sqlite3_close_v2(db); if (statusCode != SQLITE_OK) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, WTF::String::fromUTF8(sqlite3_errstr(statusCode)))); - return JSValue::encode(jsUndefined()); + return {}; } databases()[dbIndex]->db = nullptr; @@ -1697,12 +1696,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFcntlFunction, (JSC::JSGlobalObject * lex JSSQLStatementConstructor* thisObject = jsDynamicCast(thisValue.getObject()); if (UNLIKELY(!thisObject)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected SQLStatement"_s)); - return JSValue::encode(jsUndefined()); + return {}; } if (callFrame->argumentCount() < 2) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected 2 arguments"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSValue dbNumber = callFrame->argument(0); @@ -1712,7 +1711,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFcntlFunction, (JSC::JSGlobalObject * lex if (!dbNumber.isNumber() || !opNumber.isNumber()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected number"_s)); - return JSValue::encode(jsUndefined()); + return {}; } int dbIndex = dbNumber.toInt32(lexicalGlobalObject); @@ -1720,7 +1719,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFcntlFunction, (JSC::JSGlobalObject * lex if (dbIndex < 0 || dbIndex >= databases().size()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); - return JSValue::encode(jsUndefined()); + return {}; } sqlite3* db = databases()[dbIndex]->db; @@ -1742,13 +1741,13 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFcntlFunction, (JSC::JSGlobalObject * lex if (auto* view = jsDynamicCast(resultValue.getObject())) { if (view->isDetached()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "TypedArray is detached"_s)); - return JSValue::encode(jsUndefined()); + return {}; } resultPtr = view->vector(); if (resultPtr == nullptr) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Expected buffer"_s)); - return JSValue::encode(jsUndefined()); + return {}; } } } else if (resultValue.isNumber()) { @@ -1767,7 +1766,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementFcntlFunction, (JSC::JSGlobalObject * lex if (statusCode == SQLITE_ERROR) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, db)); - return JSValue::encode(jsUndefined()); + return {}; } return JSValue::encode(jsNumber(statusCode)); @@ -1915,16 +1914,16 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetPrototypeFunction, (JSGlobalObject * l if (!classObject->isConstructor()) { throwTypeError(lexicalGlobalObject, scope, "Expected a constructor"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue prototype = classObject->getIfPropertyExists(lexicalGlobalObject, vm.propertyNames->prototype); + RETURN_IF_EXCEPTION(scope, {}); if (UNLIKELY(!prototype && !scope.exception())) { throwTypeError(lexicalGlobalObject, scope, "Expected constructor to have a prototype"_s); + return {}; } - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); - if (!prototype.isObject()) { throwTypeError(lexicalGlobalObject, scope, "Expected a constructor prototype to be an object"_s); return {}; @@ -1945,7 +1944,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetPrototypeFunction, (JSGlobalObject * l } } else { throwTypeError(lexicalGlobalObject, scope, "Expected class to be a constructor or undefined"_s); - return JSValue::encode(jsUndefined()); + return {}; } return JSValue::encode(jsUndefined()); @@ -1965,7 +1964,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob if (UNLIKELY(statusCode != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); - return JSValue::encode(jsUndefined()); + return {}; } int64_t currentMemoryUsage = sqlite_malloc_amount; @@ -2019,7 +2018,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionAll, (JSC::JSGlob if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); sqlite3_reset(stmt); - return JSValue::encode(jsUndefined()); + return {}; } int64_t memoryChange = sqlite_malloc_amount - currentMemoryUsage; @@ -2045,7 +2044,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob int statusCode = sqlite3_reset(stmt); if (UNLIKELY(statusCode != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); - return JSValue::encode(jsUndefined()); + return {}; } if (callFrame->argumentCount() > 0) { @@ -2078,7 +2077,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionGet, (JSC::JSGlob } else { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); sqlite3_reset(stmt); - return JSValue::encode(jsUndefined()); + return {}; } } @@ -2098,7 +2097,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo if (UNLIKELY(statusCode != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); sqlite3_reset(stmt); - return JSValue::encode(jsUndefined()); + return {}; } int count = callFrame->argumentCount(); @@ -2154,7 +2153,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRows, (JSC::JSGlo if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); sqlite3_reset(stmt); - return JSValue::encode(jsUndefined()); + return {}; } // sqlite3_reset(stmt); @@ -2176,7 +2175,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob int statusCode = sqlite3_reset(stmt); if (UNLIKELY(statusCode != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); - return JSValue::encode(jsUndefined()); + return {}; } JSValue diffValue = callFrame->argument(0); @@ -2188,7 +2187,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob if (UNLIKELY(!castedThis->version_db->db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } int total_changes_before = sqlite3_total_changes(castedThis->version_db->db); @@ -2209,7 +2208,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteStatementFunctionRun, (JSC::JSGlob if (UNLIKELY(status != SQLITE_DONE && status != SQLITE_OK)) { throwException(lexicalGlobalObject, scope, createSQLiteError(lexicalGlobalObject, castedThis->version_db->db)); sqlite3_reset(stmt); - return JSValue::encode(jsUndefined()); + return {}; } if (auto* diff = JSC::jsDynamicCast(diffValue)) { diff --git a/src/bun.js/bindings/webcore/JSAbortController.cpp b/src/bun.js/bindings/webcore/JSAbortController.cpp index 81464aa295..467a6ce829 100644 --- a/src/bun.js/bindings/webcore/JSAbortController.cpp +++ b/src/bun.js/bindings/webcore/JSAbortController.cpp @@ -216,7 +216,7 @@ static inline JSC::EncodedJSValue jsAbortControllerPrototypeFunction_abortBody(J auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->argument(0); auto reason = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.abort(*jsCast(lexicalGlobalObject), WTFMove(reason)); }))); } diff --git a/src/bun.js/bindings/webcore/JSAbortSignal.cpp b/src/bun.js/bindings/webcore/JSAbortSignal.cpp index b724b1c419..bc3f2e3426 100644 --- a/src/bun.js/bindings/webcore/JSAbortSignal.cpp +++ b/src/bun.js/bindings/webcore/JSAbortSignal.cpp @@ -271,7 +271,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_abortBody(JSC return JSValue::encode(jsUndefined()); EnsureStillAliveScope argument0 = callFrame->argument(0); auto reason = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJSNewlyCreated>(*lexicalGlobalObject, *jsCast(lexicalGlobalObject), throwScope, AbortSignal::abort(*jsCast(lexicalGlobalObject), *context, WTFMove(reason))))); } @@ -293,7 +293,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_timeoutBody(J return JSValue::encode(jsUndefined()); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto milliseconds = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJSNewlyCreated>(*lexicalGlobalObject, *jsCast(lexicalGlobalObject), throwScope, AbortSignal::timeout(*context, WTFMove(milliseconds))))); } @@ -315,7 +315,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_anyBody(JSC:: return JSValue::encode(jsUndefined()); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto signals = convert>>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJSNewlyCreated>(*lexicalGlobalObject, *jsCast(lexicalGlobalObject), throwScope, AbortSignal::any(*context, WTFMove(signals))))); } diff --git a/src/bun.js/bindings/webcore/JSBroadcastChannel.cpp b/src/bun.js/bindings/webcore/JSBroadcastChannel.cpp index 980dfa0050..93b2a40656 100644 --- a/src/bun.js/bindings/webcore/JSBroadcastChannel.cpp +++ b/src/bun.js/bindings/webcore/JSBroadcastChannel.cpp @@ -115,7 +115,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBroadcastChannelDOMCon return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "BroadcastChannel"_s); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = BroadcastChannel::create(*context, WTFMove(name)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -281,7 +281,7 @@ static inline JSC::EncodedJSValue jsBroadcastChannelPrototypeFunction_postMessag return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast(lexicalGlobalObject), WTFMove(message)); }))); } diff --git a/src/bun.js/bindings/webcore/JSCloseEvent.cpp b/src/bun.js/bindings/webcore/JSCloseEvent.cpp index 4b297e6e41..9d11dbad98 100644 --- a/src/bun.js/bindings/webcore/JSCloseEvent.cpp +++ b/src/bun.js/bindings/webcore/JSCloseEvent.cpp @@ -185,10 +185,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSCloseEventDOMConstruct return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto eventInitDict = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = CloseEvent::create(WTFMove(type), WTFMove(eventInitDict)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/JSCustomEvent.cpp b/src/bun.js/bindings/webcore/JSCustomEvent.cpp index 1a88448182..dbc73d293d 100644 --- a/src/bun.js/bindings/webcore/JSCustomEvent.cpp +++ b/src/bun.js/bindings/webcore/JSCustomEvent.cpp @@ -166,10 +166,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSCustomEventDOMConstruc return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto eventInitDict = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = CustomEvent::create(type, WTFMove(eventInitDict)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -278,16 +278,16 @@ static inline JSC::EncodedJSValue jsCustomEventPrototypeFunction_initCustomEvent return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto bubbles = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto cancelable = convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->argument(3); auto detail = argument3.value().isUndefined() ? jsNull() : convert(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.initCustomEvent(type, WTFMove(bubbles), WTFMove(cancelable), WTFMove(detail)); }))); } diff --git a/src/bun.js/bindings/webcore/JSDOMException.cpp b/src/bun.js/bindings/webcore/JSDOMException.cpp index 0d6ca98497..4a1650a25d 100644 --- a/src/bun.js/bindings/webcore/JSDOMException.cpp +++ b/src/bun.js/bindings/webcore/JSDOMException.cpp @@ -128,10 +128,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDOMExceptionDOMConstru ASSERT(castedThis); EnsureStillAliveScope argument0 = callFrame->argument(0); auto message = argument0.value().isUndefined() ? emptyString() : convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto name = argument1.value().isUndefined() ? "Error"_s : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = DOMException::create(WTFMove(message), WTFMove(name)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/JSDOMFormData.cpp b/src/bun.js/bindings/webcore/JSDOMFormData.cpp index 755944a96b..3a1ecab66f 100644 --- a/src/bun.js/bindings/webcore/JSDOMFormData.cpp +++ b/src/bun.js/bindings/webcore/JSDOMFormData.cpp @@ -281,10 +281,10 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_append1Body(JSC auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.append(WTFMove(name), WTFMove(value)); }))); } @@ -299,7 +299,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_append2Body(JSC auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); RefPtr blobValue = nullptr; @@ -310,11 +310,11 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_append2Body(JSC if (!blobValue) { throwTypeError(lexicalGlobalObject, throwScope, "Expected argument to be a Blob."_s); } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto filename = argument2.value().isUndefined() ? Blob__getFileNameString(blobValue->impl()).toWTFString(BunString::ZeroCopy) : convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.append(WTFMove(name), WTFMove(blobValue), WTFMove(filename)); }))); } @@ -354,7 +354,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_deleteBody(JSC: return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.remove(WTFMove(name)); }))); } @@ -374,7 +374,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_getBody(JSC::JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.get(WTFMove(name))))); } @@ -394,7 +394,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_getAllBody(JSC: return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto entries = impl.getAll(WTFMove(name)); JSC::JSArray* result = JSC::constructEmptyArray(lexicalGlobalObject, nullptr, 0); for (auto entry : entries) { @@ -425,7 +425,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_hasBody(JSC::JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, impl.has(WTFMove(name))))); } @@ -443,10 +443,10 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_set1Body(JSC::J auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.set(WTFMove(name), WTFMove(value)); }))); } @@ -459,7 +459,7 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_set2Body(JSC::J auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); EnsureStillAliveScope argument2 = callFrame->argument(2); @@ -471,10 +471,10 @@ static inline JSC::EncodedJSValue jsDOMFormDataPrototypeFunction_set2Body(JSC::J if (!blobValue) { throwTypeError(lexicalGlobalObject, throwScope, "Expected argument to be a Blob."_s); } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto filename = argument2.value().isUndefined() ? Blob__getFileNameString(blobValue->impl()).toWTFString(BunString::ZeroCopy) : convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.set(WTFMove(name), WTFMove(blobValue), WTFMove(filename)); }))); } diff --git a/src/bun.js/bindings/webcore/JSDOMURL.cpp b/src/bun.js/bindings/webcore/JSDOMURL.cpp index 5f0ca50b09..f82fcfd972 100755 --- a/src/bun.js/bindings/webcore/JSDOMURL.cpp +++ b/src/bun.js/bindings/webcore/JSDOMURL.cpp @@ -151,10 +151,10 @@ template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDOMURLDOMConstructor::const return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto url = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto base = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = base.isEmpty() ? DOMURL::create(WTFMove(url)) : DOMURL::create(WTFMove(url), WTFMove(base)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -630,10 +630,10 @@ static inline JSC::EncodedJSValue jsDOMURLConstructorFunction_parseBody(JSC::JSG return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto url = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto base = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *jsCast(lexicalGlobalObject), throwScope, DOMURL::parse(WTFMove(url), WTFMove(base))))); } @@ -652,10 +652,10 @@ static inline JSC::EncodedJSValue jsDOMURLConstructorFunction_canParseBody(JSC:: return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto url = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto base = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, DOMURL::canParse(WTFMove(url), WTFMove(base))))); } @@ -690,7 +690,7 @@ static inline JSC::EncodedJSValue jsDOMURLConstructorFunction_createObjectURL1Bo return JSValue::encode(jsUndefined()); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto blob = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "blob", "URL", "createObjectURL", "Blob"); }); - // RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + // RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, DOMURL::createObjectURL(*context, *blob)))); } @@ -707,7 +707,7 @@ static inline JSC::EncodedJSValue jsDOMURLConstructorFunction_revokeObjectURLBod return JSValue::encode(jsUndefined()); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto url = convert(*lexicalGlobalObject, argument0.value()); - // RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + // RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return DOMURL::revokeObjectURL(*context, WTFMove(url)); }))); } diff --git a/src/bun.js/bindings/webcore/JSErrorEvent.cpp b/src/bun.js/bindings/webcore/JSErrorEvent.cpp index 60515f2074..109fb8cc59 100644 --- a/src/bun.js/bindings/webcore/JSErrorEvent.cpp +++ b/src/bun.js/bindings/webcore/JSErrorEvent.cpp @@ -214,10 +214,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSErrorEventDOMConstruct return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto eventInitDict = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = ErrorEvent::create(type, WTFMove(eventInitDict)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/JSEvent.cpp b/src/bun.js/bindings/webcore/JSEvent.cpp index 988f87f73e..0fe7c06d5d 100644 --- a/src/bun.js/bindings/webcore/JSEvent.cpp +++ b/src/bun.js/bindings/webcore/JSEvent.cpp @@ -156,10 +156,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSEventDOMConstructor::c return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto eventInitDict = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = Event::create(WTFMove(type), WTFMove(eventInitDict)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -565,13 +565,13 @@ static inline JSC::EncodedJSValue jsEventPrototypeFunction_initEventBody(JSC::JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto bubbles = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto cancelable = convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.initEvent(WTFMove(type), WTFMove(bubbles), WTFMove(cancelable)); }))); } diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 964c7146d0..a112593d68 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -232,7 +232,7 @@ inline JSC::EncodedJSValue JSEventEmitter::addListener(JSC::JSGlobalObject* lexi return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto eventType = argument0.value().toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); // see EventEmitterPrototype.addListener in events.ts @@ -243,13 +243,13 @@ inline JSC::EncodedJSValue JSEventEmitter::addListener(JSC::JSGlobalObject* lexi args.append(argument1.value()); JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.emitForBindings(WTFMove(newListenerEventType), WTFMove(args)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); // then, add the listener auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventEmitter"_s, "addListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addListenerForBindings(WTFMove(eventType), WTFMove(listener), once, prepend); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); impl.setThisObject(actualThis); @@ -345,7 +345,7 @@ inline JSC::EncodedJSValue JSEventEmitter::removeListener(JSC::JSGlobalObject* l return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto eventType = argument0.value().toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); if (callFrame->argumentCount() < 2) { impl.removeAllListeners(eventType); RELEASE_AND_RETURN(throwScope, JSValue::encode(actualThis)); @@ -353,9 +353,9 @@ inline JSC::EncodedJSValue JSEventEmitter::removeListener(JSC::JSGlobalObject* l EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventEmitter"_s, "removeListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.removeListenerForBindings(WTFMove(eventType), WTFMove(listener)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); impl.setThisObject(actualThis); RELEASE_AND_RETURN(throwScope, JSValue::encode(actualThis)); @@ -379,9 +379,9 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_removeAllListe EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto eventType = argument0.value().toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.removeAllListenersForBindings(WTFMove(eventType)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); impl.setThisObject(actualThis); RELEASE_AND_RETURN(throwScope, JSValue::encode(actualThis)); } @@ -400,7 +400,7 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_emitBody(JSC:: if (UNLIKELY(argumentCount < 1)) return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); auto eventType = callFrame->uncheckedArgument(0).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSC::MarkedArgumentBuffer args; for (size_t i = 1; i < argumentCount; ++i) { args.append(callFrame->uncheckedArgument(i)); @@ -439,7 +439,7 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_listenerCountB if (UNLIKELY(callFrame->argumentCount() < 1)) return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); auto eventType = callFrame->uncheckedArgument(0).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(JSC::jsNumber(impl.listenerCount(eventType)))); } @@ -456,7 +456,7 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_listenersBody( if (UNLIKELY(callFrame->argumentCount() < 1)) return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); auto eventType = callFrame->uncheckedArgument(0).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSC::MarkedArgumentBuffer args; for (auto* listener : impl.getListeners(eventType)) { args.append(listener); @@ -540,11 +540,11 @@ JSC_DEFINE_HOST_FUNCTION(Events_functionGetEventListeners, auto argument0 = jsEventEmitterCast(vm, lexicalGlobalObject, callFrame->uncheckedArgument(0)); if (UNLIKELY(!argument0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "Expected EventEmitter"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto& impl = argument0->wrapped(); auto eventType = callFrame->uncheckedArgument(1).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSC::MarkedArgumentBuffer args; for (auto* listener : impl.getListeners(eventType)) { args.append(listener); @@ -562,11 +562,11 @@ JSC_DEFINE_HOST_FUNCTION(Events_functionListenerCount, auto argument0 = jsEventEmitterCast(vm, lexicalGlobalObject, callFrame->uncheckedArgument(0)); if (UNLIKELY(!argument0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "Expected EventEmitter"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto& impl = argument0->wrapped(); auto eventType = callFrame->uncheckedArgument(1).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(JSC::jsNumber(impl.listenerCount(eventType)))); } @@ -581,15 +581,15 @@ JSC_DEFINE_HOST_FUNCTION(Events_functionOnce, auto argument0 = jsEventEmitterCastFast(vm, lexicalGlobalObject, callFrame->uncheckedArgument(0)); if (UNLIKELY(!argument0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "Expected EventEmitter"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto eventType = callFrame->uncheckedArgument(1).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto listener = convert>>(*lexicalGlobalObject, argument2.value(), *argument0, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "listener"_s, "EventEmitter"_s, "removeListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(argument0, argument2.value()); RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(argument0)); } @@ -605,16 +605,16 @@ JSC_DEFINE_HOST_FUNCTION(Events_functionOn, auto argument0 = jsEventEmitterCastFast(vm, lexicalGlobalObject, callFrame->uncheckedArgument(0)); if (UNLIKELY(!argument0)) { throwException(lexicalGlobalObject, throwScope, createError(lexicalGlobalObject, "Expected EventEmitter"_s)); - return JSValue::encode(JSC::jsUndefined()); + return {}; } auto& impl = argument0->wrapped(); auto eventType = callFrame->uncheckedArgument(1).toPropertyKey(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto listener = convert>>(*lexicalGlobalObject, argument2.value(), *argument0, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 2, "listener"_s, "EventEmitter"_s, "removeListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto result = JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addListenerForBindings(WTFMove(eventType), WTFMove(listener), false, false); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(argument0, argument2.value()); return result; } diff --git a/src/bun.js/bindings/webcore/JSEventTarget.cpp b/src/bun.js/bindings/webcore/JSEventTarget.cpp index 6a23f00f77..c2d75bc90a 100644 --- a/src/bun.js/bindings/webcore/JSEventTarget.cpp +++ b/src/bun.js/bindings/webcore/JSEventTarget.cpp @@ -216,15 +216,15 @@ static inline JSC::EncodedJSValue jsEventTargetPrototypeFunction_addEventListene return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventTarget"_s, "addEventListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto options = argument2.value().isUndefined() ? false : convert, IDLBoolean>>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto result = JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addEventListenerForBindings(WTFMove(type), WTFMove(listener), WTFMove(options)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); return result; } @@ -245,15 +245,15 @@ static inline JSC::EncodedJSValue jsEventTargetPrototypeFunction_removeEventList return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto listener = convert>>(*lexicalGlobalObject, argument1.value(), *castedThis, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "listener"_s, "EventTarget"_s, "removeEventListener"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto options = argument2.value().isUndefined() ? false : convert, IDLBoolean>>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto result = JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.removeEventListenerForBindings(WTFMove(type), WTFMove(listener), WTFMove(options)); })); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); vm.writeBarrier(&static_cast(*castedThis), argument1.value()); return result; } @@ -274,7 +274,7 @@ static inline JSC::EncodedJSValue jsEventTargetPrototypeFunction_dispatchEventBo return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto event = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "event"_s, "EventTarget"_s, "dispatchEvent"_s, "Event"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, impl.dispatchEventForBindings(*event)))); } diff --git a/src/bun.js/bindings/webcore/JSEventTargetNode.cpp b/src/bun.js/bindings/webcore/JSEventTargetNode.cpp index a2cf67c370..b278c74492 100644 --- a/src/bun.js/bindings/webcore/JSEventTargetNode.cpp +++ b/src/bun.js/bindings/webcore/JSEventTargetNode.cpp @@ -20,7 +20,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeEventsGetEventListeners, (JSGlobalObject if (callFrame->argumentCount() < 2) { throwTypeError(globalObject, throwScope, "getEventListeners needs 2 arguments"_s); - return JSValue::encode(jsUndefined()); + return {}; } JSValue thisValue = callFrame->argument(0); diff --git a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp index f0b1cc7f5a..814377532c 100644 --- a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp +++ b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp @@ -139,7 +139,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSFetchHeadersDOMConstru init = std::optional>, IDLRecord>>::ReturnType>(convert>, IDLRecord>>(*lexicalGlobalObject, argument0.value())); } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = FetchHeaders::create(WTFMove(init)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -200,11 +200,11 @@ JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_getAll, (JSGlobalObject if (UNLIKELY(!callFrame->argumentCount())) { throwTypeError(lexicalGlobalObject, scope, "Missing argument"_s); - return JSValue::encode(jsUndefined()); + return {}; } auto name = convert(*lexicalGlobalObject, callFrame->uncheckedArgument(0)); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); auto& impl = castedThis->wrapped(); if (name.length() != "set-cookie"_s.length() || name.convertToASCIILowercase() != "set-cookie"_s) { @@ -237,18 +237,18 @@ JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_getAll, (JSGlobalObject } else { array = constructEmptyArray(lexicalGlobalObject, nullptr, count); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (!array) { throwOutOfMemoryError(lexicalGlobalObject, scope); - return JSValue::encode(jsUndefined()); + return {}; } for (unsigned i = 0; i < count; ++i) { array->putDirectIndex(lexicalGlobalObject, i, strings.at(i)); - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); } } - RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); return JSValue::encode(array); } @@ -264,15 +264,15 @@ JSC::EncodedJSValue fetchHeadersGetSetCookie(JSC::JSGlobalObject* lexicalGlobalO } JSC::JSArray* array = constructEmptyArray(lexicalGlobalObject, nullptr, count); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (UNLIKELY(!array)) { throwOutOfMemoryError(lexicalGlobalObject, scope); - return encodedJSValue(); + return {}; } for (unsigned i = 0; i < count; ++i) { array->putDirectIndex(lexicalGlobalObject, i, jsString(vm, values[i])); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); } return JSValue::encode(array); @@ -383,10 +383,10 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_appendBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.append(WTFMove(name), WTFMove(value)); }))); } @@ -419,7 +419,7 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_deleteBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.remove(WTFMove(name)); }))); } @@ -439,7 +439,7 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_getBody(JSC::J return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, throwScope, impl.get(WTFMove(name))))); } @@ -459,7 +459,7 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_hasBody(JSC::J return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, impl.has(WTFMove(name))))); } @@ -479,10 +479,10 @@ static inline JSC::EncodedJSValue jsFetchHeadersPrototypeFunction_setBody(JSC::J return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.set(WTFMove(name), WTFMove(value)); }))); } diff --git a/src/bun.js/bindings/webcore/JSMessageEvent.cpp b/src/bun.js/bindings/webcore/JSMessageEvent.cpp index caf32b36ac..469afee0f2 100644 --- a/src/bun.js/bindings/webcore/JSMessageEvent.cpp +++ b/src/bun.js/bindings/webcore/JSMessageEvent.cpp @@ -227,10 +227,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMessageEventDOMConstru return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto eventInitDict = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = MessageEvent::create(WTFMove(type), WTFMove(eventInitDict)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -395,29 +395,29 @@ static inline JSC::EncodedJSValue jsMessageEventPrototypeFunction_initMessageEve return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto bubbles = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto cancelable = convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->argument(3); auto data = argument3.value().isUndefined() ? jsNull() : convert(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument4 = callFrame->argument(4); auto originArg = argument4.value().isUndefined() ? emptyString() : convert(*lexicalGlobalObject, argument4.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument5 = callFrame->argument(5); auto lastEventId = argument5.value().isUndefined() ? emptyString() : convert(*lexicalGlobalObject, argument5.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument6 = callFrame->argument(6); auto source = WebCore::MessageEventSource(); // auto source = argument6.value().isUndefined() ? std::nullopt : convert, IDLInterface, IDLInterface>>>(*lexicalGlobalObject, argument6.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument7 = callFrame->argument(7); auto messagePorts = argument7.value().isUndefined() ? Converter>>::ReturnType {} : convert>>(*lexicalGlobalObject, argument7.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.initMessageEvent(WTFMove(type), WTFMove(bubbles), WTFMove(cancelable), WTFMove(data), WTFMove(originArg), WTFMove(lastEventId), WTFMove(source), WTFMove(messagePorts)); }))); } diff --git a/src/bun.js/bindings/webcore/JSMessagePort.cpp b/src/bun.js/bindings/webcore/JSMessagePort.cpp index 576baae759..c1c662899c 100644 --- a/src/bun.js/bindings/webcore/JSMessagePort.cpp +++ b/src/bun.js/bindings/webcore/JSMessagePort.cpp @@ -250,10 +250,10 @@ static inline JSC::EncodedJSValue jsMessagePortPrototypeFunction_postMessage1Bod auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto transfer = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast(lexicalGlobalObject), WTFMove(message), WTFMove(transfer)); }))); } @@ -266,10 +266,10 @@ static inline JSC::EncodedJSValue jsMessagePortPrototypeFunction_postMessage2Bod auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto options = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast(lexicalGlobalObject), WTFMove(message), WTFMove(options)); }))); } diff --git a/src/bun.js/bindings/webcore/JSPerformance.cpp b/src/bun.js/bindings/webcore/JSPerformance.cpp index fb301cd730..f9e252644d 100644 --- a/src/bun.js/bindings/webcore/JSPerformance.cpp +++ b/src/bun.js/bindings/webcore/JSPerformance.cpp @@ -433,7 +433,7 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_getEntriesByTyp return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.getEntriesByType(WTFMove(type))))); } @@ -453,10 +453,10 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_getEntriesByNam return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto type = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.getEntriesByName(WTFMove(name), WTFMove(type))))); } @@ -491,7 +491,7 @@ JSC_DEFINE_HOST_FUNCTION(jsPerformancePrototypeFunction_getEntriesByName, (JSGlo // return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto maxSize = convert(*lexicalGlobalObject, argument0.value()); -// RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); +// RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.setResourceTimingBufferSize(WTFMove(maxSize)); }))); // } @@ -511,10 +511,10 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_markBody(JSC::J return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto markName = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto markOptions = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.mark(*jsCast(lexicalGlobalObject), WTFMove(markName), WTFMove(markOptions))))); } @@ -532,7 +532,7 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_clearMarksBody( auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->argument(0); auto markName = argument0.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.clearMarks(WTFMove(markName)); }))); } @@ -552,13 +552,13 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_measureBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto measureName = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto startOrMeasureOptions = argument1.value().isUndefined() ? std::optional>>::ReturnType>() : std::optional>>::ReturnType>(convert>>(*lexicalGlobalObject, argument1.value())); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->argument(2); auto endMark = argument2.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.measure(*jsCast(lexicalGlobalObject), WTFMove(measureName), WTFMove(startOrMeasureOptions), WTFMove(endMark))))); } @@ -576,7 +576,7 @@ static inline JSC::EncodedJSValue jsPerformancePrototypeFunction_clearMeasuresBo auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->argument(0); auto measureName = argument0.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.clearMeasures(WTFMove(measureName)); }))); } diff --git a/src/bun.js/bindings/webcore/JSPerformanceMark.cpp b/src/bun.js/bindings/webcore/JSPerformanceMark.cpp index b0a193269c..4e26dafd0d 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceMark.cpp +++ b/src/bun.js/bindings/webcore/JSPerformanceMark.cpp @@ -101,10 +101,10 @@ template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSPerformanceMarkDOMConstruct return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "PerformanceMark"_s); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto markName = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto markOptions = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = PerformanceMark::create(*castedThis->globalObject(), *context, WTFMove(markName), WTFMove(markOptions)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/JSPerformanceObserver.cpp b/src/bun.js/bindings/webcore/JSPerformanceObserver.cpp index a9ce7b6c8e..7c1b2703be 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceObserver.cpp +++ b/src/bun.js/bindings/webcore/JSPerformanceObserver.cpp @@ -175,7 +175,7 @@ template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSPerformanceObserverDOMConst [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback"_s, "PerformanceObserver"_s, nullptr); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = PerformanceObserver::create(*context, callback.releaseNonNull()); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -289,7 +289,7 @@ static inline JSC::EncodedJSValue jsPerformanceObserverPrototypeFunction_observe auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->argument(0); auto options = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.observe(WTFMove(options)); }))); } diff --git a/src/bun.js/bindings/webcore/JSPerformanceObserverEntryList.cpp b/src/bun.js/bindings/webcore/JSPerformanceObserverEntryList.cpp index 80a4a0e24c..435ca85cf0 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceObserverEntryList.cpp +++ b/src/bun.js/bindings/webcore/JSPerformanceObserverEntryList.cpp @@ -198,7 +198,7 @@ static inline JSC::EncodedJSValue jsPerformanceObserverEntryListPrototypeFunctio return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto type = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.getEntriesByType(WTFMove(type))))); } @@ -218,10 +218,10 @@ static inline JSC::EncodedJSValue jsPerformanceObserverEntryListPrototypeFunctio return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto type = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.getEntriesByName(WTFMove(name), WTFMove(type))))); } diff --git a/src/bun.js/bindings/webcore/JSReadableStreamSink.cpp b/src/bun.js/bindings/webcore/JSReadableStreamSink.cpp index 26e726660c..55e24a462c 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamSink.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamSink.cpp @@ -147,7 +147,7 @@ static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunction_enqueueB return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto chunk = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.enqueue(WTFMove(chunk)); }))); } @@ -182,7 +182,7 @@ static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunction_errorBod return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.error(WTFMove(message)); }))); } diff --git a/src/bun.js/bindings/webcore/JSReadableStreamSource.cpp b/src/bun.js/bindings/webcore/JSReadableStreamSource.cpp index ff6aa2c30f..0dfba15343 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamSource.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamSource.cpp @@ -196,7 +196,7 @@ static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunction_cancel return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto reason = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.cancel(WTFMove(reason)); }))); } diff --git a/src/bun.js/bindings/webcore/JSTextEncoder.cpp b/src/bun.js/bindings/webcore/JSTextEncoder.cpp index e03033b3d4..d886ce16e3 100644 --- a/src/bun.js/bindings/webcore/JSTextEncoder.cpp +++ b/src/bun.js/bindings/webcore/JSTextEncoder.cpp @@ -399,7 +399,7 @@ static inline JSC::EncodedJSValue jsTextEncoderPrototypeFunction_encodeBody(JSC: if (UNLIKELY(JSC::JSValue::decode(res).isObject() && JSC::JSValue::decode(res).getObject()->isErrorInstance())) { throwScope.throwException(lexicalGlobalObject, JSC::JSValue::decode(res)); - return encodedJSValue(); + return {}; } RELEASE_AND_RETURN(throwScope, res); @@ -418,12 +418,12 @@ static inline JSC::EncodedJSValue jsTextEncoderPrototypeFunction_encodeIntoBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto source = argument0.value().toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto* destination = JSC::jsDynamicCast(argument1.value()); if (!destination) { throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s); - return encodedJSValue(); + return {}; } size_t res = 0; diff --git a/src/bun.js/bindings/webcore/JSURLSearchParams.cpp b/src/bun.js/bindings/webcore/JSURLSearchParams.cpp index 5189a2cfab..66e1d13ec7 100644 --- a/src/bun.js/bindings/webcore/JSURLSearchParams.cpp +++ b/src/bun.js/bindings/webcore/JSURLSearchParams.cpp @@ -124,7 +124,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSURLSearchParamsDOMCons ASSERT(castedThis); EnsureStillAliveScope argument0 = callFrame->argument(0); auto init = argument0.value().isUndefined() ? emptyString() : convert>, IDLRecord, IDLUSVString>>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = URLSearchParams::create(WTFMove(init)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -255,10 +255,10 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_appendBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.append(WTFMove(name), WTFMove(value)); }))); } @@ -278,13 +278,13 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_deleteBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); String value; EnsureStillAliveScope argument1 = callFrame->argument(1); if (!argument1.value().isUndefined()) { value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.remove(WTFMove(name), WTFMove(value)); }))); @@ -306,7 +306,7 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_getBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, throwScope, impl.get(WTFMove(name))))); } @@ -326,7 +326,7 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_getAllBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, impl.getAll(WTFMove(name))))); } @@ -346,13 +346,13 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_hasBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); String value; EnsureStillAliveScope argument1 = callFrame->argument(1); if (!argument1.value().isUndefined()) { value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, impl.has(WTFMove(name), WTFMove(value))))); @@ -374,10 +374,10 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_setBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto name = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto value = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.set(WTFMove(name), WTFMove(value)); }))); } diff --git a/src/bun.js/bindings/webcore/JSWebSocket.cpp b/src/bun.js/bindings/webcore/JSWebSocket.cpp index 8d9150036b..f5b0aeaf32 100644 --- a/src/bun.js/bindings/webcore/JSWebSocket.cpp +++ b/src/bun.js/bindings/webcore/JSWebSocket.cpp @@ -154,10 +154,10 @@ static inline JSC::EncodedJSValue constructJSWebSocket1(JSGlobalObject* lexicalG return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "WebSocket"_s); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto url = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto protocols = argument1.value().isUndefined() ? Converter>::ReturnType {} : convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = WebSocket::create(*context, WTFMove(url), WTFMove(protocols)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -181,10 +181,10 @@ static inline JSC::EncodedJSValue constructJSWebSocket2(JSGlobalObject* lexicalG return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "WebSocket"_s); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto url = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto protocol = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = WebSocket::create(*context, WTFMove(url), WTFMove(protocol)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -206,7 +206,7 @@ static inline JSC::EncodedJSValue constructJSWebSocket3(JSGlobalObject* lexicalG if (UNLIKELY(!context)) return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "WebSocket"_s); auto url = convert(*lexicalGlobalObject, urlValue); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); Vector protocols; int rejectUnauthorized = -1; @@ -215,19 +215,19 @@ static inline JSC::EncodedJSValue constructJSWebSocket3(JSGlobalObject* lexicalG if (JSValue headersValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "headers"_s)))) { if (!headersValue.isUndefinedOrNull()) { headersInit = convert>, IDLRecord>>(*lexicalGlobalObject, headersValue); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } if (JSValue protocolsValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "protocols"_s)))) { if (!protocolsValue.isUndefinedOrNull()) { protocols = convert>(*lexicalGlobalObject, protocolsValue); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } else if (JSValue protocolValue = options->getIfPropertyExists(globalObject, PropertyName(Identifier::fromString(vm, "protocol"_s)))) { if (!protocolValue.isUndefinedOrNull()) { protocols = Vector { convert(*lexicalGlobalObject, protocolValue) }; - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } @@ -245,7 +245,7 @@ static inline JSC::EncodedJSValue constructJSWebSocket3(JSGlobalObject* lexicalG } } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = (rejectUnauthorized == -1) ? WebSocket::create(*context, WTFMove(url), protocols, WTFMove(headersInit)) : WebSocket::create(*context, WTFMove(url), protocols, WTFMove(headersInit), rejectUnauthorized ? true : false); if constexpr (IsExceptionOr) @@ -603,7 +603,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_send1Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "send"_s, "ArrayBuffer"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.send(*data); }))); } @@ -616,7 +616,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_send2Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "send"_s, "ArrayBufferView"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.send(data.releaseNonNull()); }))); } @@ -629,7 +629,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_send2Body(JSC::JS // auto& impl = castedThis->wrapped(); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto data = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "send"_s, "Blob"_s); }); -// RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); +// RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.send(*data); }))); // } @@ -642,7 +642,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_send4Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.send(WTFMove(data)); }))); } @@ -680,10 +680,10 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_closeBody(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->argument(0); auto code = argument0.value().isUndefined() ? std::optional>::ReturnType>() : std::optional>::ReturnType>(convert>(*lexicalGlobalObject, argument0.value())); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto reason = argument1.value().isUndefined() ? String() : convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.close(WTFMove(code), WTFMove(reason)); }))); } @@ -711,7 +711,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_ping2Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "ping"_s, "ArrayBuffer"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.ping(*data); }))); } @@ -724,7 +724,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_ping3Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "ping"_s, "ArrayBufferView"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.ping(data.releaseNonNull()); }))); } @@ -737,7 +737,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_ping3Body(JSC::JS // auto& impl = castedThis->wrapped(); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto data = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "ping"_s, "Blob"_s); }); -// RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); +// RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.ping(*data); }))); // } @@ -750,7 +750,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_ping5Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.ping(WTFMove(data)); }))); } @@ -800,7 +800,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_pong2Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "pong"_s, "ArrayBuffer"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.pong(*data); }))); } @@ -813,7 +813,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_pong3Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "pong"_s, "ArrayBufferView"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.pong(data.releaseNonNull()); }))); } @@ -826,7 +826,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_pong3Body(JSC::JS // auto& impl = castedThis->wrapped(); // EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); // auto data = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "data"_s, "WebSocket"_s, "pong"_s, "Blob"_s); }); -// RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); +// RETURN_IF_EXCEPTION(throwScope, {}); // RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.pong(*data); }))); // } @@ -839,7 +839,7 @@ static inline JSC::EncodedJSValue jsWebSocketPrototypeFunction_pong5Body(JSC::JS auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto data = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.pong(WTFMove(data)); }))); } diff --git a/src/bun.js/bindings/webcore/JSWorker.cpp b/src/bun.js/bindings/webcore/JSWorker.cpp index fe7ed06872..66ca015cd4 100644 --- a/src/bun.js/bindings/webcore/JSWorker.cpp +++ b/src/bun.js/bindings/webcore/JSWorker.cpp @@ -124,7 +124,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: return throwConstructorScriptExecutionContextUnavailableError(*lexicalGlobalObject, throwScope, "Worker"_s); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto scriptUrl = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto options = WorkerOptions {}; @@ -134,18 +134,18 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: if (auto nameValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, vm.propertyNames->name)) { if (nameValue.isString()) { options.name = nameValue.toWTFString(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } if (auto miniModeValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "smol"_s))) { options.bun.mini = miniModeValue.toBoolean(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } if (auto ref = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "ref"_s))) { options.bun.unref = !ref.toBoolean(lexicalGlobalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } auto workerData = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "workerData"_s)); @@ -195,7 +195,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: auto* globalObject = jsCast(lexicalGlobalObject); auto envValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "env"_s)); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); JSObject* envObject = nullptr; if (envValue && envValue.isCell()) { @@ -228,7 +228,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: } JSValue argvValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "argv"_s)); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); if (argvValue && argvValue.isCell() && argvValue.asCell()->type() == JSC::JSType::ArrayType) { Vector argv; forEachInIterable(lexicalGlobalObject, argvValue, [&argv](JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue nextValue) { @@ -242,7 +242,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: } JSValue execArgvValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "execArgv"_s)); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); if (execArgvValue && execArgvValue.isCell() && execArgvValue.asCell()->type() == JSC::JSType::ArrayType) { Vector execArgv; forEachInIterable(lexicalGlobalObject, execArgvValue, [&execArgv](JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSValue nextValue) { @@ -256,7 +256,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: } } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = Worker::create(*context, WTFMove(scriptUrl), WTFMove(options)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); @@ -268,7 +268,7 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWorkerDOMConstructor:: auto& impl = jsCast(jsValue)->wrapped(); if (!impl.updatePtr()) { throwVMError(lexicalGlobalObject, throwScope, "Failed to start Worker thread"_s); - return encodedJSValue(); + return {}; } setSubclassStructureIfNeeded(lexicalGlobalObject, callFrame, asObject(jsValue)); @@ -471,10 +471,10 @@ static inline JSC::EncodedJSValue jsWorkerPrototypeFunction_postMessage1Body(JSC auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto transfer = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast(lexicalGlobalObject), WTFMove(message), WTFMove(transfer)); }))); } @@ -487,7 +487,7 @@ static inline JSC::EncodedJSValue jsWorkerPrototypeFunction_postMessage2Body(JSC auto& impl = castedThis->wrapped(); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); JSValue optionsValue = argument1.value(); StructuredSerializeOptions options; @@ -495,12 +495,12 @@ static inline JSC::EncodedJSValue jsWorkerPrototypeFunction_postMessage2Body(JSC JSObject* optionsObject = asObject(optionsValue); if (auto transferListValue = optionsObject->getIfPropertyExists(lexicalGlobalObject, Identifier::fromString(vm, "transfer"_s))) { auto transferList = convert>(*lexicalGlobalObject, transferListValue); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); options.transfer = WTFMove(transferList); } } - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.postMessage(*jsCast(lexicalGlobalObject), WTFMove(message), WTFMove(options)); }))); } diff --git a/src/bun.js/bindings/webcore/JSWritableStream.cpp b/src/bun.js/bindings/webcore/JSWritableStream.cpp index 96fa7326e9..14c202ab89 100644 --- a/src/bun.js/bindings/webcore/JSWritableStream.cpp +++ b/src/bun.js/bindings/webcore/JSWritableStream.cpp @@ -103,10 +103,10 @@ template<> JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWritableStreamDOMConst ASSERT(castedThis); EnsureStillAliveScope argument0 = callFrame->argument(0); auto underlyingSink = argument0.value().isUndefined() ? std::optional::ReturnType>() : std::optional::ReturnType>(convert(*lexicalGlobalObject, argument0.value())); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->argument(1); auto strategy = argument1.value().isUndefined() ? std::optional::ReturnType>() : std::optional::ReturnType>(convert(*lexicalGlobalObject, argument1.value())); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); auto object = WritableStream::create(*castedThis->globalObject(), WTFMove(underlyingSink), WTFMove(strategy)); if constexpr (IsExceptionOr) RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/JSWritableStreamSink.cpp b/src/bun.js/bindings/webcore/JSWritableStreamSink.cpp index 617fa9b3f5..49c779a9ce 100644 --- a/src/bun.js/bindings/webcore/JSWritableStreamSink.cpp +++ b/src/bun.js/bindings/webcore/JSWritableStreamSink.cpp @@ -152,7 +152,7 @@ static inline JSC::EncodedJSValue jsWritableStreamSinkPrototypeFunction_writeBod return JSValue::encode(jsUndefined()); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto value = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.write(*context, WTFMove(value), WTFMove(promise)); }))); } @@ -187,7 +187,7 @@ static inline JSC::EncodedJSValue jsWritableStreamSinkPrototypeFunction_errorBod return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto message = convert(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.error(WTFMove(message)); }))); } diff --git a/src/bun.js/bindings/webcore/Worker.cpp b/src/bun.js/bindings/webcore/Worker.cpp index e0d2c09de0..07601d1d67 100644 --- a/src/bun.js/bindings/webcore/Worker.cpp +++ b/src/bun.js/bindings/webcore/Worker.cpp @@ -434,14 +434,14 @@ JSC_DEFINE_HOST_FUNCTION(jsReceiveMessageOnPort, (JSGlobalObject * lexicalGlobal if (callFrame->argumentCount() < 1) { throwTypeError(lexicalGlobalObject, scope, "receiveMessageOnPort needs 1 argument"_s); - return JSC::JSValue::encode(JSC::JSValue {}); + return {}; } auto port = callFrame->argument(0); if (!port.isObject()) { throwTypeError(lexicalGlobalObject, scope, "the \"port\" argument must be a MessagePort instance"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } if (auto* messagePort = jsDynamicCast(port)) { @@ -452,7 +452,7 @@ JSC_DEFINE_HOST_FUNCTION(jsReceiveMessageOnPort, (JSGlobalObject * lexicalGlobal } throwTypeError(lexicalGlobalObject, scope, "the \"port\" argument must be a MessagePort instance"_s); - return JSC::JSValue::encode(jsUndefined()); + return {}; } JSValue createNodeWorkerThreadsBinding(Zig::GlobalObject* globalObject) diff --git a/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp b/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp index d497ea8c9b..edd11f56ab 100644 --- a/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp +++ b/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp @@ -268,13 +268,13 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_encryptBody(JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "encrypt"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto data = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.encrypt(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *key, WTFMove(data), WTFMove(promise)); }))); } @@ -294,13 +294,13 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_decryptBody(JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "decrypt"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto data = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.decrypt(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *key, WTFMove(data), WTFMove(promise)); }))); } @@ -320,13 +320,13 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_signBody(JSC:: return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "sign"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto data = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.sign(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *key, WTFMove(data), WTFMove(promise)); }))); } @@ -346,16 +346,16 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_verifyBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "verify"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto signature = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->uncheckedArgument(3); auto data = convert>(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.verify(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *key, WTFMove(signature), WTFMove(data), WTFMove(promise)); }))); } @@ -375,10 +375,10 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_digestBody(JSC return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto data = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.digest(*jsCast(lexicalGlobalObject), WTFMove(algorithm), WTFMove(data), WTFMove(promise)); }))); } @@ -398,13 +398,13 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_generateKeyBod return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto extractable = convert(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto keyUsages = convert>>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.generateKey(*jsCast(lexicalGlobalObject), WTFMove(algorithm), WTFMove(extractable), WTFMove(keyUsages), WTFMove(promise)); }))); } @@ -424,19 +424,19 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_deriveKeyBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto baseKey = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "baseKey"_s, "SubtleCrypto"_s, "deriveKey"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto derivedKeyType = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->uncheckedArgument(3); auto extractable = convert(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument4 = callFrame->uncheckedArgument(4); auto keyUsages = convert>>(*lexicalGlobalObject, argument4.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.deriveKey(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *baseKey, WTFMove(derivedKeyType), WTFMove(extractable), WTFMove(keyUsages), WTFMove(promise)); }))); } @@ -456,13 +456,13 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_deriveBitsBody return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto algorithm = convert>(*lexicalGlobalObject, argument0.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto baseKey = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "baseKey"_s, "SubtleCrypto"_s, "deriveBits"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto length = convert(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.deriveBits(*jsCast(lexicalGlobalObject), WTFMove(algorithm), *baseKey, WTFMove(length), WTFMove(promise)); }))); } @@ -482,19 +482,19 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_importKeyBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto format = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(lexicalGlobalObject, scope, 0, "format"_s, "SubtleCrypto"_s, "importKey"_s, expectedEnumerationValues()); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto keyData = convert>>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto algorithm = convert>(*lexicalGlobalObject, argument2.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->uncheckedArgument(3); auto extractable = convert(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument4 = callFrame->uncheckedArgument(4); auto keyUsages = convert>>(*lexicalGlobalObject, argument4.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.importKey(*jsCast(lexicalGlobalObject), WTFMove(format), WTFMove(keyData), WTFMove(algorithm), WTFMove(extractable), WTFMove(keyUsages), WTFMove(promise)); }))); } @@ -514,10 +514,10 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_exportKeyBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto format = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(lexicalGlobalObject, scope, 0, "format"_s, "SubtleCrypto"_s, "exportKey"_s, expectedEnumerationValues()); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "exportKey"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.exportKey(WTFMove(format), *key, WTFMove(promise)); }))); @@ -539,16 +539,16 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_wrapKeyBody(JS return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto format = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(lexicalGlobalObject, scope, 0, "format"_s, "SubtleCrypto"_s, "wrapKey"_s, expectedEnumerationValues()); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto key = convert>(*lexicalGlobalObject, argument1.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 1, "key"_s, "SubtleCrypto"_s, "wrapKey"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto wrappingKey = convert>(*lexicalGlobalObject, argument2.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 2, "wrappingKey"_s, "SubtleCrypto"_s, "wrapKey"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->uncheckedArgument(3); auto wrapAlgorithm = convert>(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.wrapKey(*jsCast(lexicalGlobalObject), WTFMove(format), *key, *wrappingKey, WTFMove(wrapAlgorithm), WTFMove(promise)); }))); } @@ -568,25 +568,25 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_unwrapKeyBody( return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); auto format = convert>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(lexicalGlobalObject, scope, 0, "format"_s, "SubtleCrypto"_s, "unwrapKey"_s, expectedEnumerationValues()); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto wrappedKey = convert>(*lexicalGlobalObject, argument1.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument2 = callFrame->uncheckedArgument(2); auto unwrappingKey = convert>(*lexicalGlobalObject, argument2.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 2, "unwrappingKey"_s, "SubtleCrypto"_s, "unwrapKey"_s, "CryptoKey"_s); }); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument3 = callFrame->uncheckedArgument(3); auto unwrapAlgorithm = convert>(*lexicalGlobalObject, argument3.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument4 = callFrame->uncheckedArgument(4); auto unwrappedKeyAlgorithm = convert>(*lexicalGlobalObject, argument4.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument5 = callFrame->uncheckedArgument(5); auto extractable = convert(*lexicalGlobalObject, argument5.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); EnsureStillAliveScope argument6 = callFrame->uncheckedArgument(6); auto keyUsages = convert>>(*lexicalGlobalObject, argument6.value()); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.unwrapKey(*jsCast(lexicalGlobalObject), WTFMove(format), WTFMove(wrappedKey), *unwrappingKey, WTFMove(unwrapAlgorithm), WTFMove(unwrappedKeyAlgorithm), WTFMove(extractable), WTFMove(keyUsages), WTFMove(promise)); }))); } diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index 56a04cf0bc..592cb33826 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -413,7 +413,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartSamplingProfiler, throwVMError( globalObject, scope, createTypeError(globalObject, "directory couldn't be created"_s)); - return JSC::JSValue::encode(jsUndefined()); + return {}; } Options::samplingProfilerPath() = pathCString.data(); @@ -465,7 +465,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, auto scope = DECLARE_THROW_SCOPE(vm); unsigned seed = callFrame->argument(0).toUInt32(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); globalObject->weakRandom().setSeed(seed); return JSValue::encode(jsUndefined()); } @@ -582,22 +582,22 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeZone, (JSGlobalObject * globalObject, if (callFrame->argumentCount() < 1) { throwTypeError(globalObject, scope, "setTimeZone requires a timezone string"_s); - return encodedJSValue(); + return {}; } if (!callFrame->argument(0).isString()) { throwTypeError(globalObject, scope, "setTimeZone requires a timezone string"_s); - return encodedJSValue(); + return {}; } String timeZoneName = callFrame->argument(0).toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); if (!WTF::setTimeZoneOverride(timeZoneName)) { throwTypeError(globalObject, scope, makeString("Invalid timezone: \""_s, timeZoneName, "\""_s)); - return encodedJSValue(); + return {}; } vm.dateCache.resetIfNecessarySlow(); WTF::Vector buffer; @@ -708,7 +708,7 @@ JSC_DEFINE_HOST_FUNCTION(functionRunProfiler, (JSGlobalObject * globalObject, auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); reportFailure(globalObject->vm()); throwException(globalObject, scope, error.value()); - return JSValue::encode(jsUndefined()); + return JSValue::encode({}); }); promise->performPromiseThen(globalObject, resolve, reject, afterOngoingPromiseCapability); @@ -759,12 +759,12 @@ JSC_DEFINE_HOST_FUNCTION(functionSerialize, if (!binaryTypeValue.isString()) { throwTypeError(globalObject, throwScope, "binaryType must be a string"_s); - return JSValue::encode(jsUndefined()); + return {}; } asNodeBuffer = binaryTypeValue.toWTFString(globalObject) == "nodebuffer"_s; - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); } } @@ -822,10 +822,10 @@ JSC_DEFINE_HOST_FUNCTION(functionDeserialize, (JSGlobalObject * globalObject, } else { throwTypeError(globalObject, throwScope, "First argument must be an ArrayBuffer"_s); - return JSValue::encode(jsUndefined()); + return {}; } - RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + RETURN_IF_EXCEPTION(throwScope, {}); RELEASE_AND_RETURN(throwScope, JSValue::encode(result)); } @@ -840,14 +840,14 @@ JSC_DEFINE_HOST_FUNCTION(functionCodeCoverageForFile, auto throwScope = DECLARE_THROW_SCOPE(vm); String fileName = callFrame->argument(0).toWTFString(globalObject); - RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); + RETURN_IF_EXCEPTION(throwScope, {}); bool ignoreSourceMap = callFrame->argument(1).toBoolean(globalObject); auto sourceID = Zig::sourceIDForSourceURL(fileName); if (!sourceID) { throwException(globalObject, throwScope, createError(globalObject, "No source for file"_s)); - return JSValue::encode(jsUndefined()); + return {}; } auto basicBlocks = diff --git a/src/bun.js/modules/NodeBufferModule.h b/src/bun.js/modules/NodeBufferModule.h index b35dec3470..06546bd046 100644 --- a/src/bun.js/modules/NodeBufferModule.h +++ b/src/bun.js/modules/NodeBufferModule.h @@ -27,7 +27,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8, if (UNLIKELY(bufferView->isDetached())) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s); - return JSValue::encode({}); + return {}; } byteLength = bufferView->byteLength(); @@ -48,7 +48,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8, if (UNLIKELY(impl->isDetached())) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s); - return JSValue::encode({}); + return {}; } byteLength = impl->byteLength(); @@ -62,7 +62,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8, Bun::throwError(lexicalGlobalObject, throwScope, Bun::ErrorCode::ERR_INVALID_ARG_TYPE, "First argument must be an ArrayBufferView"_s); - return JSValue::encode({}); + return {}; } RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean( @@ -84,7 +84,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii, if (UNLIKELY(bufferView->isDetached())) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s); - return JSValue::encode({}); + return {}; } byteLength = bufferView->byteLength(); @@ -100,7 +100,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii, if (UNLIKELY(impl->isDetached())) { throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s); - return JSValue::encode({}); + return {}; } if (!impl) { @@ -118,7 +118,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii, Bun::throwError(lexicalGlobalObject, throwScope, Bun::ErrorCode::ERR_INVALID_ARG_TYPE, "First argument must be an ArrayBufferView"_s); - return JSValue::encode({}); + return {}; } RELEASE_AND_RETURN( @@ -136,7 +136,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented, throwException(globalObject, scope, createError(globalObject, "Not implemented"_s)); - return JSValue::encode(jsUndefined()); + return {}; } DEFINE_NATIVE_MODULE(NodeBuffer) { diff --git a/src/bun.js/modules/NodeModuleModule.h b/src/bun.js/modules/NodeModuleModule.h index d1994e4d0e..e825170848 100644 --- a/src/bun.js/modules/NodeModuleModule.h +++ b/src/bun.js/modules/NodeModuleModule.h @@ -120,7 +120,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleModuleConstructor, (JSC::JSGlobalOb auto scope = DECLARE_THROW_SCOPE(vm); if (idValue.isString()) { idString = idValue.toString(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); auto index = idString->tryGetValue()->reverseFind('/', idString->length()); @@ -165,7 +165,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionWrap, (JSC::JSGlobalObject * globalObject, auto &vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSString *code = callFrame->argument(0).toStringOrNull(globalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); if (!code) { return JSC::JSValue::encode(JSC::jsUndefined()); } @@ -205,7 +205,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleCreateRequire, val = url.fileSystemPath(); } - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); + RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN( scope, JSValue::encode(Bun::JSCommonJSModule::createBoundRequireFunction( vm, globalObject, val))); @@ -216,7 +216,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionFindSourceMap, (JSGlobalObject * globalObject auto &vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); throwException(globalObject, scope, createError(globalObject, "module.SourceMap is not yet implemented in Bun"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(jsFunctionSyncBuiltinExports, @@ -230,7 +230,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionSourceMap, (JSGlobalObject * globalObject, Ca auto scope = DECLARE_THROW_SCOPE(vm); throwException(globalObject, scope, createError(globalObject, "Not implemented"_s)); - return JSValue::encode(jsUndefined()); + return {}; } JSC_DEFINE_HOST_FUNCTION(jsFunctionResolveFileName, (JSC::JSGlobalObject * globalObject, JSC::CallFrame *callFrame)) { diff --git a/src/bun.js/modules/NodeTTYModule.cpp b/src/bun.js/modules/NodeTTYModule.cpp index 14f1551858..c5521dd97a 100644 --- a/src/bun.js/modules/NodeTTYModule.cpp +++ b/src/bun.js/modules/NodeTTYModule.cpp @@ -15,7 +15,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionTty_isatty, (JSGlobalObject * globalObject, auto scope = DECLARE_CATCH_SCOPE(vm); int fd = callFrame->argument(0).toInt32(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); + RETURN_IF_EXCEPTION(scope, {}); #if !OS(WINDOWS) bool isTTY = isatty(fd); @@ -40,7 +40,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplementedYet, auto throwScope = DECLARE_THROW_SCOPE(vm); throwException(globalObject, throwScope, createError(globalObject, "Not implemented yet"_s)); - return JSValue::encode(jsUndefined()); + return {}; } } // namespace Zig \ No newline at end of file