From 813df24dcb0bc7696f936626a35adcf0fbab9953 Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Thu, 17 Apr 2003 21:10:29 +0000 Subject: [PATCH] *** empty log message *** --- luabind/adopt_policy.hpp | 2 +- luabind/functor.hpp | 24 ++++++++++++++++++++++-- test/test_free_functions.cpp | 5 +++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/luabind/adopt_policy.hpp b/luabind/adopt_policy.hpp index 70148d2..5faebfa 100644 --- a/luabind/adopt_policy.hpp +++ b/luabind/adopt_policy.hpp @@ -126,5 +126,5 @@ namespace luabind adopt(boost::arg) { return detail::policy_cons, detail::null_type>(); } } -#endif // LUABIND_ADOPT_POLICY_HPP_INCLUDED +#endif // LUABIND_ADOPT_POLICY_HPP_INCLUDE diff --git a/luabind/functor.hpp b/luabind/functor.hpp index cf6e761..7644252 100644 --- a/luabind/functor.hpp +++ b/luabind/functor.hpp @@ -289,10 +289,30 @@ namespace luabind return *this; } + bool operator==(const functor& rhs) const + { + if (ref_ == LUA_NOREF || rhs.ref_ == LUA_NOREF) return false; + pushvalue(); + rhs.pushvalue(); + bool result = lua_equal(L_, -1, -2) != 0; + lua_pop(L_, 2); + return result; + } + + bool operator!=(const functor& rhs) const + { + if (ref_ == LUA_NOREF || rhs.ref_ == LUA_NOREF) return true; + pushvalue(); + rhs.pushvalue(); + bool result = lua_equal(L_, -1, -2) == 0; + lua_pop(L_, 2); + return result; + } + inline bool is_valid() const { return ref_ != LUA_NOREF; } - lua_State* lua_state() { return L_; } - void pushvalue() { lua_getref(L_, ref_); } + lua_State* lua_state() const { return L_; } + void pushvalue() const { lua_getref(L_, ref_); } #define BOOST_PP_ITERATION_PARAMS_1 (4, (0, LUABIND_MAX_ARITY, , 1)) #include BOOST_PP_ITERATE() diff --git a/test/test_free_functions.cpp b/test/test_free_functions.cpp index d74f481..0167337 100644 --- a/test/test_free_functions.cpp +++ b/test/test_free_functions.cpp @@ -157,9 +157,14 @@ bool test_free_functions() std::string str = functor_test(6)[detail::null_type()]; if (str != "foobar") return false; if (object_cast(get_globals(L)["glob"]) != 6) return false; + + functor functor_test2 = object_cast >(get_globals(L)["functor_test"]); + + if (functor_test != functor_test2) return false; } if (feedback != 99) return false; return true; } + -- 2.11.4.GIT