QmlJS: Make Document::Ptr point to a const Document.

Change-Id: I15a36c3f918c0ee16f30bc8366df505e0afac949
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-11-03 13:47:03 +01:00
parent 86f0f93033
commit 386fc347d7
19 changed files with 41 additions and 35 deletions

View File

@@ -119,9 +119,9 @@ Document::~Document()
delete _engine;
}
Document::Ptr Document::create(const QString &fileName, Language language)
Document::MutablePtr Document::create(const QString &fileName, Language language)
{
Document::Ptr doc(new Document(fileName, language));
Document::MutablePtr doc(new Document(fileName, language));
doc->_ptr = doc;
return doc;
}
@@ -375,11 +375,11 @@ void Snapshot::remove(const QString &fileName)
}
}
Document::Ptr Snapshot::documentFromSource(const QString &code,
const QString &fileName,
Document::Language language) const
Document::MutablePtr Snapshot::documentFromSource(
const QString &code, const QString &fileName,
Document::Language language) const
{
Document::Ptr newDoc = Document::create(fileName, language);
Document::MutablePtr newDoc = Document::create(fileName, language);
if (Document::Ptr thisDocument = document(fileName)) {
newDoc->_editorRevision = thisDocument->_editorRevision;

View File

@@ -51,7 +51,8 @@ class Snapshot;
class QMLJS_EXPORT Document
{
public:
typedef QSharedPointer<Document> Ptr;
typedef QSharedPointer<const Document> Ptr;
typedef QSharedPointer<Document> MutablePtr;
// used in a 3-bit bitfield
enum Language
@@ -68,7 +69,7 @@ protected:
public:
~Document();
static Document::Ptr create(const QString &fileName, Language language);
static MutablePtr create(const QString &fileName, Language language);
static Language guessLanguageFromSuffix(const QString &fileName);
Document::Ptr ptr() const;
@@ -230,7 +231,7 @@ public:
QList<Document::Ptr> documentsInDirectory(const QString &path) const;
LibraryInfo libraryInfo(const QString &path) const;
Document::Ptr documentFromSource(const QString &code,
Document::MutablePtr documentFromSource(const QString &code,
const QString &fileName,
Document::Language language) const;
};

View File

@@ -259,7 +259,7 @@ void ScopeChain::initializeRootScope()
m_globalScope = valueOwner->globalObject();
QHash<Document *, QmlComponentChain *> componentScopes;
QHash<const Document *, QmlComponentChain *> componentScopes;
QmlComponentChain *chain = new QmlComponentChain(m_document);
m_qmlComponentScope = QSharedPointer<const QmlComponentChain>(chain);
@@ -297,7 +297,7 @@ void ScopeChain::initializeRootScope()
void ScopeChain::makeComponentChain(
QmlComponentChain *target,
const Snapshot &snapshot,
QHash<Document *, QmlComponentChain *> *components)
QHash<const Document *, QmlComponentChain *> *components)
{
Document::Ptr doc = target->document();
if (!doc->qmlProgram())

View File

@@ -108,7 +108,7 @@ private:
void update() const;
void initializeRootScope();
void makeComponentChain(QmlComponentChain *target, const Snapshot &snapshot,
QHash<Document *, QmlComponentChain *> *components);
QHash<const Document *, QmlComponentChain *> *components);
Document::Ptr m_document;