App: Fix ExtensionPython macro

This commit is contained in:
marioalexis
2025-05-25 18:58:48 -03:00
committed by Benjamin Nauck
parent 32ddaff649
commit 0cdf0af0c6
5 changed files with 24 additions and 15 deletions

View File

@@ -63,12 +63,12 @@ using ExtensionPython = ExtensionPythonT<App::Extension>;
Base::PyGILStateLocker lock; \
Py::Object result; \
try { \
Property* proxy = this->getExtendedContainer()->getPropertyByName("Proxy"); \
if (proxy && proxy->is<PropertyPythonObject>()) { \
Py::Object feature = static_cast<PropertyPythonObject*>(proxy)->getValue(); \
if (feature.hasAttr(std::string("function"))) { \
App::Property* proxy = this->getExtendedContainer()->getPropertyByName("Proxy"); \
if (proxy && proxy->is<App::PropertyPythonObject>()) { \
Py::Object feature = static_cast<App::PropertyPythonObject*>(proxy)->getValue(); \
if (feature.hasAttr(std::string(#function))) { \
if (feature.hasAttr("__object__")) { \
Py::Callable method(feature.getAttr(std::string("function")));
Py::Callable method(feature.getAttr(std::string(#function)));
#define EXTENSION_PROXY_SECOND(function) \
@@ -76,7 +76,7 @@ using ExtensionPython = ExtensionPythonT<App::Extension>;
} \
else \
{ \
Py::Callable method(feature.getAttr(std::string("function")));
Py::Callable method(feature.getAttr(std::string(#function)));
#define EXTENSION_PROXY_THIRD() \
result = method.apply(args); \
@@ -109,13 +109,13 @@ using ExtensionPython = ExtensionPythonT<App::Extension>;
EXTENSION_PROXY_THIRD()
#define EXTENSION_PYTHON_OVERRIDE_VOID_NOARGS(function) \
virtual void function() override { EXTENSION_PROXY_NOARGS(function) };
virtual void function() override { EXTENSION_PROXY_NOARG(function) };
#define EXTENSION_PYTHON_OVERRIDE_OBJECT_NOARGS(function) \
virtual PyObject* function() override \
{ \
EXTENSION_PROXY_NOARGS(function) \
return res.ptr(); \
EXTENSION_PROXY_NOARG(function) \
return result.ptr(); \
};
} // namespace App