Address some of the issues found by cppcheck

This commit is contained in:
Jason Turner
2014-03-26 16:59:41 -06:00
parent 296769ee24
commit 65b0846e41
8 changed files with 19 additions and 25 deletions

View File

@@ -308,12 +308,6 @@ namespace chaiscript
static void throw_exception(const Boxed_Value &bv) {
throw bv;
}
static boost::shared_ptr<chaiscript::detail::Dispatch_Engine> bootstrap2(boost::shared_ptr<chaiscript::detail::Dispatch_Engine> e = boost::shared_ptr<chaiscript::detail::Dispatch_Engine> (new chaiscript::detail::Dispatch_Engine()))
{
e->add(user_type<void>(), "void");
return e;
}
static std::string what(const std::exception &e)
{

View File

@@ -307,7 +307,7 @@ namespace chaiscript
}
template<typename Source>
std::string to_string_aux(const Boxed_Value &v) const
static std::string to_string_aux(const Boxed_Value &v)
{
std::ostringstream oss;
oss << *static_cast<const Source *>(v.get_const_ptr());
@@ -520,7 +520,7 @@ namespace chaiscript
return oper(Operators::assign_bitwise_and, this->bv, t_rhs.bv);
}
void validate_boxed_number(const Boxed_Value &v)
static void validate_boxed_number(const Boxed_Value &v)
{
const Type_Info &inp_ = v.get_type_info();
if (inp_ == typeid(bool))

View File

@@ -50,11 +50,11 @@ namespace chaiscript
virtual Boxed_Value convert(const Boxed_Value &derived) const = 0;
virtual Boxed_Value convert_down(const Boxed_Value &base) const = 0;
const Type_Info &base()
const Type_Info &base() const
{
return m_base;
}
const Type_Info &derived()
const Type_Info &derived() const
{
return m_derived;
}

View File

@@ -31,7 +31,7 @@ namespace chaiscript
return m_attrs[t_attr_name];
}
std::map<std::string, Boxed_Value> get_attrs()
std::map<std::string, Boxed_Value> get_attrs() const
{
return m_attrs;
}

View File

@@ -23,7 +23,7 @@ namespace chaiscript
class Boxed_Number;
struct AST_Node;
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
typedef boost::shared_ptr<AST_Node> AST_NodePtr;
namespace dispatch
{

View File

@@ -54,7 +54,7 @@ namespace chaiscript
};
/// \brief Typedef for pointers to AST_Node objects. Used in building of the AST_Node tree
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
typedef boost::shared_ptr<AST_Node> AST_NodePtr;
/// \brief Classes which may be thrown during error cases when ChaiScript is executing.
@@ -435,7 +435,7 @@ namespace chaiscript
return eval_internal(t_e);
} catch (exception::eval_error &ee) {
ee.call_stack.push_back(shared_from_this());
throw ee;
throw;
}
}

View File

@@ -681,7 +681,7 @@ namespace chaiscript
if (t_handler) {
t_handler->handle(bv, m_engine);
}
throw bv;
throw;
}
}
@@ -707,7 +707,7 @@ namespace chaiscript
if (t_handler) {
t_handler->handle(bv, m_engine);
}
throw bv;
throw;
}
}
@@ -737,7 +737,7 @@ namespace chaiscript
if (t_handler) {
t_handler->handle(bv, m_engine);
}
throw bv;
throw;
}
}
@@ -753,7 +753,7 @@ namespace chaiscript
if (t_handler) {
t_handler->handle(bv, m_engine);
}
throw bv;
throw;
}
}
@@ -773,7 +773,7 @@ namespace chaiscript
if (t_handler) {
t_handler->handle(bv, m_engine);
}
throw bv;
throw;
}
}
};

View File

@@ -56,7 +56,8 @@ namespace chaiscript
public:
ChaiScript_Parser()
: m_multiline_comment_begin("/*"),
: m_line(-1), m_col(-1),
m_multiline_comment_begin("/*"),
m_multiline_comment_end("*/"),
m_singleline_comment("//")
{
@@ -804,10 +805,9 @@ namespace chaiscript
*/
bool Quoted_String_() {
bool retval = false;
char prev_char = 0;
if (has_more_input() && (*m_input_pos == '\"')) {
retval = true;
prev_char = *m_input_pos;
char prev_char = *m_input_pos;
++m_input_pos;
++m_col;
@@ -981,10 +981,9 @@ namespace chaiscript
*/
bool Single_Quoted_String_() {
bool retval = false;
char prev_char = 0;
if (has_more_input() && (*m_input_pos == '\'')) {
retval = true;
prev_char = *m_input_pos;
char prev_char = *m_input_pos;
++m_input_pos;
++m_col;
@@ -1350,7 +1349,6 @@ namespace chaiscript
bool Def() {
bool retval = false;
bool is_annotated = false;
bool is_method = false;
AST_NodePtr annotation;
if (Annotation()) {
@@ -1369,6 +1367,8 @@ namespace chaiscript
throw exception::eval_error("Missing function name in definition", File_Position(m_line, m_col), *m_filename);
}
bool is_method = false;
if (Symbol("::", false)) {
//We're now a method
is_method = true;