From ed11f48847a0a575580b7b18a4708e6e3ed30e38 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 15 Nov 2009 00:37:01 +0000 Subject: [PATCH] More robust handling of potential class object member types --- include/chaiscript/dispatchkit/handle_return.hpp | 13 +++++++++++++ include/chaiscript/dispatchkit/proxy_functions.hpp | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/dispatchkit/handle_return.hpp b/include/chaiscript/dispatchkit/handle_return.hpp index 564d970..f1c908b 100644 --- a/include/chaiscript/dispatchkit/handle_return.hpp +++ b/include/chaiscript/dispatchkit/handle_return.hpp @@ -83,6 +83,19 @@ namespace chaiscript } }; + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return + { + static Boxed_Value handle(const Boxed_Value &r) + { + return r; + } + }; + + /** * Used internally for handling a return value from a Proxy_Function call */ diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index eb37822..516b0a1 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -442,10 +442,11 @@ namespace chaiscript if (bv.is_const()) { const Class *o = boxed_cast(bv); - return Boxed_Value( boost::ref(o->*m_attr) ); + return Handle_Return::type>::type>::handle(o->*m_attr); } else { Class *o = boxed_cast(bv); - return Boxed_Value( boost::ref(o->*m_attr) ); + return Handle_Return::type>::handle(o->*m_attr); +// return Boxed_Value( boost::ref(o->*m_attr) ); } } else { throw arity_error(params.size(), 1);