Spreadsheet: support mapping protocol in PropertySheetPy
Read only mapping protocol support to retrieve a range of cell values. Expects the key to be a string of either a single cell address or a range.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "PropertySheet.h"
|
||||
#include "Mod/Spreadsheet/App/PropertySheet.h"
|
||||
|
||||
// inclusion of the generated files (generated out of PropertySheetPy.xml)
|
||||
#include "PropertySheetPy.h"
|
||||
@@ -31,6 +31,23 @@
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user