Update of /cvsroot/luabind/luabind/luabind/luabind/detail
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24965/luabind/detail
Modified Files:
Tag: beta7-devel2
policy.hpp property.hpp
Log Message:
properties now make the returned reference keep the object alive using the dependency policy
Index: property.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/property.hpp,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -u -d -r1.11.2.1 -r1.11.2.2
--- property.hpp 24 Oct 2005 09:44:00 -0000 1.11.2.1
+++ property.hpp 26 Oct 2005 16:10:26 -0000 1.11.2.2
@@ -27,6 +27,7 @@
#include <luabind/config.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/mpl/eval_if.hpp>
+#include <luabind/dependency_policy.hpp>
namespace luabind { namespace detail
{
@@ -204,13 +205,19 @@
typedef typename find_conversion_policy<0,Policies>::type converter_policy;
typedef typename converter_policy::template generate_converter<D,cpp_to_lua>::type converter1_t;
+
+ // if the converter is a valua converer, return a reference instead
typedef typename boost::mpl::eval_if<
typename converter1_t::is_value_converter
, make_reference_converter<converter_policy, D>
, converter1_t>::type converter2_t;
- // TODO: If this yields a reference converter, return_internal_reference policy
- // should be automatically added
+ // If this yields a reference converter, the dependency policy
+ // is automatically added
+ typedef typename boost::mpl::if_<
+ typename converter1_t::is_value_converter
+ , policy_cons<dependency_policy<1, 0>, Policies>
+ , Policies>::type policy_list;
converter2_t converter;
converter.apply(L, ptr->*member);
@@ -219,7 +226,7 @@
const int indices[] = { 1, nargs + nret };
- policy_list_postcall<Policies>::apply(L, indices);
+ policy_list_postcall<policy_list>::apply(L, indices);
return nret;
}
Index: policy.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/policy.hpp,v
retrieving revision 1.50.2.9
retrieving revision 1.50.2.10
diff -u -d -r1.50.2.9 -r1.50.2.10
--- policy.hpp 25 Oct 2005 22:57:47 -0000 1.50.2.9
+++ policy.hpp 26 Oct 2005 16:10:26 -0000 1.50.2.10
@@ -445,6 +445,7 @@
template<>
struct user_defined_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef user_defined_converter type;
template<class T>
|