Fix issues found with cppcheck inconclusive
This commit is contained in:
@@ -21,5 +21,5 @@ compilers:
|
|||||||
skip_packaging: true
|
skip_packaging: true
|
||||||
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
|
cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON
|
||||||
- name: cppcheck
|
- name: cppcheck
|
||||||
compiler_extra_flags: --enable=all -I include --inline-suppr
|
compiler_extra_flags: --enable=all -I include --inline-suppr -Umax --suppress="*:cmake*"
|
||||||
|
|
||||||
|
@@ -82,16 +82,27 @@ namespace chaiscript
|
|||||||
t().erase(m_key);
|
t().erase(m_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T *operator->() const
|
inline const T *operator->() const
|
||||||
{
|
{
|
||||||
return &(t()[m_key]);
|
return &(t()[m_key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T &operator*() const
|
inline const T &operator*() const
|
||||||
{
|
{
|
||||||
return t()[m_key];
|
return t()[m_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline T *operator->()
|
||||||
|
{
|
||||||
|
return &(t()[m_key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T &operator*()
|
||||||
|
{
|
||||||
|
return t()[m_key];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void *m_key;
|
void *m_key;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -117,12 +128,22 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T *operator->() const
|
inline const T *operator->() const
|
||||||
{
|
{
|
||||||
return get_tls().get();
|
return get_tls().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T &operator*() const
|
inline const T &operator*() const
|
||||||
|
{
|
||||||
|
return *get_tls();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T *operator->()
|
||||||
|
{
|
||||||
|
return get_tls().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T &operator*()
|
||||||
{
|
{
|
||||||
return *get_tls();
|
return *get_tls();
|
||||||
}
|
}
|
||||||
|
@@ -246,6 +246,7 @@ namespace chaiscript
|
|||||||
template<typename ContainerType>
|
template<typename ContainerType>
|
||||||
ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
|
ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
|
||||||
{
|
{
|
||||||
|
// cppcheck-suppress syntaxError
|
||||||
typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);
|
typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);
|
||||||
typedef typename ContainerType::const_reference(ContainerType::*constindexoper)(size_t) const;
|
typedef typename ContainerType::const_reference(ContainerType::*constindexoper)(size_t) const;
|
||||||
|
|
||||||
|
@@ -560,6 +560,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress operatorEq
|
||||||
Boxed_Number operator=(const Boxed_Value &v)
|
Boxed_Number operator=(const Boxed_Value &v)
|
||||||
{
|
{
|
||||||
validate_boxed_number(v);
|
validate_boxed_number(v);
|
||||||
@@ -567,6 +568,7 @@ namespace chaiscript
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress operatorEq
|
||||||
Boxed_Number operator=(const Boxed_Number &t_rhs) const
|
Boxed_Number operator=(const Boxed_Number &t_rhs) const
|
||||||
{
|
{
|
||||||
return oper(Operators::assign, this->bv, t_rhs.bv);
|
return oper(Operators::assign, this->bv, t_rhs.bv);
|
||||||
|
@@ -454,7 +454,7 @@ namespace chaiscript
|
|||||||
/// Adds a named object to the current scope
|
/// Adds a named object to the current scope
|
||||||
/// \warning This version does not check the validity of the name
|
/// \warning This version does not check the validity of the name
|
||||||
/// it is meant for internal use only
|
/// it is meant for internal use only
|
||||||
void add_object(const std::string &name, const Boxed_Value &obj) const
|
void add_object(const std::string &name, const Boxed_Value &obj)
|
||||||
{
|
{
|
||||||
if (!get_stack_data().back().insert(std::make_pair(name, obj)).second)
|
if (!get_stack_data().back().insert(std::make_pair(name, obj)).second)
|
||||||
{
|
{
|
||||||
@@ -704,10 +704,10 @@ namespace chaiscript
|
|||||||
///
|
///
|
||||||
std::map<std::string, Boxed_Value> get_scripting_objects() const
|
std::map<std::string, Boxed_Value> get_scripting_objects() const
|
||||||
{
|
{
|
||||||
Stack_Holder &s = *m_stack_holder;
|
const Stack_Holder &s = *m_stack_holder;
|
||||||
|
|
||||||
// We don't want the current context, but one up if it exists
|
// We don't want the current context, but one up if it exists
|
||||||
StackData &stack = (s.stacks.size()==1)?(s.stacks.back()):(s.stacks[s.stacks.size()-2]);
|
const StackData &stack = (s.stacks.size()==1)?(s.stacks.back()):(s.stacks[s.stacks.size()-2]);
|
||||||
|
|
||||||
std::map<std::string, Boxed_Value> retval;
|
std::map<std::string, Boxed_Value> retval;
|
||||||
|
|
||||||
@@ -974,7 +974,12 @@ namespace chaiscript
|
|||||||
private:
|
private:
|
||||||
/// Returns the current stack
|
/// Returns the current stack
|
||||||
/// make const/non const versions
|
/// make const/non const versions
|
||||||
StackData &get_stack_data() const
|
const StackData &get_stack_data() const
|
||||||
|
{
|
||||||
|
return m_stack_holder->stacks.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
StackData &get_stack_data()
|
||||||
{
|
{
|
||||||
return m_stack_holder->stacks.back();
|
return m_stack_holder->stacks.back();
|
||||||
}
|
}
|
||||||
|
@@ -217,14 +217,20 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
|
|
||||||
Type_Conversions()
|
Type_Conversions()
|
||||||
: m_num_types(0),
|
: m_mutex(),
|
||||||
|
m_conversions(),
|
||||||
|
m_convertableTypes(),
|
||||||
|
m_num_types(0),
|
||||||
m_thread_cache(this),
|
m_thread_cache(this),
|
||||||
m_conversion_saves(this)
|
m_conversion_saves(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Type_Conversions(const Type_Conversions &t_other)
|
Type_Conversions(const Type_Conversions &t_other)
|
||||||
: m_conversions(t_other.get_conversions()), m_num_types(m_conversions.size()),
|
: m_mutex(),
|
||||||
|
m_conversions(t_other.get_conversions()),
|
||||||
|
m_convertableTypes(),
|
||||||
|
m_num_types(m_conversions.size()),
|
||||||
m_thread_cache(this),
|
m_thread_cache(this),
|
||||||
m_conversion_saves(this)
|
m_conversion_saves(this)
|
||||||
|
|
||||||
@@ -370,8 +376,8 @@ namespace chaiscript
|
|||||||
std::set<std::shared_ptr<detail::Type_Conversion_Base>> m_conversions;
|
std::set<std::shared_ptr<detail::Type_Conversion_Base>> m_conversions;
|
||||||
std::set<const std::type_info *, Less_Than> m_convertableTypes;
|
std::set<const std::type_info *, Less_Than> m_convertableTypes;
|
||||||
std::atomic_size_t m_num_types;
|
std::atomic_size_t m_num_types;
|
||||||
chaiscript::detail::threading::Thread_Storage<std::set<const std::type_info *, Less_Than>> m_thread_cache;
|
mutable chaiscript::detail::threading::Thread_Storage<std::set<const std::type_info *, Less_Than>> m_thread_cache;
|
||||||
chaiscript::detail::threading::Thread_Storage<Conversion_Saves> m_conversion_saves;
|
mutable chaiscript::detail::threading::Thread_Storage<Conversion_Saves> m_conversion_saves;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<chaiscript::detail::Type_Conversion_Base> Type_Conversion;
|
typedef std::shared_ptr<chaiscript::detail::Type_Conversion_Base> Type_Conversion;
|
||||||
|
@@ -370,10 +370,10 @@ namespace chaiscript
|
|||||||
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
|
m_engine.add(fun(&ChaiScript::internal_eval, this), "eval");
|
||||||
m_engine.add(fun(&ChaiScript::internal_eval_ast, this), "eval");
|
m_engine.add(fun(&ChaiScript::internal_eval_ast, this), "eval");
|
||||||
|
|
||||||
m_engine.add(fun(&ChaiScript::version_major, this), "version_major");
|
m_engine.add(fun(&ChaiScript::version_major), "version_major");
|
||||||
m_engine.add(fun(&ChaiScript::version_minor, this), "version_minor");
|
m_engine.add(fun(&ChaiScript::version_minor), "version_minor");
|
||||||
m_engine.add(fun(&ChaiScript::version_patch, this), "version_patch");
|
m_engine.add(fun(&ChaiScript::version_patch), "version_patch");
|
||||||
m_engine.add(fun(&ChaiScript::version, this), "version");
|
m_engine.add(fun(&ChaiScript::version), "version");
|
||||||
|
|
||||||
m_engine.add(fun(&ChaiScript::add_global_const, this), "add_global_const");
|
m_engine.add(fun(&ChaiScript::add_global_const, this), "add_global_const");
|
||||||
m_engine.add(fun(&ChaiScript::add_global, this), "add_global");
|
m_engine.add(fun(&ChaiScript::add_global, this), "add_global");
|
||||||
@@ -490,22 +490,22 @@ namespace chaiscript
|
|||||||
build_eval_system(ModulePtr());
|
build_eval_system(ModulePtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
int version_major() const
|
static int version_major()
|
||||||
{
|
{
|
||||||
return chaiscript::version_major;
|
return chaiscript::version_major;
|
||||||
}
|
}
|
||||||
|
|
||||||
int version_minor() const
|
static int version_minor()
|
||||||
{
|
{
|
||||||
return chaiscript::version_minor;
|
return chaiscript::version_minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int version_patch() const
|
static int version_patch()
|
||||||
{
|
{
|
||||||
return chaiscript::version_patch;
|
return chaiscript::version_patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string version() const
|
static std::string version()
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << version_major() << "." << version_minor() << "." << version_patch();
|
ss << version_major() << "." << version_minor() << "." << version_patch();
|
||||||
@@ -604,7 +604,7 @@ namespace chaiscript
|
|||||||
/// chaiscript::ChaiScript chai;
|
/// chaiscript::ChaiScript chai;
|
||||||
/// chaiscript::ChaiScript::State s = chai.get_state(); // represents bootstrapped initial state
|
/// chaiscript::ChaiScript::State s = chai.get_state(); // represents bootstrapped initial state
|
||||||
/// \endcode
|
/// \endcode
|
||||||
State get_state()
|
State get_state() const
|
||||||
{
|
{
|
||||||
chaiscript::detail::threading::lock_guard<chaiscript::detail::threading::recursive_mutex> l(m_use_mutex);
|
chaiscript::detail::threading::lock_guard<chaiscript::detail::threading::recursive_mutex> l(m_use_mutex);
|
||||||
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l2(m_mutex);
|
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l2(m_mutex);
|
||||||
|
@@ -20,10 +20,11 @@ struct Vector2
|
|||||||
return Vector2(*this += vec_r);
|
return Vector2(*this += vec_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator=(const Vector2& ver_r)
|
Vector2 &operator=(const Vector2& ver_r)
|
||||||
{
|
{
|
||||||
x = ver_r.x;
|
x = ver_r.x;
|
||||||
y = ver_r.y;
|
y = ver_r.y;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user