2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 05:02:17 +00:00

object operator support

[SVN r14168]
This commit is contained in:
Dave Abrahams
2002-06-18 13:49:09 +00:00
parent 87bda9e124
commit 66f2cd81a8
15 changed files with 771 additions and 432 deletions

View File

@@ -8,28 +8,28 @@
#include <boost/python/errors.hpp>
#include <boost/python/object.hpp>
namespace boost { namespace python {
namespace boost { namespace python { namespace api {
object getattr(object const& target, object const& key)
BOOST_PYTHON_DECL object getattr(object const& target, object const& key)
{
return object((object::new_pyobject_reference*)PyObject_GetAttr(&*target, &*key));
}
void setattr(object const& target, object const& key, object const& value)
BOOST_PYTHON_DECL void setattr(object const& target, object const& key, object const& value)
{
if (PyObject_SetAttr(&*target, &*key, &*value) == -1)
throw_error_already_set();
}
object getitem(object const& target, object const& key)
BOOST_PYTHON_DECL object getitem(object const& target, object const& key)
{
return object((object::new_pyobject_reference*)PyObject_GetItem(&*target, &*key));
}
void setitem(object const& target, object const& key, object const& value)
BOOST_PYTHON_DECL void setitem(object const& target, object const& key, object const& value)
{
if (PyObject_SetItem(&*target, &*key, &*value) == -1)
throw_error_already_set();
}
}} // namespace boost::python
}}} // namespace boost::python::api