summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-07-23 07:13:00 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-07-23 07:13:00 (GMT)
commitfb0f1485ed37b8055b4ffbfd0805ceff1e9401f5 (patch)
treeb747942c442d3b56355d7c9c61729e8de98f280b /src/declarative/qml
parent7fe100b56ccca40de193164d3ce19600cf50bdd4 (diff)
downloadQt-fb0f1485ed37b8055b4ffbfd0805ceff1e9401f5.zip
Qt-fb0f1485ed37b8055b4ffbfd0805ceff1e9401f5.tar.gz
Qt-fb0f1485ed37b8055b4ffbfd0805ceff1e9401f5.tar.bz2
Move import access functions to QmlEnginePrivate.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qml.pri1
-rw-r--r--src/declarative/qml/qmlcompiler.cpp1
-rw-r--r--src/declarative/qml/qmlcomponent.cpp1
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h123
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp5
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h60
-rw-r--r--src/declarative/qml/qmldom.cpp1
-rw-r--r--src/declarative/qml/qmlengine.cpp49
-rw-r--r--src/declarative/qml/qmlengine.h15
-rw-r--r--src/declarative/qml/qmlengine_p.h16
10 files changed, 174 insertions, 98 deletions
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 1021dec..d8b69df 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -65,6 +65,7 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlinfo.h \
qml/qmlmetaproperty_p.h \
qml/qmlcontext_p.h \
+ qml/qmlcompositetypedata_p.h \
qml/qmlcompositetypemanager_p.h \
qml/qmllist.h \
qml/qmldeclarativedata_p.h \
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 94710c6..20f0d93f 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "private/qmlcompiler_p.h"
+#include "private/qmlcompositetypedata_p.h"
#include <private/qfxperf_p.h>
#include "qmlparser_p.h"
#include "private/qmlscriptparser_p.h"
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 214d2fa..7dcc373 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -43,6 +43,7 @@
#include "qmlcomponent_p.h"
#include "qmlcompiler_p.h"
#include "private/qmlcontext_p.h"
+#include "private/qmlcompositetypedata_p.h"
#include "private/qmlengine_p.h"
#include "qmlvme_p.h"
#include "qml.h"
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
new file mode 100644
index 0000000..3469fea
--- /dev/null
+++ b/src/declarative/qml/qmlcompositetypedata_p.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLCOMPOSITETYPEDATA_P_H
+#define QMLCOMPOSITETYPEDATA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#include <private/qmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QmlCompositeTypeData : public QmlRefCount
+{
+ QmlCompositeTypeData();
+ virtual ~QmlCompositeTypeData();
+
+ enum Status {
+ Invalid,
+ Complete,
+ Error,
+ Waiting
+ };
+ Status status;
+ enum ErrorType {
+ NoError,
+ AccessError,
+ GeneralError
+ };
+ ErrorType errorType;
+
+ QList<QmlError> errors;
+
+ QmlEnginePrivate::Imports imports;
+
+ QList<QmlCompositeTypeData *> dependants;
+
+ // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting
+ // state. The QmlComponent is owned by the QmlCompositeTypeData, so a
+ // reference should be kept to keep the QmlComponent alive.
+ QmlComponent *toComponent(QmlEngine *);
+ // Return a QmlCompiledData if possible, or 0 if an error
+ // occurs
+ QmlCompiledData *toCompiledComponent(QmlEngine *);
+
+ struct TypeReference
+ {
+ TypeReference();
+
+ QmlType *type;
+ QmlCompositeTypeData *unit;
+ };
+
+ QList<TypeReference> types;
+
+ // Add or remove p as a waiter. When the QmlCompositeTypeData becomes
+ // ready, the QmlComponentPrivate::typeDataReady() method will be invoked on
+ // p. The waiter is automatically removed when the typeDataReady() method
+ // is invoked, so there is no need to call remWaiter() in this case.
+ void addWaiter(QmlComponentPrivate *p);
+ void remWaiter(QmlComponentPrivate *p);
+
+private:
+ friend class QmlCompositeTypeManager;
+ friend class QmlCompiler;
+ friend class QmlDomDocument;
+
+ QmlScriptParser data;
+ QList<QmlComponentPrivate *> waiters;
+ QmlComponent *component;
+ QmlCompiledData *compiledComponent;
+};
+
+#endif // QMLCOMPOSITETYPEDATA_P_H
+
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 3037051..6f17b70 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <private/qmlcompositetypedata_p.h>
#include <private/qmlcompositetypemanager_p.h>
#include <private/qmlscriptparser_p.h>
#include <QtDeclarative/qmlengine.h>
@@ -246,7 +247,7 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
unit->errors << unit->data.errors();
} else {
foreach (QmlScriptParser::Import imp, unit->data.imports()) {
- if (!engine->addToImport(&unit->imports, imp.uri, imp.qualifier, imp.version, imp.type==QmlScriptParser::Import::Library ? QmlEngine::LibraryImport : QmlEngine::FileImport)) {
+ if (!engine->d_func()->addToImport(&unit->imports, imp.uri, imp.qualifier, imp.version, imp.type)) {
QmlError error;
error.setUrl(url);
error.setDescription(tr("Import %1 unavailable").arg(imp.uri));
@@ -322,7 +323,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit)
}
QUrl url;
- if (!engine->resolveType(unit->imports, type, &ref.type, &url)) {
+ if (!engine->d_func()->resolveType(unit->imports, type, &ref.type, &url)) {
// XXX could produce error message here.
}
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index 0685b03..cb0fc43 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -65,66 +65,8 @@ class QmlCompiledData;
class QmlComponentPrivate;
class QmlComponent;
class QmlDomDocument;
-struct QmlCompositeTypeData : public QmlRefCount
-{
- QmlCompositeTypeData();
- virtual ~QmlCompositeTypeData();
-
- enum Status {
- Invalid,
- Complete,
- Error,
- Waiting
- };
- Status status;
- enum ErrorType {
- NoError,
- AccessError,
- GeneralError
- };
- ErrorType errorType;
-
- QList<QmlError> errors;
-
- QmlEngine::Imports imports;
-
- QList<QmlCompositeTypeData *> dependants;
-
- // Return a QmlComponent if the QmlCompositeTypeData is not in the Waiting
- // state. The QmlComponent is owned by the QmlCompositeTypeData, so a
- // reference should be kept to keep the QmlComponent alive.
- QmlComponent *toComponent(QmlEngine *);
- // Return a QmlCompiledData if possible, or 0 if an error
- // occurs
- QmlCompiledData *toCompiledComponent(QmlEngine *);
-
- struct TypeReference
- {
- TypeReference();
-
- QmlType *type;
- QmlCompositeTypeData *unit;
- };
-
- QList<TypeReference> types;
-
- // Add or remove p as a waiter. When the QmlCompositeTypeData becomes
- // ready, the QmlComponentPrivate::typeDataReady() method will be invoked on
- // p. The waiter is automatically removed when the typeDataReady() method
- // is invoked, so there is no need to call remWaiter() in this case.
- void addWaiter(QmlComponentPrivate *p);
- void remWaiter(QmlComponentPrivate *p);
-private:
- friend class QmlCompositeTypeManager;
- friend class QmlCompiler;
- friend class QmlDomDocument;
-
- QmlScriptParser data;
- QList<QmlComponentPrivate *> waiters;
- QmlComponent *component;
- QmlCompiledData *compiledComponent;
-};
+struct QmlCompositeTypeData;
class QmlCompositeTypeManager : public QObject
{
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index 293ea6a..5082fda 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -41,6 +41,7 @@
#include "qmldom.h"
#include "qmldom_p.h"
+#include "private/qmlcompositetypedata_p.h"
#include "private/qmlcompiler_p.h"
#include "private/qmlengine_p.h"
#include <QtCore/QByteArray>
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 2229916..33c6710 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1036,7 +1036,7 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object,
}
-struct QmlEngine::ImportedNamespace {
+struct QmlEnginePrivate::ImportedNamespace {
QStringList urls;
QStringList versions;
QList<bool> isLibrary;
@@ -1100,27 +1100,27 @@ struct QmlEngine::ImportedNamespace {
class QmlImportsPrivate {
public:
- bool add(const QUrl& base, const QString& uri, const QString& prefix, const QString& version, QmlEngine::ImportType importType, const QStringList& importPath)
+ bool add(const QUrl& base, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType, const QStringList& importPath)
{
- QmlEngine::ImportedNamespace *s;
+ QmlEnginePrivate::ImportedNamespace *s;
if (prefix.isEmpty()) {
- if (importType == QmlEngine::LibraryImport && version.isEmpty()) {
+ if (importType == QmlScriptParser::Import::Library && version.isEmpty()) {
// unversioned library imports are always qualified - if only by final URI component
int lastdot = uri.lastIndexOf(QLatin1Char('.'));
QString defaultprefix = uri.mid(lastdot+1);
s = set.value(defaultprefix);
if (!s)
- set.insert(defaultprefix,(s=new QmlEngine::ImportedNamespace));
+ set.insert(defaultprefix,(s=new QmlEnginePrivate::ImportedNamespace));
} else {
s = &unqualifiedset;
}
} else {
s = set.value(prefix);
if (!s)
- set.insert(prefix,(s=new QmlEngine::ImportedNamespace));
+ set.insert(prefix,(s=new QmlEnginePrivate::ImportedNamespace));
}
QString url = uri;
- if (importType == QmlEngine::LibraryImport) {
+ if (importType == QmlScriptParser::Import::Library) {
url.replace(QLatin1Char('.'),QLatin1Char('/'));
bool found = false;
foreach (QString p, importPath) {
@@ -1139,13 +1139,13 @@ public:
}
s->urls.append(url);
s->versions.append(version);
- s->isLibrary.append(importType == QmlEngine::LibraryImport);
+ s->isLibrary.append(importType == QmlScriptParser::Import::Library);
return true;
}
QUrl find(const QString& type) const
{
- const QmlEngine::ImportedNamespace *s = 0;
+ const QmlEnginePrivate::ImportedNamespace *s = 0;
int slash = type.indexOf(QLatin1Char('/'));
if (slash >= 0) {
while (!s) {
@@ -1169,7 +1169,7 @@ public:
QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0)
{
- QmlEngine::ImportedNamespace *s = 0;
+ QmlEnginePrivate::ImportedNamespace *s = 0;
int slash = type.indexOf('/');
if (slash >= 0) {
while (!s) {
@@ -1190,29 +1190,29 @@ public:
return 0;
}
- QmlEngine::ImportedNamespace *findNamespace(const QString& type)
+ QmlEnginePrivate::ImportedNamespace *findNamespace(const QString& type)
{
return set.value(type);
}
private:
- QmlEngine::ImportedNamespace unqualifiedset;
- QHash<QString,QmlEngine::ImportedNamespace* > set;
+ QmlEnginePrivate::ImportedNamespace unqualifiedset;
+ QHash<QString,QmlEnginePrivate::ImportedNamespace* > set;
};
-QmlEngine::Imports::Imports() :
+QmlEnginePrivate::Imports::Imports() :
d(new QmlImportsPrivate)
{
}
-QmlEngine::Imports::~Imports()
+QmlEnginePrivate::Imports::~Imports()
{
}
/*!
Sets the base URL to be used for all relative file imports added.
*/
-void QmlEngine::Imports::setBaseUrl(const QUrl& url)
+void QmlEnginePrivate::Imports::setBaseUrl(const QUrl& url)
{
base = url;
}
@@ -1236,6 +1236,8 @@ void QmlEngine::addImportPath(const QString& path)
}
/*!
+ \internal
+
Adds information to \a imports such that subsequent calls to resolveType()
will resolve types qualified by \a prefix by considering types found at the given \a uri.
@@ -1247,16 +1249,17 @@ void QmlEngine::addImportPath(const QString& path)
The base URL must already have been set with Import::setBaseUrl().
*/
-bool QmlEngine::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, ImportType importType) const
+bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type importType) const
{
- Q_D(const QmlEngine);
- bool ok = imports->d->add(imports->base,uri,prefix,version,importType,d->fileImportPath);
+ bool ok = imports->d->add(imports->base,uri,prefix,version,importType,fileImportPath);
if (qmlImportTrace())
- qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==LibraryImport ? "Library" : "File") << ": " << ok;
+ qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok;
return ok;
}
/*!
+ \internal
+
Using the given \a imports, the given (namespace qualified) \a type is resolved to either
an ImportedNamespace stored at \a ns_return,
a QmlType stored at \a type_return, or
@@ -1266,7 +1269,7 @@ bool QmlEngine::addToImport(Imports* imports, const QString& uri, const QString&
\sa addToImport()
*/
-bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const
+bool QmlEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const
{
if (ns_return) {
*ns_return = imports.d->findNamespace(QLatin1String(type));
@@ -1301,6 +1304,8 @@ bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlT
}
/*!
+ \internal
+
Searching \e only in the namespace \a ns (previously returned in a call to
resolveType(), \a type is found and returned to either
a QmlType stored at \a type_return, or
@@ -1308,7 +1313,7 @@ bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlT
If either return pointer is 0, the corresponding search is not done.
*/
-void QmlEngine::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const
+void QmlEnginePrivate::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const
{
if (type_return) {
*type_return = ns->findBuiltin(type);
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 98deba7..2faad66 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -74,23 +74,8 @@ public:
void clearComponentCache();
- struct Imports {
- Imports();
- ~Imports();
- void setBaseUrl(const QUrl& url);
- QUrl baseUrl() const { return base; }
- private:
- friend class QmlEngine;
- QUrl base;
- QmlImportsPrivate *d;
- };
- struct ImportedNamespace;
void addImportPath(const QString& dir);
- enum ImportType { LibraryImport, FileImport };
- bool addToImport(Imports*, const QString& uri, const QString& prefix, const QString& version, ImportType type) const;
- bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const;
- void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const;
void setNetworkAccessManager(QNetworkAccessManager *);
QNetworkAccessManager *networkAccessManager() const;
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index af561e7..b8d49aa 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -172,6 +172,22 @@ public:
}
QmlValueTypeFactory valueTypes;
+
+ struct Imports {
+ Imports();
+ ~Imports();
+ void setBaseUrl(const QUrl& url);
+ QUrl baseUrl() const { return base; }
+ private:
+ friend class QmlEnginePrivate;
+ QUrl base;
+ QmlImportsPrivate *d;
+ };
+ struct ImportedNamespace;
+ bool addToImport(Imports*, const QString& uri, const QString& prefix, const QString& version, QmlScriptParser::Import::Type type) const;
+ bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const;
+ void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const;
+
};
class QmlScriptClass : public QScriptClass