Update of /cvsroot/luabind/luabind/luabind/luabind/detail
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15879/luabind/luabind/detail
Modified Files:
call.hpp call_function.hpp call_member.hpp
call_operator_iterate.hpp class_rep.hpp construct_rep.hpp
constructor.hpp find_best_match.hpp get_signature.hpp
object_rep.hpp other.hpp overload_rep.hpp
overload_rep_base.hpp policy.hpp primitives.hpp property.hpp
signature_match.hpp stack_utils.hpp
Added Files:
has_get_pointer.hpp most_derived.hpp object_call.hpp
Removed Files:
overload_rep_impl.hpp
Log Message:
merged in changes from beta7-devel2 (tag: beta7-devel2-merge)
Index: stack_utils.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/stack_utils.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- stack_utils.hpp 7 Aug 2004 13:37:10 -0000 1.2
+++ stack_utils.hpp 28 Nov 2005 20:55:34 -0000 1.3
@@ -20,7 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
-
#ifndef LUABIND_STACK_UTILS_HPP_INCLUDED
#define LUABIND_STACK_UTILS_HPP_INCLUDED
@@ -50,3 +49,4 @@
}}
#endif // LUABIND_STACK_UTILS_HPP_INCLUDED
+
Index: get_signature.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/get_signature.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- get_signature.hpp 7 Aug 2004 13:37:10 -0000 1.17
+++ get_signature.hpp 28 Nov 2005 20:55:34 -0000 1.18
@@ -77,8 +77,8 @@
inline std::string name_of_type(by_value<const unsigned int>, lua_State*, int) { return "number"; }
inline std::string name_of_type(by_value<const unsigned long>, lua_State*, int) { return "number"; }
- template<class T>
- inline std::string name_of_type(by_value<luabind::functor<T> >, lua_State* L, long) { return "function<" + name_of_type(LUABIND_DECORATE_TYPE(T), L, 0L) + ">"; }
+// template<class T>
+// inline std::string name_of_type(by_value<luabind::functor<T> >, lua_State* L, long) { return "function<" + name_of_type(LUABIND_DECORATE_TYPE(T), L, 0L) + ">"; }
inline std::string name_of_type(by_value<std::string>, lua_State*, int) { return "string"; }
inline std::string name_of_type(by_const_pointer<char>, lua_State*, int) { return "string"; }
--- NEW FILE: object_call.hpp ---
// Copyright (c) 2005 Daniel Wallin and Arvid Norberg
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#if !BOOST_PP_IS_ITERATING
# error Do not include object_call.hpp directly!
#endif
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#define N BOOST_PP_ITERATION()
template<BOOST_PP_ENUM_PARAMS(N, class A)>
call_proxy<
Derived
, boost::tuples::tuple<
BOOST_PP_ENUM_BINARY_PARAMS(N, A, const* BOOST_PP_INTERCEPT)
>
> operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a))
{
typedef boost::tuples::tuple<
BOOST_PP_ENUM_BINARY_PARAMS(N, A, const* BOOST_PP_INTERCEPT)
> arguments;
return call_proxy<Derived, arguments>(
derived()
, arguments(BOOST_PP_ENUM_PARAMS(N, &a))
);
}
#undef N
--- NEW FILE: has_get_pointer.hpp ---
// Copyright (c) 2005 Daniel Wallin
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef LUABIND_HAS_GET_POINTER_051022_HPP
# define LUABIND_HAS_GET_POINTER_051022_HPP
# include <boost/type_traits/add_reference.hpp>
# ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
# include <memory>
# endif
namespace luabind { namespace detail {
namespace has_get_pointer_
{
struct any
{
template<class T> any(T const&);
};
struct no_overload_tag
{};
typedef char (&yes)[1];
typedef char (&no)[2];
no_overload_tag operator,(no_overload_tag, int);
//
// On compilers with ADL, we need these generic overloads in this
// namespace as well as in luabind::. Otherwise get_pointer(any)
// will be found before them.
//
# ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
template<class T>
T* get_pointer(T*);
template<class T>
T* get_pointer(std::auto_ptr<T> const&);
# endif
//
// On compilers that doesn't support ADL, the overload below has to
// live in luabind::.
//
# ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
}} // namespace detail::has_get_pointer_
# endif
detail::has_get_pointer_::no_overload_tag
get_pointer(detail::has_get_pointer_::any);
# ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace detail { namespace has_get_pointer_
{
# endif
template<class T>
yes check(T const&);
no check(no_overload_tag);
template<class T>
struct impl
{
static typename boost::add_reference<T>::type x;
BOOST_STATIC_CONSTANT(bool,
value = sizeof(has_get_pointer_::check( (get_pointer(x),0) )) == 1
);
typedef boost::mpl::bool_<value> type;
};
} // namespace has_get_pointer_
template<class T>
struct has_get_pointer
: has_get_pointer_::impl<T>::type
{};
}} // namespace luabind::detail
#endif // LUABIND_HAS_GET_POINTER_051022_HPP
Index: construct_rep.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/construct_rep.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- construct_rep.hpp 7 Aug 2004 13:37:10 -0000 1.6
+++ construct_rep.hpp 28 Nov 2005 20:55:34 -0000 1.7
@@ -33,7 +33,7 @@
#include <boost/function/function1.hpp>
#include <boost/function/function2.hpp>
-#include <luabind/detail/signature_match.hpp>
+//#include <luabind/detail/signature_match.hpp>
#include <luabind/detail/overload_rep_base.hpp>
#include <luabind/weak_ref.hpp>
Index: signature_match.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/signature_match.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- signature_match.hpp 7 Aug 2004 13:37:10 -0000 1.3
+++ signature_match.hpp 28 Nov 2005 20:55:34 -0000 1.4
@@ -44,10 +44,11 @@
#include <boost/mpl/int.hpp>
#include <boost/type_traits.hpp>
+#include <luabind/detail/policy.hpp>
#include <luabind/detail/primitives.hpp>
#include <luabind/detail/object_rep.hpp>
#include <luabind/detail/class_rep.hpp>
-#include <luabind/detail/policy.hpp>
+#include <luabind/detail/most_derived.hpp>
namespace luabind
{
@@ -189,7 +190,7 @@
, Policies const*)
{
typedef constructor<
- T&
+ BOOST_DEDUCED_TYPENAME most_derived<T,WrappedClass>::type&
BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
> params_t;
@@ -213,7 +214,7 @@
, Policies const* policies)
{
typedef constructor<
- T const&
+ BOOST_DEDUCED_TYPENAME most_derived<T,WrappedClass>::type const&
BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
> params_t;
return match_params(
@@ -245,6 +246,10 @@
#if N
int current_index = 0;
#endif
+ // Removes unreferenced local variable warning on VC7.
+ (void)start_index;
+ (void)L;
+
BOOST_PP_REPEAT(N, LUABIND_MATCH_DECL, _)
return m;
}
Index: class_rep.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/class_rep.hpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- class_rep.hpp 7 Aug 2004 13:37:10 -0000 1.41
+++ class_rep.hpp 28 Nov 2005 20:55:34 -0000 1.42
@@ -35,12 +35,21 @@
#include <luabind/detail/construct_rep.hpp>
#include <luabind/detail/garbage_collector.hpp>
#include <luabind/detail/operator_id.hpp>
-#include <luabind/detail/signature_match.hpp>
#include <luabind/detail/class_registry.hpp>
#include <luabind/detail/find_best_match.hpp>
#include <luabind/detail/get_overload_signature.hpp>
#include <luabind/error.hpp>
+#include <luabind/handle.hpp>
+#include <luabind/detail/primitives.hpp>
+
+#ifdef BOOST_MSVC
+// msvc doesn't have two-phase, but requires
+// method_rep (and overload_rep) to be complete
+// because of its std::list implementation.
+// gcc on the other hand has two-phase but doesn't
+// require method_rep to be complete.
#include <luabind/detail/method_rep.hpp>
+#endif
namespace luabind
{
@@ -168,8 +177,8 @@
// the lua reference to the metatable for this class' instances
int metatable_ref() const throw() { return m_instance_metatable; }
- void get_table(lua_State* L) const { m_table_ref.get(L); }
- void get_default_table(lua_State* L) const { m_default_table_ref.get(L); }
+ void get_table(lua_State* L) const { m_table.push(L); }
+ void get_default_table(lua_State* L) const { m_default_table.push(L); }
void(*destructor() const)(void*) { return m_destructor; }
void(*const_holder_destructor() const)(void*) { return m_const_holder_destructor; }
@@ -342,11 +351,11 @@
// this table contains c closures for all
// member functions in this class, they
// may point to both static and virtual functions
- detail::lua_reference m_table_ref;
+ handle m_table;
// this table contains default implementations of the
- // virtual functions in m_table_ref.
- detail::lua_reference m_default_table_ref;
+ // virtual functions in m_table.
+ handle m_default_table;
// the type of this class.. determines if it's written in c++ or lua
class_type m_class_type;
@@ -358,9 +367,8 @@
// ***** the maps below contains all members in this class *****
- // list of methods. pointers into this list is put
- // in the m_table_ref and m_default_table_ref
- // for access. The struct contains the function-
+ // list of methods. pointers into this list is put in the m_table and
+ // m_default_table for access. The struct contains the function-
// signatures for every overload
std::list<method_rep> m_methods;
@@ -386,6 +394,6 @@
}}
-#include <luabind/detail/overload_rep_impl.hpp>
+//#include <luabind/detail/overload_rep_impl.hpp>
#endif // LUABIND_CLASS_REP_HPP_INCLUDED
Index: constructor.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/constructor.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- constructor.hpp 7 Aug 2004 13:37:10 -0000 1.7
+++ constructor.hpp 28 Nov 2005 20:55:34 -0000 1.8
@@ -104,7 +104,7 @@
template<class T, class Policies, BOOST_PP_ENUM_PARAMS(LUABIND_MAX_ARITY, class A)>
static T* execute(
lua_State* L
- , weak_ref const& ref
+ , weak_ref const&
, T*
, constructor<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_ARITY,A)>*
, Policies*)
Index: other.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/other.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- other.hpp 14 Jun 2003 21:05:02 -0000 1.2
+++ other.hpp 28 Nov 2005 20:55:34 -0000 1.3
@@ -74,7 +74,7 @@
no_other_t is_other_test(...);
template<typename T>
- yes_other_t is_other_test(type< other<T> >);
+ yes_other_t is_other_test(type_< other<T> >);
template<bool wrapped>
struct other_unwrapper
@@ -102,7 +102,7 @@
public:
BOOST_STATIC_CONSTANT(
bool, value = (
- sizeof(detail::is_other_test(type<T>()))
+ sizeof(detail::is_other_test(type_<T>()))
== sizeof(detail::yes_other_t)));
};
Index: find_best_match.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/find_best_match.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- find_best_match.hpp 14 Jun 2003 21:05:02 -0000 1.5
+++ find_best_match.hpp 28 Nov 2005 20:55:34 -0000 1.6
@@ -33,16 +33,25 @@
// expects that a match function can be accesed through the iterator
// as int match_fun(lua_State*)
- // returns true if it found a match better than the given. If it finds a better match match_index is
- // updated to contain the new index to the best match (this index now refers to the list given to
- // this call).
- // orep_size is supposed to tell the size of the actual structures that start and end points to
- // ambiguous is set to true if the match was ambiguous
- // min_match should be initialized to the currently best match value (the number of implicit casts
- // to get a perfect match). If there are no previous matches, set min_match to std::numeric_limits<int>::max()
+ // returns true if it found a match better than the given. If it finds a
+ // better match match_index is updated to contain the new index to the best
+ // match (this index now refers to the list given to this call).
+ // orep_size is supposed to tell the size of the actual structures that
+ // start and end points to ambiguous is set to true if the match was
+ // ambiguous min_match should be initialized to the currently best match
+ // value (the number of implicit casts to get a perfect match). If there
+ // are no previous matches, set min_match to
+ // std::numeric_limits<int>::max()
- LUABIND_API bool find_best_match(lua_State* L, const detail::overload_rep_base* start, int num_overloads, size_t orep_size, bool& ambiguous, int& min_match, int& match_index, int num_params);
- LUABIND_API void find_exact_match(lua_State* L, const detail::overload_rep_base* start, int num_overloads, size_t orep_size, int cmp_match, int num_params, std::vector<const overload_rep_base*>& dest);
+ LUABIND_API bool find_best_match(lua_State* L
+ , detail::overload_rep_base const* start, int num_overloads
+ , size_t orep_size, bool& ambiguous, int& min_match, int& match_index
+ , int num_params);
+
+ LUABIND_API void find_exact_match(lua_State* L
+ , detail::overload_rep_base const* start, int num_overloads
+ , size_t orep_size, int cmp_match, int num_params
+ , std::vector<overload_rep_base const*>& dest);
}}
Index: call_operator_iterate.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/call_operator_iterate.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- call_operator_iterate.hpp 12 Aug 2004 12:40:43 -0000 1.4
+++ call_operator_iterate.hpp 28 Nov 2005 20:55:34 -0000 1.5
@@ -45,7 +45,8 @@
BOOST_PP_ENUM_TRAILING(N, LUABIND_UNWRAP_PARAMETER, _)
)
{
- detail::operator_result(
+ using namespace detail;
+ operator_result(
L
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
, self(BOOST_PP_ENUM_PARAMS(N, _))
Index: primitives.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/primitives.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- primitives.hpp 16 Apr 2004 17:15:34 -0000 1.7
+++ primitives.hpp 28 Nov 2005 20:55:34 -0000 1.8
@@ -38,7 +38,7 @@
};
template<class T>
- struct type {};
+ struct type_ {};
struct null_type {};
@@ -78,7 +78,7 @@
// returns the offset added to a Derived* when cast to a Base*
// TODO: return ptrdiff
template<class Derived, class Base>
- int ptr_offset(type<Derived>, type<Base>)
+ int ptr_offset(type_<Derived>, type_<Base>)
{
aligned<sizeof(Derived)> obj;
Derived* ptr = reinterpret_cast<Derived*>(&obj);
Index: object_rep.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/object_rep.hpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- object_rep.hpp 7 Aug 2004 13:37:10 -0000 1.19
+++ object_rep.hpp 28 Nov 2005 20:55:34 -0000 1.20
@@ -99,6 +99,8 @@
{
static void apply(void* ptr)
{
+ // Removes unreferenced formal parameter warning on VC7.
+ (void)ptr;
#ifndef NDEBUG
int completeness_check[sizeof(T)];
(void)completeness_check;
Index: call_function.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/call_function.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- call_function.hpp 7 Aug 2004 13:37:10 -0000 1.13
+++ call_function.hpp 28 Nov 2005 20:55:34 -0000 1.14
@@ -368,8 +368,8 @@
, luabind::detail::proxy_function_void_caller<boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> >
, luabind::detail::proxy_function_caller<Ret, boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> > >::type proxy_type;
- obj.pushvalue();
- return proxy_type(obj.lua_state(), 1, &detail::pcall, args);
+ obj.push(obj.interpreter());
+ return proxy_type(obj.interpreter(), 1, &detail::pcall, args);
}
template<class Ret BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), class A)>
@@ -411,8 +411,8 @@
, luabind::detail::proxy_function_void_caller<boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> >
, luabind::detail::proxy_function_caller<Ret, boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> > >::type proxy_type;
- obj.pushvalue();
- return proxy_type(obj.lua_state(), 1, &detail::resume_impl, args);
+ obj.push(obj.interpreter());
+ return proxy_type(obj.interpreter(), 1, &detail::resume_impl, args);
}
template<class Ret BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), class A)>
Index: policy.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/policy.hpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- policy.hpp 15 Apr 2005 17:25:30 -0000 1.50
+++ policy.hpp 28 Nov 2005 20:55:34 -0000 1.51
@@ -41,6 +41,7 @@
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/bind/arg.hpp>
#include <boost/limits.hpp>
+#include <boost/tuple/tuple.hpp>
#include <luabind/detail/class_registry.hpp>
#include <luabind/detail/primitives.hpp>
@@ -48,14 +49,17 @@
#include <luabind/detail/typetraits.hpp>
#include <luabind/detail/class_cache.hpp>
#include <luabind/detail/debug.hpp>
+#include <luabind/detail/class_rep.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <luabind/detail/decorate_type.hpp>
-#include <luabind/object.hpp>
#include <luabind/weak_ref.hpp>
#include <luabind/back_reference_fwd.hpp>
+#include <luabind/value_wrapper.hpp>
+#include <luabind/from_stack.hpp>
+
namespace luabind
{
namespace detail
@@ -73,7 +77,6 @@
class index_map
{
public:
-
index_map(const int* m): m_map(m) {}
int operator[](int index) const
@@ -82,7 +85,6 @@
}
private:
-
const int* m_map;
};
@@ -111,8 +113,7 @@
LUABIND_API int implicit_cast(const class_rep* crep, LUABIND_TYPE_INFO const&, int& pointer_offset);
}
- template<class T> class functor;
- class object;
+// template<class T> class functor;
class weak_ref;
}
@@ -120,7 +121,7 @@
{
template<class>
struct is_primitive;
-
+/*
template<class T>
yes_t is_lua_functor_test(const functor<T>&);
@@ -138,7 +139,7 @@
BOOST_STATIC_CONSTANT(bool, value = sizeof(is_lua_functor_test(t)) == sizeof(yes_t));
};
-
+*/
template<class H, class T>
struct policy_cons
{
@@ -228,10 +229,6 @@
#undef LUABIND_INTEGER_TYPE
- template<> struct is_primitive<luabind::object>: boost::mpl::bool_<true> {};
- template<> struct is_primitive<const luabind::object>: boost::mpl::bool_<true> {};
- template<> struct is_primitive<const luabind::object&>: boost::mpl::bool_<true> {};
-
template<> struct is_primitive<luabind::weak_ref>: boost::mpl::bool_<true> {};
template<> struct is_primitive<const luabind::weak_ref>: boost::mpl::bool_<true> {};
template<> struct is_primitive<const luabind::weak_ref&>: boost::mpl::bool_<true> {};
@@ -265,22 +262,9 @@
template<>
struct primitive_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef primitive_converter type;
- void apply(lua_State* L, const luabind::object& v)
- {
- // if the luabind::object is uninitialized
- // treat it as nil.
- if (v.lua_state() == 0)
- {
- lua_pushnil(L);
- return;
- }
- // if you hit this assert you are trying to return a value from one state into another lua state
- assert((v.lua_state() == L) && "you cannot return an uninitilized value "
- "or a value from one lua state into another");
- v.pushvalue();
- }
void apply(lua_State* L, int v) { lua_pushnumber(L, (lua_Number)v); }
void apply(lua_State* L, short v) { lua_pushnumber(L, (lua_Number)v); }
void apply(lua_State* L, char v) { lua_pushnumber(L, (lua_Number)v); }
@@ -311,6 +295,7 @@
template<>
struct primitive_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef primitive_converter type;
#define PRIMITIVE_CONVERTER(prim) \
@@ -363,30 +348,13 @@
{ return std::string(lua_tostring(L, index), lua_strlen(L, index)); }
PRIMITIVE_MATCHER(std::string) { if (lua_type(L, index) == LUA_TSTRING) return 0; else return -1; }
- PRIMITIVE_CONVERTER(luabind::object)
- {
- LUABIND_CHECK_STACK(L);
-
- lua_pushvalue(L, index);
- detail::lua_reference ref;
- ref.set(L);
- return luabind::object(L, ref, true);
- }
-
- PRIMITIVE_MATCHER(luabind::object)
- {
- (void)index;
- (void)L;
- return std::numeric_limits<int>::max() / LUABIND_MAX_ARITY;
- }
-
PRIMITIVE_CONVERTER(luabind::weak_ref)
{
LUABIND_CHECK_STACK(L);
return luabind::weak_ref(L, index);
}
- PRIMITIVE_MATCHER(luabind::weak_ref) { (void)index; (void)L; return std::numeric_limits<int>::max() - 1; }
+ PRIMITIVE_MATCHER(luabind::weak_ref) { (void)index; (void)L; return (std::numeric_limits<int>::max)() - 1; }
const char* apply(lua_State* L, detail::by_const_pointer<char>, int index)
{
@@ -425,6 +393,7 @@
template<>
struct user_defined_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef user_defined_converter type;
template<class T>
@@ -476,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>
@@ -494,6 +464,7 @@
template<>
struct pointer_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef pointer_converter type;
template<class T>
@@ -505,7 +476,7 @@
return;
}
- if (back_reference<T>::extract(L, ptr))
+ if (luabind::get_back_reference(L, ptr))
return;
class_rep* crep = get_class_rep<T>(L);
@@ -529,6 +500,7 @@
template<>
struct pointer_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef pointer_converter type;
// TODO: does the pointer converter need this?!
@@ -594,12 +566,13 @@
template<>
struct value_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<true> is_value_converter;
typedef value_converter type;
template<class T>
void apply(lua_State* L, const T& ref)
{
- if (back_reference<T>::extract(L, &ref))
+ if (luabind::get_back_reference(L, ref))
return;
class_rep* crep = get_class_rep<T>(L);
@@ -659,6 +632,7 @@
template<>
struct value_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<true> is_value_converter;
typedef value_converter type;
template<class T>
@@ -734,6 +708,7 @@
template<>
struct const_pointer_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef const_pointer_converter type;
template<class T>
@@ -745,7 +720,7 @@
return;
}
- if (back_reference<T>::extract(L, ptr))
+ if (luabind::get_back_reference(L, ptr))
return;
class_rep* crep = get_class_rep<T>(L);
@@ -772,6 +747,7 @@
struct const_pointer_converter<lua_to_cpp>
: private pointer_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef const_pointer_converter type;
template<class T>
@@ -794,7 +770,8 @@
bool const_ = obj->flags() & object_rep::constant;
int d;
- return implicit_cast(obj->crep(), LUABIND_TYPEID(T), d) + !const_;
+ int points = implicit_cast(obj->crep(), LUABIND_TYPEID(T), d);
+ return points == -1 ? -1 : points + !const_;
}
template<class T>
@@ -811,12 +788,13 @@
template<>
struct ref_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef ref_converter type;
template<class T>
void apply(lua_State* L, T& ref)
{
- if (back_reference<T>::extract(L, &ref))
+ if (luabind::get_back_reference(L, ref))
return;
class_rep* crep = get_class_rep<T>(L);
@@ -842,6 +820,7 @@
template<>
struct ref_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef ref_converter type;
template<class T>
@@ -869,12 +848,13 @@
template<>
struct const_ref_converter<cpp_to_lua>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef const_ref_converter type;
template<class T>
void apply(lua_State* L, const T& ref)
{
- if (back_reference<T>::extract(L, &ref))
+ if (luabind::get_back_reference(L, ref))
return;
class_rep* crep = get_class_rep<T>(L);
@@ -919,6 +899,7 @@
template<>
struct const_ref_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef const_ref_converter type;
// TODO: align!
@@ -981,7 +962,8 @@
bool const_ = obj->flags() & object_rep::constant;
int d;
- return implicit_cast(obj->crep(), LUABIND_TYPEID(T), d) + !const_;
+ int points = implicit_cast(obj->crep(), LUABIND_TYPEID(T), d);
+ return points == -1 ? -1 : points + !const_;
}
~const_ref_converter()
@@ -1000,6 +982,7 @@
template<class Direction = cpp_to_lua>
struct enum_converter
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef enum_converter type;
void apply(lua_State* L, int val)
@@ -1011,6 +994,7 @@
template<>
struct enum_converter<lua_to_cpp>
{
+ typedef boost::mpl::bool_<false> is_value_converter;
typedef enum_converter type;
template<class T>
@@ -1028,7 +1012,7 @@
template<class T>
void converter_postcall(lua_State*, T, int) {}
};
-
+/*
// ****** functor converter ********
template<class Direction> struct functor_converter;
@@ -1077,10 +1061,58 @@
template<class T>
void converter_postcall(lua_State*, T, int) {}
};
+*/
+
+ template<class Direction>
+ struct value_wrapper_converter;
+
+ template<>
+ struct value_wrapper_converter<lua_to_cpp>
+ {
+ typedef boost::mpl::bool_<false> is_value_converter;
+ typedef value_wrapper_converter type;
+
+ template<class T>
+ T apply(lua_State* L, by_const_reference<T>, int index)
+ {
+ return T(from_stack(L, index));
+ }
+
+ template<class T>
+ T apply(lua_State* L, by_value<T>, int index)
+ {
+ return apply(L, by_const_reference<T>(), index);
+ }
+
+ template<class T>
+ static int match(lua_State* L, by_const_reference<T>, int index)
+ {
+ return value_wrapper_traits<T>::check(L, index)
+ ? (std::numeric_limits<int>::max)() / LUABIND_MAX_ARITY
+ : -1;
+ }
+ template<class T>
+ static int match(lua_State* L, by_value<T>, int index)
+ {
+ return match(L, by_const_reference<T>(), index);
+ }
+ void converter_postcall(...) {}
+ };
+ template<>
+ struct value_wrapper_converter<cpp_to_lua>
+ {
+ typedef boost::mpl::bool_<false> is_value_converter;
+ typedef value_wrapper_converter type;
+ template<class T>
+ void apply(lua_State* interpreter, T const& value_wrapper)
+ {
+ value_wrapper_traits<T>::unwrap(interpreter, value_wrapper);
+ }
+ };
// *********** default_policy *****************
@@ -1099,35 +1131,39 @@
is_user_defined<T>
, user_defined_converter<Direction>
, eval_if<
- is_primitive<T>
- , primitive_converter<Direction>
+ is_value_wrapper_arg<T>
+ , value_wrapper_converter<Direction>
, eval_if<
- is_lua_functor<T>
- , functor_converter<Direction>
+ is_primitive<T>
+ , primitive_converter<Direction>
, eval_if<
- boost::is_enum<T>
- , enum_converter<Direction>
- , eval_if<
- is_nonconst_pointer<T>
- , pointer_converter<Direction>
+// is_lua_functor<T>
+// , functor_converter<Direction>
+// , eval_if<
+ boost::is_enum<T>
+ , enum_converter<Direction>
, eval_if<
- is_const_pointer<T>
- , const_pointer_converter<Direction>
+ is_nonconst_pointer<T>
+ , pointer_converter<Direction>
, eval_if<
- is_nonconst_reference<T>
- , ref_converter<Direction>
+ is_const_pointer<T>
+ , const_pointer_converter<Direction>
, eval_if<
- is_const_reference<T>
- , const_ref_converter<Direction>
- , value_converter<Direction>
+ is_nonconst_reference<T>
+ , ref_converter<Direction>
+ , eval_if<
+ is_const_reference<T>
+ , const_ref_converter<Direction>
+ , value_converter<Direction>
+ >
>
>
>
>
- >
+// >
>
>
- >
+ >
{
};
};
@@ -1263,7 +1299,5 @@
LUABIND_ANONYMOUS_FIX boost::arg<0> result;
}}
-#include <luabind/detail/object_funs.hpp>
-
#endif // LUABIND_POLICY_HPP_INCLUDED
Index: call_member.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/call_member.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- call_member.hpp 7 Aug 2004 13:37:10 -0000 1.11
+++ call_member.hpp 28 Nov 2005 20:55:34 -0000 1.12
@@ -30,6 +30,10 @@
#include <luabind/detail/convert_to_lua.hpp>
#include <luabind/detail/pcall.hpp>
#include <luabind/error.hpp>
+#include <luabind/detail/stack_utils.hpp>
+#include <luabind/object.hpp> // TODO: REMOVE DEPENDENCY
+
+#include <boost/tuple/tuple.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/facilities/expand.hpp>
@@ -336,18 +340,18 @@
// once the call has been made
// get the function
- obj.pushvalue();
- lua_pushstring(obj.lua_state(), name);
- lua_gettable(obj.lua_state(), -2);
+ obj.push(obj.interpreter());
+ lua_pushstring(obj.interpreter(), name);
+ lua_gettable(obj.interpreter(), -2);
// duplicate the self-object
- lua_pushvalue(obj.lua_state(), -2);
+ lua_pushvalue(obj.interpreter(), -2);
// remove the bottom self-object
- lua_remove(obj.lua_state(), -3);
+ lua_remove(obj.interpreter(), -3);
// now the function and self objects
// are on the stack. These will both
// be popped by pcall
- return proxy_type(obj.lua_state(), args);
+ return proxy_type(obj.interpreter(), args);
}
#undef LUABIND_OPERATOR_PARAMS
Index: overload_rep.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/overload_rep.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- overload_rep.hpp 1 Aug 2005 17:29:19 -0000 1.7
+++ overload_rep.hpp 28 Nov 2005 20:55:34 -0000 1.8
@@ -30,13 +30,18 @@
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repeat.hpp>
+#include <vector>
#include <luabind/detail/overload_rep_base.hpp>
-#include <luabind/detail/class_rep.hpp>
#include <luabind/detail/is_indirect_const.hpp>
+#ifndef BOOST_MSVC
+#include <luabind/detail/policy.hpp>
+#endif
+
namespace luabind { namespace detail
{
struct dummy_ {};
@@ -94,7 +99,7 @@
#elif BOOST_PP_ITERATION_FLAGS() == 1
#define LUABIND_PARAM(z, n, _) m_params_.push_back(LUABIND_TYPEID(A##n));
-#define LUABIND_POLICY_DECL(z,n,offset) typedef typename find_conversion_policy<n + offset, Policies>::type BOOST_PP_CAT(p,n);
+#define LUABIND_POLICY_DECL(z,n,offset) typedef typename detail::find_conversion_policy<n + offset, Policies>::type BOOST_PP_CAT(p,n);
#define LUABIND_ARITY(z,n,text) + BOOST_PP_CAT(p,n)::has_arg
// overloaded template funtion that initializes the parameter list
Index: call.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/call.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- call.hpp 7 Aug 2004 13:37:10 -0000 1.6
+++ call.hpp 28 Nov 2005 20:55:34 -0000 1.7
@@ -41,6 +41,8 @@
#include <luabind/detail/policy.hpp>
#include <luabind/yield_policy.hpp>
+#include <luabind/detail/most_derived.hpp>
+
#define LUABIND_DECL(z, n, off) \
typedef typename find_conversion_policy< \
n + off \
@@ -92,16 +94,6 @@
}
};
- template<class Class, class WrappedClass>
- struct most_derived
- {
- typedef typename boost::mpl::if_<
- boost::is_base_and_derived<Class, WrappedClass>
- , WrappedClass
- , Class
- >::type type;
- };
-
template<class T>
struct returns
{
Index: overload_rep_base.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/overload_rep_base.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- overload_rep_base.hpp 7 Aug 2004 13:37:10 -0000 1.3
+++ overload_rep_base.hpp 28 Nov 2005 20:55:34 -0000 1.4
@@ -26,6 +26,8 @@
#include <luabind/config.hpp>
#include <boost/function/function1.hpp>
+struct lua_State;
+
namespace luabind { namespace detail
{
// this class represents a specific overload of a member-function.
@@ -34,10 +36,10 @@
#if !defined(NDEBUG) && !defined(LUABIND_NO_ERROR_CHECKING)
overload_rep_base(): m_get_signature_fun(0), m_match_fun(0), m_arity(-1) {}
#else
- overload_rep_base(): m_match_fun(0), m_arity(-1) {}
+ overload_rep_base(): m_match_fun(0), m_arity(-1) {}
#endif
- typedef boost::function1<int, lua_State*> match_fun_t;
+ typedef boost::function1<int, lua_State*> match_fun_t;
typedef void(*get_sig_ptr)(lua_State*, std::string&);
inline int match(lua_State* L, int num_params) const
--- overload_rep_impl.hpp DELETED ---
Index: property.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/detail/property.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- property.hpp 7 Aug 2004 13:37:10 -0000 1.11
+++ property.hpp 28 Nov 2005 20:55:34 -0000 1.12
@@ -25,6 +25,9 @@
#define LUABIND_PROPERTY_HPP_INCLUDED
#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
{
@@ -126,7 +129,6 @@
return set_matcher<Param, Policy>::apply;
}
- // TODO: add support for policies
template<class T, class D, class Policies>
struct auto_set : Policies
{
@@ -167,7 +169,15 @@
}
};
- // TODO: add support for policies
+ // if the input type is a value_converter, it will produce
+ // a reference converter
+ template<class ConverterPolicy, class D>
+ struct make_reference_converter
+ {
+ typedef typename ConverterPolicy::template generate_converter<
+ typename boost::add_reference<D>::type, cpp_to_lua>::type type;
+ };
+
template<class T, class D, class Policies>
struct auto_get : Policies
{
@@ -194,14 +204,29 @@
T* ptr = reinterpret_cast<T*>(static_cast<char*>(raw_ptr) + pointer_offset);
typedef typename find_conversion_policy<0,Policies>::type converter_policy;
- typename converter_policy::template generate_converter<D,cpp_to_lua>::type converter;
+ 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;
+
+ // 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);
int nret = lua_gettop(L) - nargs;
const int indices[] = { 1, nargs + nret };
- policy_list_postcall<Policies>::apply(L, indices);
+ policy_list_postcall<policy_list>::apply(L, indices);
return nret;
}
--- NEW FILE: most_derived.hpp ---
// Copyright (c) 2005 Daniel Wallin and Arvid Norberg
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef MOST_DERIVED_051018_HPP
# define MOST_DERIVED_051018_HPP
# include <boost/mpl/if.hpp>
# include <boost/type_traits/is_base_and_derived.hpp>
namespace luabind { namespace detail {
template<class Class, class WrappedClass>
struct most_derived
{
typedef typename boost::mpl::if_<
boost::is_base_and_derived<Class, WrappedClass>
, WrappedClass
, Class
>::type type;
};
}} // namespace luabind::detail
#endif // MOST_DERIVED_051018_HPP
|