diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-05-25 15:46:13 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-24 14:47:58 +0200 |
commit | 23fdccf7f3d4ace5b0cb9f04d9b941a1235629b8 (patch) | |
tree | ae57cde18d0c43ff09e49fa449187b7cc4accde0 /src/qml/qml/qqml.cpp | |
parent | 1b6069798aa7088457eb5e033aa2fa1d809ec3e4 (diff) |
QmlCompiler: Inline translation methods
We hardcode them into QQmlJSTypePropagator and QQmlJSCodegenerator for
now. This is OK for builtins.
Task-number: QTBUG-101387
Change-Id: Ifab46083b3a782f009859ce969c283d5bb2b4e8b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r-- | src/qml/qml/qqml.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 2f037548a8..aee0020a67 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -19,6 +19,7 @@ #include <private/qv4qobjectwrapper_p.h> #include <private/qv4identifiertable_p.h> #include <private/qv4errorobject_p.h> +#include <private/qqmlbuiltinfunctions_p.h> #include <private/qqmlfinalizer_p.h> #include <QtCore/qmutex.h> @@ -763,18 +764,26 @@ void AOTCompiledContext::setReturnValueUndefined() const } } -static void captureFallbackProperty( - QObject *object, int coreIndex, int notifyIndex, bool isConstant, - QQmlContextData *qmlContext) +static QQmlPropertyCapture *propertyCapture(const QQmlContextData *qmlContext) { - if (!qmlContext || isConstant) - return; + if (!qmlContext) + return nullptr; QQmlEngine *engine = qmlContext->engine(); Q_ASSERT(engine); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); Q_ASSERT(ep); - if (QQmlPropertyCapture *capture = ep->propertyCapture) + return ep->propertyCapture; +} + +static void captureFallbackProperty( + QObject *object, int coreIndex, int notifyIndex, bool isConstant, + const QQmlContextData *qmlContext) +{ + if (isConstant) + return; + + if (QQmlPropertyCapture *capture = propertyCapture(qmlContext)) capture->captureProperty(object, coreIndex, notifyIndex); } @@ -782,14 +791,10 @@ static void captureObjectProperty( QObject *object, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *property, QQmlContextData *qmlContext) { - if (!qmlContext || property->isConstant()) + if (property->isConstant()) return; - QQmlEngine *engine = qmlContext->engine(); - Q_ASSERT(engine); - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - Q_ASSERT(ep); - if (QQmlPropertyCapture *capture = ep->propertyCapture) + if (QQmlPropertyCapture *capture = propertyCapture(qmlContext)) capture->captureProperty(object, propertyCache, property); } @@ -1059,6 +1064,21 @@ bool AOTCompiledContext::captureQmlContextPropertyLookup(uint index) const return false; } +void AOTCompiledContext::captureTranslation() const +{ + if (QQmlPropertyCapture *capture = propertyCapture(qmlContext)) + capture->captureTranslation(); +} + +QString AOTCompiledContext::translationContext() const +{ +#if QT_CONFIG(translation) + return QV4::GlobalExtensions::currentTranslationContext(engine->handle()); +#else + return QString(); +#endif +} + QMetaType AOTCompiledContext::lookupResultMetaType(uint index) const { QV4::Lookup *l = compilationUnit->runtimeLookups + index; |