Remove another methods from v8:Context
authorLars Knoll <lars.knoll@digia.com>
Fri, 3 May 2013 14:51:32 +0000 (16:51 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Sat, 4 May 2013 07:57:28 +0000 (09:57 +0200)
Change-Id: I1f476931e7d09efc72e64dcb1b86335c987678ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/v4/qv4engine.cpp
src/qml/qml/v4/qv4engine_p.h
src/qml/qml/v4/qv4v8.cpp
src/qml/qml/v4/qv4v8_p.h
src/qml/qml/v8/qv8contextwrapper.cpp
src/qml/qml/v8/qv8include.cpp
src/qml/qml/v8/qv8qobjectwrapper.cpp

index 8fa6b53..aced2d2 100644 (file)
@@ -499,6 +499,22 @@ Object *ExecutionEngine::newForEachIteratorObject(ExecutionContext *ctx, Object
     return new (memoryManager) ForEachIteratorObject(ctx, o);
 }
 
+Object *ExecutionEngine::qmlContextObject() const
+{
+    ExecutionContext *ctx = current;
+    if (!ctx->outer)
+        return 0;
+
+    while (ctx->outer && ctx->outer->type != ExecutionContext::Type_GlobalContext)
+        ctx = ctx->outer;
+
+    assert(ctx);
+    if (ctx->type != ExecutionContext::Type_QmlContext)
+        return 0;
+
+    return static_cast<CallContext *>(ctx)->activation;
+}
+
 void ExecutionEngine::requireArgumentsAccessors(int n)
 {
     if (n <= argumentsAccessors.size())
index 9f5a04b..818cd9e 100644 (file)
@@ -245,6 +245,8 @@ struct Q_QML_EXPORT ExecutionEngine
 
     Object *newForEachIteratorObject(ExecutionContext *ctx, Object *o);
 
+    Object *qmlContextObject() const;
+
     void requireArgumentsAccessors(int n);
 
     void markObjects();
index c8df5b4..ceab9d3 100644 (file)
@@ -2001,20 +2001,6 @@ void TryCatch::Reset()
 }
 
 
-Local<Object> Context::GetCallingQmlGlobal()
-{
-    QV4::ExecutionEngine *engine = Isolate::GetCurrent()->GetEngine();
-    QV4::ExecutionContext *ctx = engine->current;
-    while (ctx && ctx->outer->type != ExecutionContext::Type_GlobalContext)
-        ctx = ctx->outer;
-
-    assert(ctx);
-    if (!ctx->type == ExecutionContext::Type_QmlContext)
-        return Local<Object>();
-
-    return Local<Object>::New(Value::fromV4Value(QV4::Value::fromObject(static_cast<CallContext *>(ctx)->activation)));
-}
-
 Local<Value> Context::GetCallingScriptData()
 {
     Q_UNIMPLEMENTED();
index a66c318..92fb9fa 100644 (file)
@@ -2276,7 +2276,6 @@ public:
    * context of the top-most JavaScript frame.  If there are no
    * JavaScript frames an empty handle is returned.
    */
-  static Local<Object> GetCallingQmlGlobal();
   static Local<Value> GetCallingScriptData();
 
 private:
index 66ccb56..7676f96 100644 (file)
@@ -45,6 +45,9 @@
 #include <private/qqmlengine_p.h>
 #include <private/qqmlcontext_p.h>
 
+#include <private/qv4engine_p.h>
+#include <private/qv4value_p.h>
+
 QT_BEGIN_NAMESPACE
 
 static QString internal(QLatin1String("You've stumbled onto an internal implementation detail "
@@ -210,11 +213,12 @@ void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Hand
 
 QQmlContextData *QV8ContextWrapper::callingContext()
 {
-    v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
-    if (qmlglobal.IsEmpty()) return 0;
+    QV4::Object *qmlglobal = QV8Engine::getV4(m_engine)->qmlContextObject();
+    if (!qmlglobal)
+        return 0;
 
-    QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(qmlglobal);
-    return r?r->getContext():0;
+    QV8ContextResource *r = v8_resource_cast<QV8ContextResource>(v8::Handle<v8::Object>(QV4::Value::fromObject(qmlglobal)));
+    return r ? r->getContext() : 0;
 }
 
 QQmlContextData *QV8ContextWrapper::context(v8::Handle<v8::Value> value)
@@ -253,7 +257,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
     if (!context)
         return v8::Undefined();
 
-    if (v8::Context::GetCallingQmlGlobal() != info.This())
+    if (info.GetIsolate()->GetEngine()->qmlContextObject() != info.This()->v4Value().asObject())
         return v8::Handle<v8::Value>();
 
     // Search type (attached property/enum/imported scripts) names
@@ -383,7 +387,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Setter(v8::Local<v8::String> property,
     if (!context)
         return v8::Undefined();
 
-    if (v8::Context::GetCallingQmlGlobal() != info.This())
+    if (info.GetIsolate()->GetEngine()->qmlContextObject() != info.This()->v4Value().asObject())
         return v8::Handle<v8::Value>();
 
     // See QV8ContextWrapper::Getter for resolution order
index 0d76050..fc59093 100644 (file)
@@ -48,6 +48,7 @@
 #include <QtQml/qqmlfile.h>
 
 #include <private/qqmlengine_p.h>
+#include <private/qv4engine_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -190,7 +191,7 @@ v8::Handle<v8::Value> QV8Include::include(const v8::Arguments &args)
     if (localFile.isEmpty()) {
 
         QV8Include *i = new QV8Include(url, engine, context, 
-                                       v8::Context::GetCallingQmlGlobal(), 
+                                       QV4::Value::fromObject(args.GetIsolate()->GetEngine()->qmlContextObject()),
                                        callbackFunction);
         result = v8::Local<v8::Object>::New(i->result());
 
@@ -214,7 +215,7 @@ v8::Handle<v8::Value> QV8Include::include(const v8::Arguments &args)
             v8::Local<v8::Script> script = engine->qmlModeCompile(code, url.toString());
 
             if (!try_catch.HasCaught()) {
-                v8::Local<v8::Object> qmlglobal = v8::Context::GetCallingQmlGlobal();
+                v8::Handle<v8::Object> qmlglobal = QV4::Value::fromObject(args.GetIsolate()->GetEngine()->qmlContextObject());
                 engine->contextWrapper()->addSubContext(qmlglobal, script, importContext);
                 script->Run(qmlglobal);
             }
index f13e2d6..6fe8721 100644 (file)
@@ -498,7 +498,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject
            v8::Handle<v8::Value> argv[] = { 
                objectHandle?*objectHandle:engine->newQObject(object),
                v8::Integer::New(index),
-               v8::Context::GetCallingQmlGlobal()
+               QV4::Value::fromObject(QV8Engine::getV4(engine)->qmlContextObject())
            };
            Q_ASSERT(argv[0]->IsObject());
            return engine->qobjectWrapper()->m_methodConstructor->Call(v8::Value::fromV4Value(engine->global()), 3, argv);