From d375273ba0d6fed567a5b8cc386395b10f5f2bda Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 7 Apr 2022 12:49:19 +0200 Subject: shiboken6: Enable adding modifications to declare-function Amends 40483a4249306b62029987d03e7de57d456954b2. Pick-to: 6.2 Task-number: PYSIDE-1627 Change-Id: I1521e7436749fb95f282a07539310257dca3918f Reviewed-by: Shyamnath Premnadh Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken6/ApiExtractor/typesystemparser.cpp | 12 +++++++----- sources/shiboken6/doc/typesystem_manipulating_objects.rst | 3 ++- sources/shiboken6/doc/typesystem_modify_function.rst | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp index 9ab7118cc..b6ff7f014 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp @@ -935,7 +935,8 @@ bool TypeSystemParser::endElement(StackElement element) } break; - case StackElement::AddFunction: { + case StackElement::AddFunction: + case StackElement::DeclareFunction: { // Leaving add-function: Assign all modifications to the added function const int modIndex = top->addedFunctionModificationIndex; top->addedFunctionModificationIndex = -1; @@ -2250,10 +2251,11 @@ bool TypeSystemParser::parseModifyArgument(const ConditionalStreamReader &, StackElement topElement, QXmlStreamAttributes *attributes) { if (topElement != StackElement::ModifyFunction - && topElement != StackElement::AddFunction) { - m_error = QString::fromLatin1("argument modification requires function" - " modification as parent, was %1") - .arg(tagFromElement(topElement)); + && topElement != StackElement::AddFunction + && topElement != StackElement::DeclareFunction) { + m_error = u"Argument modification requires ," + " or as parent, was "_qs + + tagFromElement(topElement).toString(); return false; } diff --git a/sources/shiboken6/doc/typesystem_manipulating_objects.rst b/sources/shiboken6/doc/typesystem_manipulating_objects.rst index e37d04718..2ee3c2ddf 100644 --- a/sources/shiboken6/doc/typesystem_manipulating_objects.rst +++ b/sources/shiboken6/doc/typesystem_manipulating_objects.rst @@ -261,6 +261,7 @@ add-function language, and it is a child of an :ref:`object-type` or :ref:`value-type` nodes if the function is supposed to be a method, or :ref:`namespace` and :ref:`typesystem` if the function is supposed to be a function inside a namespace or a global function. + It may contain :ref:`modify-argument` nodes. Typically when adding a function some code must be injected to provide the function logic. This can be done using the :ref:`inject-code` node. @@ -313,7 +314,7 @@ declare-function the type and it is a child of an :ref:`object-type` or :ref:`value-type` nodes if the function is supposed to be a method, or :ref:`namespace` and :ref:`typesystem` if the function is supposed to be a function inside a - namespace or a global function. + namespace or a global function. It may contain :ref:`modify-argument` nodes. .. code-block:: xml diff --git a/sources/shiboken6/doc/typesystem_modify_function.rst b/sources/shiboken6/doc/typesystem_modify_function.rst index 7de7abeb7..1e882f9c7 100644 --- a/sources/shiboken6/doc/typesystem_modify_function.rst +++ b/sources/shiboken6/doc/typesystem_modify_function.rst @@ -9,7 +9,8 @@ modify-argument ^^^^^^^^^^^^^^^ Function modifications consist of a list of ``modify-argument`` nodes - contained in a :ref:`modify-function` node. Use the :ref:`remove-argument`, + contained in :ref:`modify-function`, :ref:`add-function` or + :ref:`declare-function` nodes. Use the :ref:`remove-argument`, :ref:`replace-default-expression`, :ref:`remove-default-expression`, :ref:`replace-type`, :ref:`reference-count` and :ref:`define-ownership` nodes to specify the details of the modification. -- cgit v1.2.3