[luabind-cvs] luabind/luabind/luabind nil.hpp, NONE, 1.1 object.hpp, 1.39, 1.40
Brought to you by:
arvidn,
daniel_wallin
|
From: Arvid N. <ar...@us...> - 2006-06-13 23:28:06
|
Update of /cvsroot/luabind/luabind/luabind/luabind In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv343/luabind/luabind Modified Files: object.hpp Added Files: nil.hpp Log Message: added luabind::nil and assignment operators to handle it Index: object.hpp =================================================================== RCS file: /cvsroot/luabind/luabind/luabind/luabind/object.hpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- object.hpp 26 Mar 2006 15:47:30 -0000 1.39 +++ object.hpp 13 Jun 2006 23:27:57 -0000 1.40 @@ -30,6 +30,7 @@ #include <boost/tuple/tuple.hpp> #include <boost/optional.hpp> +#include <luabind/nil.hpp> #include <luabind/value_wrapper.hpp> #include <luabind/detail/pcall.hpp> #include <luabind/handle.hpp> @@ -356,6 +357,15 @@ lua_pop(m_interpreter, 2); } + // this will set the value to nil + iterator_proxy & operator=(luabind::detail::nil_type) + { + lua_pushvalue(m_interpreter, m_key_index); + lua_pushnil(m_interpreter); + AccessPolicy::set(m_interpreter, m_table_index); + return *this; + } + template<class T> iterator_proxy& operator=(T const& value) { @@ -580,6 +590,18 @@ // This is non-const to prevent conversion on lvalues. operator object(); + // this will set the value to nil + this_type& operator=(luabind::detail::nil_type) + { + value_wrapper_traits<Next>::unwrap(m_interpreter, m_next); + detail::stack_pop pop(m_interpreter, 1); + + lua_pushvalue(m_interpreter, m_key_index); + lua_pushnil(m_interpreter); + lua_settable(m_interpreter, -3); + return *this; + } + template<class T> this_type& operator=(T const& value) { @@ -606,6 +628,8 @@ } private: + struct hidden_type {}; + this_type& operator=(index_proxy<Next> const&); mutable lua_State* m_interpreter; --- NEW FILE: nil.hpp --- // Copyright (c) 2004 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 LUABIND_NIL_HPP #define LUABIND_NIL_HPP namespace luabind { namespace detail { struct nil_type {}; } // defined in class.cpp extern detail::nil_type nil; } #endif |