Skip to content
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
16 changes: 13 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# clang-format: 11
# clang-format: 19
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveBitFields: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: WebKit
BinPackArguments: true
Expand All @@ -13,12 +17,14 @@ BreakBeforeBraces: Attach
ColumnLimit: 0
Cpp11BracedListStyle: true
FixNamespaceComments: true
IfMacros: ['SECTION']
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PackConstructorInitializers: CurrentLine
PenaltyBreakBeforeFirstCallParameter: 200
PenaltyBreakComment: 5
PenaltyBreakFirstLessLess: 50
Expand All @@ -27,7 +33,11 @@ PointerAlignment: Right
SortIncludes: true
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterIfMacros: false
SpaceInEmptyBlock: false
Standard: Latest
TabWidth: 2
UseTab: Never
UseTab: Never
27 changes: 27 additions & 0 deletions .github/workflows/auto-clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: auto-clang-format
on:
push:
branches:
- develop
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: DoozyX/clang-format-lint-action@v0.20
with:
source: '.'
exclude: './third_party ./external ./unittests/catch.hpp'
extensions: 'h,cpp,hpp'
clangFormatVersion: 19
inplace: True
- uses: EndBug/add-and-commit@v9
with:
author_name: Clang Robot
author_email: robot@example.com
message: ':art: Committing clang-format changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions emscripten/chaiscript_eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#ifndef CHAISCRIPT_EMSCRIPTEN_EVAL_HPP_
#define CHAISCRIPT_EMSCRIPTEN_EVAL_HPP_

#include <string>
#include <chaiscript/chaiscript.hpp>
#include <string>

namespace detail {
inline chaiscript::ChaiScript &get_chai_instance() {
static chaiscript::ChaiScript chai;
return chai;
}
inline chaiscript::ChaiScript &get_chai_instance() {
static chaiscript::ChaiScript chai;
return chai;
}
} // namespace detail

inline void chaiscript_eval(const std::string &input) {
Expand Down
4 changes: 2 additions & 2 deletions include/chaiscript/chaiscript_stdlib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

#include "dispatchkit/function_call.hpp"

//#include "dispatchkit/dispatchkit.hpp"
// #include "dispatchkit/dispatchkit.hpp"
#include "dispatchkit/bootstrap.hpp"
#include "dispatchkit/bootstrap_stl.hpp"
#include "dispatchkit/operators.hpp"
//#include "dispatchkit/boxed_value.hpp"
// #include "dispatchkit/boxed_value.hpp"
#include "dispatchkit/register_function.hpp"
#include "language/chaiscript_prelude.hpp"
#include "utility/json_wrap.hpp"
Expand Down
1 change: 0 additions & 1 deletion include/chaiscript/dispatchkit/dynamic_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ namespace chaiscript {
return false;
}


bool is_explicit() const noexcept { return m_option_explicit; }

void set_explicit(const bool t_explicit) noexcept { m_option_explicit = t_explicit; }
Expand Down
10 changes: 5 additions & 5 deletions include/chaiscript/dispatchkit/dynamic_object_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ namespace chaiscript {
};

/**
* A Proxy_Function implementation designed for creating a new
* Dynamic_Object
* that is automatically guarded based on the first param based on the
* param's type name
*/
* A Proxy_Function implementation designed for creating a new
* Dynamic_Object
* that is automatically guarded based on the first param based on the
* param's type name
*/
class Dynamic_Object_Constructor final : public Proxy_Function_Base {
public:
Dynamic_Object_Constructor(std::string t_type_name, const Proxy_Function &t_func)
Expand Down
16 changes: 8 additions & 8 deletions include/chaiscript/dispatchkit/function_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,57 @@ namespace chaiscript::dispatch::detail {
Function_Signature(Ret (Class::*f)(Param...) volatile &) -> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile &noexcept)
Function_Signature(Ret (Class::*f)(Param...) volatile & noexcept)
-> Function_Signature<Ret, Function_Params<volatile Class &, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile const &)
-> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile const &noexcept)
Function_Signature(Ret (Class::*f)(Param...) volatile const & noexcept)
-> Function_Signature<Ret, Function_Params<volatile const Class &, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) &) -> Function_Signature<Ret, Function_Params<Class &, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) &noexcept) -> Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>;
Function_Signature(Ret (Class::*f)(Param...) & noexcept) -> Function_Signature<Ret, Function_Params<Class &, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) const &) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) const &noexcept) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>;
Function_Signature(Ret (Class::*f)(Param...) const & noexcept) -> Function_Signature<Ret, Function_Params<const Class &, Param...>, true, true>;

// && reference specifier

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile &&) -> Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile &&noexcept)
Function_Signature(Ret (Class::*f)(Param...) volatile && noexcept)
-> Function_Signature<Ret, Function_Params<volatile Class &&, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile const &&)
-> Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) volatile const &&noexcept)
Function_Signature(Ret (Class::*f)(Param...) volatile const && noexcept)
-> Function_Signature<Ret, Function_Params<volatile const Class &&, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) &&) -> Function_Signature<Ret, Function_Params<Class &&, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) &&noexcept) -> Function_Signature<Ret, Function_Params<Class &&, Param...>, true, true>;
Function_Signature(Ret (Class::*f)(Param...) && noexcept) -> Function_Signature<Ret, Function_Params<Class &&, Param...>, true, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) const &&) -> Function_Signature<Ret, Function_Params<const Class &&, Param...>, false, true>;

template<typename Ret, typename Class, typename... Param>
Function_Signature(Ret (Class::*f)(Param...) const &&noexcept)
Function_Signature(Ret (Class::*f)(Param...) const && noexcept)
-> Function_Signature<Ret, Function_Params<const Class &&, Param...>, true, true>;

template<typename Ret, typename Class>
Expand Down
8 changes: 4 additions & 4 deletions include/chaiscript/dispatchkit/handle_return.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ namespace chaiscript {
};

/**
* Used internally for handling a return value from a Proxy_Function call
*/
* Used internally for handling a return value from a Proxy_Function call
*/
template<>
struct Handle_Return<Boxed_Number> {
static Boxed_Value handle(const Boxed_Number &r) noexcept { return r.bv; }
Expand All @@ -182,8 +182,8 @@ namespace chaiscript {
};

/**
* Used internally for handling a return value from a Proxy_Function call
*/
* Used internally for handling a return value from a Proxy_Function call
*/
template<>
struct Handle_Return<void> {
static Boxed_Value handle() { return void_var(); }
Expand Down
14 changes: 7 additions & 7 deletions include/chaiscript/dispatchkit/proxy_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ namespace chaiscript {
};

/**
* Pure virtual base class for all Proxy_Function implementations
* Proxy_Functions are a type erasure of type safe C++
* function calls. At runtime parameter types are expected to be
* tested against passed in types.
* Dispatch_Engine only knows how to work with Proxy_Function, no other
* function classes.
*/
* Pure virtual base class for all Proxy_Function implementations
* Proxy_Functions are a type erasure of type safe C++
* function calls. At runtime parameter types are expected to be
* tested against passed in types.
* Dispatch_Engine only knows how to work with Proxy_Function, no other
* function classes.
*/
class Proxy_Function_Base {
public:
virtual ~Proxy_Function_Base() = default;
Expand Down
20 changes: 10 additions & 10 deletions include/chaiscript/dispatchkit/proxy_functions_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace chaiscript {
namespace chaiscript {
namespace exception {
/**
* Exception thrown when there is a mismatch in number of
* parameters during Proxy_Function execution
*/
* Exception thrown when there is a mismatch in number of
* parameters during Proxy_Function execution
*/
struct arity_error : std::range_error {
arity_error(int t_got, int t_expected)
: std::range_error("Function dispatch arity mismatch")
Expand All @@ -54,20 +54,20 @@ namespace chaiscript {
namespace dispatch {
namespace detail {
/**
* Used by Proxy_Function_Impl to return a list of all param types
* it contains.
*/
* Used by Proxy_Function_Impl to return a list of all param types
* it contains.
*/
template<typename Ret, typename... Params>
std::vector<Type_Info> build_param_type_list(Ret (*)(Params...)) {
/// \note somehow this is responsible for a large part of the code generation
return {user_type<Ret>(), user_type<Params>()...};
}

/**
* Used by Proxy_Function_Impl to determine if it is equivalent to another
* Proxy_Function_Impl object. This function is primarily used to prevent
* registration of two functions with the exact same signatures
*/
* Used by Proxy_Function_Impl to determine if it is equivalent to another
* Proxy_Function_Impl object. This function is primarily used to prevent
* registration of two functions with the exact same signatures
*/
template<typename Ret, typename... Params>
bool compare_types_cast(Ret (*)(Params...), const chaiscript::Function_Params &params, const Type_Conversions_State &t_conversions) noexcept {
try {
Expand Down
5 changes: 2 additions & 3 deletions include/chaiscript/dispatchkit/type_conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,8 @@ namespace chaiscript {
= detail::Cast_Helper<const std::pair<Boxed_Value, Boxed_Value> &>::cast(t_bv, nullptr);

auto pair = std::make_pair(
detail::Cast_Helper<Left>::cast(from_pair.first, nullptr),
detail::Cast_Helper<Right>::cast(from_pair.second, nullptr)
);
detail::Cast_Helper<Left>::cast(from_pair.first, nullptr),
detail::Cast_Helper<Right>::cast(from_pair.second, nullptr));

return Boxed_Value(std::move(pair));
};
Expand Down
12 changes: 6 additions & 6 deletions include/chaiscript/language/chaiscript_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,13 @@ namespace chaiscript {

} // namespace exception

//static
// static
bool AST_Node::get_bool_condition(const Boxed_Value &t_bv, const chaiscript::detail::Dispatch_State &t_ss) {
try {
return t_ss->boxed_cast<bool>(t_bv);
} catch (const exception::bad_boxed_cast &) {
throw exception::eval_error("Condition not boolean");
}
try {
return t_ss->boxed_cast<bool>(t_bv);
} catch (const exception::bad_boxed_cast &) {
throw exception::eval_error("Condition not boolean");
}
}

namespace parser {
Expand Down
8 changes: 4 additions & 4 deletions include/chaiscript/language/chaiscript_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ namespace chaiscript {
m_engine.add(fun([this](const std::string &s) { m_print_handler(s + "\n"); }), "println_string");

m_engine.add(fun([this](const std::function<void(const std::string &)> &t_handler) {
m_print_handler = t_handler;
}), "set_print_handler");
m_print_handler = t_handler;
}),
"set_print_handler");

m_engine.add(fun([this]() { m_engine.dump_system(); }), "dump_system");
m_engine.add(fun([this](const Boxed_Value &t_bv) { m_engine.dump_object(t_bv); }), "dump_object");
Expand Down Expand Up @@ -278,7 +279,6 @@ namespace chaiscript {
}

public:

/// \brief Set a custom handler for print output, used by both print_string and println_string
/// \param[in] t_handler Function to call with the string to print
void set_print_handler(std::function<void(const std::string &)> t_handler) {
Expand All @@ -287,7 +287,7 @@ namespace chaiscript {

/// \brief Virtual destructor for ChaiScript
virtual ~ChaiScript_Basic() = default;

/// \brief Constructor for ChaiScript
/// \param[in] t_lib Standard library to apply to this ChaiScript instance
/// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module
Expand Down
15 changes: 7 additions & 8 deletions include/chaiscript/language/chaiscript_eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#ifndef CHAISCRIPT_EVAL_HPP_
#define CHAISCRIPT_EVAL_HPP_

#include <algorithm>
#include <exception>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <ostream>
#include <algorithm>
#include <stdexcept>
#include <string>
#include <vector>
Expand Down Expand Up @@ -389,11 +389,11 @@ namespace chaiscript {

// static and public so we can use this to process Switch_AST_Node case equality
static Boxed_Value do_oper(const chaiscript::detail::Dispatch_State &t_ss,
Operators::Opers t_oper,
const std::string &t_oper_string,
const Boxed_Value &t_lhs,
const Boxed_Value &t_rhs,
std::atomic_uint_fast32_t &t_loc) {
Operators::Opers t_oper,
const std::string &t_oper_string,
const Boxed_Value &t_lhs,
const Boxed_Value &t_rhs,
std::atomic_uint_fast32_t &t_loc) {
try {
if (t_oper != Operators::Opers::invalid && t_lhs.get_type_info().is_arithmetic() && t_rhs.get_type_info().is_arithmetic()) {
// If it's an arithmetic operation we want to short circuit dispatch
Expand Down Expand Up @@ -1271,8 +1271,7 @@ namespace chaiscript {
const auto process_statement = [&](const AST_Node_Impl<T> &stmt) {
if (stmt.identifier == AST_Node_Type::Def) {
const auto &def_node = static_cast<const Def_AST_Node<T> &>(stmt);
target_ns[def_node.children[0]->text] =
Boxed_Value(Def_AST_Node<T>::make_proxy_function(def_node, t_ss));
target_ns[def_node.children[0]->text] = Boxed_Value(Def_AST_Node<T>::make_proxy_function(def_node, t_ss));
} else if (stmt.identifier == AST_Node_Type::Assign_Decl
|| stmt.identifier == AST_Node_Type::Const_Assign_Decl) {
const auto &var_name = stmt.children[0]->text;
Expand Down
2 changes: 1 addition & 1 deletion include/chaiscript/utility/json_wrap.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef CHAISCRIPT_SIMPLEJSON_WRAP_HPP
#define CHAISCRIPT_SIMPLEJSON_WRAP_HPP

#include "json.hpp"
#include "../dispatchkit/dynamic_object.hpp"
#include "json.hpp"

namespace chaiscript {
class json_wrap {
Expand Down
Loading
Loading