Amp up the warnings used in g++ and fix associated errors

This commit is contained in:
Jason Turner 2011-03-12 11:27:53 -07:00
parent 46a669dab1
commit 4e06478fb8
6 changed files with 29 additions and 29 deletions

View File

@ -61,7 +61,7 @@ IF(MSVC)
ENDIF() ENDIF()
ELSE() ELSE()
# -Wno-missing-field-initializers is for boost on macos # -Wno-missing-field-initializers is for boost on macos
ADD_DEFINITIONS(-Wall -Wextra -Wno-missing-field-initializers) ADD_DEFINITIONS(-Wall -Wextra -Wno-missing-field-initializers -Wshadow)
ENDIF() ENDIF()
include_directories(include) include_directories(include)

View File

@ -21,8 +21,8 @@ namespace chaiscript
{ {
public: public:
bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to, bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &what) throw() const std::string &t_what) throw()
: from(t_from), to(&t_to), m_what(what) : from(t_from), to(&t_to), m_what(t_what)
{ {
} }
@ -31,8 +31,8 @@ namespace chaiscript
{ {
} }
bad_boxed_cast(const std::string &w) throw() bad_boxed_cast(const std::string &t_what) throw()
: m_what(w) : m_what(t_what)
{ {
} }

View File

@ -203,14 +203,14 @@ namespace chaiscript
throw exception::bad_boxed_cast(">> only valid for integer types"); throw exception::bad_boxed_cast(">> only valid for integer types");
} }
Boxed_Value smart_size(boost::int64_t i) const Boxed_Value smart_size(boost::int64_t t_i) const
{ {
if (i < boost::integer_traits<int>::const_min if (t_i < boost::integer_traits<int>::const_min
|| i > boost::integer_traits<int>::const_max) || t_i > boost::integer_traits<int>::const_max)
{ {
return Boxed_Value(i); return Boxed_Value(t_i);
} else { } else {
return Boxed_Value(static_cast<int>(i)); return Boxed_Value(static_cast<int>(t_i));
} }
} }

View File

@ -76,17 +76,17 @@ namespace chaiscript
{ {
} }
virtual Boxed_Value convert(const Boxed_Value &derived) virtual Boxed_Value convert(const Boxed_Value &t_derived)
{ {
if (derived.get_type_info().bare_equal(user_type<Derived>())) if (t_derived.get_type_info().bare_equal(user_type<Derived>()))
{ {
if (derived.is_pointer()) if (t_derived.is_pointer())
{ {
// Dynamic cast out the contained boxed value, which we know is the type we want // Dynamic cast out the contained boxed value, which we know is the type we want
if (derived.is_const()) if (t_derived.is_const())
{ {
boost::shared_ptr<const Base> data boost::shared_ptr<const Base> data
= boost::dynamic_pointer_cast<const Base>(detail::Cast_Helper<boost::shared_ptr<const Derived> >::cast(derived)); = boost::dynamic_pointer_cast<const Base>(detail::Cast_Helper<boost::shared_ptr<const Derived> >::cast(t_derived));
if (!data) if (!data)
{ {
throw std::bad_cast(); throw std::bad_cast();
@ -95,7 +95,7 @@ namespace chaiscript
return Boxed_Value(data); return Boxed_Value(data);
} else { } else {
boost::shared_ptr<Base> data boost::shared_ptr<Base> data
= boost::dynamic_pointer_cast<Base>(detail::Cast_Helper<boost::shared_ptr<Derived> >::cast(derived)); = boost::dynamic_pointer_cast<Base>(detail::Cast_Helper<boost::shared_ptr<Derived> >::cast(t_derived));
if (!data) if (!data)
{ {
@ -106,19 +106,19 @@ namespace chaiscript
} }
} else { } else {
// Pull the reference out of the contained boxed value, which we know is the type we want // Pull the reference out of the contained boxed value, which we know is the type we want
if (derived.is_const()) if (t_derived.is_const())
{ {
const Derived &d = detail::Cast_Helper<const Derived &>::cast(derived); const Derived &d = detail::Cast_Helper<const Derived &>::cast(t_derived);
const Base &data = dynamic_cast<const Base &>(d); const Base &data = dynamic_cast<const Base &>(d);
return Boxed_Value(boost::cref(data)); return Boxed_Value(boost::cref(data));
} else { } else {
Derived &d = detail::Cast_Helper<Derived &>::cast(derived); Derived &d = detail::Cast_Helper<Derived &>::cast(t_derived);
Base &data = dynamic_cast<Base &>(d); Base &data = dynamic_cast<Base &>(d);
return Boxed_Value(boost::ref(data)); return Boxed_Value(boost::ref(data));
} }
} }
} else { } else {
throw exception::bad_boxed_dynamic_cast(derived.get_type_info(), typeid(Base), "Unknown dynamic_cast_conversion"); throw exception::bad_boxed_dynamic_cast(t_derived.get_type_info(), typeid(Base), "Unknown dynamic_cast_conversion");
} }
} }
}; };

View File

@ -69,7 +69,7 @@ namespace chaiscript
{ {
call_func(fun, params); call_func(fun, params);
return Handle_Return<void>::handle(); return Handle_Return<void>::handle();
}; }
}; };
} }
} }

View File

@ -633,13 +633,13 @@ namespace chaiscript
} }
try { try {
const std::string & function_name = this->children[0]->text; const std::string & l_function_name = this->children[0]->text;
const std::string & annotation = this->annotation?this->annotation->text:""; const std::string & l_annotation = this->annotation?this->annotation->text:"";
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
annotation, guard)), function_name); l_annotation, guard)), l_function_name);
} }
catch (reserved_word_error &e) { catch (reserved_word_error &e) {
throw Eval_Error("Reserved word used as function name '" + e.word + "'"); throw Eval_Error("Reserved word used as function name '" + e.word + "'");
@ -1069,8 +1069,8 @@ namespace chaiscript
try { try {
this->children.back()->children[0]->eval(t_ss); this->children.back()->children[0]->eval(t_ss);
} }
catch (Eval_Error &ee) { catch (Eval_Error &ee2) {
ee.call_stack.push_back(this->children.back()->children[0]); ee2.call_stack.push_back(this->children.back()->children[0]);
t_ss.pop_scope(); t_ss.pop_scope();
throw; throw;
} }
@ -1334,7 +1334,7 @@ namespace chaiscript
} }
try { try {
const std::string & annotation = this->annotation?this->annotation->text:""; const std::string & l_annotation = this->annotation?this->annotation->text:"";
const std::string & class_name = this->children[0]->text; const std::string & class_name = this->children[0]->text;
const std::string & function_name = this->children[1]->text; const std::string & function_name = this->children[1]->text;
if (function_name == class_name) { if (function_name == class_name) {
@ -1343,7 +1343,7 @@ namespace chaiscript
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
annotation, guard)))), function_name); l_annotation, guard)))), function_name);
} }
else { else {
@ -1358,7 +1358,7 @@ namespace chaiscript
(new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>, (new Dynamic_Proxy_Function(boost::bind(&eval_function<Dispatch_Engine>,
boost::ref(t_ss), this->children.back(), boost::ref(t_ss), this->children.back(),
t_param_names, _1), static_cast<int>(numparams), this->children.back(), t_param_names, _1), static_cast<int>(numparams), this->children.back(),
annotation, guard)), ti)), function_name); l_annotation, guard)), ti)), function_name);
} }
} }