[luabind-cvs] luabind/luabind/luabind object.hpp,1.34.2.14,1.34.2.15
Brought to you by:
arvidn,
daniel_wallin
From: Daniel W. <dan...@us...> - 2005-09-29 23:35:32
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19975 Modified Files: Tag: beta7-devel2 object.hpp Log Message: Refactored binary operator defintions into a macro Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.34.2.14 retrieving revision 1.34.2.15 diff -u -d -r1.34.2.14 -r1.34.2.15 --- object.hpp 29 Sep 2005 22:18:36 -0000 1.34.2.14 +++ object.hpp 29 Sep 2005 23:35:24 -0000 1.34.2.15 @@ -115,36 +115,27 @@ ); } - template <class LHS, class RHS> - bool operator==(LHS const& lhs, RHS const& rhs) - { - lua_State* L = binary_interpreter(lhs, rhs); - - assert(L); - - detail::stack_pop pop1(L, 1); - detail::push(L, lhs); - detail::stack_pop pop2(L, 1); - detail::push(L, rhs); - - return lua_equal(L, -1, -2) != 0; +#define LUABIND_BINARY_OP_DEF(op, fn) \ + template <class LHS, class RHS> \ + bool operator op(LHS const& lhs, RHS const& rhs) \ + { \ + lua_State* L = binary_interpreter(lhs, rhs); \ +\ + assert(L); \ +\ + detail::stack_pop pop1(L, 1); \ + detail::push(L, lhs); \ + detail::stack_pop pop2(L, 1); \ + detail::push(L, rhs); \ +\ + return fn(L, -1, -2) != 0; \ } - template <class LHS, class RHS> - bool operator<(LHS const& lhs, RHS const& rhs) - { - lua_State* L = binary_interpreter(lhs, rhs); - - assert(L); - - detail::stack_pop pop1(L, 1); - detail::push(L, lhs); - detail::stack_pop pop2(L, 1); - detail::push(L, rhs); + LUABIND_BINARY_OP_DEF(==, lua_equal) + LUABIND_BINARY_OP_DEF(<, lua_lessthan) - return lua_lessthan(L, -1, -2); - } - +#undef LUABIND_BINARY_OP_DEF + template<class ValueWrapper, class Arguments> struct call_proxy; |