From 52c4ad941b25b0ea84876da563a0c118330f8c39 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 23 Sep 2021 18:51:41 +0200 Subject: [PATCH] App: add comment for clarification --- src/App/DocumentObjectPyImp.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 88bfd1ca92..6c72bb7ec1 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -352,6 +352,15 @@ PyObject* DocumentObjectPy::evalExpression(PyObject *self, PyObject * args) if (!PyArg_ParseTuple(args, "s", &expr)) return nullptr; + // HINT: + // The standard behaviour of Python for class methods is to always pass the class + // object as first argument. + // For FreeCAD-specific types the behaviour is a bit different: + // When calling this method for an instance then this is passed as first argument + // and otherwise the class object is passed. + // This behaviour is achieved by the function _getattr() that passed 'this' to + // PyCFunction_New(). + // // evalExpression() is a class method and thus 'self' can either be an instance of // DocumentObjectPy or a type object. App::DocumentObject* obj = nullptr;