Drop ifdef'd code for gcc4.6 and msvc12

This commit is contained in:
Jason Turner
2016-03-04 11:15:39 -07:00
parent a0f3eafe30
commit b5b6e5a5a3
20 changed files with 182 additions and 357 deletions

View File

@@ -101,8 +101,8 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt")
set(CPACK_PACKAGE_VERSION_MAJOR 5) set(CPACK_PACKAGE_VERSION_MAJOR 6)
set(CPACK_PACKAGE_VERSION_MINOR 8) set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0) set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_EXECUTABLES "chai;ChaiScript Eval") set(CPACK_PACKAGE_EXECUTABLES "chai;ChaiScript Eval")

View File

@@ -12,17 +12,10 @@
#define CHAISCRIPT_COMPILER_VERSION CHAISCRIPT_STRINGIZE(_MSC_FULL_VER) #define CHAISCRIPT_COMPILER_VERSION CHAISCRIPT_STRINGIZE(_MSC_FULL_VER)
#define CHAISCRIPT_MSVC _MSC_VER #define CHAISCRIPT_MSVC _MSC_VER
#define CHAISCRIPT_HAS_DECLSPEC #define CHAISCRIPT_HAS_DECLSPEC
#if _MSC_VER <= 1800
#define CHAISCRIPT_MSVC_12
#endif
#else #else
#define CHAISCRIPT_COMPILER_VERSION __VERSION__ #define CHAISCRIPT_COMPILER_VERSION __VERSION__
#endif #endif
#ifndef CHAISCRIPT_MSVC_12
#define CHAISCRIPT_HAS_MAGIC_STATICS
#endif
#include <vector> #include <vector>
#if defined( _LIBCPP_VERSION ) #if defined( _LIBCPP_VERSION )
@@ -51,26 +44,15 @@
#endif #endif
#endif #endif
#if (defined(CHAISCRIPT_MSVC) && !defined(CHAISCRIPT_MSVC_12)) || (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined(__llvm__) && !defined(CHAISCRIPT_LIBCPP)) #if defined(CHAISCRIPT_MSVC) || (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined(__llvm__) && !defined(CHAISCRIPT_LIBCPP))
/// Currently only g++>=4.8 supports this natively
/// \todo Make this support other compilers when possible /// \todo Make this support other compilers when possible
#define CHAISCRIPT_HAS_THREAD_LOCAL #define CHAISCRIPT_HAS_THREAD_LOCAL
#endif #endif
#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6)
#define CHAISCRIPT_GCC_4_6
#endif
#if defined(__llvm__) #if defined(__llvm__)
#define CHAISCRIPT_CLANG #define CHAISCRIPT_CLANG
#endif #endif
#if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(CHAISCRIPT_MSVC) || defined(CHAISCRIPT_CLANG)
#define CHAISCRIPT_OVERRIDE override
#else
#define CHAISCRIPT_OVERRIDE
#endif
#ifdef CHAISCRIPT_HAS_DECLSPEC #ifdef CHAISCRIPT_HAS_DECLSPEC
#define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport) #define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport)
@@ -78,14 +60,6 @@
#define CHAISCRIPT_MODULE_EXPORT extern "C" #define CHAISCRIPT_MODULE_EXPORT extern "C"
#endif #endif
#ifdef CHAISCRIPT_MSVC_12
#define CHAISCRIPT_NOEXCEPT throw()
#define CHAISCRIPT_CONSTEXPR
#else
#define CHAISCRIPT_NOEXCEPT noexcept
#define CHAISCRIPT_CONSTEXPR constexpr
#endif
#ifdef _DEBUG #ifdef _DEBUG
#define CHAISCRIPT_DEBUG true #define CHAISCRIPT_DEBUG true
#else #else
@@ -95,8 +69,8 @@
#include <memory> #include <memory>
namespace chaiscript { namespace chaiscript {
static const int version_major = 5; static const int version_major = 6;
static const int version_minor = 8; static const int version_minor = 0;
static const int version_patch = 0; static const int version_patch = 0;
static const char *compiler_version = CHAISCRIPT_COMPILER_VERSION; static const char *compiler_version = CHAISCRIPT_COMPILER_VERSION;

View File

@@ -21,17 +21,17 @@ namespace chaiscript {
class bad_any_cast : public std::bad_cast class bad_any_cast : public std::bad_cast
{ {
public: public:
bad_any_cast() CHAISCRIPT_NOEXCEPT bad_any_cast() noexcept
: m_what("bad any cast") : m_what("bad any cast")
{ {
} }
bad_any_cast(const bad_any_cast &) = default; bad_any_cast(const bad_any_cast &) = default;
virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_any_cast() noexcept {}
/// \brief Description of what error occurred /// \brief Description of what error occurred
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE virtual const char * what() const noexcept override
{ {
return m_what.c_str(); return m_what.c_str();
} }
@@ -76,12 +76,12 @@ namespace chaiscript {
virtual ~Data_Impl() {} virtual ~Data_Impl() {}
virtual void *data() CHAISCRIPT_OVERRIDE virtual void *data() override
{ {
return &m_data; return &m_data;
} }
std::unique_ptr<Data> clone() const CHAISCRIPT_OVERRIDE std::unique_ptr<Data> clone() const override
{ {
return std::unique_ptr<Data>(new Data_Impl<T>(m_data)); return std::unique_ptr<Data>(new Data_Impl<T>(m_data));
} }
@@ -107,10 +107,8 @@ namespace chaiscript {
} }
} }
#if !defined(_MSC_VER) || _MSC_VER != 1800
Any(Any &&) = default; Any(Any &&) = default;
Any &operator=(Any &&t_any) = default; Any &operator=(Any &&t_any) = default;
#endif
template<typename ValueType, template<typename ValueType,
typename = typename std::enable_if<!std::is_same<Any, typename std::decay<ValueType>::type>::value>::type> typename = typename std::enable_if<!std::is_same<Any, typename std::decay<ValueType>::type>::value>::type>

View File

@@ -30,7 +30,7 @@ namespace chaiscript
{ {
public: public:
bad_boxed_cast(Type_Info t_from, const std::type_info &t_to, bad_boxed_cast(Type_Info t_from, const std::type_info &t_to,
std::string t_what) CHAISCRIPT_NOEXCEPT std::string t_what) noexcept
: from(std::move(t_from)), to(&t_to), m_what(std::move(t_what)) : from(std::move(t_from)), to(&t_to), m_what(std::move(t_what))
{ {
} }
@@ -40,16 +40,16 @@ namespace chaiscript
{ {
} }
explicit bad_boxed_cast(std::string t_what) CHAISCRIPT_NOEXCEPT explicit bad_boxed_cast(std::string t_what) noexcept
: to(nullptr), m_what(std::move(t_what)) : to(nullptr), m_what(std::move(t_what))
{ {
} }
bad_boxed_cast(const bad_boxed_cast &) = default; bad_boxed_cast(const bad_boxed_cast &) = default;
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_boxed_cast() noexcept {}
/// \brief Description of what error occurred /// \brief Description of what error occurred
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE virtual const char * what() const noexcept override
{ {
return m_what.c_str(); return m_what.c_str();
} }

View File

@@ -30,7 +30,7 @@ namespace chaiscript
{ {
arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {} arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {}
arithmetic_error(const arithmetic_error &) = default; arithmetic_error(const arithmetic_error &) = default;
virtual ~arithmetic_error() CHAISCRIPT_NOEXCEPT {} virtual ~arithmetic_error() noexcept {}
}; };
} }
} }
@@ -90,7 +90,7 @@ namespace chaiscript
{ {
} }
static CHAISCRIPT_CONSTEXPR Common_Types get_common_type(size_t t_size, bool t_signed) static constexpr Common_Types get_common_type(size_t t_size, bool t_signed)
{ {
return (t_size == 1 && t_signed)?(Common_Types::t_int8) return (t_size == 1 && t_signed)?(Common_Types::t_int8)
:(t_size == 1)?(Common_Types::t_uint8) :(t_size == 1)?(Common_Types::t_uint8)
@@ -508,11 +508,8 @@ namespace chaiscript
} }
Boxed_Number(const Boxed_Number &) = default; Boxed_Number(const Boxed_Number &) = default;
#if !defined(_MSC_VER) || _MSC_VER != 1800
Boxed_Number(Boxed_Number &&) = default; Boxed_Number(Boxed_Number &&) = default;
Boxed_Number& operator=(Boxed_Number &&) = default; Boxed_Number& operator=(Boxed_Number &&) = default;
#endif
template<typename T> explicit Boxed_Number(T t) template<typename T> explicit Boxed_Number(T t)
: bv(Boxed_Value(t)) : bv(Boxed_Value(t))

View File

@@ -62,10 +62,8 @@ namespace chaiscript
Data(const Data &) = delete; Data(const Data &) = delete;
#if !defined(__APPLE__) && (!defined(_MSC_VER) || _MSC_VER != 1800)
Data(Data &&) = default; Data(Data &&) = default;
Data &operator=(Data &&rhs) = default; Data &operator=(Data &&rhs) = default;
#endif
Type_Info m_type_info; Type_Info m_type_info;
@@ -189,11 +187,8 @@ namespace chaiscript
{ {
} }
#if !defined(_MSC_VER) || _MSC_VER != 1800
Boxed_Value(Boxed_Value&&) = default; Boxed_Value(Boxed_Value&&) = default;
Boxed_Value& operator=(Boxed_Value&&) = default; Boxed_Value& operator=(Boxed_Value&&) = default;
#endif
Boxed_Value(const Boxed_Value&) = default; Boxed_Value(const Boxed_Value&) = default;
Boxed_Value& operator=(const Boxed_Value&) = default; Boxed_Value& operator=(const Boxed_Value&) = default;
@@ -210,63 +205,63 @@ namespace chaiscript
return *this; return *this;
} }
const Type_Info &get_type_info() const CHAISCRIPT_NOEXCEPT const Type_Info &get_type_info() const noexcept
{ {
return m_data->m_type_info; return m_data->m_type_info;
} }
/// return true if the object is uninitialized /// return true if the object is uninitialized
bool is_undef() const CHAISCRIPT_NOEXCEPT bool is_undef() const noexcept
{ {
return m_data->m_type_info.is_undef(); return m_data->m_type_info.is_undef();
} }
bool is_const() const CHAISCRIPT_NOEXCEPT bool is_const() const noexcept
{ {
return m_data->m_type_info.is_const(); return m_data->m_type_info.is_const();
} }
bool is_type(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT bool is_type(const Type_Info &ti) const noexcept
{ {
return m_data->m_type_info.bare_equal(ti); return m_data->m_type_info.bare_equal(ti);
} }
bool is_null() const CHAISCRIPT_NOEXCEPT bool is_null() const noexcept
{ {
return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr); return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr);
} }
const chaiscript::detail::Any & get() const CHAISCRIPT_NOEXCEPT const chaiscript::detail::Any & get() const noexcept
{ {
return m_data->m_obj; return m_data->m_obj;
} }
bool is_ref() const CHAISCRIPT_NOEXCEPT bool is_ref() const noexcept
{ {
return m_data->m_is_ref; return m_data->m_is_ref;
} }
bool is_return_value() const CHAISCRIPT_NOEXCEPT bool is_return_value() const noexcept
{ {
return m_data->m_return_value; return m_data->m_return_value;
} }
void reset_return_value() const CHAISCRIPT_NOEXCEPT void reset_return_value() const noexcept
{ {
m_data->m_return_value = false; m_data->m_return_value = false;
} }
bool is_pointer() const CHAISCRIPT_NOEXCEPT bool is_pointer() const noexcept
{ {
return !is_ref(); return !is_ref();
} }
void *get_ptr() const CHAISCRIPT_NOEXCEPT void *get_ptr() const noexcept
{ {
return m_data->m_data_ptr; return m_data->m_data_ptr;
} }
const void *get_const_ptr() const CHAISCRIPT_NOEXCEPT const void *get_const_ptr() const noexcept
{ {
return m_data->m_const_data_ptr; return m_data->m_const_data_ptr;
} }
@@ -306,7 +301,7 @@ namespace chaiscript
/// \returns true if the two Boxed_Values share the same internal type /// \returns true if the two Boxed_Values share the same internal type
static bool type_match(const Boxed_Value &l, const Boxed_Value &r) CHAISCRIPT_NOEXCEPT static bool type_match(const Boxed_Value &l, const Boxed_Value &r) noexcept
{ {
return l.get_type_info() == r.get_type_info(); return l.get_type_info() == r.get_type_info();
} }
@@ -416,10 +411,9 @@ namespace chaiscript
return detail::const_var_impl(t); return detail::const_var_impl(t);
} }
#ifdef CHAISCRIPT_HAS_MAGIC_STATICS
inline Boxed_Value const_var(bool b) { inline Boxed_Value const_var(bool b) {
static auto t = detail::const_var_impl(true); static const auto t = detail::const_var_impl(true);
static auto f = detail::const_var_impl(false); static const auto f = detail::const_var_impl(false);
if (b) { if (b) {
return t; return t;
@@ -427,7 +421,6 @@ namespace chaiscript
return f; return f;
} }
} }
#endif
} }

View File

@@ -56,14 +56,14 @@ namespace chaiscript
class reserved_word_error : public std::runtime_error class reserved_word_error : public std::runtime_error
{ {
public: public:
reserved_word_error(const std::string &t_word) CHAISCRIPT_NOEXCEPT reserved_word_error(const std::string &t_word) noexcept
: std::runtime_error("Reserved word not allowed in object name: " + t_word), m_word(t_word) : std::runtime_error("Reserved word not allowed in object name: " + t_word), m_word(t_word)
{ {
} }
reserved_word_error(const reserved_word_error &) = default; reserved_word_error(const reserved_word_error &) = default;
virtual ~reserved_word_error() CHAISCRIPT_NOEXCEPT {} virtual ~reserved_word_error() noexcept {}
std::string word() const std::string word() const
{ {
@@ -78,14 +78,14 @@ namespace chaiscript
class illegal_name_error : public std::runtime_error class illegal_name_error : public std::runtime_error
{ {
public: public:
illegal_name_error(const std::string &t_name) CHAISCRIPT_NOEXCEPT illegal_name_error(const std::string &t_name) noexcept
: std::runtime_error("Reserved name not allowed in object name: " + t_name), m_name(t_name) : std::runtime_error("Reserved name not allowed in object name: " + t_name), m_name(t_name)
{ {
} }
illegal_name_error(const illegal_name_error &) = default; illegal_name_error(const illegal_name_error &) = default;
virtual ~illegal_name_error() CHAISCRIPT_NOEXCEPT {} virtual ~illegal_name_error() noexcept {}
std::string name() const std::string name() const
{ {
@@ -101,14 +101,14 @@ namespace chaiscript
class name_conflict_error : public std::runtime_error class name_conflict_error : public std::runtime_error
{ {
public: public:
name_conflict_error(const std::string &t_name) CHAISCRIPT_NOEXCEPT name_conflict_error(const std::string &t_name) noexcept
: std::runtime_error("Name already exists in current context " + t_name), m_name(t_name) : std::runtime_error("Name already exists in current context " + t_name), m_name(t_name)
{ {
} }
name_conflict_error(const name_conflict_error &) = default; name_conflict_error(const name_conflict_error &) = default;
virtual ~name_conflict_error() CHAISCRIPT_NOEXCEPT {} virtual ~name_conflict_error() noexcept {}
std::string name() const std::string name() const
{ {
@@ -125,13 +125,13 @@ namespace chaiscript
class global_non_const : public std::runtime_error class global_non_const : public std::runtime_error
{ {
public: public:
global_non_const() CHAISCRIPT_NOEXCEPT global_non_const() noexcept
: std::runtime_error("a global object must be const") : std::runtime_error("a global object must be const")
{ {
} }
global_non_const(const global_non_const &) = default; global_non_const(const global_non_const &) = default;
virtual ~global_non_const() CHAISCRIPT_NOEXCEPT {} virtual ~global_non_const() noexcept {}
}; };
} }
@@ -276,7 +276,7 @@ namespace chaiscript
{ {
} }
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const override
{ {
try { try {
const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs); const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs);
@@ -288,7 +288,7 @@ namespace chaiscript
virtual ~Dispatch_Function() {} virtual ~Dispatch_Function() {}
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
{ {
return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end()); return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end());
} }
@@ -314,19 +314,19 @@ namespace chaiscript
return arity; return arity;
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return std::any_of(m_funcs.cbegin(), m_funcs.cend(), return std::any_of(m_funcs.cbegin(), m_funcs.cend(),
[&vals, &t_conversions](const Proxy_Function &f){ return f->call_match(vals, t_conversions); }); [&vals, &t_conversions](const Proxy_Function &f){ return f->call_match(vals, t_conversions); });
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return "Multiple method dispatch function wrapper."; return "Multiple method dispatch function wrapper.";
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
return dispatch::dispatch(m_funcs, params, t_conversions); return dispatch::dispatch(m_funcs, params, t_conversions);
} }
@@ -1332,13 +1332,8 @@ namespace chaiscript
const auto lhssize = lhsparamtypes.size(); const auto lhssize = lhsparamtypes.size();
const auto rhssize = rhsparamtypes.size(); const auto rhssize = rhsparamtypes.size();
#ifdef CHAISCRIPT_HAS_MAGIC_STATICS static const auto boxed_type = user_type<Boxed_Value>();
static auto boxed_type = user_type<Boxed_Value>(); static const auto boxed_pod_type = user_type<Boxed_Number>();
static auto boxed_pod_type = user_type<Boxed_Number>();
#else
auto boxed_type = user_type<Boxed_Value>();
auto boxed_pod_type = user_type<Boxed_Number>();
#endif
for (size_t i = 1; i < lhssize && i < rhssize; ++i) for (size_t i = 1; i < lhssize && i < rhssize; ++i)
{ {

View File

@@ -33,7 +33,7 @@ namespace chaiscript
option_explicit_set(const option_explicit_set &) = default; option_explicit_set(const option_explicit_set &) = default;
virtual ~option_explicit_set() CHAISCRIPT_NOEXCEPT {} virtual ~option_explicit_set() noexcept {}
}; };
class Dynamic_Object class Dynamic_Object

View File

@@ -72,7 +72,7 @@ namespace chaiscript
Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete; Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
Dynamic_Object_Function(Dynamic_Object_Function &) = delete; Dynamic_Object_Function(Dynamic_Object_Function &) = delete;
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &f) const override
{ {
if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f)) if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f))
{ {
@@ -82,9 +82,9 @@ namespace chaiscript
} }
} }
virtual bool is_attribute_function() const CHAISCRIPT_OVERRIDE { return m_is_attribute; } virtual bool is_attribute_function() const override { return m_is_attribute; }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions)) if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
{ {
@@ -94,19 +94,19 @@ namespace chaiscript
} }
} }
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
{ {
return {m_func}; return {m_func};
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return m_func->annotation(); return m_func->annotation();
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions)) if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions))
{ {
@@ -116,7 +116,7 @@ namespace chaiscript
} }
} }
virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const override
{ {
return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions); return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
} }
@@ -210,13 +210,13 @@ namespace chaiscript
virtual ~Dynamic_Object_Constructor() {} virtual ~Dynamic_Object_Constructor() {}
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &f) const override
{ {
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f); const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func); return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
std::vector<Boxed_Value> new_vals{Boxed_Value(Dynamic_Object(m_type_name))}; std::vector<Boxed_Value> new_vals{Boxed_Value(Dynamic_Object(m_type_name))};
new_vals.insert(new_vals.end(), vals.begin(), vals.end()); new_vals.insert(new_vals.end(), vals.begin(), vals.end());
@@ -224,13 +224,13 @@ namespace chaiscript
return m_func->call_match(new_vals, t_conversions); return m_func->call_match(new_vals, t_conversions);
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return m_func->annotation(); return m_func->annotation();
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
auto bv = Boxed_Value(Dynamic_Object(m_type_name), true); auto bv = Boxed_Value(Dynamic_Object(m_type_name), true);
std::vector<Boxed_Value> new_params{bv}; std::vector<Boxed_Value> new_params{bv};

View File

@@ -43,7 +43,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl1() {} virtual ~Exception_Handler_Impl1() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
} }
@@ -53,7 +53,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl2() {} virtual ~Exception_Handler_Impl2() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@@ -65,7 +65,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl3() {} virtual ~Exception_Handler_Impl3() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@@ -77,7 +77,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl4() {} virtual ~Exception_Handler_Impl4() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);
@@ -90,7 +90,7 @@ namespace chaiscript
{ {
virtual ~Exception_Handler_Impl5() {} virtual ~Exception_Handler_Impl5() {}
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
{ {
throw_type<T1>(bv, t_engine); throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine); throw_type<T2>(bv, t_engine);

View File

@@ -282,13 +282,13 @@ namespace chaiscript
class guard_error : public std::runtime_error class guard_error : public std::runtime_error
{ {
public: public:
guard_error() CHAISCRIPT_NOEXCEPT guard_error() noexcept
: std::runtime_error("Guard evaluation failed") : std::runtime_error("Guard evaluation failed")
{ } { }
guard_error(const guard_error &) = default; guard_error(const guard_error &) = default;
virtual ~guard_error() CHAISCRIPT_NOEXCEPT virtual ~guard_error() noexcept
{ } { }
}; };
} }
@@ -316,7 +316,7 @@ namespace chaiscript
virtual ~Dynamic_Proxy_Function() {} virtual ~Dynamic_Proxy_Function() {}
virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &rhs) const override
{ {
const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs); const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs);
@@ -327,7 +327,7 @@ namespace chaiscript
&& this->m_param_types == prhs->m_param_types); && this->m_param_types == prhs->m_param_types);
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return (m_arity < 0 || (vals.size() == size_t(m_arity) && m_param_types.match(vals, t_conversions))) return (m_arity < 0 || (vals.size() == size_t(m_arity) && m_param_types.match(vals, t_conversions)))
&& test_guard(vals, t_conversions); && test_guard(vals, t_conversions);
@@ -344,7 +344,7 @@ namespace chaiscript
return m_parsenode; return m_parsenode;
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return m_description; return m_description;
} }
@@ -419,7 +419,7 @@ namespace chaiscript
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
if (call_match(params, t_conversions) && test_guard(params, t_conversions)) if (call_match(params, t_conversions) && test_guard(params, t_conversions))
{ {
@@ -462,19 +462,19 @@ namespace chaiscript
assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size())); assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size()));
} }
virtual bool operator==(const Proxy_Function_Base &t_f) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &t_f) const override
{ {
return &t_f == this; return &t_f == this;
} }
virtual ~Bound_Function() {} virtual ~Bound_Function() {}
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return m_f->call_match(build_param_list(vals), t_conversions); return m_f->call_match(build_param_list(vals), t_conversions);
} }
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
{ {
return std::vector<Const_Proxy_Function>{m_f}; return std::vector<Const_Proxy_Function>{m_f};
} }
@@ -511,7 +511,7 @@ namespace chaiscript
return args; return args;
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return "Bound: " + m_f->annotation(); return "Bound: " + m_f->annotation();
} }
@@ -527,15 +527,8 @@ namespace chaiscript
std::vector<Type_Info> types = t_f->get_param_types(); std::vector<Type_Info> types = t_f->get_param_types();
assert(types.size() == t_args.size() + 1); assert(types.size() == t_args.size() + 1);
#ifdef CHAISCRIPT_MSVC_12
#pragma warning(push)
#pragma warning(disable : 6011)
#endif
// this analysis warning is invalid in MSVC12 and doesn't exist in MSVC14 // this analysis warning is invalid in MSVC12 and doesn't exist in MSVC14
std::vector<Type_Info> retval{types[0]}; std::vector<Type_Info> retval{types[0]};
#ifdef CHAISCRIPT_MSVC_12
#pragma warning(pop)
#endif
for (size_t i = 0; i < types.size() - 1; ++i) for (size_t i = 0; i < types.size() - 1; ++i)
{ {
@@ -548,7 +541,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
return (*m_f)(build_param_list(params), t_conversions); return (*m_f)(build_param_list(params), t_conversions);
} }
@@ -568,12 +561,12 @@ namespace chaiscript
virtual ~Proxy_Function_Impl_Base() {} virtual ~Proxy_Function_Impl_Base() {}
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return ""; return "";
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return static_cast<int>(vals.size()) == get_arity() && (compare_types(m_types, vals, t_conversions) && compare_types_with_cast(vals, t_conversions)); return static_cast<int>(vals.size()) == get_arity() && (compare_types(m_types, vals, t_conversions) && compare_types_with_cast(vals, t_conversions));
} }
@@ -596,19 +589,19 @@ namespace chaiscript
virtual ~Proxy_Function_Callable_Impl() {} virtual ~Proxy_Function_Callable_Impl() {}
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions); return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
} }
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &t_func) const override
{ {
return dynamic_cast<const Proxy_Function_Callable_Impl<Func, Callable> *>(&t_func) != nullptr; return dynamic_cast<const Proxy_Function_Callable_Impl<Func, Callable> *>(&t_func) != nullptr;
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
typedef typename detail::Function_Signature<Func>::Return_Type Return_Type; typedef typename detail::Function_Signature<Func>::Return_Type Return_Type;
return detail::Do_Call<Return_Type>::template go<Func>(m_f, params, t_conversions); return detail::Do_Call<Return_Type>::template go<Func>(m_f, params, t_conversions);
@@ -648,12 +641,12 @@ namespace chaiscript
virtual ~Assignable_Proxy_Function_Impl() {} virtual ~Assignable_Proxy_Function_Impl() {}
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
{ {
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions); return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
} }
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &t_func) const override
{ {
return dynamic_cast<const Assignable_Proxy_Function_Impl<Func> *>(&t_func) != nullptr; return dynamic_cast<const Assignable_Proxy_Function_Impl<Func> *>(&t_func) != nullptr;
} }
@@ -663,12 +656,12 @@ namespace chaiscript
return m_f.get(); return m_f.get();
} }
virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) CHAISCRIPT_OVERRIDE { virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) override {
m_f.get() = dispatch::functor<Func>(t_rhs, nullptr); m_f.get() = dispatch::functor<Func>(t_rhs, nullptr);
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
return detail::Do_Call<typename std::function<Func>::result_type>::template go<Func>(m_f.get(), params, t_conversions); return detail::Do_Call<typename std::function<Func>::result_type>::template go<Func>(m_f.get(), params, t_conversions);
} }
@@ -691,9 +684,9 @@ namespace chaiscript
virtual ~Attribute_Access() {} virtual ~Attribute_Access() {}
virtual bool is_attribute_function() const CHAISCRIPT_OVERRIDE { return true; } virtual bool is_attribute_function() const override { return true; }
virtual bool operator==(const Proxy_Function_Base &t_func) const CHAISCRIPT_OVERRIDE virtual bool operator==(const Proxy_Function_Base &t_func) const override
{ {
const Attribute_Access<T, Class> * aa const Attribute_Access<T, Class> * aa
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func); = dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
@@ -705,7 +698,7 @@ namespace chaiscript
} }
} }
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const CHAISCRIPT_OVERRIDE virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const override
{ {
if (vals.size() != 1) if (vals.size() != 1)
{ {
@@ -715,13 +708,13 @@ namespace chaiscript
return vals[0].get_type_info().bare_equal(user_type<Class>()); return vals[0].get_type_info().bare_equal(user_type<Class>());
} }
virtual std::string annotation() const CHAISCRIPT_OVERRIDE virtual std::string annotation() const override
{ {
return ""; return "";
} }
protected: protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const CHAISCRIPT_OVERRIDE virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions) const override
{ {
const Boxed_Value &bv = params[0]; const Boxed_Value &bv = params[0];
if (bv.is_const()) if (bv.is_const())
@@ -769,7 +762,7 @@ namespace chaiscript
dispatch_error(const dispatch_error &) = default; dispatch_error(const dispatch_error &) = default;
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT {} virtual ~dispatch_error() noexcept {}
std::vector<Boxed_Value> parameters; std::vector<Boxed_Value> parameters;
std::vector<Const_Proxy_Function> functions; std::vector<Const_Proxy_Function> functions;

View File

@@ -43,7 +43,7 @@ namespace chaiscript
arity_error(const arity_error &) = default; arity_error(const arity_error &) = default;
virtual ~arity_error() CHAISCRIPT_NOEXCEPT {} virtual ~arity_error() noexcept {}
int got; int got;
int expected; int expected;
@@ -66,103 +66,6 @@ namespace chaiscript
} }
#ifdef CHAISCRIPT_GCC_4_6
/// \todo REMOVE THIS WHEN WE DROP G++4.6
// Forward declaration
template<typename ... Rest>
struct Try_Cast;
template<typename Param, typename ... Rest>
struct Try_Cast<Param, Rest...>
{
static void do_try(const std::vector<Boxed_Value> &params, size_t generation, const Type_Conversions_State &t_conversions)
{
boxed_cast<Param>(params[generation], &t_conversions);
Try_Cast<Rest...>::do_try(params, generation+1, t_conversions);
}
};
// 0th case
template<>
struct Try_Cast<>
{
static void do_try(const std::vector<Boxed_Value> &, size_t, const Type_Conversions_State &)
{
}
};
/**
* 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 std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions)
{
try {
Try_Cast<Params...>::do_try(params, 0, t_conversions);
} catch (const exception::bad_boxed_cast &) {
return false;
}
return true;
}
template<typename Ret, int count, typename ... Params>
struct Call_Func
{
template<typename Callable, typename ... InnerParams>
static Ret do_call(const Callable &f,
const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions, InnerParams &&... innerparams)
{
return Call_Func<Ret, count - 1, Params...>::do_call(f, params, t_conversions, std::forward<InnerParams>(innerparams)..., params[sizeof...(Params) - count]);
}
};
template<typename Ret, typename ... Params>
struct Call_Func<Ret, 0, Params...>
{
#ifdef CHAISCRIPT_MSVC
#pragma warning(push)
#pragma warning(disable : 4100) /// Disable unreferenced formal parameter warning, which only shows up in MSVC I don't think there's any way around it \todo evaluate this
#endif
template<typename Callable, typename ... InnerParams>
static Ret do_call(const Callable &f,
const std::vector<Boxed_Value> &, const Type_Conversions_State &t_conversions, InnerParams &&... innerparams)
{
return f(boxed_cast<Params>(std::forward<InnerParams>(innerparams), &t_conversions)...);
}
#ifdef CHAISCRIPT_MSVC
#pragma warning(pop)
#endif
};
/**
* Used by Proxy_Function_Impl to perform typesafe execution of a function.
* The function attempts to unbox each parameter to the expected type.
* if any unboxing fails the execution of the function fails and
* the bad_boxed_cast is passed up to the caller.
*/
template<typename Callable, typename Ret, typename ... Params>
Ret call_func(const chaiscript::dispatch::detail::Function_Signature<Ret (Params...)> &, const Callable &f,
const std::vector<Boxed_Value> &params, const Type_Conversions_State &t_conversions)
{
if (params.size() == sizeof...(Params))
{
return Call_Func<Ret, sizeof...(Params), Params...>::do_call(f, params, t_conversions);
}
throw exception::arity_error(static_cast<int>(params.size()), sizeof...(Params));
}
#else
template<size_t ... I> template<size_t ... I>
struct Indexes struct Indexes
@@ -234,8 +137,6 @@ namespace chaiscript
return call_func(sig, indexes(), f, params, t_conversions); return call_func(sig, indexes(), f, params, t_conversions);
} }
#endif
} }
} }

View File

@@ -29,48 +29,48 @@ namespace chaiscript
{ {
public: public:
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to, bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &t_what) CHAISCRIPT_NOEXCEPT const std::string &t_what) noexcept
: bad_boxed_cast(t_from, t_to, t_what) : bad_boxed_cast(t_from, t_to, t_what)
{ {
} }
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) CHAISCRIPT_NOEXCEPT bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
: bad_boxed_cast(t_from, t_to) : bad_boxed_cast(t_from, t_to)
{ {
} }
bad_boxed_dynamic_cast(const std::string &w) CHAISCRIPT_NOEXCEPT bad_boxed_dynamic_cast(const std::string &w) noexcept
: bad_boxed_cast(w) : bad_boxed_cast(w)
{ {
} }
bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &) = default; bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &) = default;
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_boxed_dynamic_cast() noexcept {}
}; };
class bad_boxed_type_cast : public bad_boxed_cast class bad_boxed_type_cast : public bad_boxed_cast
{ {
public: public:
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to, bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &t_what) CHAISCRIPT_NOEXCEPT const std::string &t_what) noexcept
: bad_boxed_cast(t_from, t_to, t_what) : bad_boxed_cast(t_from, t_to, t_what)
{ {
} }
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) CHAISCRIPT_NOEXCEPT bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
: bad_boxed_cast(t_from, t_to) : bad_boxed_cast(t_from, t_to)
{ {
} }
bad_boxed_type_cast(const std::string &w) CHAISCRIPT_NOEXCEPT bad_boxed_type_cast(const std::string &w) noexcept
: bad_boxed_cast(w) : bad_boxed_cast(w)
{ {
} }
bad_boxed_type_cast(const bad_boxed_type_cast &) = default; bad_boxed_type_cast(const bad_boxed_type_cast &) = default;
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT {} virtual ~bad_boxed_type_cast() noexcept {}
}; };
} }
@@ -242,12 +242,12 @@ namespace chaiscript
{ {
} }
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert_down(const Boxed_Value &t_base) const override
{ {
return Dynamic_Caster<Base, Derived>::cast(t_base); return Dynamic_Caster<Base, Derived>::cast(t_base);
} }
virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert(const Boxed_Value &t_derived) const override
{ {
return Static_Caster<Derived, Base>::cast(t_derived); return Static_Caster<Derived, Base>::cast(t_derived);
} }
@@ -262,17 +262,17 @@ namespace chaiscript
{ {
} }
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert_down(const Boxed_Value &t_base) const override
{ {
throw chaiscript::exception::bad_boxed_dynamic_cast(t_base.get_type_info(), typeid(Derived), "Unable to cast down inheritance hierarchy with non-polymorphic types"); throw chaiscript::exception::bad_boxed_dynamic_cast(t_base.get_type_info(), typeid(Derived), "Unable to cast down inheritance hierarchy with non-polymorphic types");
} }
virtual bool bidir() const CHAISCRIPT_OVERRIDE virtual bool bidir() const override
{ {
return false; return false;
} }
virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert(const Boxed_Value &t_derived) const override
{ {
return Static_Caster<Derived, Base>::cast(t_derived); return Static_Caster<Derived, Base>::cast(t_derived);
} }
@@ -290,18 +290,18 @@ namespace chaiscript
{ {
} }
virtual Boxed_Value convert_down(const Boxed_Value &) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert_down(const Boxed_Value &) const override
{ {
throw chaiscript::exception::bad_boxed_type_cast("No conversion exists"); throw chaiscript::exception::bad_boxed_type_cast("No conversion exists");
} }
virtual Boxed_Value convert(const Boxed_Value &t_from) const CHAISCRIPT_OVERRIDE virtual Boxed_Value convert(const Boxed_Value &t_from) const override
{ {
/// \todo better handling of errors from the conversion function /// \todo better handling of errors from the conversion function
return m_func(t_from); return m_func(t_from);
} }
virtual bool bidir() const CHAISCRIPT_OVERRIDE virtual bool bidir() const override
{ {
return false; return false;
} }

View File

@@ -29,7 +29,7 @@ namespace chaiscript
class Type_Info class Type_Info
{ {
public: public:
CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, constexpr Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti) bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
: m_type_info(t_ti), m_bare_type_info(t_bare_ti), : m_type_info(t_ti), m_bare_type_info(t_bare_ti),
m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag) m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
@@ -40,55 +40,52 @@ namespace chaiscript
{ {
} }
CHAISCRIPT_CONSTEXPR Type_Info() constexpr Type_Info()
: m_type_info(nullptr), m_bare_type_info(nullptr), : m_type_info(nullptr), m_bare_type_info(nullptr),
m_flags(1 << is_undef_flag) m_flags(1 << is_undef_flag)
{ {
} }
#if !defined(_MSC_VER) || _MSC_VER != 1800
Type_Info(Type_Info&&) = default; Type_Info(Type_Info&&) = default;
Type_Info& operator=(Type_Info&&) = default; Type_Info& operator=(Type_Info&&) = default;
#endif
Type_Info(const Type_Info&) = default; Type_Info(const Type_Info&) = default;
Type_Info& operator=(const Type_Info&) = default; Type_Info& operator=(const Type_Info&) = default;
CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT constexpr bool operator<(const Type_Info &ti) const noexcept
{ {
return m_type_info < ti.m_type_info; return m_type_info < ti.m_type_info;
} }
CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT constexpr bool operator==(const Type_Info &ti) const noexcept
{ {
return ti.m_type_info == m_type_info return ti.m_type_info == m_type_info
|| (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info); || (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info);
} }
CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT constexpr bool operator==(const std::type_info &ti) const noexcept
{ {
return m_type_info != nullptr && (*m_type_info) == ti; return m_type_info != nullptr && (*m_type_info) == ti;
} }
CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT constexpr bool bare_equal(const Type_Info &ti) const noexcept
{ {
return ti.m_bare_type_info == m_bare_type_info return ti.m_bare_type_info == m_bare_type_info
|| (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info); || (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info);
} }
CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT constexpr bool bare_equal_type_info(const std::type_info &ti) const noexcept
{ {
return m_bare_type_info != nullptr return m_bare_type_info != nullptr
&& (*m_bare_type_info) == ti; && (*m_bare_type_info) == ti;
} }
CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_const_flag)) != 0; } constexpr bool is_const() const noexcept { return (m_flags & (1 << is_const_flag)) != 0; }
CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_reference_flag)) != 0; } constexpr bool is_reference() const noexcept { return (m_flags & (1 << is_reference_flag)) != 0; }
CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_void_flag)) != 0; } constexpr bool is_void() const noexcept { return (m_flags & (1 << is_void_flag)) != 0; }
CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_arithmetic_flag)) != 0; } constexpr bool is_arithmetic() const noexcept { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_undef_flag)) != 0; } constexpr bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return (m_flags & (1 << is_pointer_flag)) != 0; } constexpr bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
std::string name() const std::string name() const
{ {
@@ -110,7 +107,7 @@ namespace chaiscript
} }
} }
CHAISCRIPT_CONSTEXPR const std::type_info *bare_type_info() const constexpr const std::type_info *bare_type_info() const
{ {
return m_bare_type_info; return m_bare_type_info;
} }

View File

@@ -113,7 +113,7 @@ namespace chaiscript
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname, eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname,
const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions, const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
bool t_dot_notation, bool t_dot_notation,
const chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_NOEXCEPT : const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
std::runtime_error(format(t_why, t_where, t_fname, t_parameters, t_dot_notation, t_ss)), std::runtime_error(format(t_why, t_where, t_fname, t_parameters, t_dot_notation, t_ss)),
reason(t_why), start_position(t_where), filename(t_fname), detail(format_detail(t_functions, t_dot_notation, t_ss)) reason(t_why), start_position(t_where), filename(t_fname), detail(format_detail(t_functions, t_dot_notation, t_ss))
{} {}
@@ -121,18 +121,18 @@ namespace chaiscript
eval_error(const std::string &t_why, eval_error(const std::string &t_why,
const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions, const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
bool t_dot_notation, bool t_dot_notation,
const chaiscript::detail::Dispatch_Engine &t_ss) CHAISCRIPT_NOEXCEPT : const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
std::runtime_error(format(t_why, t_parameters, t_dot_notation, t_ss)), std::runtime_error(format(t_why, t_parameters, t_dot_notation, t_ss)),
reason(t_why), detail(format_detail(t_functions, t_dot_notation, t_ss)) reason(t_why), detail(format_detail(t_functions, t_dot_notation, t_ss))
{} {}
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) CHAISCRIPT_NOEXCEPT : eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) noexcept :
std::runtime_error(format(t_why, t_where, t_fname)), std::runtime_error(format(t_why, t_where, t_fname)),
reason(t_why), start_position(t_where), filename(t_fname) reason(t_why), start_position(t_where), filename(t_fname)
{} {}
eval_error(const std::string &t_why) CHAISCRIPT_NOEXCEPT eval_error(const std::string &t_why) noexcept
: std::runtime_error("Error: \"" + t_why + "\" "), : std::runtime_error("Error: \"" + t_why + "\" "),
reason(t_why) reason(t_why)
{} {}
@@ -161,7 +161,7 @@ namespace chaiscript
return ss.str(); return ss.str();
} }
virtual ~eval_error() CHAISCRIPT_NOEXCEPT {} virtual ~eval_error() noexcept {}
private: private:
@@ -420,12 +420,12 @@ namespace chaiscript
/// Errors generated when loading a file /// Errors generated when loading a file
struct file_not_found_error : std::runtime_error { struct file_not_found_error : std::runtime_error {
file_not_found_error(const std::string &t_filename) CHAISCRIPT_NOEXCEPT file_not_found_error(const std::string &t_filename) noexcept
: std::runtime_error("File Not Found: " + t_filename) : std::runtime_error("File Not Found: " + t_filename)
{ } { }
file_not_found_error(const file_not_found_error &) = default; file_not_found_error(const file_not_found_error &) = default;
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT {} virtual ~file_not_found_error() noexcept {}
}; };
} }

View File

@@ -54,13 +54,13 @@ namespace chaiscript
/// \brief Thrown if an error occurs while attempting to load a binary module /// \brief Thrown if an error occurs while attempting to load a binary module
struct load_module_error : std::runtime_error struct load_module_error : std::runtime_error
{ {
load_module_error(const std::string &t_reason) CHAISCRIPT_NOEXCEPT load_module_error(const std::string &t_reason) noexcept
: std::runtime_error(t_reason) : std::runtime_error(t_reason)
{ {
} }
load_module_error(const load_module_error &) = default; load_module_error(const load_module_error &) = default;
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT {} virtual ~load_module_error() noexcept {}
}; };
} }

View File

@@ -89,13 +89,13 @@ namespace chaiscript
{ } { }
virtual ~Binary_Operator_AST_Node() {} virtual ~Binary_Operator_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
auto lhs = this->children[0]->eval(t_ss); auto lhs = this->children[0]->eval(t_ss);
auto rhs = this->children[1]->eval(t_ss); auto rhs = this->children[1]->eval(t_ss);
return do_oper(t_ss, m_oper, text, lhs, rhs); return do_oper(t_ss, m_oper, text, lhs, rhs);
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "(" + this->children[0]->pretty_print() + " " + text + " " + this->children[1]->pretty_print() + ")"; return "(" + this->children[0]->pretty_print() + " " + text + " " + this->children[1]->pretty_print() + ")";
} }
@@ -137,7 +137,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Int, std::move(t_loc)), AST_Node(std::move(t_ast_node_text), AST_Node_Type::Int, std::move(t_loc)),
m_value(std::move(t_bv)) { assert(text != ""); } m_value(std::move(t_bv)) { assert(text != ""); }
virtual ~Int_AST_Node() {} virtual ~Int_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
return m_value; return m_value;
} }
@@ -152,7 +152,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Float, std::move(t_loc)), AST_Node(std::move(t_ast_node_text), AST_Node_Type::Float, std::move(t_loc)),
m_value(std::move(t_bv)) { } m_value(std::move(t_bv)) { }
virtual ~Float_AST_Node() {} virtual ~Float_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
return m_value; return m_value;
} }
@@ -169,7 +169,7 @@ namespace chaiscript
{ } { }
virtual ~Id_AST_Node() {} virtual ~Id_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
if (!m_value.is_undef()) if (!m_value.is_undef())
{ {
return m_value; return m_value;
@@ -226,7 +226,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Eol, std::move(t_loc)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Eol, std::move(t_loc)) { }
virtual ~Eol_AST_Node() {} virtual ~Eol_AST_Node() {}
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "\n"; return "\n";
} }
@@ -238,7 +238,7 @@ namespace chaiscript
Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Fun_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Fun_Call, std::move(t_loc), std::move(t_children)) { }
virtual ~Fun_Call_AST_Node() {} virtual ~Fun_Call_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
std::vector<Boxed_Value> params; std::vector<Boxed_Value> params;
@@ -278,7 +278,7 @@ namespace chaiscript
} }
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
std::ostringstream oss; std::ostringstream oss;
@@ -308,7 +308,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { }
virtual ~Arg_AST_Node() {} virtual ~Arg_AST_Node() {}
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
std::ostringstream oss; std::ostringstream oss;
for (size_t j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
@@ -330,7 +330,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Arg_List, std::move(t_loc), std::move(t_children)) { }
virtual ~Arg_List_AST_Node() {} virtual ~Arg_List_AST_Node() {}
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
std::ostringstream oss; std::ostringstream oss;
for (size_t j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
@@ -401,7 +401,7 @@ namespace chaiscript
mutable std::atomic_uint_fast32_t m_clone_loc; mutable std::atomic_uint_fast32_t m_clone_loc;
virtual ~Equation_AST_Node() {} virtual ~Equation_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
Boxed_Value rhs = this->children[2]->eval(t_ss); Boxed_Value rhs = this->children[2]->eval(t_ss);
Boxed_Value lhs = this->children[0]->eval(t_ss); Boxed_Value lhs = this->children[0]->eval(t_ss);
@@ -476,7 +476,7 @@ namespace chaiscript
Global_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Global_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Global_Decl, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Global_Decl, std::move(t_loc), std::move(t_children)) { }
virtual ~Global_Decl_AST_Node() {} virtual ~Global_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
const std::string &idname = const std::string &idname =
[&]()->const std::string &{ [&]()->const std::string &{
@@ -503,7 +503,7 @@ namespace chaiscript
Var_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Var_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Var_Decl, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Var_Decl, std::move(t_loc), std::move(t_children)) { }
virtual ~Var_Decl_AST_Node() {} virtual ~Var_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
if (this->children[0]->identifier == AST_Node_Type::Reference) if (this->children[0]->identifier == AST_Node_Type::Reference)
{ {
return this->children[0]->eval(t_ss); return this->children[0]->eval(t_ss);
@@ -524,7 +524,7 @@ namespace chaiscript
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "var " + this->children[0]->text; return "var " + this->children[0]->text;
} }
@@ -537,7 +537,7 @@ namespace chaiscript
Array_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Array_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Array_Call, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Array_Call, std::move(t_loc), std::move(t_children)) { }
virtual ~Array_Call_AST_Node() {} virtual ~Array_Call_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
std::vector<Boxed_Value> params{children[0]->eval(t_ss), children[1]->eval(t_ss)}; std::vector<Boxed_Value> params{children[0]->eval(t_ss), children[1]->eval(t_ss)};
@@ -552,7 +552,7 @@ namespace chaiscript
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
std::ostringstream oss; std::ostringstream oss;
oss << this->children[0]->pretty_print(); oss << this->children[0]->pretty_print();
@@ -579,7 +579,7 @@ namespace chaiscript
children[2]->children[0]->text:children[2]->text) { } children[2]->children[0]->text:children[2]->text) { }
virtual ~Dot_Access_AST_Node() {} virtual ~Dot_Access_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
@@ -636,11 +636,11 @@ namespace chaiscript
m_value(const_var(text)) { } m_value(const_var(text)) { }
virtual ~Quoted_String_AST_Node() {} virtual ~Quoted_String_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override {
return m_value; return m_value;
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "\"" + text + "\""; return "\"" + text + "\"";
} }
@@ -657,11 +657,11 @@ namespace chaiscript
m_value(const_var(char(text.at(0)))) { } m_value(const_var(char(text.at(0)))) { }
virtual ~Single_Quoted_String_AST_Node() {} virtual ~Single_Quoted_String_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
return m_value; return m_value;
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "'" + text + "'"; return "'" + text + "'";
} }
@@ -678,7 +678,7 @@ namespace chaiscript
virtual ~Lambda_AST_Node() {} virtual ~Lambda_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
const auto captures = [&]()->std::map<std::string, Boxed_Value>{ const auto captures = [&]()->std::map<std::string, Boxed_Value>{
std::map<std::string, Boxed_Value> named_captures; std::map<std::string, Boxed_Value> named_captures;
@@ -717,7 +717,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Block, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Block, std::move(t_loc), std::move(t_children)) { }
virtual ~Block_AST_Node() {} virtual ~Block_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
const auto num_children = children.size(); const auto num_children = children.size();
@@ -735,7 +735,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc), std::move(t_children)) { }
virtual ~Def_AST_Node() {} virtual ~Def_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
std::vector<std::string> t_param_names; std::vector<std::string> t_param_names;
size_t numparams = 0; size_t numparams = 0;
AST_NodePtr guardnode; AST_NodePtr guardnode;
@@ -799,7 +799,7 @@ namespace chaiscript
While_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : While_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::While, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::While, std::move(t_loc), std::move(t_children)) { }
virtual ~While_AST_Node() {} virtual ~While_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
try { try {
@@ -825,7 +825,7 @@ namespace chaiscript
Class_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Class_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Class, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Class, std::move(t_loc), std::move(t_children)) { }
virtual ~Class_AST_Node() {} virtual ~Class_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
/// \todo do this better /// \todo do this better
@@ -844,7 +844,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children)) AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children))
{ assert(children.size() == 3); } { assert(children.size() == 3); }
virtual ~Ternary_Cond_AST_Node() {} virtual ~Ternary_Cond_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
if (get_bool_condition(children[0]->eval(t_ss))) { if (get_bool_condition(children[0]->eval(t_ss))) {
return children[1]->eval(t_ss); return children[1]->eval(t_ss);
} }
@@ -860,7 +860,7 @@ namespace chaiscript
If_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : If_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::If, std::move(t_loc), std::move(t_children)) { }
virtual ~If_AST_Node() {} virtual ~If_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
if (get_bool_condition(children[0]->eval(t_ss))) { if (get_bool_condition(children[0]->eval(t_ss))) {
return children[1]->eval(t_ss); return children[1]->eval(t_ss);
@@ -893,7 +893,7 @@ namespace chaiscript
{ assert(children.size() == 4); } { assert(children.size() == 4); }
virtual ~For_AST_Node() {} virtual ~For_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
try { try {
@@ -925,7 +925,7 @@ namespace chaiscript
Switch_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Switch_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Switch, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Switch, std::move(t_loc), std::move(t_children)) { }
virtual ~Switch_AST_Node() {} virtual ~Switch_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
bool breaking = false; bool breaking = false;
size_t currentCase = 1; size_t currentCase = 1;
bool hasMatched = false; bool hasMatched = false;
@@ -971,7 +971,7 @@ namespace chaiscript
{ assert(children.size() == 2); /* how many children does it have? */ } { assert(children.size() == 2); /* how many children does it have? */ }
virtual ~Case_AST_Node() {} virtual ~Case_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
children[1]->eval(t_ss); children[1]->eval(t_ss);
@@ -986,7 +986,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Default, std::move(t_loc), std::move(t_children)) AST_Node(std::move(t_ast_node_text), AST_Node_Type::Default, std::move(t_loc), std::move(t_children))
{ assert(children.size() == 1); } { assert(children.size() == 1); }
virtual ~Default_AST_Node() {} virtual ~Default_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
children[0]->eval(t_ss); children[0]->eval(t_ss);
@@ -1001,7 +1001,7 @@ namespace chaiscript
Inline_Array_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Inline_Array_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Array, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Array, std::move(t_loc), std::move(t_children)) { }
virtual ~Inline_Array_AST_Node() {} virtual ~Inline_Array_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
try { try {
std::vector<Boxed_Value> vec; std::vector<Boxed_Value> vec;
if (!children.empty()) { if (!children.empty()) {
@@ -1022,7 +1022,7 @@ namespace chaiscript
} }
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "[" + AST_Node::pretty_print() + "]"; return "[" + AST_Node::pretty_print() + "]";
} }
@@ -1035,7 +1035,7 @@ namespace chaiscript
Inline_Map_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Inline_Map_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Map, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Map, std::move(t_loc), std::move(t_children)) { }
virtual ~Inline_Map_AST_Node() {} virtual ~Inline_Map_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
try { try {
std::map<std::string, Boxed_Value> retval; std::map<std::string, Boxed_Value> retval;
@@ -1063,7 +1063,7 @@ namespace chaiscript
Return_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Return_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Return, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Return, std::move(t_loc), std::move(t_children)) { }
virtual ~Return_AST_Node() {} virtual ~Return_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
if (!this->children.empty()) { if (!this->children.empty()) {
throw detail::Return_Value(children[0]->eval(t_ss)); throw detail::Return_Value(children[0]->eval(t_ss));
} }
@@ -1079,7 +1079,7 @@ namespace chaiscript
File_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : File_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::File, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::File, std::move(t_loc), std::move(t_children)) { }
virtual ~File_AST_Node() {} virtual ~File_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE { virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
try { try {
const auto num_children = children.size(); const auto num_children = children.size();
@@ -1105,7 +1105,7 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Reference, std::move(t_loc), std::move(t_children)) AST_Node(std::move(t_ast_node_text), AST_Node_Type::Reference, std::move(t_loc), std::move(t_children))
{ assert(children.size() == 1); } { assert(children.size() == 1); }
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
try { try {
Boxed_Value bv; Boxed_Value bv;
t_ss.add_object(this->children[0]->text, bv); t_ss.add_object(this->children[0]->text, bv);
@@ -1127,7 +1127,7 @@ namespace chaiscript
{ } { }
virtual ~Prefix_AST_Node() {} virtual ~Prefix_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
Boxed_Value bv(children[1]->eval(t_ss)); Boxed_Value bv(children[1]->eval(t_ss));
try { try {
@@ -1155,7 +1155,7 @@ namespace chaiscript
Break_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Break_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Break, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Break, std::move(t_loc), std::move(t_children)) { }
virtual ~Break_AST_Node() {} virtual ~Break_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
throw detail::Break_Loop(); throw detail::Break_Loop();
} }
}; };
@@ -1165,7 +1165,7 @@ namespace chaiscript
Continue_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Continue_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Continue, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Continue, std::move(t_loc), std::move(t_children)) { }
virtual ~Continue_AST_Node() {} virtual ~Continue_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
throw detail::Continue_Loop(); throw detail::Continue_Loop();
} }
}; };
@@ -1178,7 +1178,7 @@ namespace chaiscript
{ } { }
virtual ~Noop_AST_Node() {} virtual ~Noop_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &) const override{
// It's a no-op, that evaluates to "true" // It's a no-op, that evaluates to "true"
return m_value; return m_value;
} }
@@ -1206,7 +1206,7 @@ namespace chaiscript
Inline_Range_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Inline_Range_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Range, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Range, std::move(t_loc), std::move(t_children)) { }
virtual ~Inline_Range_AST_Node() {} virtual ~Inline_Range_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
try { try {
auto oper1 = children[0]->children[0]->children[0]->eval(t_ss); auto oper1 = children[0]->children[0]->children[0]->eval(t_ss);
auto oper2 = children[0]->children[0]->children[1]->eval(t_ss); auto oper2 = children[0]->children[0]->children[1]->eval(t_ss);
@@ -1294,7 +1294,7 @@ namespace chaiscript
return retval; return retval;
} }
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
Boxed_Value retval; Boxed_Value retval;
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss); chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
@@ -1357,7 +1357,7 @@ namespace chaiscript
Method_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Method_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Method, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Method, std::move(t_loc), std::move(t_children)) { }
virtual ~Method_AST_Node() {} virtual ~Method_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
AST_NodePtr guardnode; AST_NodePtr guardnode;
@@ -1448,7 +1448,7 @@ namespace chaiscript
Attr_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) : Attr_Decl_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Attr_Decl, std::move(t_loc), std::move(t_children)) { } AST_Node(std::move(t_ast_node_text), AST_Node_Type::Attr_Decl, std::move(t_loc), std::move(t_children)) { }
virtual ~Attr_Decl_AST_Node() {} virtual ~Attr_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override
{ {
const auto &d = t_ss->get_parent_locals(); const auto &d = t_ss->get_parent_locals();
const auto itr = d.find("_current_class_name"); const auto itr = d.find("_current_class_name");
@@ -1487,12 +1487,12 @@ namespace chaiscript
{ assert(children.size() == 3); } { assert(children.size() == 3); }
virtual ~Logical_And_AST_Node() {} virtual ~Logical_And_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
return const_var(get_bool_condition(children[0]->eval(t_ss)) return const_var(get_bool_condition(children[0]->eval(t_ss))
&& get_bool_condition(children[2]->eval(t_ss))); && get_bool_condition(children[2]->eval(t_ss)));
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "(" + AST_Node::pretty_print() + ")"; return "(" + AST_Node::pretty_print() + ")";
} }
@@ -1504,12 +1504,12 @@ namespace chaiscript
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Logical_Or, std::move(t_loc), std::move(t_children)) AST_Node(std::move(t_ast_node_text), AST_Node_Type::Logical_Or, std::move(t_loc), std::move(t_children))
{ assert(children.size() == 3); } { assert(children.size() == 3); }
virtual ~Logical_Or_AST_Node() {} virtual ~Logical_Or_AST_Node() {}
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{ virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
return const_var(get_bool_condition(children[0]->eval(t_ss)) return const_var(get_bool_condition(children[0]->eval(t_ss))
|| get_bool_condition(children[2]->eval(t_ss))); || get_bool_condition(children[2]->eval(t_ss)));
} }
virtual std::string pretty_print() const CHAISCRIPT_OVERRIDE virtual std::string pretty_print() const override
{ {
return "(" + AST_Node::pretty_print() + ")"; return "(" + AST_Node::pretty_print() + ")";
} }

View File

@@ -69,11 +69,7 @@ namespace chaiscript
typename std::enable_if<std::is_enum<Enum>::value, void>::type typename std::enable_if<std::is_enum<Enum>::value, void>::type
add_class(ModuleType &t_module, add_class(ModuleType &t_module,
const std::string &t_class_name, const std::string &t_class_name,
#ifdef CHAISCRIPT_GCC_4_6
const std::vector<std::pair<int, std::string>> &t_constants
#else
const std::vector<std::pair<typename std::underlying_type<Enum>::type, std::string>> &t_constants const std::vector<std::pair<typename std::underlying_type<Enum>::type, std::string>> &t_constants
#endif
) )
{ {
t_module.add(chaiscript::user_type<Enum>(), t_class_name); t_module.add(chaiscript::user_type<Enum>(), t_class_name);
@@ -87,13 +83,8 @@ namespace chaiscript
return assign<Enum>(not_equal<Enum>(equal<Enum>())); return assign<Enum>(not_equal<Enum>(equal<Enum>()));
}()); }());
#ifdef CHAISCRIPT_GCC_4_6
t_module.add(chaiscript::fun([](const Enum &e, const int &i) { return e == i; }), "=="); t_module.add(chaiscript::fun([](const Enum &e, const int &i) { return e == i; }), "==");
t_module.add(chaiscript::fun([](const int &i, const Enum &e) { return i == e; }), "=="); t_module.add(chaiscript::fun([](const int &i, const Enum &e) { return i == e; }), "==");
#else
t_module.add(chaiscript::fun([](const Enum &e, const typename std::underlying_type<Enum>::type &i) { return e == i; }), "==");
t_module.add(chaiscript::fun([](const typename std::underlying_type<Enum>::type &i, const Enum &e) { return i == e; }), "==");
#endif
for (const auto &constant : t_constants) for (const auto &constant : t_constants)
{ {

View File

@@ -44,14 +44,14 @@ class ChaiScriptDerived : public BaseClass
tie(t_funcs.at(1), m_validateValueImpl); tie(t_funcs.at(1), m_validateValueImpl);
} }
std::string doSomething(float f, double d) const CHAISCRIPT_OVERRIDE std::string doSomething(float f, double d) const override
{ {
assert(m_doSomethingImpl); assert(m_doSomethingImpl);
return m_doSomethingImpl(*this, f, d); return m_doSomethingImpl(*this, f, d);
} }
protected: protected:
bool validateValue(const std::string &t_val) CHAISCRIPT_OVERRIDE bool validateValue(const std::string &t_val) override
{ {
assert(m_validateValueImpl); assert(m_validateValueImpl);
return m_validateValueImpl(*this, t_val); return m_validateValueImpl(*this, t_val);

View File

@@ -8,17 +8,9 @@
class TestBaseType class TestBaseType
{ {
public: public:
#ifdef CHAISCRIPT_MSVC_12
#pragma warning(push)
#pragma warning(disable : 4351)
#endif
// MSVC 12 warns that we are using new (correct) behavior
TestBaseType() : val(10), const_val(15), mdarray{} { } TestBaseType() : val(10), const_val(15), mdarray{} { }
TestBaseType(int) : val(10), const_val(15), mdarray{} { } TestBaseType(int) : val(10), const_val(15), mdarray{} { }
TestBaseType(int *) : val(10), const_val(15), mdarray{} { } TestBaseType(int *) : val(10), const_val(15), mdarray{} { }
#ifdef CHAISCRIPT_MSVC_12
#pragma warning(pop)
#endif
TestBaseType(const TestBaseType &) = default; TestBaseType(const TestBaseType &) = default;
virtual ~TestBaseType() {} virtual ~TestBaseType() {}
@@ -84,7 +76,7 @@ class TestDerivedType : public TestBaseType
virtual ~TestDerivedType() {} virtual ~TestDerivedType() {}
TestDerivedType(const TestDerivedType &) = default; TestDerivedType(const TestDerivedType &) = default;
TestDerivedType() = default; TestDerivedType() = default;
virtual int func() CHAISCRIPT_OVERRIDE { return 1; } virtual int func() override { return 1; }
int derived_only_func() { return 19; } int derived_only_func() { return 19; }
private: private:
@@ -179,16 +171,10 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
m->add(chaiscript::fun(&TestBaseType::base_only_func), "base_only_func"); m->add(chaiscript::fun(&TestBaseType::base_only_func), "base_only_func");
m->add(chaiscript::fun(&TestBaseType::set_string_val), "set_string_val"); m->add(chaiscript::fun(&TestBaseType::set_string_val), "set_string_val");
#ifndef CHAISCRIPT_MSVC_12
// we cannot support these in MSVC_12 because of a bug in the implementation of
// std::reference_wrapper
// Array types
m->add(chaiscript::fun(&TestBaseType::mdarray), "mdarray"); m->add(chaiscript::fun(&TestBaseType::mdarray), "mdarray");
m->add(chaiscript::bootstrap::array<int[2][3][5]>("IntArray_2_3_5")); m->add(chaiscript::bootstrap::array<int[2][3][5]>("IntArray_2_3_5"));
m->add(chaiscript::bootstrap::array<int[3][5]>("IntArray_3_5")); m->add(chaiscript::bootstrap::array<int[3][5]>("IntArray_3_5"));
m->add(chaiscript::bootstrap::array<int[5]>("IntArray_5")); m->add(chaiscript::bootstrap::array<int[5]>("IntArray_5"));
// end array types
#endif
// member that is a function // member that is a function
m->add(chaiscript::fun(&TestBaseType::func_member), "func_member"); m->add(chaiscript::fun(&TestBaseType::func_member), "func_member");