diff options
Diffstat (limited to 'sources/pyside6/PySide6')
3 files changed, 53 insertions, 4 deletions
diff --git a/sources/pyside6/PySide6/QtRemoteObjects/CMakeLists.txt b/sources/pyside6/PySide6/QtRemoteObjects/CMakeLists.txt index 07835b2f6..2522ab54f 100644 --- a/sources/pyside6/PySide6/QtRemoteObjects/CMakeLists.txt +++ b/sources/pyside6/PySide6/QtRemoteObjects/CMakeLists.txt @@ -29,20 +29,23 @@ ${QtRemoteObjects_GEN_DIR}/qtroserveriodevice_wrapper.cpp ${QtRemoteObjects_GEN_DIR}/qtremoteobjects_module_wrapper.cpp ) +find_package(Qt6 REQUIRED COMPONENTS Core) + set(QtRemoteObjects_include_dirs ${QtRemoteObjects_SOURCE_DIR} ${QtRemoteObjects_BINARY_DIR} ${Qt${QT_MAJOR_VERSION}RemoteObjects_INCLUDE_DIRS} + ${libpysideremoteobjects_SOURCE_DIR} ${SHIBOKEN_INCLUDE_DIR} ${libpyside_SOURCE_DIR} ${SHIBOKEN_PYTHON_INCLUDE_DIR} ${QtCore_GEN_DIR} ${QtNetwork_GEN_DIR}) -set(QtRemoteObjects_libraries pyside6 - ${Qt${QT_MAJOR_VERSION}RemoteObjects_LIBRARIES}) - set(QtRemoteObjects_deps QtCore QtNetwork) +set(QtRemoteObjects_libraries pyside6 pyside6remoteobjects + ${Qt${QT_MAJOR_VERSION}RemoteObjects_LIBRARIES}) + create_pyside_module(NAME QtRemoteObjects INCLUDE_DIRS QtRemoteObjects_include_dirs LIBRARIES QtRemoteObjects_libraries diff --git a/sources/pyside6/PySide6/QtRemoteObjects/typesystem_remoteobjects.xml b/sources/pyside6/PySide6/QtRemoteObjects/typesystem_remoteobjects.xml index 86e4d9093..a6e54ee18 100644 --- a/sources/pyside6/PySide6/QtRemoteObjects/typesystem_remoteobjects.xml +++ b/sources/pyside6/PySide6/QtRemoteObjects/typesystem_remoteobjects.xml @@ -8,6 +8,9 @@ <load-typesystem name="templates/core_common.xml" generate="no"/> <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/> <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/> + <inject-code class="native" position="beginning"> + #include "pysideremoteobjects.h" + </inject-code> <rejection class="QRemoteObjectStringLiterals"/> <rejection class="*" function-name="getTypeNameAndMetaobjectFromClassInfo"/> @@ -26,6 +29,10 @@ </object-type> <object-type name="QRemoteObjectNode"> <enum-type name="ErrorCode"/> + <add-function signature="acquire(PyTypeObject*, PyObject* @name@ = 0)" + return-type="PyTypeObject*"> + <inject-code class="target" file="../glue/qtremoteobjects.cpp" snippet="node-acquire"/> + </add-function> </object-type> <object-type name="QRemoteObjectPendingCall"> <enum-type name="Error"/> @@ -35,7 +42,12 @@ <object-type name="QRemoteObjectRegistryHost"/> <object-type name="QRemoteObjectReplica"> <enum-type name="State"/> - <!-- protected: <enum-type name="ConstructorType"/> --> + <enum-type name="ConstructorType" python-type="IntEnum"/> <!-- Needed even though protected --> + <modify-function signature="QRemoteObjectReplica(QRemoteObjectReplica::ConstructorType)"> + <modify-argument index="1"> + <replace-default-expression with="{}"/> + </modify-argument> + </modify-function> </object-type> <object-type name="QRemoteObjectSettingsStore"/> <value-type name="QRemoteObjectSourceLocationInfo"/> @@ -53,4 +65,7 @@ <!-- QtNetwork is pulled in via QtRemoteObjectsDepends. --> <suppress-warning text="^Scoped enum 'Q(Ocsp)|(Dtls).*' does not have a type entry.*$"/> + <inject-code class="target" position="end" + file="../glue/qtremoteobjects.cpp" snippet="qtro-init"/> + </typesystem> diff --git a/sources/pyside6/PySide6/glue/qtremoteobjects.cpp b/sources/pyside6/PySide6/glue/qtremoteobjects.cpp new file mode 100644 index 000000000..88d585892 --- /dev/null +++ b/sources/pyside6/PySide6/glue/qtremoteobjects.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Ford Motor Company +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// @snippet qtro-init +PySide::RemoteObjects::init(module); +// @snippet qtro-init + +// @snippet node-acquire +auto *typeObject = reinterpret_cast<PyTypeObject*>(%PYARG_1); +if (!PySide::inherits(typeObject, SbkPySide6_QtRemoteObjectsTypeStructs[SBK_QRemoteObjectReplica_IDX].fullName)) { + PyErr_SetString(PyExc_TypeError, "First argument must be a type deriving from QRemoteObjectReplica."); + return nullptr; +} + +static PyObject *pyConstructWithNode = Shiboken::Enum::newItem( + Shiboken::Module::get(SbkPySide6_QtRemoteObjectsTypeStructs[SBK_QRemoteObjectReplica_ConstructorType_IDX]), + 1 /* protected QRemoteObjectReplica::ConstructorType::ConstructWithNode */ +); + +Shiboken::AutoDecRef args; +if (pyArgs[1]) + args.reset(PyTuple_Pack(3, %PYSELF, pyConstructWithNode, pyArgs[1])); +else + args.reset(PyTuple_Pack(2, %PYSELF, pyConstructWithNode)); + +PyObject *instance = PyObject_CallObject(%PYARG_1, args.object()); +if (!instance) + return nullptr; // Propagate the exception + +%PYARG_0 = instance; +// @snippet node-acquire |
