diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-11 10:17:52 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-12 20:32:59 +0200 |
commit | 99c7fe45be00b694da4041c5a06e5484f2985dc6 (patch) | |
tree | 9e8a9d6cf436ae5f49a12249cf0ae0b160403ea3 /src/qml | |
parent | 235bbe8c644415a83e3f5103eff7c4ef4181164a (diff) |
QtQml: Add a wrapper builtin for QQmlV4Function*
This way qmltyperegistrar can recognize it and refrain from warning
about it.
Task-number: QTBUG-101143
Change-Id: I598140e7e90dbd3e27a78c26eff3d46f0fd3e989
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlbuiltinfunctions.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlbuiltinfunctions_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue_p.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlprivate.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertydata_p.h | 2 | ||||
-rw-r--r-- | src/qml/qqmlbuiltins_p.h | 8 |
14 files changed, 31 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 102700e25b..8e1bd24f6b 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -75,7 +75,7 @@ namespace QV4 { struct QObjectMethod; } // class MyClass : public QObject { // Q_OBJECT // ... -// Q_INVOKABLE void myMethod(QQmlV4Function*); +// Q_INVOKABLE void myMethod(QQmlV4FunctionPtr); // }; // The QQmlV8Function - and consequently the arguments and return value - only remains // valid during the call. If the return value isn't set within myMethod(), the will return diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 13b558e6b1..a16a9cab28 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -2953,7 +2953,7 @@ ReturnedValue QObjectMethod::callInternal(const Value *thisObject, const Value * return doCall([&]() { ScopedValue rv(scope, Value::undefinedValue()); QQmlV4Function func(callData, rv, v4); - QQmlV4Function *funcptr = &func; + QQmlV4FunctionPtr funcptr = &func; void *args[] = { nullptr, &funcptr }; object.metacall(QMetaObject::InvokeMetaMethod, method->coreIndex(), args); diff --git a/src/qml/qml/qqmlbuiltinfunctions.cpp b/src/qml/qml/qqmlbuiltinfunctions.cpp index 9e07879833..5c6daa0969 100644 --- a/src/qml/qml/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/qqmlbuiltinfunctions.cpp @@ -1688,7 +1688,7 @@ QJSValue QtObject::binding(const QJSValue &function) const Encode(e->memoryManager->allocate<QQmlBindingFunction>(f))); } -void QtObject::callLater(QQmlV4Function *args) +void QtObject::callLater(QQmlV4FunctionPtr args) { m_engine->delayedCallQueue()->addUniquelyAndExecuteLater(m_engine, args); } diff --git a/src/qml/qml/qqmlbuiltinfunctions_p.h b/src/qml/qml/qqmlbuiltinfunctions_p.h index 5a49db62aa..9ceedad28b 100644 --- a/src/qml/qml/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/qqmlbuiltinfunctions_p.h @@ -154,7 +154,7 @@ public: QObject *parent = nullptr) const; Q_INVOKABLE QJSValue binding(const QJSValue &function) const; - Q_INVOKABLE void callLater(QQmlV4Function *args); + Q_INVOKABLE void callLater(QQmlV4FunctionPtr args); #if QT_CONFIG(translation) QString uiLanguage() const; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 7d691db750..8574c96bc1 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1740,7 +1740,7 @@ QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(const RequiredP /*! \internal */ -void QQmlComponent::createObject(QQmlV4Function *args) +void QQmlComponent::createObject(QQmlV4FunctionPtr args) { Q_D(QQmlComponent); Q_ASSERT(d->engine); @@ -1889,7 +1889,7 @@ QObject *QQmlComponent::createObject(QObject *parent, const QVariantMap &propert /*! \internal */ -void QQmlComponent::incubateObject(QQmlV4Function *args) +void QQmlComponent::incubateObject(QQmlV4FunctionPtr args) { Q_D(QQmlComponent); Q_ASSERT(d->engine); diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h index e435aa2894..2d68c47c11 100644 --- a/src/qml/qml/qqmlcomponent.h +++ b/src/qml/qml/qqmlcomponent.h @@ -21,7 +21,6 @@ class QByteArray; class QQmlEngine; class QQmlComponent; class QQmlIncubator; -class QQmlV4Function; class QQmlComponentPrivate; class QQmlComponentAttached; @@ -102,12 +101,12 @@ protected: #if QT_DEPRECATED_SINCE(6, 3) QT_DEPRECATED_X("Use the overload with proper arguments") - Q_INVOKABLE void createObject(QQmlV4Function *); + Q_INVOKABLE void createObject(QQmlV4FunctionPtr); #endif Q_INVOKABLE QObject *createObject( QObject *parent = nullptr, const QVariantMap &properties = {}); - Q_INVOKABLE void incubateObject(QQmlV4Function *); + Q_INVOKABLE void incubateObject(QQmlV4FunctionPtr); private: QQmlComponent(QQmlEngine *, QV4::ExecutableCompilationUnit *compilationUnit, int, diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 96a5679599..efd8519a58 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -70,7 +70,7 @@ void QQmlDelayedCallQueue::init(QV4::ExecutionEngine* engine) m_tickedMethod = metaObject.method(methodIndex); } -QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine, QQmlV4Function *args) +QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine, QQmlV4FunctionPtr args) { QQmlDelayedCallQueue *self = engine->delayedCallQueue(); @@ -142,7 +142,7 @@ QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(QV4::Executi return QV4::Encode::undefined(); } -void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, QQmlV4Function *args, int offset, QV4::ExecutionEngine *engine) +void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, QQmlV4FunctionPtr args, int offset, QV4::ExecutionEngine *engine) { const int length = args->length() - offset; if (length == 0) { diff --git a/src/qml/qml/qqmldelayedcallqueue_p.h b/src/qml/qml/qqmldelayedcallqueue_p.h index 9b66e85a14..88f0c4d118 100644 --- a/src/qml/qml/qqmldelayedcallqueue_p.h +++ b/src/qml/qml/qqmldelayedcallqueue_p.h @@ -24,8 +24,6 @@ QT_BEGIN_NAMESPACE -class QQmlV4Function; - class QQmlDelayedCallQueue : public QObject { Q_OBJECT @@ -36,7 +34,7 @@ public: void init(QV4::ExecutionEngine *); static QV4::ReturnedValue addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine, - QQmlV4Function *args); + QQmlV4FunctionPtr args); public Q_SLOTS: void ticked(); @@ -56,7 +54,7 @@ private: bool m_guarded; }; - void storeAnyArguments(DelayedFunctionCall& dfc, QQmlV4Function *args, int offset, QV4::ExecutionEngine *engine); + void storeAnyArguments(DelayedFunctionCall& dfc, QQmlV4FunctionPtr args, int offset, QV4::ExecutionEngine *engine); void executeAllExpired_Later(); QV4::ExecutionEngine *m_engine; diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 50c460860b..3249f5a6eb 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -434,7 +434,7 @@ ReturnedValue QQmlNumberExtension::method_fromLocaleString(const QV4::FunctionOb //-------------- // Locale object -void QQmlLocaleValueType::formattedDataSize(QQmlV4Function *args) const +void QQmlLocaleValueType::formattedDataSize(QQmlV4FunctionPtr args) const { QV4::Scope scope(args->v4engine()); const auto doThrow = [&](const QString &message) { @@ -520,7 +520,7 @@ QList<QQmlLocale::DayOfWeek> QQmlLocaleValueType::weekDays() const return result; } -void QQmlLocaleValueType::toString(QQmlV4Function *args) const +void QQmlLocaleValueType::toString(QQmlV4FunctionPtr args) const { Scope scope(args->v4engine()); const auto doThrow = [&](const QString &message) { diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index 0fc9338015..5d26bf8a68 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -171,7 +171,7 @@ public: return locale.standaloneDayName(index == 0 ? 7 : index, format); } - Q_INVOKABLE void formattedDataSize(QQmlV4Function *args) const; + Q_INVOKABLE void formattedDataSize(QQmlV4FunctionPtr args) const; Q_INVOKABLE QString formattedDataSize( double bytes, int precision = 2, QLocale::DataSizeFormats format = QLocale::DataSizeIecFormat) const @@ -180,7 +180,7 @@ public: qint64(QV4::Value::toInteger(bytes)), precision, format); } - Q_INVOKABLE void toString(QQmlV4Function *args) const; + Q_INVOKABLE void toString(QQmlV4FunctionPtr args) const; // As a special (undocumented) case, when called with no arguments, // just forward to QDebug. This makes it consistent with other types diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index d7e1676633..93837741e1 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -82,6 +82,9 @@ class QQmlEngine; class QQmlCustomParser; class QQmlTypeNotAvailable; +class QQmlV4Function; +using QQmlV4FunctionPtr = QQmlV4Function *; + template<class T> QQmlCustomParser *qmlCreateCustomParser() { @@ -1152,4 +1155,6 @@ namespace QQmlPrivate QT_END_NAMESPACE +Q_DECLARE_OPAQUE_POINTER(QQmlV4FunctionPtr) + #endif // QQMLPRIVATE_H diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 14929d9a36..a225f94a3f 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -111,7 +111,7 @@ void QQmlPropertyData::load(const QMetaMethod &m) m_flags.setHasArguments(true); m_flags.setIsV4Function( paramCount == 1 && - m.parameterMetaType(0) == QMetaType::fromType<QQmlV4Function *>()); + m.parameterMetaType(0) == QMetaType::fromType<QQmlV4FunctionPtr>()); } else { m_flags.setHasArguments(false); m_flags.setIsV4Function(false); diff --git a/src/qml/qml/qqmlpropertydata_p.h b/src/qml/qml/qqmlpropertydata_p.h index 760e577ae1..0fa7984f05 100644 --- a/src/qml/qml/qqmlpropertydata_p.h +++ b/src/qml/qml/qqmlpropertydata_p.h @@ -71,7 +71,7 @@ public: unsigned isWritableORhasArguments : 1; // Has WRITE function OR Function takes arguments unsigned isResettableORisSignal : 1; // Has RESET function OR Function is a signal unsigned isAliasORisVMESignal : 1; // Is a QML alias to another property OR Signal was added by QML - unsigned isFinalORisV4Function : 1; // Has FINAL flag OR Function takes QQmlV4Function* args + unsigned isFinalORisV4Function : 1; // Has FINAL flag OR Function takes QQmlV4FunctionPtr args unsigned isSignalHandler : 1; // Function is a signal handler // TODO: Remove this once we can. Signals should not be overridable. diff --git a/src/qml/qqmlbuiltins_p.h b/src/qml/qqmlbuiltins_p.h index 7ce07eb41c..40375655ad 100644 --- a/src/qml/qqmlbuiltins_p.h +++ b/src/qml/qqmlbuiltins_p.h @@ -301,6 +301,14 @@ struct QQmlScriptStringForeign QML_FOREIGN(QQmlScriptString) }; +struct QQmlV4FunctionPtrForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QQmlV4FunctionPtr) + QML_EXTENDED(QQmlV4FunctionPtrForeign) +}; + QT_END_NAMESPACE #endif // QQMLBUILTINS_H |