diff options
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/parser/javascriptlexer.cpp | 37 | ||||
-rw-r--r-- | src/declarative/qml/qml.h | 14 | ||||
-rw-r--r-- | src/declarative/qml/qmlbindablevalue.h | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlbindablevalue_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcustomparser_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlparserstatus.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlprivate.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlpropertyvaluesource.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlpropertyvaluesource.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 54 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser_p.h | 40 | ||||
-rw-r--r-- | src/declarative/qml/rewriter/rewriter.cpp | 41 | ||||
-rw-r--r-- | src/declarative/qml/rewriter/rewriter.pri | 9 | ||||
-rw-r--r-- | src/declarative/qml/rewriter/rewriter_p.h | 145 | ||||
-rw-r--r-- | src/declarative/qml/rewriter/textwriter.cpp | 41 | ||||
-rw-r--r-- | src/declarative/qml/rewriter/textwriter_p.h | 91 |
19 files changed, 378 insertions, 126 deletions
diff --git a/src/declarative/qml/parser/javascriptlexer.cpp b/src/declarative/qml/parser/javascriptlexer.cpp index fda6ad2..ea36a7a 100644 --- a/src/declarative/qml/parser/javascriptlexer.cpp +++ b/src/declarative/qml/parser/javascriptlexer.cpp @@ -758,49 +758,54 @@ int Lexer::lex() flags = noSuffix; - if (current == 'e' && next1 == 'm') { + const ushort c = QChar::toLower(current); + const ushort n1 = QChar::toLower(next1); + const ushort n2 = QChar::toLower(next2); + const ushort n3 = QChar::toLower(next3); + + if (c == 'e' && n1 == 'm') { flags = emSuffix; shift(2); - } else if (current == 'e' && next1 == 'x') { + } else if (c == 'e' && n1 == 'x') { flags = exSuffix; shift(2); - } else if (current == 'p' && next1 == 'x') { + } else if (c == 'p' && n1 == 'x') { flags = pxSuffix; shift(2); - } else if (current == 'c' && next1 == 'm') { + } else if (c == 'c' && n1 == 'm') { flags = cmSuffix; shift(2); - } else if (current == 'm' && next1 == 'm') { + } else if (c == 'm' && n1 == 'm') { flags = mmSuffix; shift(2); - } else if (current == 'i' && next1 == 'n') { + } else if (c == 'i' && n1 == 'n') { flags = inSuffix; shift(2); - } else if (current == 'p' && next1 == 't') { + } else if (c == 'p' && n1 == 't') { flags = ptSuffix; shift(2); - } else if (current == 'p' && next1 == 'c') { + } else if (c == 'p' && n1 == 'c') { flags = pcSuffix; shift(1); - } else if (current == 'd' && next1 == 'e' && next2 == 'g') { + } else if (c == 'd' && n1 == 'e' && n2 == 'g') { flags = degSuffix; shift(3); - } else if (current == 'r' && next1 == 'a' && next2 == 'd') { + } else if (c == 'r' && n1 == 'a' && n2 == 'd') { flags = radSuffix; shift(3); - } else if (current == 'g' && next1 == 'r' && next2 == 'a' && next3 == 'd') { + } else if (c == 'g' && n1 == 'r' && n2 == 'a' && n3 == 'd') { flags = gradSuffix; shift(4); - } else if (current == 'm' && next1 == 's') { + } else if (c == 'm' && n1 == 's') { flags = msSuffix; shift(2); - } else if (current == 's') { + } else if (c == 's') { flags = sSuffix; shift(1); - } else if (current == 'h' && next1 == 'z') { + } else if (c == 'h' && n1 == 'z') { flags = hzSuffix; shift(2); - } else if (current == 'k' && next1 == 'h' && next2 == 'z') { + } else if (c == 'k' && n1 == 'h' && n2 == 'z') { flags = khzSuffix; shift(3); } @@ -811,7 +816,7 @@ int Lexer::lex() && isIdentLetter(current)) { state = Bad; err = IllegalIdentifier; - errmsg = QLatin1String("Identifier cannot start with numeric literal `%1'"); + errmsg = QLatin1String("Identifier cannot start with numeric literal"); } // terminate string diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index b435e94..370bb58 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -59,13 +59,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) #define QML_DECLARE_TYPE(TYPE) \ - Q_DECLARE_METATYPE(TYPE *); \ - Q_DECLARE_METATYPE(QList<TYPE *> *); \ - Q_DECLARE_METATYPE(QmlList<TYPE *> *); + Q_DECLARE_METATYPE(TYPE *) \ + Q_DECLARE_METATYPE(QList<TYPE *> *) \ + Q_DECLARE_METATYPE(QmlList<TYPE *> *) #define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \ - Q_DECLARE_METATYPE(QList<TYPE *> *); \ - Q_DECLARE_METATYPE(QmlList<TYPE *> *); + Q_DECLARE_METATYPE(QList<TYPE *> *) \ + Q_DECLARE_METATYPE(QmlList<TYPE *> *) #define QML_DECLARE_INTERFACE(INTERFACE) \ QML_DECLARE_TYPE(INTERFACE) @@ -109,8 +109,8 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj) return qmlAttachedPropertiesObjectById(idx, obj); } -QML_DECLARE_TYPE(QObject); -Q_DECLARE_METATYPE(QVariant); +QML_DECLARE_TYPE(QObject) +Q_DECLARE_METATYPE(QVariant) QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index 7831177..c5bb97b 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -70,8 +70,8 @@ public: virtual void setTarget(const QmlMetaProperty &); QmlMetaProperty property() const; - Q_CLASSINFO("DefaultProperty", "expression"); - Q_PROPERTY(QString expression READ expression WRITE setExpression); + Q_CLASSINFO("DefaultProperty", "expression") + Q_PROPERTY(QString expression READ expression WRITE setExpression) virtual void setExpression(const QString &); void init(); @@ -85,7 +85,7 @@ protected: private: Q_DECLARE_PRIVATE(QmlBindableValue) }; -QML_DECLARE_TYPE(QmlBindableValue); +QML_DECLARE_TYPE(QmlBindableValue) QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h index 9973bdc..9476b80 100644 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE class QmlBindableValuePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QmlBindableValue); + Q_DECLARE_PUBLIC(QmlBindableValue) public: QmlBindableValuePrivate(); diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index 90f7467..e7386d9 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -60,7 +60,7 @@ class QmlEngine; class Q_DECLARATIVE_EXPORT QmlComponent : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QmlComponent); + Q_DECLARE_PRIVATE(QmlComponent) public: QmlComponent(QObject *parent = 0); @@ -101,7 +101,7 @@ private: friend class QmlVME; friend struct QmlCompositeTypeData; }; -QML_DECLARE_TYPE(QmlComponent); +QML_DECLARE_TYPE(QmlComponent) QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index fd780d6..75da579 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -74,7 +74,7 @@ private: friend class QmlCustomParserPropertyPrivate; QmlCustomParserPropertyPrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserProperty); +Q_DECLARE_METATYPE(QmlCustomParserProperty) class QmlCustomParserNodePrivate; class Q_DECLARATIVE_EXPORT QmlCustomParserNode @@ -93,7 +93,7 @@ private: friend class QmlCustomParserNodePrivate; QmlCustomParserNodePrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserNode); +Q_DECLARE_METATYPE(QmlCustomParserNode) class Q_DECLARATIVE_EXPORT QmlCustomParser { diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c0ea463..3db8d92 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -75,11 +75,11 @@ QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER); +DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER) -Q_DECLARE_METATYPE(QmlMetaProperty); +Q_DECLARE_METATYPE(QmlMetaProperty) -QML_DEFINE_TYPE(QObject,Object); +QML_DEFINE_TYPE(QObject,Object) static QScriptValue qmlMetaProperty_emit(QScriptContext *ctx, QScriptEngine *engine) { diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index add5773..721f1a8 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -272,7 +272,7 @@ namespace QmlParser void dump(int = 0) const; }; } -Q_DECLARE_METATYPE(QmlParser::Variant); +Q_DECLARE_METATYPE(QmlParser::Variant) QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h index 0e58229..7c2e141 100644 --- a/src/declarative/qml/qmlparserstatus.h +++ b/src/declarative/qml/qmlparserstatus.h @@ -66,7 +66,7 @@ private: friend class QmlEnginePrivate; QmlParserStatus **d; }; -Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus"); +Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus") QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 2a9c503..62524aa 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -237,7 +237,7 @@ namespace QmlPrivate return new T(other); } }; -}; +} template<typename T> int QmlPrivate::list_op(QmlPrivate::ListOp op, int val, diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 4770929..18092c8 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. */ -QML_DEFINE_NOCREATE_TYPE(QmlPropertyValueSource); +QML_DEFINE_NOCREATE_TYPE(QmlPropertyValueSource) /*! Constructs a QmlPropertyValueSource with parent \a parent. diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h index 736b25f..9cef150 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.h +++ b/src/declarative/qml/qmlpropertyvaluesource.h @@ -69,7 +69,7 @@ protected: private: Q_DISABLE_COPY(QmlPropertyValueSource) }; -QML_DECLARE_TYPE(QmlPropertyValueSource); +QML_DECLARE_TYPE(QmlPropertyValueSource) #endif // QMLPROPERTYVALUESOURCE_H diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index fde2771..5c5b25e 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ #include "qmlscriptparser_p.h" #include "qmlparser_p.h" @@ -27,16 +67,18 @@ namespace { class RewriteNumericLiterals: protected AST::Visitor { unsigned _position; - TextWriter _writer; + TextWriter *_writer; public: QString operator()(QString code, unsigned position, AST::Node *node) { + TextWriter w; + _writer = &w; _position = position; AST::Node::acceptChild(node, this); - _writer.write(&code); + w.write(&code); return code; } @@ -54,10 +96,10 @@ protected: pre += QChar(QLatin1Char(suffixSpell[0])).toUpper(); pre += QLatin1String(&suffixSpell[1]); pre += QLatin1Char('('); - _writer.replace(node->literalToken.begin() - _position, 0, pre); - _writer.replace(node->literalToken.end() - _position - suffixLength, - suffixLength, - QLatin1String(")")); + _writer->replace(node->literalToken.begin() - _position, 0, pre); + _writer->replace(node->literalToken.end() - _position - suffixLength, + suffixLength, + QLatin1String(")")); } return false; diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index 8a5466f..a9ffa47 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** 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 QMLSCRIPTPARSER_P_H #define QMLSCRIPTPARSER_P_H diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp index ec504fa..fce4fdf 100644 --- a/src/declarative/qml/rewriter/rewriter.cpp +++ b/src/declarative/qml/rewriter/rewriter.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + #include "rewriter_p.h" #include "javascriptast_p.h" diff --git a/src/declarative/qml/rewriter/rewriter.pri b/src/declarative/qml/rewriter/rewriter.pri index 987e26d..de3c298 100644 --- a/src/declarative/qml/rewriter/rewriter.pri +++ b/src/declarative/qml/rewriter/rewriter.pri @@ -1,4 +1,9 @@ INCLUDEPATH += $$PWD -HEADERS += $$PWD/rewriter_p.h $$PWD/textwriter_p.h -SOURCES += $$PWD/rewriter.cpp $$PWD/textwriter.cpp +HEADERS += $$PWD/textwriter_p.h +SOURCES += $$PWD/textwriter.cpp + +!no_ast_rewriter { + HEADERS += $$PWD/rewriter_p.h + SOURCES += $$PWD/rewriter.cpp +} diff --git a/src/declarative/qml/rewriter/rewriter_p.h b/src/declarative/qml/rewriter/rewriter_p.h index 892c006..02b4ee4 100644 --- a/src/declarative/qml/rewriter/rewriter_p.h +++ b/src/declarative/qml/rewriter/rewriter_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 REWRITER_H #define REWRITER_H @@ -10,8 +51,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - namespace JavaScript { //////////////////////////////////////////////////////////////////////////////// @@ -19,21 +58,21 @@ namespace JavaScript { //////////////////////////////////////////////////////////////////////////////// class Replacement { - int _offset; - int _length; - QString _text; + int _offset; + int _length; + QString _text; public: - Replacement(int offset = 0, int length = 0, const QString &text = QString()) - : _offset(offset), _length(length), _text(text) - { } + Replacement(int offset = 0, int length = 0, const QString &text = QString()) + : _offset(offset), _length(length), _text(text) + { } - bool isNull() const { return _offset == _length; } - operator bool() const { return ! isNull(); } + bool isNull() const { return _offset == _length; } + operator bool() const { return ! isNull(); } - int offset() const { return _offset; } - int length() const { return _length; } - QString text() const { return _text; } + int offset() const { return _offset; } + int length() const { return _length; } + QString text() const { return _text; } }; @@ -44,64 +83,64 @@ public: class Rewriter: public AST::Visitor { protected: - TextWriter textWriter; + TextWriter textWriter; public: - // - // Token based API - // + // + // Token based API + // - /// Returns the text of the token at the given \a location. - QString textAt(const AST::SourceLocation &location) const; + /// Returns the text of the token at the given \a location. + QString textAt(const AST::SourceLocation &location) const; - QString textAt(const AST::SourceLocation &firstLoc, - const AST::SourceLocation &lastLoc) const; + QString textAt(const AST::SourceLocation &firstLoc, + const AST::SourceLocation &lastLoc) const; - /// Replace the token at \a loc with the given \a text. - void replace(const AST::SourceLocation &loc, const QString &text); + /// Replace the token at \a loc with the given \a text. + void replace(const AST::SourceLocation &loc, const QString &text); - /// Remove the token at the given \a location. - void remove(const AST::SourceLocation &location); + /// Remove the token at the given \a location. + void remove(const AST::SourceLocation &location); - /// Remove all tokens in the range [\a firstLoc, \a lastLoc]. - void remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc); + /// Remove all tokens in the range [\a firstLoc, \a lastLoc]. + void remove(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc); - /// Insert \a text before the token at the given \a location. - void insertTextBefore(const AST::SourceLocation &location, const QString &text); + /// Insert \a text before the token at the given \a location. + void insertTextBefore(const AST::SourceLocation &location, const QString &text); - /// Insert \a text after the token at the given \a location. - void insertTextAfter(const AST::SourceLocation &loc, const QString &text); + /// Insert \a text after the token at the given \a location. + void insertTextAfter(const AST::SourceLocation &loc, const QString &text); - void moveTextBefore(const AST::SourceLocation &firstLoc, - const AST::SourceLocation &lastLoc, - const AST::SourceLocation &loc); + void moveTextBefore(const AST::SourceLocation &firstLoc, + const AST::SourceLocation &lastLoc, + const AST::SourceLocation &loc); - void moveTextAfter(const AST::SourceLocation &firstLoc, - const AST::SourceLocation &lastLoc, - const AST::SourceLocation &loc); + void moveTextAfter(const AST::SourceLocation &firstLoc, + const AST::SourceLocation &lastLoc, + const AST::SourceLocation &loc); - // - // low-level offset based API - // - void replace(int offset, int length, const QString &text); - void insertText(int offset, const QString &text); - void removeText(int offset, int length); + // + // low-level offset based API + // + void replace(int offset, int length, const QString &text); + void insertText(int offset, const QString &text); + void removeText(int offset, int length); - /// Visit the given \a node. - void accept(AST::Node *node); + /// Visit the given \a node. + void accept(AST::Node *node); - /// Returns the original unchanged source code. - QString code() const { return _code; } + /// Returns the original unchanged source code. + QString code() const { return _code; } - /// Returns the list of replacements. - QList<Replacement> replacementList() const { return _replacementList; } + /// Returns the list of replacements. + QList<Replacement> replacementList() const { return _replacementList; } protected: - /// \internal - void setCode(const QString &code) { _code = code; } + /// \internal + void setCode(const QString &code) { _code = code; } private: - QString _code; - QList<Replacement> _replacementList; + QString _code; + QList<Replacement> _replacementList; }; } // end of namespace JavaScript diff --git a/src/declarative/qml/rewriter/textwriter.cpp b/src/declarative/qml/rewriter/textwriter.cpp index d56c9a1..21122ff 100644 --- a/src/declarative/qml/rewriter/textwriter.cpp +++ b/src/declarative/qml/rewriter/textwriter.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + #include "textwriter_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/rewriter/textwriter_p.h b/src/declarative/qml/rewriter/textwriter_p.h index 52d18d3..57800bf 100644 --- a/src/declarative/qml/rewriter/textwriter_p.h +++ b/src/declarative/qml/rewriter/textwriter_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 TEXTWRITER_H #define TEXTWRITER_H @@ -8,47 +49,45 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - namespace JavaScript { class TextWriter { - QString *string; - QTextCursor *cursor; + QString *string; + QTextCursor *cursor; - struct Replace { - int pos; - int length; - QString replacement; - }; + struct Replace { + int pos; + int length; + QString replacement; + }; - QList<Replace> replaceList; + QList<Replace> replaceList; - struct Move { - int pos; - int length; - int to; - }; + struct Move { + int pos; + int length; + int to; + }; - QList<Move> moveList; + QList<Move> moveList; - bool hasOverlap(int pos, int length); - bool hasMoveInto(int pos, int length); + bool hasOverlap(int pos, int length); + bool hasMoveInto(int pos, int length); - void doReplace(const Replace &replace); - void doMove(const Move &move); + void doReplace(const Replace &replace); + void doMove(const Move &move); - void write_helper(); + void write_helper(); public: - TextWriter(); + TextWriter(); - void replace(int pos, int length, const QString &replacement); - void move(int pos, int length, int to); + void replace(int pos, int length, const QString &replacement); + void move(int pos, int length, int to); - void write(QString *s); - void write(QTextCursor *textCursor); + void write(QString *s); + void write(QTextCursor *textCursor); }; |