aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/doc/typesystem_codeinjection.rst
diff options
context:
space:
mode:
authorSimo Fält <simo.falt@qt.io>2023-05-25 11:12:40 +0300
committerSimo Fält <simo.falt@qt.io>2023-05-25 11:12:40 +0300
commitca0519cb3f6b62e3b61ba74f0c60eac891dd3a15 (patch)
tree46e94d1b9a77648ca080a36b7d266f2322031d67 /sources/shiboken2/doc/typesystem_codeinjection.rst
parent72d32f66685fbb7fefc41eee629e63f4824cb10b (diff)
parent7c386888b453b7f2ac78ef1da59d077b25e372b3 (diff)
Merge tag 'v5.15.4-lts' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Qt For Python Release 5.15.4 Change-Id: I8457501ba90fc481fb9de686eb8a2f880ecc06cd
Diffstat (limited to 'sources/shiboken2/doc/typesystem_codeinjection.rst')
-rw-r--r--sources/shiboken2/doc/typesystem_codeinjection.rst20
1 files changed, 12 insertions, 8 deletions
diff --git a/sources/shiboken2/doc/typesystem_codeinjection.rst b/sources/shiboken2/doc/typesystem_codeinjection.rst
index b0d5f3851..836609508 100644
--- a/sources/shiboken2/doc/typesystem_codeinjection.rst
+++ b/sources/shiboken2/doc/typesystem_codeinjection.rst
@@ -112,7 +112,8 @@ Below is the example C++ class for whom wrapper code will be generated.
.. code-block:: c++
- class InjectCode {
+ class InjectCode
+ {
public:
InjectCode();
double overloadedMethod(int arg);
@@ -124,6 +125,10 @@ From the C++ class, |project| will generate a ``injectcode_wrapper.cpp`` file
with the binding code. The next section will use a simplified version of the
generated wrapper code with the injection spots marked with comments.
+There are a number of placeholders indicated by a percent sign ``%``, which
+will be expanded when inserting the code. For a list, see
+:ref:`typesystemvariables`.
+
Noteworthy Cases
----------------
@@ -196,7 +201,7 @@ class is polymorphic.
int InjectCodeWrapper::virtualMethod(int arg)
{
- PyObject* method = BindingManager::instance().getOverride(this, "virtualMethod");
+ PyObject *method = BindingManager::instance().getOverride(this, "virtualMethod");
if (!py_override)
return this->InjectCode::virtualMethod(arg);
@@ -228,10 +233,9 @@ own ``beginning`` and ``end`` code injections.
.. code-block:: c++
- static PyObject*
- PyInjectCode_overloadedMethod(PyObject* self, PyObject* arg)
+ static PyObject *PyInjectCode_overloadedMethod(PyObject *self, PyObject *arg)
{
- PyObject* py_result = 0;
+ PyObject* py_result{};
if (PyFloat_Check(arg)) {
double cpp_arg0 = Shiboken::Converter<double >::toCpp(arg);
@@ -250,13 +254,13 @@ own ``beginning`` and ``end`` code injections.
} else goto PyInjectCode_overloadedMethod_TypeError;
if (PyErr_Occurred() || !py_result)
- return 0;
+ return {};
return py_result;
PyInjectCode_overloadedMethod_TypeError:
PyErr_SetString(PyExc_TypeError, "'overloadedMethod()' called with wrong parameters.");
- return 0;
+ return {};
}
@@ -371,7 +375,7 @@ to prevent bad custom code to pass unnoticed.
// INJECT-CODE: <typesystem><inject-code class="target" position="beginning">
// Uses: do something before the module is created.
- PyObject* module = Py_InitModule("MODULENAME", MODULENAME_methods);
+ PyObject *module = Py_InitModule("MODULENAME", MODULENAME_methods);
(... initialization of wrapped classes, namespaces, functions and enums ...)