#include <private/qv8engine_p.h>
#include <private/qv8include_p.h>
+#include <private/qv4functionobject_p.h>
+
#include <QStack>
#include <QStringList>
#include <QThreadStorage>
#include <qqmlinfo.h>
#include "qqmlmemoryprofiler_p.h"
+#define INITIALPROPERTIES_SOURCE \
+ "(function(object, values) {"\
+ "try {"\
+ "for (var property in values) {" \
+ "try {"\
+ "var properties = property.split(\".\");"\
+ "var o = object;"\
+ "for (var ii = 0; ii < properties.length - 1; ++ii) {"\
+ "o = o[properties[ii]];"\
+ "}"\
+ "o[properties[properties.length - 1]] = values[property];"\
+ "} catch(e) {}"\
+ "}"\
+ "} catch(e) {}"\
+ "})"
+
+
namespace {
QThreadStorage<int> creationDepth;
}
virtual ~QQmlComponentExtension();
v8::Persistent<v8::Function> incubationConstructor;
- v8::Persistent<v8::Script> initialProperties;
v8::Persistent<v8::Function> forceCompletion;
};
V8_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension);
}
QV8Engine *v8engine = args->engine();
+ QV4::ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
QQmlContext *ctxt = creationContext();
if (!ctxt) ctxt = d->engine->rootContext();
if (!valuemap.IsEmpty()) {
QQmlComponentExtension *e = componentExtension(v8engine);
- // Try catch isn't needed as the function itself is loaded with try/catch
- v8::Handle<v8::Value> function = e->initialProperties->Run(args->qmlGlobal());
- v8::Handle<v8::Value> args[] = { object, valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
+ QV4::Value f = v8engine->evaluateScript(QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal()->v4Value().asObject());
+ QV4::Value args[] = { object->v4Value(), valuemap->v4Value() };
+ f.asFunctionObject()->call(v4engine->current, QV4::Value::fromObject(v4engine->globalObject), args, 2);
}
d->completeCreate();
{
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
QV8Engine *v8engine = ep->v8engine();
+ QV4::ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
v8::HandleScope handle_scope;
v8::Context::Scope scope(v8engine->context());
if (!valuemap.IsEmpty()) {
QQmlComponentExtension *e = componentExtension(v8engine);
- // Try catch isn't needed as the function itself is loaded with try/catch
- v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
- v8::Handle<v8::Value> args[] = { object, valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(v8engine->global(), 2, args);
+ QV4::Value f = v8engine->evaluateScript(QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal->v4Value().asObject());
+ QV4::Value args[] = { object->v4Value(), valuemap->v4Value() };
+ f.asFunctionObject()->call(v4engine->current, QV4::Value::fromObject(v4engine->globalObject), args, 2);
}
}
QV8IncubatorResource::ForceCompletionGetter);
incubationConstructor = qPersistentNew(ft->GetFunction());
}
-
- {
-#define INITIALPROPERTIES_SOURCE \
- "(function(object, values) {"\
- "try {"\
- "for(var property in values) {" \
- "try {"\
- "var properties = property.split(\".\");"\
- "var o = object;"\
- "for (var ii = 0; ii < properties.length - 1; ++ii) {"\
- "o = o[properties[ii]];"\
- "}"\
- "o[properties[properties.length - 1]] = values[property];"\
- "} catch(e) {}"\
- "}"\
- "} catch(e) {}"\
- "})"
- initialProperties = qPersistentNew(engine->qmlModeCompile(QLatin1String(INITIALPROPERTIES_SOURCE)));
-#undef INITIALPROPERTIES_SOURCE
- }
}
v8::Handle<v8::Value> QV8IncubatorResource::ObjectGetter(v8::Local<v8::String>,
QQmlComponentExtension::~QQmlComponentExtension()
{
qPersistentDispose(incubationConstructor);
- qPersistentDispose(initialProperties);
qPersistentDispose(forceCompletion);
}
if (!valuemap.IsEmpty()) {
QQmlComponentExtension *e = componentExtension(engine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Handle<v8::Value> function = e->initialProperties->Run(qmlGlobal);
- v8::Handle<v8::Value> args[] = { engine->newQObject(o), valuemap };
- v8::Handle<v8::Function>::Cast(function)->Call(engine->global(), 2, args);
+ QV4::ExecutionEngine *v4engine = QV8Engine::getV4(engine);
- qPersistentDispose(valuemap);
- qPersistentDispose(qmlGlobal);
+ QV4::Value f = engine->evaluateScript(QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal->v4Value().asObject());
+ QV4::Value args[] = { engine->newQObject(o)->v4Value(), valuemap->v4Value() };
+ f.asFunctionObject()->call(v4engine->current, QV4::Value::fromObject(v4engine->globalObject), args, 2);
}
}
dispose();
}
+#undef INITIALPROPERTIES_SOURCE
+
QT_END_NAMESPACE