diff options
Diffstat (limited to 'sources/pyside6/PySide6/QtQml')
-rw-r--r-- | sources/pyside6/PySide6/QtQml/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp | 53 | ||||
-rw-r--r-- | sources/pyside6/PySide6/QtQml/typesystem_qml.xml | 101 |
3 files changed, 110 insertions, 49 deletions
diff --git a/sources/pyside6/PySide6/QtQml/CMakeLists.txt b/sources/pyside6/PySide6/QtQml/CMakeLists.txt index a2a0af2cd..87de1d7dd 100644 --- a/sources/pyside6/PySide6/QtQml/CMakeLists.txt +++ b/sources/pyside6/PySide6/QtQml/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + project(QtQml) qt_wrap_cpp(QPYQMLPARSERSTATUS_MOC "${pyside6_SOURCE_DIR}/qpyqmlparserstatus.h") @@ -60,8 +63,6 @@ set(QtQml_include_dirs ${QtQml_SOURCE_DIR} ${QtQml_GEN_DIR}) set(QtQml_libraries pyside6 pyside6qml - ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} - ${Qt${QT_MAJOR_VERSION}Network_LIBRARIES} ${Qt${QT_MAJOR_VERSION}Qml_LIBRARIES}) set(QtQml_deps QtNetwork) diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp index d498f5bb0..ca3dfebed 100644 --- a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp +++ b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp @@ -3,6 +3,7 @@ #include "pysideqmlvolatilebool.h" +#include <pep384ext.h> #include <signature.h> #include <QtCore/QDebug> @@ -30,8 +31,7 @@ QtQml_VolatileBoolObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (ok < 0) return nullptr; - QtQml_VolatileBoolObject *self - = reinterpret_cast<QtQml_VolatileBoolObject *>(type->tp_alloc(type, 0)); + auto *self = PepExt_TypeCallAlloc<QtQml_VolatileBoolObject>(type, 0); if (self != nullptr) self->flag = new AtomicBool(ok); @@ -49,7 +49,10 @@ static void QtQml_VolatileBoolObject_dealloc(PyObject *self) static PyObject * QtQml_VolatileBoolObject_get(QtQml_VolatileBoolObject *self) { - return *self->flag ? Py_True : Py_False; + if (*self->flag) { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; } static PyObject * @@ -63,10 +66,8 @@ QtQml_VolatileBoolObject_set(QtQml_VolatileBoolObject *self, PyObject *args) } ok = PyObject_IsTrue(value); - if (ok < 0) { - PyErr_SetString(PyExc_TypeError, "Not a boolean value."); - return nullptr; - } + if (ok < 0) + return PyErr_Format(PyExc_TypeError, "Not a boolean value."); *self->flag = ok > 0; @@ -113,25 +114,31 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self) return s; } -static PyType_Slot QtQml_VolatileBoolType_slots[] = { - {Py_tp_repr, reinterpret_cast<void *>(QtQml_VolatileBoolObject_repr)}, - {Py_tp_str, reinterpret_cast<void *>(QtQml_VolatileBoolObject_str)}, - {Py_tp_methods, reinterpret_cast<void *>(QtQml_VolatileBoolObject_methods)}, - {Py_tp_new, reinterpret_cast<void *>(QtQml_VolatileBoolObject_new)}, - {Py_tp_dealloc, reinterpret_cast<void *>(QtQml_VolatileBoolObject_dealloc)}, - {0, 0} -}; -static PyType_Spec QtQml_VolatileBoolType_spec = { - "2:PySide6.QtQml.VolatileBool", - sizeof(QtQml_VolatileBoolObject), - 0, - Py_TPFLAGS_DEFAULT, - QtQml_VolatileBoolType_slots, -}; +static PyTypeObject *createVolatileBoolType() +{ + PyType_Slot QtQml_VolatileBoolType_slots[] = { + {Py_tp_repr, reinterpret_cast<void *>(QtQml_VolatileBoolObject_repr)}, + {Py_tp_str, reinterpret_cast<void *>(QtQml_VolatileBoolObject_str)}, + {Py_tp_methods, reinterpret_cast<void *>(QtQml_VolatileBoolObject_methods)}, + {Py_tp_new, reinterpret_cast<void *>(QtQml_VolatileBoolObject_new)}, + {Py_tp_dealloc, reinterpret_cast<void *>(QtQml_VolatileBoolObject_dealloc)}, + {0, 0} + }; + + PyType_Spec QtQml_VolatileBoolType_spec = { + "2:PySide6.QtQml.VolatileBool", + sizeof(QtQml_VolatileBoolObject), + 0, + Py_TPFLAGS_DEFAULT, + QtQml_VolatileBoolType_slots, + }; + + return SbkType_FromSpec(&QtQml_VolatileBoolType_spec); +} PyTypeObject *QtQml_VolatileBool_TypeF(void) { - static auto *type = SbkType_FromSpec(&QtQml_VolatileBoolType_spec); + static auto *type = createVolatileBoolType(); return type; } diff --git a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml index c59c353be..3392ef379 100644 --- a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml +++ b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml @@ -3,20 +3,23 @@ // Copyright (C) 2016 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 --> -<typesystem package="PySide6.QtQml"> +<typesystem package="PySide6.QtQml" + namespace-begin="QT_BEGIN_NAMESPACE" namespace-end="QT_END_NAMESPACE"> <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/> <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/> + <rejection class="QQmlPrivate"/> + <inject-code class="target" position="declaration"> // Volatile Bool Ptr type definition for QQmlIncubationController::incubateWhile(std::atomic<bool> *, int) #include <atomic> using AtomicBool = std::atomic<bool>; - typedef struct { + struct QtQml_VolatileBoolObject { PyObject_HEAD AtomicBool *flag; - } QtQml_VolatileBoolObject; + }; </inject-code> <inject-code class="native" position="beginning"> @@ -35,7 +38,7 @@ in generator tests folder. --> </primitive-type> - <enum-type name="QQmlModuleImportSpecialVersions" since="6.0"/> + <enum-type name="QQmlModuleImportSpecialVersions" doc-file="qqmlengine"/> <!-- expose QQmlIncubationController::incubateWhile() (see QtQml_VolatileBoolTypeF/pysideqmlvolatilebool.h) --> @@ -43,33 +46,51 @@ <value-type name="atomic" generate="no"/> </namespace-type> - <add-function signature="qmlAttachedPropertiesObject(PyTypeObject*,QObject*,bool=true)" + <add-function signature="qmlAttachedPropertiesObject(PyTypeObject*@type_obj@,QObject*,bool=true)" return-type="QObject*"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlattachedpropertiesobject"/> </add-function> - <add-function signature="qmlRegisterType(PyTypeObject,const char*,int,int,const char*)" return-type="int"> + <add-function signature="qmlRegisterType(PyTypeObject@type_obj@,const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistertype"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregistertype"/> + <modify-argument index="2" pyi-type="str"/> </add-function> - <add-function signature="qmlRegisterSingletonType(PyTypeObject,const char*,int,int,const char*,PyObject*)" return-type="int"> + <add-function signature="qmlRegisterSingletonType(PyTypeObject@type_obj@,const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@,PyObject*@callback@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qobject_callback"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregistersingletontype_qobject_callback"/> + <modify-argument index="2" pyi-type="str"/> </add-function> - <add-function signature="qmlRegisterSingletonType(PyTypeObject,const char*,int,int,const char*)" return-type="int"> + <add-function signature="qmlRegisterSingletonType(PyTypeObject@type_obj@,const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qobject_nocallback"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregistersingletontype_qobject_nocallback"/> + <modify-argument index="2" pyi-type="str"/> </add-function> - <add-function signature="qmlRegisterSingletonType(const char*,int,int,const char*,PyObject*)" return-type="int"> + <add-function signature="qmlRegisterSingletonType(const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@,PyObject*@callback@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletontype_qjsvalue"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregistersingletontype_qjsvalue"/> + <modify-argument index="1" pyi-type="str"/> </add-function> - <add-function signature="qmlRegisterSingletonInstance(PyTypeObject,const char*,int,int,const char*,PyObject*)" return-type="int"> + <add-function signature="qmlRegisterSingletonInstance(PyTypeObject@type_obj@,const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@,PyObject*@callback@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregistersingletoninstance"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregistersingletoninstance"/> + <modify-argument index="2" pyi-type="str"/> </add-function> - <add-function signature="qmlRegisterUncreatableType(PyTypeObject,const char*,int,int,const char*,const char*)" return-type="int"> + <add-function signature="qmlRegisterUncreatableType(PyTypeObject@type_obj@,const char*@uri@,int@version_major@,int@version_minor@,const char*@qml_name@,const char*@message@)" return-type="int"> <inject-code class="target" file="../glue/qtqml.cpp" snippet="qmlregisteruncreatabletype"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qmlregisteruncreatabletype"/> + <modify-argument index="2" pyi-type="str"/> </add-function> <add-function signature="QmlElement(PyObject*)" return-type="PyObject*"> @@ -89,7 +110,7 @@ <modify-argument index="return" pyi-type="Optional[PySide6.QtQml.QJSEngine]"/> </modify-function> </function> - <function signature="qmlClearTypeRegistrations()"/> + <function signature="qmlClearTypeRegistrations()" doc-file="qqmlengine"/> <function signature="qmlContext(const QObject*)"> <modify-function> <modify-argument index="return" pyi-type="Optional[PySide6.QtQml.QQmlContext]"/> @@ -100,12 +121,15 @@ <modify-argument index="return" pyi-type="Optional[PySide6.QtQml.QQmlEngine]"/> </modify-function> </function> - <function signature="qmlProtectModule(const char*,int)"/> - <function signature="qmlRegisterModule(const char*,int,int)"/> - <function signature="qmlTypeId(const char*,int,int,const char*)"/> - <function signature="qmlRegisterType(const QUrl &,const char *,int,int,const char *)"/> - <function signature="qmlRegisterSingletonType(const QUrl &,const char *,int,int,const char *)"/> - <function signature="qmlRegisterUncreatableMetaObject(const QMetaObject&,const char*,int,int, const char*,const QString&)"/> + <function signature="qmlProtectModule(const char*,int)" doc-file="qqmlengine"/> + <function signature="qmlRegisterModule(const char*,int,int)" doc-file="qqmlengine"/> + <function signature="qmlTypeId(const char*,int,int,const char*)" doc-file="qqmlengine"/> + <function signature="qmlRegisterType(const QUrl &,const char *,int,int,const char *)" + doc-file="qqmlengine"/> + <function signature="qmlRegisterSingletonType(const QUrl &,const char *,int,int,const char *)" + doc-file="qqmlengine"/> + <function signature="qmlRegisterUncreatableMetaObject(const QMetaObject&,const char*,int,int, const char*,const QString&)" + doc-file="qqmlengine"/> <enum-type identified-by-value="QML_HAS_ATTACHED_PROPERTIES"> <extra-includes> @@ -116,8 +140,8 @@ <inject-code class="target" position="end" file="../glue/qtqml.cpp" snippet="init"/> <object-type name="QJSEngine"> - <enum-type name="Extension" flags="Extensions" since="5.6"/> - <enum-type name="ObjectOwnership" since="6.0"/> + <enum-type name="Extension" flags="Extensions"/> + <enum-type name="ObjectOwnership"/> <add-function signature="toScriptValue(const QVariant&)" return-type="QJSValue"> <inject-code class="target" position="end" file="../glue/qtqml.cpp" snippet="qjsengine-toscriptvalue"/> </add-function> @@ -129,7 +153,7 @@ <enum-type name="Type"/> </value-type> <value-type name="QJSValue"> - <enum-type name="ErrorType" since="5.12"/> + <enum-type name="ErrorType"/> <enum-type name="SpecialValue"/> <enum-type name="ObjectConversionBehavior" since="6.1"/> </value-type> @@ -149,6 +173,7 @@ <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qfile-path-1"/> </modify-function> <modify-function signature="load(const QUrl &)" allow-thread="yes" overload-number="2"/> + <modify-function signature="loadFromModule(QAnyStringView,QAnyStringView)" allow-thread="yes"/> </object-type> <object-type name="QQmlComponent"> <enum-type name="CompilationMode"/> @@ -159,6 +184,10 @@ <modify-function signature="QQmlComponent(QQmlEngine*,QString,QQmlComponent::CompilationMode,QObject*)" allow-thread="yes"/> <modify-function signature="QQmlComponent(QQmlEngine*,QUrl,QObject*)" allow-thread="yes"/> <modify-function signature="QQmlComponent(QQmlEngine*,QUrl,QQmlComponent::CompilationMode,QObject*)" allow-thread="yes"/> + <modify-function signature="loadFromModule(QAnyStringView,QAnyStringView,QQmlComponent::CompilationMode)" allow-thread="yes"/> + <modify-function signature="loadUrl(QUrl)" allow-thread="yes"/> + <modify-function signature="loadUrl(QUrl,QQmlComponent::CompilationMode)" allow-thread="yes"/> + <modify-function signature="setData(QByteArray,QUrl)" allow-thread="yes"/> </object-type> <object-type name="QQmlContext"> <value-type name="PropertyPair"/> @@ -186,6 +215,30 @@ <modify-argument index="1"><replace-type modified-type="PyPathLike"/></modify-argument> <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qfile-path-1"/> </modify-function> + <add-function signature="singletonInstance(int@qmlTypeId@)" + return-type="QObject*"> + <!-- Suppress return value heuristics --> + <modify-argument index="return" + pyi-type="Union[PySide6.QtCore.QObject, PySide6.QtQml.QJSValue, None]"> + <define-ownership class="target" owner="default"/> + </modify-argument> + <inject-code class="target" file="../glue/qtqml.cpp" + snippet="qqmlengine-singletoninstance-qmltypeid"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qqmlengine-singletoninstance-qmltypeid"/> + </add-function> + <add-function signature="singletonInstance(QString@uri@,QString@typeName@)" + return-type="QObject*"> + <!-- Suppress return value heuristics --> + <modify-argument index="return" + pyi-type="Union[PySide6.QtCore.QObject, PySide6.QtQml.QJSValue, None]"> + <define-ownership class="target" owner="default"/> + </modify-argument> + <inject-code class="target" file="../glue/qtqml.cpp" + snippet="qqmlengine-singletoninstance-typename"/> + <inject-documentation format="target" mode="append" file="../doc/qtqml_functions.rst" + snippet="qqmlengine-singletoninstance-typename"/> + </add-function> </object-type> <object-type name="QQmlExpression"> @@ -193,7 +246,7 @@ <modify-argument index="1"> <remove-argument /> </modify-argument> - <modify-argument index="return"> + <modify-argument index="return" pyi-type="Tuple[Any, bool]"> <replace-type modified-type="PyTuple"/> </modify-argument> <inject-code class="target" position="beginning"> @@ -255,7 +308,7 @@ <modify-argument index="1"> <remove-argument /> </modify-argument> - <modify-argument index="return"> + <modify-argument index="return" pyi-type="Tuple[float, bool]"> <replace-type modified-type="PyTuple"/> </modify-argument> <inject-code class="target" position="beginning"> @@ -266,7 +319,7 @@ <modify-argument index="1"> <remove-argument /> </modify-argument> - <modify-argument index="return"> + <modify-argument index="return" pyi-type="Tuple[bool, bool]"> <replace-type modified-type="PyTuple"/> </modify-argument> <inject-code class="target" position="beginning"> |