diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-02 14:38:52 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-02 14:38:52 (GMT) |
commit | 2b54a6831ebf8af0540c72519173a9c5e2d94aef (patch) | |
tree | 7b019f9d143e4c52f6df3fc220b06671b65ad2c1 /src/script/api/qscriptvalue.cpp | |
parent | 0357533025a7e4066def7665f3c77337f1ab21db (diff) | |
download | Qt-2b54a6831ebf8af0540c72519173a9c5e2d94aef.zip Qt-2b54a6831ebf8af0540c72519173a9c5e2d94aef.tar.gz Qt-2b54a6831ebf8af0540c72519173a9c5e2d94aef.tar.bz2 |
implement a fair amount of the QScriptClass functionality
Enumeration is missing, as is the ability to change the class
of an object after it has been created.
Diffstat (limited to 'src/script/api/qscriptvalue.cpp')
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 4d8f18a..09f0d0c 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2323,11 +2323,13 @@ void QScriptValue::setData(const QScriptValue &data) */ QScriptClass *QScriptValue::scriptClass() const { - if (isObject()) + Q_D(const QScriptValue); + if (!d || !d->isJSC() || !d->jscValue.isObject()) return 0; - // ### implement me - Q_ASSERT_X(false, Q_FUNC_INFO, "not implemented"); - return 0; + if (!d->jscValue.isObject(&QScript::ClassObject::info)) + return 0; + QScript::ClassObject *instance = static_cast<QScript::ClassObject*>(JSC::asObject(d->jscValue)); + return instance->scriptClass(); } /*! @@ -2345,9 +2347,15 @@ QScriptClass *QScriptValue::scriptClass() const */ void QScriptValue::setScriptClass(QScriptClass *scriptClass) { - Q_ASSERT_X(false, Q_FUNC_INFO, "not implemented"); - // no idea... use a "hidden" property? - Q_UNUSED(scriptClass); + Q_D(QScriptValue); + if (!d || !d->isJSC() || !d->jscValue.isObject()) + return; + if (!d->jscValue.isObject(&QScript::ClassObject::info)) { + qWarning("QScriptValue::setScriptClass() not implemented"); + return; + } + QScript::ClassObject *instance = static_cast<QScript::ClassObject*>(JSC::asObject(d->jscValue)); + instance->setScriptClass(scriptClass); } /*! |