Skip to content

Commit

Permalink
Use ClangFormat 18
Browse files Browse the repository at this point in the history
Fixes the formatting errors on macOS CI:
https://github.com/crossnx/includejs/actions/runs/8596937858/job/23554537781?pr=56#step:9:10
by using the same latest ClangFormat version on all platforms.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Apr 8, 2024
1 parent 7c20cc4 commit c6cac08
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
if: runner.os == 'linux'
run: |
sudo apt-get update --yes
sudo apt-get install --yes clang-format libjavascriptcoregtk-4.0-dev
sudo apt-get install --yes libjavascriptcoregtk-4.0-dev
# See https://github.com/actions/runner-images/issues/8659
- name: Workaround Clang issue (GNU/Linux)
Expand All @@ -98,6 +98,8 @@ jobs:
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Install ClangFormat
run: pip install clang-format==18.1.0
- run: cmake --version
- name: Configure IncludeJS (static)
if: matrix.platform.type == 'static'
Expand Down
1 change: 0 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
brew "cmake"
brew "clang-format"
brew "doxygen"
brew "v8"
4 changes: 2 additions & 2 deletions src/engine/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
namespace includejs {

// For convenience
auto Engine::evaluate(std::ifstream &stream, const std::filesystem::path &path)
-> Value {
auto Engine::evaluate(std::ifstream &stream,
const std::filesystem::path &path) -> Value {
stream.exceptions(std::ios_base::badbit);
std::string line;
std::ostringstream result;
Expand Down
20 changes: 10 additions & 10 deletions src/engine/include/includejs/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ class INCLUDEJS_ENGINE_EXPORT Engine {
~Engine();

auto evaluate(const std::filesystem::path &path) -> Value;
auto evaluate(const std::string &code, const std::filesystem::path &path)
-> Value;
auto evaluate(std::ifstream &stream, const std::filesystem::path &path)
-> Value;
auto evaluate(const std::string &code,
const std::filesystem::path &path) -> Value;
auto evaluate(std::ifstream &stream,
const std::filesystem::path &path) -> Value;

// TODO(RaisinTen): Add support for bind_function() to the V8 backend.
#if !defined(INCLUDEJS_ENGINE_V8)
auto bind_function(std::initializer_list<std::string> location,
Function function) -> void;
#endif
auto bind_global(std::initializer_list<std::string> location, Value value)
-> void;
auto bind_global(std::initializer_list<std::string> location, bool value)
-> void;
auto bind_global(std::initializer_list<std::string> location, int value)
-> void;
auto bind_global(std::initializer_list<std::string> location,
Value value) -> void;
auto bind_global(std::initializer_list<std::string> location,
bool value) -> void;
auto bind_global(std::initializer_list<std::string> location,
int value) -> void;
auto bind_global(std::initializer_list<std::string> location,
std::initializer_list<Value> values) -> void;

Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/includejs/engine_private_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ struct INCLUDEJS_ENGINE_EXPORT PrivateObjectData {
~PrivateObjectData();

auto data() -> void *;
auto set_data(void *new_data, std::function<void(void *)> new_deleter)
-> void;
auto set_data(void *new_data,
std::function<void(void *)> new_deleter) -> void;

private:
void *data_ = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/javascript_core/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ auto Engine::bind_global(std::initializer_list<std::string> location,
}
}

auto Engine::bind_global(std::initializer_list<std::string> location, int value)
-> void {
auto Engine::bind_global(std::initializer_list<std::string> location,
int value) -> void {
JSValueRef exception = nullptr;
JSValueRef js_value =
JSValueMakeNumber(this->internal->context, static_cast<double>(value));
Expand Down
5 changes: 2 additions & 3 deletions src/engine/javascript_core/engine_private_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ PrivateObjectData::~PrivateObjectData() { clear(); }

auto PrivateObjectData::data() -> void * { return data_; }

auto PrivateObjectData::set_data(void *new_data,
std::function<void(void *)> new_deleter)
-> void {
auto PrivateObjectData::set_data(
void *new_data, std::function<void(void *)> new_deleter) -> void {
clear();
data_ = new_data;
deleter_ = new_deleter;
Expand Down
16 changes: 8 additions & 8 deletions src/engine/javascript_core/engine_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static auto js_string_to_std_string(JSStringRef value) -> std::string {

// Converting a value into a string first requires copying
// the value reference into a string reference.
static auto js_value_to_std_string(JSContextRef context, JSValueRef value)
-> std::string {
static auto js_value_to_std_string(JSContextRef context,
JSValueRef value) -> std::string {
JSValueRef exception = nullptr;
JSStringRef copy = JSValueToStringCopy(context, value, &exception);
assert(!exception);
Expand All @@ -50,17 +50,17 @@ static auto js_value_to_std_string(JSContextRef context, JSValueRef value)
}
}

static auto get_current_object(JSContextRef context, JSValueRef value)
-> JSObjectRef {
static auto get_current_object(JSContextRef context,
JSValueRef value) -> JSObjectRef {
JSValueRef exception = nullptr;
JSObjectRef object = JSValueToObject(context, value, &exception);
assert(!exception);
assert(object == value);
return object;
}

static auto get_object_length(JSContextRef context, JSObjectRef object)
-> std::size_t {
static auto get_object_length(JSContextRef context,
JSObjectRef object) -> std::size_t {
JSValueRef exception = nullptr;
JSStringRef length_string = JSStringCreateWithUTF8CString("length");
const double length = JSValueToNumber(
Expand Down Expand Up @@ -321,8 +321,8 @@ auto Value::set(const std::string &name, Function cpp_function) -> void {
JSStringRelease(function_name_ref);
}

auto Value::private_data(void *data, std::function<void(void *)> deleter)
-> void {
auto Value::private_data(void *data,
std::function<void(void *)> deleter) -> void {
assert(is_object());

// Get the parent object
Expand Down
8 changes: 4 additions & 4 deletions test/engine/engine_binding_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ static auto is_string(const includejs::Context &context,
}

// TODO: Add overload that doesn't take arguments
static auto get_details(const includejs::Context &context, INCLUDEJS_ARGS)
-> includejs::Value {
static auto get_details(const includejs::Context &context,
INCLUDEJS_ARGS) -> includejs::Value {
includejs::Value result{context.make_object()};
result.set("version", context.from("1.0.0"));
return result;
}

static auto promise_test(const includejs::Context &context, INCLUDEJS_ARGS)
-> includejs::Value {
static auto promise_test(const includejs::Context &context,
INCLUDEJS_ARGS) -> includejs::Value {
includejs::Promise promise{context.make_promise()};
promise.resolve(context.from(true));
return promise.value();
Expand Down

0 comments on commit c6cac08

Please sign in to comment.