Skip to content

Commit

Permalink
Make override a #define for gcc 4.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed May 10, 2014
1 parent ee17a18 commit f29af46
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 107 deletions.
9 changes: 8 additions & 1 deletion include/chaiscript/chaiscript_defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
#define CHAISCRIPT_WINDOWS
#endif

#if defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/// Currently only g++>=4.8supports this natively
/// \todo Make this support other compilers when possible
#define CHAISCRIPT_HAS_THREAD_LOCAL
#endif

#if (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(CHAISCRIPT_MSVC) || defined(__llvm__)
#define CHAISCRIPT_OVERRIDE override
#else
#define CHAISCRIPT_OVERRIDE
#endif


#ifdef CHAISCRIPT_HAS_DECLSPEC
#define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport)
#else
Expand Down
8 changes: 4 additions & 4 deletions include/chaiscript/dispatchkit/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace chaiscript {
virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {}

/// \brief Description of what error occured
virtual const char * what() const CHAISCRIPT_NOEXCEPT override
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
{
return m_what.c_str();
}
Expand Down Expand Up @@ -61,17 +61,17 @@ namespace chaiscript {

virtual ~Data_Impl() {}

virtual void *data() override
virtual void *data() CHAISCRIPT_OVERRIDE
{
return &m_data;
}

const std::type_info &type() const override
const std::type_info &type() const CHAISCRIPT_OVERRIDE
{
return m_type;
}

std::shared_ptr<Data> clone() const override
std::shared_ptr<Data> clone() const CHAISCRIPT_OVERRIDE
{
return std::shared_ptr<Data>(new Data_Impl<T>(m_data));
}
Expand Down
2 changes: 1 addition & 1 deletion include/chaiscript/dispatchkit/bad_boxed_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace chaiscript
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {}

/// \brief Description of what error occured
virtual const char * what() const CHAISCRIPT_NOEXCEPT override
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
{
return m_what.c_str();
}
Expand Down
12 changes: 6 additions & 6 deletions include/chaiscript/dispatchkit/dispatchkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace chaiscript
{
}

virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const override
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
{
try {
const Dispatch_Function &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs);
Expand All @@ -264,13 +264,13 @@ namespace chaiscript

virtual ~Dispatch_Function() {}

virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
{
return std::vector<Const_Proxy_Function>(m_funcs.begin(), m_funcs.end());
}


virtual int get_arity() const override
virtual int get_arity() const CHAISCRIPT_OVERRIDE
{
typedef std::vector<Proxy_Function> function_vec;

Expand Down Expand Up @@ -300,7 +300,7 @@ namespace chaiscript
return -1; // unknown arity
}

virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const override
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
auto begin = m_funcs.begin();
auto end = m_funcs.end();
Expand All @@ -318,13 +318,13 @@ namespace chaiscript
return false;
}

virtual std::string annotation() const override
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{
return "Multiple method dispatch function wrapper.";
}

protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const override
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
return dispatch::dispatch(m_funcs.begin(), m_funcs.end(), params, t_conversions);
}
Expand Down
4 changes: 2 additions & 2 deletions include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ namespace chaiscript
{
}

virtual Boxed_Value convert_down(const Boxed_Value &t_base) const override
virtual Boxed_Value convert_down(const Boxed_Value &t_base) const CHAISCRIPT_OVERRIDE
{
return Dynamic_Caster<Base, Derived>::cast(t_base);
}

virtual Boxed_Value convert(const Boxed_Value &t_derived) const override
virtual Boxed_Value convert(const Boxed_Value &t_derived) const CHAISCRIPT_OVERRIDE
{
return Dynamic_Caster<Derived, Base>::cast(t_derived);
}
Expand Down
24 changes: 12 additions & 12 deletions include/chaiscript/dispatchkit/dynamic_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace chaiscript

Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;

virtual bool operator==(const Proxy_Function_Base &f) const override
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
{
const Dynamic_Object_Function *df = dynamic_cast<const Dynamic_Object_Function *>(&f);
if (df)
Expand All @@ -89,7 +89,7 @@ namespace chaiscript
}
}

virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const override
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
{
Expand All @@ -99,25 +99,25 @@ namespace chaiscript
}
}

virtual std::vector<Const_Proxy_Function> get_contained_functions() const override
virtual std::vector<Const_Proxy_Function> get_contained_functions() const CHAISCRIPT_OVERRIDE
{
return {m_func};
}


virtual int get_arity() const override
virtual int get_arity() const CHAISCRIPT_OVERRIDE
{
return m_func->get_arity();
}

virtual std::string annotation() const override
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{
return m_func->annotation();
}


protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const override
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions))
{
Expand All @@ -127,7 +127,7 @@ namespace chaiscript
}
}

virtual bool compare_first_type(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions) const override
virtual bool compare_first_type(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ namespace chaiscript

virtual ~Dynamic_Object_Constructor() {}

virtual bool operator==(const Proxy_Function_Base &f) const override
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
{
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
if (dc)
Expand All @@ -231,7 +231,7 @@ namespace chaiscript
}
}

virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const override
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
std::vector<Boxed_Value> new_vals;
new_vals.push_back(Boxed_Value(Dynamic_Object(m_type_name)));
Expand All @@ -241,19 +241,19 @@ namespace chaiscript
}


virtual int get_arity() const override
virtual int get_arity() const CHAISCRIPT_OVERRIDE
{
// "this" is not considered part of the arity
return m_func->get_arity() - 1;
}

virtual std::string annotation() const override
virtual std::string annotation() const CHAISCRIPT_OVERRIDE
{
return m_func->annotation();
}

protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const override
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
std::vector<Boxed_Value> new_params;
chaiscript::Boxed_Value bv = var(Dynamic_Object(m_type_name));
Expand Down
10 changes: 5 additions & 5 deletions include/chaiscript/dispatchkit/exception_specification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace chaiscript
{
virtual ~Exception_Handler_Impl1() {}

virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{
throw_type<T1>(bv, t_engine);
}
Expand All @@ -42,7 +42,7 @@ namespace chaiscript
{
virtual ~Exception_Handler_Impl2() {}

virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{
throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine);
Expand All @@ -54,7 +54,7 @@ namespace chaiscript
{
virtual ~Exception_Handler_Impl3() {}

virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{
throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine);
Expand All @@ -66,7 +66,7 @@ namespace chaiscript
{
virtual ~Exception_Handler_Impl4() {}

virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{
throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine);
Expand All @@ -79,7 +79,7 @@ namespace chaiscript
{
virtual ~Exception_Handler_Impl5() {}

virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) override
virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) CHAISCRIPT_OVERRIDE
{
throw_type<T1>(bv, t_engine);
throw_type<T2>(bv, t_engine);
Expand Down
Loading

1 comment on commit f29af46

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.