2013-08-14 08:17:31 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-08-14 08:17:31 +00:00
|
|
|
**
|
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2013-08-14 08:17:31 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 09:38:36 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-08-14 08:17:31 +00:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2016-01-19 09:38:36 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
2013-08-14 08:17:31 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 2.0 or (at your option) the GNU General
|
|
|
|
** Public license version 3 or any later version approved by the KDE Free
|
|
|
|
** Qt Foundation. The licenses are as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
|
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-08-14 08:17:31 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "qv4compileddata_p.h"
|
|
|
|
#include "qv4jsir_p.h"
|
2015-02-14 21:46:41 +00:00
|
|
|
#include <private/qv4value_p.h>
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2013-08-14 08:17:37 +00:00
|
|
|
#include <private/qv4engine_p.h>
|
2013-08-14 13:44:53 +00:00
|
|
|
#include <private/qv4function_p.h>
|
2013-08-29 12:31:32 +00:00
|
|
|
#include <private/qv4objectproto_p.h>
|
2013-08-15 10:48:05 +00:00
|
|
|
#include <private/qv4lookup_p.h>
|
2013-08-15 13:54:36 +00:00
|
|
|
#include <private/qv4regexpobject_p.h>
|
2015-04-09 08:23:17 +00:00
|
|
|
#include <private/qqmlpropertycache_p.h>
|
2016-05-29 17:05:27 +00:00
|
|
|
#include <private/qqmltypeloader_p.h>
|
2016-05-29 17:21:54 +00:00
|
|
|
#include <private/qqmlengine_p.h>
|
|
|
|
#include <QQmlPropertyMap>
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif
|
2014-03-27 16:07:06 +00:00
|
|
|
#include <private/qqmlirbuilder_p.h>
|
2014-03-06 15:19:42 +00:00
|
|
|
#include <QCoreApplication>
|
2013-08-14 08:17:31 +00:00
|
|
|
|
2013-09-12 09:06:59 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2013-08-18 13:35:02 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2013-08-14 08:17:31 +00:00
|
|
|
namespace QV4 {
|
|
|
|
|
|
|
|
namespace CompiledData {
|
|
|
|
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2015-04-09 08:23:17 +00:00
|
|
|
CompilationUnit::CompilationUnit()
|
|
|
|
: data(0)
|
|
|
|
, engine(0)
|
|
|
|
, runtimeStrings(0)
|
|
|
|
, runtimeLookups(0)
|
|
|
|
, runtimeRegularExpressions(0)
|
|
|
|
, runtimeClasses(0)
|
2016-05-29 16:47:57 +00:00
|
|
|
, totalBindingsCount(0)
|
|
|
|
, totalParserStatusCount(0)
|
|
|
|
, totalObjectCount(0)
|
2016-05-29 16:58:07 +00:00
|
|
|
, metaTypeId(-1)
|
|
|
|
, listMetaTypeId(-1)
|
|
|
|
, isRegisteredWithEngine(false)
|
2015-04-09 08:23:17 +00:00
|
|
|
{}
|
|
|
|
|
2013-08-14 08:17:37 +00:00
|
|
|
CompilationUnit::~CompilationUnit()
|
|
|
|
{
|
2013-09-19 07:32:42 +00:00
|
|
|
unlink();
|
2016-05-20 13:22:31 +00:00
|
|
|
if (data && !(data->flags & QV4::CompiledData::Unit::StaticData))
|
2016-06-03 09:23:25 +00:00
|
|
|
free(const_cast<Unit *>(data));
|
2016-05-20 13:22:31 +00:00
|
|
|
data = 0;
|
2013-08-14 08:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
|
|
|
|
{
|
2013-08-15 12:11:19 +00:00
|
|
|
this->engine = engine;
|
|
|
|
engine->compilationUnits.insert(this);
|
|
|
|
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(!runtimeStrings);
|
|
|
|
Q_ASSERT(data);
|
2014-11-12 15:07:56 +00:00
|
|
|
runtimeStrings = (QV4::Heap::String **)malloc(data->stringTableSize * sizeof(QV4::Heap::String*));
|
2013-09-20 13:13:14 +00:00
|
|
|
// memset the strings to 0 in case a GC run happens while we're within the loop below
|
2014-11-12 15:07:56 +00:00
|
|
|
memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*));
|
|
|
|
for (uint i = 0; i < data->stringTableSize; ++i)
|
|
|
|
runtimeStrings[i] = engine->newIdentifier(data->stringAt(i));
|
2013-08-14 08:17:37 +00:00
|
|
|
|
2014-01-24 21:55:39 +00:00
|
|
|
runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
|
2013-09-20 13:13:14 +00:00
|
|
|
// memset the regexps to 0 in case a GC run happens while we're within the loop below
|
2014-01-24 21:55:39 +00:00
|
|
|
memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::Value));
|
2013-11-01 11:38:32 +00:00
|
|
|
for (uint i = 0; i < data->regexpTableSize; ++i) {
|
2013-08-15 13:54:36 +00:00
|
|
|
const CompiledData::RegExp *re = data->regexpAt(i);
|
|
|
|
int flags = 0;
|
|
|
|
if (re->flags & CompiledData::RegExp::RegExp_Global)
|
2014-02-14 12:58:40 +00:00
|
|
|
flags |= IR::RegExp::RegExp_Global;
|
2013-08-15 13:54:36 +00:00
|
|
|
if (re->flags & CompiledData::RegExp::RegExp_IgnoreCase)
|
2014-02-14 12:58:40 +00:00
|
|
|
flags |= IR::RegExp::RegExp_IgnoreCase;
|
2013-08-15 13:54:36 +00:00
|
|
|
if (re->flags & CompiledData::RegExp::RegExp_Multiline)
|
2014-02-14 12:58:40 +00:00
|
|
|
flags |= IR::RegExp::RegExp_Multiline;
|
2014-11-12 15:07:56 +00:00
|
|
|
runtimeRegularExpressions[i] = engine->newRegExpObject(data->stringAt(re->stringIndex), flags);
|
2013-08-15 13:54:36 +00:00
|
|
|
}
|
|
|
|
|
2013-08-15 10:48:05 +00:00
|
|
|
if (data->lookupTableSize) {
|
|
|
|
runtimeLookups = new QV4::Lookup[data->lookupTableSize];
|
2013-10-11 12:58:45 +00:00
|
|
|
memset(runtimeLookups, 0, data->lookupTableSize * sizeof(QV4::Lookup));
|
2013-08-15 10:48:05 +00:00
|
|
|
const CompiledData::Lookup *compiledLookups = data->lookupTable();
|
|
|
|
for (uint i = 0; i < data->lookupTableSize; ++i) {
|
|
|
|
QV4::Lookup *l = runtimeLookups + i;
|
|
|
|
|
2014-01-24 12:16:55 +00:00
|
|
|
Lookup::Type type = Lookup::Type(compiledLookups[i].type_and_flags);
|
|
|
|
if (type == CompiledData::Lookup::Type_Getter)
|
2013-08-15 10:48:05 +00:00
|
|
|
l->getter = QV4::Lookup::getterGeneric;
|
2014-01-24 12:16:55 +00:00
|
|
|
else if (type == CompiledData::Lookup::Type_Setter)
|
2013-08-15 10:48:05 +00:00
|
|
|
l->setter = QV4::Lookup::setterGeneric;
|
2014-01-24 12:16:55 +00:00
|
|
|
else if (type == CompiledData::Lookup::Type_GlobalGetter)
|
2013-08-15 10:48:05 +00:00
|
|
|
l->globalGetter = QV4::Lookup::globalGetterGeneric;
|
2014-01-24 12:16:55 +00:00
|
|
|
else if (type == CompiledData::Lookup::Type_IndexedGetter)
|
2014-01-17 11:19:34 +00:00
|
|
|
l->indexedGetter = QV4::Lookup::indexedGetterGeneric;
|
2014-01-24 12:16:55 +00:00
|
|
|
else if (type == CompiledData::Lookup::Type_IndexedSetter)
|
|
|
|
l->indexedSetter = QV4::Lookup::indexedSetterGeneric;
|
2013-08-15 10:48:05 +00:00
|
|
|
|
2013-11-01 11:38:32 +00:00
|
|
|
for (int j = 0; j < QV4::Lookup::Size; ++j)
|
|
|
|
l->classList[j] = 0;
|
2013-08-15 10:48:05 +00:00
|
|
|
l->level = -1;
|
|
|
|
l->index = UINT_MAX;
|
2014-11-12 15:07:56 +00:00
|
|
|
l->nameIndex = compiledLookups[i].nameIndex;
|
2014-01-24 12:16:55 +00:00
|
|
|
if (type == CompiledData::Lookup::Type_IndexedGetter || type == CompiledData::Lookup::Type_IndexedSetter)
|
2014-01-17 11:19:34 +00:00
|
|
|
l->engine = engine;
|
2013-08-15 10:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-16 11:21:31 +00:00
|
|
|
if (data->jsClassTableSize) {
|
|
|
|
runtimeClasses = (QV4::InternalClass**)malloc(data->jsClassTableSize * sizeof(QV4::InternalClass*));
|
2013-11-01 11:38:32 +00:00
|
|
|
for (uint i = 0; i < data->jsClassTableSize; ++i) {
|
2013-08-16 11:21:31 +00:00
|
|
|
int memberCount = 0;
|
|
|
|
const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount);
|
2015-01-10 19:35:18 +00:00
|
|
|
QV4::InternalClass *klass = engine->emptyClass;
|
2013-08-16 11:21:31 +00:00
|
|
|
for (int j = 0; j < memberCount; ++j, ++member)
|
2014-11-12 19:07:27 +00:00
|
|
|
klass = klass->addMember(runtimeStrings[member->nameOffset]->identifier, member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
|
2013-08-16 11:21:31 +00:00
|
|
|
|
|
|
|
runtimeClasses[i] = klass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-19 06:31:35 +00:00
|
|
|
linkBackendToEngine(engine);
|
2013-08-16 16:35:29 +00:00
|
|
|
|
2013-10-18 13:36:40 +00:00
|
|
|
if (data->indexOfRootFunction != -1)
|
|
|
|
return runtimeFunctions[data->indexOfRootFunction];
|
|
|
|
else
|
|
|
|
return 0;
|
2013-08-14 08:17:37 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 07:32:42 +00:00
|
|
|
void CompilationUnit::unlink()
|
|
|
|
{
|
|
|
|
if (engine)
|
|
|
|
engine->compilationUnits.erase(engine->compilationUnits.find(this));
|
2016-05-29 07:33:26 +00:00
|
|
|
|
2016-05-29 16:58:07 +00:00
|
|
|
if (isRegisteredWithEngine) {
|
2016-06-14 13:44:09 +00:00
|
|
|
Q_ASSERT(data && quint32(propertyCaches.count()) > data->indexOfRootObject && propertyCaches.at(data->indexOfRootObject));
|
2016-05-29 16:58:07 +00:00
|
|
|
QQmlEnginePrivate *qmlEngine = QQmlEnginePrivate::get(propertyCaches.at(data->indexOfRootObject)->engine);
|
|
|
|
qmlEngine->unregisterInternalCompositeType(this);
|
|
|
|
isRegisteredWithEngine = false;
|
|
|
|
}
|
|
|
|
|
2016-05-29 07:33:26 +00:00
|
|
|
propertyCaches.clear();
|
|
|
|
|
2016-05-29 17:05:27 +00:00
|
|
|
for (int ii = 0; ii < dependentScripts.count(); ++ii)
|
|
|
|
dependentScripts.at(ii)->release();
|
|
|
|
dependentScripts.clear();
|
|
|
|
|
2016-05-29 16:42:28 +00:00
|
|
|
importCache = nullptr;
|
|
|
|
|
2016-05-29 17:21:54 +00:00
|
|
|
qDeleteAll(resolvedTypes);
|
|
|
|
resolvedTypes.clear();
|
|
|
|
|
2013-09-19 07:32:42 +00:00
|
|
|
engine = 0;
|
|
|
|
free(runtimeStrings);
|
|
|
|
runtimeStrings = 0;
|
|
|
|
delete [] runtimeLookups;
|
|
|
|
runtimeLookups = 0;
|
|
|
|
delete [] runtimeRegularExpressions;
|
|
|
|
runtimeRegularExpressions = 0;
|
|
|
|
free(runtimeClasses);
|
|
|
|
runtimeClasses = 0;
|
|
|
|
qDeleteAll(runtimeFunctions);
|
|
|
|
runtimeFunctions.clear();
|
|
|
|
}
|
|
|
|
|
2013-11-02 15:30:26 +00:00
|
|
|
void CompilationUnit::markObjects(QV4::ExecutionEngine *e)
|
2013-08-15 12:11:19 +00:00
|
|
|
{
|
2013-11-01 11:38:32 +00:00
|
|
|
for (uint i = 0; i < data->stringTableSize; ++i)
|
2014-07-23 11:56:43 +00:00
|
|
|
if (runtimeStrings[i])
|
|
|
|
runtimeStrings[i]->mark(e);
|
2013-10-11 12:58:45 +00:00
|
|
|
if (runtimeRegularExpressions) {
|
2013-11-01 11:38:32 +00:00
|
|
|
for (uint i = 0; i < data->regexpTableSize; ++i)
|
2013-11-02 15:30:26 +00:00
|
|
|
runtimeRegularExpressions[i].mark(e);
|
2013-10-11 12:58:45 +00:00
|
|
|
}
|
2013-08-15 12:11:19 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 08:55:45 +00:00
|
|
|
void CompilationUnit::destroy()
|
|
|
|
{
|
|
|
|
QQmlEngine *qmlEngine = 0;
|
|
|
|
if (engine)
|
|
|
|
qmlEngine = engine->qmlEngine();
|
|
|
|
if (qmlEngine)
|
|
|
|
QQmlEnginePrivate::deleteInEngineThread(qmlEngine, this);
|
|
|
|
else
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2016-05-25 12:55:44 +00:00
|
|
|
IdentifierHash<int> CompilationUnit::namedObjectsPerComponent(int componentObjectIndex)
|
|
|
|
{
|
|
|
|
auto it = namedObjectsPerComponentCache.find(componentObjectIndex);
|
|
|
|
if (it == namedObjectsPerComponentCache.end()) {
|
|
|
|
IdentifierHash<int> namedObjectCache(engine);
|
|
|
|
const CompiledData::Object *component = data->objectAt(componentObjectIndex);
|
|
|
|
const quint32 *namedObjectIndexPtr = component->namedObjectsInComponentTable();
|
|
|
|
for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) {
|
|
|
|
const CompiledData::Object *namedObject = data->objectAt(*namedObjectIndexPtr);
|
|
|
|
namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id);
|
|
|
|
}
|
|
|
|
it = namedObjectsPerComponentCache.insert(componentObjectIndex, namedObjectCache);
|
|
|
|
}
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif // V4_BOOTSTRAP
|
|
|
|
|
2014-03-27 16:07:06 +00:00
|
|
|
Unit *CompilationUnit::createUnitData(QmlIR::Document *irDocument)
|
|
|
|
{
|
2014-09-24 10:27:21 +00:00
|
|
|
return irDocument->jsGenerator.generateUnit(QV4::Compiler::JSUnitGenerator::GenerateWithoutStringTable);
|
2014-03-27 16:07:06 +00:00
|
|
|
}
|
|
|
|
|
2013-09-13 07:08:41 +00:00
|
|
|
QString Binding::valueAsString(const Unit *unit) const
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Type_Script:
|
|
|
|
case Type_String:
|
|
|
|
return unit->stringAt(stringIndex);
|
|
|
|
case Type_Boolean:
|
|
|
|
return value.b ? QStringLiteral("true") : QStringLiteral("false");
|
|
|
|
case Type_Number:
|
|
|
|
return QString::number(value.d);
|
|
|
|
case Type_Invalid:
|
|
|
|
return QString();
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifdef QT_NO_TRANSLATION
|
|
|
|
case Type_TranslationById:
|
|
|
|
case Type_Translation:
|
|
|
|
return unit->stringAt(stringIndex);
|
|
|
|
#else
|
2014-03-06 15:19:42 +00:00
|
|
|
case Type_TranslationById: {
|
|
|
|
QByteArray id = unit->stringAt(stringIndex).toUtf8();
|
|
|
|
return qtTrId(id.constData(), value.translationData.number);
|
|
|
|
}
|
|
|
|
case Type_Translation: {
|
|
|
|
// This code must match that in the qsTr() implementation
|
|
|
|
const QString &path = unit->stringAt(unit->sourceFileIndex);
|
|
|
|
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
|
2016-04-06 12:23:58 +00:00
|
|
|
QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5)
|
|
|
|
: QStringRef();
|
2014-03-06 15:19:42 +00:00
|
|
|
QByteArray contextUtf8 = context.toUtf8();
|
|
|
|
QByteArray comment = unit->stringAt(value.translationData.commentIndex).toUtf8();
|
|
|
|
QByteArray text = unit->stringAt(stringIndex).toUtf8();
|
|
|
|
return QCoreApplication::translate(contextUtf8.constData(), text.constData(),
|
|
|
|
comment.constData(), value.translationData.number);
|
|
|
|
}
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif
|
2013-09-13 07:08:41 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2014-01-10 13:46:33 +00:00
|
|
|
//reverse of Lexer::singleEscape()
|
2014-08-12 11:52:50 +00:00
|
|
|
QString Binding::escapedString(const QString &string)
|
2014-01-10 13:46:33 +00:00
|
|
|
{
|
|
|
|
QString tmp = QLatin1String("\"");
|
|
|
|
for (int i = 0; i < string.length(); ++i) {
|
|
|
|
const QChar &c = string.at(i);
|
|
|
|
switch (c.unicode()) {
|
|
|
|
case 0x08:
|
|
|
|
tmp += QLatin1String("\\b");
|
|
|
|
break;
|
|
|
|
case 0x09:
|
|
|
|
tmp += QLatin1String("\\t");
|
|
|
|
break;
|
|
|
|
case 0x0A:
|
|
|
|
tmp += QLatin1String("\\n");
|
|
|
|
break;
|
|
|
|
case 0x0B:
|
|
|
|
tmp += QLatin1String("\\v");
|
|
|
|
break;
|
|
|
|
case 0x0C:
|
|
|
|
tmp += QLatin1String("\\f");
|
|
|
|
break;
|
|
|
|
case 0x0D:
|
|
|
|
tmp += QLatin1String("\\r");
|
|
|
|
break;
|
|
|
|
case 0x22:
|
|
|
|
tmp += QLatin1String("\\\"");
|
|
|
|
break;
|
|
|
|
case 0x27:
|
|
|
|
tmp += QLatin1String("\\\'");
|
|
|
|
break;
|
|
|
|
case 0x5C:
|
|
|
|
tmp += QLatin1String("\\\\");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tmp += c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tmp += QLatin1Char('\"');
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Binding::valueAsScriptString(const Unit *unit) const
|
|
|
|
{
|
|
|
|
if (type == Type_String)
|
|
|
|
return escapedString(unit->stringAt(stringIndex));
|
|
|
|
else
|
|
|
|
return valueAsString(unit);
|
|
|
|
}
|
|
|
|
|
2016-05-29 17:21:54 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
|
|
|
/*!
|
|
|
|
Returns the property cache, if one alread exists. The cache is not referenced.
|
|
|
|
*/
|
|
|
|
QQmlPropertyCache *CompilationUnit::ResolvedTypeReference::propertyCache() const
|
|
|
|
{
|
|
|
|
if (type)
|
|
|
|
return typePropertyCache;
|
|
|
|
else
|
2016-06-01 10:22:11 +00:00
|
|
|
return compilationUnit->rootPropertyCache();
|
2016-05-29 17:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
|
|
|
|
*/
|
|
|
|
QQmlPropertyCache *CompilationUnit::ResolvedTypeReference::createPropertyCache(QQmlEngine *engine)
|
|
|
|
{
|
|
|
|
if (typePropertyCache) {
|
|
|
|
return typePropertyCache;
|
|
|
|
} else if (type) {
|
|
|
|
typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type->metaObject());
|
|
|
|
return typePropertyCache;
|
|
|
|
} else {
|
2016-06-01 10:22:11 +00:00
|
|
|
return compilationUnit->rootPropertyCache();
|
2016-05-29 17:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool qtTypeInherits(const QMetaObject *mo) {
|
|
|
|
while (mo) {
|
|
|
|
if (mo == &T::staticMetaObject)
|
|
|
|
return true;
|
|
|
|
mo = mo->superClass();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompilationUnit::ResolvedTypeReference::doDynamicTypeCheck()
|
|
|
|
{
|
|
|
|
const QMetaObject *mo = 0;
|
|
|
|
if (typePropertyCache)
|
|
|
|
mo = typePropertyCache->firstCppMetaObject();
|
|
|
|
else if (type)
|
|
|
|
mo = type->metaObject();
|
2016-06-01 10:22:11 +00:00
|
|
|
else if (compilationUnit)
|
|
|
|
mo = compilationUnit->rootPropertyCache()->firstCppMetaObject();
|
2016-05-29 17:21:54 +00:00
|
|
|
isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-08-14 08:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-08-18 13:35:02 +00:00
|
|
|
|
|
|
|
QT_END_NAMESPACE
|