67 LASS_EXECUTE_BEFORE_MAIN_EX( Map_executeBeforeMain,
68 Map::_lassPyClassDef.setSlot(Py_mp_length, &
Map::length);
69 Map::_lassPyClassDef.setSlot(Py_mp_subscript, &
Map::subscript);
70 Map::_lassPyClassDef.setSlot(Py_mp_ass_subscript, &
Map::assSubscript);
77 Map::Map(TPimpl&& pimpl)
79 init(std::move(pimpl));
82 void Map::init(TPimpl&& pimpl)
84 LockGIL LASS_UNUSED(lock);
85 impl::initLassModule();
86 impl::fixObjectType(
this);
87 pimpl_ = std::move(pimpl);
90 std::string Map::repr()
const
92 LockGIL LASS_UNUSED(lock);
93 return pimpl_->repr();
98 LockGIL LASS_UNUSED(lock);
104 LockGIL LASS_UNUSED(lock);
110 LockGIL LASS_UNUSED(lock);
116 LockGIL LASS_UNUSED(lock);
118 if (!result && PyErr_ExceptionMatches(PyExc_KeyError))
121 result = defaultValue;
128 LockGIL LASS_UNUSED(lock);
132 const TMapPtr Map::copy()
const
134 LockGIL LASS_UNUSED(lock);
135 TPimpl pimpl = pimpl_->copy();
136 return TMapPtr(
new Map(std::move(pimpl)));
141 LockGIL LASS_UNUSED(lock);
142 return pimpl_->asNative();
147 LockGIL LASS_UNUSED(lock);
148 if (!pimpl_->clear())
154 const std::type_info& Map::type()
const
156 return pimpl_->type();
158 void* Map::raw(
bool writable)
const
160 return pimpl_->raw(writable);
163 Py_ssize_t Map::length( PyObject* self)
165 return static_cast<Map*
>(self)->pimpl_->length();
168 PyObject* Map::subscript( PyObject* self, PyObject* key)
170 return static_cast<Map*
>(self)->pimpl_->subscript(key);
173 int Map::assSubscript( PyObject* self, PyObject* key, PyObject* value)
175 return static_cast<Map*
>(self)->pimpl_->assSubscript(key, value);
#define PY_DECLARE_CLASS(i_cppClass)
Declare a Python class with automatic name and no documentation.
#define PY_CLASS_METHOD_NAME(i_cppClass, i_cppMethod, s_methodName)
Export a C++ method to Python with custom name (no documentation).
#define PY_CLASS_METHOD(i_cppClass, i_cppMethod)
Export a C++ method to Python using the C++ method name (no documentation).
void fetchAndThrowPythonException(std::string loc)
Fetch the current Python exception and throw it as a C++ PythonException.
PyObjectPtr< PyObject >::Type TPyObjPtr
PyObjectPtr to a PyObject.
lass::util::SharedPtr< T, PyObjectStorage, PyObjectCounter > fromNakedToSharedPtrCast(PyObject *object)
fromNakedToSharedPtrCast.
const lass::python::impl::IterSlot _iter_("__iter__", Py_tp_iter)
__iter__ method (iterator)
const lass::python::impl::UnarySlot _repr_("__repr__", Py_tp_repr)
__repr__ method (must always return a string)
Comprehensive C++ to Python binding library.
Library for Assembled Shared Sources.