aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtserialbus.cpp
blob: b5b491f49de589f155b45a7f745274c0747c90f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

/*********************************************************************
 * INJECT CODE
 ********************************************************************/

// @snippet qcanbus-available-devices
QString errorMessage;
const QList<QCanBusDeviceInfo> result = %CPPSELF.%FUNCTION_NAME(%1, &errorMessage);
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QList<QCanBusDeviceInfo>](result));
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](errorMessage));
// @snippet qcanbus-available-devices

// @snippet qcanbus-createdevice
PyObject *pyDevice{};
QString errorMessage;
if (auto *device = %CPPSELF.%FUNCTION_NAME(%1, %2, &errorMessage)) {
    pyDevice = %CONVERTTOPYTHON[%RETURN_TYPE](device);
    // Ownership transferences (target)
    Shiboken::Object::getOwnership(pyDevice);
} else {
    pyDevice = Py_None;
    Py_INCREF(pyDevice);
}
%PYARG_0 = PyTuple_New(2);
PyTuple_SET_ITEM(%PYARG_0, 0, pyDevice);
PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](errorMessage));
// @snippet qcanbus-createdevice