Skip to content

Commit aa25c5a

Browse files
committed
run clang-format
1 parent 0c452b1 commit aa25c5a

28 files changed

+143
-159
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (RIFT_INCLUDE_MATJSON)
1717
CPMAddPackage("gh:geode-sdk/json#0ea6009")
1818
target_compile_definitions(rift PUBLIC RIFT_INCLUDE_MATJSON)
1919
target_link_libraries(rift mat-json)
20-
endif()
20+
endif ()
2121

2222
# Tests
2323
option(RIFT_BUILD_TESTS "Build tests" OFF)
@@ -27,4 +27,4 @@ option(RIFT_BUILD_FUZZERS "Build fuzzers" OFF)
2727
if (RIFT_BUILD_TESTS)
2828
add_executable(rift_test test/main.cpp)
2929
target_link_libraries(rift_test rift)
30-
endif()
30+
endif ()

include/rift.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
#ifndef RIFT_HPP
33
#define RIFT_HPP
44

5+
#include "rift/config.hpp"
56
#include "rift/script.hpp"
67
#include "rift/value.hpp"
7-
#include "rift/config.hpp"
88
#include "rift/errors/compile.hpp"
99

1010
#include <Geode/Result.hpp>
1111

1212
namespace rift {
13-
1413
using CompileResult = geode::Result<std::unique_ptr<Script>, CompileError>;
1514
using FormatResult = geode::Result<std::string, CompileError>;
1615
using EvaluateResult = geode::Result<Value, CompileError>;
@@ -32,7 +31,6 @@ namespace rift {
3231
/// @param variables the variables to use in the script
3332
/// @return a Result containing the evaluated value if successful, otherwise a CompileError
3433
EvaluateResult evaluate(std::string_view source, Object const& variables = {}) noexcept;
35-
3634
}
3735

38-
#endif // RIFT_HPP
36+
#endif // RIFT_HPP

include/rift/config.hpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
#ifndef RIFT_CONFIG_HPP
33
#define RIFT_CONFIG_HPP
44

5-
#include "value.hpp"
65
#include "util.hpp"
6+
#include "value.hpp"
77

8+
#include <functional>
89
#include <span>
910
#include <string>
10-
#include <functional>
11-
#include <unordered_map>
1211
#include <tuple>
12+
#include <unordered_map>
1313

1414
#include <fmt/format.h>
1515

1616
namespace rift {
17-
1817
/// @brief Can be int64_t, double, bool, std::string, Array, or Object.
19-
template<typename T>
18+
template <typename T>
2019
concept ValueConvertible = std::same_as<T, int64_t>
21-
|| std::same_as<T, double>
22-
|| std::same_as<T, bool>
23-
|| std::same_as<T, std::string>
24-
|| std::same_as<T, Array>
25-
|| std::same_as<T, Object>;
20+
|| std::same_as<T, double>
21+
|| std::same_as<T, bool>
22+
|| std::same_as<T, std::string>
23+
|| std::same_as<T, Array>
24+
|| std::same_as<T, Object>;
2625

2726
using RuntimeFuncResult = geode::Result<Value>;
2827
using RuntimeFunction = std::function<RuntimeFuncResult(std::span<Value>)>;
@@ -31,6 +30,7 @@ namespace rift {
3130
/// @brief Global configuration for the Rift library.
3231
class Config {
3332
Config();
33+
3434
public:
3535
Config(Config const&) = delete;
3636
Config(Config&&) = delete;
@@ -92,8 +92,8 @@ namespace rift {
9292
std::tuple<std::remove_cvref_t<Args>...> argsTuple;
9393
bool success = true;
9494
((success && args[I].template is<std::remove_cvref_t<Args>>()
95-
? void(std::get<I>(argsTuple) = args[I].template to<std::remove_cvref_t<Args>>())
96-
: void(success = false)), ...);
95+
? void(std::get<I>(argsTuple) = args[I].template to<std::remove_cvref_t<Args>>())
96+
: void(success = false)), ...);
9797

9898
if (!success) {
9999
return geode::Err("Argument type mismatch");
@@ -144,7 +144,6 @@ namespace rift {
144144
RuntimeFunctions m_functions;
145145
size_t m_maxLoopIterations = 10000;
146146
};
147-
148147
}
149148

150-
#endif // RIFT_CONFIG_HPP
149+
#endif // RIFT_CONFIG_HPP

include/rift/errors/compile.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#include <fmt/format.h>
66

77
namespace rift {
8-
98
/// @brief Represents an error that occurred during compilation (lexing/parsing).
109
class [[nodiscard]] CompileError {
1110
public:
12-
CompileError(std::string&& source, std::string&& message, size_t index, size_t endIndex) noexcept :
13-
m_source(std::move(source)), m_message(std::move(message)), m_index(index), m_endIndex(endIndex) {
11+
CompileError(
12+
std::string&& source, std::string&& message, size_t index, size_t endIndex
13+
) noexcept : m_source(std::move(source)), m_message(std::move(message)), m_index(index), m_endIndex(endIndex) {
1414
if (m_index + 1 == m_endIndex) {
1515
m_index++;
1616
}
@@ -61,7 +61,6 @@ namespace rift {
6161
std::string m_message;
6262
size_t m_index, m_endIndex;
6363
};
64-
6564
}
6665

67-
#endif // RIFT_COMPILE_ERROR_HPP
66+
#endif // RIFT_COMPILE_ERROR_HPP

include/rift/errors/runtime.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
#include <fmt/format.h>
66

77
namespace rift {
8-
98
/// @brief Represents an error that occurred during compilation (lexing/parsing).
109
class [[nodiscard]] RuntimeError {
1110
public:
12-
RuntimeError(std::string&& message, size_t index, size_t endIndex) noexcept :
13-
m_message(std::move(message)), m_index(index), m_endIndex(endIndex) {
11+
RuntimeError(std::string&& message, size_t index, size_t endIndex) noexcept : m_message(std::move(message)),
12+
m_index(index), m_endIndex(endIndex) {
1413
if (m_index + 1 == m_endIndex) {
1514
m_index++;
1615
}
@@ -60,7 +59,6 @@ namespace rift {
6059
std::string m_message;
6160
size_t m_index, m_endIndex;
6261
};
63-
6462
}
6563

66-
#endif // RIFT_RUNTIME_ERROR_HPP
64+
#endif // RIFT_RUNTIME_ERROR_HPP

include/rift/lexer.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include <string>
66

77
#include "token.hpp"
8-
#include "util.hpp"
98
#include "errors/compile.hpp"
109

11-
namespace rift {
10+
#include <Geode/Result.hpp>
1211

12+
namespace rift {
1313
using LexerResult = geode::Result<Token, CompileError>;
1414

1515
class Lexer {
@@ -99,7 +99,6 @@ namespace rift {
9999

100100
friend class Parser; // Parser needs access to m_index for error reporting
101101
};
102-
103102
}
104103

105-
#endif // RIFT_LEXER_HPP
104+
#endif // RIFT_LEXER_HPP

include/rift/nodes/accessor.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
#include <string>
99

1010
namespace rift {
11-
1211
class AccessorNode final : public Node {
1312
public:
14-
explicit AccessorNode(std::unique_ptr<Node>&& node, std::string&& name, size_t fromIndex, size_t toIndex) noexcept
15-
: Node(fromIndex, toIndex), m_node(std::move(node)), m_name(std::move(name)) { m_type = Type::Accessor; }
13+
explicit AccessorNode(
14+
std::unique_ptr<Node>&& node, std::string&& name, size_t fromIndex, size_t toIndex
15+
) noexcept : Node(fromIndex, toIndex), m_node(std::move(node)), m_name(std::move(name)) {
16+
m_type = Type::Accessor;
17+
}
1618

1719
[[nodiscard]] std::string toDebugString() const noexcept override {
1820
return fmt::format("AccessorNode({}, {})", m_node->toDebugString(), m_name);
@@ -30,7 +32,6 @@ namespace rift {
3032
std::unique_ptr<Node> m_node;
3133
std::string m_name;
3234
};
33-
3435
}
3536

36-
#endif // RIFT_ACCESSOR_NODE_HPP
37+
#endif // RIFT_ACCESSOR_NODE_HPP

include/rift/nodes/assign.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
#include "node.hpp"
66

77
namespace rift {
8-
98
class AssignNode final : public Node {
109
public:
11-
explicit AssignNode(std::string&& name, std::unique_ptr<Node>&& value, size_t fromIndex, size_t toIndex) noexcept
12-
: Node(fromIndex, toIndex), m_name(std::move(name)), m_value(std::move(value)) { m_type = Type::Assign; }
10+
explicit AssignNode(
11+
std::string&& name, std::unique_ptr<Node>&& value, size_t fromIndex, size_t toIndex
12+
) noexcept : Node(fromIndex, toIndex), m_name(std::move(name)), m_value(std::move(value)) {
13+
m_type = Type::Assign;
14+
}
1315

1416
[[nodiscard]] std::string toDebugString() const noexcept override {
1517
return fmt::format("AssignNode({}, {})", m_name, m_value->toDebugString());
@@ -27,7 +29,6 @@ namespace rift {
2729
std::string m_name;
2830
std::unique_ptr<Node> m_value;
2931
};
30-
3132
}
3233

33-
#endif // RIFT_ASSIGN_NODE_HPP
34+
#endif // RIFT_ASSIGN_NODE_HPP

include/rift/nodes/binary.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88
#include <memory>
99

1010
namespace rift {
11-
1211
class BinaryNode final : public Node {
1312
public:
14-
explicit BinaryNode(std::unique_ptr<Node>&& lhs, TokenType op, std::unique_ptr<Node>&& rhs, size_t fromIndex, size_t toIndex) noexcept
15-
: Node(fromIndex, toIndex), m_lhs(std::move(lhs)), m_rhs(std::move(rhs)), m_op(op) { m_type = Type::Binary; }
13+
explicit BinaryNode(
14+
std::unique_ptr<Node>&& lhs, TokenType op, std::unique_ptr<Node>&& rhs, size_t fromIndex, size_t toIndex
15+
) noexcept : Node(fromIndex, toIndex), m_lhs(std::move(lhs)), m_rhs(std::move(rhs)), m_op(op) {
16+
m_type = Type::Binary;
17+
}
1618

1719
[[nodiscard]] std::string toDebugString() const noexcept override {
18-
return fmt::format("BinaryNode({}, {}, {})", m_lhs->toDebugString(), TOKEN_TYPE_NAMES[static_cast<size_t>(m_op)], m_rhs->toDebugString());
20+
return fmt::format(
21+
"BinaryNode({}, {}, {})", m_lhs->toDebugString(), TOKEN_TYPE_NAMES[static_cast<size_t>(m_op)],
22+
m_rhs->toDebugString()
23+
);
1924
}
2025

2126
[[nodiscard]] std::unique_ptr<Node> const& lhs() const noexcept { return m_lhs; }
@@ -30,7 +35,6 @@ namespace rift {
3035
std::unique_ptr<Node> m_lhs, m_rhs;
3136
TokenType m_op;
3237
};
33-
3438
}
3539

36-
#endif // RIFT_BINARY_NODE_HPP
40+
#endif // RIFT_BINARY_NODE_HPP

include/rift/nodes/call.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
#include "node.hpp"
66

77
namespace rift {
8-
98
class CallNode final : public Node {
109
public:
11-
explicit CallNode(std::unique_ptr<Node>&& node, std::vector<std::unique_ptr<Node>>&& args, size_t fromIndex, size_t toIndex) noexcept
12-
: Node(fromIndex, toIndex), m_node(std::move(node)), m_args(std::move(args)) { m_type = Type::Call; }
10+
explicit CallNode(
11+
std::unique_ptr<Node>&& node, std::vector<std::unique_ptr<Node>>&& args, size_t fromIndex, size_t toIndex
12+
) noexcept : Node(fromIndex, toIndex), m_node(std::move(node)), m_args(std::move(args)) {
13+
m_type = Type::Call;
14+
}
1315

1416
[[nodiscard]] std::string toDebugString() const noexcept override {
1517
std::string result = fmt::format("CallNode({}", m_node->toDebugString());
16-
for (const auto & m_arg : m_args) {
18+
for (const auto& m_arg : m_args) {
1719
result += ", ";
1820
result += m_arg->toDebugString();
1921
}
@@ -36,7 +38,6 @@ namespace rift {
3638
std::unique_ptr<Node> m_node;
3739
std::vector<std::unique_ptr<Node>> m_args;
3840
};
39-
4041
}
4142

42-
#endif // RIFT_CALL_NODE_HPP
43+
#endif // RIFT_CALL_NODE_HPP

0 commit comments

Comments
 (0)