diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-05-21 09:27:43 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-24 00:55:55 +0200 |
commit | 0853343c33e394f35c31c161b019b2aed17f9256 (patch) | |
tree | 3f792f58979ae75f8e75a0c0ef6e7f89265b1c16 /src/qml/qml/v8 | |
parent | 9ee6bb0e14d968647350683eafbe80eed7a27058 (diff) |
Avoid dynamic lookup of signal handler arguments
Rewrite signal handlers to include the parameters
in the rewrite. Also check whether parameters are
actually used when possible, and if not don't
provide them to the expression.
Change-Id: I7d65c05f4639979dd61035cf7478119ef7647c25
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper.cpp | 27 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper_p.h | 7 |
2 files changed, 1 insertions, 33 deletions
diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp index 435ac69ce3..82ff64fac5 100644 --- a/src/qml/qml/v8/qv8contextwrapper.cpp +++ b/src/qml/qml/v8/qv8contextwrapper.cpp @@ -66,8 +66,6 @@ public: quint32 readOnly:1; quint32 dummy:29; - QObject *secondaryScope; - // This is a pretty horrible hack, and an abuse of external strings. When we create a // sub-context (a context created by a Qt.include() in an external javascript file), // we pass a specially crafted SubContext external string as the v8::Script::Data() to @@ -90,7 +88,7 @@ private: QV8ContextResource::QV8ContextResource(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject) : QV8ObjectResource(engine), isSharedContext(false), hasSubContexts(false), readOnly(true), - secondaryScope(0), context(context), scopeObject(scopeObject) + context(context), scopeObject(scopeObject) { } @@ -209,16 +207,6 @@ void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Hand script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt))); } -QObject *QV8ContextWrapper::setSecondaryScope(v8::Handle<v8::Object> ctxt, QObject *scope) -{ - QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(ctxt); - if (!resource) return 0; - - QObject *rv = resource->secondaryScope; - resource->secondaryScope = scope; - return rv; -} - QQmlContextData *QV8ContextWrapper::callingContext() { v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal(); @@ -262,7 +250,6 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property, return v8::Handle<v8::Value>(); // Search type (attached property/enum/imported scripts) names - // Secondary scope object // while (context) { // Search context properties // Search scope object @@ -301,12 +288,6 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property, QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine->engine()); QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper(); - if (resource->secondaryScope) { - v8::Handle<v8::Value> result = qobjectWrapper->getProperty(resource->secondaryScope, propertystring, - QV8QObjectWrapper::IgnoreRevision); - if (!result.IsEmpty()) return result; - } - while (context) { // Search context properties if (context->propertyNames) { @@ -408,12 +389,6 @@ v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property, QV8QObjectWrapper *qobjectWrapper = engine->qobjectWrapper(); - // Search scope object - if (resource->secondaryScope && - qobjectWrapper->setProperty(resource->secondaryScope, propertystring, value, - QV8QObjectWrapper::IgnoreRevision)) - return value; - while (context) { // Search context properties if (context->propertyNames && -1 != context->propertyNames->value(propertystring)) diff --git a/src/qml/qml/v8/qv8contextwrapper_p.h b/src/qml/qml/v8/qv8contextwrapper_p.h index 117f16ab39..5c7b8c2187 100644 --- a/src/qml/qml/v8/qv8contextwrapper_p.h +++ b/src/qml/qml/v8/qv8contextwrapper_p.h @@ -79,13 +79,6 @@ public: void addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script>, QQmlContextData *ctxt); - // XXX We only use the secondary scope to pass the "arguments" of the signal to - // on<SignalName> properties. Instead of doing this we should rewrite the - // JavaScript closure function to accept these arguments as named parameters. - // To keep backwards compatibility we have to check that the argument names are - // not members of the QV8Engine::illegalNames() set. - QObject *setSecondaryScope(v8::Handle<v8::Object>, QObject *); - QQmlContextData *callingContext(); QQmlContextData *context(v8::Handle<v8::Value>); |