mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-02-09 11:16:48 +08:00
Various noexcept additions
This commit is contained in:
parent
e1cf8b9eb1
commit
5d56051532
@ -102,7 +102,9 @@ namespace chaiscript
|
|||||||
void *m_key;
|
void *m_key;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unordered_map<const void*, T> &t()
|
/// todo: is it valid to make this noexcept? The allocation could fail, but if it
|
||||||
|
/// does there is no possible way to recover
|
||||||
|
static std::unordered_map<const void*, T> &t() noexcept
|
||||||
{
|
{
|
||||||
thread_local std::unordered_map<const void *, T> my_t;
|
thread_local std::unordered_map<const void *, T> my_t;
|
||||||
return my_t;
|
return my_t;
|
||||||
|
|||||||
@ -212,7 +212,7 @@ namespace chaiscript
|
|||||||
/// \returns the types of all parameters.
|
/// \returns the types of all parameters.
|
||||||
const std::vector<Type_Info> &get_param_types() const noexcept { return m_types; }
|
const std::vector<Type_Info> &get_param_types() const noexcept { return m_types; }
|
||||||
|
|
||||||
virtual bool operator==(const Proxy_Function_Base &) const = 0;
|
virtual bool operator==(const Proxy_Function_Base &) const noexcept = 0;
|
||||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const = 0;
|
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const = 0;
|
||||||
|
|
||||||
virtual bool is_attribute_function() const noexcept { return false; }
|
virtual bool is_attribute_function() const noexcept { return false; }
|
||||||
@ -268,8 +268,9 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const
|
virtual bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const noexcept
|
||||||
{
|
{
|
||||||
|
/// TODO is m_types guaranteed to be at least 2??
|
||||||
return compare_type_to_param(m_types[1], bv, t_conversions);
|
return compare_type_to_param(m_types[1], bv, t_conversions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +380,7 @@ namespace chaiscript
|
|||||||
return bool(m_guard);
|
return bool(m_guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
Proxy_Function get_guard() const
|
Proxy_Function get_guard() const noexcept
|
||||||
{
|
{
|
||||||
return m_guard;
|
return m_guard;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -371,18 +371,18 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool convertable_type() const
|
bool convertable_type() const noexcept
|
||||||
{
|
{
|
||||||
return thread_cache().count(user_type<T>().bare_type_info()) != 0;
|
return thread_cache().count(user_type<T>().bare_type_info()) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename To, typename From>
|
template<typename To, typename From>
|
||||||
bool converts() const
|
bool converts() const noexcept
|
||||||
{
|
{
|
||||||
return converts(user_type<To>(), user_type<From>());
|
return converts(user_type<To>(), user_type<From>());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool converts(const Type_Info &to, const Type_Info &from) const
|
bool converts(const Type_Info &to, const Type_Info &from) const noexcept
|
||||||
{
|
{
|
||||||
const auto &types = thread_cache();
|
const auto &types = thread_cache();
|
||||||
if (types.count(to.bare_type_info()) != 0 && types.count(from.bare_type_info()) != 0)
|
if (types.count(to.bare_type_info()) != 0 && types.count(from.bare_type_info()) != 0)
|
||||||
@ -464,7 +464,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Conversion_Saves &conversion_saves() const {
|
Conversion_Saves &conversion_saves() const noexcept {
|
||||||
return *m_conversion_saves;
|
return *m_conversion_saves;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,15 +519,15 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type_Conversions *operator->() const {
|
const Type_Conversions *operator->() const noexcept {
|
||||||
return &m_conversions.get();
|
return &m_conversions.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type_Conversions *get() const {
|
const Type_Conversions *get() const noexcept {
|
||||||
return &m_conversions.get();
|
return &m_conversions.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Type_Conversions::Conversion_Saves &saves() const {
|
Type_Conversions::Conversion_Saves &saves() const noexcept {
|
||||||
return m_saves;
|
return m_saves;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace chaiscript
|
|||||||
invalid
|
invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *to_string(Opers t_oper) {
|
static const char *to_string(Opers t_oper) noexcept {
|
||||||
static const char *opers[] = {
|
static const char *opers[] = {
|
||||||
"",
|
"",
|
||||||
"==", "<", ">", "<=", ">=", "!=",
|
"==", "<", ">", "<=", ">=", "!=",
|
||||||
|
|||||||
@ -31,16 +31,18 @@ struct AST_Node;
|
|||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
struct Name_Validator {
|
struct Name_Validator {
|
||||||
static bool is_reserved_word(const std::string &name)
|
static bool is_reserved_word(const std::string &name) noexcept
|
||||||
{
|
{
|
||||||
static const std::set<std::string> m_reserved_words
|
static const char *m_reserved_words[]
|
||||||
= {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto",
|
= {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto",
|
||||||
"return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_",
|
"return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_",
|
||||||
"__LINE__", "__FILE__", "__FUNC__", "__CLASS__"};
|
"__LINE__", "__FILE__", "__FUNC__", "__CLASS__"};
|
||||||
return m_reserved_words.count(name) > 0;
|
|
||||||
|
return std::any_of(std::begin(m_reserved_words), std::end(m_reserved_words),
|
||||||
|
[&name](const char *str){ return str == name; });
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool valid_object_name(const std::string &name)
|
static bool valid_object_name(const std::string &name) noexcept
|
||||||
{
|
{
|
||||||
return name.find("::") == std::string::npos && !is_reserved_word(name);
|
return name.find("::") == std::string::npos && !is_reserved_word(name);
|
||||||
}
|
}
|
||||||
@ -136,7 +138,7 @@ 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
|
||||||
{
|
{
|
||||||
explicit load_module_error(const std::string &t_reason) noexcept
|
explicit load_module_error(const std::string &t_reason)
|
||||||
: std::runtime_error(t_reason)
|
: std::runtime_error(t_reason)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -479,7 +481,7 @@ 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 {
|
||||||
explicit file_not_found_error(const std::string &t_filename) noexcept
|
explicit file_not_found_error(const std::string &t_filename)
|
||||||
: std::runtime_error("File Not Found: " + t_filename)
|
: std::runtime_error("File Not Found: " + t_filename)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|||||||
@ -741,7 +741,7 @@ namespace chaiscript
|
|||||||
return std::move(vec.back());
|
return std::move(vec.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool has_guard(const std::vector<AST_Node_Impl_Ptr<T>> &t_children, const std::size_t offset)
|
static bool has_guard(const std::vector<AST_Node_Impl_Ptr<T>> &t_children, const std::size_t offset) noexcept
|
||||||
{
|
{
|
||||||
if ((t_children.size() > 2 + offset) && (t_children[1+offset]->identifier == AST_Node_Type::Arg_List)) {
|
if ((t_children.size() > 2 + offset) && (t_children[1+offset]->identifier == AST_Node_Type::Arg_List)) {
|
||||||
if (t_children.size() > 3 + offset) {
|
if (t_children.size() > 3 + offset) {
|
||||||
|
|||||||
@ -447,3 +447,4 @@ namespace chaiscript {
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user