diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-26 11:04:10 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-26 11:04:10 (GMT) |
commit | 0f71f6dd993194dafd0385d4697ced38839e2b37 (patch) | |
tree | 50a869e48dc9e46713db2d1918955df13311acca /src/script/api/qscriptengine.cpp | |
parent | 811c1d7e6de03ec16c9bdaec20ab66332b92cd7c (diff) | |
download | Qt-0f71f6dd993194dafd0385d4697ced38839e2b37.zip Qt-0f71f6dd993194dafd0385d4697ced38839e2b37.tar.gz Qt-0f71f6dd993194dafd0385d4697ced38839e2b37.tar.bz2 |
implement QMetaObject bindings
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 0831e48..ec5c3ca 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -532,6 +532,8 @@ void GlobalObject::mark() if (engine->qobjectPrototype) engine->qobjectPrototype->mark(); + if (engine->qmetaobjectPrototype) + engine->qmetaobjectPrototype->mark(); if (engine->variantPrototype) engine->variantPrototype->mark(); @@ -571,6 +573,8 @@ QScriptEnginePrivate::QScriptEnginePrivate() qobjectPrototype = new (exec) QScript::QObjectPrototype(exec, QScript::QObjectPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure()); qobjectWrapperObjectStructure = QScript::QObjectWrapperObject::createStructure(qobjectPrototype); + qmetaobjectPrototype = new (exec) QScript::QMetaObjectPrototype(exec, QScript::QMetaObjectPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure()); + qmetaobjectWrapperObjectStructure = QScript::QMetaObjectWrapperObject::createStructure(qmetaobjectPrototype); variantPrototype = new (exec) QScript::QVariantPrototype(exec, QScript::QVariantPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure()); variantWrapperObjectStructure = QScript::QVariantWrapperObject::createStructure(variantPrototype); @@ -759,6 +763,16 @@ JSC::JSValue QScriptEnginePrivate::newQObject( return result; } +JSC::JSValue QScriptEnginePrivate::newQMetaObject( + const QMetaObject *metaObject, JSC::JSValue ctor) +{ + if (!metaObject) + return JSC::jsNull(); + JSC::ExecState* exec = globalObject->globalExec(); + QScript::QMetaObjectWrapperObject *result = new (exec) QScript::QMetaObjectWrapperObject(metaObject, ctor, qmetaobjectWrapperObjectStructure); + return result; +} + bool QScriptEnginePrivate::convertToNativeQObject(const QScriptValue &value, const QByteArray &targetType, void **result) @@ -1411,8 +1425,10 @@ QScriptValue QScriptEngine::newDate(const QDateTime &value) QScriptValue QScriptEngine::newQMetaObject( const QMetaObject *metaObject, const QScriptValue &ctor) { - qWarning("QScriptEngine::newQMetaObject() not implemented"); - return QScriptValue(); + Q_D(QScriptEngine); + JSC::JSValue jscCtor = d->scriptValueToJSCValue(ctor); + JSC::JSValue jscQMetaObject = d->newQMetaObject(metaObject, jscCtor); + return d->scriptValueFromJSCValue(jscQMetaObject); } /*! |