Skip to content

Commit

Permalink
ci: run clang-format on .h files too (#14597)
Browse files Browse the repository at this point in the history
Co-authored-by: nektro <nektro@users.noreply.github.com>
  • Loading branch information
nektro and nektro authored Oct 15, 2024
1 parent 409e674 commit 06e733c
Show file tree
Hide file tree
Showing 50 changed files with 1,823 additions and 1,775 deletions.
7 changes: 6 additions & 1 deletion cmake/analysis/RunClangFormat.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/bindings/BufferEncodingType.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ enum class BufferEncodingType {

};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/BunClientData.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ namespace WebCore {
using JSVMClientData = WebCore::JSVMClientData;
using JSHeapData = WebCore::JSHeapData;

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/BunInjectedScriptHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class BunInjectedScriptHost final : public Inspector::InjectedScriptHost {
bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) override { return false; }
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/BunPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/BunWorkerGlobalScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public EventTarg
private:
MessagePortChannelProviderImpl* m_messagePortChannelProvider;
};
}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/CachedScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace WebCore {

class CachedScript {
};
}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/CallSitePrototype.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ class CallSitePrototype final : public JSC::JSNonFinalObject {
void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/DeleteCallbackDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class DeleteCallbackDataTask : public EventLoopTask {
}
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/EventLoopTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class EventLoopTask {
bool m_isCleanupTask;
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/GCDefferalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ ALWAYS_INLINE GCDeferralContext::~GCDeferralContext()
m_vm.heap.collectIfNecessaryOrDefer();
}

} // namespace JSC
} // namespace JSC
2 changes: 1 addition & 1 deletion src/bun.js/bindings/IDLTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,4 @@ template<typename T>
struct IsIDLArrayBufferViewAllowShared : public std::integral_constant<bool, std::is_base_of<IDLAllowSharedAdaptor<IDLArrayBufferView>, T>::value> {
};

} // namespace WebCore
} // namespace WebCore
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JS2Native.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsDollarCpp);
JSC_DECLARE_HOST_FUNCTION(jsDollarZig);

} // namespace JS2Native
} // namespace Bun
} // namespace Bun
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSBundlerPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ class BundlerPlugin final {
bool tombstoned { false };
};

} // namespace Zig
} // namespace Zig
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSCTaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class JSCTaskScheduler {
HashSet<Ref<JSC::DeferredWorkTimer::TicketData>> m_pendingTicketsOther;
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSCTestingHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ namespace Bun {

JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* global);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSDOMConvertBufferSource+JSBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

namespace WebCore {

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSDOMGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ JSClass* toJSDOMGlobalObject(JSC::VM& vm, JSC::JSValue value)
return nullptr;
}

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSEnvironmentVariableMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ namespace Bun {

JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSNextTickQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class JSNextTickQueue : public JSC::JSInternalFieldObjectImpl<3> {
bool isEmpty();
void drain(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
};
}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSWrappingFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ class JSWrappingFunction final : public JSC::JSFunction {
JSC::WriteBarrier<JSC::JSFunction> m_wrappedFn;
};

}
}
4 changes: 2 additions & 2 deletions src/bun.js/bindings/NodeAsyncHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"

namespace Bun {

JSC::JSValue createAsyncHooksBinding(Zig::GlobalObject*);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/NodeFetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace Bun {

JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject*);

}
}
4 changes: 2 additions & 2 deletions src/bun.js/bindings/NodeHTTP.h
Original file line number Diff line number Diff line change
@@ -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*);

}
}
4 changes: 2 additions & 2 deletions src/bun.js/bindings/NodeTLS.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"

namespace Bun {

JSC::JSValue createNodeTLSBinding(Zig::GlobalObject*);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/NodeURL.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace Bun {

JSC::JSValue createNodeURLBinding(Zig::GlobalObject*);

} // namespace Bun
} // namespace Bun
2 changes: 1 addition & 1 deletion src/bun.js/bindings/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"

namespace Bun {

JSC::JSValue createNodePathBinding(Zig::GlobalObject* globalObject);

} // namespace Bun
2 changes: 1 addition & 1 deletion src/bun.js/bindings/ProcessBindingTTYWrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ JSC::JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject);

JSC_DECLARE_HOST_FUNCTION(Process_functionInternalGetWindowSize);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/ProcessBindingUV.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsGetErrorMap);
JSC::JSObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject);

} // namespace ProcessBindingUV
} // namespace Bun
} // namespace Bun
2 changes: 1 addition & 1 deletion src/bun.js/bindings/ScriptExecutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ class ScriptExecutionContext : public CanMakeWeakPtr<ScriptExecutionContext> {

ScriptExecutionContext* executionContext(JSC::JSGlobalObject*);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/Sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ enum SinkID : uint8_t {
static constexpr unsigned numberOfSinkIDs
= 7;

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/Strong.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class StrongRef {
JSC::Strong<JSC::Unknown> m_cell;
};

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/Undici.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ namespace Bun {

JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/UtilInspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace Bun {

JSC::Structure* createUtilInspectOptionsStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject);

}
}
2 changes: 1 addition & 1 deletion src/bun.js/bindings/debug-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Inspector::InspectorDebuggerAgent* debuggerAgent(JSC::JSGlobalObject* globalObje

return nullptr;
}
}
}
4 changes: 2 additions & 2 deletions src/bun.js/bindings/isBuiltinModule.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

namespace Bun {
bool isBuiltinModule(const String &namePossiblyWithNodePrefix);
} // namespace Bun
bool isBuiltinModule(const String& namePossiblyWithNodePrefix);
} // namespace Bun
2 changes: 1 addition & 1 deletion src/bun.js/bindings/napi_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ class NapiExternal : public JSC::JSDestructibleObject {
#endif
};

} // namespace Zig
} // namespace Zig
2 changes: 1 addition & 1 deletion src/bun.js/bindings/wtf-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class VM;
namespace Bun {
String base64URLEncodeToString(Vector<uint8_t> data);
size_t toISOString(JSC::VM& vm, double date, char buffer[64]);
}
}
60 changes: 29 additions & 31 deletions src/bun.js/modules/AbortControllerModuleModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,44 @@ using namespace WebCore;
namespace Zig {

inline void generateNativeModule_AbortControllerModule(
JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4>& exportNames,
JSC::MarkedArgumentBuffer& exportValues)
{

Zig::GlobalObject *globalObject =
reinterpret_cast<Zig::GlobalObject *>(lexicalGlobalObject);
JSC::VM &vm = globalObject->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(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<unsigned>(PropertyAttribute::DontDelete));
// https://github.com/mysticatea/abort-controller/blob/a935d38e09eb95d6b633a8c42fcceec9969e7b05/dist/abort-controller.js#L125
abortController->putDirect(
vm, signalIdent, abortSignal,
static_cast<unsigned>(PropertyAttribute::DontDelete));

abortController->putDirect(
vm, controllerIdent, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, controllerIdent, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));

abortController->putDirect(
vm, vm.propertyNames->defaultKeyword, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, vm.propertyNames->defaultKeyword, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
}
} // namespace Zig
Loading

0 comments on commit 06e733c

Please sign in to comment.