aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/doc/considerations.rst
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/doc/considerations.rst')
-rw-r--r--sources/shiboken6/doc/considerations.rst72
1 files changed, 42 insertions, 30 deletions
diff --git a/sources/shiboken6/doc/considerations.rst b/sources/shiboken6/doc/considerations.rst
index abab2c28d..ad913e7a6 100644
--- a/sources/shiboken6/doc/considerations.rst
+++ b/sources/shiboken6/doc/considerations.rst
@@ -6,6 +6,18 @@ Words of Advice
When writing or using Python bindings there is some things you must keep in mind.
+.. _rvalue_references:
+
+Rvalue References
+=================
+
+Normally, no bindings are generated for functions taking rvalue references.
+Experimental support has been added in 6.6. The functions need to be explicitly
+specified using the :ref:`add-function`, :ref:`declare-function` or
+:ref:`function` elements. For :ref:`value-type` objects, this does not have any
+implications since the arguments are copied in the generated code and the copy
+is moved from. For :ref:`object-type` objects however, it means that the object
+instance is moved from and should no longer be referenced.
.. _duck-punching-and-virtual-methods:
@@ -18,19 +30,19 @@ be tricky. That was an optimistic statement.
Let's see duck punching in action for educational purposes.
- .. code-block:: python
+.. code-block:: python
- import types
- import Binding
+ import types
+ import Binding
- obj = Binding.CppClass()
+ obj = Binding.CppClass()
- # CppClass has a virtual method called 'virtualMethod',
- # but we don't like it anymore.
- def myVirtualMethod(self_obj, arg):
- pass
+ # CppClass has a virtual method called 'virtualMethod',
+ # but we don't like it anymore.
+ def myVirtualMethod(self_obj, arg):
+ pass
- obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
+ obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
If some C++ code happens to call `CppClass::virtualMethod(...)` on the C++ object
@@ -46,17 +58,17 @@ Python-land by the usage of class constructors, like in the example above.
Brief interruption to show what I was saying:
- .. code-block:: python
+.. code-block:: python
- import types
- import Binding
+ import types
+ import Binding
- obj = Binding.createCppClass()
- def myVirtualMethod(self_obj, arg):
- pass
+ obj = Binding.createCppClass()
+ def myVirtualMethod(self_obj, arg):
+ pass
- # Punching a dead duck...
- obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
+ # Punching a dead duck...
+ obj.virtualMethod = types.MethodType(myVirtualMethod, obj, Binding.CppClass)
The `Binding.createCppClass()` factory method is just an example, C++ created objects
@@ -82,30 +94,30 @@ Below you can check the examples:
Example with old style class:
- .. code-block:: python
+.. code-block:: python
- from PySide6 import QtCore
+ from PySide6 import QtCore
- class MyOldStyleObject:
- pass
+ class MyOldStyleObject:
+ pass
- class MyObject(QtCore, MyOldStyleObject):
- pass
+ class MyObject(QtCore, MyOldStyleObject):
+ pass
this example will raise a 'TypeError' due to the limitation on PySide, to fix
this you will need use the new style class:
- .. code-block:: python
+.. code-block:: python
- from PySide6 import QtCore
+ from PySide6 import QtCore
- class MyOldStyleObject(object):
- pass
+ class MyOldStyleObject(object):
+ pass
- class MyObject(QtCore, MyOldStyleObject):
- pass
+ class MyObject(QtCore, MyOldStyleObject):
+ pass
All classes used for multiple inheritance with other PySide types need to have
@@ -181,4 +193,4 @@ What is 'inject code'?
That's how we call customized code that will be *injected* into the
generated at specific locations. They are specified inside the typesystem.
-.. _`Mailing list`: http://lists.qt-project.org/mailman/listinfo/pyside
+.. _`Mailing list`: https://lists.qt-project.org/mailman/listinfo/pyside