Update of /cvsroot/luabind/luabind/luabind/luabind
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247/luabind/luabind
Modified Files:
class.hpp function.hpp handle.hpp object.hpp
Log Message:
merged back rc 0.7 changes into head
Index: object.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- object.hpp 16 Dec 2005 18:52:23 -0000 1.38
+++ object.hpp 26 Mar 2006 15:47:30 -0000 1.39
@@ -140,23 +140,46 @@
};
# endif
- template<class T, class U, class V>
- lua_State* binary_interpreter(T const& x, U const&, boost::mpl::true_, V)
+ template<class T, class U>
+ int binary_interpreter(lua_State*& L, T const& lhs, U const& rhs
+ , boost::mpl::true_, boost::mpl::true_)
{
- return value_wrapper_traits<T>::interpreter(x);
+ L = value_wrapper_traits<T>::interpreter(lhs);
+ lua_State* L2 = value_wrapper_traits<U>::interpreter(rhs);
+
+ // you are comparing objects with different interpreters
+ // that's not allowed.
+ assert(L == L2 || L == 0 || L2 == 0);
+
+ // if the two objects we compare have different interpreters
+ // then they
+
+ if (L != L2) return -1;
+ if (L == 0) return 1;
+ return 0;
+ }
+
+ template<class T, class U>
+ int binary_interpreter(lua_State*& L, T const& x, U const&
+ , boost::mpl::true_, boost::mpl::false_)
+ {
+ L = value_wrapper_traits<T>::interpreter(x);
+ return 0;
}
template<class T, class U>
- lua_State* binary_interpreter(T const&, U const& x, boost::mpl::false_, boost::mpl::true_)
+ int binary_interpreter(lua_State*& L, T const&, U const& x, boost::mpl::false_, boost::mpl::true_)
{
- return value_wrapper_traits<U>::interpreter(x);
+ L = value_wrapper_traits<U>::interpreter(x);
+ return 0;
}
template<class T, class U>
- lua_State* binary_interpreter(T const& x, U const& y)
+ int binary_interpreter(lua_State*& L, T const& x, U const& y)
{
return binary_interpreter(
- x
+ L
+ , x
, y
, is_value_wrapper<T>()
, is_value_wrapper<U>()
@@ -168,7 +191,14 @@
typename enable_binary<bool,LHS,RHS>::type \
operator op(LHS const& lhs, RHS const& rhs) \
{ \
- lua_State* L = binary_interpreter(lhs, rhs); \
+ lua_State* L = 0; \
+ switch (binary_interpreter(L, lhs, rhs)) \
+ { \
+ case 1: \
+ return true; \
+ case -1: \
+ return false; \
+ } \
\
assert(L); \
\
@@ -180,8 +210,24 @@
return fn(L, -1, -2) != 0; \
}
- LUABIND_BINARY_OP_DEF(==, lua_equal)
- LUABIND_BINARY_OP_DEF(<, lua_lessthan)
+LUABIND_BINARY_OP_DEF(==, lua_equal)
+LUABIND_BINARY_OP_DEF(<, lua_lessthan)
+
+ template<class ValueWrapper>
+ std::ostream& operator<<(std::ostream& os
+ , object_interface<ValueWrapper> const& v)
+ {
+ using namespace luabind;
+ lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter(
+ static_cast<ValueWrapper const&>(v));
+ detail::stack_pop pop(interpreter, 1);
+ value_wrapper_traits<ValueWrapper>::unwrap(interpreter
+ , static_cast<ValueWrapper const&>(v));
+ char const* p = lua_tostring(interpreter, -1);
+ int len = lua_strlen(interpreter, -1);
+ std::copy(p, p + len, std::ostream_iterator<char>(os));
+ return os;
+ }
#undef LUABIND_BINARY_OP_DEF
Index: handle.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/handle.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- handle.hpp 28 Nov 2005 20:55:34 -0000 1.2
+++ handle.hpp 26 Mar 2006 15:47:30 -0000 1.3
@@ -62,6 +62,7 @@
: m_interpreter(other.m_interpreter)
, m_index(LUA_NOREF)
{
+ if (m_interpreter == 0) return;
detail::getref(m_interpreter, other.m_index);
m_index = detail::ref(m_interpreter);
}
Index: class.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/class.hpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- class.hpp 28 Nov 2005 20:55:34 -0000 1.64
+++ class.hpp 26 Mar 2006 15:47:30 -0000 1.65
@@ -726,11 +726,11 @@
, const boost::function2<int, lua_State*, int>& g);
#ifdef LUABIND_NO_ERROR_CHECKING
- void class_base::add_setter(
+ void add_setter(
const char* name
, const boost::function2<int, lua_State*, int>& s);
#else
- void class_base::add_setter(
+ void add_setter(
const char* name
, const boost::function2<int, lua_State*, int>& s
, int (*match)(lua_State*, int)
Index: function.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/function.hpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- function.hpp 4 Dec 2005 13:56:15 -0000 1.25
+++ function.hpp 26 Mar 2006 15:47:30 -0000 1.26
@@ -87,7 +87,7 @@
char end;
};
- struct function_rep
+ struct LUABIND_API function_rep
{
function_rep(const char* name): m_name(name) {}
void add_overload(const free_functions::overload_rep& o);
|