From 5e509227d2d3cf701b56817d132e2e5d9f478564 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 7 Jan 2022 19:55:21 +0100 Subject: [PATCH] Spreadsheet: proper implementation of mp_subscript of Mapping protocol of PropertySheetPy --- src/Mod/Spreadsheet/App/PropertySheetPy.xml | 12 ++++++++++ .../Spreadsheet/App/PropertySheetPyImp.cpp | 24 +++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Mod/Spreadsheet/App/PropertySheetPy.xml b/src/Mod/Spreadsheet/App/PropertySheetPy.xml index 14125a8540..4ee484140d 100644 --- a/src/Mod/Spreadsheet/App/PropertySheetPy.xml +++ b/src/Mod/Spreadsheet/App/PropertySheetPy.xml @@ -15,5 +15,17 @@ Internal spreadsheet object + + diff --git a/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp b/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp index 1313ed80b4..fff334e8b8 100644 --- a/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp @@ -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(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(o)->getPropertySheetPtr()->getPyValue(key); +} + PyObject *PropertySheetPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int PropertySheetPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)