mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-02-08 18:56:48 +08:00
More work towards all noexcept, warning cleanups
This commit is contained in:
parent
34534c1386
commit
7986ea08b6
@ -188,7 +188,7 @@ if(MSVC)
|
|||||||
# how to workaround or fix the error. So I'm disabling it globally.
|
# how to workaround or fix the error. So I'm disabling it globally.
|
||||||
add_definitions(/wd4503)
|
add_definitions(/wd4503)
|
||||||
else()
|
else()
|
||||||
add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -pedantic ${CPP14_FLAG})
|
add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual -Wno-noexcept-type -Wpedantic ${CPP14_FLAG})
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
add_definitions(-Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn -Wno-exit-time-destructors -Wno-documentation-unknown-command -Wno-unused-template -Wno-undef )
|
add_definitions(-Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn -Wno-exit-time-destructors -Wno-documentation-unknown-command -Wno-unused-template -Wno-undef )
|
||||||
|
|||||||
@ -179,6 +179,7 @@ namespace chaiscript
|
|||||||
return t != u;
|
return t != u;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,20 +255,9 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static auto const_unary_int_go(Operators::Opers t_oper, const T &t) noexcept
|
|
||||||
{
|
|
||||||
switch (t_oper)
|
|
||||||
{
|
|
||||||
case Operators::Opers::bitwise_complement:
|
|
||||||
return ~t;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static auto const_binary_int_go(Operators::Opers t_oper, const T &t, const T &u)
|
static auto const_binary_int_go(Operators::Opers t_oper, T t, T u)
|
||||||
noexcept(noexcept(check_divide_by_zero(u)))
|
noexcept(noexcept(check_divide_by_zero(u)))
|
||||||
{
|
{
|
||||||
switch (t_oper)
|
switch (t_oper)
|
||||||
@ -287,11 +277,12 @@ namespace chaiscript
|
|||||||
return t ^ u;
|
return t ^ u;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
return static_cast<decltype(t ^ u)>(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static auto const_unary_go(Operators::Opers t_oper, const T &t) noexcept
|
static auto const_unary_go(Operators::Opers t_oper, T t) noexcept
|
||||||
{
|
{
|
||||||
switch (t_oper)
|
switch (t_oper)
|
||||||
{
|
{
|
||||||
@ -301,11 +292,12 @@ namespace chaiscript
|
|||||||
return +t;
|
return +t;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
return static_cast<decltype(+t)>(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static auto const_binary_go(Operators::Opers t_oper, const T &t, const T &u)
|
static auto const_binary_go(Operators::Opers t_oper, T t, T u)
|
||||||
noexcept(noexcept(check_divide_by_zero(u)))
|
noexcept(noexcept(check_divide_by_zero(u)))
|
||||||
{
|
{
|
||||||
switch (t_oper)
|
switch (t_oper)
|
||||||
@ -321,6 +313,7 @@ namespace chaiscript
|
|||||||
return t - u;
|
return t - u;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
return static_cast<decltype(t + u)>(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,8 +435,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
case Operators::Opers::bitwise_complement:
|
case Operators::Opers::bitwise_complement:
|
||||||
{
|
{
|
||||||
const auto val = const_unary_int_go(t_oper, *static_cast<const LHS *>(t_lhs.get_const_ptr()));
|
return const_var(~(*static_cast<const LHS *>(t_lhs.get_const_ptr())));
|
||||||
return const_var(val);
|
|
||||||
}
|
}
|
||||||
case Operators::Opers::unary_minus:
|
case Operators::Opers::unary_minus:
|
||||||
case Operators::Opers::unary_plus:
|
case Operators::Opers::unary_plus:
|
||||||
|
|||||||
@ -208,14 +208,14 @@ namespace chaiscript
|
|||||||
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;
|
||||||
|
|
||||||
void swap(Boxed_Value &rhs)
|
void swap(Boxed_Value &rhs) noexcept
|
||||||
{
|
{
|
||||||
std::swap(m_data, rhs.m_data);
|
std::swap(m_data, rhs.m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy the values stored in rhs.m_data to m_data.
|
/// Copy the values stored in rhs.m_data to m_data.
|
||||||
/// m_data pointers are not shared in this case
|
/// m_data pointers are not shared in this case
|
||||||
Boxed_Value assign(const Boxed_Value &rhs)
|
Boxed_Value assign(const Boxed_Value &rhs) noexcept
|
||||||
{
|
{
|
||||||
(*m_data) = (*rhs.m_data);
|
(*m_data) = (*rhs.m_data);
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@ -196,7 +196,7 @@ namespace chaiscript
|
|||||||
apply_globals(m_globals.begin(), m_globals.end(), t_engine);
|
apply_globals(m_globals.begin(), m_globals.end(), t_engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_function(const Proxy_Function &new_f, const std::string &name)
|
bool has_function(const Proxy_Function &new_f, const std::string &name) noexcept
|
||||||
{
|
{
|
||||||
return std::any_of(m_funcs.begin(), m_funcs.end(),
|
return std::any_of(m_funcs.begin(), m_funcs.end(),
|
||||||
[&](const std::pair<Proxy_Function, std::string> &existing_f) {
|
[&](const std::pair<Proxy_Function, std::string> &existing_f) {
|
||||||
@ -276,7 +276,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const dispatch::Proxy_Function_Base &rhs) const override
|
bool operator==(const dispatch::Proxy_Function_Base &rhs) const noexcept override
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs);
|
const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs);
|
||||||
@ -820,7 +820,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
|
|
||||||
/// Return true if a function exists
|
/// Return true if a function exists
|
||||||
bool function_exists(const std::string &name) const noexcept
|
bool function_exists(const std::string &name) const
|
||||||
{
|
{
|
||||||
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
|
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ namespace chaiscript
|
|||||||
m_option_explicit = t_explicit;
|
m_option_explicit = t_explicit;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_type_name() const
|
const std::string &get_type_name() const noexcept
|
||||||
{
|
{
|
||||||
return m_type_name;
|
return m_type_name;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const override
|
bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const noexcept 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename P>
|
template<typename P>
|
||||||
static Boxed_Value box(Boxed_Value bv)
|
static Boxed_Value box(Boxed_Value bv) noexcept
|
||||||
{
|
{
|
||||||
return bv;
|
return bv;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -199,7 +199,7 @@ namespace chaiscript
|
|||||||
template<>
|
template<>
|
||||||
struct Handle_Return<Boxed_Value>
|
struct Handle_Return<Boxed_Value>
|
||||||
{
|
{
|
||||||
static Boxed_Value handle(const Boxed_Value &r)
|
static Boxed_Value handle(const Boxed_Value &r) noexcept
|
||||||
{
|
{
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ namespace chaiscript
|
|||||||
template<>
|
template<>
|
||||||
struct Handle_Return<Boxed_Number>
|
struct Handle_Return<Boxed_Number>
|
||||||
{
|
{
|
||||||
static Boxed_Value handle(const Boxed_Number &r)
|
static Boxed_Value handle(const Boxed_Number &r) noexcept
|
||||||
{
|
{
|
||||||
return r.bv;
|
return r.bv;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -460,7 +460,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return *itr;
|
return *itr;
|
||||||
} else {
|
} else {
|
||||||
throw std::out_of_range("No such conversion exists from " + from.bare_name() + " to " + to.bare_name());
|
throw std::out_of_range(std::string("No such conversion exists from ") + from.bare_name() + " to " + to.bare_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ namespace chaiscript
|
|||||||
bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
|
bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
|
||||||
bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||||
|
|
||||||
std::string name() const
|
const char * name() const noexcept
|
||||||
{
|
{
|
||||||
if (!is_undef())
|
if (!is_undef())
|
||||||
{
|
{
|
||||||
@ -100,7 +100,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bare_name() const
|
const char * bare_name() const noexcept
|
||||||
{
|
{
|
||||||
if (!is_undef())
|
if (!is_undef())
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user