diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-06-21 23:16:08 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-06-21 23:16:08 (GMT) |
commit | 511d86e88b33380116f27d5f6a2a0754e8f62fa0 (patch) | |
tree | 6fdcb11b5270984112bc2563738c24d2891595d4 /src/declarative/qml | |
parent | aae3c899b10bee2dd64bb00bb2832620a47cff87 (diff) | |
parent | fbf9db1fc6b500bfe05fdfca121986687d73d5c6 (diff) | |
download | Qt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.zip Qt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.tar.gz Qt-511d86e88b33380116f27d5f6a2a0754e8f62fa0.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
44 files changed, 771 insertions, 472 deletions
diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri index 72bd46c..610b2aa 100644 --- a/src/declarative/qml/parser/parser.pri +++ b/src/declarative/qml/parser/parser.pri @@ -1,22 +1,22 @@ INCLUDEPATH += $$PWD -HEADERS += $$PWD/javascriptast_p.h \ - $$PWD/javascriptastfwd_p.h \ - $$PWD/javascriptastvisitor_p.h \ - $$PWD/javascriptengine_p.h \ - $$PWD/javascriptgrammar_p.h \ - $$PWD/javascriptlexer_p.h \ - $$PWD/javascriptmemorypool_p.h \ - $$PWD/javascriptnodepool_p.h \ - $$PWD/javascriptparser_p.h \ - $$PWD/javascriptprettypretty_p.h +HEADERS += $$PWD/qmljsast_p.h \ + $$PWD/qmljsastfwd_p.h \ + $$PWD/qmljsastvisitor_p.h \ + $$PWD/qmljsengine_p.h \ + $$PWD/qmljsgrammar_p.h \ + $$PWD/qmljslexer_p.h \ + $$PWD/qmljsmemorypool_p.h \ + $$PWD/qmljsnodepool_p.h \ + $$PWD/qmljsparser_p.h \ + $$PWD/qmljsprettypretty_p.h -SOURCES += $$PWD/javascriptast.cpp \ - $$PWD/javascriptastvisitor.cpp \ - $$PWD/javascriptengine_p.cpp \ - $$PWD/javascriptgrammar.cpp \ - $$PWD/javascriptlexer.cpp \ - $$PWD/javascriptprettypretty.cpp \ - $$PWD/javascriptparser.cpp +SOURCES += $$PWD/qmljsast.cpp \ + $$PWD/qmljsastvisitor.cpp \ + $$PWD/qmljsengine_p.cpp \ + $$PWD/qmljsgrammar.cpp \ + $$PWD/qmljslexer.cpp \ + $$PWD/qmljsprettypretty.cpp \ + $$PWD/qmljsparser.cpp diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/qmljs.g index 884d814..907ca52 100644 --- a/src/declarative/qml/parser/javascript.g +++ b/src/declarative/qml/parser/qmljs.g @@ -42,11 +42,11 @@ -- ---------------------------------------------------------------------------- -%parser JavaScriptGrammar -%decl javascriptparser_p.h -%impl javascriptparser.cpp +%parser QmlJSGrammar +%decl qmljsparser_p.h +%impl qmljsparser.cpp %expect 2 -%expect-rr 2 +%expect-rr 3 %token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" %token T_BREAK "break" T_CASE "case" T_CATCH "catch" @@ -137,10 +137,10 @@ #include <string.h> -#include "javascriptengine_p.h" -#include "javascriptlexer_p.h" -#include "javascriptast_p.h" -#include "javascriptnodepool_p.h" +#include "qmljsengine_p.h" +#include "qmljslexer_p.h" +#include "qmljsast_p.h" +#include "qmljsnodepool_p.h" ./ @@ -198,16 +198,16 @@ // // -// This file is automatically generated from javascript.g. +// This file is automatically generated from qmljs.g. // Changes will be lost. // -#ifndef JAVASCRIPTPARSER_P_H -#define JAVASCRIPTPARSER_P_H +#ifndef QMLJSPARSER_P_H +#define QMLJSPARSER_P_H -#include "javascriptgrammar_p.h" -#include "javascriptast_p.h" -#include "javascriptengine_p.h" +#include "qmljsgrammar_p.h" +#include "qmljsast_p.h" +#include "qmljsengine_p.h" #include <QtCore/QList> @@ -215,7 +215,7 @@ QT_BEGIN_NAMESPACE class QString; -namespace JavaScript { +namespace QmlJS { class Engine; class NameId; @@ -262,6 +262,7 @@ public: AST::UiArrayBinding *UiArrayBinding; AST::UiObjectMember *UiObjectMember; AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; AST::UiQualifiedId *UiQualifiedId; }; @@ -337,7 +338,7 @@ protected: QList<DiagnosticMessage> diagnostic_messages; }; -} // end of namespace JavaScript +} // end of namespace QmlJS :/ @@ -345,15 +346,15 @@ protected: /. -#include "javascriptparser_p.h" +#include "qmljsparser_p.h" #include <QVarLengthArray> // -// This file is automatically generated from javascript.g. +// This file is automatically generated from qmljs.g. // Changes will be lost. // -using namespace JavaScript; +using namespace QmlJS; QT_BEGIN_NAMESPACE @@ -809,7 +810,7 @@ JsIdentifier: T_IDENTIFIER; JsIdentifier: T_PROPERTY ; /. case $rule_number: { - QString s = QLatin1String(JavaScriptGrammar::spell[T_PROPERTY]); + QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } @@ -818,7 +819,7 @@ case $rule_number: { JsIdentifier: T_SIGNAL ; /. case $rule_number: { - QString s = QLatin1String(JavaScriptGrammar::spell[T_SIGNAL]); + QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } @@ -2697,7 +2698,7 @@ case $rule_number: { } break; ./ ---JavaScriptProgram: SourceElements ; +--QmlJSProgram: SourceElements ; --/. --case $rule_number: { -- sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ()); @@ -2876,5 +2877,5 @@ QT_END_NAMESPACE -#endif // JAVASCRIPTPARSER_P_H +#endif // QMLJSPARSER_P_H :/ diff --git a/src/declarative/qml/parser/javascriptast.cpp b/src/declarative/qml/parser/qmljsast.cpp index ada19d5..d10c071 100644 --- a/src/declarative/qml/parser/javascriptast.cpp +++ b/src/declarative/qml/parser/qmljsast.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "javascriptast_p.h" +#include "qmljsast_p.h" -#include "javascriptastvisitor_p.h" +#include "qmljsastvisitor_p.h" QT_BEGIN_NAMESPACE -namespace JavaScript { namespace AST { +namespace QmlJS { namespace AST { int NumericLiteral::suffixLength[] = { 0, // noSuffix @@ -955,7 +955,7 @@ void UiSourceElement::accept0(Visitor *visitor) visitor->endVisit(this); } -} } // namespace JavaScript::AST +} } // namespace QmlJS::AST QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptast_p.h b/src/declarative/qml/parser/qmljsast_p.h index 8c1e2bc..8dc32ed 100644 --- a/src/declarative/qml/parser/javascriptast_p.h +++ b/src/declarative/qml/parser/qmljsast_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTAST_P_H -#define JAVASCRIPTAST_P_H +#ifndef QMLJSAST_P_H +#define QMLJSAST_P_H // // W A R N I N G @@ -53,12 +53,12 @@ // We mean it. // -#include "javascriptastvisitor_p.h" +#include "qmljsastvisitor_p.h" #include <QtCore/QString> QT_BEGIN_NAMESPACE -#define JAVASCRIPT_DECLARE_AST_NODE(name) \ +#define QMLJS_DECLARE_AST_NODE(name) \ enum { K = Kind_##name }; namespace QSOperator // ### rename @@ -104,7 +104,7 @@ enum Op { } // namespace QSOperator -namespace JavaScript { +namespace QmlJS { class NameId; namespace AST { @@ -271,7 +271,7 @@ public: class NestedExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NestedExpression) + QMLJS_DECLARE_AST_NODE(NestedExpression) NestedExpression(ExpressionNode *expression) : expression(expression) @@ -294,7 +294,7 @@ public: class ThisExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(ThisExpression) + QMLJS_DECLARE_AST_NODE(ThisExpression) ThisExpression() { kind = K; } virtual ~ThisExpression() {} @@ -314,7 +314,7 @@ public: class IdentifierExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(IdentifierExpression) + QMLJS_DECLARE_AST_NODE(IdentifierExpression) IdentifierExpression(NameId *n): name (n) { kind = K; } @@ -337,7 +337,7 @@ public: class NullExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NullExpression) + QMLJS_DECLARE_AST_NODE(NullExpression) NullExpression() { kind = K; } virtual ~NullExpression() {} @@ -357,7 +357,7 @@ public: class TrueLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(TrueLiteral) + QMLJS_DECLARE_AST_NODE(TrueLiteral) TrueLiteral() { kind = K; } virtual ~TrueLiteral() {} @@ -377,7 +377,7 @@ public: class FalseLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(FalseLiteral) + QMLJS_DECLARE_AST_NODE(FalseLiteral) FalseLiteral() { kind = K; } virtual ~FalseLiteral() {} @@ -397,9 +397,9 @@ public: class NumericLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NumericLiteral) + QMLJS_DECLARE_AST_NODE(NumericLiteral) - enum Suffix { // ### keep it in sync with the Suffix enum in javascriptlexer_p.h + enum Suffix { // ### keep it in sync with the Suffix enum in qmljslexer_p.h noSuffix, emSuffix, exSuffix, @@ -442,7 +442,7 @@ public: class StringLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(StringLiteral) + QMLJS_DECLARE_AST_NODE(StringLiteral) StringLiteral(NameId *v): value (v) { kind = K; } @@ -465,7 +465,7 @@ public: class RegExpLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(RegExpLiteral) + QMLJS_DECLARE_AST_NODE(RegExpLiteral) RegExpLiteral(NameId *p, int f): pattern (p), flags (f) { kind = K; } @@ -489,7 +489,7 @@ public: class ArrayLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(ArrayLiteral) + QMLJS_DECLARE_AST_NODE(ArrayLiteral) ArrayLiteral(Elision *e): elements (0), elision (e) @@ -524,7 +524,7 @@ public: class ObjectLiteral: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(ObjectLiteral) + QMLJS_DECLARE_AST_NODE(ObjectLiteral) ObjectLiteral(): properties (0) { kind = K; } @@ -551,7 +551,7 @@ public: class ElementList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(ElementList) + QMLJS_DECLARE_AST_NODE(ElementList) ElementList(Elision *e, ExpressionNode *expr): elision (e), expression (expr), next (this) @@ -586,7 +586,7 @@ public: class Elision: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(Elision) + QMLJS_DECLARE_AST_NODE(Elision) Elision(): next (this) { kind = K; } @@ -617,7 +617,7 @@ public: class PropertyNameAndValueList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(PropertyNameAndValueList) + QMLJS_DECLARE_AST_NODE(PropertyNameAndValueList) PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): name (n), value (v), next (this) @@ -653,7 +653,7 @@ public: class PropertyName: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(PropertyName) + QMLJS_DECLARE_AST_NODE(PropertyName) PropertyName() { kind = K; } virtual ~PropertyName() {} @@ -665,7 +665,7 @@ public: class IdentifierPropertyName: public PropertyName { public: - JAVASCRIPT_DECLARE_AST_NODE(IdentifierPropertyName) + QMLJS_DECLARE_AST_NODE(IdentifierPropertyName) IdentifierPropertyName(NameId *n): id (n) { kind = K; } @@ -681,7 +681,7 @@ public: class StringLiteralPropertyName: public PropertyName { public: - JAVASCRIPT_DECLARE_AST_NODE(StringLiteralPropertyName) + QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName) StringLiteralPropertyName(NameId *n): id (n) { kind = K; } @@ -696,7 +696,7 @@ public: class NumericLiteralPropertyName: public PropertyName { public: - JAVASCRIPT_DECLARE_AST_NODE(NumericLiteralPropertyName) + QMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName) NumericLiteralPropertyName(double n): id (n) { kind = K; } @@ -711,7 +711,7 @@ public: class ArrayMemberExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(ArrayMemberExpression) + QMLJS_DECLARE_AST_NODE(ArrayMemberExpression) ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): base (b), expression (e) @@ -737,7 +737,7 @@ public: class FieldMemberExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(FieldMemberExpression) + QMLJS_DECLARE_AST_NODE(FieldMemberExpression) FieldMemberExpression(ExpressionNode *b, NameId *n): base (b), name (n) @@ -763,7 +763,7 @@ public: class NewMemberExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NewMemberExpression) + QMLJS_DECLARE_AST_NODE(NewMemberExpression) NewMemberExpression(ExpressionNode *b, ArgumentList *a): base (b), arguments (a) @@ -790,7 +790,7 @@ public: class NewExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NewExpression) + QMLJS_DECLARE_AST_NODE(NewExpression) NewExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -813,7 +813,7 @@ public: class CallExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(CallExpression) + QMLJS_DECLARE_AST_NODE(CallExpression) CallExpression(ExpressionNode *b, ArgumentList *a): base (b), arguments (a) @@ -839,7 +839,7 @@ public: class ArgumentList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(ArgumentList) + QMLJS_DECLARE_AST_NODE(ArgumentList) ArgumentList(ExpressionNode *e): expression (e), next (this) @@ -873,7 +873,7 @@ public: class PostIncrementExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(PostIncrementExpression) + QMLJS_DECLARE_AST_NODE(PostIncrementExpression) PostIncrementExpression(ExpressionNode *b): base (b) { kind = K; } @@ -896,7 +896,7 @@ public: class PostDecrementExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(PostDecrementExpression) + QMLJS_DECLARE_AST_NODE(PostDecrementExpression) PostDecrementExpression(ExpressionNode *b): base (b) { kind = K; } @@ -919,7 +919,7 @@ public: class DeleteExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(DeleteExpression) + QMLJS_DECLARE_AST_NODE(DeleteExpression) DeleteExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -941,7 +941,7 @@ public: class VoidExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(VoidExpression) + QMLJS_DECLARE_AST_NODE(VoidExpression) VoidExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -964,7 +964,7 @@ public: class TypeOfExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(TypeOfExpression) + QMLJS_DECLARE_AST_NODE(TypeOfExpression) TypeOfExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -987,7 +987,7 @@ public: class PreIncrementExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(PreIncrementExpression) + QMLJS_DECLARE_AST_NODE(PreIncrementExpression) PreIncrementExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1010,7 +1010,7 @@ public: class PreDecrementExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(PreDecrementExpression) + QMLJS_DECLARE_AST_NODE(PreDecrementExpression) PreDecrementExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1033,7 +1033,7 @@ public: class UnaryPlusExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(UnaryPlusExpression) + QMLJS_DECLARE_AST_NODE(UnaryPlusExpression) UnaryPlusExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1056,7 +1056,7 @@ public: class UnaryMinusExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(UnaryMinusExpression) + QMLJS_DECLARE_AST_NODE(UnaryMinusExpression) UnaryMinusExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1079,7 +1079,7 @@ public: class TildeExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(TildeExpression) + QMLJS_DECLARE_AST_NODE(TildeExpression) TildeExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1102,7 +1102,7 @@ public: class NotExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(NotExpression) + QMLJS_DECLARE_AST_NODE(NotExpression) NotExpression(ExpressionNode *e): expression (e) { kind = K; } @@ -1125,7 +1125,7 @@ public: class BinaryExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(BinaryExpression) + QMLJS_DECLARE_AST_NODE(BinaryExpression) BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): left (l), op (o), right (r) @@ -1153,7 +1153,7 @@ public: class ConditionalExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(ConditionalExpression) + QMLJS_DECLARE_AST_NODE(ConditionalExpression) ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): expression (e), ok (t), ko (f) @@ -1180,7 +1180,7 @@ public: class Expression: public ExpressionNode // ### rename { public: - JAVASCRIPT_DECLARE_AST_NODE(Expression) + QMLJS_DECLARE_AST_NODE(Expression) Expression(ExpressionNode *l, ExpressionNode *r): left (l), right (r) { kind = K; } @@ -1204,7 +1204,7 @@ public: class Block: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(Block) + QMLJS_DECLARE_AST_NODE(Block) Block(StatementList *slist): statements (slist) { kind = K; } @@ -1228,7 +1228,7 @@ public: class StatementList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(StatementList) + QMLJS_DECLARE_AST_NODE(StatementList) StatementList(Statement *stmt): statement (stmt), next (this) @@ -1261,7 +1261,7 @@ public: class VariableStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(VariableStatement) + QMLJS_DECLARE_AST_NODE(VariableStatement) VariableStatement(VariableDeclarationList *vlist): declarations (vlist) @@ -1286,7 +1286,7 @@ public: class VariableDeclaration: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(VariableDeclaration) + QMLJS_DECLARE_AST_NODE(VariableDeclaration) VariableDeclaration(NameId *n, ExpressionNode *e): name (n), expression (e), readOnly(false) @@ -1306,7 +1306,7 @@ public: class VariableDeclarationList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(VariableDeclarationList) + QMLJS_DECLARE_AST_NODE(VariableDeclarationList) VariableDeclarationList(VariableDeclaration *decl): declaration (decl), next (this) @@ -1345,7 +1345,7 @@ public: class EmptyStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(EmptyStatement) + QMLJS_DECLARE_AST_NODE(EmptyStatement) EmptyStatement() { kind = K; } virtual ~EmptyStatement() {} @@ -1365,7 +1365,7 @@ public: class ExpressionStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ExpressionStatement) + QMLJS_DECLARE_AST_NODE(ExpressionStatement) ExpressionStatement(ExpressionNode *e): expression (e) { kind = K; } @@ -1388,7 +1388,7 @@ public: class IfStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(IfStatement) + QMLJS_DECLARE_AST_NODE(IfStatement) IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): expression (e), ok (t), ko (f) @@ -1422,7 +1422,7 @@ public: class DoWhileStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(DoWhileStatement) + QMLJS_DECLARE_AST_NODE(DoWhileStatement) DoWhileStatement(Statement *stmt, ExpressionNode *e): statement (stmt), expression (e) @@ -1451,7 +1451,7 @@ public: class WhileStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(WhileStatement) + QMLJS_DECLARE_AST_NODE(WhileStatement) WhileStatement(ExpressionNode *e, Statement *stmt): expression (e), statement (stmt) @@ -1478,7 +1478,7 @@ public: class ForStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ForStatement) + QMLJS_DECLARE_AST_NODE(ForStatement) ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): initialiser (i), condition (c), expression (e), statement (stmt) @@ -1509,7 +1509,7 @@ public: class LocalForStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(LocalForStatement) + QMLJS_DECLARE_AST_NODE(LocalForStatement) LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): declarations (vlist), condition (c), expression (e), statement (stmt) @@ -1541,7 +1541,7 @@ public: class ForEachStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ForEachStatement) + QMLJS_DECLARE_AST_NODE(ForEachStatement) ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): initialiser (i), expression (e), statement (stmt) @@ -1570,7 +1570,7 @@ public: class LocalForEachStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(LocalForEachStatement) + QMLJS_DECLARE_AST_NODE(LocalForEachStatement) LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): declaration (v), expression (e), statement (stmt) @@ -1600,7 +1600,7 @@ public: class ContinueStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ContinueStatement) + QMLJS_DECLARE_AST_NODE(ContinueStatement) ContinueStatement(NameId *l = 0): label (l) { kind = K; } @@ -1625,7 +1625,7 @@ public: class BreakStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(BreakStatement) + QMLJS_DECLARE_AST_NODE(BreakStatement) BreakStatement(NameId *l = 0): label (l) { kind = K; } @@ -1650,7 +1650,7 @@ public: class ReturnStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ReturnStatement) + QMLJS_DECLARE_AST_NODE(ReturnStatement) ReturnStatement(ExpressionNode *e): expression (e) { kind = K; } @@ -1674,7 +1674,7 @@ public: class WithStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(WithStatement) + QMLJS_DECLARE_AST_NODE(WithStatement) WithStatement(ExpressionNode *e, Statement *stmt): expression (e), statement (stmt) @@ -1701,7 +1701,7 @@ public: class CaseBlock: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(CaseBlock) + QMLJS_DECLARE_AST_NODE(CaseBlock) CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): clauses (c), defaultClause (d), moreClauses (r) @@ -1722,7 +1722,7 @@ public: class SwitchStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(SwitchStatement) + QMLJS_DECLARE_AST_NODE(SwitchStatement) SwitchStatement(ExpressionNode *e, CaseBlock *b): expression (e), block (b) @@ -1749,7 +1749,7 @@ public: class CaseClauses: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(CaseClauses) + QMLJS_DECLARE_AST_NODE(CaseClauses) CaseClauses(CaseClause *c): clause (c), next (this) @@ -1782,7 +1782,7 @@ public: class CaseClause: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(CaseClause) + QMLJS_DECLARE_AST_NODE(CaseClause) CaseClause(ExpressionNode *e, StatementList *slist): expression (e), statements (slist) @@ -1802,7 +1802,7 @@ public: class DefaultClause: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(DefaultClause) + QMLJS_DECLARE_AST_NODE(DefaultClause) DefaultClause(StatementList *slist): statements (slist) @@ -1821,7 +1821,7 @@ public: class LabelledStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(LabelledStatement) + QMLJS_DECLARE_AST_NODE(LabelledStatement) LabelledStatement(NameId *l, Statement *stmt): label (l), statement (stmt) @@ -1847,7 +1847,7 @@ public: class ThrowStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(ThrowStatement) + QMLJS_DECLARE_AST_NODE(ThrowStatement) ThrowStatement(ExpressionNode *e): expression (e) { kind = K; } @@ -1871,7 +1871,7 @@ public: class Catch: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(Catch) + QMLJS_DECLARE_AST_NODE(Catch) Catch(NameId *n, Block *stmt): name (n), statement (stmt) @@ -1893,7 +1893,7 @@ public: class Finally: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(Finally) + QMLJS_DECLARE_AST_NODE(Finally) Finally(Block *stmt): statement (stmt) @@ -1911,7 +1911,7 @@ public: class TryStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(TryStatement) + QMLJS_DECLARE_AST_NODE(TryStatement) TryStatement(Statement *stmt, Catch *c, Finally *f): statement (stmt), catchExpression (c), finallyExpression (f) @@ -1952,7 +1952,7 @@ public: class FunctionExpression: public ExpressionNode { public: - JAVASCRIPT_DECLARE_AST_NODE(FunctionExpression) + QMLJS_DECLARE_AST_NODE(FunctionExpression) FunctionExpression(NameId *n, FormalParameterList *f, FunctionBody *b): name (n), formals (f), body (b) @@ -1983,7 +1983,7 @@ public: class FunctionDeclaration: public FunctionExpression { public: - JAVASCRIPT_DECLARE_AST_NODE(FunctionDeclaration) + QMLJS_DECLARE_AST_NODE(FunctionDeclaration) FunctionDeclaration(NameId *n, FormalParameterList *f, FunctionBody *b): FunctionExpression(n, f, b) @@ -1997,7 +1997,7 @@ public: class FormalParameterList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(FormalParameterList) + QMLJS_DECLARE_AST_NODE(FormalParameterList) FormalParameterList(NameId *n): name (n), next (this) @@ -2032,7 +2032,7 @@ public: class FunctionBody: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(FunctionBody) + QMLJS_DECLARE_AST_NODE(FunctionBody) FunctionBody(SourceElements *elts): elements (elts) @@ -2049,7 +2049,7 @@ public: class Program: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(Program) + QMLJS_DECLARE_AST_NODE(Program) Program(SourceElements *elts): elements (elts) @@ -2066,7 +2066,7 @@ public: class SourceElements: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(SourceElements) + QMLJS_DECLARE_AST_NODE(SourceElements) SourceElements(SourceElement *elt): element (elt), next (this) @@ -2099,7 +2099,7 @@ public: class SourceElement: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(SourceElement) + QMLJS_DECLARE_AST_NODE(SourceElement) inline SourceElement() { kind = K; } @@ -2110,7 +2110,7 @@ public: class FunctionSourceElement: public SourceElement { public: - JAVASCRIPT_DECLARE_AST_NODE(FunctionSourceElement) + QMLJS_DECLARE_AST_NODE(FunctionSourceElement) FunctionSourceElement(FunctionDeclaration *f): declaration (f) @@ -2127,7 +2127,7 @@ public: class StatementSourceElement: public SourceElement { public: - JAVASCRIPT_DECLARE_AST_NODE(StatementSourceElement) + QMLJS_DECLARE_AST_NODE(StatementSourceElement) StatementSourceElement(Statement *stmt): statement (stmt) @@ -2144,7 +2144,7 @@ public: class DebuggerStatement: public Statement { public: - JAVASCRIPT_DECLARE_AST_NODE(DebuggerStatement) + QMLJS_DECLARE_AST_NODE(DebuggerStatement) DebuggerStatement() { kind = K; } @@ -2167,7 +2167,7 @@ public: class UiProgram: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiProgram) + QMLJS_DECLARE_AST_NODE(UiProgram) UiProgram(UiImportList *imports, UiObjectMemberList *members) : imports(imports), members(members) @@ -2183,7 +2183,7 @@ public: class UiQualifiedId: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiQualifiedId) + QMLJS_DECLARE_AST_NODE(UiQualifiedId) UiQualifiedId(NameId *name) : next(this), name(name) @@ -2217,7 +2217,7 @@ public: class UiImport: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiImport) + QMLJS_DECLARE_AST_NODE(UiImport) UiImport(NameId *fileName) : fileName(fileName) @@ -2235,7 +2235,7 @@ public: class UiImportList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiImportList) + QMLJS_DECLARE_AST_NODE(UiImportList) UiImportList(UiImport *import) : import(import), @@ -2274,7 +2274,7 @@ public: class UiObjectMemberList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiObjectMemberList) + QMLJS_DECLARE_AST_NODE(UiObjectMemberList) UiObjectMemberList(UiObjectMember *member) : next(this), member(member) @@ -2305,7 +2305,7 @@ public: class UiArrayMemberList: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiArrayMemberList) + QMLJS_DECLARE_AST_NODE(UiArrayMemberList) UiArrayMemberList(UiObjectMember *member) : next(this), member(member) @@ -2337,7 +2337,7 @@ public: class UiObjectInitializer: public Node { public: - JAVASCRIPT_DECLARE_AST_NODE(UiObjectInitializer) + QMLJS_DECLARE_AST_NODE(UiObjectInitializer) UiObjectInitializer(UiObjectMemberList *members) : members(members) @@ -2354,7 +2354,7 @@ public: class UiPublicMember: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiPublicMember) + QMLJS_DECLARE_AST_NODE(UiPublicMember) UiPublicMember(NameId *memberType, NameId *name) @@ -2399,7 +2399,7 @@ public: class UiObjectDefinition: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiObjectDefinition) + QMLJS_DECLARE_AST_NODE(UiObjectDefinition) UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, UiObjectInitializer *initializer) @@ -2422,7 +2422,7 @@ public: class UiSourceElement: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiSourceElement) + QMLJS_DECLARE_AST_NODE(UiSourceElement) UiSourceElement(Node *sourceElement) : sourceElement(sourceElement) @@ -2458,7 +2458,7 @@ public: class UiObjectBinding: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiObjectBinding) + QMLJS_DECLARE_AST_NODE(UiObjectBinding) UiObjectBinding(UiQualifiedId *qualifiedId, UiQualifiedId *qualifiedTypeNameId, @@ -2486,7 +2486,7 @@ public: class UiScriptBinding: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiScriptBinding) + QMLJS_DECLARE_AST_NODE(UiScriptBinding) UiScriptBinding(UiQualifiedId *qualifiedId, Statement *statement) @@ -2511,7 +2511,7 @@ public: class UiArrayBinding: public UiObjectMember { public: - JAVASCRIPT_DECLARE_AST_NODE(UiArrayBinding) + QMLJS_DECLARE_AST_NODE(UiArrayBinding) UiArrayBinding(UiQualifiedId *qualifiedId, UiArrayMemberList *members) diff --git a/src/declarative/qml/parser/javascriptastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h index 23270e5..339bea4 100644 --- a/src/declarative/qml/parser/javascriptastfwd_p.h +++ b/src/declarative/qml/parser/qmljsastfwd_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTAST_FWD_P_H -#define JAVASCRIPTAST_FWD_P_H +#ifndef QMLJSAST_FWD_P_H +#define QMLJSAST_FWD_P_H #include <QtCore/qglobal.h> @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -namespace JavaScript { namespace AST { +namespace QmlJS { namespace AST { class SourceLocation { diff --git a/src/declarative/qml/parser/javascriptastvisitor.cpp b/src/declarative/qml/parser/qmljsastvisitor.cpp index eac291d..642bcee 100644 --- a/src/declarative/qml/parser/javascriptastvisitor.cpp +++ b/src/declarative/qml/parser/qmljsastvisitor.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#include "javascriptastvisitor_p.h" +#include "qmljsastvisitor_p.h" QT_BEGIN_NAMESPACE -namespace JavaScript { namespace AST { +namespace QmlJS { namespace AST { Visitor::Visitor() { @@ -53,6 +53,6 @@ Visitor::~Visitor() { } -} } // namespace JavaScript::AST +} } // namespace QmlJS::AST QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptastvisitor_p.h b/src/declarative/qml/parser/qmljsastvisitor_p.h index 7c73e43..3677b1a 100644 --- a/src/declarative/qml/parser/javascriptastvisitor_p.h +++ b/src/declarative/qml/parser/qmljsastvisitor_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTASTVISITOR_P_H -#define JAVASCRIPTASTVISITOR_P_H +#ifndef QMLJSASTVISITOR_P_H +#define QMLJSASTVISITOR_P_H // // W A R N I N G @@ -53,11 +53,11 @@ // We mean it. // -#include "javascriptastfwd_p.h" +#include "qmljsastfwd_p.h" QT_BEGIN_NAMESPACE -namespace JavaScript { namespace AST { +namespace QmlJS { namespace AST { class Visitor { @@ -97,7 +97,7 @@ public: virtual void endVisit(UiArrayMemberList *) {} virtual void endVisit(UiQualifiedId *) {} - // JavaScript + // QmlJS virtual bool visit(ThisExpression *) { return true; } virtual void endVisit(ThisExpression *) {} @@ -325,4 +325,4 @@ public: QT_END_NAMESPACE -#endif // JAVASCRIPTASTVISITOR_P_H +#endif // QMLJSASTVISITOR_P_H diff --git a/src/declarative/qml/parser/javascriptengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index d893a90..42885d8 100644 --- a/src/declarative/qml/parser/javascriptengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -27,16 +27,16 @@ ** **************************************************************************/ -#include "javascriptengine_p.h" -#include "javascriptnodepool_p.h" +#include "qmljsengine_p.h" +#include "qmljsnodepool_p.h" #include <qnumeric.h> #include <QHash> QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { -uint qHash(const JavaScript::NameId &id) +uint qHash(const QmlJS::NameId &id) { return qHash(id.asString()); } QString numberToString(double value) @@ -186,6 +186,6 @@ void Engine::setNodePool(NodePool *nodePool) -} // end of namespace JavaScript +} // end of namespace QmlJS QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h index 3bd924a..b9ff042 100644 --- a/src/declarative/qml/parser/javascriptengine_p.h +++ b/src/declarative/qml/parser/qmljsengine_p.h @@ -27,17 +27,17 @@ ** **************************************************************************/ -#ifndef JAVASCRIPTENGINE_P_H -#define JAVASCRIPTENGINE_P_H +#ifndef QMLJSENGINE_P_H +#define QMLJSENGINE_P_H #include <QString> #include <QSet> -#include "javascriptastfwd_p.h" +#include "qmljsastfwd_p.h" QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { class NameId { QString _text; @@ -60,17 +60,17 @@ public: { return _text < other._text; } }; -uint qHash(const JavaScript::NameId &id); +uint qHash(const QmlJS::NameId &id); -} // end of namespace JavaScript +} // end of namespace QmlJS #if defined(Q_CC_MSVC) && _MSC_VER <= 1300 -//this ensures that code outside JavaScript can use the hash function +//this ensures that code outside QmlJS can use the hash function //it also a workaround for some compilers -inline uint qHash(const JavaScript::NameId &nameId) { return JavaScript::qHash(nameId); } +inline uint qHash(const QmlJS::NameId &nameId) { return QmlJS::qHash(nameId); } #endif -namespace JavaScript { +namespace QmlJS { class Lexer; class NodePool; @@ -138,8 +138,8 @@ public: void setNodePool(NodePool *nodePool); }; -} // end of namespace JavaScript +} // end of namespace QmlJS QT_END_NAMESPACE -#endif // JAVASCRIPTENGINE_P_H +#endif // QMLJSENGINE_P_H diff --git a/src/declarative/qml/parser/javascriptgrammar.cpp b/src/declarative/qml/parser/qmljsgrammar.cpp index a879bfe..835ee44 100644 --- a/src/declarative/qml/parser/javascriptgrammar.cpp +++ b/src/declarative/qml/parser/qmljsgrammar.cpp @@ -40,9 +40,9 @@ ** ****************************************************************************/ -#include "javascriptgrammar_p.h" +#include "qmljsgrammar_p.h" -const char *const JavaScriptGrammar::spell [] = { +const char *const QmlJSGrammar::spell [] = { "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue", "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", @@ -54,7 +54,7 @@ const char *const JavaScriptGrammar::spell [] = { "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "public", "import", 0, 0}; -const int JavaScriptGrammar::lhs [] = { +const int QmlJSGrammar::lhs [] = { 91, 92, 92, 95, 95, 96, 96, 94, 93, 98, 98, 100, 100, 101, 101, 97, 99, 99, 103, 104, 104, 99, 99, 99, 99, 99, 99, 99, 111, 111, @@ -89,7 +89,7 @@ const int JavaScriptGrammar::lhs [] = { 185, 186, 186, 189, 190, 190, 191, 191, 187, 187, 118, 118, 192}; -const int JavaScriptGrammar:: rhs[] = { +const int QmlJSGrammar:: rhs[] = { 2, 1, 1, 1, 2, 3, 3, 0, 1, 1, 2, 1, 3, 2, 3, 2, 1, 5, 1, 2, 2, 4, 3, 3, 3, 3, 3, 3, 1, 1, @@ -124,7 +124,7 @@ const int JavaScriptGrammar:: rhs[] = { 1, 0, 1, 1, 1, 2, 1, 1, 0, 1, 0, 1, 2}; -const int JavaScriptGrammar::action_default [] = { +const int QmlJSGrammar::action_default [] = { 8, 2, 0, 4, 3, 0, 0, 0, 6, 7, 5, 65, 45, 46, 43, 44, 47, 9, 0, 1, 0, 0, 16, 66, 41, 248, 0, 0, 46, 14, @@ -185,7 +185,7 @@ const int JavaScriptGrammar::action_default [] = { 0, 12, 0, 18, 13, 20, 21, 257, 250, 0, 258, 254, 0, 256, 246, 0, 247, 251, 323}; -const int JavaScriptGrammar::goto_default [] = { +const int QmlJSGrammar::goto_default [] = { 6, 5, 19, 1, 4, 3, 32, 34, 33, 570, 22, 18, 538, 539, 231, 226, 230, 232, 229, 236, 517, 235, 264, 57, 65, 495, 494, 388, 387, 48, @@ -198,7 +198,7 @@ const int JavaScriptGrammar::goto_default [] = { 454, 453, 473, 474, 220, 234, 216, 219, 233, 241, 240, 0}; -const int JavaScriptGrammar::action_index [] = { +const int QmlJSGrammar::action_index [] = { 8, -91, 14, -91, -15, 296, 67, 94, -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, 109, -91, 184, 408, -91, -91, -91, -91, 45, 125, 170, -91, @@ -319,7 +319,7 @@ const int JavaScriptGrammar::action_index [] = { -102, -102, 128, -102, -102, -102, -102, -102, -102, -102, -102, -102, -6, -102, -102, 58, -102, -102, -102}; -const int JavaScriptGrammar::action_info [] = { +const int QmlJSGrammar::action_info [] = { 338, 174, 289, 485, 472, 472, -89, 480, -105, 380, 43, 472, -79, -78, -100, 448, -97, 435, -102, 134, 304, 326, 132, 104, 478, 375, 489, 372, 374, 456, @@ -573,7 +573,7 @@ const int JavaScriptGrammar::action_info [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const int JavaScriptGrammar::action_check [] = { +const int QmlJSGrammar::action_check [] = { 60, 8, 36, 36, 33, 33, 7, 60, 7, 36, 29, 33, 7, 7, 7, 36, 7, 55, 7, 78, 1, 78, 48, 1, 36, 33, 36, 36, 60, 5, diff --git a/src/declarative/qml/parser/javascriptgrammar_p.h b/src/declarative/qml/parser/qmljsgrammar_p.h index 830f533..c514485 100644 --- a/src/declarative/qml/parser/javascriptgrammar_p.h +++ b/src/declarative/qml/parser/qmljsgrammar_p.h @@ -51,10 +51,10 @@ // We mean it. // -#ifndef JAVASCRIPTGRAMMAR_P_H -#define JAVASCRIPTGRAMMAR_P_H +#ifndef QMLJSGRAMMAR_P_H +#define QMLJSGRAMMAR_P_H -class JavaScriptGrammar +class QmlJSGrammar { public: enum { @@ -196,5 +196,5 @@ public: }; -#endif // JAVASCRIPTGRAMMAR_P_H +#endif // QMLJSGRAMMAR_P_H diff --git a/src/declarative/qml/parser/javascriptlexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index ea36a7a..843f6ae 100644 --- a/src/declarative/qml/parser/javascriptlexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -43,9 +43,9 @@ #include "config.h" #endif -#include "javascriptengine_p.h" -#include "javascriptlexer_p.h" -#include "javascriptgrammar_p.h" +#include "qmljsengine_p.h" +#include "qmljslexer_p.h" +#include "qmljsgrammar_p.h" #include <ctype.h> #include <stdlib.h> @@ -65,11 +65,11 @@ extern double qstrtod(const char *s00, char const **se, bool *ok); } \ while (0) -namespace JavaScript { +namespace QmlJS { extern double integerFromString(const char *buf, int size, int radix); } -using namespace JavaScript; +using namespace QmlJS; Lexer::Lexer(Engine *eng) : driver(eng), @@ -154,66 +154,66 @@ int Lexer::findReservedWord(const QChar *c, int size) const switch (size) { case 2: { if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o')) - return JavaScriptGrammar::T_DO; + return QmlJSGrammar::T_DO; else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('f')) - return JavaScriptGrammar::T_IF; + return QmlJSGrammar::T_IF; else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')) - return JavaScriptGrammar::T_IN; + return QmlJSGrammar::T_IN; } break; case 3: { if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('r')) - return JavaScriptGrammar::T_FOR; + return QmlJSGrammar::T_FOR; else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('w')) - return JavaScriptGrammar::T_NEW; + return QmlJSGrammar::T_NEW; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('y')) - return JavaScriptGrammar::T_TRY; + return QmlJSGrammar::T_TRY; else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('r')) - return JavaScriptGrammar::T_VAR; + return QmlJSGrammar::T_VAR; else if (check_reserved) { if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; case 4: { if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e')) - return JavaScriptGrammar::T_CASE; + return QmlJSGrammar::T_CASE; else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('l') && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('e')) - return JavaScriptGrammar::T_ELSE; + return QmlJSGrammar::T_ELSE; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('s')) - return JavaScriptGrammar::T_THIS; + return QmlJSGrammar::T_THIS; else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('d')) - return JavaScriptGrammar::T_VOID; + return QmlJSGrammar::T_VOID; else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('i') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('h')) - return JavaScriptGrammar::T_WITH; + return QmlJSGrammar::T_WITH; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('e')) - return JavaScriptGrammar::T_TRUE; + return QmlJSGrammar::T_TRUE; else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('u') && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('l')) - return JavaScriptGrammar::T_NULL; + return QmlJSGrammar::T_NULL; else if (check_reserved) { if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('n') && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('m')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('y') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('l') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('g')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('r')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('g') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('o')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -221,48 +221,48 @@ int Lexer::findReservedWord(const QChar *c, int size) const if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('e') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('k')) - return JavaScriptGrammar::T_BREAK; + return QmlJSGrammar::T_BREAK; else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('c') && c[4] == QLatin1Char('h')) - return JavaScriptGrammar::T_CATCH; + return QmlJSGrammar::T_CATCH; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o') && c[4] == QLatin1Char('w')) - return JavaScriptGrammar::T_THROW; + return QmlJSGrammar::T_THROW; else if (c[0] == QLatin1Char('w') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('l') && c[4] == QLatin1Char('e')) - return JavaScriptGrammar::T_WHILE; + return QmlJSGrammar::T_WHILE; else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('s') && c[4] == QLatin1Char('t')) - return JavaScriptGrammar::T_CONST; + return QmlJSGrammar::T_CONST; else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('s') && c[4] == QLatin1Char('e')) - return JavaScriptGrammar::T_FALSE; + return QmlJSGrammar::T_FALSE; else if (check_reserved) { if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('r') && c[4] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('u') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e') && c[4] == QLatin1Char('r')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i') && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('l')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('c') && c[1] == QLatin1Char('l') && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('s') && c[4] == QLatin1Char('s')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('l') && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -270,56 +270,56 @@ int Lexer::findReservedWord(const QChar *c, int size) const if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('e') && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('e')) - return JavaScriptGrammar::T_DELETE; + return QmlJSGrammar::T_DELETE; else if (c[0] == QLatin1Char('r') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('u') && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('n')) - return JavaScriptGrammar::T_RETURN; + return QmlJSGrammar::T_RETURN; else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('w') && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('t') && c[4] == QLatin1Char('c') && c[5] == QLatin1Char('h')) - return JavaScriptGrammar::T_SWITCH; + return QmlJSGrammar::T_SWITCH; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('y') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('e') && c[4] == QLatin1Char('o') && c[5] == QLatin1Char('f')) - return JavaScriptGrammar::T_TYPEOF; + return QmlJSGrammar::T_TYPEOF; else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o') && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t')) - return JavaScriptGrammar::T_IMPORT; + return QmlJSGrammar::T_IMPORT; else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('i') && c[2] == QLatin1Char('g') && c[3] == QLatin1Char('n') && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('l')) - return JavaScriptGrammar::T_SIGNAL; + return QmlJSGrammar::T_SIGNAL; else if (check_reserved) { if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o') && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('s') && c[1] == QLatin1Char('t') && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('t') && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('u') && c[3] == QLatin1Char('b') && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('o') && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('u') && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('l') && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('c')) - return JavaScriptGrammar::T_PUBLIC; + return QmlJSGrammar::T_PUBLIC; else if (c[0] == QLatin1Char('n') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('i') && c[4] == QLatin1Char('v') && c[5] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('h') && c[2] == QLatin1Char('r') && c[3] == QLatin1Char('o') && c[4] == QLatin1Char('w') && c[5] == QLatin1Char('s')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -328,33 +328,33 @@ int Lexer::findReservedWord(const QChar *c, int size) const && c[2] == QLatin1Char('f') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('u') && c[5] == QLatin1Char('l') && c[6] == QLatin1Char('t')) - return JavaScriptGrammar::T_DEFAULT; + return QmlJSGrammar::T_DEFAULT; else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('i') && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('l') && c[5] == QLatin1Char('l') && c[6] == QLatin1Char('y')) - return JavaScriptGrammar::T_FINALLY; + return QmlJSGrammar::T_FINALLY; else if (check_reserved) { if (c[0] == QLatin1Char('b') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('l') && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('a') && c[6] == QLatin1Char('n')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('e') && c[1] == QLatin1Char('x') && c[2] == QLatin1Char('t') && c[3] == QLatin1Char('e') && c[4] == QLatin1Char('n') && c[5] == QLatin1Char('d') && c[6] == QLatin1Char('s')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('a') && c[2] == QLatin1Char('c') && c[3] == QLatin1Char('k') && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('g') && c[6] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('i') && c[3] == QLatin1Char('v') && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('t') && c[6] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -363,33 +363,33 @@ int Lexer::findReservedWord(const QChar *c, int size) const && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('t') && c[4] == QLatin1Char('i') && c[5] == QLatin1Char('n') && c[6] == QLatin1Char('u') && c[7] == QLatin1Char('e')) - return JavaScriptGrammar::T_CONTINUE; + return QmlJSGrammar::T_CONTINUE; else if (c[0] == QLatin1Char('f') && c[1] == QLatin1Char('u') && c[2] == QLatin1Char('n') && c[3] == QLatin1Char('c') && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i') && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n')) - return JavaScriptGrammar::T_FUNCTION; + return QmlJSGrammar::T_FUNCTION; else if (c[0] == QLatin1Char('d') && c[1] == QLatin1Char('e') && c[2] == QLatin1Char('b') && c[3] == QLatin1Char('u') && c[4] == QLatin1Char('g') && c[5] == QLatin1Char('g') && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('r')) - return JavaScriptGrammar::T_DEBUGGER; + return QmlJSGrammar::T_DEBUGGER; else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('p') && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('r') && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('y')) - return JavaScriptGrammar::T_PROPERTY; + return QmlJSGrammar::T_PROPERTY; else if (check_reserved) { if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('b') && c[2] == QLatin1Char('s') && c[3] == QLatin1Char('t') && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('a') && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('v') && c[1] == QLatin1Char('o') && c[2] == QLatin1Char('l') && c[3] == QLatin1Char('a') && c[4] == QLatin1Char('t') && c[5] == QLatin1Char('i') && c[6] == QLatin1Char('l') && c[7] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -400,19 +400,19 @@ int Lexer::findReservedWord(const QChar *c, int size) const && c[4] == QLatin1Char('r') && c[5] == QLatin1Char('f') && c[6] == QLatin1Char('a') && c[7] == QLatin1Char('c') && c[8] == QLatin1Char('e')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('t') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('a') && c[3] == QLatin1Char('n') && c[4] == QLatin1Char('s') && c[5] == QLatin1Char('i') && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n') && c[8] == QLatin1Char('t')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; else if (c[0] == QLatin1Char('p') && c[1] == QLatin1Char('r') && c[2] == QLatin1Char('o') && c[3] == QLatin1Char('t') && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('c') && c[6] == QLatin1Char('t') && c[7] == QLatin1Char('e') && c[8] == QLatin1Char('d')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -422,14 +422,14 @@ int Lexer::findReservedWord(const QChar *c, int size) const && c[4] == QLatin1Char('a') && c[5] == QLatin1Char('n') && c[6] == QLatin1Char('c') && c[7] == QLatin1Char('e') && c[8] == QLatin1Char('o') && c[9] == QLatin1Char('f')) - return JavaScriptGrammar::T_INSTANCEOF; + return QmlJSGrammar::T_INSTANCEOF; else if (check_reserved) { if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('m') && c[2] == QLatin1Char('p') && c[3] == QLatin1Char('l') && c[4] == QLatin1Char('e') && c[5] == QLatin1Char('m') && c[6] == QLatin1Char('e') && c[7] == QLatin1Char('n') && c[8] == QLatin1Char('t') && c[9] == QLatin1Char('s')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -441,7 +441,7 @@ int Lexer::findReservedWord(const QChar *c, int size) const && c[6] == QLatin1Char('o') && c[7] == QLatin1Char('n') && c[8] == QLatin1Char('i') && c[9] == QLatin1Char('z') && c[10] == QLatin1Char('e') && c[11] == QLatin1Char('d')) - return JavaScriptGrammar::T_RESERVED_WORD; + return QmlJSGrammar::T_RESERVED_WORD; } } break; @@ -485,7 +485,7 @@ int Lexer::lex() syncProhibitAutomaticSemicolon(); if (!terminator && !delimited && !prohibitAutomaticSemicolon) { // automatic semicolon insertion if program incomplete - token = JavaScriptGrammar::T_SEMICOLON; + token = QmlJSGrammar::T_SEMICOLON; stackToken = 0; setDone(Other); } else { @@ -499,7 +499,7 @@ int Lexer::lex() terminator = true; syncProhibitAutomaticSemicolon(); if (restrKeyword) { - token = JavaScriptGrammar::T_SEMICOLON; + token = QmlJSGrammar::T_SEMICOLON; setDone(Other); } } else if (current == '"' || current == '\'') { @@ -528,11 +528,11 @@ int Lexer::lex() token = matchPunctuator(current, next1, next2, next3); if (token != -1) { if (terminator && !delimited && !prohibitAutomaticSemicolon - && (token == JavaScriptGrammar::T_PLUS_PLUS - || token == JavaScriptGrammar::T_MINUS_MINUS)) { + && (token == QmlJSGrammar::T_PLUS_PLUS + || token == QmlJSGrammar::T_MINUS_MINUS)) { // automatic semicolon insertion stackToken = token; - token = JavaScriptGrammar::T_SEMICOLON; + token = QmlJSGrammar::T_SEMICOLON; } setDone(Other); } @@ -636,7 +636,7 @@ int Lexer::lex() terminator = true; bol = true; if (restrKeyword) { - token = JavaScriptGrammar::T_SEMICOLON; + token = QmlJSGrammar::T_SEMICOLON; setDone(Other); } else state = Start; @@ -840,11 +840,11 @@ int Lexer::lex() case IgnoreParentheses: break; case CountParentheses: - if (token == JavaScriptGrammar::T_RPAREN) { + if (token == QmlJSGrammar::T_RPAREN) { --parenthesesCount; if (parenthesesCount == 0) parenthesesState = BalancedParentheses; - } else if (token == JavaScriptGrammar::T_LPAREN) { + } else if (token == QmlJSGrammar::T_LPAREN) { ++parenthesesCount; } break; @@ -857,7 +857,7 @@ int Lexer::lex() case Eof: return 0; case Other: - if (token == JavaScriptGrammar::T_RBRACE || token == JavaScriptGrammar::T_SEMICOLON) + if (token == QmlJSGrammar::T_RBRACE || token == QmlJSGrammar::T_SEMICOLON) delimited = true; return token; case Identifier: @@ -867,16 +867,16 @@ int Lexer::lex() qsyylval.ustr = driver->intern(buffer16, pos16); else qsyylval.ustr = 0; - return JavaScriptGrammar::T_IDENTIFIER; + return QmlJSGrammar::T_IDENTIFIER; } - if (token == JavaScriptGrammar::T_CONTINUE || token == JavaScriptGrammar::T_BREAK - || token == JavaScriptGrammar::T_RETURN || token == JavaScriptGrammar::T_THROW) { + if (token == QmlJSGrammar::T_CONTINUE || token == QmlJSGrammar::T_BREAK + || token == QmlJSGrammar::T_RETURN || token == QmlJSGrammar::T_THROW) { restrKeyword = true; - } else if (token == JavaScriptGrammar::T_IF || token == JavaScriptGrammar::T_FOR - || token == JavaScriptGrammar::T_WHILE || token == JavaScriptGrammar::T_WITH) { + } else if (token == QmlJSGrammar::T_IF || token == QmlJSGrammar::T_FOR + || token == QmlJSGrammar::T_WHILE || token == QmlJSGrammar::T_WITH) { parenthesesState = CountParentheses; parenthesesCount = 0; - } else if (token == JavaScriptGrammar::T_DO) { + } else if (token == QmlJSGrammar::T_DO) { parenthesesState = BalancedParentheses; } return token; @@ -885,10 +885,10 @@ int Lexer::lex() qsyylval.ustr = driver->intern(buffer16, pos16); else qsyylval.ustr = 0; - return multiLineString?JavaScriptGrammar::T_MULTILINE_STRING_LITERAL:JavaScriptGrammar::T_STRING_LITERAL; + return multiLineString?QmlJSGrammar::T_MULTILINE_STRING_LITERAL:QmlJSGrammar::T_STRING_LITERAL; case Number: qsyylval.dval = dval; - return JavaScriptGrammar::T_NUMERIC_LITERAL; + return QmlJSGrammar::T_NUMERIC_LITERAL; case Bad: return -1; default: @@ -939,103 +939,103 @@ int Lexer::matchPunctuator(ushort c1, ushort c2, { if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { shift(4); - return JavaScriptGrammar::T_GT_GT_GT_EQ; + return QmlJSGrammar::T_GT_GT_GT_EQ; } else if (c1 == '=' && c2 == '=' && c3 == '=') { shift(3); - return JavaScriptGrammar::T_EQ_EQ_EQ; + return QmlJSGrammar::T_EQ_EQ_EQ; } else if (c1 == '!' && c2 == '=' && c3 == '=') { shift(3); - return JavaScriptGrammar::T_NOT_EQ_EQ; + return QmlJSGrammar::T_NOT_EQ_EQ; } else if (c1 == '>' && c2 == '>' && c3 == '>') { shift(3); - return JavaScriptGrammar::T_GT_GT_GT; + return QmlJSGrammar::T_GT_GT_GT; } else if (c1 == '<' && c2 == '<' && c3 == '=') { shift(3); - return JavaScriptGrammar::T_LT_LT_EQ; + return QmlJSGrammar::T_LT_LT_EQ; } else if (c1 == '>' && c2 == '>' && c3 == '=') { shift(3); - return JavaScriptGrammar::T_GT_GT_EQ; + return QmlJSGrammar::T_GT_GT_EQ; } else if (c1 == '<' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_LE; + return QmlJSGrammar::T_LE; } else if (c1 == '>' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_GE; + return QmlJSGrammar::T_GE; } else if (c1 == '!' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_NOT_EQ; + return QmlJSGrammar::T_NOT_EQ; } else if (c1 == '+' && c2 == '+') { shift(2); - return JavaScriptGrammar::T_PLUS_PLUS; + return QmlJSGrammar::T_PLUS_PLUS; } else if (c1 == '-' && c2 == '-') { shift(2); - return JavaScriptGrammar::T_MINUS_MINUS; + return QmlJSGrammar::T_MINUS_MINUS; } else if (c1 == '=' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_EQ_EQ; + return QmlJSGrammar::T_EQ_EQ; } else if (c1 == '+' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_PLUS_EQ; + return QmlJSGrammar::T_PLUS_EQ; } else if (c1 == '-' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_MINUS_EQ; + return QmlJSGrammar::T_MINUS_EQ; } else if (c1 == '*' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_STAR_EQ; + return QmlJSGrammar::T_STAR_EQ; } else if (c1 == '/' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_DIVIDE_EQ; + return QmlJSGrammar::T_DIVIDE_EQ; } else if (c1 == '&' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_AND_EQ; + return QmlJSGrammar::T_AND_EQ; } else if (c1 == '^' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_XOR_EQ; + return QmlJSGrammar::T_XOR_EQ; } else if (c1 == '%' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_REMAINDER_EQ; + return QmlJSGrammar::T_REMAINDER_EQ; } else if (c1 == '|' && c2 == '=') { shift(2); - return JavaScriptGrammar::T_OR_EQ; + return QmlJSGrammar::T_OR_EQ; } else if (c1 == '<' && c2 == '<') { shift(2); - return JavaScriptGrammar::T_LT_LT; + return QmlJSGrammar::T_LT_LT; } else if (c1 == '>' && c2 == '>') { shift(2); - return JavaScriptGrammar::T_GT_GT; + return QmlJSGrammar::T_GT_GT; } else if (c1 == '&' && c2 == '&') { shift(2); - return JavaScriptGrammar::T_AND_AND; + return QmlJSGrammar::T_AND_AND; } else if (c1 == '|' && c2 == '|') { shift(2); - return JavaScriptGrammar::T_OR_OR; + return QmlJSGrammar::T_OR_OR; } switch(c1) { - case '=': shift(1); return JavaScriptGrammar::T_EQ; - case '>': shift(1); return JavaScriptGrammar::T_GT; - case '<': shift(1); return JavaScriptGrammar::T_LT; - case ',': shift(1); return JavaScriptGrammar::T_COMMA; - case '!': shift(1); return JavaScriptGrammar::T_NOT; - case '~': shift(1); return JavaScriptGrammar::T_TILDE; - case '?': shift(1); return JavaScriptGrammar::T_QUESTION; - case ':': shift(1); return JavaScriptGrammar::T_COLON; - case '.': shift(1); return JavaScriptGrammar::T_DOT; - case '+': shift(1); return JavaScriptGrammar::T_PLUS; - case '-': shift(1); return JavaScriptGrammar::T_MINUS; - case '*': shift(1); return JavaScriptGrammar::T_STAR; - case '/': shift(1); return JavaScriptGrammar::T_DIVIDE_; - case '&': shift(1); return JavaScriptGrammar::T_AND; - case '|': shift(1); return JavaScriptGrammar::T_OR; - case '^': shift(1); return JavaScriptGrammar::T_XOR; - case '%': shift(1); return JavaScriptGrammar::T_REMAINDER; - case '(': shift(1); return JavaScriptGrammar::T_LPAREN; - case ')': shift(1); return JavaScriptGrammar::T_RPAREN; - case '{': shift(1); return JavaScriptGrammar::T_LBRACE; - case '}': shift(1); return JavaScriptGrammar::T_RBRACE; - case '[': shift(1); return JavaScriptGrammar::T_LBRACKET; - case ']': shift(1); return JavaScriptGrammar::T_RBRACKET; - case ';': shift(1); return JavaScriptGrammar::T_SEMICOLON; + case '=': shift(1); return QmlJSGrammar::T_EQ; + case '>': shift(1); return QmlJSGrammar::T_GT; + case '<': shift(1); return QmlJSGrammar::T_LT; + case ',': shift(1); return QmlJSGrammar::T_COMMA; + case '!': shift(1); return QmlJSGrammar::T_NOT; + case '~': shift(1); return QmlJSGrammar::T_TILDE; + case '?': shift(1); return QmlJSGrammar::T_QUESTION; + case ':': shift(1); return QmlJSGrammar::T_COLON; + case '.': shift(1); return QmlJSGrammar::T_DOT; + case '+': shift(1); return QmlJSGrammar::T_PLUS; + case '-': shift(1); return QmlJSGrammar::T_MINUS; + case '*': shift(1); return QmlJSGrammar::T_STAR; + case '/': shift(1); return QmlJSGrammar::T_DIVIDE_; + case '&': shift(1); return QmlJSGrammar::T_AND; + case '|': shift(1); return QmlJSGrammar::T_OR; + case '^': shift(1); return QmlJSGrammar::T_XOR; + case '%': shift(1); return QmlJSGrammar::T_REMAINDER; + case '(': shift(1); return QmlJSGrammar::T_LPAREN; + case ')': shift(1); return QmlJSGrammar::T_RPAREN; + case '{': shift(1); return QmlJSGrammar::T_LBRACE; + case '}': shift(1); return QmlJSGrammar::T_RBRACE; + case '[': shift(1); return QmlJSGrammar::T_LBRACKET; + case ']': shift(1); return QmlJSGrammar::T_RBRACKET; + case ';': shift(1); return QmlJSGrammar::T_SEMICOLON; default: return -1; } diff --git a/src/declarative/qml/parser/javascriptlexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h index a47c1ae..e1ff23e 100644 --- a/src/declarative/qml/parser/javascriptlexer_p.h +++ b/src/declarative/qml/parser/qmljslexer_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTLEXER_P_H -#define JAVASCRIPTLEXER_P_H +#ifndef QMLJSLEXER_P_H +#define QMLJSLEXER_P_H // // W A R N I N G @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { class Engine; class NameId; @@ -260,7 +260,7 @@ private: bool prohibitAutomaticSemicolon; }; -} // namespace JavaScript +} // namespace QmlJS QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptmemorypool_p.h b/src/declarative/qml/parser/qmljsmemorypool_p.h index cff7677..d7506be 100644 --- a/src/declarative/qml/parser/javascriptmemorypool_p.h +++ b/src/declarative/qml/parser/qmljsmemorypool_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTMEMORYPOOL_P_H -#define JAVASCRIPTMEMORYPOOL_P_H +#ifndef QMLJSMEMORYPOOL_P_H +#define QMLJSMEMORYPOOL_P_H // // W A R N I N G @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { class MemoryPool : public QSharedData { @@ -123,7 +123,7 @@ private: Q_DISABLE_COPY(MemoryPool) }; -} // namespace JavaScript +} // namespace QmlJS QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptnodepool_p.h b/src/declarative/qml/parser/qmljsnodepool_p.h index cb56fbb..1a5b7f6 100644 --- a/src/declarative/qml/parser/javascriptnodepool_p.h +++ b/src/declarative/qml/parser/qmljsnodepool_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTNODEPOOL_P_H -#define JAVASCRIPTNODEPOOL_P_H +#ifndef QMLJSNODEPOOL_P_H +#define QMLJSNODEPOOL_P_H // // W A R N I N G @@ -56,11 +56,11 @@ #include <QtCore/QHash> #include <QtCore/QString> -#include "javascriptmemorypool_p.h" +#include "qmljsmemorypool_p.h" QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { namespace AST { class Node; @@ -131,7 +131,7 @@ private: Q_DISABLE_COPY(NodePool) }; -} // namespace JavaScript +} // namespace QmlJS QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index bbffc4f..6ecff3d 100644 --- a/src/declarative/qml/parser/javascriptparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -45,22 +45,22 @@ #include <string.h> -#include "javascriptengine_p.h" -#include "javascriptlexer_p.h" -#include "javascriptast_p.h" -#include "javascriptnodepool_p.h" +#include "qmljsengine_p.h" +#include "qmljslexer_p.h" +#include "qmljsast_p.h" +#include "qmljsnodepool_p.h" -#include "javascriptparser_p.h" +#include "qmljsparser_p.h" #include <QVarLengthArray> // -// This file is automatically generated from javascript.g. +// This file is automatically generated from qmljs.g. // Changes will be lost. // -using namespace JavaScript; +using namespace QmlJS; QT_BEGIN_NAMESPACE @@ -78,7 +78,7 @@ void Parser::reallocateStack() inline static bool automatic(Engine *driver, int token) { - return token == JavaScriptGrammar::T_RBRACE + return token == QmlJSGrammar::T_RBRACE || token == 0 || driver->lexer()->prevTerminator(); } @@ -389,13 +389,13 @@ case 43: } break; case 45: { - QString s = QLatin1String(JavaScriptGrammar::spell[T_PROPERTY]); + QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } case 46: { - QString s = QLatin1String(JavaScriptGrammar::spell[T_SIGNAL]); + QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } diff --git a/src/declarative/qml/parser/javascriptparser_p.h b/src/declarative/qml/parser/qmljsparser_p.h index b6a2432..cd2c7f5 100644 --- a/src/declarative/qml/parser/javascriptparser_p.h +++ b/src/declarative/qml/parser/qmljsparser_p.h @@ -53,16 +53,16 @@ // // -// This file is automatically generated from javascript.g. +// This file is automatically generated from qmljs.g. // Changes will be lost. // -#ifndef JAVASCRIPTPARSER_P_H -#define JAVASCRIPTPARSER_P_H +#ifndef QMLJSPARSER_P_H +#define QMLJSPARSER_P_H -#include "javascriptgrammar_p.h" -#include "javascriptast_p.h" -#include "javascriptengine_p.h" +#include "qmljsgrammar_p.h" +#include "qmljsast_p.h" +#include "qmljsengine_p.h" #include <QtCore/QList> @@ -70,12 +70,12 @@ QT_BEGIN_NAMESPACE class QString; -namespace JavaScript { +namespace QmlJS { class Engine; class NameId; -class Parser: protected JavaScriptGrammar +class Parser: protected QmlJSGrammar { public: union Value { @@ -193,7 +193,7 @@ protected: QList<DiagnosticMessage> diagnostic_messages; }; -} // end of namespace JavaScript +} // end of namespace QmlJS @@ -205,4 +205,4 @@ QT_END_NAMESPACE -#endif // JAVASCRIPTPARSER_P_H +#endif // QMLJSPARSER_P_H diff --git a/src/declarative/qml/parser/javascriptprettypretty.cpp b/src/declarative/qml/parser/qmljsprettypretty.cpp index 0342b39..1045792 100644 --- a/src/declarative/qml/parser/javascriptprettypretty.cpp +++ b/src/declarative/qml/parser/qmljsprettypretty.cpp @@ -39,16 +39,16 @@ ** ****************************************************************************/ -#include "javascriptprettypretty_p.h" +#include "qmljsprettypretty_p.h" -#include "javascriptengine_p.h" +#include "qmljsengine_p.h" -#include "javascriptast_p.h" +#include "qmljsast_p.h" #include <QtCore/QString> #include <QtCore/QTextStream> @@ -56,11 +56,11 @@ QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { QString numberToString(double value); } -using namespace JavaScript; +using namespace QmlJS; PrettyPretty::PrettyPretty(QTextStream &o): out(o), m_indentLevel(0) @@ -242,7 +242,7 @@ void PrettyPretty::endVisit(AST::StringLiteral *node) bool PrettyPretty::visit(AST::NumericLiteral *node) { - out << JavaScript::numberToString(node->value); + out << QmlJS::numberToString(node->value); return true; } @@ -255,7 +255,7 @@ bool PrettyPretty::visit(AST::RegExpLiteral *node) { out << "/" << Engine::toString(node->pattern) << "/"; if (node->flags) - out << JavaScript::Ecma::RegExp::flagsToString(node->flags); + out << QmlJS::Ecma::RegExp::flagsToString(node->flags); return true; } diff --git a/src/declarative/qml/parser/javascriptprettypretty_p.h b/src/declarative/qml/parser/qmljsprettypretty_p.h index c692da5..fe82ca2 100644 --- a/src/declarative/qml/parser/javascriptprettypretty_p.h +++ b/src/declarative/qml/parser/qmljsprettypretty_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef JAVASCRIPTPRETTYPRETTY_P_H -#define JAVASCRIPTPRETTYPRETTY_P_H +#ifndef QMLJSPRETTYPRETTY_P_H +#define QMLJSPRETTYPRETTY_P_H // // W A R N I N G @@ -55,13 +55,13 @@ #include <QtCore/qglobal.h> -#include "javascriptastvisitor_p.h" +#include "qmljsastvisitor_p.h" QT_BEGIN_NAMESPACE class QTextStream; -namespace JavaScript { +namespace QmlJS { class PrettyPretty: protected AST::Visitor { @@ -322,7 +322,7 @@ private: Q_DISABLE_COPY(PrettyPretty) }; -} // namespace JavaScript +} // namespace QmlJS QT_END_NAMESPACE diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 370bb58..51ca612 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -90,6 +90,7 @@ QT_MODULE(Declarative) class QmlContext; class QmlEngine; +Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); Q_DECLARATIVE_EXPORT QmlContext *qmlContext(const QObject *); Q_DECLARATIVE_EXPORT QmlEngine *qmlEngine(const QObject *); Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *); diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index d8e65bf..a679532 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -17,12 +17,12 @@ #include <QStack> #include <qfxperf.h> #include <private/qmlrefcount_p.h> -#include <private/javascriptast_p.h> -#include <private/javascriptengine_p.h> +#include <private/qmljsast_p.h> +#include <private/qmljsengine_p.h> QT_BEGIN_NAMESPACE -using namespace JavaScript; +using namespace QmlJS; struct ScriptInstruction { enum { @@ -270,16 +270,16 @@ struct QmlBasicScriptCompiler QmlParser::Object *component; QHash<QString, QPair<QmlParser::Object *, int> > ids; - bool compile(JavaScript::AST::Node *); + bool compile(QmlJS::AST::Node *); - bool compileExpression(JavaScript::AST::Node *); + bool compileExpression(QmlJS::AST::Node *); - bool tryConstant(JavaScript::AST::Node *); - bool parseConstant(JavaScript::AST::Node *); - bool tryName(JavaScript::AST::Node *); - bool parseName(JavaScript::AST::Node *, QmlParser::Object ** = 0); - bool tryBinaryExpression(JavaScript::AST::Node *); - bool compileBinaryExpression(JavaScript::AST::Node *); + bool tryConstant(QmlJS::AST::Node *); + bool parseConstant(QmlJS::AST::Node *); + bool tryName(QmlJS::AST::Node *); + bool parseName(QmlJS::AST::Node *, QmlParser::Object ** = 0); + bool tryBinaryExpression(QmlJS::AST::Node *); + bool compileBinaryExpression(QmlJS::AST::Node *); QByteArray data; QList<ScriptInstruction> bytecode; @@ -288,10 +288,10 @@ struct QmlBasicScriptCompiler /*! \internal \class QmlBasicScript - \brief The QmlBasicScript class provides a fast implementation of a limited subset of JavaScript bindings. + \brief The QmlBasicScript class provides a fast implementation of a limited subset of QmlJS bindings. QmlBasicScript instances are used to accelerate binding. Instead of using - the slower, fully fledged JavaScript engine, many simple bindings can be + the slower, fully fledged QmlJS engine, many simple bindings can be evaluated using the QmlBasicScript engine. To see if the QmlBasicScript engine can handle a binding, call compile() @@ -495,12 +495,12 @@ bool QmlBasicScript::compile(const Expression &expression) return d != 0; } -bool QmlBasicScriptCompiler::compile(JavaScript::AST::Node *node) +bool QmlBasicScriptCompiler::compile(QmlJS::AST::Node *node) { return compileExpression(node); } -bool QmlBasicScriptCompiler::tryConstant(JavaScript::AST::Node *node) +bool QmlBasicScriptCompiler::tryConstant(QmlJS::AST::Node *node) { if (node->kind == AST::Node::Kind_TrueLiteral || node->kind == AST::Node::Kind_FalseLiteral) @@ -516,7 +516,7 @@ bool QmlBasicScriptCompiler::tryConstant(JavaScript::AST::Node *node) return false; } -bool QmlBasicScriptCompiler::parseConstant(JavaScript::AST::Node *node) +bool QmlBasicScriptCompiler::parseConstant(QmlJS::AST::Node *node) { ScriptInstruction instr; @@ -534,7 +534,7 @@ bool QmlBasicScriptCompiler::parseConstant(JavaScript::AST::Node *node) return true; } -bool QmlBasicScriptCompiler::tryName(JavaScript::AST::Node *node) +bool QmlBasicScriptCompiler::tryName(QmlJS::AST::Node *node) { return node->kind == AST::Node::Kind_IdentifierExpression || node->kind == AST::Node::Kind_FieldMemberExpression; @@ -629,7 +629,7 @@ bool QmlBasicScriptCompiler::parseName(AST::Node *node, return true; } -bool QmlBasicScriptCompiler::compileExpression(JavaScript::AST::Node *node) +bool QmlBasicScriptCompiler::compileExpression(QmlJS::AST::Node *node) { if (tryBinaryExpression(node)) return compileBinaryExpression(node); @@ -828,7 +828,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c if (instr.type == ScriptInstruction::Load) { - if (n.type == QmlBasicScriptNodeCache::Invalid) { + if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) { context->engine()->d_func()->loadCache(n, QLatin1String(id), static_cast<QmlContextPrivate*>(context->d_ptr)); state = Incremental; } @@ -852,7 +852,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c CacheState dummy; return run(context, voidCache, &dummy); } - } else if (n.type == QmlBasicScriptNodeCache::Invalid) { + } else if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) { context->engine()->d_func()->fetchCache(n, QLatin1String(id), obj); guard(n); state = Incremental; diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index e1b6961..d1835cf 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -134,9 +134,16 @@ void QmlBindableValue::update() } else { QVariant value = this->value(); + if ((uint)d->property.propertyType() >= QVariant::UserType && + value.type() == QVariant::String) { + QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(d->property.propertyType()); + if (con) + value = con(value.toString()); + } + if (d->property.propertyType() == QVariant::Url && value.canConvert(QVariant::String) && !value.isNull()) - value.setValue(context()->resolvedUrl(value.toString())); + value.setValue(context()->resolvedUrl(QUrl(value.toString()))); d->property.write(value); } diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index d29ac1f..8297ac4 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -62,7 +62,7 @@ #include "private/qmlcustomparser_p_p.h" #include <private/qmlcontext_p.h> #include <private/qmlcomponent_p.h> -#include "parser/javascriptast_p.h" +#include "parser/qmljsast_p.h" #include "qmlscriptparser_p.h" @@ -281,7 +281,7 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr, case QVariant::Url: { instr.type = QmlInstruction::StoreUrl; - QUrl u = output->url.resolved(string); + QUrl u = output->url.resolved(QUrl(string)); instr.storeUrl.propertyIndex = prop.propertyIndex(); instr.storeUrl.value = output->indexForString(u.toString()); } @@ -621,13 +621,19 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) output->types.at(obj->type).type->customParser() != 0; QList<QmlCustomParserProperty> customProps; + QStringList deferred = deferredProperties(obj); + QList<Property *> deferredProps; + // Compile all explicit properties specified foreach(Property *prop, obj->properties) { if (isCustomParser) { // Custom parser types don't support signal properties if (testProperty(prop, obj)) { - COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); + if (deferred.contains(prop->name)) + deferredProps << prop; + else + COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); } else { customProps << QmlCustomParserNodePrivate::fromProperty(prop); } @@ -635,7 +641,10 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isSignalPropertyName(prop->name)) { COMPILE_CHECK(compileSignal(prop,obj)); } else { - COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); + if (deferred.contains(prop->name)) + deferredProps << prop; + else + COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); } } @@ -647,12 +656,20 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isCustomParser) { if (testProperty(prop, obj)) { - COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); + QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); + if (deferred.contains(p.name())) + deferredProps << prop; + else + COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); } else { customProps << QmlCustomParserNodePrivate::fromProperty(prop); } } else { - COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); + QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); + if (deferred.contains(p.name())) + deferredProps << prop; + else + COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); } } @@ -670,6 +687,26 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) output->indexForByteArray(customData); } + // Build the deferred block + if (!deferredProps.isEmpty()) { + QmlInstruction defer; + defer.type = QmlInstruction::Defer; + defer.line = 0; + defer.defer.deferCount = 0; + int deferIdx = output->bytecode.count(); + output->bytecode << defer; + + // ### This is lame, we should check if individual properties have + // ids defined within them + int idCount = compileState.ids.count(); + foreach (Property *prop, deferredProps) { + COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); + } + if (idCount == compileState.ids.count()) + output->bytecode[deferIdx].defer.deferCount = + output->bytecode.count() - deferIdx - 1; + } + // If the type support the QmlParserStatusInterface we need to invoke // classComplete() if (parserStatusCast != -1) { @@ -1484,7 +1521,7 @@ bool QmlCompiler::compileBinding(QmlParser::Value *value, //////////////////////////////////////////////////////////////////////////////// // AST Dump //////////////////////////////////////////////////////////////////////////////// -class Dump: protected JavaScript::AST::Visitor +class Dump: protected QmlJS::AST::Visitor { std::ostream &out; int depth; @@ -1494,11 +1531,11 @@ public: : out(out), depth(-1) { } - void operator()(JavaScript::AST::Node *node) - { JavaScript::AST::Node::acceptChild(node, this); } + void operator()(QmlJS::AST::Node *node) + { QmlJS::AST::Node::acceptChild(node, this); } protected: - virtual bool preVisit(JavaScript::AST::Node *node) + virtual bool preVisit(QmlJS::AST::Node *node) { const char *name = typeid(*node).name(); #ifdef Q_CC_GNU @@ -1508,7 +1545,7 @@ protected: return true; } - virtual void postVisit(JavaScript::AST::Node *) + virtual void postVisit(QmlJS::AST::Node *) { --depth; } @@ -1634,6 +1671,19 @@ bool QmlCompiler::canConvert(int convertType, QmlParser::Object *object) return false; } +QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj) +{ + const QMetaObject *mo = obj->metatype; + + int idx = mo->indexOfClassInfo("DeferredPropertyNames"); + if (idx == -1) + return QStringList(); + + QMetaClassInfo classInfo = mo->classInfo(idx); + QStringList rv = QString(QLatin1String(classInfo.value())).split(','); + return rv; +} + QmlCompiledData::QmlCompiledData() { } diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 3b1a496..2559b14 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -180,6 +180,7 @@ private: void finalizeBinding(const BindingReference &); bool canConvert(int, QmlParser::Object *); + QStringList deferredProperties(QmlParser::Object *); struct IdReference { QString id; diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index a5e302c..9950b48 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -109,7 +109,7 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine) status = Error; errors = compiler.errors(); for(int ii = 0; ii < errors.count(); ++ii) - errors[ii].setUrl(url); + errors[ii].setUrl(compiledComponent->url); compiledComponent->release(); compiledComponent = 0; } @@ -336,7 +336,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) unit->status = QmlCompositeTypeData::Error; { QmlError error; - error.setUrl(unit->url); + error.setUrl(QUrl(unit->url)); error.setDescription(tr("Type %1 unavailable").arg(QLatin1String(type))); unit->errors << error; } diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index fb7a015..85a80fa 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -52,20 +52,108 @@ public: QmlSimpleDeclarativeData() : flags(0), context(0) {} virtual void destroyed(QObject *); - enum Flag { Extended = 0x00000001 }; + enum Flag { Instance = 0x00000001, Extended = 0x00000002 }; quint32 flags; QmlContext *context; + + static inline QmlSimpleDeclarativeData *get(QObject *object, + bool create = false); }; -class QmlExtendedDeclarativeData : public QmlSimpleDeclarativeData +class QmlCompiledComponent; +class QmlInstanceDeclarativeData : public QmlSimpleDeclarativeData { public: - QmlExtendedDeclarativeData() { flags = Extended; } + QmlInstanceDeclarativeData() : deferredComponent(0) { flags |= Instance; } virtual void destroyed(QObject *); + + QmlCompiledComponent *deferredComponent; + unsigned int deferredIdx; + + static inline QmlInstanceDeclarativeData *get(QObject *object, + bool create = false); +}; + +class QmlExtendedDeclarativeData : public QmlInstanceDeclarativeData +{ +public: + QmlExtendedDeclarativeData() { flags |= Extended; } + QHash<int, QObject *> attachedProperties; + + static inline QmlExtendedDeclarativeData *get(QObject *object, + bool create = false); }; +QmlSimpleDeclarativeData * +QmlSimpleDeclarativeData::get(QObject *object, bool create) +{ + QObjectPrivate *priv = QObjectPrivate::get(object); + + if (create && !priv->declarativeData) + priv->declarativeData = new QmlInstanceDeclarativeData; + + return static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); +} + +QmlInstanceDeclarativeData * +QmlInstanceDeclarativeData::get(QObject *object, bool create) +{ + QObjectPrivate *priv = QObjectPrivate::get(object); + + QmlSimpleDeclarativeData *simple = + static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); + + if (simple && (simple->flags & Instance)) { + return static_cast<QmlInstanceDeclarativeData *>(simple); + } else if (create && simple) { + QmlInstanceDeclarativeData *rv = new QmlInstanceDeclarativeData; + rv->context = simple->context; + simple->destroyed(object); + priv->declarativeData = rv; + return rv; + } else if (create) { + QmlInstanceDeclarativeData *rv = new QmlInstanceDeclarativeData; + priv->declarativeData = rv; + return rv; + } + return 0; +} + +QmlExtendedDeclarativeData * +QmlExtendedDeclarativeData::get(QObject *object, bool create) +{ + QObjectPrivate *priv = QObjectPrivate::get(object); + + QmlSimpleDeclarativeData *simple = + static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); + + if (simple && (simple->flags & Extended)) { + return static_cast<QmlExtendedDeclarativeData *>(simple); + } else if (create && simple) { + QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData; + rv->context = simple->context; + + if (simple->flags & Instance) { + QmlInstanceDeclarativeData *instance = + static_cast<QmlInstanceDeclarativeData *>(priv->declarativeData); + rv->deferredComponent = instance->deferredComponent; + rv->deferredIdx = instance->deferredIdx; + delete simple; + } else { + simple->destroyed(object); + } + priv->declarativeData = rv; + return rv; + } else if (create) { + QmlExtendedDeclarativeData *rv = new QmlExtendedDeclarativeData; + priv->declarativeData = rv; + return rv; + } + return 0; +} + QT_END_NAMESPACE #endif // QMLDECLARATIVEDATA_P_H diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 66781ce..36b6424 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -71,7 +71,7 @@ #include <qmlcomponent.h> #include "private/qmlmetaproperty_p.h" #include <private/qmlbindablevalue_p.h> - +#include <private/qmlvme_p.h> QT_BEGIN_NAMESPACE @@ -706,6 +706,19 @@ void QmlEngine::setContextForObject(QObject *object, QmlContext *context) context->d_func()->contextObjects.append(object); } +void qmlExecuteDeferred(QObject *object) +{ + QmlInstanceDeclarativeData *data = QmlInstanceDeclarativeData::get(object); + + if (data && data->deferredComponent) { + QmlVME vme; + vme.runDeferred(object); + + data->deferredComponent->release(); + data->deferredComponent = 0; + } +} + QmlContext *qmlContext(const QObject *obj) { return QmlEngine::contextForObject(obj); @@ -719,36 +732,21 @@ QmlEngine *qmlEngine(const QObject *obj) QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object) { - QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object)); - - - QmlSimpleDeclarativeData *data = static_cast<QmlSimpleDeclarativeData *>(priv->declarativeData); + QmlExtendedDeclarativeData *edata = + QmlExtendedDeclarativeData::get(const_cast<QObject *>(object), true); - QmlExtendedDeclarativeData *edata = (data && data->flags & QmlSimpleDeclarativeData::Extended)?static_cast<QmlExtendedDeclarativeData *>(data):0; - - if (edata) { - QObject *rv = edata->attachedProperties.value(id); - if (rv) - return rv; - } + QObject *rv = edata->attachedProperties.value(id); + if (rv) + return rv; QmlAttachedPropertiesFunc pf = QmlMetaType::attachedPropertiesFuncById(id); if (!pf) return 0; - QObject *rv = pf(const_cast<QObject *>(object)); - - if (rv) { - if (!edata) { - - edata = new QmlExtendedDeclarativeData; - if (data) edata->context = data->context; - priv->declarativeData = edata; - - } + rv = pf(const_cast<QObject *>(object)); + if (rv) edata->attachedProperties.insert(id, rv); - } return rv; } @@ -759,9 +757,11 @@ void QmlSimpleDeclarativeData::destroyed(QObject *object) context->d_func()->contextObjects.removeAll(object); } -void QmlExtendedDeclarativeData::destroyed(QObject *object) +void QmlInstanceDeclarativeData::destroyed(QObject *object) { QmlSimpleDeclarativeData::destroyed(object); + if (deferredComponent) + deferredComponent->release(); delete this; } @@ -808,7 +808,7 @@ QmlEngine *QmlEngine::activeEngine() dynamically creates and returns objects when called from QtScript, and these objects are visual items in the QML tree. - \sa QmlEngine::newQObject() + \sa QScriptEngine::newQObject() */ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) { @@ -823,7 +823,7 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) This function takes the URL of a QML file as its only argument. It returns a component object which can be used to create and load that QML file. - Example JavaScript is below, remember that QML files that might be loaded + Example QmlJS is below, remember that QML files that might be loaded over the network cannot be expected to be ready immediately. \code var component; @@ -865,6 +865,7 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) } \endcode + \sa QmlComponent::createObject() */ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine) { @@ -1128,7 +1129,7 @@ QVariant QmlExpression::value() for (int i = context()->d_func()->scopeChain.size() - 1; i > -1; --i) { scriptEngine->currentContext()->pushScope(context()->d_func()->scopeChain.at(i)); } - QScriptValue svalue = scriptEngine->evaluate(expression(), d->fileName, d->line); + QScriptValue svalue = scriptEngine->evaluate(expression(), d->fileName.toString(), d->line); if (scriptEngine->hasUncaughtException()) { if (scriptEngine->uncaughtException().isError()){ QScriptValue exception = scriptEngine->uncaughtException(); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index 0f1f697..e3b0dfe 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -139,6 +139,11 @@ public: PopFetchedObject, PopQList, + // + // Deferred creation + // + Defer, /* defer */ + // // Expression optimizations // @@ -270,6 +275,9 @@ public: int property; int object; } assignStackObject; + struct { + int deferCount; + } defer; }; void dump(QmlCompiledComponent *); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index a152807..52036c2 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -814,6 +814,16 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value) default: + { + if ((uint)t >= QVariant::UserType && vt == QVariant::String) { + QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(t); + if (con) { + QVariant v = con(value.toString()); + prop.write(object, v); + return; + } + } + } break; } prop.write(object, value); diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 3e25ae0..8ce8571 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -214,9 +214,12 @@ void QmlTypePrivate::init() const mo = mo->d.superdata; } - for (int ii = 0; ii < m_metaObjects.count(); ++ii) + for (int ii = 0; ii < m_metaObjects.count(); ++ii) { m_metaObjects[ii].propertyOffset = m_metaObjects.at(ii).metaObject->propertyOffset(); + m_metaObjects[ii].methodOffset = + m_metaObjects.at(ii).metaObject->methodOffset(); + } // Calculate hash QByteArray hashData; diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index fadfbb1..5ad4a6e 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -290,7 +290,7 @@ QmlParser::Variant::Variant(const QString &v) { } -QmlParser::Variant::Variant(const QString &v, JavaScript::AST::Node *n) +QmlParser::Variant::Variant(const QString &v, QmlJS::AST::Node *n) : t(Script), n(n), s(v) { } @@ -342,7 +342,7 @@ QString QmlParser::Variant::asScript() const } } -JavaScript::AST::Node *QmlParser::Variant::asAST() const +QmlJS::AST::Node *QmlParser::Variant::asAST() const { if (type() == Script) return n; diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 1481391..a38ce69 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -namespace JavaScript { namespace AST { class Node; } } +namespace QmlJS { namespace AST { class Node; } } /* XXX @@ -178,7 +178,7 @@ namespace QmlParser Variant(bool); Variant(double, const QString &asWritten=QString()); Variant(const QString &); - Variant(const QString &, JavaScript::AST::Node *); + Variant(const QString &, QmlJS::AST::Node *); Variant &operator=(const Variant &); Type type() const; @@ -192,14 +192,14 @@ namespace QmlParser QString asString() const; double asNumber() const; QString asScript() const; - JavaScript::AST::Node *asAST() const; + QmlJS::AST::Node *asAST() const; private: Type t; union { bool b; double d; - JavaScript::AST::Node *n; + QmlJS::AST::Node *n; }; QString s; }; diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 25e60e0..ed1304a 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -123,13 +123,57 @@ namespace QmlPrivate } }; - template<typename T, typename Sign = T *(*)(QObject *)> - struct has_qmlAttachedProperties +#if defined(Q_CC_MSVC) + template <typename T> + class has_attachedPropertiesMember { - template <typename U, U> struct type_check; - template <typename _1> static char check(type_check<Sign, &_1::qmlAttachedProperties> *); - template <typename > static int check(...); - static bool const value = sizeof(check<T>(0)) == sizeof(char); + public: + __if_exists(T::qmlAttachedProperties) { + static bool const value = true; + } + __if_not_exists(T::qmlAttachedProperties) { + static bool const value = false; + } + }; +#else + template <typename T> + class has_attachedPropertiesMember + { + typedef int yes_type; + typedef char no_type; + template <int> + struct Selector {}; + + template <typename S> + static yes_type test(Selector<sizeof(&S::qmlAttachedProperties)>*); + + template <typename S> + static no_type test(...); + + public: + static bool const value = sizeof(test<T>(0)) == sizeof(yes_type); + }; +#endif + + template <typename T, bool hasMember> + class has_attachedPropertiesMethod + { + typedef int yes_type; + typedef char no_type; + + template<typename ReturnType> + static yes_type check(ReturnType *(*)(QObject *)); + static no_type check(...); + + public: + static bool const value = sizeof(check(&T::qmlAttachedProperties)) == sizeof(yes_type); + }; + + template <typename T> + class has_attachedPropertiesMethod<T, false> + { + public: + static bool const value = false; }; template<typename T, int N> @@ -161,13 +205,13 @@ namespace QmlPrivate template<typename T> inline QmlAttachedPropertiesFunc attachedPropertiesFunc() { - return AttachedPropertySelector<T, has_qmlAttachedProperties<T>::value >::func(); + return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::func(); } template<typename T> inline const QMetaObject *attachedPropertiesMetaObject() { - return AttachedPropertySelector<T, has_qmlAttachedProperties<T>::value >::metaObject(); + return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject(); } struct MetaTypeIds { diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp index 686c6d7..06d8a50 100644 --- a/src/declarative/qml/qmlproxymetaobject.cpp +++ b/src/declarative/qml/qmlproxymetaobject.cpp @@ -78,6 +78,7 @@ QmlProxyMetaObject::~QmlProxyMetaObject() proxies = 0; } +#include <QDebug> int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) { if ((c == QMetaObject::ReadProperty || @@ -93,8 +94,24 @@ int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) sizeof(QObject *) * metaObjects->count()); } - if (!proxies[ii]) - proxies[ii] = data.createFunc(object); + if (!proxies[ii]) { + QObject *proxy = data.createFunc(object); + const QMetaObject *metaObject = proxy->metaObject(); + proxies[ii] = proxy; + + int localOffset = data.metaObject->methodOffset(); + int methodOffset = metaObject->methodOffset(); + int methods = metaObject->methodCount() - methodOffset; + + // ### - Can this be done more optimally? + for (int jj = 0; jj < methods; ++jj) { + QMetaMethod method = + metaObject->method(jj + methodOffset); + if (method.methodType() == QMetaMethod::Signal) + QMetaObject::connect(proxy, methodOffset + jj, + object, localOffset + jj); + } + } int proxyOffset = proxies[ii]->metaObject()->propertyOffset(); int proxyId = id - data.propertyOffset + proxyOffset; @@ -102,6 +119,13 @@ int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) return proxies[ii]->qt_metacall(c, proxyId, a); } } + } else if (c == QMetaObject::InvokeMetaMethod && + id >= metaObjects->last().methodOffset) { + QMetaMethod m = object->metaObject()->method(id); + if (m.methodType() == QMetaMethod::Signal) { + QMetaObject::activate(object, id, a); + return -1; + } } if (parent) diff --git a/src/declarative/qml/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h index 0ffa365..c0ce36e 100644 --- a/src/declarative/qml/qmlproxymetaobject_p.h +++ b/src/declarative/qml/qmlproxymetaobject_p.h @@ -61,6 +61,7 @@ public: QMetaObject *metaObject; CreateFunc createFunc; int propertyOffset; + int methodOffset; }; QmlProxyMetaObject(QObject *, QList<ProxyData> *); diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index ee2981e..fb7492d 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -42,12 +42,12 @@ #include "qmlscriptparser_p.h" #include "qmlparser_p.h" -#include "parser/javascriptengine_p.h" -#include "parser/javascriptparser_p.h" -#include "parser/javascriptlexer_p.h" -#include "parser/javascriptnodepool_p.h" -#include "parser/javascriptastvisitor_p.h" -#include "parser/javascriptast_p.h" +#include "parser/qmljsengine_p.h" +#include "parser/qmljsparser_p.h" +#include "parser/qmljslexer_p.h" +#include "parser/qmljsnodepool_p.h" +#include "parser/qmljsastvisitor_p.h" +#include "parser/qmljsast_p.h" #include "rewriter/textwriter_p.h" @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -using namespace JavaScript; +using namespace QmlJS; using namespace QmlParser; namespace { @@ -628,6 +628,8 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) node->statement); } + prop->location.range.length = prop->location.range.offset + prop->location.range.length - node->qualifiedId->identifierToken.offset; + prop->location.range.offset = node->qualifiedId->identifierToken.offset; Value *v = new Value; v->value = primitive; v->location = location(node->statement->firstSourceLocation(), @@ -715,7 +717,7 @@ bool ProcessAST::visit(AST::UiSourceElement *node) obj->dynamicSlots << slot; } else { QmlError error; - error.setDescription(QCoreApplication::translate("QmlParser","JavaScript declaration outside Script element")); + error.setDescription(QCoreApplication::translate("QmlParser","QmlJS declaration outside Script element")); error.setLine(node->firstSourceLocation().startLine); error.setColumn(node->firstSourceLocation().startColumn); _parser->_errors << error; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 3a66c69..a3ee4e5 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -44,6 +44,7 @@ #include <private/qmlboundsignal_p.h> #include <private/qmlstringconverters_p.h> #include "private/qmetaobjectbuilder_p.h" +#include "private/qmldeclarativedata_p.h" #include <qml.h> #include <private/qmlcustomparser_p.h> #include <qperformancelog.h> @@ -88,16 +89,11 @@ QmlVME::QmlVME() struct ListInstance { ListInstance() {} - /* - ListInstance(const QVariant &l, int t) - : list(l), type(t), qmlListInterface(0) {} - */ ListInstance(QList<void *> *q, int t) - : type(t), qListInterface(q) {} + : type(t), qListInterface(q), qmlListInterface(0) {} ListInstance(QmlPrivate::ListInterface *q, int t) - : type(t), qmlListInterface(q) {} + : type(t), qListInterface(0), qmlListInterface(q) {} - //QVariant list; int type; QList<void *> *qListInterface; QmlPrivate::ListInterface *qmlListInterface; @@ -105,6 +101,35 @@ struct ListInstance QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count) { + QStack<QObject *> stack; + + if (start == -1) start = 0; + if (count == -1) count = comp->bytecode.count(); + + return run(stack, ctxt, comp, start, count); +} + +void QmlVME::runDeferred(QObject *object) +{ + QmlInstanceDeclarativeData *data = QmlInstanceDeclarativeData::get(object); + + if (!data || !data->context || !data->deferredComponent) + return; + + QmlContext *ctxt = data->context; + ctxt->activate(); + QmlCompiledComponent *comp = data->deferredComponent; + int start = data->deferredIdx + 1; + int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount; + QStack<QObject *> stack; + stack.push(object); + + run(stack, ctxt, comp, start, count); + ctxt->deactivate(); +} + +QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count) +{ // XXX - All instances of QmlContext::activeContext() here should be // replaced with the use of ctxt. However, this cannot be done until // behaviours stop modifying the active context and expecting the @@ -125,7 +150,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in QmlEnginePrivate::SimpleList<QmlBindableValue> bindValues; QmlEnginePrivate::SimpleList<QmlParserStatus> parserStatus; - QStack<QObject *> stack; QStack<ListInstance> qliststack; QStack<QmlMetaProperty> pushedProperties; @@ -133,9 +157,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in vmeErrors.clear(); - if (start == -1) start = 0; - if (count == -1) count = comp->bytecode.count(); - for (int ii = start; !isError() && ii < (start + count); ++ii) { QmlInstruction &instr = comp->bytecode[ii]; @@ -172,7 +193,17 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } if (!stack.isEmpty()) { QObject *parent = stack.top(); - o->setParent(parent); + if (o->isWidgetType()) { + QWidget *widget = static_cast<QWidget*>(o); + if (parent->isWidgetType()) { + QWidget *parentWidget = static_cast<QWidget*>(parent); + widget->setParent(parentWidget); + } else { + // TODO: parent might be a layout + } + } else { + o->setParent(parent); + } } stack.push(o); } @@ -745,6 +776,20 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; + case QmlInstruction::Defer: + { + if (instr.defer.deferCount) { + QObject *target = stack.top(); + QmlInstanceDeclarativeData *data = + QmlInstanceDeclarativeData::get(target, true); + comp->addref(); + data->deferredComponent = comp; + data->deferredIdx = ii; + ii += instr.defer.deferCount; + } + } + break; + case QmlInstruction::PopFetchedObject: { stack.pop(); diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index f2ed576..149c82c 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -58,12 +58,14 @@ class QmlVME public: QmlVME(); - QObject *run(QmlContext *, QmlCompiledComponent *, int start = -1, int end = -1); + QObject *run(QmlContext *, QmlCompiledComponent *, int start = -1, int count = -1); + void runDeferred(QObject *); bool isError() const; QList<QmlError> errors() const; private: + QObject *run(QStack<QObject *> &, QmlContext *, QmlCompiledComponent *, int start, int count); QList<QmlError> vmeErrors; }; diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 0117448..4b2c64c 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -55,14 +55,18 @@ QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj, QList<QString> *strData, int slotData, QmlRefCount *rc) -: object(obj), ref(rc), slotData(strData), slotDataIdx(slotData) +: object(obj), ref(rc), slotData(strData), slotDataIdx(slotData), parent(0) { if (ref) ref->addref(); *static_cast<QMetaObject *>(this) = *other; this->d.superdata = obj->metaObject(); - QObjectPrivate::get(obj)->metaObject = this; + + QObjectPrivate *op = QObjectPrivate::get(obj); + if (op->metaObject) + parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject); + op->metaObject = this; baseProp = propertyOffset(); baseSig = methodOffset(); @@ -101,6 +105,8 @@ QmlVMEMetaObject::~QmlVMEMetaObject() { if (ref) ref->release(); + if (parent) + delete parent; delete [] data; } @@ -172,6 +178,10 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int id, void **a) } } - return object->qt_metacall(c, id, a); + if (parent) + return parent->metaCall(c, id, a); + else + return object->qt_metacall(c, id, a); } + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h index 6f1e31b..17140ef 100644 --- a/src/declarative/qml/qmlvmemetaobject_p.h +++ b/src/declarative/qml/qmlvmemetaobject_p.h @@ -69,6 +69,7 @@ private: QBitArray vTypes; QList<QString> *slotData; int slotDataIdx; + QAbstractDynamicMetaObject *parent; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp index fce4fdf..2ce927c 100644 --- a/src/declarative/qml/rewriter/rewriter.cpp +++ b/src/declarative/qml/rewriter/rewriter.cpp @@ -40,11 +40,11 @@ ****************************************************************************/ #include "rewriter_p.h" -#include "javascriptast_p.h" +#include "qmljsast_p.h" QT_BEGIN_NAMESPACE -using namespace JavaScript; +using namespace QmlJS; void Rewriter::replace(const AST::SourceLocation &loc, const QString &text) { replace(loc.offset, loc.length, text); } @@ -76,8 +76,8 @@ QString Rewriter::textAt(const AST::SourceLocation &loc) const QString Rewriter::textAt(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc) const { return _code.mid(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset); } -void Rewriter::accept(JavaScript::AST::Node *node) -{ JavaScript::AST::Node::acceptChild(node, this); } +void Rewriter::accept(QmlJS::AST::Node *node) +{ QmlJS::AST::Node::acceptChild(node, this); } void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc, diff --git a/src/declarative/qml/rewriter/rewriter_p.h b/src/declarative/qml/rewriter/rewriter_p.h index 02b4ee4..fcb9ca5 100644 --- a/src/declarative/qml/rewriter/rewriter_p.h +++ b/src/declarative/qml/rewriter/rewriter_p.h @@ -46,12 +46,12 @@ #include <QtCore/QString> #include "textwriter_p.h" -#include "javascriptastvisitor_p.h" +#include "qmljsastvisitor_p.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { //////////////////////////////////////////////////////////////////////////////// // Replacement @@ -143,7 +143,7 @@ private: QList<Replacement> _replacementList; }; -} // end of namespace JavaScript +} // end of namespace QmlJS QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/rewriter/textwriter.cpp b/src/declarative/qml/rewriter/textwriter.cpp index 21122ff..fbbdb2bbab 100644 --- a/src/declarative/qml/rewriter/textwriter.cpp +++ b/src/declarative/qml/rewriter/textwriter.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -using namespace JavaScript; +using namespace QmlJS; TextWriter::TextWriter() :string(0), cursor(0) diff --git a/src/declarative/qml/rewriter/textwriter_p.h b/src/declarative/qml/rewriter/textwriter_p.h index 57800bf..3041e04 100644 --- a/src/declarative/qml/rewriter/textwriter_p.h +++ b/src/declarative/qml/rewriter/textwriter_p.h @@ -49,7 +49,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -namespace JavaScript { +namespace QmlJS { class TextWriter { @@ -91,7 +91,7 @@ public: }; -} // end of namespace JavaScript +} // end of namespace QmlJS QT_END_NAMESPACE QT_END_HEADER |