Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ClangFormat 18 #57

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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