Skip to content

Commit 65b0846

Browse files
committed
Address some of the issues found by cppcheck
1 parent 296769e commit 65b0846

File tree

8 files changed

+19
-25
lines changed

8 files changed

+19
-25
lines changed

include/chaiscript/dispatchkit/bootstrap.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,6 @@ namespace chaiscript
308308
static void throw_exception(const Boxed_Value &bv) {
309309
throw bv;
310310
}
311-
312-
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()))
313-
{
314-
e->add(user_type<void>(), "void");
315-
return e;
316-
}
317311

318312
static std::string what(const std::exception &e)
319313
{

include/chaiscript/dispatchkit/boxed_number.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ namespace chaiscript
307307
}
308308

309309
template<typename Source>
310-
std::string to_string_aux(const Boxed_Value &v) const
310+
static std::string to_string_aux(const Boxed_Value &v)
311311
{
312312
std::ostringstream oss;
313313
oss << *static_cast<const Source *>(v.get_const_ptr());
@@ -520,7 +520,7 @@ namespace chaiscript
520520
return oper(Operators::assign_bitwise_and, this->bv, t_rhs.bv);
521521
}
522522

523-
void validate_boxed_number(const Boxed_Value &v)
523+
static void validate_boxed_number(const Boxed_Value &v)
524524
{
525525
const Type_Info &inp_ = v.get_type_info();
526526
if (inp_ == typeid(bool))

include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ namespace chaiscript
5050
virtual Boxed_Value convert(const Boxed_Value &derived) const = 0;
5151
virtual Boxed_Value convert_down(const Boxed_Value &base) const = 0;
5252

53-
const Type_Info &base()
53+
const Type_Info &base() const
5454
{
5555
return m_base;
5656
}
57-
const Type_Info &derived()
57+
const Type_Info &derived() const
5858
{
5959
return m_derived;
6060
}

include/chaiscript/dispatchkit/dynamic_object.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace chaiscript
3131
return m_attrs[t_attr_name];
3232
}
3333

34-
std::map<std::string, Boxed_Value> get_attrs()
34+
std::map<std::string, Boxed_Value> get_attrs() const
3535
{
3636
return m_attrs;
3737
}

include/chaiscript/dispatchkit/proxy_functions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace chaiscript
2323
class Boxed_Number;
2424
struct AST_Node;
2525

26-
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
26+
typedef boost::shared_ptr<AST_Node> AST_NodePtr;
2727

2828
namespace dispatch
2929
{

include/chaiscript/language/chaiscript_common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace chaiscript
5454
};
5555

5656
/// \brief Typedef for pointers to AST_Node objects. Used in building of the AST_Node tree
57-
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
57+
typedef boost::shared_ptr<AST_Node> AST_NodePtr;
5858

5959

6060
/// \brief Classes which may be thrown during error cases when ChaiScript is executing.
@@ -435,7 +435,7 @@ namespace chaiscript
435435
return eval_internal(t_e);
436436
} catch (exception::eval_error &ee) {
437437
ee.call_stack.push_back(shared_from_this());
438-
throw ee;
438+
throw;
439439
}
440440
}
441441

include/chaiscript/language/chaiscript_engine.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ namespace chaiscript
681681
if (t_handler) {
682682
t_handler->handle(bv, m_engine);
683683
}
684-
throw bv;
684+
throw;
685685
}
686686
}
687687

@@ -707,7 +707,7 @@ namespace chaiscript
707707
if (t_handler) {
708708
t_handler->handle(bv, m_engine);
709709
}
710-
throw bv;
710+
throw;
711711
}
712712
}
713713

@@ -737,7 +737,7 @@ namespace chaiscript
737737
if (t_handler) {
738738
t_handler->handle(bv, m_engine);
739739
}
740-
throw bv;
740+
throw;
741741
}
742742
}
743743

@@ -753,7 +753,7 @@ namespace chaiscript
753753
if (t_handler) {
754754
t_handler->handle(bv, m_engine);
755755
}
756-
throw bv;
756+
throw;
757757
}
758758
}
759759

@@ -773,7 +773,7 @@ namespace chaiscript
773773
if (t_handler) {
774774
t_handler->handle(bv, m_engine);
775775
}
776-
throw bv;
776+
throw;
777777
}
778778
}
779779
};

include/chaiscript/language/chaiscript_parser.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ namespace chaiscript
5656

5757
public:
5858
ChaiScript_Parser()
59-
: m_multiline_comment_begin("/*"),
59+
: m_line(-1), m_col(-1),
60+
m_multiline_comment_begin("/*"),
6061
m_multiline_comment_end("*/"),
6162
m_singleline_comment("//")
6263
{
@@ -804,10 +805,9 @@ namespace chaiscript
804805
*/
805806
bool Quoted_String_() {
806807
bool retval = false;
807-
char prev_char = 0;
808808
if (has_more_input() && (*m_input_pos == '\"')) {
809809
retval = true;
810-
prev_char = *m_input_pos;
810+
char prev_char = *m_input_pos;
811811
++m_input_pos;
812812
++m_col;
813813

@@ -981,10 +981,9 @@ namespace chaiscript
981981
*/
982982
bool Single_Quoted_String_() {
983983
bool retval = false;
984-
char prev_char = 0;
985984
if (has_more_input() && (*m_input_pos == '\'')) {
986985
retval = true;
987-
prev_char = *m_input_pos;
986+
char prev_char = *m_input_pos;
988987
++m_input_pos;
989988
++m_col;
990989

@@ -1350,7 +1349,6 @@ namespace chaiscript
13501349
bool Def() {
13511350
bool retval = false;
13521351
bool is_annotated = false;
1353-
bool is_method = false;
13541352
AST_NodePtr annotation;
13551353

13561354
if (Annotation()) {
@@ -1369,6 +1367,8 @@ namespace chaiscript
13691367
throw exception::eval_error("Missing function name in definition", File_Position(m_line, m_col), *m_filename);
13701368
}
13711369

1370+
bool is_method = false;
1371+
13721372
if (Symbol("::", false)) {
13731373
//We're now a method
13741374
is_method = true;

0 commit comments

Comments
 (0)