diff --git a/.github/workflows/run-format.yml b/.github/workflows/run-format.yml index 6a063788e3..49432e1381 100644 --- a/.github/workflows/run-format.yml +++ b/.github/workflows/run-format.yml @@ -21,6 +21,7 @@ jobs: sparse-checkout: | .prettierrc-ci .github + .vscode src scripts packages @@ -28,7 +29,7 @@ jobs: bench package.json bun.lockb - .vscode + .clang-format - name: Setup Bun uses: ./.github/actions/setup-bun with: @@ -46,6 +47,9 @@ jobs: - name: Format Zig run: | bun fmt:zig + - name: Format Cpp + run: | + bun fmt:cpp - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/.vscode/settings.json b/.vscode/settings.json index a533a0a9f0..e9135f0993 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -61,6 +61,7 @@ "[h]": { "editor.defaultFormatter": "xaver.clang-format", }, + "clangd.arguments": ["-header-insertion=never"], // JavaScript "prettier.enable": true, diff --git a/package.json b/package.json index da392ef244..d8f239e0f4 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "typecheck": "tsc --noEmit && cd test && bun run typecheck", "fmt": "prettier --config=.prettierrc-ci --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'", "fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig", + "fmt:cpp": "clang-format -i src/bun.js/bindings/**/*.{cpp,h} --verbose", "lint": "eslint './**/*.d.ts' --cache", "lint:fix": "eslint './**/*.d.ts' --cache --fix", "test": "node scripts/runner.node.mjs ./build/bun-debug", diff --git a/src/bun.js/bindings/.clang-format-ignore b/src/bun.js/bindings/.clang-format-ignore new file mode 100644 index 0000000000..2a91525822 --- /dev/null +++ b/src/bun.js/bindings/.clang-format-ignore @@ -0,0 +1,2 @@ +*.lut.h +sqlite/sqlite3_local.h \ No newline at end of file diff --git a/src/bun.js/bindings/webcore/CallbackResult.h b/src/bun.js/bindings/webcore/CallbackResult.h index 878fe42219..abedf5a2ff 100644 --- a/src/bun.js/bindings/webcore/CallbackResult.h +++ b/src/bun.js/bindings/webcore/CallbackResult.h @@ -58,7 +58,6 @@ private: CallbackResultType m_type = CallbackResultType::Success; }; - template inline CallbackResult::CallbackResult(CallbackResultType type) : m_value(makeUnexpected(type)) { @@ -80,7 +79,6 @@ template inline auto CallbackResult::releaseRet return WTFMove(m_value.value()); } - // Void specialization inline CallbackResult::CallbackResult(CallbackResultType type) diff --git a/src/bun.js/bindings/webcore/CommonAtomStrings.cpp b/src/bun.js/bindings/webcore/CommonAtomStrings.cpp index 57cdc3d246..bf1cdcff08 100644 --- a/src/bun.js/bindings/webcore/CommonAtomStrings.cpp +++ b/src/bun.js/bindings/webcore/CommonAtomStrings.cpp @@ -28,12 +28,14 @@ namespace WebCore { +// clang-format off #define DEFINE_COMMON_ATOM(atomName, atomValue) \ MainThreadLazyNeverDestroyed atomName ## AtomData; #define INITIALIZE_COMMON_ATOM(atomName, atomValue) \ atomName ## AtomData.constructWithoutAccessCheck(atomValue ## _s); WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(DEFINE_COMMON_ATOM) +// clang-format on void initializeCommonAtomStrings() { diff --git a/src/bun.js/bindings/webcore/CommonAtomStrings.h b/src/bun.js/bindings/webcore/CommonAtomStrings.h index 0385f82224..8581023cd5 100644 --- a/src/bun.js/bindings/webcore/CommonAtomStrings.h +++ b/src/bun.js/bindings/webcore/CommonAtomStrings.h @@ -30,6 +30,7 @@ namespace WebCore { +// clang-format off #define WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(macro) \ macro(alternative, "alternative") \ macro(auto, "auto") \ @@ -66,6 +67,7 @@ namespace WebCore { WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(DECLARE_COMMON_ATOM) #undef DECLARE_COMMON_ATOM +// clang-format on WEBCORE_EXPORT void initializeCommonAtomStrings(); diff --git a/src/bun.js/bindings/webcore/DOMJITIDLConvert.h b/src/bun.js/bindings/webcore/DOMJITIDLConvert.h index 81395e125b..fbc95f7ebb 100644 --- a/src/bun.js/bindings/webcore/DOMJITIDLConvert.h +++ b/src/bun.js/bindings/webcore/DOMJITIDLConvert.h @@ -27,7 +27,8 @@ #include "IDLTypes.h" -namespace WebCore { namespace DOMJIT { +namespace WebCore { +namespace DOMJIT { template struct DirectConverter; @@ -56,4 +57,5 @@ struct DirectConverter> { } }; -} } +} +} diff --git a/src/bun.js/bindings/webcore/DOMJITIDLTypeFilter.h b/src/bun.js/bindings/webcore/DOMJITIDLTypeFilter.h index 7728db7d29..b7130336e6 100644 --- a/src/bun.js/bindings/webcore/DOMJITIDLTypeFilter.h +++ b/src/bun.js/bindings/webcore/DOMJITIDLTypeFilter.h @@ -28,53 +28,116 @@ #include "IDLTypes.h" #include -namespace WebCore { namespace DOMJIT { +namespace WebCore { +namespace DOMJIT { template struct IDLArgumentTypeFilter; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLArgumentTypeFilter> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLArgumentTypeFilter> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLArgumentTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; }; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLArgumentTypeFilter> { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLArgumentTypeFilter> { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLArgumentTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; +}; template struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecFullTop; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecHeapTop; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLResultTypeFilter> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLResultTypeFilter> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; }; -template<> struct IDLResultTypeFilter { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeTop; }; - +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecHeapTop; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLResultTypeFilter> { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLResultTypeFilter> { + static const constexpr JSC::SpeculatedType value = JSC::SpecString; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; +}; +template<> struct IDLResultTypeFilter { + static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeTop; +}; template struct IDLResultTypeFilter> { static const constexpr JSC::SpeculatedType value = JSC::SpecOther | IDLResultTypeFilter::value; }; -} } +} +} diff --git a/src/bun.js/bindings/webcore/DOMPromiseProxy.h b/src/bun.js/bindings/webcore/DOMPromiseProxy.h index 2b8706e76e..70d42122b7 100644 --- a/src/bun.js/bindings/webcore/DOMPromiseProxy.h +++ b/src/bun.js/bindings/webcore/DOMPromiseProxy.h @@ -36,6 +36,7 @@ namespace WebCore { template class DOMPromiseProxy { WTF_MAKE_FAST_ALLOCATED; + public: using Value = typename IDLType::StorageType; @@ -51,7 +52,7 @@ public: void resolve(typename IDLType::StorageType); void resolveWithNewlyCreated(typename IDLType::StorageType); void reject(Exception, RejectAsHandled = RejectAsHandled::No); - + private: JSC::JSValue resolvePromise(JSC::JSGlobalObject&, JSDOMGlobalObject&, const Function&); @@ -62,6 +63,7 @@ private: template<> class DOMPromiseProxy { WTF_MAKE_FAST_ALLOCATED; + public: DOMPromiseProxy() = default; ~DOMPromiseProxy() = default; @@ -87,10 +89,11 @@ private: template class DOMPromiseProxyWithResolveCallback { WTF_MAKE_FAST_ALLOCATED; + public: using ResolveCallback = Function; - template + template DOMPromiseProxyWithResolveCallback(Class&, typename IDLType::ParameterType (BaseClass::*)()); DOMPromiseProxyWithResolveCallback(ResolveCallback&&); ~DOMPromiseProxyWithResolveCallback() = default; @@ -104,7 +107,7 @@ public: void resolve(typename IDLType::ParameterType); void resolveWithNewlyCreated(typename IDLType::ParameterType); void reject(Exception, RejectAsHandled = RejectAsHandled::No); - + private: ResolveCallback m_resolveCallback; std::optional> m_valueOrException; @@ -208,7 +211,6 @@ inline void DOMPromiseProxy::reject(Exception exception, RejectAsHandle deferredPromise->reject(m_valueOrException->exception(), rejectAsHandled); } - // MARK: - DOMPromiseProxy specialization inline JSC::JSValue DOMPromiseProxy::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject) @@ -250,7 +252,7 @@ inline bool DOMPromiseProxy::isFulfilled() const inline void DOMPromiseProxy::resolve() { ASSERT(!m_valueOrException); - m_valueOrException = ExceptionOr { }; + m_valueOrException = ExceptionOr {}; for (auto& deferredPromise : m_deferredPromises) deferredPromise->resolve(); } @@ -266,7 +268,7 @@ inline void DOMPromiseProxy::reject(Exception exception, RejectAsH // MARK: - DOMPromiseProxyWithResolveCallback implementation template -template +template inline DOMPromiseProxyWithResolveCallback::DOMPromiseProxyWithResolveCallback(Class& object, typename IDLType::ParameterType (BaseClass::*function)()) : m_resolveCallback(std::bind(function, &object)) { @@ -322,7 +324,7 @@ inline void DOMPromiseProxyWithResolveCallback::resolve(typename IDLTyp { ASSERT(!m_valueOrException); - m_valueOrException = ExceptionOr { }; + m_valueOrException = ExceptionOr {}; for (auto& deferredPromise : m_deferredPromises) deferredPromise->template resolve(value); } @@ -332,7 +334,7 @@ inline void DOMPromiseProxyWithResolveCallback::resolveWithNewlyCreated { ASSERT(!m_valueOrException); - m_valueOrException = ExceptionOr { }; + m_valueOrException = ExceptionOr {}; for (auto& deferredPromise : m_deferredPromises) deferredPromise->template resolveWithNewlyCreated(value); } diff --git a/src/bun.js/bindings/webcore/ErrorCallback.cpp b/src/bun.js/bindings/webcore/ErrorCallback.cpp index 5b81eea065..5c9aab344c 100644 --- a/src/bun.js/bindings/webcore/ErrorCallback.cpp +++ b/src/bun.js/bindings/webcore/ErrorCallback.cpp @@ -33,7 +33,7 @@ namespace WebCore { void ErrorCallback::scheduleCallback(ScriptExecutionContext& context, Ref&& exception) { - context.postTask([protectedThis = Ref { *this }, exception = WTFMove(exception)] (ScriptExecutionContext&) { + context.postTask([protectedThis = Ref { *this }, exception = WTFMove(exception)](ScriptExecutionContext&) { protectedThis->handleEvent(exception); }); } diff --git a/src/bun.js/bindings/webcore/EventListener.h b/src/bun.js/bindings/webcore/EventListener.h index 7ceb38b1e6..b50a6898ad 100644 --- a/src/bun.js/bindings/webcore/EventListener.h +++ b/src/bun.js/bindings/webcore/EventListener.h @@ -53,14 +53,14 @@ public: virtual bool operator==(const EventListener&) const = 0; virtual void handleEvent(ScriptExecutionContext&, Event&) = 0; - virtual void visitJSFunction(JSC::AbstractSlotVisitor&) { } - virtual void visitJSFunction(JSC::SlotVisitor&) { } + virtual void visitJSFunction(JSC::AbstractSlotVisitor&) {} + virtual void visitJSFunction(JSC::SlotVisitor&) {} virtual bool isAttribute() const { return false; } Type type() const { return m_type; } #if ASSERT_ENABLED - virtual void checkValidityForEventTarget(EventTarget&) { } + virtual void checkValidityForEventTarget(EventTarget&) {} #endif virtual JSC::JSObject* jsFunction() const { return nullptr; } diff --git a/src/bun.js/bindings/webcore/EventListenerOptions.h b/src/bun.js/bindings/webcore/EventListenerOptions.h index 101b44bce2..f8de32875b 100644 --- a/src/bun.js/bindings/webcore/EventListenerOptions.h +++ b/src/bun.js/bindings/webcore/EventListenerOptions.h @@ -30,7 +30,8 @@ namespace WebCore { struct EventListenerOptions { EventListenerOptions(bool capture = false) : capture(capture) - { } + { + } bool capture { false }; }; diff --git a/src/bun.js/bindings/webcore/EventOptions.h b/src/bun.js/bindings/webcore/EventOptions.h index ec59b69801..d98f4b7c30 100644 --- a/src/bun.js/bindings/webcore/EventOptions.h +++ b/src/bun.js/bindings/webcore/EventOptions.h @@ -27,9 +27,13 @@ namespace WebCore { -enum class EventIsTrusted : bool { No, Yes }; -enum class EventCanBubble : bool { No, Yes }; -enum class EventIsCancelable : bool { No, Yes }; -enum class EventIsComposed : bool { No, Yes }; +enum class EventIsTrusted : bool { No, + Yes }; +enum class EventCanBubble : bool { No, + Yes }; +enum class EventIsCancelable : bool { No, + Yes }; +enum class EventIsComposed : bool { No, + Yes }; } diff --git a/src/bun.js/bindings/webcore/EventSender.h b/src/bun.js/bindings/webcore/EventSender.h index d69a6e5e9c..246329841d 100644 --- a/src/bun.js/bindings/webcore/EventSender.h +++ b/src/bun.js/bindings/webcore/EventSender.h @@ -34,7 +34,9 @@ namespace WebCore { class Page; template class EventSender { - WTF_MAKE_NONCOPYABLE(EventSender); WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_NONCOPYABLE(EventSender); + WTF_MAKE_FAST_ALLOCATED; + public: explicit EventSender(const AtomString& eventType); @@ -98,7 +100,7 @@ template void EventSender::dispatchPendingEvents(Page* page) m_dispatchSoonList.checkConsistency(); - m_dispatchingList = std::exchange(m_dispatchSoonList, { }); + m_dispatchingList = std::exchange(m_dispatchSoonList, {}); for (auto& event : m_dispatchingList) { if (auto sender = event.get()) { event = nullptr; diff --git a/src/bun.js/bindings/webcore/InternalWritableStream.cpp b/src/bun.js/bindings/webcore/InternalWritableStream.cpp index d3988c9084..d63acc71f5 100644 --- a/src/bun.js/bindings/webcore/InternalWritableStream.cpp +++ b/src/bun.js/bindings/webcore/InternalWritableStream.cpp @@ -127,7 +127,7 @@ JSC::JSValue InternalWritableStream::abort(JSC::JSGlobalObject& globalObject, JS auto result = invokeWritableStreamFunction(globalObject, privateName, arguments); if (result.hasException()) - return { }; + return {}; return result.returnValue(); } @@ -143,7 +143,7 @@ JSC::JSValue InternalWritableStream::close(JSC::JSGlobalObject& globalObject) auto result = invokeWritableStreamFunction(globalObject, privateName, arguments); if (result.hasException()) - return { }; + return {}; return result.returnValue(); } @@ -159,7 +159,7 @@ JSC::JSValue InternalWritableStream::getWriter(JSC::JSGlobalObject& globalObject auto result = invokeWritableStreamFunction(globalObject, privateName, arguments); if (result.hasException()) - return { }; + return {}; return result.returnValue(); } diff --git a/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.h b/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.h index 75d5288145..20fb28e915 100644 --- a/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.h +++ b/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSByteLengthQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSCloseEvent.h b/src/bun.js/bindings/webcore/JSCloseEvent.h index d7f25493b0..13dc230087 100644 --- a/src/bun.js/bindings/webcore/JSCloseEvent.h +++ b/src/bun.js/bindings/webcore/JSCloseEvent.h @@ -61,6 +61,7 @@ public: { return static_cast(Base::wrapped()); } + protected: JSCloseEvent(JSC::Structure*, JSDOMGlobalObject&, Ref&&); @@ -78,5 +79,4 @@ template<> struct JSDOMWrapperConverterTraits { }; template<> CloseEvent::Init convertDictionary(JSC::JSGlobalObject&, JSC::JSValue); - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSCountQueuingStrategy.h b/src/bun.js/bindings/webcore/JSCountQueuingStrategy.h index 0cd89d4fc7..0e582615ea 100644 --- a/src/bun.js/bindings/webcore/JSCountQueuingStrategy.h +++ b/src/bun.js/bindings/webcore/JSCountQueuingStrategy.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSCountQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSDOMAttribute.h b/src/bun.js/bindings/webcore/JSDOMAttribute.h index 17b0f588c7..19923b76c7 100644 --- a/src/bun.js/bindings/webcore/JSDOMAttribute.h +++ b/src/bun.js/bindings/webcore/JSDOMAttribute.h @@ -76,7 +76,7 @@ public: { return setter(lexicalGlobalObject, JSC::JSValue::decode(encodedValue)); } - + template static JSC::EncodedJSValue get(JSC::JSGlobalObject& lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName attributeName) { diff --git a/src/bun.js/bindings/webcore/JSDOMConvertBase.h b/src/bun.js/bindings/webcore/JSDOMConvertBase.h index d1b994f090..737b65bc12 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertBase.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertBase.h @@ -38,10 +38,10 @@ template struct Converter; namespace Detail { -template inline T* getPtrOrRef(const T* p) { return const_cast(p); } -template inline T& getPtrOrRef(const T& p) { return const_cast(p); } -template inline T* getPtrOrRef(const RefPtr& p) { return p.get(); } -template inline T& getPtrOrRef(const Ref& p) { return p.get(); } +template inline T* getPtrOrRef(const T* p) { return const_cast(p); } +template inline T& getPtrOrRef(const T& p) { return const_cast(p); } +template inline T* getPtrOrRef(const RefPtr& p) { return p.get(); } +template inline T& getPtrOrRef(const Ref& p) { return p.get(); } } @@ -89,7 +89,6 @@ template inline typename Converter::Re return Converter::convert(lexicalGlobalObject, value, globalObject, std::forward(exceptionThrower)); } - // Conversion from Implementation -> JSValue template struct JSConverter; @@ -171,7 +170,7 @@ template inline JSC::JSValue toJS(JSC::JSGlobalObject& l auto result = valueOrFunctor(); if (UNLIKELY(result.hasException())) { propagateException(lexicalGlobalObject, throwScope, result.releaseException()); - return { }; + return {}; } return JSC::jsUndefined(); } else @@ -180,7 +179,7 @@ template inline JSC::JSValue toJS(JSC::JSGlobalObject& l if constexpr (IsExceptionOr) { if (UNLIKELY(valueOrFunctor.hasException())) { propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException()); - return { }; + return {}; } return toJS(lexicalGlobalObject, valueOrFunctor.releaseReturnValue()); @@ -201,7 +200,7 @@ template inline JSC::JSValue toJS(JSC::JSGlobalObject& l auto result = valueOrFunctor(); if (UNLIKELY(result.hasException())) { propagateException(lexicalGlobalObject, throwScope, result.releaseException()); - return { }; + return {}; } return JSC::jsUndefined(); } else @@ -210,7 +209,7 @@ template inline JSC::JSValue toJS(JSC::JSGlobalObject& l if constexpr (IsExceptionOr) { if (UNLIKELY(valueOrFunctor.hasException())) { propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException()); - return { }; + return {}; } return toJS(lexicalGlobalObject, globalObject, valueOrFunctor.releaseReturnValue()); @@ -231,7 +230,7 @@ template inline JSC::JSValue toJSNewlyCreated(JSC::JSGlo auto result = valueOrFunctor(); if (UNLIKELY(result.hasException())) { propagateException(lexicalGlobalObject, throwScope, result.releaseException()); - return { }; + return {}; } return JSC::jsUndefined(); } else @@ -241,7 +240,7 @@ template inline JSC::JSValue toJSNewlyCreated(JSC::JSGlo if constexpr (IsExceptionOr) { if (UNLIKELY(valueOrFunctor.hasException())) { propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException()); - return { }; + return {}; } return toJSNewlyCreated(lexicalGlobalObject, globalObject, valueOrFunctor.releaseReturnValue()); diff --git a/src/bun.js/bindings/webcore/JSDOMConvertCallbacks.h b/src/bun.js/bindings/webcore/JSDOMConvertCallbacks.h index eb49f2357e..05dcc37ae1 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertCallbacks.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertCallbacks.h @@ -68,7 +68,7 @@ template struct JSConverter> { static constexpr bool needsState = false; static constexpr bool needsGlobalObject = false; - template + template static JSC::JSValue convert(const U& value) { return toJS(Detail::getPtrOrRef(value)); @@ -81,7 +81,6 @@ template struct JSConverter> { } }; - template struct Converter> : DefaultConverter> { template static RefPtr convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower()) @@ -102,7 +101,7 @@ template struct JSConverter> { static constexpr bool needsState = false; static constexpr bool needsGlobalObject = false; - template + template static JSC::JSValue convert(const U& value) { return toJS(Detail::getPtrOrRef(value)); diff --git a/src/bun.js/bindings/webcore/JSDOMConvertDictionary.h b/src/bun.js/bindings/webcore/JSDOMConvertDictionary.h index 94173b16fd..87f1a1c468 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertDictionary.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertDictionary.h @@ -33,7 +33,6 @@ namespace WebCore { // Specialized by generated code for IDL dictionary conversion. template T convertDictionary(JSC::JSGlobalObject&, JSC::JSValue); - template struct Converter> : DefaultConverter> { using ReturnType = T; diff --git a/src/bun.js/bindings/webcore/JSDOMConvertNullable.h b/src/bun.js/bindings/webcore/JSDOMConvertNullable.h index a3e4b5cc41..549d126bb4 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertNullable.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertNullable.h @@ -38,7 +38,7 @@ namespace Detail { template struct NullableConversionType; -template +template struct NullableConversionType { using Type = typename IDLNullable::ImplementationType; }; @@ -57,7 +57,7 @@ struct NullableConversionType { template struct Converter> : DefaultConverter> { using ReturnType = typename Detail::NullableConversionType::Type; - + // 1. If Type(V) is not Object, and the conversion to an IDL value is being performed // due to V being assigned to an attribute whose type is a nullable callback function // that is annotated with [LegacyTreatNonObjectAsNull], then return the IDL nullable @@ -146,5 +146,4 @@ template struct JSConverter> { } }; - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSDOMConvertNumbers.h b/src/bun.js/bindings/webcore/JSDOMConvertNumbers.h index 29413d8d98..9d8bd929ee 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertNumbers.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertNumbers.h @@ -251,7 +251,6 @@ template struct JSConverter> { } }; - template struct Converter> : DefaultConverter> { using ReturnType = typename IDLEnforceRangeAdaptor::ImplementationType; @@ -273,7 +272,6 @@ template struct JSConverter> { } }; - // MARK: - // MARK: Floating point types diff --git a/src/bun.js/bindings/webcore/JSDOMConvertWebGL.h b/src/bun.js/bindings/webcore/JSDOMConvertWebGL.h index ae8f7e688d..0f899215ac 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertWebGL.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertWebGL.h @@ -56,7 +56,7 @@ template<> struct JSConverter { static constexpr bool needsState = true; static constexpr bool needsGlobalObject = true; - template + template static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const T& value) { return convertToJSValue(lexicalGlobalObject, globalObject, Detail::getPtrOrRef(value)); diff --git a/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h b/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h index c4d1513ad5..c90c5f2536 100644 --- a/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h +++ b/src/bun.js/bindings/webcore/JSDOMOperationReturningPromise.h @@ -38,7 +38,7 @@ public: template static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName) { - return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref&& promise) { + return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName](JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref&& promise) { auto* thisObject = IDLOperation::cast(lexicalGlobalObject, callFrame); if constexpr (shouldThrow != CastedThisErrorBehavior::Assert) { if (UNLIKELY(!thisObject)) @@ -47,7 +47,7 @@ public: ASSERT(thisObject); ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info()); - + // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject and thisObject. return operation(&lexicalGlobalObject, &callFrame, thisObject, WTFMove(promise)); })); @@ -74,7 +74,7 @@ public: template static JSC::EncodedJSValue callStatic(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char*) { - return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref&& promise) { + return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref&& promise) { // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject. return operation(&lexicalGlobalObject, &callFrame, WTFMove(promise)); })); diff --git a/src/bun.js/bindings/webcore/JSDOMPromise.h b/src/bun.js/bindings/webcore/JSDOMPromise.h index 97ebafa747..742ecbc392 100644 --- a/src/bun.js/bindings/webcore/JSDOMPromise.h +++ b/src/bun.js/bindings/webcore/JSDOMPromise.h @@ -44,11 +44,14 @@ public: return guarded(); } - enum class IsCallbackRegistered { No, Yes }; + enum class IsCallbackRegistered { No, + Yes }; IsCallbackRegistered whenSettled(std::function&&); JSC::JSValue result() const; - enum class Status { Pending, Fulfilled, Rejected }; + enum class Status { Pending, + Fulfilled, + Rejected }; Status status() const; static IsCallbackRegistered whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, Function&&); diff --git a/src/bun.js/bindings/webcore/JSEventCustom.cpp b/src/bun.js/bindings/webcore/JSEventCustom.cpp index 2f8a9b04d5..8df99f03c5 100644 --- a/src/bun.js/bindings/webcore/JSEventCustom.cpp +++ b/src/bun.js/bindings/webcore/JSEventCustom.cpp @@ -6,13 +6,13 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED diff --git a/src/bun.js/bindings/webcore/JSEventDOMJIT.cpp b/src/bun.js/bindings/webcore/JSEventDOMJIT.cpp index f6c6b77d80..e6b70181d1 100644 --- a/src/bun.js/bindings/webcore/JSEventDOMJIT.cpp +++ b/src/bun.js/bindings/webcore/JSEventDOMJIT.cpp @@ -30,7 +30,6 @@ #include "DOMJITCheckDOM.h" - namespace WebCore { using namespace JSC; diff --git a/src/bun.js/bindings/webcore/JSPerformanceMark.h b/src/bun.js/bindings/webcore/JSPerformanceMark.h index dd838da31c..00c92883ef 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceMark.h +++ b/src/bun.js/bindings/webcore/JSPerformanceMark.h @@ -63,6 +63,7 @@ public: { return static_cast(Base::wrapped()); } + protected: JSPerformanceMark(JSC::Structure*, JSDOMGlobalObject&, Ref&&); diff --git a/src/bun.js/bindings/webcore/JSPerformanceMarkOptions.cpp b/src/bun.js/bindings/webcore/JSPerformanceMarkOptions.cpp index e638624f01..1a7ff1fbe3 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceMarkOptions.cpp +++ b/src/bun.js/bindings/webcore/JSPerformanceMarkOptions.cpp @@ -25,7 +25,6 @@ #include "JSDOMConvertNumbers.h" #include - namespace WebCore { using namespace JSC; @@ -37,7 +36,7 @@ template<> PerformanceMarkOptions convertDictionary(JSGl auto* object = isNullOrUndefined ? nullptr : value.getObject(); if (UNLIKELY(!isNullOrUndefined && !object)) { throwTypeError(&lexicalGlobalObject, throwScope); - return { }; + return {}; } PerformanceMarkOptions result; JSValue detailValue; @@ -45,11 +44,11 @@ template<> PerformanceMarkOptions convertDictionary(JSGl detailValue = jsUndefined(); else { detailValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "detail"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!detailValue.isUndefined()) { result.detail = convert(lexicalGlobalObject, detailValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } else result.detail = jsUndefined(); JSValue startTimeValue; @@ -57,11 +56,11 @@ template<> PerformanceMarkOptions convertDictionary(JSGl startTimeValue = jsUndefined(); else { startTimeValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "startTime"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!startTimeValue.isUndefined()) { result.startTime = convert(lexicalGlobalObject, startTimeValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } return result; } diff --git a/src/bun.js/bindings/webcore/JSPerformanceMeasure.h b/src/bun.js/bindings/webcore/JSPerformanceMeasure.h index 6f31644b01..15134c1891 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceMeasure.h +++ b/src/bun.js/bindings/webcore/JSPerformanceMeasure.h @@ -63,13 +63,13 @@ public: { return static_cast(Base::wrapped()); } + protected: JSPerformanceMeasure(JSC::Structure*, JSDOMGlobalObject&, Ref&&); DECLARE_DEFAULT_FINISH_CREATION; }; - template<> struct JSDOMWrapperConverterTraits { using WrapperClass = JSPerformanceMeasure; using ToWrappedReturnType = PerformanceMeasure*; diff --git a/src/bun.js/bindings/webcore/JSPerformanceMeasureOptions.cpp b/src/bun.js/bindings/webcore/JSPerformanceMeasureOptions.cpp index cb5b4d6c25..8eaa6dd9cb 100644 --- a/src/bun.js/bindings/webcore/JSPerformanceMeasureOptions.cpp +++ b/src/bun.js/bindings/webcore/JSPerformanceMeasureOptions.cpp @@ -28,7 +28,6 @@ #include #include - namespace WebCore { using namespace JSC; @@ -40,7 +39,7 @@ template<> PerformanceMeasureOptions convertDictionary PerformanceMeasureOptions convertDictionaryget(&lexicalGlobalObject, Identifier::fromString(vm, "detail"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!detailValue.isUndefined()) { result.detail = convert(lexicalGlobalObject, detailValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } else result.detail = jsUndefined(); JSValue durationValue; @@ -60,33 +59,33 @@ template<> PerformanceMeasureOptions convertDictionaryget(&lexicalGlobalObject, Identifier::fromString(vm, "duration"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!durationValue.isUndefined()) { result.duration = convert(lexicalGlobalObject, durationValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } JSValue endValue; if (isNullOrUndefined) endValue = jsUndefined(); else { endValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "end"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!endValue.isUndefined()) { result.end = convert>(lexicalGlobalObject, endValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } JSValue startValue; if (isNullOrUndefined) startValue = jsUndefined(); else { startValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "start"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!startValue.isUndefined()) { result.start = convert>(lexicalGlobalObject, startValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } return result; } diff --git a/src/bun.js/bindings/webcore/JSReadableByteStreamController.h b/src/bun.js/bindings/webcore/JSReadableByteStreamController.h index 6d512aaed6..6fbe0488f5 100644 --- a/src/bun.js/bindings/webcore/JSReadableByteStreamController.h +++ b/src/bun.js/bindings/webcore/JSReadableByteStreamController.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSReadableByteStreamController(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.h b/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.h index 8d69390aed..b206a3beed 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.h +++ b/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSReadableStreamBYOBReader(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.h b/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.h index 39f18c2291..94bb293b44 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.h +++ b/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSReadableStreamBYOBRequest(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.h b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.h index a38c95daf9..4279e712f1 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.h +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSReadableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.h b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.h index 61a4d13366..4178cf2be9 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.h +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSReadableStreamDefaultReader(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSReadableStreamSourceCustom.cpp b/src/bun.js/bindings/webcore/JSReadableStreamSourceCustom.cpp index 476c0f8528..7082fd6f29 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamSourceCustom.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamSourceCustom.cpp @@ -37,7 +37,7 @@ using namespace JSC; JSValue JSReadableStreamSource::start(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame, Ref&& promise) { VM& vm = lexicalGlobalObject.vm(); - + // FIXME: Why is it ok to ASSERT the argument count here? ASSERT(callFrame.argumentCount()); JSReadableStreamDefaultController* controller = jsDynamicCast(callFrame.uncheckedArgument(0)); diff --git a/src/bun.js/bindings/webcore/JSTransformStream.h b/src/bun.js/bindings/webcore/JSTransformStream.h index 26646df030..a68e7da476 100644 --- a/src/bun.js/bindings/webcore/JSTransformStream.h +++ b/src/bun.js/bindings/webcore/JSTransformStream.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSTransformStream(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.h b/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.h index e63fdd7c41..9fe4c0568f 100644 --- a/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.h +++ b/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSTransformStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.h b/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.h index 8da0be568f..c695f439b9 100644 --- a/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.h +++ b/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSWritableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.h b/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.h index bc13fb8c1b..3434df33a2 100644 --- a/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.h +++ b/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.h @@ -53,12 +53,11 @@ public: return subspaceForImpl(vm); } static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm); + protected: JSWritableStreamDefaultWriter(JSC::Structure*, JSDOMGlobalObject&); void finishCreation(JSC::VM&); }; - - } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/Performance.h b/src/bun.js/bindings/webcore/Performance.h index 70fc7b212c..ce3549af1f 100644 --- a/src/bun.js/bindings/webcore/Performance.h +++ b/src/bun.js/bindings/webcore/Performance.h @@ -78,6 +78,7 @@ struct PerformanceMeasureOptions; class Performance final : public RefCounted, public ContextDestructionObserver, public EventTarget { WTF_MAKE_ISO_ALLOCATED(Performance); + public: static Ref create(ScriptExecutionContext* context, MonotonicTime timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); } ~Performance(); @@ -123,14 +124,13 @@ public: ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } - using RefCounted::ref; using RefCounted::deref; + using RefCounted::ref; // void scheduleNavigationObservationTaskIfNeeded(); // PerformanceNavigationTiming* navigationTiming() { return m_navigationTiming.get(); } - // EventTargetData* eventTargetData() override; // EventTargetData* eventTargetDataConcurrently() override; // EventTargetData& ensureEventTargetData() override; @@ -174,7 +174,6 @@ private: ListHashSet> m_observers; - EventTargetData* eventTargetData() final { return &m_eventTargetData; } EventTargetData* eventTargetDataConcurrently() final { return &m_eventTargetData; } EventTargetData& ensureEventTargetData() final { return m_eventTargetData; } diff --git a/src/bun.js/bindings/webcore/PerformanceMeasure.cpp b/src/bun.js/bindings/webcore/PerformanceMeasure.cpp index 6c9e0fa62f..5c24b08dea 100644 --- a/src/bun.js/bindings/webcore/PerformanceMeasure.cpp +++ b/src/bun.js/bindings/webcore/PerformanceMeasure.cpp @@ -48,7 +48,7 @@ JSC::JSValue PerformanceMeasure::detail(JSC::JSGlobalObject& globalObject) if (!m_serializedDetail) { return JSC::jsNull(); } - + return m_serializedDetail->deserialize(globalObject, &globalObject); } diff --git a/src/bun.js/bindings/webcore/PerformanceObserver.cpp b/src/bun.js/bindings/webcore/PerformanceObserver.cpp index 5aa7c7d8af..75fa7d7b40 100644 --- a/src/bun.js/bindings/webcore/PerformanceObserver.cpp +++ b/src/bun.js/bindings/webcore/PerformanceObserver.cpp @@ -48,7 +48,6 @@ PerformanceObserver::PerformanceObserver(ScriptExecutionContext& scriptExecution // } else // ASSERT_NOT_REACHED(); m_performance = jsCast(scriptExecutionContext.globalObject())->performance(); - } void PerformanceObserver::disassociate() @@ -74,7 +73,7 @@ ExceptionOr PerformanceObserver::observe(Init&& init) filter.add(*type); } if (filter.isEmpty()) - return { }; + return {}; m_typeFilter = filter; } else { if (!init.type) @@ -85,7 +84,7 @@ ExceptionOr PerformanceObserver::observe(Init&& init) if (auto type = PerformanceEntry::parseEntryTypeString(*init.type)) filter.add(*type); else - return { }; + return {}; if (init.buffered) { isBuffered = true; auto oldSize = m_entriesToDeliver.size(); @@ -106,12 +105,12 @@ ExceptionOr PerformanceObserver::observe(Init&& init) if (isBuffered) deliver(); - return { }; + return {}; } Vector> PerformanceObserver::takeRecords() { - return std::exchange(m_entriesToDeliver, { }); + return std::exchange(m_entriesToDeliver, {}); } void PerformanceObserver::disconnect() @@ -121,7 +120,7 @@ void PerformanceObserver::disconnect() m_registered = false; m_entriesToDeliver.clear(); - m_typeFilter = { }; + m_typeFilter = {}; } void PerformanceObserver::queueEntry(PerformanceEntry& entry) @@ -138,7 +137,7 @@ void PerformanceObserver::deliver() if (!context) return; - Vector> entries = std::exchange(m_entriesToDeliver, { }); + Vector> entries = std::exchange(m_entriesToDeliver, {}); auto list = PerformanceObserverEntryList::create(WTFMove(entries)); // InspectorInstrumentation::willFireObserverCallback(*context, "PerformanceObserver"_s); diff --git a/src/bun.js/bindings/webcore/PerformanceObserverEntryList.h b/src/bun.js/bindings/webcore/PerformanceObserverEntryList.h index 6d7658780d..61f615c888 100644 --- a/src/bun.js/bindings/webcore/PerformanceObserverEntryList.h +++ b/src/bun.js/bindings/webcore/PerformanceObserverEntryList.h @@ -35,6 +35,7 @@ class PerformanceEntry; class PerformanceObserverEntryList : public RefCounted { WTF_MAKE_FAST_ALLOCATED; + public: static Ref create(Vector>&& entries); diff --git a/src/bun.js/bindings/webcore/PerformanceTiming.cpp b/src/bun.js/bindings/webcore/PerformanceTiming.cpp index 3e770a7617..a4081d6338 100644 --- a/src/bun.js/bindings/webcore/PerformanceTiming.cpp +++ b/src/bun.js/bindings/webcore/PerformanceTiming.cpp @@ -77,77 +77,77 @@ unsigned long long PerformanceTiming::fetchStart() const unsigned long long PerformanceTiming::domainLookupStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domainLookupEnd() const { -return 0; + return 0; } unsigned long long PerformanceTiming::connectStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::connectEnd() const { -return 0; + return 0; } unsigned long long PerformanceTiming::secureConnectionStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::requestStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::responseStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::responseEnd() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domLoading() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domInteractive() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domContentLoadedEventStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domContentLoadedEventEnd() const { -return 0; + return 0; } unsigned long long PerformanceTiming::domComplete() const { -return 0; + return 0; } unsigned long long PerformanceTiming::loadEventStart() const { -return 0; + return 0; } unsigned long long PerformanceTiming::loadEventEnd() const { -return 0; + return 0; } unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(MonotonicTime timeStamp) const diff --git a/src/bun.js/bindings/webcore/RegisteredEventListener.h b/src/bun.js/bindings/webcore/RegisteredEventListener.h index 1b2f48af49..a52890ef42 100644 --- a/src/bun.js/bindings/webcore/RegisteredEventListener.h +++ b/src/bun.js/bindings/webcore/RegisteredEventListener.h @@ -36,7 +36,8 @@ public: : capture(capture) , passive(passive) , once(once) - { } + { + } bool capture; bool passive; diff --git a/src/bun.js/bindings/webcore/WebSocketIdentifier.h b/src/bun.js/bindings/webcore/WebSocketIdentifier.h index 97884abd8e..ebbd804f51 100644 --- a/src/bun.js/bindings/webcore/WebSocketIdentifier.h +++ b/src/bun.js/bindings/webcore/WebSocketIdentifier.h @@ -29,7 +29,7 @@ namespace WebCore { -enum WebSocketIdentifierType { }; +enum WebSocketIdentifierType {}; using WebSocketIdentifier = ObjectIdentifier; } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/WritableStreamSink.h b/src/bun.js/bindings/webcore/WritableStreamSink.h index 2caa86c395..b15e34d91e 100644 --- a/src/bun.js/bindings/webcore/WritableStreamSink.h +++ b/src/bun.js/bindings/webcore/WritableStreamSink.h @@ -23,7 +23,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ - #pragma once #include "JSDOMPromiseDeferred.h" @@ -54,8 +53,8 @@ private: explicit SimpleWritableStreamSink(WriteCallback&&); void write(ScriptExecutionContext&, JSC::JSValue, DOMPromiseDeferred&&) final; - void close() final { } - void error(String&&) final { } + void close() final {} + void error(String&&) final {} WriteCallback m_writeCallback; }; diff --git a/src/bun.js/bindings/webcrypto/CommonCryptoDERUtilities.h b/src/bun.js/bindings/webcrypto/CommonCryptoDERUtilities.h index 2f991740fd..b64362a129 100644 --- a/src/bun.js/bindings/webcrypto/CommonCryptoDERUtilities.h +++ b/src/bun.js/bindings/webcrypto/CommonCryptoDERUtilities.h @@ -41,7 +41,7 @@ static const unsigned char IntegerMark = 0x02; static const unsigned char OctetStringMark = 0x04; static const unsigned char SequenceMark = 0x30; // Version 0. Per https://tools.ietf.org/html/rfc5208#section-5 -static const unsigned char Version[] = {0x02, 0x01, 0x00}; +static const unsigned char Version[] = { 0x02, 0x01, 0x00 }; static const unsigned char InitialOctet = 0x00; static const size_t MaxLengthInOneByte = 128; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CFB.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CFB.cpp index 88e8075b62..c5d802cfd1 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CFB.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CFB.cpp @@ -110,7 +110,7 @@ void CryptoAlgorithmAES_CFB::generateKey(const CryptoAlgorithmParameters& parame void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) { using namespace CryptoAlgorithmAES_CFBInternal; - + if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) { exceptionCallback(SyntaxError); return; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.cpp index 9b2648e8a1..09e397a9bb 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.cpp @@ -292,7 +292,7 @@ auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator~() c return { ~m_hi, ~m_lo }; } -auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator <<=(unsigned shift) -> CounterBlockBits& +auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator<<=(unsigned shift) -> CounterBlockBits& { if (shift < 64) { m_hi = (m_hi << shift) | m_lo >> (64 - shift); @@ -308,7 +308,7 @@ auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator <<=( return *this; } -auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator &=(const CounterBlockBits& rhs) -> CounterBlockBits& +auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator&=(const CounterBlockBits& rhs) -> CounterBlockBits& { m_hi &= rhs.m_hi; m_lo &= rhs.m_lo; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.h index 8bd39339dc..c3b41b2538 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmAES_CTR.h @@ -53,8 +53,8 @@ public: CounterBlockBits operator&(const CounterBlockBits&) const; CounterBlockBits operator~() const; - CounterBlockBits& operator <<=(unsigned); - CounterBlockBits& operator &=(const CounterBlockBits&); + CounterBlockBits& operator<<=(unsigned); + CounterBlockBits& operator&=(const CounterBlockBits&); uint64_t m_hi { 0 }; uint64_t m_lo { 0 }; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSA.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSA.h index 00687cd9a9..75efa7046f 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSA.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSA.h @@ -42,6 +42,7 @@ public: static ExceptionOr> platformSign(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector&); static ExceptionOr platformVerify(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector&, const Vector&); + private: CryptoAlgorithmECDSA() = default; CryptoAlgorithmIdentifier identifier() const final; @@ -51,7 +52,6 @@ private: void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; void exportKey(CryptoKeyFormat, Ref&&, KeyDataCallback&&, ExceptionCallback&&) final; - }; } // namespace WebCore diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSAOpenSSL.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSAOpenSSL.cpp index de6f773f56..fa114bca31 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSAOpenSSL.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmECDSAOpenSSL.cpp @@ -62,7 +62,7 @@ ExceptionOr> CryptoAlgorithmECDSA::platformSign(const CryptoAlgo return Exception { OperationError }; Vector signature(derSigLength); uint8_t* p = signature.data(); - if(i2d_ECDSA_SIG(sig.get(), &p) != derSigLength) + if (i2d_ECDSA_SIG(sig.get(), &p) != derSigLength) return Exception { OperationError }; return signature; } else { @@ -107,7 +107,7 @@ ExceptionOr CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmEcds // Bail if the signature size isn't double the key size (i.e. concatenated r and s components). if (signature.size() != keySizeInBytes * 2) return false; - + auto sig = ECDSASigPtr(ECDSA_SIG_new()); auto r = BN_bin2bn(signature.data(), keySizeInBytes, nullptr); auto s = BN_bin2bn(signature.data() + keySizeInBytes, keySizeInBytes, nullptr); diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmEd25519.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmEd25519.h index 9b2eb8cc64..65dcd06644 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmEd25519.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmEd25519.h @@ -39,11 +39,12 @@ public: static ExceptionOr> platformSign(const CryptoKeyOKP&, const Vector&); static ExceptionOr platformVerify(const CryptoKeyOKP&, const Vector&, const Vector&); + private: CryptoAlgorithmEd25519() = default; CryptoAlgorithmIdentifier identifier() const final; - void generateKey(const CryptoAlgorithmParameters& , bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& , ExceptionCallback&& , ScriptExecutionContext&); + void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&); void sign(const CryptoAlgorithmParameters&, Ref&&, Vector&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; void verify(const CryptoAlgorithmParameters&, Ref&&, Vector&& signature, Vector&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHKDF.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHKDF.cpp index 5c7a2f4c53..b45e6aa8a2 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHKDF.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHKDF.cpp @@ -80,7 +80,7 @@ ExceptionOr CryptoAlgorithmHKDF::getKeyLength(const CryptoAlgorithmParam { return 0; } - + } // namespace WebCore #endif // ENABLE(WEB_CRYPTO) diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMAC.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMAC.h index 22064797ae..eb69939b8b 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMAC.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMAC.h @@ -45,7 +45,6 @@ public: static ExceptionOr platformVerify(const CryptoKeyHMAC&, const Vector&, const Vector&); static ExceptionOr platformVerifyWithAlgorithm(const CryptoKeyHMAC&, CryptoAlgorithmIdentifier, const Vector&, const Vector&); - private: CryptoAlgorithmHMAC() = default; CryptoAlgorithmIdentifier identifier() const final; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMACOpenSSL.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMACOpenSSL.cpp index c71751b360..2caf8149e8 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMACOpenSSL.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmHMACOpenSSL.cpp @@ -59,8 +59,9 @@ static std::optional> calculateSignature(const EVP_MD* algorithm return cipherText; } -ExceptionOr> CryptoAlgorithmHMAC::platformSignWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector& data) { - +ExceptionOr> CryptoAlgorithmHMAC::platformSignWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector& data) +{ + auto algorithm = digestAlgorithm(algorithmIdentifier); if (!algorithm) return Exception { OperationError }; @@ -83,7 +84,8 @@ ExceptionOr> CryptoAlgorithmHMAC::platformSign(const CryptoKeyHM return WTFMove(*result); } -ExceptionOr CryptoAlgorithmHMAC::platformVerifyWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector& signature, const Vector& data) { +ExceptionOr CryptoAlgorithmHMAC::platformVerifyWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector& signature, const Vector& data) +{ auto algorithm = digestAlgorithm(algorithmIdentifier); if (!algorithm) diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmParameters.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmParameters.h index ae47350ec9..2b398bc295 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmParameters.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmParameters.h @@ -67,9 +67,13 @@ public: } // namespace WebCore +// clang-format off + #define SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(ToClassName) \ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CryptoAlgorithm##ToClassName) \ static bool isType(const WebCore::CryptoAlgorithmParameters& parameters) { return parameters.parametersClass() == WebCore::CryptoAlgorithmParameters::Class::ToClassName; } \ SPECIALIZE_TYPE_TRAITS_END() +// clang-format on + #endif // ENABLE(WEB_CRYPTO) diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5.h index a08f08854a..bf9419a01e 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5.h @@ -45,7 +45,6 @@ public: static ExceptionOr platformVerify(const CryptoKeyRSA&, const Vector&, const Vector&); static ExceptionOr platformVerifyWithAlgorithm(const CryptoKeyRSA&, CryptoAlgorithmIdentifier, const Vector&, const Vector&); - private: CryptoAlgorithmRSASSA_PKCS1_v1_5() = default; CryptoAlgorithmIdentifier identifier() const final; diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5OpenSSL.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5OpenSSL.cpp index f31585a3a4..8d7f74168c 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5OpenSSL.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSASSA_PKCS1_v1_5OpenSSL.cpp @@ -33,8 +33,8 @@ namespace WebCore { - -static ExceptionOr> signWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector& data) { +static ExceptionOr> signWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector& data) +{ std::optional> digest = calculateDigest(md, data); if (!digest) @@ -65,7 +65,8 @@ static ExceptionOr> signWithEVP_MD(const CryptoKeyRSA& key, con return signature; } -ExceptionOr> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSignWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector& data) { +ExceptionOr> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSignWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector& data) +{ const EVP_MD* md = digestAlgorithm(algorithm); if (!md) @@ -82,8 +83,8 @@ ExceptionOr> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(cons return signWithEVP_MD(key, md, data); } - -static ExceptionOr verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector& signature, const Vector& data) { +static ExceptionOr verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector& signature, const Vector& data) +{ std::optional> digest = calculateDigest(md, data); if (!digest) return Exception { OperationError }; @@ -106,7 +107,8 @@ static ExceptionOr verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD return ret == 1; } -ExceptionOr CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector& signature, const Vector& data) { +ExceptionOr CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector& signature, const Vector& data) +{ const EVP_MD* md = digestAlgorithm(algorithm); if (!md) return Exception { NotSupportedError }; @@ -114,7 +116,6 @@ ExceptionOr CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm( return verifyWithEVP_MD(key, md, signature, data); } - ExceptionOr CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKeyRSA& key, const Vector& signature, const Vector& data) { const EVP_MD* md = digestAlgorithm(key.hashAlgorithmIdentifier()); diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSS.h b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSS.h index 5b79811796..d87f04565b 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSS.h +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSS.h @@ -46,7 +46,6 @@ public: static ExceptionOr platformVerify(const CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector&, const Vector&); static ExceptionOr platformVerifyWithAlgorithm(const CryptoAlgorithmRsaPssParams&, CryptoAlgorithmIdentifier, const CryptoKeyRSA&, const Vector&, const Vector&); - private: CryptoAlgorithmRSA_PSS() = default; CryptoAlgorithmIdentifier identifier() const final; @@ -56,7 +55,6 @@ private: void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; void exportKey(CryptoKeyFormat, Ref&&, KeyDataCallback&&, ExceptionCallback&&) final; - }; } // namespace WebCore diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSSOpenSSL.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSSOpenSSL.cpp index c768bc519c..5aa3eb09ce 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSSOpenSSL.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_PSSOpenSSL.cpp @@ -37,7 +37,7 @@ namespace WebCore { static ExceptionOr> signWithMD(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector& data, const EVP_MD* md) { auto padding = parameters.padding; - if(padding == 0) { + if (padding == 0) { padding = RSA_PKCS1_PSS_PADDING; } std::optional> digest = calculateDigest(md, data); @@ -54,7 +54,7 @@ static ExceptionOr> signWithMD(const CryptoAlgorithmRsaPssParams if (EVP_PKEY_CTX_set_rsa_padding(ctx.get(), padding) <= 0) return Exception { OperationError }; - if(padding == RSA_PKCS1_PSS_PADDING) { + if (padding == RSA_PKCS1_PSS_PADDING) { if (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx.get(), parameters.saltLength) <= 0) return Exception { OperationError }; } @@ -89,7 +89,6 @@ ExceptionOr> CryptoAlgorithmRSA_PSS::platformSignWithAlgorithm(c #endif } - ExceptionOr> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector& data) { #if 1 // defined(EVP_PKEY_CTX_set_rsa_pss_saltlen) && defined(EVP_PKEY_CTX_set_rsa_mgf1_md) @@ -106,7 +105,7 @@ ExceptionOr> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAl static ExceptionOr verifyWithMD(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector& signature, const Vector& data, const EVP_MD* md) { auto padding = parameters.padding; - if(padding == 0) { + if (padding == 0) { padding = RSA_PKCS1_PSS_PADDING; } @@ -120,7 +119,7 @@ static ExceptionOr verifyWithMD(const CryptoAlgorithmRsaPssParams& paramet if (EVP_PKEY_CTX_set_rsa_padding(ctx.get(), padding) <= 0) return Exception { OperationError }; - if(padding == RSA_PKCS1_PSS_PADDING) { + if (padding == RSA_PKCS1_PSS_PADDING) { if (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx.get(), parameters.saltLength) <= 0) return Exception { OperationError }; } @@ -146,7 +145,6 @@ ExceptionOr CryptoAlgorithmRSA_PSS::platformVerifyWithAlgorithm(const Cryp return Exception { NotSupportedError }; return verifyWithMD(parameters, key, signature, data, md); - } ExceptionOr CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector& signature, const Vector& data) diff --git a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRegistry.cpp b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRegistry.cpp index d8192bc920..db6bf6cf43 100644 --- a/src/bun.js/bindings/webcrypto/CryptoAlgorithmRegistry.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoAlgorithmRegistry.cpp @@ -69,7 +69,7 @@ String CryptoAlgorithmRegistry::name(CryptoAlgorithmIdentifier identifier) auto contructor = m_constructors.find(static_cast(identifier)); if (contructor == m_constructors.end()) - return { }; + return {}; return contructor->value.first.isolatedCopy(); } @@ -97,7 +97,6 @@ void CryptoAlgorithmRegistry::registerAlgorithm(const String& name, CryptoAlgori m_constructors.add(static_cast(identifier), std::make_pair(name, constructor)); } - } // namespace WebCore #endif // ENABLE(WEB_CRYPTO) diff --git a/src/bun.js/bindings/webcrypto/CryptoEcKeyAlgorithm.h b/src/bun.js/bindings/webcrypto/CryptoEcKeyAlgorithm.h index dc6e67683d..10782d5db6 100644 --- a/src/bun.js/bindings/webcrypto/CryptoEcKeyAlgorithm.h +++ b/src/bun.js/bindings/webcrypto/CryptoEcKeyAlgorithm.h @@ -35,4 +35,3 @@ struct CryptoEcKeyAlgorithm : CryptoKeyAlgorithm { }; } - diff --git a/src/bun.js/bindings/webcrypto/CryptoHmacKeyAlgorithm.h b/src/bun.js/bindings/webcrypto/CryptoHmacKeyAlgorithm.h index 92aa132ba6..89549a4e05 100644 --- a/src/bun.js/bindings/webcrypto/CryptoHmacKeyAlgorithm.h +++ b/src/bun.js/bindings/webcrypto/CryptoHmacKeyAlgorithm.h @@ -37,5 +37,3 @@ struct CryptoHmacKeyAlgorithm : CryptoKeyAlgorithm { }; } - - diff --git a/src/bun.js/bindings/webcrypto/CryptoKeyHMAC.h b/src/bun.js/bindings/webcrypto/CryptoKeyHMAC.h index 714888019b..0ef4ad0900 100644 --- a/src/bun.js/bindings/webcrypto/CryptoKeyHMAC.h +++ b/src/bun.js/bindings/webcrypto/CryptoKeyHMAC.h @@ -43,7 +43,7 @@ public: { return adoptRef(*new CryptoKeyHMAC(key, hash, extractable, usage)); } - + virtual ~CryptoKeyHMAC(); static RefPtr generate(size_t lengthBits, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap); diff --git a/src/bun.js/bindings/webcrypto/CryptoKeyRSAOpenSSL.cpp b/src/bun.js/bindings/webcrypto/CryptoKeyRSAOpenSSL.cpp index ef4794e361..111cd081c6 100644 --- a/src/bun.js/bindings/webcrypto/CryptoKeyRSAOpenSSL.cpp +++ b/src/bun.js/bindings/webcrypto/CryptoKeyRSAOpenSSL.cpp @@ -395,7 +395,7 @@ std::unique_ptr CryptoKeyRSA::exportData() const return CryptoKeyRSAComponents::createPrivateWithAdditionalData( convertToBytes(n), convertToBytes(e), convertToBytes(d), - WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector { }); + WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector {}); } default: ASSERT_NOT_REACHED(); diff --git a/src/bun.js/bindings/webcrypto/CryptoRsaHashedKeyAlgorithm.h b/src/bun.js/bindings/webcrypto/CryptoRsaHashedKeyAlgorithm.h index 30109aa907..39a2f0d025 100644 --- a/src/bun.js/bindings/webcrypto/CryptoRsaHashedKeyAlgorithm.h +++ b/src/bun.js/bindings/webcrypto/CryptoRsaHashedKeyAlgorithm.h @@ -35,4 +35,3 @@ struct CryptoRsaHashedKeyAlgorithm : CryptoRsaKeyAlgorithm { }; } - diff --git a/src/bun.js/bindings/webcrypto/CryptoRsaKeyAlgorithm.h b/src/bun.js/bindings/webcrypto/CryptoRsaKeyAlgorithm.h index 7723d09f4f..4cc84c20ff 100644 --- a/src/bun.js/bindings/webcrypto/CryptoRsaKeyAlgorithm.h +++ b/src/bun.js/bindings/webcrypto/CryptoRsaKeyAlgorithm.h @@ -38,4 +38,3 @@ struct CryptoRsaKeyAlgorithm : CryptoKeyAlgorithm { }; } - diff --git a/src/bun.js/bindings/webcrypto/JSCryptoKeyPair.cpp b/src/bun.js/bindings/webcrypto/JSCryptoKeyPair.cpp index 82947e907f..b0b7ae2fe4 100644 --- a/src/bun.js/bindings/webcrypto/JSCryptoKeyPair.cpp +++ b/src/bun.js/bindings/webcrypto/JSCryptoKeyPair.cpp @@ -30,7 +30,6 @@ #include #include - namespace WebCore { using namespace JSC; @@ -44,7 +43,7 @@ template<> CryptoKeyPair convertDictionary(JSGlobalObject& lexica auto* object = isNullOrUndefined ? nullptr : value.getObject(); if (UNLIKELY(!isNullOrUndefined && !object)) { throwTypeError(&lexicalGlobalObject, throwScope); - return { }; + return {}; } CryptoKeyPair result; JSValue privateKeyValue; @@ -52,22 +51,22 @@ template<> CryptoKeyPair convertDictionary(JSGlobalObject& lexica privateKeyValue = jsUndefined(); else { privateKeyValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "privateKey"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!privateKeyValue.isUndefined()) { result.privateKey = convert>(lexicalGlobalObject, privateKeyValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } JSValue publicKeyValue; if (isNullOrUndefined) publicKeyValue = jsUndefined(); else { publicKeyValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "publicKey"_s)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } if (!publicKeyValue.isUndefined()) { result.publicKey = convert>(lexicalGlobalObject, publicKeyValue); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); } return result; } @@ -81,12 +80,12 @@ JSC::JSObject* convertDictionaryToJS(JSC::JSGlobalObject& lexicalGlobalObject, J if (!IDLInterface::isNullValue(dictionary.privateKey)) { auto privateKeyValue = toJS>(lexicalGlobalObject, globalObject, throwScope, IDLInterface::extractValueFromNullable(dictionary.privateKey)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "privateKey"_s), privateKeyValue); } if (!IDLInterface::isNullValue(dictionary.publicKey)) { auto publicKeyValue = toJS>(lexicalGlobalObject, globalObject, throwScope, IDLInterface::extractValueFromNullable(dictionary.publicKey)); - RETURN_IF_EXCEPTION(throwScope, { }); + RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "publicKey"_s), publicKeyValue); } return result; diff --git a/src/bun.js/bindings/webcrypto/OpenSSLCryptoUniquePtr.h b/src/bun.js/bindings/webcrypto/OpenSSLCryptoUniquePtr.h index b87aa561a1..0ce30dee6b 100644 --- a/src/bun.js/bindings/webcrypto/OpenSSLCryptoUniquePtr.h +++ b/src/bun.js/bindings/webcrypto/OpenSSLCryptoUniquePtr.h @@ -37,14 +37,14 @@ namespace WebCore { -template +template struct OpenSSLCryptoPtrDeleter { void operator()(T* ptr) const = delete; }; -template +template using OpenSSLCryptoPtr = std::unique_ptr>; - +// clang-format off #define DEFINE_OPENSSL_CRYPTO_PTR_FULL(alias, typeName, deleterFunc) \ template<> struct OpenSSLCryptoPtrDeleter { \ void operator()(typeName* ptr) const { \ @@ -55,7 +55,7 @@ using OpenSSLCryptoPtr = std::unique_ptr>; #define DEFINE_OPENSSL_CRYPTO_PTR(alias, typeName, deleterFunc) \ DEFINE_OPENSSL_CRYPTO_PTR_FULL(alias, typeName, deleterFunc(ptr)) - +// clang-format on DEFINE_OPENSSL_CRYPTO_PTR(EvpCipherCtxPtr, EVP_CIPHER_CTX, EVP_CIPHER_CTX_free) DEFINE_OPENSSL_CRYPTO_PTR(EvpDigestCtxPtr, EVP_MD_CTX, EVP_MD_CTX_free) DEFINE_OPENSSL_CRYPTO_PTR(EvpPKeyPtr, EVP_PKEY, EVP_PKEY_free) diff --git a/src/bun.js/bindings/webcrypto/OpenSSLUtilities.cpp b/src/bun.js/bindings/webcrypto/OpenSSLUtilities.cpp index 2996cae2ab..f37b50334e 100644 --- a/src/bun.js/bindings/webcrypto/OpenSSLUtilities.cpp +++ b/src/bun.js/bindings/webcrypto/OpenSSLUtilities.cpp @@ -84,7 +84,7 @@ Vector convertToBytesExpand(const BIGNUM* bignum, size_t minimumBufferS { int length = BN_num_bytes(bignum); if (length < 0) - return { }; + return {}; size_t bufferSize = std::max(length, minimumBufferSize); @@ -134,5 +134,4 @@ AESKey::~AESKey() } // namespace WebCore - #endif // ENABLE(WEB_CRYPTO) diff --git a/src/bun.js/bindings/webcrypto/OpenSSLUtilities.h b/src/bun.js/bindings/webcrypto/OpenSSLUtilities.h index 53d884c582..6adffe4b79 100644 --- a/src/bun.js/bindings/webcrypto/OpenSSLUtilities.h +++ b/src/bun.js/bindings/webcrypto/OpenSSLUtilities.h @@ -49,6 +49,7 @@ BIGNUMPtr convertToBigNumber(const Vector& bytes); class AESKey { WTF_MAKE_NONCOPYABLE(AESKey); + public: AESKey() = default; ~AESKey(); @@ -56,6 +57,7 @@ public: bool setKey(const Vector& key, int enc /* AES_ENCRYPT or AES_DECRYPT */); AES_KEY* key() { return &m_key; } + private: AES_KEY m_key; }; diff --git a/src/bun.js/bindings/windows/musl-memmem.h b/src/bun.js/bindings/windows/musl-memmem.h index c036e9e934..b0d2f38fec 100644 --- a/src/bun.js/bindings/windows/musl-memmem.h +++ b/src/bun.js/bindings/windows/musl-memmem.h @@ -1 +1 @@ -extern "C" void *memmem(const void *h0, size_t k, const void *n0, size_t l); \ No newline at end of file +extern "C" void* memmem(const void* h0, size_t k, const void* n0, size_t l); \ No newline at end of file