aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-01-18 17:12:25 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-24 23:18:34 +0100
commit149f6afe321ce59aebe4ce2f9dddd1881d0ac22b (patch)
tree45233b8c808ed553051799b38a6b1e73898db2e1 /src/declarative/qml/v8
parent49212ef6d8934a023e6d0a7b778ec25605a8be7a (diff)
Allow JS API in modules
Allow modules to export verisoned javascript code into specified namespaces. Task-number: QTBUG-20857 Change-Id: Ic968c697ba36cbc4535870ed5eed2fe7f01af11d Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8')
-rw-r--r--src/declarative/qml/v8/qv8typewrapper.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/declarative/qml/v8/qv8typewrapper.cpp b/src/declarative/qml/v8/qv8typewrapper.cpp
index 32db26324f..f1c095678b 100644
--- a/src/declarative/qml/v8/qv8typewrapper.cpp
+++ b/src/declarative/qml/v8/qv8typewrapper.cpp
@@ -196,9 +196,16 @@ v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property,
resource->importNamespace);
if (r.isValid()) {
- Q_ASSERT(r.type);
+ if (r.type) {
+ return v8engine->typeWrapper()->newObject(object, r.type, resource->mode);
+ } else if (r.scriptIndex != -1) {
+ int index = r.scriptIndex;
+ QDeclarativeContextData *context = v8engine->callingContext();
+ if (index < context->importedScripts.count())
+ return context->importedScripts.at(index);
+ }
- return v8engine->typeWrapper()->newObject(object, r.type, resource->mode);
+ return v8::Undefined();
} else if (QDeclarativeMetaType::ModuleApiInstance *moduleApi = resource->typeNamespace->moduleApi(resource->importNamespace)) {
if (moduleApi->scriptCallback) {