From e2f20d794f30378344a00d7ac13545eb765d73bf Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 1 Oct 2024 03:49:10 -0700 Subject: [PATCH] clang-format: add InsertNewlineAtEOF (#14267) Co-authored-by: nektro --- .github/workflows/clang-format.yml | 13 +++- cmake/analysis/RunClangFormat.cmake | 11 +++ package.json | 1 + src/bun.js/bindings/.clang-format | 1 + src/bun.js/bindings/Base64Helpers.cpp | 2 +- src/bun.js/bindings/BunClientData.cpp | 2 +- src/bun.js/bindings/BunCommonStrings.cpp | 2 +- src/bun.js/bindings/BunInjectedScriptHost.cpp | 2 +- src/bun.js/bindings/BunPlugin.cpp | 2 +- src/bun.js/bindings/BunProcess.cpp | 66 ++++++++-------- src/bun.js/bindings/BunWorkerGlobalScope.cpp | 2 +- src/bun.js/bindings/CPUFeatures.cpp | 2 +- src/bun.js/bindings/ConsoleObject.cpp | 2 +- src/bun.js/bindings/ErrorStackFrame.cpp | 2 +- .../bindings/InternalModuleRegistry.cpp | 2 +- src/bun.js/bindings/JS2Native.cpp | 2 +- src/bun.js/bindings/JSCTestingHelpers.cpp | 2 +- .../bindings/JSCUSocketsLoopIntegration.cpp | 2 +- src/bun.js/bindings/JSDOMFile.cpp | 2 +- src/bun.js/bindings/JSDOMGlobalObject.cpp | 2 +- src/bun.js/bindings/JSMockFunction.cpp | 2 +- src/bun.js/bindings/JSNextTickQueue.cpp | 2 +- src/bun.js/bindings/KeyObject.cpp | 8 +- src/bun.js/bindings/NodeAsyncHooks.cpp | 2 +- src/bun.js/bindings/NodeFetch.cpp | 2 +- src/bun.js/bindings/NodeTLS.cpp | 2 +- src/bun.js/bindings/ProcessBindingTTYWrap.cpp | 2 +- src/bun.js/bindings/ProcessBindingUV.cpp | 2 +- src/bun.js/bindings/RegularExpression.cpp | 2 +- src/bun.js/bindings/Serialization.cpp | 2 +- src/bun.js/bindings/Uint8Array.cpp | 2 +- src/bun.js/bindings/Undici.cpp | 2 +- src/bun.js/bindings/UtilInspect.cpp | 2 +- src/bun.js/bindings/Weak.cpp | 2 +- src/bun.js/bindings/blob.cpp | 2 +- src/bun.js/bindings/bun-simdutf.cpp | 2 +- src/bun.js/bindings/bun-spawn.cpp | 2 +- src/bun.js/bindings/coroutine.cpp | 2 +- src/bun.js/bindings/helpers.cpp | 2 +- src/bun.js/bindings/isBuiltinModule.cpp | 2 +- src/bun.js/bindings/napi_external.cpp | 2 +- src/bun.js/bindings/spawn.cpp | 2 +- .../bindings/webcore/JSDOMConvertStrings.cpp | 2 +- .../bindings/webcore/JSDOMGuardedObject.cpp | 2 +- src/bun.js/bindings/webcore/JSDOMIterator.cpp | 2 +- .../bindings/webcore/JSDOMOperation.cpp | 2 +- .../bindings/webcore/JSEventTargetNode.cpp | 2 +- .../webcore/SerializedScriptValue.cpp | 8 +- src/kit/KitDevGlobalObject.cpp | 76 ++++++++++--------- 49 files changed, 146 insertions(+), 120 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 193225603c6e2..12e2e5fe6638a 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -9,7 +9,7 @@ on: pull_request: paths: - ".github/workflows/clang-format.yml" - - ".clang-format" + - "**.clang-format" - "package.json" - "scripts/**" - "cmake/**" @@ -30,6 +30,7 @@ jobs: name: clang-format runs-on: ubuntu-latest steps: + - run: sudo rm /usr/bin/clang-format - name: Checkout uses: actions/checkout@v4 with: @@ -48,12 +49,20 @@ jobs: - name: Install LLVM run: | curl -fsSL https://apt.llvm.org/llvm.sh | sudo bash -s -- ${{ env.LLVM_VERSION_MAJOR }} all + - run: ls -l /usr/lib/llvm-${LLVM_VERSION_MAJOR}/bin/ + - run: echo "/usr/lib/llvm-${LLVM_VERSION_MAJOR}/bin/" >> $GITHUB_PATH + - name: Clang Format Version + env: + ENABLE_CCACHE: OFF + LLVM_VERSION: ${{ env.LLVM_VERSION }} + run: | + bun run clang-format:version - name: Clang Format env: ENABLE_CCACHE: OFF LLVM_VERSION: ${{ env.LLVM_VERSION }} run: | - bun run clang-format:diff + bun run clang-format - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/cmake/analysis/RunClangFormat.cmake b/cmake/analysis/RunClangFormat.cmake index 7586e68aeb56e..31e9140205758 100644 --- a/cmake/analysis/RunClangFormat.cmake +++ b/cmake/analysis/RunClangFormat.cmake @@ -11,6 +11,17 @@ find_command( set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES}) +register_command( + TARGET + clang-format-version + COMMENT + "Print clang-format version" + COMMAND + ${CLANG_FORMAT_PROGRAM} + --version + ALWAYS_RUN +) + register_command( TARGET clang-format-check diff --git a/package.json b/package.json index 6f9c56e1ff1ef..f302e0f0747f4 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "zig:check-windows": "bun run zig build check-windows --summary new", "cmake": "bun ./scripts/build.mjs -DCMAKE_BUILD_TYPE=Debug -B build/debug", "clang-format": "bun run cmake --target clang-format", + "clang-format:version": "bun run cmake --target clang-format-version", "clang-format:check": "bun run cmake --target clang-format-check", "clang-format:diff": "bun run cmake --target clang-format-diff", "clang-tidy": "bun run cmake --target clang-tidy", diff --git a/src/bun.js/bindings/.clang-format b/src/bun.js/bindings/.clang-format index 79808145f886f..d3d5f2ecb3357 100644 --- a/src/bun.js/bindings/.clang-format +++ b/src/bun.js/bindings/.clang-format @@ -73,6 +73,7 @@ IncludeIsMainRegex: "(Test)?$" IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false +InsertNewlineAtEOF: true JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true diff --git a/src/bun.js/bindings/Base64Helpers.cpp b/src/bun.js/bindings/Base64Helpers.cpp index ac99cf78e81f5..1e13730f47b56 100644 --- a/src/bun.js/bindings/Base64Helpers.cpp +++ b/src/bun.js/bindings/Base64Helpers.cpp @@ -50,4 +50,4 @@ ExceptionOr atob(const String& encodedString) return outString; } } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunClientData.cpp b/src/bun.js/bindings/BunClientData.cpp index ee48afd07fb41..f8734725e4bf3 100644 --- a/src/bun.js/bindings/BunClientData.cpp +++ b/src/bun.js/bindings/BunClientData.cpp @@ -94,4 +94,4 @@ void JSVMClientData::create(VM* vm, void* bunVM) clientData->builtinFunctions().exportNames(); } -} // namespace WebCore \ No newline at end of file +} // namespace WebCore diff --git a/src/bun.js/bindings/BunCommonStrings.cpp b/src/bun.js/bindings/BunCommonStrings.cpp index 0d93179cf606c..c0327ca6e7e4a 100644 --- a/src/bun.js/bindings/BunCommonStrings.cpp +++ b/src/bun.js/bindings/BunCommonStrings.cpp @@ -36,4 +36,4 @@ void CommonStrings::visit(Visitor& visitor) template void CommonStrings::visit(JSC::AbstractSlotVisitor&); template void CommonStrings::visit(JSC::SlotVisitor&); -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/BunInjectedScriptHost.cpp b/src/bun.js/bindings/BunInjectedScriptHost.cpp index a31aefdc2948c..13c7a48febf97 100644 --- a/src/bun.js/bindings/BunInjectedScriptHost.cpp +++ b/src/bun.js/bindings/BunInjectedScriptHost.cpp @@ -174,4 +174,4 @@ JSValue BunInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exe return {}; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp index 3f7386e7ba52b..8f1bb8d06ea74 100644 --- a/src/bun.js/bindings/BunPlugin.cpp +++ b/src/bun.js/bindings/BunPlugin.cpp @@ -936,4 +936,4 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBunPluginClear, (JSC::JSGlobalObject * global BUN_DEFINE_HOST_FUNCTION(jsFunctionBunPlugin, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) { return Bun::setupBunPlugin(globalObject, callframe, BunPluginTargetBun); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index 9115a9ba259da..f0c01bc46e2d2 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -383,7 +383,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, return JSValue::encode(jsUndefined()); } - JSC::EncodedJSValue (*napi_register_module_v1)(JSC::JSGlobalObject * globalObject, + JSC::EncodedJSValue (*napi_register_module_v1)(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue exports); #if OS(WINDOWS) #define dlsym GetProcAddress @@ -697,82 +697,82 @@ static void loadSignalNumberMap() signalNameToNumberMap->add(signalNames[9], SIGKILL); signalNameToNumberMap->add(signalNames[15], SIGTERM); #else - signalNameToNumberMap->add(signalNames[0], SIGHUP); - signalNameToNumberMap->add(signalNames[1], SIGINT); - signalNameToNumberMap->add(signalNames[2], SIGQUIT); - signalNameToNumberMap->add(signalNames[3], SIGILL); + signalNameToNumberMap->add(signalNames[0], SIGHUP); + signalNameToNumberMap->add(signalNames[1], SIGINT); + signalNameToNumberMap->add(signalNames[2], SIGQUIT); + signalNameToNumberMap->add(signalNames[3], SIGILL); #ifdef SIGTRAP - signalNameToNumberMap->add(signalNames[4], SIGTRAP); + signalNameToNumberMap->add(signalNames[4], SIGTRAP); #endif - signalNameToNumberMap->add(signalNames[5], SIGABRT); + signalNameToNumberMap->add(signalNames[5], SIGABRT); #ifdef SIGIOT - signalNameToNumberMap->add(signalNames[6], SIGIOT); + signalNameToNumberMap->add(signalNames[6], SIGIOT); #endif #ifdef SIGBUS - signalNameToNumberMap->add(signalNames[7], SIGBUS); + signalNameToNumberMap->add(signalNames[7], SIGBUS); #endif - signalNameToNumberMap->add(signalNames[8], SIGFPE); - signalNameToNumberMap->add(signalNames[9], SIGKILL); + signalNameToNumberMap->add(signalNames[8], SIGFPE); + signalNameToNumberMap->add(signalNames[9], SIGKILL); #ifdef SIGUSR1 - signalNameToNumberMap->add(signalNames[10], SIGUSR1); + signalNameToNumberMap->add(signalNames[10], SIGUSR1); #endif - signalNameToNumberMap->add(signalNames[11], SIGSEGV); + signalNameToNumberMap->add(signalNames[11], SIGSEGV); #ifdef SIGUSR2 - signalNameToNumberMap->add(signalNames[12], SIGUSR2); + signalNameToNumberMap->add(signalNames[12], SIGUSR2); #endif #ifdef SIGPIPE - signalNameToNumberMap->add(signalNames[13], SIGPIPE); + signalNameToNumberMap->add(signalNames[13], SIGPIPE); #endif #ifdef SIGALRM - signalNameToNumberMap->add(signalNames[14], SIGALRM); + signalNameToNumberMap->add(signalNames[14], SIGALRM); #endif - signalNameToNumberMap->add(signalNames[15], SIGTERM); + signalNameToNumberMap->add(signalNames[15], SIGTERM); #ifdef SIGCHLD - signalNameToNumberMap->add(signalNames[16], SIGCHLD); + signalNameToNumberMap->add(signalNames[16], SIGCHLD); #endif #ifdef SIGCONT - signalNameToNumberMap->add(signalNames[17], SIGCONT); + signalNameToNumberMap->add(signalNames[17], SIGCONT); #endif #ifdef SIGSTOP - signalNameToNumberMap->add(signalNames[18], SIGSTOP); + signalNameToNumberMap->add(signalNames[18], SIGSTOP); #endif #ifdef SIGTSTP - signalNameToNumberMap->add(signalNames[19], SIGTSTP); + signalNameToNumberMap->add(signalNames[19], SIGTSTP); #endif #ifdef SIGTTIN - signalNameToNumberMap->add(signalNames[20], SIGTTIN); + signalNameToNumberMap->add(signalNames[20], SIGTTIN); #endif #ifdef SIGTTOU - signalNameToNumberMap->add(signalNames[21], SIGTTOU); + signalNameToNumberMap->add(signalNames[21], SIGTTOU); #endif #ifdef SIGURG - signalNameToNumberMap->add(signalNames[22], SIGURG); + signalNameToNumberMap->add(signalNames[22], SIGURG); #endif #ifdef SIGXCPU - signalNameToNumberMap->add(signalNames[23], SIGXCPU); + signalNameToNumberMap->add(signalNames[23], SIGXCPU); #endif #ifdef SIGXFSZ - signalNameToNumberMap->add(signalNames[24], SIGXFSZ); + signalNameToNumberMap->add(signalNames[24], SIGXFSZ); #endif #ifdef SIGVTALRM - signalNameToNumberMap->add(signalNames[25], SIGVTALRM); + signalNameToNumberMap->add(signalNames[25], SIGVTALRM); #endif #ifdef SIGPROF - signalNameToNumberMap->add(signalNames[26], SIGPROF); + signalNameToNumberMap->add(signalNames[26], SIGPROF); #endif - signalNameToNumberMap->add(signalNames[27], SIGWINCH); + signalNameToNumberMap->add(signalNames[27], SIGWINCH); #ifdef SIGIO - signalNameToNumberMap->add(signalNames[28], SIGIO); + signalNameToNumberMap->add(signalNames[28], SIGIO); #endif #ifdef SIGINFO - signalNameToNumberMap->add(signalNames[29], SIGINFO); + signalNameToNumberMap->add(signalNames[29], SIGINFO); #endif #ifndef SIGINFO - signalNameToNumberMap->add(signalNames[29], 255); + signalNameToNumberMap->add(signalNames[29], 255); #endif #ifdef SIGSYS - signalNameToNumberMap->add(signalNames[30], SIGSYS); + signalNameToNumberMap->add(signalNames[30], SIGSYS); #endif #endif }); diff --git a/src/bun.js/bindings/BunWorkerGlobalScope.cpp b/src/bun.js/bindings/BunWorkerGlobalScope.cpp index 3bac99269b094..40b1fbfddbd83 100644 --- a/src/bun.js/bindings/BunWorkerGlobalScope.cpp +++ b/src/bun.js/bindings/BunWorkerGlobalScope.cpp @@ -41,4 +41,4 @@ void WorkerGlobalScope::onDidChangeListenerImpl(EventTarget& self, const AtomStr } }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/CPUFeatures.cpp b/src/bun.js/bindings/CPUFeatures.cpp index 861de32dc1be4..d6665cd6b7de6 100644 --- a/src/bun.js/bindings/CPUFeatures.cpp +++ b/src/bun.js/bindings/CPUFeatures.cpp @@ -107,4 +107,4 @@ extern "C" uint8_t bun_cpu_features() #else return 0; #endif -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/ConsoleObject.cpp b/src/bun.js/bindings/ConsoleObject.cpp index 754cfe5c676f0..1645511c7f2ca 100644 --- a/src/bun.js/bindings/ConsoleObject.cpp +++ b/src/bun.js/bindings/ConsoleObject.cpp @@ -132,4 +132,4 @@ void ConsoleObject::profileEnd(JSC::JSGlobalObject* globalObject, const String& } } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/ErrorStackFrame.cpp b/src/bun.js/bindings/ErrorStackFrame.cpp index 98fe90acf6f4a..cb8c553e28ccf 100644 --- a/src/bun.js/bindings/ErrorStackFrame.cpp +++ b/src/bun.js/bindings/ErrorStackFrame.cpp @@ -88,4 +88,4 @@ ZigStackFramePosition getAdjustedPositionForBytecode(JSC::CodeBlock* code, JSC:: return pos; } -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/InternalModuleRegistry.cpp b/src/bun.js/bindings/InternalModuleRegistry.cpp index 3043fd0e9d19f..01cc9c65b68e3 100644 --- a/src/bun.js/bindings/InternalModuleRegistry.cpp +++ b/src/bun.js/bindings/InternalModuleRegistry.cpp @@ -169,4 +169,4 @@ JSC_DEFINE_HOST_FUNCTION(InternalModuleRegistry::jsCreateInternalModuleById, (JS } // namespace Bun #undef INTERNAL_MODULE_REGISTRY_GENERATE_ -#undef INTERNAL_MODULE_REGISTRY_GENERATE \ No newline at end of file +#undef INTERNAL_MODULE_REGISTRY_GENERATE diff --git a/src/bun.js/bindings/JS2Native.cpp b/src/bun.js/bindings/JS2Native.cpp index 61b16fefb19b3..4ce898bf38985 100644 --- a/src/bun.js/bindings/JS2Native.cpp +++ b/src/bun.js/bindings/JS2Native.cpp @@ -36,4 +36,4 @@ JSC_DEFINE_HOST_FUNCTION(jsDollarLazy, (JSC::JSGlobalObject * lexicalGlobalObjec } } // namespace JS2Native -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/JSCTestingHelpers.cpp b/src/bun.js/bindings/JSCTestingHelpers.cpp index 5f64580d351f2..78092eec0c3a3 100644 --- a/src/bun.js/bindings/JSCTestingHelpers.cpp +++ b/src/bun.js/bindings/JSCTestingHelpers.cpp @@ -68,4 +68,4 @@ JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* globalObject) return object; } -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/JSCUSocketsLoopIntegration.cpp b/src/bun.js/bindings/JSCUSocketsLoopIntegration.cpp index 0e3fcf47dc990..9566a289099c8 100644 --- a/src/bun.js/bindings/JSCUSocketsLoopIntegration.cpp +++ b/src/bun.js/bindings/JSCUSocketsLoopIntegration.cpp @@ -27,4 +27,4 @@ extern "C" void bun_on_tick_after(JSC::VM* vm) #if ACQUIRE_RELEASE_HEAP_ACCESS // vm->heap.acquireAccess(); #endif -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSDOMFile.cpp b/src/bun.js/bindings/JSDOMFile.cpp index 212cbeb0c09bd..6b6f980062a2f 100644 --- a/src/bun.js/bindings/JSDOMFile.cpp +++ b/src/bun.js/bindings/JSDOMFile.cpp @@ -110,4 +110,4 @@ JSC::JSObject* createJSDOMFileConstructor(JSC::VM& vm, JSC::JSGlobalObject* glob return JSDOMFile::create(vm, globalObject); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSDOMGlobalObject.cpp b/src/bun.js/bindings/JSDOMGlobalObject.cpp index f90268828d1a2..c83a1a95cb5d2 100644 --- a/src/bun.js/bindings/JSDOMGlobalObject.cpp +++ b/src/bun.js/bindings/JSDOMGlobalObject.cpp @@ -84,4 +84,4 @@ Zig::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWo // return callerGlobalObject(lexicalGlobalObject, callFrame, skipFirstFrame, lookUpFromVMEntryScope); // } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index 699f695a451cf..5140505d04c9f 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -1585,4 +1585,4 @@ BUN_DEFINE_HOST_FUNCTION(JSMock__jsMockFn, (JSC::JSGlobalObject * lexicalGlobalO return JSValue::encode(thisObject); } -#undef CHECK_IS_MOCK_FUNCTION \ No newline at end of file +#undef CHECK_IS_MOCK_FUNCTION diff --git a/src/bun.js/bindings/JSNextTickQueue.cpp b/src/bun.js/bindings/JSNextTickQueue.cpp index 6c3557177bd3b..7b9c1f98bb10f 100644 --- a/src/bun.js/bindings/JSNextTickQueue.cpp +++ b/src/bun.js/bindings/JSNextTickQueue.cpp @@ -93,4 +93,4 @@ void JSNextTickQueue::drain(JSC::VM& vm, JSC::JSGlobalObject* globalObject) } } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/KeyObject.cpp b/src/bun.js/bindings/KeyObject.cpp index 75784483158aa..c5c5c113ec994 100644 --- a/src/bun.js/bindings/KeyObject.cpp +++ b/src/bun.js/bindings/KeyObject.cpp @@ -3113,7 +3113,7 @@ static EncodedJSValue doAsymmetricSign(JSGlobalObject* globalObject, CallFrame* // We may classify the key as RSA_OAEP, but it can still be used for signing. RSA_PSS relies // on an incompatible scheme, and must be used via the generic crypto.sign function. || (cryptoKey.algorithmIdentifier() != CryptoAlgorithmIdentifier::RSA_OAEP - && cryptoKey.algorithmIdentifier() != CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5)) { + && cryptoKey.algorithmIdentifier() != CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5)) { return Bun::throwError(globalObject, scope, Bun::ErrorCode::ERR_INVALID_ARG_VALUE, "unsupported key type for asymmetric signing"_s); } @@ -3141,7 +3141,7 @@ static EncodedJSValue doAsymmetricSign(JSGlobalObject* globalObject, CallFrame* const auto& rsaKey = downcast(cryptoKey); auto operation = encrypt ? CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSignNoAlgorithm - : CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyRecover; + : CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyRecover; auto result = operation(rsaKey, padding, buffer); if (result.hasException()) { WebCore::propagateException(*globalObject, scope, result.releaseException()); @@ -3151,12 +3151,12 @@ static EncodedJSValue doAsymmetricSign(JSGlobalObject* globalObject, CallFrame* return JSValue::encode(WebCore::createBuffer(globalObject, outBuffer)); } -JSC_DEFINE_HOST_FUNCTION(KeyObject__privateEncrypt, (JSGlobalObject* globalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(KeyObject__privateEncrypt, (JSGlobalObject * globalObject, CallFrame* callFrame)) { return doAsymmetricSign(globalObject, callFrame, true); } -JSC_DEFINE_HOST_FUNCTION(KeyObject__publicDecrypt, (JSGlobalObject* globalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(KeyObject__publicDecrypt, (JSGlobalObject * globalObject, CallFrame* callFrame)) { return doAsymmetricSign(globalObject, callFrame, false); } diff --git a/src/bun.js/bindings/NodeAsyncHooks.cpp b/src/bun.js/bindings/NodeAsyncHooks.cpp index 8828d2d3540cc..c36ed476f1b7f 100644 --- a/src/bun.js/bindings/NodeAsyncHooks.cpp +++ b/src/bun.js/bindings/NodeAsyncHooks.cpp @@ -48,4 +48,4 @@ JSC::JSValue createAsyncHooksBinding(Zig::GlobalObject* globalObject) return binding; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeFetch.cpp b/src/bun.js/bindings/NodeFetch.cpp index 1b25af677dad7..742a4fb0e7f26 100644 --- a/src/bun.js/bindings/NodeFetch.cpp +++ b/src/bun.js/bindings/NodeFetch.cpp @@ -47,4 +47,4 @@ JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject* globalObject) return obj; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeTLS.cpp b/src/bun.js/bindings/NodeTLS.cpp index f1c5efa37d095..71ba5fa7fd866 100644 --- a/src/bun.js/bindings/NodeTLS.cpp +++ b/src/bun.js/bindings/NodeTLS.cpp @@ -37,4 +37,4 @@ JSC::JSValue createNodeTLSBinding(Zig::GlobalObject* globalObject) return obj; } -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp index 052863c90024f..130d150cb942b 100644 --- a/src/bun.js/bindings/ProcessBindingTTYWrap.cpp +++ b/src/bun.js/bindings/ProcessBindingTTYWrap.cpp @@ -517,4 +517,4 @@ JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject) return obj; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/ProcessBindingUV.cpp b/src/bun.js/bindings/ProcessBindingUV.cpp index c6151ffefe9a1..b3a9aa5e0c0ea 100644 --- a/src/bun.js/bindings/ProcessBindingUV.cpp +++ b/src/bun.js/bindings/ProcessBindingUV.cpp @@ -171,4 +171,4 @@ JSObject* create(VM& vm, JSGlobalObject* globalObject) } } // namespace ProcessBindingUV -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/RegularExpression.cpp b/src/bun.js/bindings/RegularExpression.cpp index 6fbf1b7733b55..1a4b03568917c 100644 --- a/src/bun.js/bindings/RegularExpression.cpp +++ b/src/bun.js/bindings/RegularExpression.cpp @@ -38,4 +38,4 @@ extern "C" int Yarr__RegularExpression__searchRev(RegularExpression* re, BunStri extern "C" int Yarr__RegularExpression__matches(RegularExpression* re, BunString string) { return re->match(string.toWTFString(BunString::ZeroCopy), 0, 0); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Serialization.cpp b/src/bun.js/bindings/Serialization.cpp index fafb08b3736e6..93a1393d660d7 100644 --- a/src/bun.js/bindings/Serialization.cpp +++ b/src/bun.js/bindings/Serialization.cpp @@ -56,4 +56,4 @@ extern "C" EncodedJSValue Bun__JSValue__deserialize(JSGlobalObject* globalObject /// ?! did i just give ownership of these bytes to JSC? auto scriptValue = SerializedScriptValue::createFromWireBytes(WTFMove(vector)); return JSValue::encode(scriptValue->deserialize(*globalObject, globalObject)); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Uint8Array.cpp b/src/bun.js/bindings/Uint8Array.cpp index 697bf61a5ac46..62d43612ddbea 100644 --- a/src/bun.js/bindings/Uint8Array.cpp +++ b/src/bun.js/bindings/Uint8Array.cpp @@ -41,4 +41,4 @@ extern "C" JSC::EncodedJSValue JSArrayBuffer__fromDefaultAllocator(JSC::JSGlobal return JSC::JSValue::encode(arrayBuffer); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Undici.cpp b/src/bun.js/bindings/Undici.cpp index 879b9f4fe25bf..43f196c198b3b 100644 --- a/src/bun.js/bindings/Undici.cpp +++ b/src/bun.js/bindings/Undici.cpp @@ -56,4 +56,4 @@ JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject) return obj; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/UtilInspect.cpp b/src/bun.js/bindings/UtilInspect.cpp index f96bfbbe93318..9df5b95eada7e 100644 --- a/src/bun.js/bindings/UtilInspect.cpp +++ b/src/bun.js/bindings/UtilInspect.cpp @@ -68,4 +68,4 @@ extern "C" JSC::EncodedJSValue JSC__JSValue__callCustomInspectFunction( RELEASE_AND_RETURN(scope, JSValue::encode(inspectRet)); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Weak.cpp b/src/bun.js/bindings/Weak.cpp index 33c885dea4844..2d1a8e50181a9 100644 --- a/src/bun.js/bindings/Weak.cpp +++ b/src/bun.js/bindings/Weak.cpp @@ -117,4 +117,4 @@ extern "C" JSC::EncodedJSValue Bun__WeakRef__get(Bun::WeakRef* weakRef) return JSC::JSValue::encode(cell); } return JSC::encodedJSValue(); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/blob.cpp b/src/bun.js/bindings/blob.cpp index bfbdc1fd49946..85982f1b8b3e8 100644 --- a/src/bun.js/bindings/blob.cpp +++ b/src/bun.js/bindings/blob.cpp @@ -26,4 +26,4 @@ JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlo return JSC::JSValue::decode(encoded); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/bun-simdutf.cpp b/src/bun.js/bindings/bun-simdutf.cpp index ea6ff06416509..e6dd1c471d4c6 100644 --- a/src/bun.js/bindings/bun-simdutf.cpp +++ b/src/bun.js/bindings/bun-simdutf.cpp @@ -362,4 +362,4 @@ SIMDUTFResult simdutf__base64_decode_from_binary16(const char16_t* input, size_t return { .error = res.error, .count = res.count }; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/bun-spawn.cpp b/src/bun.js/bindings/bun-spawn.cpp index 70d84833e1e5f..a9aa921dc1914 100644 --- a/src/bun.js/bindings/bun-spawn.cpp +++ b/src/bun.js/bindings/bun-spawn.cpp @@ -201,4 +201,4 @@ extern "C" ssize_t posix_spawn_bun( return res; } -#endif \ No newline at end of file +#endif diff --git a/src/bun.js/bindings/coroutine.cpp b/src/bun.js/bindings/coroutine.cpp index bf3ebea3f936f..883d3ed3c24c1 100644 --- a/src/bun.js/bindings/coroutine.cpp +++ b/src/bun.js/bindings/coroutine.cpp @@ -39,4 +39,4 @@ extern "C" void Bun__startMacro(BunMacroFunction ctx, JSC::JSGlobalObject* globa // mco_result res = mco_create(&co, &desc); // mco_resume(co); // mco_destroy(co); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/helpers.cpp b/src/bun.js/bindings/helpers.cpp index 88f2a5be2bc1e..6aa6a6096a8a7 100644 --- a/src/bun.js/bindings/helpers.cpp +++ b/src/bun.js/bindings/helpers.cpp @@ -22,4 +22,4 @@ JSC::JSValue createSystemError(JSC::JSGlobalObject* global, ASCIILiteral syscall instance->putDirect(vm, builtinNames.errnoPublicName(), JSC::jsNumber(err), 0); instance->putDirect(vm, vm.propertyNames->name, jsString(vm, String("SystemError"_s)), JSC::PropertyAttribute::DontEnum | 0); return instance; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/isBuiltinModule.cpp b/src/bun.js/bindings/isBuiltinModule.cpp index ee1bd77a76913..1d8484618be6f 100644 --- a/src/bun.js/bindings/isBuiltinModule.cpp +++ b/src/bun.js/bindings/isBuiltinModule.cpp @@ -96,4 +96,4 @@ bool isBuiltinModule(const String& namePossiblyWithNodePrefix) return false; } -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/napi_external.cpp b/src/bun.js/bindings/napi_external.cpp index 3780ebc210cf2..f6925d999297c 100644 --- a/src/bun.js/bindings/napi_external.cpp +++ b/src/bun.js/bindings/napi_external.cpp @@ -19,4 +19,4 @@ void NapiExternal::destroy(JSC::JSCell* cell) const ClassInfo NapiExternal::s_info = { "External"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(NapiExternal) }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/spawn.cpp b/src/bun.js/bindings/spawn.cpp index 04570f4bab174..daa0f782c3957 100644 --- a/src/bun.js/bindings/spawn.cpp +++ b/src/bun.js/bindings/spawn.cpp @@ -19,4 +19,4 @@ extern "C" int posix_spawnattr_reset_signals(posix_spawnattr_t* attr) return 0; } -#endif \ No newline at end of file +#endif diff --git a/src/bun.js/bindings/webcore/JSDOMConvertStrings.cpp b/src/bun.js/bindings/webcore/JSDOMConvertStrings.cpp index d5ae213042355..53003fa258120 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertStrings.cpp +++ b/src/bun.js/bindings/webcore/JSDOMConvertStrings.cpp @@ -117,4 +117,4 @@ AtomString valueToUSVAtomString(JSGlobalObject& lexicalGlobalObject, JSValue val return replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(string)); } -} // namespace WebCore \ No newline at end of file +} // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSDOMGuardedObject.cpp b/src/bun.js/bindings/webcore/JSDOMGuardedObject.cpp index 863fbb7385ce1..13cc800b24eb3 100644 --- a/src/bun.js/bindings/webcore/JSDOMGuardedObject.cpp +++ b/src/bun.js/bindings/webcore/JSDOMGuardedObject.cpp @@ -74,4 +74,4 @@ void DOMGuardedObject::contextDestroyed() clear(); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/webcore/JSDOMIterator.cpp b/src/bun.js/bindings/webcore/JSDOMIterator.cpp index 0bc957e177be0..4dc57d5e653aa 100644 --- a/src/bun.js/bindings/webcore/JSDOMIterator.cpp +++ b/src/bun.js/bindings/webcore/JSDOMIterator.cpp @@ -52,4 +52,4 @@ void addValueIterableMethods(JSC::JSGlobalObject& globalObject, JSC::JSObject& p copyProperty(vm.propertyNames->builtinNames().valuesPrivateName(), vm.propertyNames->builtinNames().valuesPublicName()); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/webcore/JSDOMOperation.cpp b/src/bun.js/bindings/webcore/JSDOMOperation.cpp index 1c1b40e951586..4aa4a8b6267b7 100644 --- a/src/bun.js/bindings/webcore/JSDOMOperation.cpp +++ b/src/bun.js/bindings/webcore/JSDOMOperation.cpp @@ -42,4 +42,4 @@ void throwNodeRangeError(JSGlobalObject* lexicalGlobalObject, ThrowScope& scope, } } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/webcore/JSEventTargetNode.cpp b/src/bun.js/bindings/webcore/JSEventTargetNode.cpp index b278c744922e3..7fc9eec1d340c 100644 --- a/src/bun.js/bindings/webcore/JSEventTargetNode.cpp +++ b/src/bun.js/bindings/webcore/JSEventTargetNode.cpp @@ -44,4 +44,4 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeEventsGetEventListeners, (JSGlobalObject return JSValue::encode(constructArray(globalObject, static_cast(nullptr), values)); } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp index 823f2a46edf35..c3b936459e8fd 100644 --- a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp +++ b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp @@ -2574,7 +2574,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) indexStack.last()++; goto objectStartVisitMember; } - mapStartState : { + mapStartState: { ASSERT(inValue.isObject()); if (inputObjectStack.size() > maximumFilterRecursion) return SerializationReturnCode::StackOverflowError; @@ -2622,7 +2622,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in) goto mapDataStartVisitEntry; } - setStartState : { + setStartState: { ASSERT(inValue.isObject()); if (inputObjectStack.size() > maximumFilterRecursion) return SerializationReturnCode::StackOverflowError; @@ -5084,7 +5084,7 @@ DeserializationResult CloneDeserializer::deserialize() propertyNameStack.removeLast(); goto objectStartVisitMember; } - mapObjectStartState : { + mapObjectStartState: { if (outputObjectStack.size() > maximumFilterRecursion) return std::make_pair(JSValue(), SerializationReturnCode::StackOverflowError); JSMap* map = JSMap::create(m_lexicalGlobalObject->vm(), m_globalObject->mapStructure()); @@ -5113,7 +5113,7 @@ DeserializationResult CloneDeserializer::deserialize() goto mapDataStartVisitEntry; } - setObjectStartState : { + setObjectStartState: { if (outputObjectStack.size() > maximumFilterRecursion) return std::make_pair(JSValue(), SerializationReturnCode::StackOverflowError); JSSet* set = JSSet::create(m_lexicalGlobalObject->vm(), m_globalObject->setStructure()); diff --git a/src/kit/KitDevGlobalObject.cpp b/src/kit/KitDevGlobalObject.cpp index 8716fa3790dfd..83527a65a6e08 100644 --- a/src/kit/KitDevGlobalObject.cpp +++ b/src/kit/KitDevGlobalObject.cpp @@ -6,45 +6,49 @@ namespace Kit { -JSC::JSInternalPromise* moduleLoaderImportModule( - JSC::JSGlobalObject* jsGlobalObject, - JSC::JSModuleLoader*, - JSC::JSString* moduleNameValue, - JSC::JSValue parameters, - const JSC::SourceOrigin& sourceOrigin) -{ - // TODO: forward this to the runtime - JSC::VM&vm=jsGlobalObject->vm(); - auto err = JSC::createTypeError(jsGlobalObject, WTF::makeString("Dynamic import should have been replaced with a hook into the module runtime"_s)); - auto* promise = JSC::JSInternalPromise::create(vm, jsGlobalObject->internalPromiseStructure()); - promise->reject(jsGlobalObject, err); - return promise; +JSC::JSInternalPromise * +moduleLoaderImportModule(JSC::JSGlobalObject *jsGlobalObject, + JSC::JSModuleLoader *, JSC::JSString *moduleNameValue, + JSC::JSValue parameters, + const JSC::SourceOrigin &sourceOrigin) { + // TODO: forward this to the runtime + JSC::VM &vm = jsGlobalObject->vm(); + auto err = JSC::createTypeError( + jsGlobalObject, + WTF::makeString( + "Dynamic import should have been replaced with a hook into the module runtime"_s)); + auto *promise = JSC::JSInternalPromise::create( + vm, jsGlobalObject->internalPromiseStructure()); + promise->reject(jsGlobalObject, err); + return promise; } -#define INHERIT_HOOK_METHOD(name) Zig::GlobalObject::s_globalObjectMethodTable. name +#define INHERIT_HOOK_METHOD(name) \ + Zig::GlobalObject::s_globalObjectMethodTable.name -const JSC::GlobalObjectMethodTable DevGlobalObject::s_globalObjectMethodTable = { - INHERIT_HOOK_METHOD(supportsRichSourceInfo), - INHERIT_HOOK_METHOD(shouldInterruptScript), - INHERIT_HOOK_METHOD(javaScriptRuntimeFlags), - INHERIT_HOOK_METHOD(queueMicrotaskToEventLoop), - INHERIT_HOOK_METHOD(shouldInterruptScriptBeforeTimeout), - moduleLoaderImportModule, - INHERIT_HOOK_METHOD(moduleLoaderResolve), - INHERIT_HOOK_METHOD(moduleLoaderFetch), - INHERIT_HOOK_METHOD(moduleLoaderCreateImportMetaProperties), - INHERIT_HOOK_METHOD(moduleLoaderEvaluate), - INHERIT_HOOK_METHOD(promiseRejectionTracker), - INHERIT_HOOK_METHOD(reportUncaughtExceptionAtEventLoop), - INHERIT_HOOK_METHOD(currentScriptExecutionOwner), - INHERIT_HOOK_METHOD(scriptExecutionStatus), - INHERIT_HOOK_METHOD(reportViolationForUnsafeEval), - INHERIT_HOOK_METHOD(defaultLanguage), - INHERIT_HOOK_METHOD(compileStreaming), - INHERIT_HOOK_METHOD(instantiateStreaming), - INHERIT_HOOK_METHOD(deriveShadowRealmGlobalObject), - INHERIT_HOOK_METHOD(codeForEval), - INHERIT_HOOK_METHOD(canCompileStrings), +const JSC::GlobalObjectMethodTable DevGlobalObject::s_globalObjectMethodTable = + { + INHERIT_HOOK_METHOD(supportsRichSourceInfo), + INHERIT_HOOK_METHOD(shouldInterruptScript), + INHERIT_HOOK_METHOD(javaScriptRuntimeFlags), + INHERIT_HOOK_METHOD(queueMicrotaskToEventLoop), + INHERIT_HOOK_METHOD(shouldInterruptScriptBeforeTimeout), + moduleLoaderImportModule, + INHERIT_HOOK_METHOD(moduleLoaderResolve), + INHERIT_HOOK_METHOD(moduleLoaderFetch), + INHERIT_HOOK_METHOD(moduleLoaderCreateImportMetaProperties), + INHERIT_HOOK_METHOD(moduleLoaderEvaluate), + INHERIT_HOOK_METHOD(promiseRejectionTracker), + INHERIT_HOOK_METHOD(reportUncaughtExceptionAtEventLoop), + INHERIT_HOOK_METHOD(currentScriptExecutionOwner), + INHERIT_HOOK_METHOD(scriptExecutionStatus), + INHERIT_HOOK_METHOD(reportViolationForUnsafeEval), + INHERIT_HOOK_METHOD(defaultLanguage), + INHERIT_HOOK_METHOD(compileStreaming), + INHERIT_HOOK_METHOD(instantiateStreaming), + INHERIT_HOOK_METHOD(deriveShadowRealmGlobalObject), + INHERIT_HOOK_METHOD(codeForEval), + INHERIT_HOOK_METHOD(canCompileStrings), }; DevGlobalObject *