summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlobjectscriptclass.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-02 07:09:09 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-05 02:40:47 (GMT)
commit3490b478ed02859f0355438efba900cd853e9c13 (patch)
treef554feca685671aef6775da255150a122597c258 /src/declarative/qml/qmlobjectscriptclass.cpp
parentb3605d7f45c1cdb61bbd2a572e58bd29aaea6956 (diff)
downloadQt-3490b478ed02859f0355438efba900cd853e9c13.zip
Qt-3490b478ed02859f0355438efba900cd853e9c13.tar.gz
Qt-3490b478ed02859f0355438efba900cd853e9c13.tar.bz2
Reenable types/enums and move scripts into an isolated scope
Diffstat (limited to 'src/declarative/qml/qmlobjectscriptclass.cpp')
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index bb5f191..6a34a2f 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -64,14 +64,13 @@ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine)
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(bindEngine);
m_destroy = scriptEngine->newFunction(destroy);
- m_destroyId = createPersistentIdentifier<Dummy>(QLatin1String("destroy"));
+ m_destroyId = createPersistentIdentifier(QLatin1String("destroy"));
m_toString = scriptEngine->newFunction(tostring);
- m_toStringId = createPersistentIdentifier<Dummy>(QLatin1String("toString"));
+ m_toStringId = createPersistentIdentifier(QLatin1String("toString"));
}
QmlObjectScriptClass::~QmlObjectScriptClass()
{
- delete m_destroyId;
}
QScriptValue QmlObjectScriptClass::newQObject(QObject *object)
@@ -100,8 +99,8 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
Q_UNUSED(flags);
lastData = 0;
- if (name == m_destroyId->identifier ||
- name == m_toStringId->identifier)
+ if (name == m_destroyId.identifier ||
+ name == m_toStringId.identifier)
return QScriptClass::HandlesReadAccess;
if (!obj)
@@ -140,9 +139,9 @@ QScriptValue QmlObjectScriptClass::property(const Object &object, const Identifi
QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name)
{
- if (name == m_destroyId->identifier)
+ if (name == m_destroyId.identifier)
return m_destroy;
- else if (name == m_toStringId->identifier)
+ else if (name == m_toStringId.identifier)
return m_toString;
Q_ASSERT(lastData);
@@ -156,6 +155,11 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name
QScriptValue sobj = scriptEngine->newQObject(obj);
return sobj.property(toString(name));
} else {
+ if (lastData->propType < QVariant::UserType) {
+ QmlValueType *valueType = enginePriv->valueTypes[lastData->propType];
+ if (valueType)
+ return enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType);
+ }
QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj);
if (!(lastData->flags & QmlPropertyCache::Data::IsConstant)) {
@@ -167,7 +171,7 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name
QObject *rv = *(QObject **)var.constData();
return newQObject(rv);
} else {
- return qScriptValueFromValue(scriptEngine, var);
+ return enginePriv->scriptValueFromVariant(var);
}
}
@@ -250,5 +254,5 @@ QScriptValue QmlObjectScriptClass::destroy(QScriptContext *context, QScriptEngin
return engine->nullValue();
}
-
QT_END_NAMESPACE
+