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())
Object *newForEachIteratorObject(ExecutionContext *ctx, Object *o);
+ Object *qmlContextObject() const;
+
void requireArgumentsAccessors(int n);
void markObjects();
}
-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();
* 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:
#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 "
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)
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
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
#include <QtQml/qqmlfile.h>
#include <private/qqmlengine_p.h>
+#include <private/qv4engine_p.h>
QT_BEGIN_NAMESPACE
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());
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);
}
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);