Spreadsheet: proper implementation of mp_subscript of Mapping protocol of PropertySheetPy
This commit is contained in:
@@ -15,5 +15,17 @@
|
||||
<Author Licence="LGPL" Name="Eivind Kvedalen" EMail="eivind@kvedalen.name" />
|
||||
<UserDocu>Internal spreadsheet object</UserDocu>
|
||||
</Documentation>
|
||||
<Sequence
|
||||
sq_length="false"
|
||||
sq_concat="false"
|
||||
sq_repeat="false"
|
||||
sq_item="false"
|
||||
mp_subscript="true"
|
||||
sq_ass_item="false"
|
||||
mp_ass_subscript="false"
|
||||
sq_contains="false"
|
||||
sq_inplace_concat="false"
|
||||
sq_inplace_repeat="false">
|
||||
</Sequence>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -31,23 +31,6 @@
|
||||
|
||||
using namespace Spreadsheet;
|
||||
|
||||
struct PropertySheetPyInit {
|
||||
|
||||
PyMappingMethods methods;
|
||||
|
||||
PropertySheetPyInit() {
|
||||
methods.mp_length = 0;
|
||||
methods.mp_ass_subscript = 0;
|
||||
methods.mp_subscript = [](PyObject *o, PyObject *key) {
|
||||
return static_cast<PropertySheetPy*>(o)->getPropertySheetPtr()->getPyValue(key);
|
||||
};
|
||||
|
||||
PropertySheetPy::Type.tp_as_mapping = &methods;
|
||||
}
|
||||
};
|
||||
|
||||
static PropertySheetPyInit _PropertySheetPyInit;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string PropertySheetPy::representation(void) const
|
||||
{
|
||||
@@ -66,9 +49,14 @@ int PropertySheetPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject * PropertySheetPy::mapping_subscript(PyObject * o, PyObject *key)
|
||||
{
|
||||
return static_cast<PropertySheetPy*>(o)->getPropertySheetPtr()->getPyValue(key);
|
||||
}
|
||||
|
||||
PyObject *PropertySheetPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int PropertySheetPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
|
||||
Reference in New Issue
Block a user