diff --git a/cmake/analysis/RunClangFormat.cmake b/cmake/analysis/RunClangFormat.cmake index 1b0b0bac0d..106ac54ef6 100644 --- a/cmake/analysis/RunClangFormat.cmake +++ b/cmake/analysis/RunClangFormat.cmake @@ -1,6 +1,11 @@ # https://clang.llvm.org/docs/ClangFormat.html -set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES}) +file(GLOB BUN_H_SOURCES LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} + ${CWD}/src/bun.js/bindings/*.h + ${CWD}/src/bun.js/modules/*.h +) + +set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES} ${BUN_H_SOURCES}) register_command( TARGET diff --git a/src/bun.js/bindings/BufferEncodingType.h b/src/bun.js/bindings/BufferEncodingType.h index 0d50587126..6d3e93274c 100644 --- a/src/bun.js/bindings/BufferEncodingType.h +++ b/src/bun.js/bindings/BufferEncodingType.h @@ -17,4 +17,4 @@ enum class BufferEncodingType { }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunClientData.h b/src/bun.js/bindings/BunClientData.h index 5b28bb5801..c4b7f5745a 100644 --- a/src/bun.js/bindings/BunClientData.h +++ b/src/bun.js/bindings/BunClientData.h @@ -199,4 +199,4 @@ namespace WebCore { using JSVMClientData = WebCore::JSVMClientData; using JSHeapData = WebCore::JSHeapData; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunInjectedScriptHost.h b/src/bun.js/bindings/BunInjectedScriptHost.h index 09e7e13614..5da7446552 100644 --- a/src/bun.js/bindings/BunInjectedScriptHost.h +++ b/src/bun.js/bindings/BunInjectedScriptHost.h @@ -12,4 +12,4 @@ public: bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) override { return false; } }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunPlugin.h b/src/bun.js/bindings/BunPlugin.h index 44a606234e..a8edf0d3aa 100644 --- a/src/bun.js/bindings/BunPlugin.h +++ b/src/bun.js/bindings/BunPlugin.h @@ -106,4 +106,4 @@ class GlobalObject; namespace Bun { JSC::JSValue runVirtualModule(Zig::GlobalObject*, BunString* specifier, bool& wasModuleMock); JSC::Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/BunWorkerGlobalScope.h b/src/bun.js/bindings/BunWorkerGlobalScope.h index eb9a2bac8a..ad9114de84 100644 --- a/src/bun.js/bindings/BunWorkerGlobalScope.h +++ b/src/bun.js/bindings/BunWorkerGlobalScope.h @@ -53,4 +53,4 @@ public: private: MessagePortChannelProviderImpl* m_messagePortChannelProvider; }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/CachedScript.h b/src/bun.js/bindings/CachedScript.h index 3f54613d86..43a7e4ae6b 100644 --- a/src/bun.js/bindings/CachedScript.h +++ b/src/bun.js/bindings/CachedScript.h @@ -6,4 +6,4 @@ namespace WebCore { class CachedScript { }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/CallSitePrototype.h b/src/bun.js/bindings/CallSitePrototype.h index 8aa543fd30..5030763990 100644 --- a/src/bun.js/bindings/CallSitePrototype.h +++ b/src/bun.js/bindings/CallSitePrototype.h @@ -44,4 +44,4 @@ private: void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject); }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/DeleteCallbackDataTask.h b/src/bun.js/bindings/DeleteCallbackDataTask.h index 4c3a5b05d3..e80ddf6fc7 100644 --- a/src/bun.js/bindings/DeleteCallbackDataTask.h +++ b/src/bun.js/bindings/DeleteCallbackDataTask.h @@ -13,4 +13,4 @@ public: } }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/EventLoopTask.h b/src/bun.js/bindings/EventLoopTask.h index 965a36adc0..8461ac17dd 100644 --- a/src/bun.js/bindings/EventLoopTask.h +++ b/src/bun.js/bindings/EventLoopTask.h @@ -41,4 +41,4 @@ protected: bool m_isCleanupTask; }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/GCDefferalContext.h b/src/bun.js/bindings/GCDefferalContext.h index 7bedfb3e0d..802f63033e 100644 --- a/src/bun.js/bindings/GCDefferalContext.h +++ b/src/bun.js/bindings/GCDefferalContext.h @@ -18,4 +18,4 @@ ALWAYS_INLINE GCDeferralContext::~GCDeferralContext() m_vm.heap.collectIfNecessaryOrDefer(); } -} // namespace JSC \ No newline at end of file +} // namespace JSC diff --git a/src/bun.js/bindings/IDLTypes.h b/src/bun.js/bindings/IDLTypes.h index 8eccb08f4e..3ebea7e596 100644 --- a/src/bun.js/bindings/IDLTypes.h +++ b/src/bun.js/bindings/IDLTypes.h @@ -414,4 +414,4 @@ template struct IsIDLArrayBufferViewAllowShared : public std::integral_constant, T>::value> { }; -} // namespace WebCore \ No newline at end of file +} // namespace WebCore diff --git a/src/bun.js/bindings/JS2Native.h b/src/bun.js/bindings/JS2Native.h index 1dd14bfa2c..6765bff3a4 100644 --- a/src/bun.js/bindings/JS2Native.h +++ b/src/bun.js/bindings/JS2Native.h @@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsDollarCpp); JSC_DECLARE_HOST_FUNCTION(jsDollarZig); } // namespace JS2Native -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/JSBundlerPlugin.h b/src/bun.js/bindings/JSBundlerPlugin.h index 3a1f062243..ca0d9f6c96 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.h +++ b/src/bun.js/bindings/JSBundlerPlugin.h @@ -69,4 +69,4 @@ public: bool tombstoned { false }; }; -} // namespace Zig \ No newline at end of file +} // namespace Zig diff --git a/src/bun.js/bindings/JSCTaskScheduler.h b/src/bun.js/bindings/JSCTaskScheduler.h index 45a6d3888d..29660c406d 100644 --- a/src/bun.js/bindings/JSCTaskScheduler.h +++ b/src/bun.js/bindings/JSCTaskScheduler.h @@ -26,4 +26,4 @@ public: HashSet> m_pendingTicketsOther; }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSCTestingHelpers.h b/src/bun.js/bindings/JSCTestingHelpers.h index fad7dd0665..db46851b7a 100644 --- a/src/bun.js/bindings/JSCTestingHelpers.h +++ b/src/bun.js/bindings/JSCTestingHelpers.h @@ -2,4 +2,4 @@ namespace Bun { JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* global); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSDOMConvertBufferSource+JSBuffer.h b/src/bun.js/bindings/JSDOMConvertBufferSource+JSBuffer.h index 88664ff257..d7e2a80062 100644 --- a/src/bun.js/bindings/JSDOMConvertBufferSource+JSBuffer.h +++ b/src/bun.js/bindings/JSDOMConvertBufferSource+JSBuffer.h @@ -8,4 +8,4 @@ namespace WebCore { -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSDOMGlobalObject.h b/src/bun.js/bindings/JSDOMGlobalObject.h index 9e33508a93..49281d94ac 100644 --- a/src/bun.js/bindings/JSDOMGlobalObject.h +++ b/src/bun.js/bindings/JSDOMGlobalObject.h @@ -35,4 +35,4 @@ JSClass* toJSDOMGlobalObject(JSC::VM& vm, JSC::JSValue value) return nullptr; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSEnvironmentVariableMap.h b/src/bun.js/bindings/JSEnvironmentVariableMap.h index 7cc605303e..0de7c81ba4 100644 --- a/src/bun.js/bindings/JSEnvironmentVariableMap.h +++ b/src/bun.js/bindings/JSEnvironmentVariableMap.h @@ -12,4 +12,4 @@ namespace Bun { JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSNextTickQueue.h b/src/bun.js/bindings/JSNextTickQueue.h index 3a499345d8..63c75f6453 100644 --- a/src/bun.js/bindings/JSNextTickQueue.h +++ b/src/bun.js/bindings/JSNextTickQueue.h @@ -37,4 +37,4 @@ public: bool isEmpty(); void drain(JSC::VM& vm, JSC::JSGlobalObject* globalObject); }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/JSWrappingFunction.h b/src/bun.js/bindings/JSWrappingFunction.h index ed3a925583..ac9b9d1919 100644 --- a/src/bun.js/bindings/JSWrappingFunction.h +++ b/src/bun.js/bindings/JSWrappingFunction.h @@ -71,4 +71,4 @@ private: JSC::WriteBarrier m_wrappedFn; }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeAsyncHooks.h b/src/bun.js/bindings/NodeAsyncHooks.h index 84e7c95b13..466dd70e2b 100644 --- a/src/bun.js/bindings/NodeAsyncHooks.h +++ b/src/bun.js/bindings/NodeAsyncHooks.h @@ -2,7 +2,7 @@ #include "ZigGlobalObject.h" namespace Bun { - + JSC::JSValue createAsyncHooksBinding(Zig::GlobalObject*); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeFetch.h b/src/bun.js/bindings/NodeFetch.h index 2b20c2d0be..ee4ee9875d 100644 --- a/src/bun.js/bindings/NodeFetch.h +++ b/src/bun.js/bindings/NodeFetch.h @@ -4,4 +4,4 @@ namespace Bun { JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject*); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeHTTP.h b/src/bun.js/bindings/NodeHTTP.h index e79a2b21d1..d953e3b0f5 100644 --- a/src/bun.js/bindings/NodeHTTP.h +++ b/src/bun.js/bindings/NodeHTTP.h @@ -1,11 +1,11 @@ #include "config.h" namespace Bun { - + JSC_DECLARE_HOST_FUNCTION(jsHTTPAssignHeaders); JSC_DECLARE_HOST_FUNCTION(jsHTTPGetHeader); JSC_DECLARE_HOST_FUNCTION(jsHTTPSetHeader); JSC::JSValue createNodeHTTPInternalBinding(Zig::GlobalObject*); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeTLS.h b/src/bun.js/bindings/NodeTLS.h index 1f1fdb7b3f..2650f0cfaf 100644 --- a/src/bun.js/bindings/NodeTLS.h +++ b/src/bun.js/bindings/NodeTLS.h @@ -2,7 +2,7 @@ #include "ZigGlobalObject.h" namespace Bun { - + JSC::JSValue createNodeTLSBinding(Zig::GlobalObject*); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/NodeURL.h b/src/bun.js/bindings/NodeURL.h index 69a13e2d25..3252194123 100644 --- a/src/bun.js/bindings/NodeURL.h +++ b/src/bun.js/bindings/NodeURL.h @@ -5,4 +5,4 @@ namespace Bun { JSC::JSValue createNodeURLBinding(Zig::GlobalObject*); -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/Path.h b/src/bun.js/bindings/Path.h index 4cdf983b18..edc73912c2 100644 --- a/src/bun.js/bindings/Path.h +++ b/src/bun.js/bindings/Path.h @@ -2,7 +2,7 @@ #include "ZigGlobalObject.h" namespace Bun { - + JSC::JSValue createNodePathBinding(Zig::GlobalObject* globalObject); } // namespace Bun diff --git a/src/bun.js/bindings/ProcessBindingTTYWrap.h b/src/bun.js/bindings/ProcessBindingTTYWrap.h index dfcd56966f..53f82092da 100644 --- a/src/bun.js/bindings/ProcessBindingTTYWrap.h +++ b/src/bun.js/bindings/ProcessBindingTTYWrap.h @@ -15,4 +15,4 @@ JSC::JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject); JSC_DECLARE_HOST_FUNCTION(Process_functionInternalGetWindowSize); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/ProcessBindingUV.h b/src/bun.js/bindings/ProcessBindingUV.h index 4306e21f82..92f1a50600 100644 --- a/src/bun.js/bindings/ProcessBindingUV.h +++ b/src/bun.js/bindings/ProcessBindingUV.h @@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsGetErrorMap); JSC::JSObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject); } // namespace ProcessBindingUV -} // namespace Bun \ No newline at end of file +} // namespace Bun diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index e2cf419111..23bca74153 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -206,4 +206,4 @@ public: ScriptExecutionContext* executionContext(JSC::JSGlobalObject*); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Sink.h b/src/bun.js/bindings/Sink.h index 6f7168c004..38aea38e01 100644 --- a/src/bun.js/bindings/Sink.h +++ b/src/bun.js/bindings/Sink.h @@ -14,4 +14,4 @@ enum SinkID : uint8_t { static constexpr unsigned numberOfSinkIDs = 7; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Strong.h b/src/bun.js/bindings/Strong.h index 8da881a282..f8b2bd7b01 100644 --- a/src/bun.js/bindings/Strong.h +++ b/src/bun.js/bindings/Strong.h @@ -31,4 +31,4 @@ public: JSC::Strong m_cell; }; -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/Undici.h b/src/bun.js/bindings/Undici.h index 5bc89e5a29..88828edc70 100644 --- a/src/bun.js/bindings/Undici.h +++ b/src/bun.js/bindings/Undici.h @@ -3,4 +3,4 @@ namespace Bun { JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/UtilInspect.h b/src/bun.js/bindings/UtilInspect.h index 388865b301..3a8d708c97 100644 --- a/src/bun.js/bindings/UtilInspect.h +++ b/src/bun.js/bindings/UtilInspect.h @@ -4,4 +4,4 @@ namespace Bun { JSC::Structure* createUtilInspectOptionsStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/debug-helpers.h b/src/bun.js/bindings/debug-helpers.h index 01dc92df8f..c40316c4d1 100644 --- a/src/bun.js/bindings/debug-helpers.h +++ b/src/bun.js/bindings/debug-helpers.h @@ -15,4 +15,4 @@ Inspector::InspectorDebuggerAgent* debuggerAgent(JSC::JSGlobalObject* globalObje return nullptr; } -} \ No newline at end of file +} diff --git a/src/bun.js/bindings/isBuiltinModule.h b/src/bun.js/bindings/isBuiltinModule.h index d66f025d11..296dbf402f 100644 --- a/src/bun.js/bindings/isBuiltinModule.h +++ b/src/bun.js/bindings/isBuiltinModule.h @@ -1,5 +1,5 @@ #pragma once namespace Bun { -bool isBuiltinModule(const String &namePossiblyWithNodePrefix); -} // namespace Bun \ No newline at end of file +bool isBuiltinModule(const String& namePossiblyWithNodePrefix); +} // namespace Bun diff --git a/src/bun.js/bindings/napi_external.h b/src/bun.js/bindings/napi_external.h index a9e38676dc..99a50648dc 100644 --- a/src/bun.js/bindings/napi_external.h +++ b/src/bun.js/bindings/napi_external.h @@ -100,4 +100,4 @@ public: #endif }; -} // namespace Zig \ No newline at end of file +} // namespace Zig diff --git a/src/bun.js/bindings/wtf-bindings.h b/src/bun.js/bindings/wtf-bindings.h index 6b96ac070d..d7298c77a5 100644 --- a/src/bun.js/bindings/wtf-bindings.h +++ b/src/bun.js/bindings/wtf-bindings.h @@ -12,4 +12,4 @@ class VM; namespace Bun { String base64URLEncodeToString(Vector data); size_t toISOString(JSC::VM& vm, double date, char buffer[64]); -} \ No newline at end of file +} diff --git a/src/bun.js/modules/AbortControllerModuleModule.h b/src/bun.js/modules/AbortControllerModuleModule.h index 31cd3d23de..d3f198e089 100644 --- a/src/bun.js/modules/AbortControllerModuleModule.h +++ b/src/bun.js/modules/AbortControllerModuleModule.h @@ -9,46 +9,44 @@ using namespace WebCore; namespace Zig { inline void generateNativeModule_AbortControllerModule( - JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, - Vector &exportNames, - JSC::MarkedArgumentBuffer &exportValues) { + JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues) +{ - Zig::GlobalObject *globalObject = - reinterpret_cast(lexicalGlobalObject); - JSC::VM &vm = globalObject->vm(); + Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + JSC::VM& vm = globalObject->vm(); - auto *abortController = - WebCore::JSAbortController::getConstructor(vm, globalObject).getObject(); - JSValue abortSignal = - WebCore::JSAbortSignal::getConstructor(vm, globalObject); + auto* abortController = WebCore::JSAbortController::getConstructor(vm, globalObject).getObject(); + JSValue abortSignal = WebCore::JSAbortSignal::getConstructor(vm, globalObject); - const auto controllerIdent = Identifier::fromString(vm, "AbortController"_s); - const auto signalIdent = Identifier::fromString(vm, "AbortSignal"_s); - const Identifier esModuleMarker = builtinNames(vm).__esModulePublicName(); + const auto controllerIdent = Identifier::fromString(vm, "AbortController"_s); + const auto signalIdent = Identifier::fromString(vm, "AbortSignal"_s); + const Identifier esModuleMarker = builtinNames(vm).__esModulePublicName(); - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(abortController); + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(abortController); - exportNames.append(signalIdent); - exportValues.append(abortSignal); + exportNames.append(signalIdent); + exportValues.append(abortSignal); - exportNames.append(controllerIdent); - exportValues.append(abortController); + exportNames.append(controllerIdent); + exportValues.append(abortController); - exportNames.append(esModuleMarker); - exportValues.append(jsBoolean(true)); + exportNames.append(esModuleMarker); + exportValues.append(jsBoolean(true)); - // https://github.com/mysticatea/abort-controller/blob/a935d38e09eb95d6b633a8c42fcceec9969e7b05/dist/abort-controller.js#L125 - abortController->putDirect( - vm, signalIdent, abortSignal, - static_cast(PropertyAttribute::DontDelete)); + // https://github.com/mysticatea/abort-controller/blob/a935d38e09eb95d6b633a8c42fcceec9969e7b05/dist/abort-controller.js#L125 + abortController->putDirect( + vm, signalIdent, abortSignal, + static_cast(PropertyAttribute::DontDelete)); - abortController->putDirect( - vm, controllerIdent, abortController, - static_cast(PropertyAttribute::DontDelete)); + abortController->putDirect( + vm, controllerIdent, abortController, + static_cast(PropertyAttribute::DontDelete)); - abortController->putDirect( - vm, vm.propertyNames->defaultKeyword, abortController, - static_cast(PropertyAttribute::DontDelete)); + abortController->putDirect( + vm, vm.propertyNames->defaultKeyword, abortController, + static_cast(PropertyAttribute::DontDelete)); } } // namespace Zig diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index 592cb33826..353e09fac9 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -60,827 +60,833 @@ using namespace WebCore; JSC_DECLARE_HOST_FUNCTION(functionStartRemoteDebugger); JSC_DEFINE_HOST_FUNCTION(functionStartRemoteDebugger, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ #if ENABLE(REMOTE_INSPECTOR) - static const char *defaultHost = "127.0.0.1\0"; - static uint16_t defaultPort = 9230; // node + 1 + static const char* defaultHost = "127.0.0.1\0"; + static uint16_t defaultPort = 9230; // node + 1 - auto &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - JSC::JSValue hostValue = callFrame->argument(0); - JSC::JSValue portValue = callFrame->argument(1); - const char *host = defaultHost; - if (hostValue.isString()) { + JSC::JSValue hostValue = callFrame->argument(0); + JSC::JSValue portValue = callFrame->argument(1); + const char* host = defaultHost; + if (hostValue.isString()) { - auto str = hostValue.toWTFString(globalObject); - if (!str.isEmpty()) - host = toCString(str).data(); - } else if (!hostValue.isUndefined()) { - throwVMError(globalObject, scope, - createTypeError(globalObject, "host must be a string"_s)); - return JSC::JSValue::encode(JSC::jsUndefined()); - } - - uint16_t port = defaultPort; - if (portValue.isNumber()) { - auto port_int = portValue.toUInt32(globalObject); - if (!(port_int > 0 && port_int < 65536)) { - throwVMError( - globalObject, scope, - createRangeError(globalObject, "port must be between 0 and 65535"_s)); - return JSC::JSValue::encode(JSC::jsUndefined()); + auto str = hostValue.toWTFString(globalObject); + if (!str.isEmpty()) + host = toCString(str).data(); + } else if (!hostValue.isUndefined()) { + throwVMError(globalObject, scope, + createTypeError(globalObject, "host must be a string"_s)); + return JSC::JSValue::encode(JSC::jsUndefined()); } - port = port_int; - } else if (!portValue.isUndefined()) { - throwVMError( - globalObject, scope, - createTypeError(globalObject, - "port must be a number between 0 and 65535"_s)); - return JSC::JSValue::encode(JSC::jsUndefined()); - } - globalObject->setInspectable(true); - auto &server = Inspector::RemoteInspectorServer::singleton(); - if (!server.start(reinterpret_cast(host), port)) { - throwVMError( - globalObject, scope, - createError(globalObject, - makeString("Failed to start server \""_s, - reinterpret_cast(host), - ":"_s, port, "\". Is port already in use?"_s))); - return JSC::JSValue::encode(JSC::jsUndefined()); - } + uint16_t port = defaultPort; + if (portValue.isNumber()) { + auto port_int = portValue.toUInt32(globalObject); + if (!(port_int > 0 && port_int < 65536)) { + throwVMError( + globalObject, scope, + createRangeError(globalObject, "port must be between 0 and 65535"_s)); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + port = port_int; + } else if (!portValue.isUndefined()) { + throwVMError( + globalObject, scope, + createTypeError(globalObject, + "port must be a number between 0 and 65535"_s)); + return JSC::JSValue::encode(JSC::jsUndefined()); + } - RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::jsUndefined())); + globalObject->setInspectable(true); + auto& server = Inspector::RemoteInspectorServer::singleton(); + if (!server.start(reinterpret_cast(host), port)) { + throwVMError( + globalObject, scope, + createError(globalObject, + makeString("Failed to start server \""_s, + reinterpret_cast(host), + ":"_s, port, "\". Is port already in use?"_s))); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::jsUndefined())); #else - auto &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - throwVMError(globalObject, scope, - createTypeError( - globalObject, - "Remote inspector is not enabled in this build of Bun"_s)); - return JSC::JSValue::encode(JSC::jsUndefined()); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + throwVMError(globalObject, scope, + createTypeError( + globalObject, + "Remote inspector is not enabled in this build of Bun"_s)); + return JSC::JSValue::encode(JSC::jsUndefined()); #endif } JSC_DECLARE_HOST_FUNCTION(functionDescribe); -JSC_DEFINE_HOST_FUNCTION(functionDescribe, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - if (callFrame->argumentCount() < 1) - return JSValue::encode(jsUndefined()); - return JSValue::encode(jsString(vm, toString(callFrame->argument(0)))); +JSC_DEFINE_HOST_FUNCTION(functionDescribe, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + if (callFrame->argumentCount() < 1) + return JSValue::encode(jsUndefined()); + return JSValue::encode(jsString(vm, toString(callFrame->argument(0)))); } JSC_DECLARE_HOST_FUNCTION(functionDescribeArray); -JSC_DEFINE_HOST_FUNCTION(functionDescribeArray, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - if (callFrame->argumentCount() < 1) - return JSValue::encode(jsUndefined()); - VM &vm = globalObject->vm(); - JSObject *object = jsDynamicCast(callFrame->argument(0)); - if (!object) - return JSValue::encode(jsNontrivialString(vm, ""_s)); - return JSValue::encode(jsNontrivialString( - vm, toString("butterfly()), - "; public length: ", object->getArrayLength(), - "; vector length: ", object->getVectorLength(), ">"))); +JSC_DEFINE_HOST_FUNCTION(functionDescribeArray, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + if (callFrame->argumentCount() < 1) + return JSValue::encode(jsUndefined()); + VM& vm = globalObject->vm(); + JSObject* object = jsDynamicCast(callFrame->argument(0)); + if (!object) + return JSValue::encode(jsNontrivialString(vm, ""_s)); + return JSValue::encode(jsNontrivialString( + vm, toString("butterfly()), "; public length: ", object->getArrayLength(), "; vector length: ", object->getVectorLength(), ">"))); } JSC_DECLARE_HOST_FUNCTION(functionGCAndSweep); JSC_DEFINE_HOST_FUNCTION(functionGCAndSweep, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - JSLockHolder lock(vm); - vm.heap.collectNow(Sync, CollectionScope::Full); - return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection())); + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + JSLockHolder lock(vm); + vm.heap.collectNow(Sync, CollectionScope::Full); + return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection())); } JSC_DECLARE_HOST_FUNCTION(functionFullGC); JSC_DEFINE_HOST_FUNCTION(functionFullGC, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - JSLockHolder lock(vm); - vm.heap.collectSync(CollectionScope::Full); - return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection())); + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + JSLockHolder lock(vm); + vm.heap.collectSync(CollectionScope::Full); + return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection())); } JSC_DECLARE_HOST_FUNCTION(functionEdenGC); JSC_DEFINE_HOST_FUNCTION(functionEdenGC, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - JSLockHolder lock(vm); - vm.heap.collectSync(CollectionScope::Eden); - return JSValue::encode(jsNumber(vm.heap.sizeAfterLastEdenCollection())); + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + JSLockHolder lock(vm); + vm.heap.collectSync(CollectionScope::Eden); + return JSValue::encode(jsNumber(vm.heap.sizeAfterLastEdenCollection())); } JSC_DECLARE_HOST_FUNCTION(functionHeapSize); JSC_DEFINE_HOST_FUNCTION(functionHeapSize, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - JSLockHolder lock(vm); - return JSValue::encode(jsNumber(vm.heap.size())); + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + JSLockHolder lock(vm); + return JSValue::encode(jsNumber(vm.heap.size())); } -JSC::Structure * -createMemoryFootprintStructure(JSC::VM &vm, JSC::JSGlobalObject *globalObject) { +JSC::Structure* +createMemoryFootprintStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ - JSC::Structure *structure = - globalObject->structureCache().emptyObjectStructureForPrototype( - globalObject, globalObject->objectPrototype(), 5); - JSC::PropertyOffset offset; + JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype( + globalObject, globalObject->objectPrototype(), 5); + JSC::PropertyOffset offset; - structure = structure->addPropertyTransition( - vm, structure, Identifier::fromString(vm, "current"_s), 0, offset); - structure = structure->addPropertyTransition( - vm, structure, Identifier::fromString(vm, "peak"_s), 0, offset); - structure = structure->addPropertyTransition( - vm, structure, Identifier::fromString(vm, "currentCommit"_s), 0, offset); - structure = structure->addPropertyTransition( - vm, structure, Identifier::fromString(vm, "peakCommit"_s), 0, offset); - structure = structure->addPropertyTransition( - vm, structure, Identifier::fromString(vm, "pageFaults"_s), 0, offset); + structure = structure->addPropertyTransition( + vm, structure, Identifier::fromString(vm, "current"_s), 0, offset); + structure = structure->addPropertyTransition( + vm, structure, Identifier::fromString(vm, "peak"_s), 0, offset); + structure = structure->addPropertyTransition( + vm, structure, Identifier::fromString(vm, "currentCommit"_s), 0, offset); + structure = structure->addPropertyTransition( + vm, structure, Identifier::fromString(vm, "peakCommit"_s), 0, offset); + structure = structure->addPropertyTransition( + vm, structure, Identifier::fromString(vm, "pageFaults"_s), 0, offset); - return structure; + return structure; } JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics); JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, - (JSGlobalObject * globalObject, CallFrame *)) { + (JSGlobalObject * globalObject, CallFrame*)) +{ - auto &vm = globalObject->vm(); + auto& vm = globalObject->vm(); - if (vm.heap.size() == 0) { - vm.heap.collectNow(Sync, CollectionScope::Full); - JSC::DisallowGC disallowGC; - } - - const auto createdSortedTypeCounts = - [&](JSC::TypeCountSet *typeCounts) -> JSC::JSValue { - WTF::Vector> counts; - counts.reserveInitialCapacity(typeCounts->size()); - for (auto &it : *typeCounts) { - if (it.value > 0) - counts.append( - std::make_pair(Identifier::fromLatin1(vm, it.key), it.value)); + if (vm.heap.size() == 0) { + vm.heap.collectNow(Sync, CollectionScope::Full); + JSC::DisallowGC disallowGC; } - // Sort by count first, then by name. - std::sort(counts.begin(), counts.end(), - [](const std::pair &a, - const std::pair &b) { - if (a.second == b.second) { - WTF::StringView left = a.first.string(); - WTF::StringView right = b.first.string(); - unsigned originalLeftLength = left.length(); - unsigned originalRightLength = right.length(); - unsigned size = std::min(left.length(), right.length()); - left = left.substring(0, size); - right = right.substring(0, size); - int result = WTF::codePointCompare(right, left); - if (result == 0) { - return originalLeftLength > originalRightLength; - } + const auto createdSortedTypeCounts = + [&](JSC::TypeCountSet* typeCounts) -> JSC::JSValue { + WTF::Vector> counts; + counts.reserveInitialCapacity(typeCounts->size()); + for (auto& it : *typeCounts) { + if (it.value > 0) + counts.append( + std::make_pair(Identifier::fromLatin1(vm, it.key), it.value)); + } - return result > 0; + // Sort by count first, then by name. + std::sort(counts.begin(), counts.end(), + [](const std::pair& a, + const std::pair& b) { + if (a.second == b.second) { + WTF::StringView left = a.first.string(); + WTF::StringView right = b.first.string(); + unsigned originalLeftLength = left.length(); + unsigned originalRightLength = right.length(); + unsigned size = std::min(left.length(), right.length()); + left = left.substring(0, size); + right = right.substring(0, size); + int result = WTF::codePointCompare(right, left); + if (result == 0) { + return originalLeftLength > originalRightLength; + } + + return result > 0; } return a.second > b.second; - }); + }); - auto *objectTypeCounts = constructEmptyObject(globalObject); - for (auto &it : counts) { - objectTypeCounts->putDirect(vm, it.first, jsNumber(it.second)); - } - return objectTypeCounts; - }; + auto* objectTypeCounts = constructEmptyObject(globalObject); + for (auto& it : counts) { + objectTypeCounts->putDirect(vm, it.first, jsNumber(it.second)); + } + return objectTypeCounts; + }; - JSValue objectTypeCounts = - createdSortedTypeCounts(vm.heap.objectTypeCounts().get()); - JSValue protectedCounts = - createdSortedTypeCounts(vm.heap.protectedObjectTypeCounts().get()); + JSValue objectTypeCounts = createdSortedTypeCounts(vm.heap.objectTypeCounts().get()); + JSValue protectedCounts = createdSortedTypeCounts(vm.heap.protectedObjectTypeCounts().get()); - JSObject *object = constructEmptyObject(globalObject); - object->putDirect(vm, Identifier::fromString(vm, "objectTypeCounts"_s), - objectTypeCounts); + JSObject* object = constructEmptyObject(globalObject); + object->putDirect(vm, Identifier::fromString(vm, "objectTypeCounts"_s), + objectTypeCounts); - object->putDirect(vm, - Identifier::fromLatin1(vm, "protectedObjectTypeCounts"_s), - protectedCounts); - object->putDirect(vm, Identifier::fromString(vm, "heapSize"_s), - jsNumber(vm.heap.size())); - object->putDirect(vm, Identifier::fromString(vm, "heapCapacity"_s), - jsNumber(vm.heap.capacity())); - object->putDirect(vm, Identifier::fromString(vm, "extraMemorySize"_s), - jsNumber(vm.heap.extraMemorySize())); - object->putDirect(vm, Identifier::fromString(vm, "objectCount"_s), - jsNumber(vm.heap.objectCount())); - object->putDirect(vm, Identifier::fromString(vm, "protectedObjectCount"_s), - jsNumber(vm.heap.protectedObjectCount())); - object->putDirect(vm, Identifier::fromString(vm, "globalObjectCount"_s), - jsNumber(vm.heap.globalObjectCount())); - object->putDirect(vm, - Identifier::fromString(vm, "protectedGlobalObjectCount"_s), - jsNumber(vm.heap.protectedGlobalObjectCount())); + object->putDirect(vm, + Identifier::fromLatin1(vm, "protectedObjectTypeCounts"_s), + protectedCounts); + object->putDirect(vm, Identifier::fromString(vm, "heapSize"_s), + jsNumber(vm.heap.size())); + object->putDirect(vm, Identifier::fromString(vm, "heapCapacity"_s), + jsNumber(vm.heap.capacity())); + object->putDirect(vm, Identifier::fromString(vm, "extraMemorySize"_s), + jsNumber(vm.heap.extraMemorySize())); + object->putDirect(vm, Identifier::fromString(vm, "objectCount"_s), + jsNumber(vm.heap.objectCount())); + object->putDirect(vm, Identifier::fromString(vm, "protectedObjectCount"_s), + jsNumber(vm.heap.protectedObjectCount())); + object->putDirect(vm, Identifier::fromString(vm, "globalObjectCount"_s), + jsNumber(vm.heap.globalObjectCount())); + object->putDirect(vm, + Identifier::fromString(vm, "protectedGlobalObjectCount"_s), + jsNumber(vm.heap.protectedGlobalObjectCount())); #if IS_MALLOC_DEBUGGING_ENABLED #if OS(DARWIN) - { - vm_address_t *zones; - unsigned count; + { + vm_address_t* zones; + unsigned count; - // Zero out the structures in case a zone is missing - malloc_statistics_t zone_stats; - zone_stats.blocks_in_use = 0; - zone_stats.size_in_use = 0; - zone_stats.max_size_in_use = 0; - zone_stats.size_allocated = 0; + // Zero out the structures in case a zone is missing + malloc_statistics_t zone_stats; + zone_stats.blocks_in_use = 0; + zone_stats.size_in_use = 0; + zone_stats.max_size_in_use = 0; + zone_stats.size_allocated = 0; - malloc_zone_pressure_relief(nullptr, 0); - malloc_get_all_zones(mach_task_self(), 0, &zones, &count); - Vector> zoneSizes; - zoneSizes.reserveInitialCapacity(count); - for (unsigned i = 0; i < count; i++) { - auto zone = reinterpret_cast(zones[i]); - if (const char *name = malloc_get_zone_name(zone)) { - malloc_zone_statistics(reinterpret_cast(zones[i]), - &zone_stats); - zoneSizes.append( - std::make_pair(Identifier::fromString(vm, String::fromUTF8(name)), - zone_stats.size_in_use)); - } - } + malloc_zone_pressure_relief(nullptr, 0); + malloc_get_all_zones(mach_task_self(), 0, &zones, &count); + Vector> zoneSizes; + zoneSizes.reserveInitialCapacity(count); + for (unsigned i = 0; i < count; i++) { + auto zone = reinterpret_cast(zones[i]); + if (const char* name = malloc_get_zone_name(zone)) { + malloc_zone_statistics(reinterpret_cast(zones[i]), + &zone_stats); + zoneSizes.append( + std::make_pair(Identifier::fromString(vm, String::fromUTF8(name)), + zone_stats.size_in_use)); + } + } - std::sort(zoneSizes.begin(), zoneSizes.end(), - [](const std::pair &a, - const std::pair &b) { + std::sort(zoneSizes.begin(), zoneSizes.end(), + [](const std::pair& a, + const std::pair& b) { // Sort by name if the sizes are the same. if (a.second == b.second) { - WTF::StringView left = a.first.string(); - WTF::StringView right = b.first.string(); - unsigned originalLeftLength = left.length(); - unsigned originalRightLength = right.length(); - unsigned size = std::min(left.length(), right.length()); - left = left.substring(0, size); - right = right.substring(0, size); - int result = WTF::codePointCompare(right, left); - if (result == 0) { - return originalLeftLength > originalRightLength; - } + WTF::StringView left = a.first.string(); + WTF::StringView right = b.first.string(); + unsigned originalLeftLength = left.length(); + unsigned originalRightLength = right.length(); + unsigned size = std::min(left.length(), right.length()); + left = left.substring(0, size); + right = right.substring(0, size); + int result = WTF::codePointCompare(right, left); + if (result == 0) { + return originalLeftLength > originalRightLength; + } - return result > 0; + return result > 0; } return a.second > b.second; - }); + }); - auto *zoneSizesObject = constructEmptyObject(globalObject); - for (auto &it : zoneSizes) { - zoneSizesObject->putDirect(vm, it.first, jsDoubleNumber(it.second)); + auto* zoneSizesObject = constructEmptyObject(globalObject); + for (auto& it : zoneSizes) { + zoneSizesObject->putDirect(vm, it.first, jsDoubleNumber(it.second)); + } + + object->putDirect(vm, Identifier::fromString(vm, "zones"_s), + zoneSizesObject); } - - object->putDirect(vm, Identifier::fromString(vm, "zones"_s), - zoneSizesObject); - } #endif #endif - return JSValue::encode(object); + return JSValue::encode(object); } JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint); JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, - (JSGlobalObject * globalObject, CallFrame *)) { + (JSGlobalObject * globalObject, CallFrame*)) +{ - size_t elapsed_msecs = 0; - size_t user_msecs = 0; - size_t system_msecs = 0; - size_t current_rss = 0; - size_t peak_rss = 0; - size_t current_commit = 0; - size_t peak_commit = 0; - size_t page_faults = 0; + size_t elapsed_msecs = 0; + size_t user_msecs = 0; + size_t system_msecs = 0; + size_t current_rss = 0; + size_t peak_rss = 0; + size_t current_commit = 0; + size_t peak_commit = 0; + size_t page_faults = 0; - mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs, ¤t_rss, - &peak_rss, ¤t_commit, &peak_commit, &page_faults); + mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs, ¤t_rss, + &peak_rss, ¤t_commit, &peak_commit, &page_faults); - // mi_process_info produces incorrect rss size on linux. - Bun::getRSS(¤t_rss); + // mi_process_info produces incorrect rss size on linux. + Bun::getRSS(¤t_rss); - VM &vm = globalObject->vm(); - JSC::JSObject *object = JSC::constructEmptyObject( - vm, JSC::jsCast(globalObject) - ->memoryFootprintStructure()); + VM& vm = globalObject->vm(); + JSC::JSObject* object = JSC::constructEmptyObject( + vm, JSC::jsCast(globalObject)->memoryFootprintStructure()); - object->putDirectOffset(vm, 0, jsNumber(current_rss)); - object->putDirectOffset(vm, 1, jsNumber(peak_rss)); - object->putDirectOffset(vm, 2, jsNumber(current_commit)); - object->putDirectOffset(vm, 3, jsNumber(peak_commit)); - object->putDirectOffset(vm, 4, jsNumber(page_faults)); + object->putDirectOffset(vm, 0, jsNumber(current_rss)); + object->putDirectOffset(vm, 1, jsNumber(peak_rss)); + object->putDirectOffset(vm, 2, jsNumber(current_commit)); + object->putDirectOffset(vm, 3, jsNumber(peak_commit)); + object->putDirectOffset(vm, 4, jsNumber(page_faults)); - return JSValue::encode(object); + return JSValue::encode(object); } JSC_DECLARE_HOST_FUNCTION(functionNeverInlineFunction); JSC_DEFINE_HOST_FUNCTION(functionNeverInlineFunction, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - return JSValue::encode(setNeverInline(globalObject, callFrame)); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + return JSValue::encode(setNeverInline(globalObject, callFrame)); } -extern "C" bool Bun__mkdirp(JSC::JSGlobalObject *, const char *); +extern "C" bool Bun__mkdirp(JSC::JSGlobalObject*, const char*); JSC_DECLARE_HOST_FUNCTION(functionStartSamplingProfiler); JSC_DEFINE_HOST_FUNCTION(functionStartSamplingProfiler, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callFrame)) { - JSC::VM &vm = globalObject->vm(); - JSC::SamplingProfiler &samplingProfiler = - vm.ensureSamplingProfiler(WTF::Stopwatch::create()); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + JSC::SamplingProfiler& samplingProfiler = vm.ensureSamplingProfiler(WTF::Stopwatch::create()); - JSC::JSValue directoryValue = callFrame->argument(0); - JSC::JSValue sampleValue = callFrame->argument(1); + JSC::JSValue directoryValue = callFrame->argument(0); + JSC::JSValue sampleValue = callFrame->argument(1); - auto scope = DECLARE_THROW_SCOPE(vm); - if (directoryValue.isString()) { - auto path = directoryValue.toWTFString(globalObject); - if (!path.isEmpty()) { - StringPrintStream pathOut; - auto pathCString = toCString(String(path)); - if (!Bun__mkdirp(globalObject, pathCString.data())) { - throwVMError( - globalObject, scope, - createTypeError(globalObject, "directory couldn't be created"_s)); - return {}; - } + auto scope = DECLARE_THROW_SCOPE(vm); + if (directoryValue.isString()) { + auto path = directoryValue.toWTFString(globalObject); + if (!path.isEmpty()) { + StringPrintStream pathOut; + auto pathCString = toCString(String(path)); + if (!Bun__mkdirp(globalObject, pathCString.data())) { + throwVMError( + globalObject, scope, + createTypeError(globalObject, "directory couldn't be created"_s)); + return {}; + } - Options::samplingProfilerPath() = pathCString.data(); - samplingProfiler.registerForReportAtExit(); + Options::samplingProfilerPath() = pathCString.data(); + samplingProfiler.registerForReportAtExit(); + } + } + if (sampleValue.isNumber()) { + unsigned sampleInterval = sampleValue.toUInt32(globalObject); + samplingProfiler.setTimingInterval( + Seconds::fromMicroseconds(sampleInterval)); } - } - if (sampleValue.isNumber()) { - unsigned sampleInterval = sampleValue.toUInt32(globalObject); - samplingProfiler.setTimingInterval( - Seconds::fromMicroseconds(sampleInterval)); - } - samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(); - samplingProfiler.start(); - return JSC::JSValue::encode(jsUndefined()); + samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(); + samplingProfiler.start(); + return JSC::JSValue::encode(jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(functionSamplingProfilerStackTraces); JSC_DEFINE_HOST_FUNCTION(functionSamplingProfilerStackTraces, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *)) { - JSC::VM &vm = globalObject->vm(); - JSC::DeferTermination deferScope(vm); - auto scope = DECLARE_THROW_SCOPE(vm); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame*)) +{ + JSC::VM& vm = globalObject->vm(); + JSC::DeferTermination deferScope(vm); + auto scope = DECLARE_THROW_SCOPE(vm); - if (!vm.samplingProfiler()) - return JSC::JSValue::encode(throwException( - globalObject, scope, - createError(globalObject, "Sampling profiler was never started"_s))); + if (!vm.samplingProfiler()) + return JSC::JSValue::encode(throwException( + globalObject, scope, + createError(globalObject, "Sampling profiler was never started"_s))); - WTF::String jsonString = - vm.samplingProfiler()->stackTracesAsJSON()->toJSONString(); - JSC::EncodedJSValue result = - JSC::JSValue::encode(JSONParse(globalObject, jsonString)); - scope.releaseAssertNoException(); - return result; + WTF::String jsonString = vm.samplingProfiler()->stackTracesAsJSON()->toJSONString(); + JSC::EncodedJSValue result = JSC::JSValue::encode(JSONParse(globalObject, jsonString)); + scope.releaseAssertNoException(); + return result; } JSC_DECLARE_HOST_FUNCTION(functionGetRandomSeed); JSC_DEFINE_HOST_FUNCTION(functionGetRandomSeed, - (JSGlobalObject * globalObject, CallFrame *)) { - return JSValue::encode(jsNumber(globalObject->weakRandom().seed())); + (JSGlobalObject * globalObject, CallFrame*)) +{ + return JSValue::encode(jsNumber(globalObject->weakRandom().seed())); } JSC_DECLARE_HOST_FUNCTION(functionSetRandomSeed); -JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); +JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - unsigned seed = callFrame->argument(0).toUInt32(globalObject); - RETURN_IF_EXCEPTION(scope, {}); - globalObject->weakRandom().setSeed(seed); - return JSValue::encode(jsUndefined()); + unsigned seed = callFrame->argument(0).toUInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + globalObject->weakRandom().setSeed(seed); + return JSValue::encode(jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(functionIsRope); JSC_DEFINE_HOST_FUNCTION(functionIsRope, - (JSGlobalObject *, CallFrame *callFrame)) { - JSValue argument = callFrame->argument(0); - if (!argument.isString()) - return JSValue::encode(jsBoolean(false)); - const StringImpl *impl = asString(argument)->tryGetValueImpl(); - return JSValue::encode(jsBoolean(!impl)); + (JSGlobalObject*, CallFrame* callFrame)) +{ + JSValue argument = callFrame->argument(0); + if (!argument.isString()) + return JSValue::encode(jsBoolean(false)); + const StringImpl* impl = asString(argument)->tryGetValueImpl(); + return JSValue::encode(jsBoolean(!impl)); } JSC_DECLARE_HOST_FUNCTION(functionCallerSourceOrigin); JSC_DEFINE_HOST_FUNCTION(functionCallerSourceOrigin, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - if (sourceOrigin.url().isNull()) - return JSValue::encode(jsNull()); - return JSValue::encode(jsString(vm, sourceOrigin.string())); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + if (sourceOrigin.url().isNull()) + return JSValue::encode(jsNull()); + return JSValue::encode(jsString(vm, sourceOrigin.string())); } JSC_DECLARE_HOST_FUNCTION(functionNoFTL); JSC_DEFINE_HOST_FUNCTION(functionNoFTL, - (JSGlobalObject *, CallFrame *callFrame)) { - if (callFrame->argumentCount()) { - FunctionExecutable *executable = - getExecutableForFunction(callFrame->argument(0)); - if (executable) - executable->setNeverFTLOptimize(true); - } - return JSValue::encode(jsUndefined()); + (JSGlobalObject*, CallFrame* callFrame)) +{ + if (callFrame->argumentCount()) { + FunctionExecutable* executable = getExecutableForFunction(callFrame->argument(0)); + if (executable) + executable->setNeverFTLOptimize(true); + } + return JSValue::encode(jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(functionNoOSRExitFuzzing); JSC_DEFINE_HOST_FUNCTION(functionNoOSRExitFuzzing, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - return JSValue::encode(setCannotUseOSRExitFuzzing(globalObject, callFrame)); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + return JSValue::encode(setCannotUseOSRExitFuzzing(globalObject, callFrame)); } JSC_DECLARE_HOST_FUNCTION(functionOptimizeNextInvocation); JSC_DEFINE_HOST_FUNCTION(functionOptimizeNextInvocation, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - return JSValue::encode(optimizeNextInvocation(globalObject, callFrame)); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + return JSValue::encode(optimizeNextInvocation(globalObject, callFrame)); } JSC_DECLARE_HOST_FUNCTION(functionNumberOfDFGCompiles); JSC_DEFINE_HOST_FUNCTION(functionNumberOfDFGCompiles, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - return JSValue::encode(numberOfDFGCompiles(globalObject, callFrame)); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + return JSValue::encode(numberOfDFGCompiles(globalObject, callFrame)); } JSC_DECLARE_HOST_FUNCTION(functionReleaseWeakRefs); JSC_DEFINE_HOST_FUNCTION(functionReleaseWeakRefs, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - globalObject->vm().finalizeSynchronousJSExecution(); - return JSValue::encode(jsUndefined()); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + globalObject->vm().finalizeSynchronousJSExecution(); + return JSValue::encode(jsUndefined()); } JSC_DECLARE_HOST_FUNCTION(functionTotalCompileTime); JSC_DEFINE_HOST_FUNCTION(functionTotalCompileTime, - (JSGlobalObject *, CallFrame *)) { - return JSValue::encode(jsNumber(JIT::totalCompileTime().milliseconds())); + (JSGlobalObject*, CallFrame*)) +{ + return JSValue::encode(jsNumber(JIT::totalCompileTime().milliseconds())); } JSC_DECLARE_HOST_FUNCTION(functionGetProtectedObjects); JSC_DEFINE_HOST_FUNCTION(functionGetProtectedObjects, - (JSGlobalObject * globalObject, CallFrame *)) { - MarkedArgumentBuffer list; - globalObject->vm().heap.forEachProtectedCell( - [&](JSCell *cell) { list.append(cell); }); - RELEASE_ASSERT(!list.hasOverflowed()); - return JSC::JSValue::encode(constructArray( - globalObject, static_cast(nullptr), list)); + (JSGlobalObject * globalObject, CallFrame*)) +{ + MarkedArgumentBuffer list; + globalObject->vm().heap.forEachProtectedCell( + [&](JSCell* cell) { list.append(cell); }); + RELEASE_ASSERT(!list.hasOverflowed()); + return JSC::JSValue::encode(constructArray( + globalObject, static_cast(nullptr), list)); } JSC_DECLARE_HOST_FUNCTION(functionReoptimizationRetryCount); JSC_DEFINE_HOST_FUNCTION(functionReoptimizationRetryCount, - (JSGlobalObject *, CallFrame *callFrame)) { - if (callFrame->argumentCount() < 1) - return JSValue::encode(jsUndefined()); + (JSGlobalObject*, CallFrame* callFrame)) +{ + if (callFrame->argumentCount() < 1) + return JSValue::encode(jsUndefined()); - CodeBlock *block = - getSomeBaselineCodeBlockForFunction(callFrame->argument(0)); - if (!block) - return JSValue::encode(jsNumber(0)); + CodeBlock* block = getSomeBaselineCodeBlockForFunction(callFrame->argument(0)); + if (!block) + return JSValue::encode(jsNumber(0)); - return JSValue::encode(jsNumber(block->reoptimizationRetryCounter())); + return JSValue::encode(jsNumber(block->reoptimizationRetryCounter())); } extern "C" void Bun__drainMicrotasks(); JSC_DECLARE_HOST_FUNCTION(functionDrainMicrotasks); JSC_DEFINE_HOST_FUNCTION(functionDrainMicrotasks, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - vm.drainMicrotasks(); - Bun__drainMicrotasks(); - return JSValue::encode(jsUndefined()); + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + vm.drainMicrotasks(); + Bun__drainMicrotasks(); + return JSValue::encode(jsUndefined()); } -JSC_DEFINE_HOST_FUNCTION(functionSetTimeZone, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); +JSC_DEFINE_HOST_FUNCTION(functionSetTimeZone, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - if (callFrame->argumentCount() < 1) { - throwTypeError(globalObject, scope, - "setTimeZone requires a timezone string"_s); - return {}; - } - - if (!callFrame->argument(0).isString()) { - throwTypeError(globalObject, scope, - "setTimeZone requires a timezone string"_s); - return {}; - } - - String timeZoneName = callFrame->argument(0).toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, {}); - - if (!WTF::setTimeZoneOverride(timeZoneName)) { - throwTypeError(globalObject, scope, - makeString("Invalid timezone: \""_s, timeZoneName, "\""_s)); - return {}; - } - vm.dateCache.resetIfNecessarySlow(); - WTF::Vector buffer; - WTF::getTimeZoneOverride(buffer); - WTF::String timeZoneString({buffer.data(), buffer.size()}); - return JSValue::encode(jsString(vm, timeZoneString)); -} - -JSC_DEFINE_HOST_FUNCTION(functionRunProfiler, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - JSC::VM &vm = globalObject->vm(); - JSC::SamplingProfiler &samplingProfiler = - vm.ensureSamplingProfiler(WTF::Stopwatch::create()); - - JSC::JSValue callbackValue = callFrame->argument(0); - JSC::JSValue sampleValue = callFrame->argument(1); - - MarkedArgumentBuffer args; - - if (callFrame->argumentCount() > 2) { - size_t count = callFrame->argumentCount(); - args.ensureCapacity(count - 2); - for (size_t i = 2; i < count; i++) { - args.append(callFrame->argument(i)); + if (callFrame->argumentCount() < 1) { + throwTypeError(globalObject, scope, + "setTimeZone requires a timezone string"_s); + return {}; } - } - auto throwScope = DECLARE_THROW_SCOPE(vm); - if (callbackValue.isUndefinedOrNull() || !callbackValue.isCallable()) { - throwException( - globalObject, throwScope, - createTypeError(globalObject, "First argument must be a function."_s)); - return JSValue::encode(JSValue{}); - } + if (!callFrame->argument(0).isString()) { + throwTypeError(globalObject, scope, + "setTimeZone requires a timezone string"_s); + return {}; + } - JSC::JSFunction *function = jsCast(callbackValue); + String timeZoneName = callFrame->argument(0).toWTFString(globalObject); + RETURN_IF_EXCEPTION(scope, {}); - if (sampleValue.isNumber()) { - unsigned sampleInterval = sampleValue.toUInt32(globalObject); - samplingProfiler.setTimingInterval( - Seconds::fromMicroseconds(sampleInterval)); - } + if (!WTF::setTimeZoneOverride(timeZoneName)) { + throwTypeError(globalObject, scope, + makeString("Invalid timezone: \""_s, timeZoneName, "\""_s)); + return {}; + } + vm.dateCache.resetIfNecessarySlow(); + WTF::Vector buffer; + WTF::getTimeZoneOverride(buffer); + WTF::String timeZoneString({ buffer.data(), buffer.size() }); + return JSValue::encode(jsString(vm, timeZoneString)); +} + +JSC_DEFINE_HOST_FUNCTION(functionRunProfiler, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + JSC::SamplingProfiler& samplingProfiler = vm.ensureSamplingProfiler(WTF::Stopwatch::create()); + + JSC::JSValue callbackValue = callFrame->argument(0); + JSC::JSValue sampleValue = callFrame->argument(1); + + MarkedArgumentBuffer args; + + if (callFrame->argumentCount() > 2) { + size_t count = callFrame->argumentCount(); + args.ensureCapacity(count - 2); + for (size_t i = 2; i < count; i++) { + args.append(callFrame->argument(i)); + } + } - const auto report = [](JSC::VM &vm, - JSC::JSGlobalObject *globalObject) -> JSC::JSValue { auto throwScope = DECLARE_THROW_SCOPE(vm); - - auto &samplingProfiler = *vm.samplingProfiler(); - StringPrintStream topFunctions; - samplingProfiler.reportTopFunctions(topFunctions); - - StringPrintStream byteCodes; - samplingProfiler.reportTopBytecodes(byteCodes); - - JSValue stackTraces = JSONParse( - globalObject, samplingProfiler.stackTracesAsJSON()->toJSONString()); - - samplingProfiler.shutdown(); - RETURN_IF_EXCEPTION(throwScope, {}); - - JSObject *result = - constructEmptyObject(globalObject, globalObject->objectPrototype(), 3); - result->putDirect(vm, Identifier::fromString(vm, "functions"_s), - jsString(vm, topFunctions.toString())); - result->putDirect(vm, Identifier::fromString(vm, "bytecodes"_s), - jsString(vm, byteCodes.toString())); - result->putDirect(vm, Identifier::fromString(vm, "stackTraces"_s), - stackTraces); - - return result; - }; - const auto reportFailure = [](JSC::VM &vm) -> JSC::JSValue { - if (auto *samplingProfiler = vm.samplingProfiler()) { - samplingProfiler->pause(); - samplingProfiler->shutdown(); - samplingProfiler->clearData(); + if (callbackValue.isUndefinedOrNull() || !callbackValue.isCallable()) { + throwException( + globalObject, throwScope, + createTypeError(globalObject, "First argument must be a function."_s)); + return JSValue::encode(JSValue {}); } - return {}; - }; + JSC::JSFunction* function = jsCast(callbackValue); - JSC::CallData callData = JSC::getCallData(function); + if (sampleValue.isNumber()) { + unsigned sampleInterval = sampleValue.toUInt32(globalObject); + samplingProfiler.setTimingInterval( + Seconds::fromMicroseconds(sampleInterval)); + } - samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(); - samplingProfiler.start(); - JSValue returnValue = - JSC::call(globalObject, function, callData, JSC::jsUndefined(), args); + const auto report = [](JSC::VM& vm, + JSC::JSGlobalObject* globalObject) -> JSC::JSValue { + auto throwScope = DECLARE_THROW_SCOPE(vm); - if (returnValue.isEmpty() || throwScope.exception()) { - return JSValue::encode(reportFailure(vm)); - } + auto& samplingProfiler = *vm.samplingProfiler(); + StringPrintStream topFunctions; + samplingProfiler.reportTopFunctions(topFunctions); - if (auto *promise = jsDynamicCast(returnValue)) { - auto afterOngoingPromiseCapability = - JSC::JSPromise::create(vm, globalObject->promiseStructure()); - RETURN_IF_EXCEPTION(throwScope, {}); + StringPrintStream byteCodes; + samplingProfiler.reportTopBytecodes(byteCodes); - JSNativeStdFunction *resolve = JSNativeStdFunction::create( - vm, globalObject, 0, "resolve"_s, - [report](JSGlobalObject *globalObject, CallFrame *callFrame) { - return JSValue::encode(JSPromise::resolvedPromise( - globalObject, report(globalObject->vm(), globalObject))); - }); - JSNativeStdFunction *reject = JSNativeStdFunction::create( - vm, globalObject, 0, "reject"_s, - [reportFailure](JSGlobalObject *globalObject, CallFrame *callFrame) { - EnsureStillAliveScope error = callFrame->argument(0); - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - reportFailure(globalObject->vm()); - throwException(globalObject, scope, error.value()); - return JSValue::encode({}); - }); - promise->performPromiseThen(globalObject, resolve, reject, - afterOngoingPromiseCapability); - return JSValue::encode(afterOngoingPromiseCapability); - } + JSValue stackTraces = JSONParse( + globalObject, samplingProfiler.stackTracesAsJSON()->toJSONString()); - return JSValue::encode(report(vm, globalObject)); + samplingProfiler.shutdown(); + RETURN_IF_EXCEPTION(throwScope, {}); + + JSObject* result = constructEmptyObject(globalObject, globalObject->objectPrototype(), 3); + result->putDirect(vm, Identifier::fromString(vm, "functions"_s), + jsString(vm, topFunctions.toString())); + result->putDirect(vm, Identifier::fromString(vm, "bytecodes"_s), + jsString(vm, byteCodes.toString())); + result->putDirect(vm, Identifier::fromString(vm, "stackTraces"_s), + stackTraces); + + return result; + }; + const auto reportFailure = [](JSC::VM& vm) -> JSC::JSValue { + if (auto* samplingProfiler = vm.samplingProfiler()) { + samplingProfiler->pause(); + samplingProfiler->shutdown(); + samplingProfiler->clearData(); + } + + return {}; + }; + + JSC::CallData callData = JSC::getCallData(function); + + samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(); + samplingProfiler.start(); + JSValue returnValue = JSC::call(globalObject, function, callData, JSC::jsUndefined(), args); + + if (returnValue.isEmpty() || throwScope.exception()) { + return JSValue::encode(reportFailure(vm)); + } + + if (auto* promise = jsDynamicCast(returnValue)) { + auto afterOngoingPromiseCapability = JSC::JSPromise::create(vm, globalObject->promiseStructure()); + RETURN_IF_EXCEPTION(throwScope, {}); + + JSNativeStdFunction* resolve = JSNativeStdFunction::create( + vm, globalObject, 0, "resolve"_s, + [report](JSGlobalObject* globalObject, CallFrame* callFrame) { + return JSValue::encode(JSPromise::resolvedPromise( + globalObject, report(globalObject->vm(), globalObject))); + }); + JSNativeStdFunction* reject = JSNativeStdFunction::create( + vm, globalObject, 0, "reject"_s, + [reportFailure](JSGlobalObject* globalObject, CallFrame* callFrame) { + EnsureStillAliveScope error = callFrame->argument(0); + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + reportFailure(globalObject->vm()); + throwException(globalObject, scope, error.value()); + return JSValue::encode({}); + }); + promise->performPromiseThen(globalObject, resolve, reject, + afterOngoingPromiseCapability); + return JSValue::encode(afterOngoingPromiseCapability); + } + + return JSValue::encode(report(vm, globalObject)); } JSC_DECLARE_HOST_FUNCTION(functionGenerateHeapSnapshotForDebugging); JSC_DEFINE_HOST_FUNCTION(functionGenerateHeapSnapshotForDebugging, - (JSGlobalObject * globalObject, CallFrame *)) { - VM &vm = globalObject->vm(); - JSLockHolder lock(vm); - DeferTermination deferScope(vm); - auto scope = DECLARE_THROW_SCOPE(vm); - String jsonString; - { - DeferGCForAWhile deferGC(vm); // Prevent concurrent GC from interfering with - // the full GC that the snapshot does. + (JSGlobalObject * globalObject, CallFrame*)) +{ + VM& vm = globalObject->vm(); + JSLockHolder lock(vm); + DeferTermination deferScope(vm); + auto scope = DECLARE_THROW_SCOPE(vm); + String jsonString; + { + DeferGCForAWhile deferGC(vm); // Prevent concurrent GC from interfering with + // the full GC that the snapshot does. - HeapSnapshotBuilder snapshotBuilder( - vm.ensureHeapProfiler(), - HeapSnapshotBuilder::SnapshotType::GCDebuggingSnapshot); - snapshotBuilder.buildSnapshot(); + HeapSnapshotBuilder snapshotBuilder( + vm.ensureHeapProfiler(), + HeapSnapshotBuilder::SnapshotType::GCDebuggingSnapshot); + snapshotBuilder.buildSnapshot(); - jsonString = snapshotBuilder.json(); - } - scope.releaseAssertNoException(); + jsonString = snapshotBuilder.json(); + } + scope.releaseAssertNoException(); - return JSValue::encode(JSONParse(globalObject, WTFMove(jsonString))); + return JSValue::encode(JSONParse(globalObject, WTFMove(jsonString))); } JSC_DEFINE_HOST_FUNCTION(functionSerialize, - (JSGlobalObject * lexicalGlobalObject, - CallFrame *callFrame)) { - auto *globalObject = jsCast(lexicalGlobalObject); - JSC::VM &vm = globalObject->vm(); - auto throwScope = DECLARE_THROW_SCOPE(vm); + (JSGlobalObject * lexicalGlobalObject, + CallFrame* callFrame)) +{ + auto* globalObject = jsCast(lexicalGlobalObject); + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - JSValue value = callFrame->argument(0); - JSValue optionsObject = callFrame->argument(1); - bool asNodeBuffer = false; - if (optionsObject.isObject()) { - JSC::JSObject *options = optionsObject.getObject(); - if (JSC::JSValue binaryTypeValue = options->getIfPropertyExists( - globalObject, JSC::Identifier::fromString(vm, "binaryType"_s))) { - if (!binaryTypeValue.isString()) { - throwTypeError(globalObject, throwScope, - "binaryType must be a string"_s); - return {}; - } + JSValue value = callFrame->argument(0); + JSValue optionsObject = callFrame->argument(1); + bool asNodeBuffer = false; + if (optionsObject.isObject()) { + JSC::JSObject* options = optionsObject.getObject(); + if (JSC::JSValue binaryTypeValue = options->getIfPropertyExists( + globalObject, JSC::Identifier::fromString(vm, "binaryType"_s))) { + if (!binaryTypeValue.isString()) { + throwTypeError(globalObject, throwScope, + "binaryType must be a string"_s); + return {}; + } - asNodeBuffer = - binaryTypeValue.toWTFString(globalObject) == "nodebuffer"_s; - RETURN_IF_EXCEPTION(throwScope, {}); + asNodeBuffer = binaryTypeValue.toWTFString(globalObject) == "nodebuffer"_s; + RETURN_IF_EXCEPTION(throwScope, {}); + } } - } - Vector> transferList; - Vector> dummyPorts; - ExceptionOr> serialized = - SerializedScriptValue::create(*globalObject, value, WTFMove(transferList), - dummyPorts); + Vector> transferList; + Vector> dummyPorts; + ExceptionOr> serialized = SerializedScriptValue::create(*globalObject, value, WTFMove(transferList), + dummyPorts); - if (serialized.hasException()) { - WebCore::propagateException(*globalObject, throwScope, - serialized.releaseException()); - return JSValue::encode(jsUndefined()); - } + if (serialized.hasException()) { + WebCore::propagateException(*globalObject, throwScope, + serialized.releaseException()); + return JSValue::encode(jsUndefined()); + } - auto serializedValue = serialized.releaseReturnValue(); - auto arrayBuffer = serializedValue->toArrayBuffer(); + auto serializedValue = serialized.releaseReturnValue(); + auto arrayBuffer = serializedValue->toArrayBuffer(); - if (asNodeBuffer) { - size_t byteLength = arrayBuffer->byteLength(); - JSC::JSUint8Array *uint8Array = JSC::JSUint8Array::create( - lexicalGlobalObject, globalObject->JSBufferSubclassStructure(), - WTFMove(arrayBuffer), 0, byteLength); - return JSValue::encode(uint8Array); - } + if (asNodeBuffer) { + size_t byteLength = arrayBuffer->byteLength(); + JSC::JSUint8Array* uint8Array = JSC::JSUint8Array::create( + lexicalGlobalObject, globalObject->JSBufferSubclassStructure(), + WTFMove(arrayBuffer), 0, byteLength); + return JSValue::encode(uint8Array); + } - if (arrayBuffer->isShared()) { - return JSValue::encode( - JSArrayBuffer::create(vm, - globalObject->arrayBufferStructureWithSharingMode< - ArrayBufferSharingMode::Shared>(), - WTFMove(arrayBuffer))); - } + if (arrayBuffer->isShared()) { + return JSValue::encode( + JSArrayBuffer::create(vm, + globalObject->arrayBufferStructureWithSharingMode< + ArrayBufferSharingMode::Shared>(), + WTFMove(arrayBuffer))); + } - return JSValue::encode(JSArrayBuffer::create( - vm, globalObject->arrayBufferStructure(), WTFMove(arrayBuffer))); + return JSValue::encode(JSArrayBuffer::create( + vm, globalObject->arrayBufferStructure(), WTFMove(arrayBuffer))); } -JSC_DEFINE_HOST_FUNCTION(functionDeserialize, (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - JSC::VM &vm = globalObject->vm(); - auto throwScope = DECLARE_THROW_SCOPE(vm); - JSValue value = callFrame->argument(0); +JSC_DEFINE_HOST_FUNCTION(functionDeserialize, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSValue value = callFrame->argument(0); - JSValue result; + JSValue result; - if (auto *jsArrayBuffer = jsDynamicCast(value)) { - result = SerializedScriptValue::fromArrayBuffer( - *globalObject, globalObject, jsArrayBuffer->impl(), 0, - jsArrayBuffer->impl()->byteLength()); - } else if (auto *view = jsDynamicCast(value)) { - auto arrayBuffer = view->possiblySharedImpl()->possiblySharedBuffer(); - result = SerializedScriptValue::fromArrayBuffer( - *globalObject, globalObject, arrayBuffer.get(), view->byteOffset(), - view->byteLength()); - } else { - throwTypeError(globalObject, throwScope, - "First argument must be an ArrayBuffer"_s); - return {}; - } + if (auto* jsArrayBuffer = jsDynamicCast(value)) { + result = SerializedScriptValue::fromArrayBuffer( + *globalObject, globalObject, jsArrayBuffer->impl(), 0, + jsArrayBuffer->impl()->byteLength()); + } else if (auto* view = jsDynamicCast(value)) { + auto arrayBuffer = view->possiblySharedImpl()->possiblySharedBuffer(); + result = SerializedScriptValue::fromArrayBuffer( + *globalObject, globalObject, arrayBuffer.get(), view->byteOffset(), + view->byteLength()); + } else { + throwTypeError(globalObject, throwScope, + "First argument must be an ArrayBuffer"_s); + return {}; + } - RETURN_IF_EXCEPTION(throwScope, {}); - RELEASE_AND_RETURN(throwScope, JSValue::encode(result)); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, JSValue::encode(result)); } extern "C" JSC::EncodedJSValue ByteRangeMapping__findExecutedLines( - JSC::JSGlobalObject *, BunString sourceURL, BasicBlockRange *ranges, + JSC::JSGlobalObject*, BunString sourceURL, BasicBlockRange* ranges, size_t len, size_t functionOffset, bool ignoreSourceMap); JSC_DEFINE_HOST_FUNCTION(functionCodeCoverageForFile, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - auto throwScope = DECLARE_THROW_SCOPE(vm); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - String fileName = callFrame->argument(0).toWTFString(globalObject); - RETURN_IF_EXCEPTION(throwScope, {}); - bool ignoreSourceMap = callFrame->argument(1).toBoolean(globalObject); + String fileName = callFrame->argument(0).toWTFString(globalObject); + 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 {}; - } + auto sourceID = Zig::sourceIDForSourceURL(fileName); + if (!sourceID) { + throwException(globalObject, throwScope, + createError(globalObject, "No source for file"_s)); + return {}; + } - auto basicBlocks = - vm.controlFlowProfiler()->getBasicBlocksForSourceIDWithoutFunctionRange( - sourceID, vm); + auto basicBlocks = vm.controlFlowProfiler()->getBasicBlocksForSourceIDWithoutFunctionRange( + sourceID, vm); - if (basicBlocks.isEmpty()) { - return JSC::JSValue::encode( - JSC::constructEmptyArray(globalObject, nullptr, 0)); - } + if (basicBlocks.isEmpty()) { + return JSC::JSValue::encode( + JSC::constructEmptyArray(globalObject, nullptr, 0)); + } - size_t functionStartOffset = basicBlocks.size(); + size_t functionStartOffset = basicBlocks.size(); - const Vector> &functionRanges = - vm.functionHasExecutedCache()->getFunctionRanges(sourceID); + const Vector>& functionRanges = vm.functionHasExecutedCache()->getFunctionRanges(sourceID); - basicBlocks.reserveCapacity(functionRanges.size() + basicBlocks.size()); + basicBlocks.reserveCapacity(functionRanges.size() + basicBlocks.size()); - for (const auto &functionRange : functionRanges) { - BasicBlockRange range; - range.m_hasExecuted = std::get<0>(functionRange); - range.m_startOffset = static_cast(std::get<1>(functionRange)); - range.m_endOffset = static_cast(std::get<2>(functionRange)); - range.m_executionCount = - range.m_hasExecuted + for (const auto& functionRange : functionRanges) { + BasicBlockRange range; + range.m_hasExecuted = std::get<0>(functionRange); + range.m_startOffset = static_cast(std::get<1>(functionRange)); + range.m_endOffset = static_cast(std::get<2>(functionRange)); + range.m_executionCount = range.m_hasExecuted ? 1 : 0; // This is a hack. We don't actually count this. - basicBlocks.append(range); - } + basicBlocks.append(range); + } - return ByteRangeMapping__findExecutedLines( - globalObject, Bun::toString(fileName), basicBlocks.data(), - basicBlocks.size(), functionStartOffset, ignoreSourceMap); + return ByteRangeMapping__findExecutedLines( + globalObject, Bun::toString(fileName), basicBlocks.data(), + basicBlocks.size(), functionStartOffset, ignoreSourceMap); } // clang-format off diff --git a/src/bun.js/modules/BunObjectModule.h b/src/bun.js/modules/BunObjectModule.h index 3d7ba1534f..c5aefa3e94 100644 --- a/src/bun.js/modules/BunObjectModule.h +++ b/src/bun.js/modules/BunObjectModule.h @@ -1,8 +1,8 @@ namespace Zig { -void generateNativeModule_BunObject(JSC::JSGlobalObject *lexicalGlobalObject, - JSC::Identifier moduleKey, - Vector &exportNames, - JSC::MarkedArgumentBuffer &exportValues); +void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues); -} // namespace Zig \ No newline at end of file +} // namespace Zig diff --git a/src/bun.js/modules/BunTestModule.h b/src/bun.js/modules/BunTestModule.h index 84687b6e93..4e276bd2fc 100644 --- a/src/bun.js/modules/BunTestModule.h +++ b/src/bun.js/modules/BunTestModule.h @@ -1,17 +1,18 @@ namespace Zig { void generateNativeModule_BunTest( - JSC::JSGlobalObject *lexicalGlobalObject, - JSC::Identifier moduleKey, - Vector &exportNames, - JSC::MarkedArgumentBuffer &exportValues) { - JSC::VM &vm = lexicalGlobalObject->vm(); - auto globalObject = jsCast(lexicalGlobalObject); + JSC::JSGlobalObject* lexicalGlobalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues) +{ + JSC::VM& vm = lexicalGlobalObject->vm(); + auto globalObject = jsCast(lexicalGlobalObject); - JSObject *object = globalObject->lazyPreloadTestModuleObject(); + JSObject* object = globalObject->lazyPreloadTestModuleObject(); - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(object); + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(object); } -} // namespace Zig \ No newline at end of file +} // namespace Zig diff --git a/src/bun.js/modules/NodeBufferModule.h b/src/bun.js/modules/NodeBufferModule.h index 5da5d2f9f9..a86ebb3a12 100644 --- a/src/bun.js/modules/NodeBufferModule.h +++ b/src/bun.js/modules/NodeBufferModule.h @@ -16,219 +16,218 @@ using namespace JSC; // TODO: Add DOMJIT fast path JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8, - (JSC::JSGlobalObject * lexicalGlobalObject, - JSC::CallFrame *callframe)) { - auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + (JSC::JSGlobalObject * lexicalGlobalObject, + JSC::CallFrame* callframe)) +{ + auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); - auto buffer = callframe->argument(0); - auto *bufferView = JSC::jsDynamicCast(buffer); - const char *ptr = nullptr; - size_t byteLength = 0; - if (bufferView) { - if (UNLIKELY(bufferView->isDetached())) { - throwTypeError(lexicalGlobalObject, throwScope, - "ArrayBufferView is detached"_s); - return {}; + auto buffer = callframe->argument(0); + auto* bufferView = JSC::jsDynamicCast(buffer); + const char* ptr = nullptr; + size_t byteLength = 0; + if (bufferView) { + if (UNLIKELY(bufferView->isDetached())) { + throwTypeError(lexicalGlobalObject, throwScope, + "ArrayBufferView is detached"_s); + return {}; + } + + byteLength = bufferView->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(bufferView->vector()); + } else if (auto* arrayBuffer = JSC::jsDynamicCast(buffer)) { + auto* impl = arrayBuffer->impl(); + + if (!impl) { + return JSValue::encode(jsBoolean(true)); + } + + if (UNLIKELY(impl->isDetached())) { + return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, + "Cannot validate on a detached buffer"_s); + } + + byteLength = impl->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(impl->data()); + } else { + Bun::throwError(lexicalGlobalObject, throwScope, + Bun::ErrorCode::ERR_INVALID_ARG_TYPE, + "First argument must be an ArrayBufferView"_s); + return {}; } - byteLength = bufferView->byteLength(); - - if (byteLength == 0) { - return JSValue::encode(jsBoolean(true)); - } - - ptr = reinterpret_cast(bufferView->vector()); - } else if (auto *arrayBuffer = - JSC::jsDynamicCast(buffer)) { - auto *impl = arrayBuffer->impl(); - - if (!impl) { - return JSValue::encode(jsBoolean(true)); - } - - if (UNLIKELY(impl->isDetached())) { - return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, - "Cannot validate on a detached buffer"_s); - } - - byteLength = impl->byteLength(); - - if (byteLength == 0) { - return JSValue::encode(jsBoolean(true)); - } - - ptr = reinterpret_cast(impl->data()); - } else { - Bun::throwError(lexicalGlobalObject, throwScope, - Bun::ErrorCode::ERR_INVALID_ARG_TYPE, - "First argument must be an ArrayBufferView"_s); - return {}; - } - - RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean( - simdutf::validate_utf8(ptr, byteLength)))); + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(simdutf::validate_utf8(ptr, byteLength)))); } // TODO: Add DOMJIT fast path JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii, - (JSC::JSGlobalObject * lexicalGlobalObject, - JSC::CallFrame *callframe)) { - auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + (JSC::JSGlobalObject * lexicalGlobalObject, + JSC::CallFrame* callframe)) +{ + auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); - auto buffer = callframe->argument(0); - auto *bufferView = JSC::jsDynamicCast(buffer); - const char *ptr = nullptr; - size_t byteLength = 0; - if (bufferView) { + auto buffer = callframe->argument(0); + auto* bufferView = JSC::jsDynamicCast(buffer); + const char* ptr = nullptr; + size_t byteLength = 0; + if (bufferView) { - if (UNLIKELY(bufferView->isDetached())) { - return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, - "Cannot validate on a detached buffer"_s); + if (UNLIKELY(bufferView->isDetached())) { + return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, + "Cannot validate on a detached buffer"_s); + } + + byteLength = bufferView->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(bufferView->vector()); + } else if (auto* arrayBuffer = JSC::jsDynamicCast(buffer)) { + auto* impl = arrayBuffer->impl(); + if (UNLIKELY(impl->isDetached())) { + return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, + "Cannot validate on a detached buffer"_s); + } + + if (!impl) { + return JSValue::encode(jsBoolean(true)); + } + + byteLength = impl->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(impl->data()); + } else { + Bun::throwError(lexicalGlobalObject, throwScope, + Bun::ErrorCode::ERR_INVALID_ARG_TYPE, + "First argument must be an ArrayBufferView"_s); + return {}; } - byteLength = bufferView->byteLength(); - - if (byteLength == 0) { - return JSValue::encode(jsBoolean(true)); - } - - ptr = reinterpret_cast(bufferView->vector()); - } else if (auto *arrayBuffer = - JSC::jsDynamicCast(buffer)) { - auto *impl = arrayBuffer->impl(); - if (UNLIKELY(impl->isDetached())) { - return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, - "Cannot validate on a detached buffer"_s); - } - - if (!impl) { - return JSValue::encode(jsBoolean(true)); - } - - byteLength = impl->byteLength(); - - if (byteLength == 0) { - return JSValue::encode(jsBoolean(true)); - } - - ptr = reinterpret_cast(impl->data()); - } else { - Bun::throwError(lexicalGlobalObject, throwScope, - Bun::ErrorCode::ERR_INVALID_ARG_TYPE, - "First argument must be an ArrayBufferView"_s); - return {}; - } - - RELEASE_AND_RETURN( - throwScope, - JSValue::encode(jsBoolean(simdutf::validate_ascii(ptr, byteLength)))); + RELEASE_AND_RETURN( + throwScope, + JSValue::encode(jsBoolean(simdutf::validate_ascii(ptr, byteLength)))); } BUN_DECLARE_HOST_FUNCTION(jsFunctionResolveObjectURL); JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { - VM &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ + VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - throwException(globalObject, scope, - createError(globalObject, "Not implemented"_s)); - return {}; + throwException(globalObject, scope, + createError(globalObject, "Not implemented"_s)); + return {}; } JSC_DEFINE_CUSTOM_GETTER(jsGetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName propertyName)) { - auto globalObject = reinterpret_cast(lexicalGlobalObject); - return JSValue::encode(jsNumber(globalObject->INSPECT_MAX_BYTES)); + auto globalObject = reinterpret_cast(lexicalGlobalObject); + return JSValue::encode(jsNumber(globalObject->INSPECT_MAX_BYTES)); } JSC_DEFINE_CUSTOM_SETTER(jsSetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName)) { - auto globalObject = reinterpret_cast(lexicalGlobalObject); - auto &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - auto val = JSValue::decode(value); - Bun::V::validateNumber(scope, globalObject, val, jsString(vm, String("INSPECT_MAX_BYTES"_s)), jsNumber(0), jsUndefined()); - RETURN_IF_EXCEPTION(scope, {}); - globalObject->INSPECT_MAX_BYTES = val.asNumber(); - return JSValue::encode(jsUndefined()); + auto globalObject = reinterpret_cast(lexicalGlobalObject); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + auto val = JSValue::decode(value); + Bun::V::validateNumber(scope, globalObject, val, jsString(vm, String("INSPECT_MAX_BYTES"_s)), jsNumber(0), jsUndefined()); + RETURN_IF_EXCEPTION(scope, {}); + globalObject->INSPECT_MAX_BYTES = val.asNumber(); + return JSValue::encode(jsUndefined()); } -DEFINE_NATIVE_MODULE(NodeBuffer) { - INIT_NATIVE_MODULE(12); +DEFINE_NATIVE_MODULE(NodeBuffer) +{ + INIT_NATIVE_MODULE(12); - put(JSC::Identifier::fromString(vm, "Buffer"_s), - globalObject->JSBufferConstructor()); + put(JSC::Identifier::fromString(vm, "Buffer"_s), + globalObject->JSBufferConstructor()); - auto *slowBuffer = JSC::JSFunction::create( - vm, globalObject, 0, "SlowBuffer"_s, WebCore::constructSlowBuffer, - ImplementationVisibility::Public, NoIntrinsic, - WebCore::constructSlowBuffer); - slowBuffer->putDirect( - vm, vm.propertyNames->prototype, globalObject->JSBufferPrototype(), - JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | - JSC::PropertyAttribute::DontDelete); - put(JSC::Identifier::fromString(vm, "SlowBuffer"_s), slowBuffer); - auto blobIdent = JSC::Identifier::fromString(vm, "Blob"_s); + auto* slowBuffer = JSC::JSFunction::create( + vm, globalObject, 0, "SlowBuffer"_s, WebCore::constructSlowBuffer, + ImplementationVisibility::Public, NoIntrinsic, + WebCore::constructSlowBuffer); + slowBuffer->putDirect( + vm, vm.propertyNames->prototype, globalObject->JSBufferPrototype(), + JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); + put(JSC::Identifier::fromString(vm, "SlowBuffer"_s), slowBuffer); + auto blobIdent = JSC::Identifier::fromString(vm, "Blob"_s); - JSValue blobValue = globalObject->JSBlobConstructor(); - put(blobIdent, blobValue); + JSValue blobValue = globalObject->JSBlobConstructor(); + put(blobIdent, blobValue); - put(JSC::Identifier::fromString(vm, "File"_s), - globalObject->JSDOMFileConstructor()); + put(JSC::Identifier::fromString(vm, "File"_s), + globalObject->JSDOMFileConstructor()); - { - auto name = Identifier::fromString(vm, "INSPECT_MAX_BYTES"_s); - auto value = JSC::CustomGetterSetter::create(vm, jsGetter_INSPECT_MAX_BYTES, jsSetter_INSPECT_MAX_BYTES); - auto attributes = PropertyAttribute::DontDelete | PropertyAttribute::CustomAccessor; - defaultObject->putDirectCustomAccessor(vm, name, value, (unsigned)attributes); - exportNames.append(name); - exportValues.append(value); - __NATIVE_MODULE_ASSERT_INCR; - } + { + auto name = Identifier::fromString(vm, "INSPECT_MAX_BYTES"_s); + auto value = JSC::CustomGetterSetter::create(vm, jsGetter_INSPECT_MAX_BYTES, jsSetter_INSPECT_MAX_BYTES); + auto attributes = PropertyAttribute::DontDelete | PropertyAttribute::CustomAccessor; + defaultObject->putDirectCustomAccessor(vm, name, value, (unsigned)attributes); + exportNames.append(name); + exportValues.append(value); + __NATIVE_MODULE_ASSERT_INCR; + } - put(JSC::Identifier::fromString(vm, "kMaxLength"_s), JSC::jsNumber(Bun::Buffer::kMaxLength)); - put(JSC::Identifier::fromString(vm, "kStringMaxLength"_s), JSC::jsNumber(Bun::Buffer::kStringMaxLength)); + put(JSC::Identifier::fromString(vm, "kMaxLength"_s), JSC::jsNumber(Bun::Buffer::kMaxLength)); + put(JSC::Identifier::fromString(vm, "kStringMaxLength"_s), JSC::jsNumber(Bun::Buffer::kStringMaxLength)); - JSC::JSObject *constants = JSC::constructEmptyObject(lexicalGlobalObject, globalObject->objectPrototype(), 2); - constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_LENGTH)); - constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_STRING_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_STRING_LENGTH)); + JSC::JSObject* constants = JSC::constructEmptyObject(lexicalGlobalObject, globalObject->objectPrototype(), 2); + constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_LENGTH)); + constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_STRING_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_STRING_LENGTH)); - put(JSC::Identifier::fromString(vm, "constants"_s), constants); + put(JSC::Identifier::fromString(vm, "constants"_s), constants); - JSC::Identifier atobI = JSC::Identifier::fromString(vm, "atob"_s); - JSC::JSValue atobV = lexicalGlobalObject->get(globalObject, PropertyName(atobI)); + JSC::Identifier atobI = JSC::Identifier::fromString(vm, "atob"_s); + JSC::JSValue atobV = lexicalGlobalObject->get(globalObject, PropertyName(atobI)); - JSC::Identifier btoaI = JSC::Identifier::fromString(vm, "btoa"_s); - JSC::JSValue btoaV = lexicalGlobalObject->get(globalObject, PropertyName(btoaI)); + JSC::Identifier btoaI = JSC::Identifier::fromString(vm, "btoa"_s); + JSC::JSValue btoaV = lexicalGlobalObject->get(globalObject, PropertyName(btoaI)); - put(atobI, atobV); - put(btoaI, btoaV); + put(atobI, atobV); + put(btoaI, btoaV); - auto *transcode = InternalFunction::createFunctionThatMasqueradesAsUndefined( - vm, globalObject, 1, "transcode"_s, jsFunctionNotImplemented); + auto* transcode = InternalFunction::createFunctionThatMasqueradesAsUndefined( + vm, globalObject, 1, "transcode"_s, jsFunctionNotImplemented); - put(JSC::Identifier::fromString(vm, "transcode"_s), transcode); + put(JSC::Identifier::fromString(vm, "transcode"_s), transcode); - auto *resolveObjectURL = - InternalFunction::createFunctionThatMasqueradesAsUndefined( - vm, globalObject, 1, "resolveObjectURL"_s, - jsFunctionResolveObjectURL); + auto* resolveObjectURL = InternalFunction::createFunctionThatMasqueradesAsUndefined( + vm, globalObject, 1, "resolveObjectURL"_s, + jsFunctionResolveObjectURL); - put(JSC::Identifier::fromString(vm, "resolveObjectURL"_s), resolveObjectURL); + put(JSC::Identifier::fromString(vm, "resolveObjectURL"_s), resolveObjectURL); - put(JSC::Identifier::fromString(vm, "isAscii"_s), - JSC::JSFunction::create(vm, globalObject, 1, "isAscii"_s, - jsBufferConstructorFunction_isAscii, - ImplementationVisibility::Public, NoIntrinsic, - jsBufferConstructorFunction_isUtf8)); + put(JSC::Identifier::fromString(vm, "isAscii"_s), + JSC::JSFunction::create(vm, globalObject, 1, "isAscii"_s, + jsBufferConstructorFunction_isAscii, + ImplementationVisibility::Public, NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); - put(JSC::Identifier::fromString(vm, "isUtf8"_s), - JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s, - jsBufferConstructorFunction_isUtf8, - ImplementationVisibility::Public, NoIntrinsic, - jsBufferConstructorFunction_isUtf8)); + put(JSC::Identifier::fromString(vm, "isUtf8"_s), + JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s, + jsBufferConstructorFunction_isUtf8, + ImplementationVisibility::Public, NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); } } // namespace Zig diff --git a/src/bun.js/modules/NodeConstantsModule.h b/src/bun.js/modules/NodeConstantsModule.h index ce701f5e32..9a0d2f0643 100644 --- a/src/bun.js/modules/NodeConstantsModule.h +++ b/src/bun.js/modules/NodeConstantsModule.h @@ -49,941 +49,942 @@ namespace Zig { using namespace WebCore; -DEFINE_NATIVE_MODULE(NodeConstants) { - INIT_NATIVE_MODULE(0); +DEFINE_NATIVE_MODULE(NodeConstants) +{ + INIT_NATIVE_MODULE(0); #ifdef RTLD_LAZY - put(Identifier::fromString(vm, "RTLD_LAZY"_s), jsNumber(RTLD_LAZY)); + put(Identifier::fromString(vm, "RTLD_LAZY"_s), jsNumber(RTLD_LAZY)); #endif #ifdef RTLD_NOW - put(Identifier::fromString(vm, "RTLD_NOW"_s), jsNumber(RTLD_NOW)); + put(Identifier::fromString(vm, "RTLD_NOW"_s), jsNumber(RTLD_NOW)); #endif #ifdef RTLD_GLOBAL - put(Identifier::fromString(vm, "RTLD_GLOBAL"_s), jsNumber(RTLD_GLOBAL)); + put(Identifier::fromString(vm, "RTLD_GLOBAL"_s), jsNumber(RTLD_GLOBAL)); #endif #ifdef RTLD_LOCAL - put(Identifier::fromString(vm, "RTLD_LOCAL"_s), jsNumber(RTLD_LOCAL)); + put(Identifier::fromString(vm, "RTLD_LOCAL"_s), jsNumber(RTLD_LOCAL)); #endif #ifdef RTLD_DEEPBIND - put(Identifier::fromString(vm, "RTLD_DEEPBIND"_s), jsNumber(RTLD_DEEPBIND)); + put(Identifier::fromString(vm, "RTLD_DEEPBIND"_s), jsNumber(RTLD_DEEPBIND)); #endif #ifdef E2BIG - put(Identifier::fromString(vm, "E2BIG"_s), jsNumber(E2BIG)); + put(Identifier::fromString(vm, "E2BIG"_s), jsNumber(E2BIG)); #endif #ifdef EACCES - put(Identifier::fromString(vm, "EACCES"_s), jsNumber(EACCES)); + put(Identifier::fromString(vm, "EACCES"_s), jsNumber(EACCES)); #endif #ifdef EADDRINUSE - put(Identifier::fromString(vm, "EADDRINUSE"_s), jsNumber(EADDRINUSE)); + put(Identifier::fromString(vm, "EADDRINUSE"_s), jsNumber(EADDRINUSE)); #endif #ifdef EADDRNOTAVAIL - put(Identifier::fromString(vm, "EADDRNOTAVAIL"_s), jsNumber(EADDRNOTAVAIL)); + put(Identifier::fromString(vm, "EADDRNOTAVAIL"_s), jsNumber(EADDRNOTAVAIL)); #endif #ifdef EAFNOSUPPORT - put(Identifier::fromString(vm, "EAFNOSUPPORT"_s), jsNumber(EAFNOSUPPORT)); + put(Identifier::fromString(vm, "EAFNOSUPPORT"_s), jsNumber(EAFNOSUPPORT)); #endif #ifdef EAGAIN - put(Identifier::fromString(vm, "EAGAIN"_s), jsNumber(EAGAIN)); + put(Identifier::fromString(vm, "EAGAIN"_s), jsNumber(EAGAIN)); #endif #ifdef EALREADY - put(Identifier::fromString(vm, "EALREADY"_s), jsNumber(EALREADY)); + put(Identifier::fromString(vm, "EALREADY"_s), jsNumber(EALREADY)); #endif #ifdef EBADF - put(Identifier::fromString(vm, "EBADF"_s), jsNumber(EBADF)); + put(Identifier::fromString(vm, "EBADF"_s), jsNumber(EBADF)); #endif #ifdef EBADMSG - put(Identifier::fromString(vm, "EBADMSG"_s), jsNumber(EBADMSG)); + put(Identifier::fromString(vm, "EBADMSG"_s), jsNumber(EBADMSG)); #endif #ifdef EBUSY - put(Identifier::fromString(vm, "EBUSY"_s), jsNumber(EBUSY)); + put(Identifier::fromString(vm, "EBUSY"_s), jsNumber(EBUSY)); #endif #ifdef ECANCELED - put(Identifier::fromString(vm, "ECANCELED"_s), jsNumber(ECANCELED)); + put(Identifier::fromString(vm, "ECANCELED"_s), jsNumber(ECANCELED)); #endif #ifdef ECHILD - put(Identifier::fromString(vm, "ECHILD"_s), jsNumber(ECHILD)); + put(Identifier::fromString(vm, "ECHILD"_s), jsNumber(ECHILD)); #endif #ifdef ECONNABORTED - put(Identifier::fromString(vm, "ECONNABORTED"_s), jsNumber(ECONNABORTED)); + put(Identifier::fromString(vm, "ECONNABORTED"_s), jsNumber(ECONNABORTED)); #endif #ifdef ECONNREFUSED - put(Identifier::fromString(vm, "ECONNREFUSED"_s), jsNumber(ECONNREFUSED)); + put(Identifier::fromString(vm, "ECONNREFUSED"_s), jsNumber(ECONNREFUSED)); #endif #ifdef ECONNRESET - put(Identifier::fromString(vm, "ECONNRESET"_s), jsNumber(ECONNRESET)); + put(Identifier::fromString(vm, "ECONNRESET"_s), jsNumber(ECONNRESET)); #endif #ifdef EDEADLK - put(Identifier::fromString(vm, "EDEADLK"_s), jsNumber(EDEADLK)); + put(Identifier::fromString(vm, "EDEADLK"_s), jsNumber(EDEADLK)); #endif #ifdef EDESTADDRREQ - put(Identifier::fromString(vm, "EDESTADDRREQ"_s), jsNumber(EDESTADDRREQ)); + put(Identifier::fromString(vm, "EDESTADDRREQ"_s), jsNumber(EDESTADDRREQ)); #endif #ifdef EDOM - put(Identifier::fromString(vm, "EDOM"_s), jsNumber(EDOM)); + put(Identifier::fromString(vm, "EDOM"_s), jsNumber(EDOM)); #endif #ifdef EDQUOT - put(Identifier::fromString(vm, "EDQUOT"_s), jsNumber(EDQUOT)); + put(Identifier::fromString(vm, "EDQUOT"_s), jsNumber(EDQUOT)); #endif #ifdef EEXIST - put(Identifier::fromString(vm, "EEXIST"_s), jsNumber(EEXIST)); + put(Identifier::fromString(vm, "EEXIST"_s), jsNumber(EEXIST)); #endif #ifdef EFAULT - put(Identifier::fromString(vm, "EFAULT"_s), jsNumber(EFAULT)); + put(Identifier::fromString(vm, "EFAULT"_s), jsNumber(EFAULT)); #endif #ifdef EFBIG - put(Identifier::fromString(vm, "EFBIG"_s), jsNumber(EFBIG)); + put(Identifier::fromString(vm, "EFBIG"_s), jsNumber(EFBIG)); #endif #ifdef EHOSTUNREACH - put(Identifier::fromString(vm, "EHOSTUNREACH"_s), jsNumber(EHOSTUNREACH)); + put(Identifier::fromString(vm, "EHOSTUNREACH"_s), jsNumber(EHOSTUNREACH)); #endif #ifdef EIDRM - put(Identifier::fromString(vm, "EIDRM"_s), jsNumber(EIDRM)); + put(Identifier::fromString(vm, "EIDRM"_s), jsNumber(EIDRM)); #endif #ifdef EILSEQ - put(Identifier::fromString(vm, "EILSEQ"_s), jsNumber(EILSEQ)); + put(Identifier::fromString(vm, "EILSEQ"_s), jsNumber(EILSEQ)); #endif #ifdef EINPROGRESS - put(Identifier::fromString(vm, "EINPROGRESS"_s), jsNumber(EINPROGRESS)); + put(Identifier::fromString(vm, "EINPROGRESS"_s), jsNumber(EINPROGRESS)); #endif #ifdef EINTR - put(Identifier::fromString(vm, "EINTR"_s), jsNumber(EINTR)); + put(Identifier::fromString(vm, "EINTR"_s), jsNumber(EINTR)); #endif #ifdef EINVAL - put(Identifier::fromString(vm, "EINVAL"_s), jsNumber(EINVAL)); + put(Identifier::fromString(vm, "EINVAL"_s), jsNumber(EINVAL)); #endif #ifdef EIO - put(Identifier::fromString(vm, "EIO"_s), jsNumber(EIO)); + put(Identifier::fromString(vm, "EIO"_s), jsNumber(EIO)); #endif #ifdef EISCONN - put(Identifier::fromString(vm, "EISCONN"_s), jsNumber(EISCONN)); + put(Identifier::fromString(vm, "EISCONN"_s), jsNumber(EISCONN)); #endif #ifdef EISDIR - put(Identifier::fromString(vm, "EISDIR"_s), jsNumber(EISDIR)); + put(Identifier::fromString(vm, "EISDIR"_s), jsNumber(EISDIR)); #endif #ifdef ELOOP - put(Identifier::fromString(vm, "ELOOP"_s), jsNumber(ELOOP)); + put(Identifier::fromString(vm, "ELOOP"_s), jsNumber(ELOOP)); #endif #ifdef EMFILE - put(Identifier::fromString(vm, "EMFILE"_s), jsNumber(EMFILE)); + put(Identifier::fromString(vm, "EMFILE"_s), jsNumber(EMFILE)); #endif #ifdef EMLINK - put(Identifier::fromString(vm, "EMLINK"_s), jsNumber(EMLINK)); + put(Identifier::fromString(vm, "EMLINK"_s), jsNumber(EMLINK)); #endif #ifdef EMSGSIZE - put(Identifier::fromString(vm, "EMSGSIZE"_s), jsNumber(EMSGSIZE)); + put(Identifier::fromString(vm, "EMSGSIZE"_s), jsNumber(EMSGSIZE)); #endif #ifdef EMULTIHOP - put(Identifier::fromString(vm, "EMULTIHOP"_s), jsNumber(EMULTIHOP)); + put(Identifier::fromString(vm, "EMULTIHOP"_s), jsNumber(EMULTIHOP)); #endif #ifdef ENAMETOOLONG - put(Identifier::fromString(vm, "ENAMETOOLONG"_s), jsNumber(ENAMETOOLONG)); + put(Identifier::fromString(vm, "ENAMETOOLONG"_s), jsNumber(ENAMETOOLONG)); #endif #ifdef ENETDOWN - put(Identifier::fromString(vm, "ENETDOWN"_s), jsNumber(ENETDOWN)); + put(Identifier::fromString(vm, "ENETDOWN"_s), jsNumber(ENETDOWN)); #endif #ifdef ENETRESET - put(Identifier::fromString(vm, "ENETRESET"_s), jsNumber(ENETRESET)); + put(Identifier::fromString(vm, "ENETRESET"_s), jsNumber(ENETRESET)); #endif #ifdef ENETUNREACH - put(Identifier::fromString(vm, "ENETUNREACH"_s), jsNumber(ENETUNREACH)); + put(Identifier::fromString(vm, "ENETUNREACH"_s), jsNumber(ENETUNREACH)); #endif #ifdef ENFILE - put(Identifier::fromString(vm, "ENFILE"_s), jsNumber(ENFILE)); + put(Identifier::fromString(vm, "ENFILE"_s), jsNumber(ENFILE)); #endif #ifdef ENOBUFS - put(Identifier::fromString(vm, "ENOBUFS"_s), jsNumber(ENOBUFS)); + put(Identifier::fromString(vm, "ENOBUFS"_s), jsNumber(ENOBUFS)); #endif #ifdef ENODATA - put(Identifier::fromString(vm, "ENODATA"_s), jsNumber(ENODATA)); + put(Identifier::fromString(vm, "ENODATA"_s), jsNumber(ENODATA)); #endif #ifdef ENODEV - put(Identifier::fromString(vm, "ENODEV"_s), jsNumber(ENODEV)); + put(Identifier::fromString(vm, "ENODEV"_s), jsNumber(ENODEV)); #endif #ifdef ENOENT - put(Identifier::fromString(vm, "ENOENT"_s), jsNumber(ENOENT)); + put(Identifier::fromString(vm, "ENOENT"_s), jsNumber(ENOENT)); #endif #ifdef ENOEXEC - put(Identifier::fromString(vm, "ENOEXEC"_s), jsNumber(ENOEXEC)); + put(Identifier::fromString(vm, "ENOEXEC"_s), jsNumber(ENOEXEC)); #endif #ifdef ENOLCK - put(Identifier::fromString(vm, "ENOLCK"_s), jsNumber(ENOLCK)); + put(Identifier::fromString(vm, "ENOLCK"_s), jsNumber(ENOLCK)); #endif #ifdef ENOLINK - put(Identifier::fromString(vm, "ENOLINK"_s), jsNumber(ENOLINK)); + put(Identifier::fromString(vm, "ENOLINK"_s), jsNumber(ENOLINK)); #endif #ifdef ENOMEM - put(Identifier::fromString(vm, "ENOMEM"_s), jsNumber(ENOMEM)); + put(Identifier::fromString(vm, "ENOMEM"_s), jsNumber(ENOMEM)); #endif #ifdef ENOMSG - put(Identifier::fromString(vm, "ENOMSG"_s), jsNumber(ENOMSG)); + put(Identifier::fromString(vm, "ENOMSG"_s), jsNumber(ENOMSG)); #endif #ifdef ENOPROTOOPT - put(Identifier::fromString(vm, "ENOPROTOOPT"_s), jsNumber(ENOPROTOOPT)); + put(Identifier::fromString(vm, "ENOPROTOOPT"_s), jsNumber(ENOPROTOOPT)); #endif #ifdef ENOSPC - put(Identifier::fromString(vm, "ENOSPC"_s), jsNumber(ENOSPC)); + put(Identifier::fromString(vm, "ENOSPC"_s), jsNumber(ENOSPC)); #endif #ifdef ENOSR - put(Identifier::fromString(vm, "ENOSR"_s), jsNumber(ENOSR)); + put(Identifier::fromString(vm, "ENOSR"_s), jsNumber(ENOSR)); #endif #ifdef ENOSTR - put(Identifier::fromString(vm, "ENOSTR"_s), jsNumber(ENOSTR)); + put(Identifier::fromString(vm, "ENOSTR"_s), jsNumber(ENOSTR)); #endif #ifdef ENOSYS - put(Identifier::fromString(vm, "ENOSYS"_s), jsNumber(ENOSYS)); + put(Identifier::fromString(vm, "ENOSYS"_s), jsNumber(ENOSYS)); #endif #ifdef ENOTCONN - put(Identifier::fromString(vm, "ENOTCONN"_s), jsNumber(ENOTCONN)); + put(Identifier::fromString(vm, "ENOTCONN"_s), jsNumber(ENOTCONN)); #endif #ifdef ENOTDIR - put(Identifier::fromString(vm, "ENOTDIR"_s), jsNumber(ENOTDIR)); + put(Identifier::fromString(vm, "ENOTDIR"_s), jsNumber(ENOTDIR)); #endif #ifdef ENOTEMPTY - put(Identifier::fromString(vm, "ENOTEMPTY"_s), jsNumber(ENOTEMPTY)); + put(Identifier::fromString(vm, "ENOTEMPTY"_s), jsNumber(ENOTEMPTY)); #endif #ifdef ENOTSOCK - put(Identifier::fromString(vm, "ENOTSOCK"_s), jsNumber(ENOTSOCK)); + put(Identifier::fromString(vm, "ENOTSOCK"_s), jsNumber(ENOTSOCK)); #endif #ifdef ENOTSUP - put(Identifier::fromString(vm, "ENOTSUP"_s), jsNumber(ENOTSUP)); + put(Identifier::fromString(vm, "ENOTSUP"_s), jsNumber(ENOTSUP)); #endif #ifdef ENOTTY - put(Identifier::fromString(vm, "ENOTTY"_s), jsNumber(ENOTTY)); + put(Identifier::fromString(vm, "ENOTTY"_s), jsNumber(ENOTTY)); #endif #ifdef ENXIO - put(Identifier::fromString(vm, "ENXIO"_s), jsNumber(ENXIO)); + put(Identifier::fromString(vm, "ENXIO"_s), jsNumber(ENXIO)); #endif #ifdef EOPNOTSUPP - put(Identifier::fromString(vm, "EOPNOTSUPP"_s), jsNumber(EOPNOTSUPP)); + put(Identifier::fromString(vm, "EOPNOTSUPP"_s), jsNumber(EOPNOTSUPP)); #endif #ifdef EOVERFLOW - put(Identifier::fromString(vm, "EOVERFLOW"_s), jsNumber(EOVERFLOW)); + put(Identifier::fromString(vm, "EOVERFLOW"_s), jsNumber(EOVERFLOW)); #endif #ifdef EPERM - put(Identifier::fromString(vm, "EPERM"_s), jsNumber(EPERM)); + put(Identifier::fromString(vm, "EPERM"_s), jsNumber(EPERM)); #endif #ifdef EPIPE - put(Identifier::fromString(vm, "EPIPE"_s), jsNumber(EPIPE)); + put(Identifier::fromString(vm, "EPIPE"_s), jsNumber(EPIPE)); #endif #ifdef EPROTO - put(Identifier::fromString(vm, "EPROTO"_s), jsNumber(EPROTO)); + put(Identifier::fromString(vm, "EPROTO"_s), jsNumber(EPROTO)); #endif #ifdef EPROTONOSUPPORT - put(Identifier::fromString(vm, "EPROTONOSUPPORT"_s), - jsNumber(EPROTONOSUPPORT)); + put(Identifier::fromString(vm, "EPROTONOSUPPORT"_s), + jsNumber(EPROTONOSUPPORT)); #endif #ifdef EPROTOTYPE - put(Identifier::fromString(vm, "EPROTOTYPE"_s), jsNumber(EPROTOTYPE)); + put(Identifier::fromString(vm, "EPROTOTYPE"_s), jsNumber(EPROTOTYPE)); #endif #ifdef ERANGE - put(Identifier::fromString(vm, "ERANGE"_s), jsNumber(ERANGE)); + put(Identifier::fromString(vm, "ERANGE"_s), jsNumber(ERANGE)); #endif #ifdef EROFS - put(Identifier::fromString(vm, "EROFS"_s), jsNumber(EROFS)); + put(Identifier::fromString(vm, "EROFS"_s), jsNumber(EROFS)); #endif #ifdef ESPIPE - put(Identifier::fromString(vm, "ESPIPE"_s), jsNumber(ESPIPE)); + put(Identifier::fromString(vm, "ESPIPE"_s), jsNumber(ESPIPE)); #endif #ifdef ESRCH - put(Identifier::fromString(vm, "ESRCH"_s), jsNumber(ESRCH)); + put(Identifier::fromString(vm, "ESRCH"_s), jsNumber(ESRCH)); #endif #ifdef ESTALE - put(Identifier::fromString(vm, "ESTALE"_s), jsNumber(ESTALE)); + put(Identifier::fromString(vm, "ESTALE"_s), jsNumber(ESTALE)); #endif #ifdef ETIME - put(Identifier::fromString(vm, "ETIME"_s), jsNumber(ETIME)); + put(Identifier::fromString(vm, "ETIME"_s), jsNumber(ETIME)); #endif #ifdef ETIMEDOUT - put(Identifier::fromString(vm, "ETIMEDOUT"_s), jsNumber(ETIMEDOUT)); + put(Identifier::fromString(vm, "ETIMEDOUT"_s), jsNumber(ETIMEDOUT)); #endif #ifdef ETXTBSY - put(Identifier::fromString(vm, "ETXTBSY"_s), jsNumber(ETXTBSY)); + put(Identifier::fromString(vm, "ETXTBSY"_s), jsNumber(ETXTBSY)); #endif #ifdef EWOULDBLOCK - put(Identifier::fromString(vm, "EWOULDBLOCK"_s), jsNumber(EWOULDBLOCK)); + put(Identifier::fromString(vm, "EWOULDBLOCK"_s), jsNumber(EWOULDBLOCK)); #endif #ifdef EXDEV - put(Identifier::fromString(vm, "EXDEV"_s), jsNumber(EXDEV)); + put(Identifier::fromString(vm, "EXDEV"_s), jsNumber(EXDEV)); #endif #ifdef WSAEINTR - put(Identifier::fromString(vm, "WSAEINTR"_s), jsNumber(WSAEINTR)); + put(Identifier::fromString(vm, "WSAEINTR"_s), jsNumber(WSAEINTR)); #endif #ifdef WSAEBADF - put(Identifier::fromString(vm, "WSAEBADF"_s), jsNumber(WSAEBADF)); + put(Identifier::fromString(vm, "WSAEBADF"_s), jsNumber(WSAEBADF)); #endif #ifdef WSAEACCES - put(Identifier::fromString(vm, "WSAEACCES"_s), jsNumber(WSAEACCES)); + put(Identifier::fromString(vm, "WSAEACCES"_s), jsNumber(WSAEACCES)); #endif #ifdef WSAEFAULT - put(Identifier::fromString(vm, "WSAEFAULT"_s), jsNumber(WSAEFAULT)); + put(Identifier::fromString(vm, "WSAEFAULT"_s), jsNumber(WSAEFAULT)); #endif #ifdef WSAEINVAL - put(Identifier::fromString(vm, "WSAEINVAL"_s), jsNumber(WSAEINVAL)); + put(Identifier::fromString(vm, "WSAEINVAL"_s), jsNumber(WSAEINVAL)); #endif #ifdef WSAEMFILE - put(Identifier::fromString(vm, "WSAEMFILE"_s), jsNumber(WSAEMFILE)); + put(Identifier::fromString(vm, "WSAEMFILE"_s), jsNumber(WSAEMFILE)); #endif #ifdef WSAEWOULDBLOCK - put(Identifier::fromString(vm, "WSAEWOULDBLOCK"_s), jsNumber(WSAEWOULDBLOCK)); + put(Identifier::fromString(vm, "WSAEWOULDBLOCK"_s), jsNumber(WSAEWOULDBLOCK)); #endif #ifdef WSAEINPROGRESS - put(Identifier::fromString(vm, "WSAEINPROGRESS"_s), jsNumber(WSAEINPROGRESS)); + put(Identifier::fromString(vm, "WSAEINPROGRESS"_s), jsNumber(WSAEINPROGRESS)); #endif #ifdef WSAEALREADY - put(Identifier::fromString(vm, "WSAEALREADY"_s), jsNumber(WSAEALREADY)); + put(Identifier::fromString(vm, "WSAEALREADY"_s), jsNumber(WSAEALREADY)); #endif #ifdef WSAENOTSOCK - put(Identifier::fromString(vm, "WSAENOTSOCK"_s), jsNumber(WSAENOTSOCK)); + put(Identifier::fromString(vm, "WSAENOTSOCK"_s), jsNumber(WSAENOTSOCK)); #endif #ifdef WSAEDESTADDRREQ - put(Identifier::fromString(vm, "WSAEDESTADDRREQ"_s), - jsNumber(WSAEDESTADDRREQ)); + put(Identifier::fromString(vm, "WSAEDESTADDRREQ"_s), + jsNumber(WSAEDESTADDRREQ)); #endif #ifdef WSAEMSGSIZE - put(Identifier::fromString(vm, "WSAEMSGSIZE"_s), jsNumber(WSAEMSGSIZE)); + put(Identifier::fromString(vm, "WSAEMSGSIZE"_s), jsNumber(WSAEMSGSIZE)); #endif #ifdef WSAEPROTOTYPE - put(Identifier::fromString(vm, "WSAEPROTOTYPE"_s), jsNumber(WSAEPROTOTYPE)); + put(Identifier::fromString(vm, "WSAEPROTOTYPE"_s), jsNumber(WSAEPROTOTYPE)); #endif #ifdef WSAENOPROTOOPT - put(Identifier::fromString(vm, "WSAENOPROTOOPT"_s), jsNumber(WSAENOPROTOOPT)); + put(Identifier::fromString(vm, "WSAENOPROTOOPT"_s), jsNumber(WSAENOPROTOOPT)); #endif #ifdef WSAEPROTONOSUPPORT - put(Identifier::fromString(vm, "WSAEPROTONOSUPPORT"_s), - jsNumber(WSAEPROTONOSUPPORT)); + put(Identifier::fromString(vm, "WSAEPROTONOSUPPORT"_s), + jsNumber(WSAEPROTONOSUPPORT)); #endif #ifdef WSAESOCKTNOSUPPORT - put(Identifier::fromString(vm, "WSAESOCKTNOSUPPORT"_s), - jsNumber(WSAESOCKTNOSUPPORT)); + put(Identifier::fromString(vm, "WSAESOCKTNOSUPPORT"_s), + jsNumber(WSAESOCKTNOSUPPORT)); #endif #ifdef WSAEOPNOTSUPP - put(Identifier::fromString(vm, "WSAEOPNOTSUPP"_s), jsNumber(WSAEOPNOTSUPP)); + put(Identifier::fromString(vm, "WSAEOPNOTSUPP"_s), jsNumber(WSAEOPNOTSUPP)); #endif #ifdef WSAEPFNOSUPPORT - put(Identifier::fromString(vm, "WSAEPFNOSUPPORT"_s), - jsNumber(WSAEPFNOSUPPORT)); + put(Identifier::fromString(vm, "WSAEPFNOSUPPORT"_s), + jsNumber(WSAEPFNOSUPPORT)); #endif #ifdef WSAEAFNOSUPPORT - put(Identifier::fromString(vm, "WSAEAFNOSUPPORT"_s), - jsNumber(WSAEAFNOSUPPORT)); + put(Identifier::fromString(vm, "WSAEAFNOSUPPORT"_s), + jsNumber(WSAEAFNOSUPPORT)); #endif #ifdef WSAEADDRINUSE - put(Identifier::fromString(vm, "WSAEADDRINUSE"_s), jsNumber(WSAEADDRINUSE)); + put(Identifier::fromString(vm, "WSAEADDRINUSE"_s), jsNumber(WSAEADDRINUSE)); #endif #ifdef WSAEADDRNOTAVAIL - put(Identifier::fromString(vm, "WSAEADDRNOTAVAIL"_s), - jsNumber(WSAEADDRNOTAVAIL)); + put(Identifier::fromString(vm, "WSAEADDRNOTAVAIL"_s), + jsNumber(WSAEADDRNOTAVAIL)); #endif #ifdef WSAENETDOWN - put(Identifier::fromString(vm, "WSAENETDOWN"_s), jsNumber(WSAENETDOWN)); + put(Identifier::fromString(vm, "WSAENETDOWN"_s), jsNumber(WSAENETDOWN)); #endif #ifdef WSAENETUNREACH - put(Identifier::fromString(vm, "WSAENETUNREACH"_s), jsNumber(WSAENETUNREACH)); + put(Identifier::fromString(vm, "WSAENETUNREACH"_s), jsNumber(WSAENETUNREACH)); #endif #ifdef WSAENETRESET - put(Identifier::fromString(vm, "WSAENETRESET"_s), jsNumber(WSAENETRESET)); + put(Identifier::fromString(vm, "WSAENETRESET"_s), jsNumber(WSAENETRESET)); #endif #ifdef WSAECONNABORTED - put(Identifier::fromString(vm, "WSAECONNABORTED"_s), - jsNumber(WSAECONNABORTED)); + put(Identifier::fromString(vm, "WSAECONNABORTED"_s), + jsNumber(WSAECONNABORTED)); #endif #ifdef WSAECONNRESET - put(Identifier::fromString(vm, "WSAECONNRESET"_s), jsNumber(WSAECONNRESET)); + put(Identifier::fromString(vm, "WSAECONNRESET"_s), jsNumber(WSAECONNRESET)); #endif #ifdef WSAENOBUFS - put(Identifier::fromString(vm, "WSAENOBUFS"_s), jsNumber(WSAENOBUFS)); + put(Identifier::fromString(vm, "WSAENOBUFS"_s), jsNumber(WSAENOBUFS)); #endif #ifdef WSAEISCONN - put(Identifier::fromString(vm, "WSAEISCONN"_s), jsNumber(WSAEISCONN)); + put(Identifier::fromString(vm, "WSAEISCONN"_s), jsNumber(WSAEISCONN)); #endif #ifdef WSAENOTCONN - put(Identifier::fromString(vm, "WSAENOTCONN"_s), jsNumber(WSAENOTCONN)); + put(Identifier::fromString(vm, "WSAENOTCONN"_s), jsNumber(WSAENOTCONN)); #endif #ifdef WSAESHUTDOWN - put(Identifier::fromString(vm, "WSAESHUTDOWN"_s), jsNumber(WSAESHUTDOWN)); + put(Identifier::fromString(vm, "WSAESHUTDOWN"_s), jsNumber(WSAESHUTDOWN)); #endif #ifdef WSAETOOMANYREFS - put(Identifier::fromString(vm, "WSAETOOMANYREFS"_s), - jsNumber(WSAETOOMANYREFS)); + put(Identifier::fromString(vm, "WSAETOOMANYREFS"_s), + jsNumber(WSAETOOMANYREFS)); #endif #ifdef WSAETIMEDOUT - put(Identifier::fromString(vm, "WSAETIMEDOUT"_s), jsNumber(WSAETIMEDOUT)); + put(Identifier::fromString(vm, "WSAETIMEDOUT"_s), jsNumber(WSAETIMEDOUT)); #endif #ifdef WSAECONNREFUSED - put(Identifier::fromString(vm, "WSAECONNREFUSED"_s), - jsNumber(WSAECONNREFUSED)); + put(Identifier::fromString(vm, "WSAECONNREFUSED"_s), + jsNumber(WSAECONNREFUSED)); #endif #ifdef WSAELOOP - put(Identifier::fromString(vm, "WSAELOOP"_s), jsNumber(WSAELOOP)); + put(Identifier::fromString(vm, "WSAELOOP"_s), jsNumber(WSAELOOP)); #endif #ifdef WSAENAMETOOLONG - put(Identifier::fromString(vm, "WSAENAMETOOLONG"_s), - jsNumber(WSAENAMETOOLONG)); + put(Identifier::fromString(vm, "WSAENAMETOOLONG"_s), + jsNumber(WSAENAMETOOLONG)); #endif #ifdef WSAEHOSTDOWN - put(Identifier::fromString(vm, "WSAEHOSTDOWN"_s), jsNumber(WSAEHOSTDOWN)); + put(Identifier::fromString(vm, "WSAEHOSTDOWN"_s), jsNumber(WSAEHOSTDOWN)); #endif #ifdef WSAEHOSTUNREACH - put(Identifier::fromString(vm, "WSAEHOSTUNREACH"_s), - jsNumber(WSAEHOSTUNREACH)); + put(Identifier::fromString(vm, "WSAEHOSTUNREACH"_s), + jsNumber(WSAEHOSTUNREACH)); #endif #ifdef WSAENOTEMPTY - put(Identifier::fromString(vm, "WSAENOTEMPTY"_s), jsNumber(WSAENOTEMPTY)); + put(Identifier::fromString(vm, "WSAENOTEMPTY"_s), jsNumber(WSAENOTEMPTY)); #endif #ifdef WSAEPROCLIM - put(Identifier::fromString(vm, "WSAEPROCLIM"_s), jsNumber(WSAEPROCLIM)); + put(Identifier::fromString(vm, "WSAEPROCLIM"_s), jsNumber(WSAEPROCLIM)); #endif #ifdef WSAEUSERS - put(Identifier::fromString(vm, "WSAEUSERS"_s), jsNumber(WSAEUSERS)); + put(Identifier::fromString(vm, "WSAEUSERS"_s), jsNumber(WSAEUSERS)); #endif #ifdef WSAEDQUOT - put(Identifier::fromString(vm, "WSAEDQUOT"_s), jsNumber(WSAEDQUOT)); + put(Identifier::fromString(vm, "WSAEDQUOT"_s), jsNumber(WSAEDQUOT)); #endif #ifdef WSAESTALE - put(Identifier::fromString(vm, "WSAESTALE"_s), jsNumber(WSAESTALE)); + put(Identifier::fromString(vm, "WSAESTALE"_s), jsNumber(WSAESTALE)); #endif #ifdef WSAEREMOTE - put(Identifier::fromString(vm, "WSAEREMOTE"_s), jsNumber(WSAEREMOTE)); + put(Identifier::fromString(vm, "WSAEREMOTE"_s), jsNumber(WSAEREMOTE)); #endif #ifdef WSASYSNOTREADY - put(Identifier::fromString(vm, "WSASYSNOTREADY"_s), jsNumber(WSASYSNOTREADY)); + put(Identifier::fromString(vm, "WSASYSNOTREADY"_s), jsNumber(WSASYSNOTREADY)); #endif #ifdef WSAVERNOTSUPPORTED - put(Identifier::fromString(vm, "WSAVERNOTSUPPORTED"_s), - jsNumber(WSAVERNOTSUPPORTED)); + put(Identifier::fromString(vm, "WSAVERNOTSUPPORTED"_s), + jsNumber(WSAVERNOTSUPPORTED)); #endif #ifdef WSANOTINITIALISED - put(Identifier::fromString(vm, "WSANOTINITIALISED"_s), - jsNumber(WSANOTINITIALISED)); + put(Identifier::fromString(vm, "WSANOTINITIALISED"_s), + jsNumber(WSANOTINITIALISED)); #endif #ifdef WSAEDISCON - put(Identifier::fromString(vm, "WSAEDISCON"_s), jsNumber(WSAEDISCON)); + put(Identifier::fromString(vm, "WSAEDISCON"_s), jsNumber(WSAEDISCON)); #endif #ifdef WSAENOMORE - put(Identifier::fromString(vm, "WSAENOMORE"_s), jsNumber(WSAENOMORE)); + put(Identifier::fromString(vm, "WSAENOMORE"_s), jsNumber(WSAENOMORE)); #endif #ifdef WSAECANCELLED - put(Identifier::fromString(vm, "WSAECANCELLED"_s), jsNumber(WSAECANCELLED)); + put(Identifier::fromString(vm, "WSAECANCELLED"_s), jsNumber(WSAECANCELLED)); #endif #ifdef WSAEINVALIDPROCTABLE - put(Identifier::fromString(vm, "WSAEINVALIDPROCTABLE"_s), - jsNumber(WSAEINVALIDPROCTABLE)); + put(Identifier::fromString(vm, "WSAEINVALIDPROCTABLE"_s), + jsNumber(WSAEINVALIDPROCTABLE)); #endif #ifdef WSAEINVALIDPROVIDER - put(Identifier::fromString(vm, "WSAEINVALIDPROVIDER"_s), - jsNumber(WSAEINVALIDPROVIDER)); + put(Identifier::fromString(vm, "WSAEINVALIDPROVIDER"_s), + jsNumber(WSAEINVALIDPROVIDER)); #endif #ifdef WSAEPROVIDERFAILEDINIT - put(Identifier::fromString(vm, "WSAEPROVIDERFAILEDINIT"_s), - jsNumber(WSAEPROVIDERFAILEDINIT)); + put(Identifier::fromString(vm, "WSAEPROVIDERFAILEDINIT"_s), + jsNumber(WSAEPROVIDERFAILEDINIT)); #endif #ifdef WSASYSCALLFAILURE - put(Identifier::fromString(vm, "WSASYSCALLFAILURE"_s), - jsNumber(WSASYSCALLFAILURE)); + put(Identifier::fromString(vm, "WSASYSCALLFAILURE"_s), + jsNumber(WSASYSCALLFAILURE)); #endif #ifdef WSASERVICE_NOT_FOUND - put(Identifier::fromString(vm, "WSASERVICE_NOT_FOUND"_s), - jsNumber(WSASERVICE_NOT_FOUND)); + put(Identifier::fromString(vm, "WSASERVICE_NOT_FOUND"_s), + jsNumber(WSASERVICE_NOT_FOUND)); #endif #ifdef WSATYPE_NOT_FOUND - put(Identifier::fromString(vm, "WSATYPE_NOT_FOUND"_s), - jsNumber(WSATYPE_NOT_FOUND)); + put(Identifier::fromString(vm, "WSATYPE_NOT_FOUND"_s), + jsNumber(WSATYPE_NOT_FOUND)); #endif #ifdef WSA_E_NO_MORE - put(Identifier::fromString(vm, "WSA_E_NO_MORE"_s), jsNumber(WSA_E_NO_MORE)); + put(Identifier::fromString(vm, "WSA_E_NO_MORE"_s), jsNumber(WSA_E_NO_MORE)); #endif #ifdef WSA_E_CANCELLED - put(Identifier::fromString(vm, "WSA_E_CANCELLED"_s), - jsNumber(WSA_E_CANCELLED)); + put(Identifier::fromString(vm, "WSA_E_CANCELLED"_s), + jsNumber(WSA_E_CANCELLED)); #endif #ifdef WSAEREFUSED - put(Identifier::fromString(vm, "WSAEREFUSED"_s), jsNumber(WSAEREFUSED)); + put(Identifier::fromString(vm, "WSAEREFUSED"_s), jsNumber(WSAEREFUSED)); #endif - put(Identifier::fromString(vm, "PRIORITY_LOW"_s), jsNumber(19)); - put(Identifier::fromString(vm, "PRIORITY_BELOW_NORMAL"_s), jsNumber(10)); - put(Identifier::fromString(vm, "PRIORITY_NORMAL"_s), jsNumber(0)); - put(Identifier::fromString(vm, "PRIORITY_ABOVE_NORMAL"_s), jsNumber(-7)); - put(Identifier::fromString(vm, "PRIORITY_HIGH"_s), jsNumber(-14)); - put(Identifier::fromString(vm, "PRIORITY_HIGHEST"_s), jsNumber(-20)); + put(Identifier::fromString(vm, "PRIORITY_LOW"_s), jsNumber(19)); + put(Identifier::fromString(vm, "PRIORITY_BELOW_NORMAL"_s), jsNumber(10)); + put(Identifier::fromString(vm, "PRIORITY_NORMAL"_s), jsNumber(0)); + put(Identifier::fromString(vm, "PRIORITY_ABOVE_NORMAL"_s), jsNumber(-7)); + put(Identifier::fromString(vm, "PRIORITY_HIGH"_s), jsNumber(-14)); + put(Identifier::fromString(vm, "PRIORITY_HIGHEST"_s), jsNumber(-20)); #ifdef SIGHUP - put(Identifier::fromString(vm, "SIGHUP"_s), jsNumber(SIGHUP)); + put(Identifier::fromString(vm, "SIGHUP"_s), jsNumber(SIGHUP)); #endif #ifdef SIGINT - put(Identifier::fromString(vm, "SIGINT"_s), jsNumber(SIGINT)); + put(Identifier::fromString(vm, "SIGINT"_s), jsNumber(SIGINT)); #endif #ifdef SIGQUIT - put(Identifier::fromString(vm, "SIGQUIT"_s), jsNumber(SIGQUIT)); + put(Identifier::fromString(vm, "SIGQUIT"_s), jsNumber(SIGQUIT)); #endif #ifdef SIGILL - put(Identifier::fromString(vm, "SIGILL"_s), jsNumber(SIGILL)); + put(Identifier::fromString(vm, "SIGILL"_s), jsNumber(SIGILL)); #endif #ifdef SIGTRAP - put(Identifier::fromString(vm, "SIGTRAP"_s), jsNumber(SIGTRAP)); + put(Identifier::fromString(vm, "SIGTRAP"_s), jsNumber(SIGTRAP)); #endif #ifdef SIGABRT - put(Identifier::fromString(vm, "SIGABRT"_s), jsNumber(SIGABRT)); + put(Identifier::fromString(vm, "SIGABRT"_s), jsNumber(SIGABRT)); #endif #ifdef SIGIOT - put(Identifier::fromString(vm, "SIGIOT"_s), jsNumber(SIGIOT)); + put(Identifier::fromString(vm, "SIGIOT"_s), jsNumber(SIGIOT)); #endif #ifdef SIGBUS - put(Identifier::fromString(vm, "SIGBUS"_s), jsNumber(SIGBUS)); + put(Identifier::fromString(vm, "SIGBUS"_s), jsNumber(SIGBUS)); #endif #ifdef SIGFPE - put(Identifier::fromString(vm, "SIGFPE"_s), jsNumber(SIGFPE)); + put(Identifier::fromString(vm, "SIGFPE"_s), jsNumber(SIGFPE)); #endif #ifdef SIGKILL - put(Identifier::fromString(vm, "SIGKILL"_s), jsNumber(SIGKILL)); + put(Identifier::fromString(vm, "SIGKILL"_s), jsNumber(SIGKILL)); #endif #ifdef SIGUSR1 - put(Identifier::fromString(vm, "SIGUSR1"_s), jsNumber(SIGUSR1)); + put(Identifier::fromString(vm, "SIGUSR1"_s), jsNumber(SIGUSR1)); #endif #ifdef SIGSEGV - put(Identifier::fromString(vm, "SIGSEGV"_s), jsNumber(SIGSEGV)); + put(Identifier::fromString(vm, "SIGSEGV"_s), jsNumber(SIGSEGV)); #endif #ifdef SIGUSR2 - put(Identifier::fromString(vm, "SIGUSR2"_s), jsNumber(SIGUSR2)); + put(Identifier::fromString(vm, "SIGUSR2"_s), jsNumber(SIGUSR2)); #endif #ifdef SIGPIPE - put(Identifier::fromString(vm, "SIGPIPE"_s), jsNumber(SIGPIPE)); + put(Identifier::fromString(vm, "SIGPIPE"_s), jsNumber(SIGPIPE)); #endif #ifdef SIGALRM - put(Identifier::fromString(vm, "SIGALRM"_s), jsNumber(SIGALRM)); + put(Identifier::fromString(vm, "SIGALRM"_s), jsNumber(SIGALRM)); #endif #ifdef SIGTERM - put(Identifier::fromString(vm, "SIGTERM"_s), jsNumber(SIGTERM)); + put(Identifier::fromString(vm, "SIGTERM"_s), jsNumber(SIGTERM)); #endif #ifdef SIGCHLD - put(Identifier::fromString(vm, "SIGCHLD"_s), jsNumber(SIGCHLD)); + put(Identifier::fromString(vm, "SIGCHLD"_s), jsNumber(SIGCHLD)); #endif #ifdef SIGSTKFLT - put(Identifier::fromString(vm, "SIGSTKFLT"_s), jsNumber(SIGSTKFLT)); + put(Identifier::fromString(vm, "SIGSTKFLT"_s), jsNumber(SIGSTKFLT)); #endif #ifdef SIGCONT - put(Identifier::fromString(vm, "SIGCONT"_s), jsNumber(SIGCONT)); + put(Identifier::fromString(vm, "SIGCONT"_s), jsNumber(SIGCONT)); #endif #ifdef SIGSTOP - put(Identifier::fromString(vm, "SIGSTOP"_s), jsNumber(SIGSTOP)); + put(Identifier::fromString(vm, "SIGSTOP"_s), jsNumber(SIGSTOP)); #endif #ifdef SIGTSTP - put(Identifier::fromString(vm, "SIGTSTP"_s), jsNumber(SIGTSTP)); + put(Identifier::fromString(vm, "SIGTSTP"_s), jsNumber(SIGTSTP)); #endif #ifdef SIGBREAK - put(Identifier::fromString(vm, "SIGBREAK"_s), jsNumber(SIGBREAK)); + put(Identifier::fromString(vm, "SIGBREAK"_s), jsNumber(SIGBREAK)); #endif #ifdef SIGTTIN - put(Identifier::fromString(vm, "SIGTTIN"_s), jsNumber(SIGTTIN)); + put(Identifier::fromString(vm, "SIGTTIN"_s), jsNumber(SIGTTIN)); #endif #ifdef SIGTTOU - put(Identifier::fromString(vm, "SIGTTOU"_s), jsNumber(SIGTTOU)); + put(Identifier::fromString(vm, "SIGTTOU"_s), jsNumber(SIGTTOU)); #endif #ifdef SIGURG - put(Identifier::fromString(vm, "SIGURG"_s), jsNumber(SIGURG)); + put(Identifier::fromString(vm, "SIGURG"_s), jsNumber(SIGURG)); #endif #ifdef SIGXCPU - put(Identifier::fromString(vm, "SIGXCPU"_s), jsNumber(SIGXCPU)); + put(Identifier::fromString(vm, "SIGXCPU"_s), jsNumber(SIGXCPU)); #endif #ifdef SIGXFSZ - put(Identifier::fromString(vm, "SIGXFSZ"_s), jsNumber(SIGXFSZ)); + put(Identifier::fromString(vm, "SIGXFSZ"_s), jsNumber(SIGXFSZ)); #endif #ifdef SIGVTALRM - put(Identifier::fromString(vm, "SIGVTALRM"_s), jsNumber(SIGVTALRM)); + put(Identifier::fromString(vm, "SIGVTALRM"_s), jsNumber(SIGVTALRM)); #endif #ifdef SIGPROF - put(Identifier::fromString(vm, "SIGPROF"_s), jsNumber(SIGPROF)); + put(Identifier::fromString(vm, "SIGPROF"_s), jsNumber(SIGPROF)); #endif #ifdef SIGWINCH - put(Identifier::fromString(vm, "SIGWINCH"_s), jsNumber(SIGWINCH)); + put(Identifier::fromString(vm, "SIGWINCH"_s), jsNumber(SIGWINCH)); #endif #ifdef SIGIO - put(Identifier::fromString(vm, "SIGIO"_s), jsNumber(SIGIO)); + put(Identifier::fromString(vm, "SIGIO"_s), jsNumber(SIGIO)); #endif #ifdef SIGPOLL - put(Identifier::fromString(vm, "SIGPOLL"_s), jsNumber(SIGPOLL)); + put(Identifier::fromString(vm, "SIGPOLL"_s), jsNumber(SIGPOLL)); #endif #ifdef SIGLOST - put(Identifier::fromString(vm, "SIGLOST"_s), jsNumber(SIGLOST)); + put(Identifier::fromString(vm, "SIGLOST"_s), jsNumber(SIGLOST)); #endif #ifdef SIGPWR - put(Identifier::fromString(vm, "SIGPWR"_s), jsNumber(SIGPWR)); + put(Identifier::fromString(vm, "SIGPWR"_s), jsNumber(SIGPWR)); #endif #ifdef SIGINFO - put(Identifier::fromString(vm, "SIGINFO"_s), jsNumber(SIGINFO)); + put(Identifier::fromString(vm, "SIGINFO"_s), jsNumber(SIGINFO)); #endif #ifdef SIGSYS - put(Identifier::fromString(vm, "SIGSYS"_s), jsNumber(SIGSYS)); + put(Identifier::fromString(vm, "SIGSYS"_s), jsNumber(SIGSYS)); #endif #ifdef SIGUNUSED - put(Identifier::fromString(vm, "SIGUNUSED"_s), jsNumber(SIGUNUSED)); + put(Identifier::fromString(vm, "SIGUNUSED"_s), jsNumber(SIGUNUSED)); #endif - put(Identifier::fromString(vm, "UV_FS_SYMLINK_DIR"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_FS_SYMLINK_JUNCTION"_s), jsNumber(2)); - put(Identifier::fromString(vm, "O_RDONLY"_s), jsNumber(O_RDONLY)); - put(Identifier::fromString(vm, "O_WRONLY"_s), jsNumber(O_WRONLY)); - put(Identifier::fromString(vm, "O_RDWR"_s), jsNumber(O_RDWR)); + put(Identifier::fromString(vm, "UV_FS_SYMLINK_DIR"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_FS_SYMLINK_JUNCTION"_s), jsNumber(2)); + put(Identifier::fromString(vm, "O_RDONLY"_s), jsNumber(O_RDONLY)); + put(Identifier::fromString(vm, "O_WRONLY"_s), jsNumber(O_WRONLY)); + put(Identifier::fromString(vm, "O_RDWR"_s), jsNumber(O_RDWR)); - put(Identifier::fromString(vm, "UV_DIRENT_UNKNOWN"_s), jsNumber(0)); - put(Identifier::fromString(vm, "UV_DIRENT_FILE"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_DIRENT_DIR"_s), jsNumber(2)); - put(Identifier::fromString(vm, "UV_DIRENT_LINK"_s), jsNumber(3)); - put(Identifier::fromString(vm, "UV_DIRENT_FIFO"_s), jsNumber(4)); - put(Identifier::fromString(vm, "UV_DIRENT_SOCKET"_s), jsNumber(5)); - put(Identifier::fromString(vm, "UV_DIRENT_CHAR"_s), jsNumber(6)); - put(Identifier::fromString(vm, "UV_DIRENT_BLOCK"_s), jsNumber(7)); + put(Identifier::fromString(vm, "UV_DIRENT_UNKNOWN"_s), jsNumber(0)); + put(Identifier::fromString(vm, "UV_DIRENT_FILE"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_DIRENT_DIR"_s), jsNumber(2)); + put(Identifier::fromString(vm, "UV_DIRENT_LINK"_s), jsNumber(3)); + put(Identifier::fromString(vm, "UV_DIRENT_FIFO"_s), jsNumber(4)); + put(Identifier::fromString(vm, "UV_DIRENT_SOCKET"_s), jsNumber(5)); + put(Identifier::fromString(vm, "UV_DIRENT_CHAR"_s), jsNumber(6)); + put(Identifier::fromString(vm, "UV_DIRENT_BLOCK"_s), jsNumber(7)); - put(Identifier::fromString(vm, "S_IFMT"_s), jsNumber(S_IFMT)); - put(Identifier::fromString(vm, "S_IFREG"_s), jsNumber(S_IFREG)); - put(Identifier::fromString(vm, "S_IFDIR"_s), jsNumber(S_IFDIR)); - put(Identifier::fromString(vm, "S_IFCHR"_s), jsNumber(S_IFCHR)); + put(Identifier::fromString(vm, "S_IFMT"_s), jsNumber(S_IFMT)); + put(Identifier::fromString(vm, "S_IFREG"_s), jsNumber(S_IFREG)); + put(Identifier::fromString(vm, "S_IFDIR"_s), jsNumber(S_IFDIR)); + put(Identifier::fromString(vm, "S_IFCHR"_s), jsNumber(S_IFCHR)); #ifdef S_IFBLK - put(Identifier::fromString(vm, "S_IFBLK"_s), jsNumber(S_IFBLK)); + put(Identifier::fromString(vm, "S_IFBLK"_s), jsNumber(S_IFBLK)); #endif #ifdef S_IFIFO - put(Identifier::fromString(vm, "S_IFIFO"_s), jsNumber(S_IFIFO)); + put(Identifier::fromString(vm, "S_IFIFO"_s), jsNumber(S_IFIFO)); #endif #ifdef S_IFLNK - put(Identifier::fromString(vm, "S_IFLNK"_s), jsNumber(S_IFLNK)); + put(Identifier::fromString(vm, "S_IFLNK"_s), jsNumber(S_IFLNK)); #endif #ifdef S_IFSOCK - put(Identifier::fromString(vm, "S_IFSOCK"_s), jsNumber(S_IFSOCK)); + put(Identifier::fromString(vm, "S_IFSOCK"_s), jsNumber(S_IFSOCK)); #endif #ifdef O_CREAT - put(Identifier::fromString(vm, "O_CREAT"_s), jsNumber(O_CREAT)); + put(Identifier::fromString(vm, "O_CREAT"_s), jsNumber(O_CREAT)); #endif #ifdef O_EXCL - put(Identifier::fromString(vm, "O_EXCL"_s), jsNumber(O_EXCL)); + put(Identifier::fromString(vm, "O_EXCL"_s), jsNumber(O_EXCL)); #endif - put(Identifier::fromString(vm, "UV_FS_O_FILEMAP"_s), jsNumber(0)); + put(Identifier::fromString(vm, "UV_FS_O_FILEMAP"_s), jsNumber(0)); #ifdef O_NOCTTY - put(Identifier::fromString(vm, "O_NOCTTY"_s), jsNumber(O_NOCTTY)); + put(Identifier::fromString(vm, "O_NOCTTY"_s), jsNumber(O_NOCTTY)); #endif #ifdef O_TRUNC - put(Identifier::fromString(vm, "O_TRUNC"_s), jsNumber(O_TRUNC)); + put(Identifier::fromString(vm, "O_TRUNC"_s), jsNumber(O_TRUNC)); #endif #ifdef O_APPEND - put(Identifier::fromString(vm, "O_APPEND"_s), jsNumber(O_APPEND)); + put(Identifier::fromString(vm, "O_APPEND"_s), jsNumber(O_APPEND)); #endif #ifdef O_DIRECTORY - put(Identifier::fromString(vm, "O_DIRECTORY"_s), jsNumber(O_DIRECTORY)); + put(Identifier::fromString(vm, "O_DIRECTORY"_s), jsNumber(O_DIRECTORY)); #endif #ifdef O_NOATIME - put(Identifier::fromString(vm, "O_NOATIME"_s), jsNumber(O_NOATIME)); + put(Identifier::fromString(vm, "O_NOATIME"_s), jsNumber(O_NOATIME)); #endif #ifdef O_NOFOLLOW - put(Identifier::fromString(vm, "O_NOFOLLOW"_s), jsNumber(O_NOFOLLOW)); + put(Identifier::fromString(vm, "O_NOFOLLOW"_s), jsNumber(O_NOFOLLOW)); #endif #ifdef O_SYNC - put(Identifier::fromString(vm, "O_SYNC"_s), jsNumber(O_SYNC)); + put(Identifier::fromString(vm, "O_SYNC"_s), jsNumber(O_SYNC)); #endif #ifdef O_DSYNC - put(Identifier::fromString(vm, "O_DSYNC"_s), jsNumber(O_DSYNC)); + put(Identifier::fromString(vm, "O_DSYNC"_s), jsNumber(O_DSYNC)); #endif #ifdef O_SYMLINK - put(Identifier::fromString(vm, "O_SYMLINK"_s), jsNumber(O_SYMLINK)); + put(Identifier::fromString(vm, "O_SYMLINK"_s), jsNumber(O_SYMLINK)); #endif #ifdef O_DIRECT - put(Identifier::fromString(vm, "O_DIRECT"_s), jsNumber(O_DIRECT)); + put(Identifier::fromString(vm, "O_DIRECT"_s), jsNumber(O_DIRECT)); #endif #ifdef O_NONBLOCK - put(Identifier::fromString(vm, "O_NONBLOCK"_s), jsNumber(O_NONBLOCK)); + put(Identifier::fromString(vm, "O_NONBLOCK"_s), jsNumber(O_NONBLOCK)); #endif #ifdef S_IRWXU - put(Identifier::fromString(vm, "S_IRWXU"_s), jsNumber(S_IRWXU)); + put(Identifier::fromString(vm, "S_IRWXU"_s), jsNumber(S_IRWXU)); #endif #ifdef S_IRUSR - put(Identifier::fromString(vm, "S_IRUSR"_s), jsNumber(S_IRUSR)); + put(Identifier::fromString(vm, "S_IRUSR"_s), jsNumber(S_IRUSR)); #endif #ifdef S_IWUSR - put(Identifier::fromString(vm, "S_IWUSR"_s), jsNumber(S_IWUSR)); + put(Identifier::fromString(vm, "S_IWUSR"_s), jsNumber(S_IWUSR)); #endif #ifdef S_IXUSR - put(Identifier::fromString(vm, "S_IXUSR"_s), jsNumber(S_IXUSR)); + put(Identifier::fromString(vm, "S_IXUSR"_s), jsNumber(S_IXUSR)); #endif #ifdef S_IRWXG - put(Identifier::fromString(vm, "S_IRWXG"_s), jsNumber(S_IRWXG)); + put(Identifier::fromString(vm, "S_IRWXG"_s), jsNumber(S_IRWXG)); #endif #ifdef S_IRGRP - put(Identifier::fromString(vm, "S_IRGRP"_s), jsNumber(S_IRGRP)); + put(Identifier::fromString(vm, "S_IRGRP"_s), jsNumber(S_IRGRP)); #endif #ifdef S_IWGRP - put(Identifier::fromString(vm, "S_IWGRP"_s), jsNumber(S_IWGRP)); + put(Identifier::fromString(vm, "S_IWGRP"_s), jsNumber(S_IWGRP)); #endif #ifdef S_IXGRP - put(Identifier::fromString(vm, "S_IXGRP"_s), jsNumber(S_IXGRP)); + put(Identifier::fromString(vm, "S_IXGRP"_s), jsNumber(S_IXGRP)); #endif #ifdef S_IRWXO - put(Identifier::fromString(vm, "S_IRWXO"_s), jsNumber(S_IRWXO)); + put(Identifier::fromString(vm, "S_IRWXO"_s), jsNumber(S_IRWXO)); #endif #ifdef S_IROTH - put(Identifier::fromString(vm, "S_IROTH"_s), jsNumber(S_IROTH)); + put(Identifier::fromString(vm, "S_IROTH"_s), jsNumber(S_IROTH)); #endif #ifdef S_IWOTH - put(Identifier::fromString(vm, "S_IWOTH"_s), jsNumber(S_IWOTH)); + put(Identifier::fromString(vm, "S_IWOTH"_s), jsNumber(S_IWOTH)); #endif #ifdef S_IXOTH - put(Identifier::fromString(vm, "S_IXOTH"_s), jsNumber(S_IXOTH)); + put(Identifier::fromString(vm, "S_IXOTH"_s), jsNumber(S_IXOTH)); #endif #ifdef F_OK - put(Identifier::fromString(vm, "F_OK"_s), jsNumber(F_OK)); + put(Identifier::fromString(vm, "F_OK"_s), jsNumber(F_OK)); #endif #ifdef R_OK - put(Identifier::fromString(vm, "R_OK"_s), jsNumber(R_OK)); + put(Identifier::fromString(vm, "R_OK"_s), jsNumber(R_OK)); #endif #ifdef W_OK - put(Identifier::fromString(vm, "W_OK"_s), jsNumber(W_OK)); + put(Identifier::fromString(vm, "W_OK"_s), jsNumber(W_OK)); #endif #ifdef X_OK - put(Identifier::fromString(vm, "X_OK"_s), jsNumber(X_OK)); + put(Identifier::fromString(vm, "X_OK"_s), jsNumber(X_OK)); #endif - put(Identifier::fromString(vm, "UV_FS_COPYFILE_EXCL"_s), jsNumber(1)); - put(Identifier::fromString(vm, "COPYFILE_EXCL"_s), jsNumber(1)); - put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE"_s), jsNumber(2)); - put(Identifier::fromString(vm, "COPYFILE_FICLONE"_s), jsNumber(2)); - put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE_FORCE"_s), - jsNumber(4)); - put(Identifier::fromString(vm, "COPYFILE_FICLONE_FORCE"_s), jsNumber(4)); + put(Identifier::fromString(vm, "UV_FS_COPYFILE_EXCL"_s), jsNumber(1)); + put(Identifier::fromString(vm, "COPYFILE_EXCL"_s), jsNumber(1)); + put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE"_s), jsNumber(2)); + put(Identifier::fromString(vm, "COPYFILE_FICLONE"_s), jsNumber(2)); + put(Identifier::fromString(vm, "UV_FS_COPYFILE_FICLONE_FORCE"_s), + jsNumber(4)); + put(Identifier::fromString(vm, "COPYFILE_FICLONE_FORCE"_s), jsNumber(4)); #ifdef OPENSSL_VERSION_NUMBER - put(Identifier::fromString(vm, "OPENSSL_VERSION_NUMBER"_s), - jsNumber(OPENSSL_VERSION_NUMBER)); + put(Identifier::fromString(vm, "OPENSSL_VERSION_NUMBER"_s), + jsNumber(OPENSSL_VERSION_NUMBER)); #endif #ifdef SSL_OP_ALL - put(Identifier::fromString(vm, "SSL_OP_ALL"_s), jsNumber(SSL_OP_ALL)); + put(Identifier::fromString(vm, "SSL_OP_ALL"_s), jsNumber(SSL_OP_ALL)); #endif #ifdef SSL_OP_ALLOW_NO_DHE_KEX - put(Identifier::fromString(vm, "SSL_OP_ALLOW_NO_DHE_KEX"_s), - jsNumber(SSL_OP_ALLOW_NO_DHE_KEX)); + put(Identifier::fromString(vm, "SSL_OP_ALLOW_NO_DHE_KEX"_s), + jsNumber(SSL_OP_ALLOW_NO_DHE_KEX)); #endif #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION - put(Identifier::fromString(vm, "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION"_s), - jsNumber(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)); + put(Identifier::fromString(vm, "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION"_s), + jsNumber(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)); #endif #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE - put(Identifier::fromString(vm, "SSL_OP_CIPHER_SERVER_PREFERENCE"_s), - jsNumber(SSL_OP_CIPHER_SERVER_PREFERENCE)); + put(Identifier::fromString(vm, "SSL_OP_CIPHER_SERVER_PREFERENCE"_s), + jsNumber(SSL_OP_CIPHER_SERVER_PREFERENCE)); #endif #ifdef SSL_OP_CISCO_ANYCONNECT - put(Identifier::fromString(vm, "SSL_OP_CISCO_ANYCONNECT"_s), - jsNumber(SSL_OP_CISCO_ANYCONNECT)); + put(Identifier::fromString(vm, "SSL_OP_CISCO_ANYCONNECT"_s), + jsNumber(SSL_OP_CISCO_ANYCONNECT)); #endif #ifdef SSL_OP_COOKIE_EXCHANGE - put(Identifier::fromString(vm, "SSL_OP_COOKIE_EXCHANGE"_s), - jsNumber(SSL_OP_COOKIE_EXCHANGE)); + put(Identifier::fromString(vm, "SSL_OP_COOKIE_EXCHANGE"_s), + jsNumber(SSL_OP_COOKIE_EXCHANGE)); #endif #ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG - put(Identifier::fromString(vm, "SSL_OP_CRYPTOPRO_TLSEXT_BUG"_s), - jsNumber(SSL_OP_CRYPTOPRO_TLSEXT_BUG)); + put(Identifier::fromString(vm, "SSL_OP_CRYPTOPRO_TLSEXT_BUG"_s), + jsNumber(SSL_OP_CRYPTOPRO_TLSEXT_BUG)); #endif #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS - put(Identifier::fromString(vm, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS"_s), - jsNumber(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); + put(Identifier::fromString(vm, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS"_s), + jsNumber(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); #endif #ifdef SSL_OP_LEGACY_SERVER_CONNECT - put(Identifier::fromString(vm, "SSL_OP_LEGACY_SERVER_CONNECT"_s), - jsNumber(SSL_OP_LEGACY_SERVER_CONNECT)); + put(Identifier::fromString(vm, "SSL_OP_LEGACY_SERVER_CONNECT"_s), + jsNumber(SSL_OP_LEGACY_SERVER_CONNECT)); #endif #ifdef SSL_OP_NO_COMPRESSION - put(Identifier::fromString(vm, "SSL_OP_NO_COMPRESSION"_s), - jsNumber(SSL_OP_NO_COMPRESSION)); + put(Identifier::fromString(vm, "SSL_OP_NO_COMPRESSION"_s), + jsNumber(SSL_OP_NO_COMPRESSION)); #endif #ifdef SSL_OP_NO_ENCRYPT_THEN_MAC - put(Identifier::fromString(vm, "SSL_OP_NO_ENCRYPT_THEN_MAC"_s), - jsNumber(SSL_OP_NO_ENCRYPT_THEN_MAC)); + put(Identifier::fromString(vm, "SSL_OP_NO_ENCRYPT_THEN_MAC"_s), + jsNumber(SSL_OP_NO_ENCRYPT_THEN_MAC)); #endif #ifdef SSL_OP_NO_QUERY_MTU - put(Identifier::fromString(vm, "SSL_OP_NO_QUERY_MTU"_s), - jsNumber(SSL_OP_NO_QUERY_MTU)); + put(Identifier::fromString(vm, "SSL_OP_NO_QUERY_MTU"_s), + jsNumber(SSL_OP_NO_QUERY_MTU)); #endif #ifdef SSL_OP_NO_RENEGOTIATION - put(Identifier::fromString(vm, "SSL_OP_NO_RENEGOTIATION"_s), - jsNumber(SSL_OP_NO_RENEGOTIATION)); + put(Identifier::fromString(vm, "SSL_OP_NO_RENEGOTIATION"_s), + jsNumber(SSL_OP_NO_RENEGOTIATION)); #endif #ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION - put(Identifier::fromString(vm, - "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION"_s), - jsNumber(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)); + put(Identifier::fromString(vm, + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION"_s), + jsNumber(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)); #endif #ifdef SSL_OP_NO_SSLv2 - put(Identifier::fromString(vm, "SSL_OP_NO_SSLv2"_s), - jsNumber(SSL_OP_NO_SSLv2)); + put(Identifier::fromString(vm, "SSL_OP_NO_SSLv2"_s), + jsNumber(SSL_OP_NO_SSLv2)); #endif #ifdef SSL_OP_NO_SSLv3 - put(Identifier::fromString(vm, "SSL_OP_NO_SSLv3"_s), - jsNumber(SSL_OP_NO_SSLv3)); + put(Identifier::fromString(vm, "SSL_OP_NO_SSLv3"_s), + jsNumber(SSL_OP_NO_SSLv3)); #endif #ifdef SSL_OP_NO_TICKET - put(Identifier::fromString(vm, "SSL_OP_NO_TICKET"_s), - jsNumber(SSL_OP_NO_TICKET)); + put(Identifier::fromString(vm, "SSL_OP_NO_TICKET"_s), + jsNumber(SSL_OP_NO_TICKET)); #endif #ifdef SSL_OP_NO_TLSv1 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1"_s), - jsNumber(SSL_OP_NO_TLSv1)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1"_s), + jsNumber(SSL_OP_NO_TLSv1)); #endif #ifdef SSL_OP_NO_TLSv1_1 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_1"_s), - jsNumber(SSL_OP_NO_TLSv1_1)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_1"_s), + jsNumber(SSL_OP_NO_TLSv1_1)); #endif #ifdef SSL_OP_NO_TLSv1_2 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_2"_s), - jsNumber(SSL_OP_NO_TLSv1_2)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_2"_s), + jsNumber(SSL_OP_NO_TLSv1_2)); #endif #ifdef SSL_OP_NO_TLSv1_3 - put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_3"_s), - jsNumber(SSL_OP_NO_TLSv1_3)); + put(Identifier::fromString(vm, "SSL_OP_NO_TLSv1_3"_s), + jsNumber(SSL_OP_NO_TLSv1_3)); #endif #ifdef SSL_OP_PRIORITIZE_CHACHA - put(Identifier::fromString(vm, "SSL_OP_PRIORITIZE_CHACHA"_s), - jsNumber(SSL_OP_PRIORITIZE_CHACHA)); + put(Identifier::fromString(vm, "SSL_OP_PRIORITIZE_CHACHA"_s), + jsNumber(SSL_OP_PRIORITIZE_CHACHA)); #endif #ifdef SSL_OP_TLS_ROLLBACK_BUG - put(Identifier::fromString(vm, "SSL_OP_TLS_ROLLBACK_BUG"_s), - jsNumber(SSL_OP_TLS_ROLLBACK_BUG)); + put(Identifier::fromString(vm, "SSL_OP_TLS_ROLLBACK_BUG"_s), + jsNumber(SSL_OP_TLS_ROLLBACK_BUG)); #endif #ifndef OPENSSL_NO_ENGINE #ifdef ENGINE_METHOD_RSA - put(Identifier::fromString(vm, "ENGINE_METHOD_RSA"_s), - jsNumber(ENGINE_METHOD_RSA)); + put(Identifier::fromString(vm, "ENGINE_METHOD_RSA"_s), + jsNumber(ENGINE_METHOD_RSA)); #endif #ifdef ENGINE_METHOD_DSA - put(Identifier::fromString(vm, "ENGINE_METHOD_DSA"_s), - jsNumber(ENGINE_METHOD_DSA)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DSA"_s), + jsNumber(ENGINE_METHOD_DSA)); #endif #ifdef ENGINE_METHOD_DH - put(Identifier::fromString(vm, "ENGINE_METHOD_DH"_s), - jsNumber(ENGINE_METHOD_DH)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DH"_s), + jsNumber(ENGINE_METHOD_DH)); #endif #ifdef ENGINE_METHOD_RAND - put(Identifier::fromString(vm, "ENGINE_METHOD_RAND"_s), - jsNumber(ENGINE_METHOD_RAND)); + put(Identifier::fromString(vm, "ENGINE_METHOD_RAND"_s), + jsNumber(ENGINE_METHOD_RAND)); #endif #ifdef ENGINE_METHOD_EC - put(Identifier::fromString(vm, "ENGINE_METHOD_EC"_s), - jsNumber(ENGINE_METHOD_EC)); + put(Identifier::fromString(vm, "ENGINE_METHOD_EC"_s), + jsNumber(ENGINE_METHOD_EC)); #endif #ifdef ENGINE_METHOD_CIPHERS - put(Identifier::fromString(vm, "ENGINE_METHOD_CIPHERS"_s), - jsNumber(ENGINE_METHOD_CIPHERS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_CIPHERS"_s), + jsNumber(ENGINE_METHOD_CIPHERS)); #endif #ifdef ENGINE_METHOD_DIGESTS - put(Identifier::fromString(vm, "ENGINE_METHOD_DIGESTS"_s), - jsNumber(ENGINE_METHOD_DIGESTS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_DIGESTS"_s), + jsNumber(ENGINE_METHOD_DIGESTS)); #endif #ifdef ENGINE_METHOD_PKEY_METHS - put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_METHS"_s), - jsNumber(ENGINE_METHOD_PKEY_METHS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_METHS"_s), + jsNumber(ENGINE_METHOD_PKEY_METHS)); #endif #ifdef ENGINE_METHOD_PKEY_ASN1_METHS - put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_ASN1_METHS"_s), - jsNumber(ENGINE_METHOD_PKEY_ASN1_METHS)); + put(Identifier::fromString(vm, "ENGINE_METHOD_PKEY_ASN1_METHS"_s), + jsNumber(ENGINE_METHOD_PKEY_ASN1_METHS)); #endif #ifdef ENGINE_METHOD_ALL - put(Identifier::fromString(vm, "ENGINE_METHOD_ALL"_s), - jsNumber(ENGINE_METHOD_ALL)); + put(Identifier::fromString(vm, "ENGINE_METHOD_ALL"_s), + jsNumber(ENGINE_METHOD_ALL)); #endif #ifdef ENGINE_METHOD_NONE - put(Identifier::fromString(vm, "ENGINE_METHOD_NONE"_s), - jsNumber(ENGINE_METHOD_NONE)); + put(Identifier::fromString(vm, "ENGINE_METHOD_NONE"_s), + jsNumber(ENGINE_METHOD_NONE)); #endif #endif // !OPENSSL_NO_ENGINE #ifdef DH_CHECK_P_NOT_SAFE_PRIME - put(Identifier::fromString(vm, "DH_CHECK_P_NOT_SAFE_PRIME"_s), - jsNumber(DH_CHECK_P_NOT_SAFE_PRIME)); + put(Identifier::fromString(vm, "DH_CHECK_P_NOT_SAFE_PRIME"_s), + jsNumber(DH_CHECK_P_NOT_SAFE_PRIME)); #endif #ifdef DH_CHECK_P_NOT_PRIME - put(Identifier::fromString(vm, "DH_CHECK_P_NOT_PRIME"_s), - jsNumber(DH_CHECK_P_NOT_PRIME)); + put(Identifier::fromString(vm, "DH_CHECK_P_NOT_PRIME"_s), + jsNumber(DH_CHECK_P_NOT_PRIME)); #endif #ifdef DH_UNABLE_TO_CHECK_GENERATOR - put(Identifier::fromString(vm, "DH_UNABLE_TO_CHECK_GENERATOR"_s), - jsNumber(DH_UNABLE_TO_CHECK_GENERATOR)); + put(Identifier::fromString(vm, "DH_UNABLE_TO_CHECK_GENERATOR"_s), + jsNumber(DH_UNABLE_TO_CHECK_GENERATOR)); #endif #ifdef DH_NOT_SUITABLE_GENERATOR - put(Identifier::fromString(vm, "DH_NOT_SUITABLE_GENERATOR"_s), - jsNumber(DH_NOT_SUITABLE_GENERATOR)); + put(Identifier::fromString(vm, "DH_NOT_SUITABLE_GENERATOR"_s), + jsNumber(DH_NOT_SUITABLE_GENERATOR)); #endif #ifdef RSA_PKCS1_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_PADDING"_s), - jsNumber(RSA_PKCS1_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_PADDING"_s), + jsNumber(RSA_PKCS1_PADDING)); #endif #ifdef RSA_SSLV23_PADDING - put(Identifier::fromString(vm, "RSA_SSLV23_PADDING"_s), - jsNumber(RSA_SSLV23_PADDING)); + put(Identifier::fromString(vm, "RSA_SSLV23_PADDING"_s), + jsNumber(RSA_SSLV23_PADDING)); #endif #ifdef RSA_NO_PADDING - put(Identifier::fromString(vm, "RSA_NO_PADDING"_s), jsNumber(RSA_NO_PADDING)); + put(Identifier::fromString(vm, "RSA_NO_PADDING"_s), jsNumber(RSA_NO_PADDING)); #endif #ifdef RSA_PKCS1_OAEP_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_OAEP_PADDING"_s), - jsNumber(RSA_PKCS1_OAEP_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_OAEP_PADDING"_s), + jsNumber(RSA_PKCS1_OAEP_PADDING)); #endif #ifdef RSA_X931_PADDING - put(Identifier::fromString(vm, "RSA_X931_PADDING"_s), - jsNumber(RSA_X931_PADDING)); + put(Identifier::fromString(vm, "RSA_X931_PADDING"_s), + jsNumber(RSA_X931_PADDING)); #endif #ifdef RSA_PKCS1_PSS_PADDING - put(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s), - jsNumber(RSA_PKCS1_PSS_PADDING)); + put(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s), + jsNumber(RSA_PKCS1_PSS_PADDING)); #endif #ifdef RSA_PSS_SALTLEN_DIGEST - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s), - jsNumber(RSA_PSS_SALTLEN_DIGEST)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s), + jsNumber(RSA_PSS_SALTLEN_DIGEST)); #endif #ifdef RSA_PSS_SALTLEN_MAX_SIGN - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s), - jsNumber(RSA_PSS_SALTLEN_MAX_SIGN)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s), + jsNumber(RSA_PSS_SALTLEN_MAX_SIGN)); #endif #ifdef RSA_PSS_SALTLEN_AUTO - put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s), - jsNumber(RSA_PSS_SALTLEN_AUTO)); + put(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s), + jsNumber(RSA_PSS_SALTLEN_AUTO)); #endif - auto cipherList = String("TLS_AES_256_GCM_SHA384:" - "TLS_CHACHA20_POLY1305_SHA256:" - "TLS_AES_128_GCM_SHA256:" - "ECDHE-RSA-AES128-GCM-SHA256:" - "ECDHE-ECDSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES256-GCM-SHA384:" - "ECDHE-ECDSA-AES256-GCM-SHA384:" - "DHE-RSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES128-SHA256:" - "DHE-RSA-AES128-SHA256:" - "ECDHE-RSA-AES256-SHA384:" - "DHE-RSA-AES256-SHA384:" - "ECDHE-RSA-AES256-SHA256:" - "DHE-RSA-AES256-SHA256:" - "HIGH:" - "!aNULL:" - "!eNULL:" - "!EXPORT:" - "!DES:" - "!RC4:" - "!MD5:" - "!PSK:" - "!SRP:" - "!CAMELLIA"_s); - put(Identifier::fromString(vm, "defaultCoreCipherList"_s), - jsString(vm, cipherList)); - put(Identifier::fromString(vm, "defaultCipherList"_s), - jsString(vm, cipherList)); + auto cipherList = String("TLS_AES_256_GCM_SHA384:" + "TLS_CHACHA20_POLY1305_SHA256:" + "TLS_AES_128_GCM_SHA256:" + "ECDHE-RSA-AES128-GCM-SHA256:" + "ECDHE-ECDSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES256-GCM-SHA384:" + "ECDHE-ECDSA-AES256-GCM-SHA384:" + "DHE-RSA-AES128-GCM-SHA256:" + "ECDHE-RSA-AES128-SHA256:" + "DHE-RSA-AES128-SHA256:" + "ECDHE-RSA-AES256-SHA384:" + "DHE-RSA-AES256-SHA384:" + "ECDHE-RSA-AES256-SHA256:" + "DHE-RSA-AES256-SHA256:" + "HIGH:" + "!aNULL:" + "!eNULL:" + "!EXPORT:" + "!DES:" + "!RC4:" + "!MD5:" + "!PSK:" + "!SRP:" + "!CAMELLIA"_s); + put(Identifier::fromString(vm, "defaultCoreCipherList"_s), + jsString(vm, cipherList)); + put(Identifier::fromString(vm, "defaultCipherList"_s), + jsString(vm, cipherList)); #ifdef TLS1_VERSION - put(Identifier::fromString(vm, "TLS1_VERSION"_s), jsNumber(TLS1_VERSION)); + put(Identifier::fromString(vm, "TLS1_VERSION"_s), jsNumber(TLS1_VERSION)); #endif #ifdef TLS1_1_VERSION - put(Identifier::fromString(vm, "TLS1_1_VERSION"_s), jsNumber(TLS1_1_VERSION)); + put(Identifier::fromString(vm, "TLS1_1_VERSION"_s), jsNumber(TLS1_1_VERSION)); #endif #ifdef TLS1_2_VERSION - put(Identifier::fromString(vm, "TLS1_2_VERSION"_s), jsNumber(TLS1_2_VERSION)); + put(Identifier::fromString(vm, "TLS1_2_VERSION"_s), jsNumber(TLS1_2_VERSION)); #endif #ifdef TLS1_3_VERSION - put(Identifier::fromString(vm, "TLS1_3_VERSION"_s), jsNumber(TLS1_3_VERSION)); + put(Identifier::fromString(vm, "TLS1_3_VERSION"_s), jsNumber(TLS1_3_VERSION)); #endif - put(Identifier::fromString(vm, "POINT_CONVERSION_COMPRESSED"_s), - jsNumber(POINT_CONVERSION_COMPRESSED)); - put(Identifier::fromString(vm, "POINT_CONVERSION_UNCOMPRESSED"_s), - jsNumber(POINT_CONVERSION_UNCOMPRESSED)); - put(Identifier::fromString(vm, "POINT_CONVERSION_HYBRID"_s), - jsNumber(POINT_CONVERSION_HYBRID)); + put(Identifier::fromString(vm, "POINT_CONVERSION_COMPRESSED"_s), + jsNumber(POINT_CONVERSION_COMPRESSED)); + put(Identifier::fromString(vm, "POINT_CONVERSION_UNCOMPRESSED"_s), + jsNumber(POINT_CONVERSION_UNCOMPRESSED)); + put(Identifier::fromString(vm, "POINT_CONVERSION_HYBRID"_s), + jsNumber(POINT_CONVERSION_HYBRID)); - // RETURN_NATIVE_MODULE(); + // RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/NodeProcessModule.h b/src/bun.js/modules/NodeProcessModule.h index 9058c00108..edde3fa5e5 100644 --- a/src/bun.js/modules/NodeProcessModule.h +++ b/src/bun.js/modules/NodeProcessModule.h @@ -6,69 +6,72 @@ namespace Zig { JSC_DEFINE_HOST_FUNCTION(jsFunctionProcessModuleCommonJS, - (JSGlobalObject * globalObject, - CallFrame *callFrame)) { + (JSGlobalObject * globalObject, + CallFrame* callFrame)) +{ - return JSValue::encode( - reinterpret_cast(globalObject)->processObject()); + return JSValue::encode( + reinterpret_cast(globalObject)->processObject()); } JSC_DEFINE_CUSTOM_GETTER(jsFunctionProcessModuleCommonJSGetter, - (JSGlobalObject * globalObject, - JSC::EncodedJSValue thisValue, - PropertyName propertyName)) { + (JSGlobalObject * globalObject, + JSC::EncodedJSValue thisValue, + PropertyName propertyName)) +{ - return JSValue::encode(reinterpret_cast(globalObject) - ->processObject() - ->get(globalObject, propertyName)); + return JSValue::encode(reinterpret_cast(globalObject) + ->processObject() + ->get(globalObject, propertyName)); } JSC_DEFINE_CUSTOM_SETTER(jsFunctionProcessModuleCommonJSSetter, - (JSGlobalObject * globalObject, - JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue encodedValue, - PropertyName propertyName)) { - VM &vm = globalObject->vm(); + (JSGlobalObject * globalObject, + JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue encodedValue, + PropertyName propertyName)) +{ + VM& vm = globalObject->vm(); - return reinterpret_cast(globalObject) - ->processObject() - ->putDirect(vm, propertyName, JSValue::decode(encodedValue), 0); + return reinterpret_cast(globalObject) + ->processObject() + ->putDirect(vm, propertyName, JSValue::decode(encodedValue), 0); } -DEFINE_NATIVE_MODULE(NodeProcess) { - JSC::VM &vm = lexicalGlobalObject->vm(); - GlobalObject *globalObject = - reinterpret_cast(lexicalGlobalObject); +DEFINE_NATIVE_MODULE(NodeProcess) +{ + JSC::VM& vm = lexicalGlobalObject->vm(); + GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); - JSC::JSObject *process = globalObject->processObject(); - auto scope = DECLARE_THROW_SCOPE(vm); - if (!process->staticPropertiesReified()) { - process->reifyAllStaticProperties(globalObject); - if (scope.exception()) - return; - } - - PropertyNameArray properties(vm, PropertyNameMode::Strings, - PrivateSymbolMode::Exclude); - process->getPropertyNames(globalObject, properties, - DontEnumPropertiesMode::Exclude); - if (scope.exception()) - return; - - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(process); - - for (auto &entry : properties) { - exportNames.append(entry); - auto catchScope = DECLARE_CATCH_SCOPE(vm); - JSValue result = process->get(globalObject, entry); - if (catchScope.exception()) { - result = jsUndefined(); - catchScope.clearException(); + JSC::JSObject* process = globalObject->processObject(); + auto scope = DECLARE_THROW_SCOPE(vm); + if (!process->staticPropertiesReified()) { + process->reifyAllStaticProperties(globalObject); + if (scope.exception()) + return; } - exportValues.append(result); - } + PropertyNameArray properties(vm, PropertyNameMode::Strings, + PrivateSymbolMode::Exclude); + process->getPropertyNames(globalObject, properties, + DontEnumPropertiesMode::Exclude); + if (scope.exception()) + return; + + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(process); + + for (auto& entry : properties) { + exportNames.append(entry); + auto catchScope = DECLARE_CATCH_SCOPE(vm); + JSValue result = process->get(globalObject, entry); + if (catchScope.exception()) { + result = jsUndefined(); + catchScope.clearException(); + } + + exportValues.append(result); + } } } // namespace Zig diff --git a/src/bun.js/modules/NodeStringDecoderModule.h b/src/bun.js/modules/NodeStringDecoderModule.h index 253ba0f7e2..d4ffdc85a3 100644 --- a/src/bun.js/modules/NodeStringDecoderModule.h +++ b/src/bun.js/modules/NodeStringDecoderModule.h @@ -4,13 +4,14 @@ namespace Zig { -DEFINE_NATIVE_MODULE(NodeStringDecoder) { - INIT_NATIVE_MODULE(1); +DEFINE_NATIVE_MODULE(NodeStringDecoder) +{ + INIT_NATIVE_MODULE(1); - put(JSC::Identifier::fromString(vm, "StringDecoder"_s), - globalObject->JSStringDecoder()); + put(JSC::Identifier::fromString(vm, "StringDecoder"_s), + globalObject->JSStringDecoder()); - RETURN_NATIVE_MODULE(); + RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/NodeTTYModule.h b/src/bun.js/modules/NodeTTYModule.h index 30a3b51586..5b897a3a48 100644 --- a/src/bun.js/modules/NodeTTYModule.h +++ b/src/bun.js/modules/NodeTTYModule.h @@ -13,19 +13,20 @@ using namespace WebCore; JSC_DECLARE_HOST_FUNCTION(jsFunctionTty_isatty); JSC_DECLARE_HOST_FUNCTION(jsFunctionNotImplementedYet); -DEFINE_NATIVE_MODULE(NodeTTY) { - INIT_NATIVE_MODULE(3); +DEFINE_NATIVE_MODULE(NodeTTY) +{ + INIT_NATIVE_MODULE(3); - auto *notimpl = JSFunction::create(vm, globalObject, 0, "notimpl"_s, - jsFunctionNotImplementedYet, - ImplementationVisibility::Public, - NoIntrinsic, jsFunctionNotImplementedYet); + auto* notimpl = JSFunction::create(vm, globalObject, 0, "notimpl"_s, + jsFunctionNotImplementedYet, + ImplementationVisibility::Public, + NoIntrinsic, jsFunctionNotImplementedYet); - putNativeFn(Identifier::fromString(vm, "isatty"_s), jsFunctionTty_isatty); - put(Identifier::fromString(vm, "ReadStream"_s), notimpl); - put(Identifier::fromString(vm, "WriteStream"_s), notimpl); + putNativeFn(Identifier::fromString(vm, "isatty"_s), jsFunctionTty_isatty); + put(Identifier::fromString(vm, "ReadStream"_s), notimpl); + put(Identifier::fromString(vm, "WriteStream"_s), notimpl); - RETURN_NATIVE_MODULE(); + RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/NodeUtilTypesModule.h b/src/bun.js/modules/NodeUtilTypesModule.h index a90fd7e681..cc4117701e 100644 --- a/src/bun.js/modules/NodeUtilTypesModule.h +++ b/src/bun.js/modules/NodeUtilTypesModule.h @@ -18,491 +18,523 @@ using namespace JSC; -#define GET_FIRST_VALUE \ - if (callframe->argumentCount() < 1) \ - return JSValue::encode(jsBoolean(false)); \ - JSValue value = callframe->uncheckedArgument(0); +#define GET_FIRST_VALUE \ + if (callframe->argumentCount() < 1) \ + return JSValue::encode(jsBoolean(false)); \ + JSValue value = callframe->uncheckedArgument(0); -#define GET_FIRST_CELL \ - if (callframe->argumentCount() < 1) \ - return JSValue::encode(jsBoolean(false)); \ - JSValue value = callframe->uncheckedArgument(0); \ - if (!value.isCell()) \ - return JSValue::encode(jsBoolean(false)); \ - JSCell *cell = value.asCell(); +#define GET_FIRST_CELL \ + if (callframe->argumentCount() < 1) \ + return JSValue::encode(jsBoolean(false)); \ + JSValue value = callframe->uncheckedArgument(0); \ + if (!value.isCell()) \ + return JSValue::encode(jsBoolean(false)); \ + JSCell* cell = value.asCell(); JSC_DEFINE_HOST_FUNCTION(jsFunctionIsExternal, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - return JSValue::encode(jsBoolean(value.inherits())); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + return JSValue::encode(jsBoolean(value.inherits())); } -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDate, (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSDateType)); +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDate, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSDateType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArgumentsObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - if (!value.isCell()) - return JSValue::encode(jsBoolean(false)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + if (!value.isCell()) + return JSValue::encode(jsBoolean(false)); - auto type = value.asCell()->type(); - switch (type) { - case DirectArgumentsType: - case ScopedArgumentsType: - case ClonedArgumentsType: - return JSValue::encode(jsBoolean(true)); - default: - return JSValue::encode(jsBoolean(false)); - } - - __builtin_unreachable(); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigIntObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode( - jsBoolean(globalObject->bigIntObjectStructure() == cell->structure())); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBooleanObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - return JSValue::encode( - jsBoolean(value.isCell() && value.asCell()->type() == BooleanObjectType)); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNumberObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - return JSValue::encode( - jsBoolean(value.isCell() && value.asCell()->type() == NumberObjectType)); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsStringObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - return JSValue::encode(jsBoolean( - value.isCell() && (value.asCell()->type() == StringObjectType || - value.asCell()->type() == DerivedStringObjectType))); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSymbolObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - - return JSValue::encode( - jsBoolean(globalObject->symbolObjectStructure() == cell->structure())); -} -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - if (value.isCell()) { - if (value.inherits() || - value.asCell()->type() == ErrorInstanceType) - return JSValue::encode(jsBoolean(true)); - - VM &vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - JSObject *object = value.toObject(globalObject); - - // node util.isError relies on toString - // https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/doc/api/util.md#L2923 - PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, &vm); - if (object->getPropertySlot(globalObject, - vm.propertyNames->toStringTagSymbol, slot)) { - EXCEPTION_ASSERT(!scope.exception()); - if (slot.isValue()) { - JSValue value = - slot.getValue(globalObject, vm.propertyNames->toStringTagSymbol); - if (value.isString()) { - String tag = asString(value)->value(globalObject); - if (UNLIKELY(scope.exception())) - scope.clearException(); - if (tag == "Error"_s) - return JSValue::encode(jsBoolean(true)); - } - } + auto type = value.asCell()->type(); + switch (type) { + case DirectArgumentsType: + case ScopedArgumentsType: + case ClonedArgumentsType: + return JSValue::encode(jsBoolean(true)); + default: + return JSValue::encode(jsBoolean(false)); } - JSValue proto = object->getPrototype(vm, globalObject); - if (proto.isCell() && (proto.inherits() || - proto.asCell()->type() == ErrorInstanceType || - proto.inherits())) - return JSValue::encode(jsBoolean(true)); - } + __builtin_unreachable(); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigIntObject, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode( + jsBoolean(globalObject->bigIntObjectStructure() == cell->structure())); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBooleanObject, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + return JSValue::encode( + jsBoolean(value.isCell() && value.asCell()->type() == BooleanObjectType)); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNumberObject, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + return JSValue::encode( + jsBoolean(value.isCell() && value.asCell()->type() == NumberObjectType)); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsStringObject, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + return JSValue::encode(jsBoolean( + value.isCell() && (value.asCell()->type() == StringObjectType || value.asCell()->type() == DerivedStringObjectType))); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSymbolObject, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL - return JSValue::encode(jsBoolean(false)); + return JSValue::encode( + jsBoolean(globalObject->symbolObjectStructure() == cell->structure())); +} +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError, + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + if (value.isCell()) { + if (value.inherits() || value.asCell()->type() == ErrorInstanceType) + return JSValue::encode(jsBoolean(true)); + + VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSObject* object = value.toObject(globalObject); + + // node util.isError relies on toString + // https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/doc/api/util.md#L2923 + PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, &vm); + if (object->getPropertySlot(globalObject, + vm.propertyNames->toStringTagSymbol, slot)) { + EXCEPTION_ASSERT(!scope.exception()); + if (slot.isValue()) { + JSValue value = slot.getValue(globalObject, vm.propertyNames->toStringTagSymbol); + if (value.isString()) { + String tag = asString(value)->value(globalObject); + if (UNLIKELY(scope.exception())) + scope.clearException(); + if (tag == "Error"_s) + return JSValue::encode(jsBoolean(true)); + } + } + } + + JSValue proto = object->getPrototype(vm, globalObject); + if (proto.isCell() && (proto.inherits() || proto.asCell()->type() == ErrorInstanceType || proto.inherits())) + return JSValue::encode(jsBoolean(true)); + } + + return JSValue::encode(jsBoolean(false)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsRegExp, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - return JSValue::encode( - jsBoolean(value.isCell() && value.asCell()->type() == RegExpObjectType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + return JSValue::encode( + jsBoolean(value.isCell() && value.asCell()->type() == RegExpObjectType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsAsyncFunction, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE - auto *function = jsDynamicCast(value); - if (!function) - return JSValue::encode(jsBoolean(false)); + auto* function = jsDynamicCast(value); + if (!function) + return JSValue::encode(jsBoolean(false)); - auto *executable = function->jsExecutable(); - if (!executable) - return JSValue::encode(jsBoolean(false)); + auto* executable = function->jsExecutable(); + if (!executable) + return JSValue::encode(jsBoolean(false)); - if (executable->isAsyncGenerator()) { - return JSValue::encode(jsBoolean(true)); - } + if (executable->isAsyncGenerator()) { + return JSValue::encode(jsBoolean(true)); + } - auto &vm = globalObject->vm(); - auto proto = function->getPrototype(vm, globalObject); - if (!proto.isCell()) { - return JSValue::encode(jsBoolean(false)); - } + auto& vm = globalObject->vm(); + auto proto = function->getPrototype(vm, globalObject); + if (!proto.isCell()) { + return JSValue::encode(jsBoolean(false)); + } - auto *protoCell = proto.asCell(); - return JSValue::encode( - jsBoolean(protoCell->inherits())); + auto* protoCell = proto.asCell(); + return JSValue::encode( + jsBoolean(protoCell->inherits())); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsGeneratorFunction, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_VALUE - auto *function = jsDynamicCast(value); - if (!function) - return JSValue::encode(jsBoolean(false)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_VALUE + auto* function = jsDynamicCast(value); + if (!function) + return JSValue::encode(jsBoolean(false)); - auto *executable = function->jsExecutable(); - if (!executable) - return JSValue::encode(jsBoolean(false)); + auto* executable = function->jsExecutable(); + if (!executable) + return JSValue::encode(jsBoolean(false)); - return JSValue::encode( - jsBoolean(executable->isGenerator() || executable->isAsyncGenerator())); + return JSValue::encode( + jsBoolean(executable->isGenerator() || executable->isAsyncGenerator())); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsGeneratorObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSGeneratorType || - cell->type() == JSAsyncGeneratorType)); + return JSValue::encode(jsBoolean(cell->type() == JSGeneratorType || cell->type() == JSAsyncGeneratorType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsPromise, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSPromiseType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSPromiseType)); } -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMap, (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSMapType)); +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMap, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSMapType)); } -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSet, (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSSetType)); +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSet, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSSetType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMapIterator, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSMapIteratorType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSMapIteratorType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSetIterator, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSSetIteratorType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSSetIteratorType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsWeakMap, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSWeakMapType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSWeakMapType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsWeakSet, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == JSWeakSetType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == JSWeakSetType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArrayBuffer, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - auto *arrayBuffer = jsDynamicCast(cell); - if (!arrayBuffer) - return JSValue::encode(jsBoolean(false)); - return JSValue::encode(jsBoolean(!arrayBuffer->isShared())); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + auto* arrayBuffer = jsDynamicCast(cell); + if (!arrayBuffer) + return JSValue::encode(jsBoolean(false)); + return JSValue::encode(jsBoolean(!arrayBuffer->isShared())); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDataView, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == DataViewType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == DataViewType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSharedArrayBuffer, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - auto *arrayBuffer = jsDynamicCast(cell); - if (!arrayBuffer) - return JSValue::encode(jsBoolean(false)); - return JSValue::encode(jsBoolean(arrayBuffer->isShared())); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + auto* arrayBuffer = jsDynamicCast(cell); + if (!arrayBuffer) + return JSValue::encode(jsBoolean(false)); + return JSValue::encode(jsBoolean(arrayBuffer->isShared())); } -JSC_DEFINE_HOST_FUNCTION(jsFunctionIsProxy, (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == GlobalProxyType || - cell->type() == ProxyObjectType)); +JSC_DEFINE_HOST_FUNCTION(jsFunctionIsProxy, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == GlobalProxyType || cell->type() == ProxyObjectType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsModuleNamespaceObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == ModuleNamespaceObjectType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == ModuleNamespaceObjectType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsAnyArrayBuffer, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - auto *arrayBuffer = jsDynamicCast(cell); - return JSValue::encode(jsBoolean(arrayBuffer != nullptr)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + auto* arrayBuffer = jsDynamicCast(cell); + return JSValue::encode(jsBoolean(arrayBuffer != nullptr)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBoxedPrimitive, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - switch (cell->type()) { - case JSC::BooleanObjectType: - case JSC::NumberObjectType: - case JSC::StringObjectType: - case JSC::DerivedStringObjectType: - return JSValue::encode(jsBoolean(true)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + switch (cell->type()) { + case JSC::BooleanObjectType: + case JSC::NumberObjectType: + case JSC::StringObjectType: + case JSC::DerivedStringObjectType: + return JSValue::encode(jsBoolean(true)); - default: { - if (cell->structure() == globalObject->symbolObjectStructure()) - return JSValue::encode(jsBoolean(true)); + default: { + if (cell->structure() == globalObject->symbolObjectStructure()) + return JSValue::encode(jsBoolean(true)); - if (cell->structure() == globalObject->bigIntObjectStructure()) - return JSValue::encode(jsBoolean(true)); - } - } + if (cell->structure() == globalObject->bigIntObjectStructure()) + return JSValue::encode(jsBoolean(true)); + } + } - return JSValue::encode(jsBoolean(false)); + return JSValue::encode(jsBoolean(false)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArrayBufferView, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode( - jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= DataViewType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode( + jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= DataViewType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsTypedArray, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() >= Int8ArrayType && - cell->type() <= BigUint64ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= BigUint64ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint8Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Uint8ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Uint8ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint8ClampedArray, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Uint8ClampedArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Uint8ClampedArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint16Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Uint16ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Uint16ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint32Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Uint32ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Uint32ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt8Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Int8ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Int8ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt16Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Int16ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Int16ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt32Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Int32ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Int32ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat16Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Float16ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Float16ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat32Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Float32ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Float32ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat64Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == Float64ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == Float64ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigInt64Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == BigInt64ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == BigInt64ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigUint64Array, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->type() == BigUint64ArrayType)); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->type() == BigUint64ArrayType)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsKeyObject, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + + if (!cell->isObject()) { + return JSValue::encode(jsBoolean(false)); + } + + auto* object = cell->getObject(); + + auto& vm = globalObject->vm(); + const auto& names = WebCore::builtinNames(vm); + + auto scope = DECLARE_CATCH_SCOPE(vm); + + if (auto val = object->getIfPropertyExists(globalObject, + names.bunNativePtrPrivateName())) { + if (val.isCell() && val.inherits()) + return JSValue::encode(jsBoolean(true)); + } + + if (scope.exception()) { + scope.clearException(); + } - if (!cell->isObject()) { return JSValue::encode(jsBoolean(false)); - } - - auto *object = cell->getObject(); - - auto &vm = globalObject->vm(); - const auto &names = WebCore::builtinNames(vm); - - auto scope = DECLARE_CATCH_SCOPE(vm); - - if (auto val = object->getIfPropertyExists(globalObject, - names.bunNativePtrPrivateName())) { - if (val.isCell() && val.inherits()) - return JSValue::encode(jsBoolean(true)); - } - - if (scope.exception()) { - scope.clearException(); - } - - return JSValue::encode(jsBoolean(false)); } JSC_DEFINE_HOST_FUNCTION(jsFunctionIsCryptoKey, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callframe)) { - GET_FIRST_CELL - return JSValue::encode(jsBoolean(cell->inherits())); + (JSC::JSGlobalObject * globalObject, + JSC::CallFrame* callframe)) +{ + GET_FIRST_CELL + return JSValue::encode(jsBoolean(cell->inherits())); } namespace Zig { -DEFINE_NATIVE_MODULE(NodeUtilTypes) { - INIT_NATIVE_MODULE(43); +DEFINE_NATIVE_MODULE(NodeUtilTypes) +{ + INIT_NATIVE_MODULE(43); - putNativeFn(Identifier::fromString(vm, "isExternal"_s), jsFunctionIsExternal); - putNativeFn(Identifier::fromString(vm, "isDate"_s), jsFunctionIsDate); - putNativeFn(Identifier::fromString(vm, "isArgumentsObject"_s), - jsFunctionIsArgumentsObject); - putNativeFn(Identifier::fromString(vm, "isBigIntObject"_s), - jsFunctionIsBigIntObject); - putNativeFn(Identifier::fromString(vm, "isBooleanObject"_s), - jsFunctionIsBooleanObject); - putNativeFn(Identifier::fromString(vm, "isNumberObject"_s), - jsFunctionIsNumberObject); - putNativeFn(Identifier::fromString(vm, "isStringObject"_s), - jsFunctionIsStringObject); - putNativeFn(Identifier::fromString(vm, "isSymbolObject"_s), - jsFunctionIsSymbolObject); - putNativeFn(Identifier::fromString(vm, "isNativeError"_s), - jsFunctionIsNativeError); - putNativeFn(Identifier::fromString(vm, "isRegExp"_s), jsFunctionIsRegExp); - putNativeFn(Identifier::fromString(vm, "isAsyncFunction"_s), - jsFunctionIsAsyncFunction); - putNativeFn(Identifier::fromString(vm, "isGeneratorFunction"_s), - jsFunctionIsGeneratorFunction); - putNativeFn(Identifier::fromString(vm, "isGeneratorObject"_s), - jsFunctionIsGeneratorObject); - putNativeFn(Identifier::fromString(vm, "isPromise"_s), jsFunctionIsPromise); - putNativeFn(Identifier::fromString(vm, "isMap"_s), jsFunctionIsMap); - putNativeFn(Identifier::fromString(vm, "isSet"_s), jsFunctionIsSet); - putNativeFn(Identifier::fromString(vm, "isMapIterator"_s), - jsFunctionIsMapIterator); - putNativeFn(Identifier::fromString(vm, "isSetIterator"_s), - jsFunctionIsSetIterator); - putNativeFn(Identifier::fromString(vm, "isWeakMap"_s), jsFunctionIsWeakMap); - putNativeFn(Identifier::fromString(vm, "isWeakSet"_s), jsFunctionIsWeakSet); - putNativeFn(Identifier::fromString(vm, "isArrayBuffer"_s), - jsFunctionIsArrayBuffer); - putNativeFn(Identifier::fromString(vm, "isDataView"_s), jsFunctionIsDataView); - putNativeFn(Identifier::fromString(vm, "isSharedArrayBuffer"_s), - jsFunctionIsSharedArrayBuffer); - putNativeFn(Identifier::fromString(vm, "isProxy"_s), jsFunctionIsProxy); - putNativeFn(Identifier::fromString(vm, "isModuleNamespaceObject"_s), - jsFunctionIsModuleNamespaceObject); - putNativeFn(Identifier::fromString(vm, "isAnyArrayBuffer"_s), - jsFunctionIsAnyArrayBuffer); - putNativeFn(Identifier::fromString(vm, "isBoxedPrimitive"_s), - jsFunctionIsBoxedPrimitive); - putNativeFn(Identifier::fromString(vm, "isArrayBufferView"_s), - jsFunctionIsArrayBufferView); - putNativeFn(Identifier::fromString(vm, "isTypedArray"_s), - jsFunctionIsTypedArray); - putNativeFn(Identifier::fromString(vm, "isUint8Array"_s), - jsFunctionIsUint8Array); - putNativeFn(Identifier::fromString(vm, "isUint8ClampedArray"_s), - jsFunctionIsUint8ClampedArray); - putNativeFn(Identifier::fromString(vm, "isUint16Array"_s), - jsFunctionIsUint16Array); - putNativeFn(Identifier::fromString(vm, "isUint32Array"_s), - jsFunctionIsUint32Array); - putNativeFn(Identifier::fromString(vm, "isInt8Array"_s), - jsFunctionIsInt8Array); - putNativeFn(Identifier::fromString(vm, "isInt16Array"_s), - jsFunctionIsInt16Array); - putNativeFn(Identifier::fromString(vm, "isInt32Array"_s), - jsFunctionIsInt32Array); - putNativeFn(Identifier::fromString(vm, "isFloat16Array"_s), - jsFunctionIsFloat16Array); - putNativeFn(Identifier::fromString(vm, "isFloat32Array"_s), - jsFunctionIsFloat32Array); - putNativeFn(Identifier::fromString(vm, "isFloat64Array"_s), - jsFunctionIsFloat64Array); - putNativeFn(Identifier::fromString(vm, "isBigInt64Array"_s), - jsFunctionIsBigInt64Array); - putNativeFn(Identifier::fromString(vm, "isBigUint64Array"_s), - jsFunctionIsBigUint64Array); - putNativeFn(Identifier::fromString(vm, "isKeyObject"_s), - jsFunctionIsKeyObject); - putNativeFn(Identifier::fromString(vm, "isCryptoKey"_s), - jsFunctionIsCryptoKey); + putNativeFn(Identifier::fromString(vm, "isExternal"_s), jsFunctionIsExternal); + putNativeFn(Identifier::fromString(vm, "isDate"_s), jsFunctionIsDate); + putNativeFn(Identifier::fromString(vm, "isArgumentsObject"_s), + jsFunctionIsArgumentsObject); + putNativeFn(Identifier::fromString(vm, "isBigIntObject"_s), + jsFunctionIsBigIntObject); + putNativeFn(Identifier::fromString(vm, "isBooleanObject"_s), + jsFunctionIsBooleanObject); + putNativeFn(Identifier::fromString(vm, "isNumberObject"_s), + jsFunctionIsNumberObject); + putNativeFn(Identifier::fromString(vm, "isStringObject"_s), + jsFunctionIsStringObject); + putNativeFn(Identifier::fromString(vm, "isSymbolObject"_s), + jsFunctionIsSymbolObject); + putNativeFn(Identifier::fromString(vm, "isNativeError"_s), + jsFunctionIsNativeError); + putNativeFn(Identifier::fromString(vm, "isRegExp"_s), jsFunctionIsRegExp); + putNativeFn(Identifier::fromString(vm, "isAsyncFunction"_s), + jsFunctionIsAsyncFunction); + putNativeFn(Identifier::fromString(vm, "isGeneratorFunction"_s), + jsFunctionIsGeneratorFunction); + putNativeFn(Identifier::fromString(vm, "isGeneratorObject"_s), + jsFunctionIsGeneratorObject); + putNativeFn(Identifier::fromString(vm, "isPromise"_s), jsFunctionIsPromise); + putNativeFn(Identifier::fromString(vm, "isMap"_s), jsFunctionIsMap); + putNativeFn(Identifier::fromString(vm, "isSet"_s), jsFunctionIsSet); + putNativeFn(Identifier::fromString(vm, "isMapIterator"_s), + jsFunctionIsMapIterator); + putNativeFn(Identifier::fromString(vm, "isSetIterator"_s), + jsFunctionIsSetIterator); + putNativeFn(Identifier::fromString(vm, "isWeakMap"_s), jsFunctionIsWeakMap); + putNativeFn(Identifier::fromString(vm, "isWeakSet"_s), jsFunctionIsWeakSet); + putNativeFn(Identifier::fromString(vm, "isArrayBuffer"_s), + jsFunctionIsArrayBuffer); + putNativeFn(Identifier::fromString(vm, "isDataView"_s), jsFunctionIsDataView); + putNativeFn(Identifier::fromString(vm, "isSharedArrayBuffer"_s), + jsFunctionIsSharedArrayBuffer); + putNativeFn(Identifier::fromString(vm, "isProxy"_s), jsFunctionIsProxy); + putNativeFn(Identifier::fromString(vm, "isModuleNamespaceObject"_s), + jsFunctionIsModuleNamespaceObject); + putNativeFn(Identifier::fromString(vm, "isAnyArrayBuffer"_s), + jsFunctionIsAnyArrayBuffer); + putNativeFn(Identifier::fromString(vm, "isBoxedPrimitive"_s), + jsFunctionIsBoxedPrimitive); + putNativeFn(Identifier::fromString(vm, "isArrayBufferView"_s), + jsFunctionIsArrayBufferView); + putNativeFn(Identifier::fromString(vm, "isTypedArray"_s), + jsFunctionIsTypedArray); + putNativeFn(Identifier::fromString(vm, "isUint8Array"_s), + jsFunctionIsUint8Array); + putNativeFn(Identifier::fromString(vm, "isUint8ClampedArray"_s), + jsFunctionIsUint8ClampedArray); + putNativeFn(Identifier::fromString(vm, "isUint16Array"_s), + jsFunctionIsUint16Array); + putNativeFn(Identifier::fromString(vm, "isUint32Array"_s), + jsFunctionIsUint32Array); + putNativeFn(Identifier::fromString(vm, "isInt8Array"_s), + jsFunctionIsInt8Array); + putNativeFn(Identifier::fromString(vm, "isInt16Array"_s), + jsFunctionIsInt16Array); + putNativeFn(Identifier::fromString(vm, "isInt32Array"_s), + jsFunctionIsInt32Array); + putNativeFn(Identifier::fromString(vm, "isFloat16Array"_s), + jsFunctionIsFloat16Array); + putNativeFn(Identifier::fromString(vm, "isFloat32Array"_s), + jsFunctionIsFloat32Array); + putNativeFn(Identifier::fromString(vm, "isFloat64Array"_s), + jsFunctionIsFloat64Array); + putNativeFn(Identifier::fromString(vm, "isBigInt64Array"_s), + jsFunctionIsBigInt64Array); + putNativeFn(Identifier::fromString(vm, "isBigUint64Array"_s), + jsFunctionIsBigUint64Array); + putNativeFn(Identifier::fromString(vm, "isKeyObject"_s), + jsFunctionIsKeyObject); + putNativeFn(Identifier::fromString(vm, "isCryptoKey"_s), + jsFunctionIsCryptoKey); - RETURN_NATIVE_MODULE(); + RETURN_NATIVE_MODULE(); } } // namespace Zig diff --git a/src/bun.js/modules/ObjectModule.h b/src/bun.js/modules/ObjectModule.h index 5b9aba2cd7..6988e9a94e 100644 --- a/src/bun.js/modules/ObjectModule.h +++ b/src/bun.js/modules/ObjectModule.h @@ -5,15 +5,15 @@ namespace Zig { JSC::SyntheticSourceProvider::SyntheticSourceGenerator -generateObjectModuleSourceCode(JSC::JSGlobalObject *globalObject, - JSC::JSObject *object); +generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject, + JSC::JSObject* object); JSC::SyntheticSourceProvider::SyntheticSourceGenerator -generateObjectModuleSourceCodeForJSON(JSC::JSGlobalObject *globalObject, - JSC::JSObject *object); +generateObjectModuleSourceCodeForJSON(JSC::JSGlobalObject* globalObject, + JSC::JSObject* object); JSC::SyntheticSourceProvider::SyntheticSourceGenerator -generateJSValueModuleSourceCode(JSC::JSGlobalObject *globalObject, - JSC::JSValue value); +generateJSValueModuleSourceCode(JSC::JSGlobalObject* globalObject, + JSC::JSValue value); -} // namespace Zig \ No newline at end of file +} // namespace Zig diff --git a/src/bun.js/modules/UTF8ValidateModule.h b/src/bun.js/modules/UTF8ValidateModule.h index 18f309e630..a0ea1ff72d 100644 --- a/src/bun.js/modules/UTF8ValidateModule.h +++ b/src/bun.js/modules/UTF8ValidateModule.h @@ -4,17 +4,18 @@ using namespace WebCore; namespace Zig { inline void -generateNativeModule_UTF8Validate(JSC::JSGlobalObject *globalObject, - JSC::Identifier moduleKey, - Vector &exportNames, - JSC::MarkedArgumentBuffer &exportValues) { - auto &vm = globalObject->vm(); +generateNativeModule_UTF8Validate(JSC::JSGlobalObject* globalObject, + JSC::Identifier moduleKey, + Vector& exportNames, + JSC::MarkedArgumentBuffer& exportValues) +{ + auto& vm = globalObject->vm(); - exportNames.append(vm.propertyNames->defaultKeyword); - exportValues.append(JSC::JSFunction::create( - vm, globalObject, 1, "utf8Validate"_s, jsBufferConstructorFunction_isUtf8, - ImplementationVisibility::Public, NoIntrinsic, - jsBufferConstructorFunction_isUtf8)); + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(JSC::JSFunction::create( + vm, globalObject, 1, "utf8Validate"_s, jsBufferConstructorFunction_isUtf8, + ImplementationVisibility::Public, NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); } } // namespace Zig