From 5998ab3d4d111a536eb44e74aa901aa103b0bfc3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 29 May 2013 12:30:34 +0200 Subject: [PATCH] Remove now unused subcontext functionality Change-Id: I63b1803397dc79a671bd4cf35fb667ecacb10cab Reviewed-by: Simon Hausmann --- src/qml/qml/v8/qv8contextwrapper.cpp | 40 ++---------------------------------- src/qml/qml/v8/qv8contextwrapper_p.h | 3 --- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp index 643dd79..7cbf7f7 100644 --- a/src/qml/qml/v8/qv8contextwrapper.cpp +++ b/src/qml/qml/v8/qv8contextwrapper.cpp @@ -65,25 +65,10 @@ public: inline QQmlContextData *getContext() const; inline QObject *getScopeObject() const; - quint32 hasSubContexts:1; quint32 readOnly:1; quint32 ownsContext:1; quint32 dummy:29; - // 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 - // the script, which contains a pointer to the context. We can then access the - // v8::Script::Data() later on to resolve names and URLs against the sub-context instead - // of the main outer context. - struct SubContext : public v8::String::ExternalStringResource { - SubContext(QQmlContextData *context) : context(context) {} - QQmlGuardedContextData context; - - virtual const uint16_t* data() const { return (const uint16_t *)internal.constData(); } - virtual size_t length() const { return internal.length(); } - }; - private: QQmlGuardedContextData context; QQmlGuard scopeObject; @@ -91,7 +76,7 @@ private: }; QV8ContextResource::QV8ContextResource(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext) -: QV8ObjectResource(engine), hasSubContexts(false), readOnly(true), +: QV8ObjectResource(engine), readOnly(true), ownsContext(ownsContext), dummy(0), context(context), scopeObject(scopeObject) { } @@ -111,19 +96,7 @@ QObject *QV8ContextResource::getScopeObject() const // Returns the context, including resolving a subcontext QQmlContextData *QV8ContextResource::getContext() const { - if (!hasSubContexts) - return context; - - v8::Handle callingdata = v8::Context::GetCallingScriptData(); - if (callingdata.IsEmpty() || !callingdata->IsString()) - return context; - - v8::Handle callingstring = callingdata->ToString(); - Q_ASSERT(callingstring->IsExternal()); - Q_ASSERT(callingstring->GetExternalStringResource()); - - SubContext *sc = static_cast(callingstring->GetExternalStringResource()); - return sc->context; + return context; } QV8ContextWrapper::QV8ContextWrapper() @@ -186,15 +159,6 @@ void QV8ContextWrapper::setReadOnly(v8::Handle qmlglobal, bool readO resource->readOnly = readOnly; } -//void QV8ContextWrapper::addSubContext(v8::Handle qmlglobal, v8::Handle script, -// QQmlContextData *ctxt) -//{ -// QV8ContextResource *resource = v8_resource_cast(qmlglobal); -// Q_ASSERT(resource); -// resource->hasSubContexts = true; -// script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt))); -//} - QQmlContextData *QV8ContextWrapper::callingContext() { QV4::Object *qmlglobal = QV8Engine::getV4(m_engine)->qmlContextObject(); diff --git a/src/qml/qml/v8/qv8contextwrapper_p.h b/src/qml/qml/v8/qv8contextwrapper_p.h index 783cc42..cd75cc6 100644 --- a/src/qml/qml/v8/qv8contextwrapper_p.h +++ b/src/qml/qml/v8/qv8contextwrapper_p.h @@ -79,9 +79,6 @@ public: void setReadOnly(v8::Handle, bool); -// void addSubContext(v8::Handle qmlglobal, v8::Handle, -// QQmlContextData *ctxt); - QQmlContextData *callingContext(); QQmlContextData *context(v8::Handle); -- 2.7.4