diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-03 00:14:54 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-03 00:14:54 (GMT) |
commit | b9c834048d6dc6e04567c1c73212ecb1b9c96664 (patch) | |
tree | 223b1d3d101883dabadadbf68b020808de56399e /src/declarative/qml/qmlengine_p.h | |
parent | dc26066be54bed3d508b460db1cc8d8b4b68cc1f (diff) | |
download | Qt-b9c834048d6dc6e04567c1c73212ecb1b9c96664.zip Qt-b9c834048d6dc6e04567c1c73212ecb1b9c96664.tar.gz Qt-b9c834048d6dc6e04567c1c73212ecb1b9c96664.tar.bz2 |
Add QML enum support
Enums are accessed as <Type Name>.<Enum value name>
Currently this is highly unoptimal - enum assignments are not detected
in the compiler, nor are they cached in the script engine.
Diffstat (limited to 'src/declarative/qml/qmlengine_p.h')
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 451276d..f492ccb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -82,6 +82,7 @@ class QmlExpression; class QmlBasicScriptNodeCache; class QmlContextScriptClass; class QmlObjectScriptClass; +class QmlTypeNameScriptClass; class QmlValueTypeScriptClass; class QScriptEngineDebugger; class QNetworkReply; @@ -127,16 +128,22 @@ public: QScriptEngineDebugger *debugger; #endif + struct ImportedNamespace; struct ResolveData { ResolveData() : safetyCheckId(0) {} int safetyCheckId; void clear() { - object = 0; context = 0; contextIndex = -1; isFunction = false; + object = 0; context = 0; + type = 0; ns = 0; + contextIndex = -1; isFunction = false; } QObject *object; QmlContext *context; + QmlType *type; + QmlEnginePrivate::ImportedNamespace *ns; + int contextIndex; bool isFunction; QmlMetaProperty property; @@ -144,6 +151,7 @@ public: QmlContextScriptClass *contextClass; QmlObjectScriptClass *objectClass; QmlValueTypeScriptClass *valueTypeClass; + QmlTypeNameScriptClass *typeNameClass; // Used by DOM Core 3 API QScriptClass *nodeListClass; QScriptClass *namedNodeMapClass; @@ -199,6 +207,9 @@ public: } QmlValueTypeFactory valueTypes; + // ### Fixme + typedef QHash<QPair<const QMetaObject *, QString>, bool> FunctionCache; + FunctionCache functionCache; QHash<const QMetaObject *, QmlMetaObjectCache> propertyCache; static QmlMetaObjectCache *cache(QmlEnginePrivate *priv, QObject *obj) { if (!priv || !obj || QObjectPrivate::get(obj)->metaObject) return 0; @@ -219,7 +230,6 @@ public: QmlImportsPrivate *d; }; - struct ImportedNamespace; bool addToImport(Imports*, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const; bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, @@ -313,6 +323,25 @@ public: const QScriptValue &value); }; +class QmlTypeNameScriptClass : public QmlScriptClass +{ +public: + QmlTypeNameScriptClass(QmlEngine *); + ~QmlTypeNameScriptClass(); + + virtual QueryFlags queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id); + virtual QScriptValue property(const QScriptValue &object, + const QScriptString &name, + uint id); + +private: + QObject *object; + QmlType *type; + quint32 enumValue; +}; + class QmlValueTypeScriptClass : public QmlScriptClass { public: |