if (d && d->type) {
return v8engine->typeWrapper()->newObject(object, d->type, resource->mode);
} else if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = typeNamespace->moduleApi()) {
- // XXX TODO: Currently module APIs are implemented against QScriptValues. Consequently we
- // can't do anything here until the QtScript/V8 binding is complete.
- return v8::Undefined();
+ // XXX TODO: Currently module APIs are implemented against QScriptValues. Consequently we
+ // can't do anything for script module apis here until the QtScript/V8 binding is complete.
+ if (moduleApi->qobjectCallback) {
+ moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), 0);
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ }
+
+ if (moduleApi->qobjectApi) {
+ v8::Handle<v8::Value> rv = v8engine->qobjectWrapper()->getProperty(moduleApi->qobjectApi, propertystring, QV8QObjectWrapper::IgnoreRevision);
+ if (rv.IsEmpty())
+ return v8::Undefined();
+ else
+ return rv;
+ } else {
+ return v8::Undefined();
+ }
}
// Fall through to undefined
if (ao)
v8engine->qobjectWrapper()->setProperty(ao, propertystring, value,
QV8QObjectWrapper::IgnoreRevision);
+ } else if (resource->typeNamespace) {
+ if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi()) {
+ // XXX TODO: Currently module APIs are implemented against QScriptValues. Consequently we
+ // can't do anything for script module apis here until the QtScript/V8 binding is complete.
+ if (moduleApi->qobjectCallback) {
+ moduleApi->qobjectApi = moduleApi->qobjectCallback(v8engine->engine(), 0);
+ moduleApi->scriptCallback = 0;
+ moduleApi->qobjectCallback = 0;
+ }
+
+ if (moduleApi->qobjectApi)
+ v8engine->qobjectWrapper()->setProperty(moduleApi->qobjectApi, propertystring, value,
+ QV8QObjectWrapper::IgnoreRevision);
+ }
}
return value;
void tst_qdeclarativeecmascript::moduleApi()
{
- QSKIP("Module API not supported with V8", SkipAll);
-
QDeclarativeComponent component(&engine, TEST_FILE("moduleApi.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("existingUriTest").toInt(), 20);
+
+ QEXPECT_FAIL("", "QTBUG-17318", Continue);
QCOMPARE(object->property("scriptTest").toInt(), 13);
QCOMPARE(object->property("qobjectTest").toInt(), 20);
QCOMPARE(object->property("qobjectMethodTest").toInt(), 1); // first call of method, so count = 1.
object = componentTwo.create();
QVERIFY(object != 0);
QCOMPARE(object->property("existingUriTest").toInt(), 20);
+ QEXPECT_FAIL("", "QTBUG-17318", Continue);
QCOMPARE(object->property("scriptTest").toInt(), 13); // shouldn't have incremented.
QCOMPARE(object->property("qobjectParentedTest").toInt(), 26); // shouldn't have incremented.
delete object;