diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/parser/javascriptengine_p.cpp | 35 | ||||
-rw-r--r-- | src/declarative/qml/parser/javascriptengine_p.h | 82 |
2 files changed, 71 insertions, 46 deletions
diff --git a/src/declarative/qml/parser/javascriptengine_p.cpp b/src/declarative/qml/parser/javascriptengine_p.cpp index 5debfd3..d893a90 100644 --- a/src/declarative/qml/parser/javascriptengine_p.cpp +++ b/src/declarative/qml/parser/javascriptengine_p.cpp @@ -34,11 +34,11 @@ QT_BEGIN_NAMESPACE +namespace JavaScript { + uint qHash(const JavaScript::NameId &id) { return qHash(id.asString()); } -namespace JavaScript { - QString numberToString(double value) { return QString::number(value); } @@ -155,6 +155,37 @@ double integerFromString(const QString &str, int radix) return integerFromString(ba.constData(), ba.size(), radix); } + +Engine::Engine() + : _lexer(0), _nodePool(0) +{ } + +Engine::~Engine() +{ } + +QSet<NameId> Engine::literals() const +{ return _literals; } + +NameId *Engine::intern(const QChar *u, int s) +{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); } + +QString Engine::toString(NameId *id) +{ return id->asString(); } + +Lexer *Engine::lexer() const +{ return _lexer; } + +void Engine::setLexer(Lexer *lexer) +{ _lexer = lexer; } + +NodePool *Engine::nodePool() const +{ return _nodePool; } + +void Engine::setNodePool(NodePool *nodePool) +{ _nodePool = nodePool; } + + + } // end of namespace JavaScript QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/javascriptengine_p.h b/src/declarative/qml/parser/javascriptengine_p.h index 933487f..3bd924a 100644 --- a/src/declarative/qml/parser/javascriptengine_p.h +++ b/src/declarative/qml/parser/javascriptengine_p.h @@ -38,11 +38,38 @@ QT_BEGIN_NAMESPACE namespace JavaScript { -class NameId; -} +class NameId +{ + QString _text; + +public: + NameId(const QChar *u, int s) + : _text(u, s) + { } + + const QString asString() const + { return _text; } + + bool operator == (const NameId &other) const + { return _text == other._text; } + + bool operator != (const NameId &other) const + { return _text != other._text; } + + bool operator < (const NameId &other) const + { return _text < other._text; } +}; uint qHash(const JavaScript::NameId &id); +} // end of namespace JavaScript + +#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 +//this ensures that code outside JavaScript can use the hash function +//it also a workaround for some compilers +inline uint qHash(const JavaScript::NameId &nameId) { return JavaScript::qHash(nameId); } +#endif + namespace JavaScript { class Lexer; @@ -66,29 +93,6 @@ public: } // end of namespace Ecma - -class NameId -{ - QString _text; - -public: - NameId(const QChar *u, int s) - : _text(u, s) - { } - - const QString asString() const - { return _text; } - - bool operator == (const NameId &other) const - { return _text == other._text; } - - bool operator != (const NameId &other) const - { return _text != other._text; } - - bool operator < (const NameId &other) const - { return _text < other._text; } -}; - class DiagnosticMessage { public: @@ -118,30 +122,20 @@ class Engine QSet<NameId> _literals; public: - Engine() - : _lexer(0), _nodePool(0) - { } - - QSet<NameId> literals() const - { return _literals; } - - NameId *intern(const QChar *u, int s) - { return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); } + Engine(); + ~Engine(); - static QString toString(NameId *id) - { return id->asString(); } + QSet<NameId> literals() const; - Lexer *lexer() const - { return _lexer; } + NameId *intern(const QChar *u, int s); - void setLexer(Lexer *lexer) - { _lexer = lexer; } + static QString toString(NameId *id); - NodePool *nodePool() const - { return _nodePool; } + Lexer *lexer() const; + void setLexer(Lexer *lexer); - void setNodePool(NodePool *nodePool) - { _nodePool = nodePool; } + NodePool *nodePool() const; + void setNodePool(NodePool *nodePool); }; } // end of namespace JavaScript |