This prepares things for a rewrite of the internals of Persistent.
Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
QV4::Scope scope(e);
QV4::ScopedObject o(scope, jsp->value);
- iterator = e->newForEachIteratorObject(o)->asReturnedValue();
+ iterator.set(e, e->newForEachIteratorObject(o));
currentName = (QV4::String *)0;
nextName = (QV4::String *)0;
d_ptr->nextName = (QV4::String *)0;
QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
if (!v4) {
- d_ptr->iterator = QV4::Encode::undefined();
+ d_ptr->iterator.set(v4, QV4::Encode::undefined());
return *this;
}
QJSValuePrivate *jsp = QJSValuePrivate::get(object);
QV4::Scope scope(v4);
QV4::ScopedObject o(scope, jsp->value);
- d_ptr->iterator = v4->newForEachIteratorObject(o)->asReturnedValue();
+ d_ptr->iterator.set(v4, v4->newForEachIteratorObject(o));
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
it->d()->it.flags = QV4::ObjectIterator::NoFlags;
QV4::ScopedString nm(scope);
, m_pauseRequested(false)
, m_haveBreakPoints(false)
, m_breakOnThrow(false)
- , m_returnedValue(Primitive::undefinedValue())
+ , m_returnedValue(engine, Primitive::undefinedValue())
, m_gatherSources(0)
, m_runningJob(0)
{
return;
if (!m_returnedValue.isUndefined())
- m_returnedValue = Encode::undefined();
+ m_returnedValue.set(m_engine, Encode::undefined());
- m_currentContext = m_engine->currentContext();
+ m_currentContext.set(m_engine, m_engine->currentContext());
m_stepping = speed;
m_runningCondition.wakeAll();
}
QMutexLocker locker(&m_lock);
if (m_stepping == StepIn) {
- m_currentContext = m_engine->currentContext();
+ m_currentContext.set(m_engine, m_engine->currentContext());
}
}
QMutexLocker locker(&m_lock);
- Scope scope(m_engine);
if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->currentContext()) {
- m_currentContext = m_engine->currentContext()->parent;
+ m_currentContext.set(m_engine, m_engine->currentContext()->parent);
m_stepping = StepOver;
- m_returnedValue = retVal;
+ m_returnedValue.set(m_engine, retVal);
}
}
const QV4::ValueRef qmlglobal, const QV4::ValueRef callback)
: v4(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context)
{
- m_qmlglobal = qmlglobal;
+ m_qmlglobal.set(engine, qmlglobal);
if (callback->asFunctionObject())
- m_callbackFunction = callback;
+ m_callbackFunction.set(engine, callback);
- m_resultObject = resultValue(v4);
+ m_resultObject.set(v4, resultValue(v4));
m_network = engine->v8Engine->networkAccessManager();
#include "qv4persistent_p.h"
#include "qv4mm_p.h"
+#include "qv4object_p.h"
using namespace QV4;
-PersistentValue::PersistentValue(const ValueRef val)
- : d(new PersistentValuePrivate(val.asReturnedValue()))
+PersistentValue::PersistentValue(ExecutionEngine *engine, const ValueRef val)
+ : d(new PersistentValuePrivate(val.asReturnedValue(), engine))
{
}
-PersistentValue::PersistentValue(ReturnedValue val)
- : d(new PersistentValuePrivate(val))
+PersistentValue::PersistentValue(ExecutionEngine *engine, ReturnedValue val)
+ : d(new PersistentValuePrivate(val, engine))
{
}
d->ref();
}
+PersistentValue::~PersistentValue()
+{
+ if (d)
+ d->deref();
+}
+
PersistentValue &PersistentValue::operator=(const PersistentValue &other)
{
if (d == other.d)
return *this;
}
-PersistentValue &PersistentValue::operator =(const ValueRef other)
+PersistentValue &PersistentValue::operator=(const WeakValue &other)
{
- if (!d) {
- d = new PersistentValuePrivate(other.asReturnedValue());
- return *this;
- }
- d = d->detach(other.asReturnedValue());
+ QV4::ExecutionEngine *engine = other.engine();
+ if (!d)
+ d = new PersistentValuePrivate(other.value(), engine);
+ else
+ d = d->detach(other.value());
return *this;
}
-PersistentValue &PersistentValue::operator =(ReturnedValue other)
+PersistentValue &PersistentValue::operator=(Object *object)
{
- if (!d) {
- d = new PersistentValuePrivate(other);
- return *this;
- }
- d = d->detach(other);
+ QV4::ExecutionEngine *engine = object->engine();
+ if (!d)
+ d = new PersistentValuePrivate(object->asReturnedValue(), engine);
+ else
+ d = d->detach(object->asReturnedValue());
return *this;
}
-PersistentValue &PersistentValue::operator=(Heap::Base *obj)
+void PersistentValue::set(ExecutionEngine *engine, const ValueRef val)
{
- if (!d) {
- d = new PersistentValuePrivate(Value::fromHeapObject(obj).asReturnedValue());
- return *this;
- }
- d = d->detach(Value::fromHeapObject(obj).asReturnedValue());
- return *this;
+ if (!d)
+ d = new PersistentValuePrivate(val.asReturnedValue(), engine);
+ else
+ d = d->detach(val.asReturnedValue());
}
-PersistentValue::~PersistentValue()
+void PersistentValue::set(ExecutionEngine *engine, ReturnedValue val)
{
- if (d)
- d->deref();
+ if (!d)
+ d = new PersistentValuePrivate(val, engine);
+ else
+ d = d->detach(val);
}
-WeakValue::WeakValue(const ValueRef val)
- : d(new PersistentValuePrivate(val.asReturnedValue(), /*engine*/0, /*weak*/true))
+void PersistentValue::set(ExecutionEngine *engine, Heap::Base *obj)
{
+ if (!d)
+ d = new PersistentValuePrivate(obj->asReturnedValue(), engine);
+ else
+ d = d->detach(obj->asReturnedValue());
}
WeakValue::WeakValue(const WeakValue &other)
d->ref();
}
-WeakValue::WeakValue(ReturnedValue val)
- : d(new PersistentValuePrivate(val, /*engine*/0, /*weak*/true))
-{
-}
-
WeakValue &WeakValue::operator=(const WeakValue &other)
{
if (d == other.d)
return *this;
}
-WeakValue &WeakValue::operator =(const ValueRef other)
+WeakValue::~WeakValue()
{
- if (!d) {
- d = new PersistentValuePrivate(other.asReturnedValue(), /*engine*/0, /*weak*/true);
- return *this;
- }
- d = d->detach(other.asReturnedValue(), /*weak*/true);
- return *this;
+ if (d)
+ d->deref();
}
-WeakValue &WeakValue::operator =(const ReturnedValue &other)
+void WeakValue::set(ExecutionEngine *e, const ValueRef val)
{
- if (!d) {
- d = new PersistentValuePrivate(other, /*engine*/0, /*weak*/true);
- return *this;
- }
- d = d->detach(other, /*weak*/true);
- return *this;
+ if (!d)
+ d = new PersistentValuePrivate(val.asReturnedValue(), e, /*weak*/true);
+ else
+ d = d->detach(val.asReturnedValue(), /*weak*/true);
}
+void WeakValue::set(ExecutionEngine *e, ReturnedValue val)
+{
+ if (!d)
+ d = new PersistentValuePrivate(val, e, /*weak*/true);
+ else
+ d = d->detach(val, /*weak*/true);
+}
-WeakValue::~WeakValue()
+void WeakValue::set(ExecutionEngine *e, Heap::Base *obj)
{
- if (d)
- d->deref();
+ if (!d)
+ d = new PersistentValuePrivate(obj->asReturnedValue(), e, /*weak*/true);
+ else
+ d = d->detach(obj->asReturnedValue(), /*weak*/true);
}
void WeakValue::markOnce(ExecutionEngine *e)
PersistentValue() : d(0) {}
PersistentValue(const PersistentValue &other);
PersistentValue &operator=(const PersistentValue &other);
-
- PersistentValue(const ValueRef val);
- PersistentValue(ReturnedValue val);
- PersistentValue &operator=(const ValueRef other);
- PersistentValue &operator=(const ScopedValue &other);
- PersistentValue &operator =(ReturnedValue other);
- PersistentValue &operator=(Heap::Base *obj);
+ PersistentValue &operator=(const WeakValue &other);
+ PersistentValue &operator=(Object *object);
~PersistentValue();
+ PersistentValue(ExecutionEngine *engine, const ValueRef val);
+ PersistentValue(ExecutionEngine *engine, ReturnedValue val);
+
+ void set(ExecutionEngine *engine, const ValueRef val);
+ void set(ExecutionEngine *engine, ReturnedValue val);
+ void set(ExecutionEngine *engine, Heap::Base *obj);
+
ReturnedValue value() const {
return (d ? d->value.asReturnedValue() : Primitive::undefinedValue().asReturnedValue());
}
return d->value.asManaged();
}
- ExecutionEngine *engine() {
+ ExecutionEngine *engine() const {
if (!d)
return 0;
if (d->engine)
{
public:
WeakValue() : d(0) {}
- WeakValue(const ValueRef val);
WeakValue(const WeakValue &other);
- WeakValue(ReturnedValue val);
WeakValue &operator=(const WeakValue &other);
- WeakValue &operator=(const ValueRef other);
- WeakValue &operator =(const ReturnedValue &other);
-
~WeakValue();
+ void set(ExecutionEngine *e, const ValueRef val);
+ void set(ExecutionEngine *e, ReturnedValue val);
+ void set(ExecutionEngine *e, Heap::Base *obj);
+
ReturnedValue value() const {
return (d ? d->value.asReturnedValue() : Primitive::undefinedValue().asReturnedValue());
}
- ExecutionEngine *engine() {
+ ExecutionEngine *engine() const {
if (!d)
return 0;
if (d->engine)
!ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
QV4::ScopedValue rv(scope, create(engine, object));
- ddata->jsWrapper = rv;
+ ddata->jsWrapper.set(scope.engine, rv);
ddata->jsEngineId = engine->m_engineId;
return rv.asReturnedValue();
// a handle in the ddata, we can assume ownership of the ddata->v8object
if (ddata->jsWrapper.isUndefined() && !alternateWrapper) {
QV4::ScopedValue result(scope, create(engine, object));
- ddata->jsWrapper = result;
+ ddata->jsWrapper.set(scope.engine, result);
ddata->jsEngineId = engine->m_engineId;
return result.asReturnedValue();
}
QV4::QObjectSlotDispatcher *slot = new QV4::QObjectSlotDispatcher;
slot->signalIndex = signalIndex;
- slot->thisObject = thisObject;
- slot->function = f;
+ slot->thisObject.set(scope.engine, thisObject);
+ slot->function.set(scope.engine, f);
if (QQmlData *ddata = QQmlData::get(signalObject)) {
if (QQmlPropertyCache *propertyCache = ddata->propertyCache) {
return *this;
}
-inline PersistentValue &PersistentValue::operator=(const ScopedValue &other)
-{
- return operator=(other.asReturnedValue());
-}
-
inline ValueRef::ValueRef(const ScopedValue &v)
: ptr(v.ptr)
{}
Script::Script(ExecutionEngine *v4, Object *qml, CompiledData::CompilationUnit *compilationUnit)
: line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
- , qml(qml->asReturnedValue()), vmFunction(0), parseAsBinding(true)
+ , qml(v4, qml->asReturnedValue()), vmFunction(0), parseAsBinding(true)
{
parsed = true;
if (vmFunction) {
Scope valueScope(v4);
ScopedObject holder(valueScope, v4->memoryManager->alloc<CompilationUnitHolder>(v4, compilationUnit));
- compilationUnitHolder = holder.asReturnedValue();
+ compilationUnitHolder.set(v4, holder);
}
}
QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = isel->compile();
vmFunction = compilationUnit->linkToEngine(v4);
ScopedObject holder(valueScope, v4->memoryManager->alloc<CompilationUnitHolder>(v4, compilationUnit));
- compilationUnitHolder = holder.asReturnedValue();
+ compilationUnitHolder.set(v4, holder);
}
if (!vmFunction) {
Script(ExecutionEngine *engine, Object *qml, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
: sourceFile(source), line(line), column(column), sourceCode(sourceCode)
, scope(engine->rootContext()), strictMode(false), inheritContext(true), parsed(false)
- , qml(qml->asReturnedValue()), vmFunction(0), parseAsBinding(true) {}
+ , qml(engine, qml->asReturnedValue()), vmFunction(0), parseAsBinding(true) {}
Script(ExecutionEngine *engine, Object *qml, CompiledData::CompilationUnit *compilationUnit);
~Script();
QString sourceFile;
QQmlAbstractExpression::setContext(QQmlContextData::get(ctxt));
setScopeObject(obj);
- v4function = qmlBinding(context(), obj, str, QString(), 0);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(context()->engine)->v4engine();
+ v4function.set(v4, qmlBinding(context(), obj, str, QString(), 0));
}
QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
QQmlAbstractExpression::setContext(QQmlContextData::get(ctxt ? ctxt : scriptPrivate->context));
setScopeObject(obj ? obj : scriptPrivate->scope);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(context()->engine)->v4engine();
if (runtimeFunction) {
- v4function = QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxtdata, scopeObject(), runtimeFunction);
+ v4function.set(v4, QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxtdata, scopeObject(), runtimeFunction));
} else {
QString code = scriptPrivate->script;
- v4function = qmlBinding(context(), scopeObject(), code, url, scriptPrivate->lineNumber);
+ v4function.set(v4, qmlBinding(context(), scopeObject(), code, url, scriptPrivate->lineNumber));
}
}
QQmlAbstractExpression::setContext(ctxt);
setScopeObject(obj);
- v4function = qmlBinding(ctxt, obj, str, QString(), 0);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(context()->engine)->v4engine();
+ v4function.set(v4, qmlBinding(ctxt, obj, str, QString(), 0));
}
QQmlBinding::QQmlBinding(const QString &str, QObject *obj,
QQmlAbstractExpression::setContext(ctxt);
setScopeObject(obj);
- v4function = qmlBinding(ctxt, obj, str, url, lineNumber);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(context()->engine)->v4engine();
+ v4function.set(v4, qmlBinding(ctxt, obj, str, url, lineNumber));
}
QQmlBinding::QQmlBinding(const QV4::ValueRef functionPtr, QObject *obj, QQmlContextData *ctxt)
QQmlAbstractExpression::setContext(ctxt);
setScopeObject(obj);
- v4function = functionPtr;
+ v4function.set(functionPtr->asObject()->engine(), functionPtr);
}
QQmlBinding::~QQmlBinding()
QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::ValueRef &function)
: QQmlJavaScriptExpression(&QQmlBoundSignalExpression_jsvtable),
m_index(index),
- m_v8function(function),
+ m_function(function->asObject()->engine(), function),
m_target(target),
m_extra(0)
{
QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index);
QString error;
- m_v8function = QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error);
+ QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
+ m_function.set(engine, QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error));
if (!error.isEmpty()) {
qmlInfo(scopeObject()) << error;
setInvalidParameterName(true);
if (expressionFunctionValid()) {
Q_ASSERT (context() && engine());
QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedValue v(scope, m_v8function.value());
+ QV4::ScopedValue v(scope, m_function.value());
return v->toQStringNoThrow();
} else {
Q_ASSERT(!m_extra.isNull());
if (expressionFunctionValid()) {
Q_ASSERT (context() && engine());
QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedFunctionObject v(scope, m_v8function.value());
+ QV4::ScopedFunctionObject v(scope, m_function.value());
return v ? v->function() : 0;
}
return 0;
m_extra->m_handlerName.clear();
m_extra->m_parameterString.clear();
- m_v8function = evalFunction(context(), scopeObject(), expression,
- m_extra->m_sourceLocation.sourceFile, m_extra->m_sourceLocation.line, &m_extra->m_v8qmlscope);
+ m_function.set(scope.engine, evalFunction(context(), scopeObject(), expression,
+ m_extra->m_sourceLocation.sourceFile, m_extra->m_sourceLocation.line, &m_extra->m_v8qmlscope));
- if (m_v8function.isNullOrUndefined()) {
+ if (m_function.isNullOrUndefined()) {
ep->dereferenceScarceResources();
return; // could not evaluate function. Not valid.
}
int *argsTypes = QQmlMetaObject(m_target).methodParameterTypes(methodIndex, dummy, 0);
int argCount = argsTypes ? *argsTypes : 0;
- QV4::ScopedValue f(scope, m_v8function.value());
+ QV4::ScopedValue f(scope, m_function.value());
QV4::ScopedCallData callData(scope, argCount);
for (int ii = 0; ii < argCount; ++ii) {
int type = argsTypes[ii + 1];
void setInvalidParameterName(bool v) { m_extra.setFlag2Value(v); }
int m_index;
- QV4::PersistentValue m_v8function;
+ QV4::PersistentValue m_function;
QObject *m_target;
proto->defineAccessorProperty(QStringLiteral("object"), QV4::QmlIncubatorObject::method_get_object, 0);
proto->defineDefaultProperty(QStringLiteral("forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion);
- incubationProto = proto;
+ incubationProto.set(v4, proto);
}
QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(QV4::CallContext *ctx)
void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFunction, QObject *me)
{
expressionFunctionValid = true;
- function = QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxt, me, runtimeFunction);
+ QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
+ function.set(engine, QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxt, me, runtimeFunction));
QQmlAbstractExpression::setContext(ctxt);
setScopeObject(me);
{
Q_Q(QQmlExpression);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(q->engine())->v4engine();
+
if (!expressionFunctionValid) {
- function = qmlBinding(context(), scopeObject(), expression, url, line, &qmlscope);
+ function.set(v4, qmlBinding(context(), scopeObject(), expression, url, line, &qmlscope));
expressionFunctionValid = true;
}
- QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(q->engine())->v4engine();
QV4::Scope scope(v4);
QV4::ScopedValue f(scope, function.value());
return evaluate(context(), f, isUndefined);
return QV4::Encode::undefined();
}
if (qmlscope)
- *qmlscope = qmlScopeObject;
+ qmlscope->set(v4, qmlScopeObject);
return result.asReturnedValue();
}
return QV4::Encode::undefined();
}
if (qmlscope)
- *qmlscope = qmlScopeObject;
+ qmlscope->set(v4, qmlScopeObject);
return result.asReturnedValue();
}
o->defineAccessorProperty(QStringLiteral("measurementSystem"), QQmlLocaleData::method_get_measurementSystem, 0);
o->defineAccessorProperty(QStringLiteral("exponential"), QQmlLocaleData::method_get_exponential, 0);
- prototype = o;
+ prototype.set(engine, o);
}
QV4LocaleDataDeletable::~QV4LocaleDataDeletable()
if (subComponentIndex == -1) {
QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count()));
- context->importedScripts = scripts;
+ context->importedScripts.set(v4, scripts);
for (int i = 0; i < compiledData->scripts.count(); ++i) {
QQmlScriptData *s = compiledData->scripts.at(i);
scripts->putIndexed(i, s->scriptValueForContext(context));
QV4::ScopedObject scriptsArray(scope);
if (ctxt->importedScripts.isNullOrUndefined()) {
scriptsArray = v4->newArrayObject(scripts.count());
- ctxt->importedScripts = scriptsArray;
+ ctxt->importedScripts.set(v4, scriptsArray);
} else {
scriptsArray = ctxt->importedScripts;
}
QV4::ScopedValue qmlglobal(scope, QV4::QmlContextWrapper::qmlScope(v4, ctxt, 0));
QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
- m_program->qml = qmlglobal;
+ m_program->qml.set(scope.engine, qmlglobal);
m_program->run();
if (scope.engine->hasException) {
QQmlError error = scope.engine->catchExceptionAsQmlError();
ep->warning(error);
}
- rv = qmlglobal;
+ rv.set(scope.engine, qmlglobal);
if (shared) {
m_value = rv;
m_loaded = true;
QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[data->runtimeFunctionIndex];
o = QV4::FunctionObject::createScriptFunction(qmlBindingContext, runtimeFunction);
- v8methods[index] = o;
+ v8methods[index].set(qmlBindingContext->engine(), o);
}
}
}
v8methods = new QV4::PersistentValue[metaData->methodCount];
int methodIndex = index - methodOffset() - plainSignals;
- v8methods[methodIndex] = function;
+ v8methods[methodIndex].set(function->asObject()->engine(), function);
}
QV4::ReturnedValue QQmlVMEMetaObject::vmeProperty(int index)
assert(qml);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(qml->handle());
QV4::Scope scope(v4);
- varProperties = QV4::ScopedValue(scope, v4->newArrayObject(metaData->varPropertyCount));
+ varProperties.set(scope.engine, v4->newArrayObject(metaData->varPropertyCount));
varPropertiesInitialized = true;
}
QQmlXMLHttpRequestData *d = xhrdata(v4);
if (d->nodePrototype.isUndefined()) {
ScopedObject p(scope, v4->memoryManager->alloc<NodePrototype>(v4));
- d->nodePrototype = p;
+ d->nodePrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
return d->nodePrototype.value();
ScopedObject pp(scope);
p->setPrototype((pp = NodePrototype::getProto(engine)));
p->defineAccessorProperty(QStringLiteral("tagName"), NodePrototype::method_get_nodeName, 0);
- d->elementPrototype = p;
+ d->elementPrototype.set(engine, p);
engine->v8Engine->freezeObject(p);
}
return d->elementPrototype.value();
p->defineAccessorProperty(QStringLiteral("name"), method_name, 0);
p->defineAccessorProperty(QStringLiteral("value"), method_value, 0);
p->defineAccessorProperty(QStringLiteral("ownerElement"), method_ownerElement, 0);
- d->attrPrototype = p;
+ d->attrPrototype.set(engine, p);
engine->v8Engine->freezeObject(p);
}
return d->attrPrototype.value();
p->setPrototype((pp = NodePrototype::getProto(v4)));
p->defineAccessorProperty(QStringLiteral("data"), NodePrototype::method_get_nodeValue, 0);
p->defineAccessorProperty(QStringLiteral("length"), method_length, 0);
- d->characterDataPrototype = p;
+ d->characterDataPrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
return d->characterDataPrototype.value();
p->setPrototype((pp = CharacterData::prototype(v4)));
p->defineAccessorProperty(QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, 0);
p->defineAccessorProperty(QStringLiteral("wholeText"), method_wholeText, 0);
- d->textPrototype = p;
+ d->textPrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
return d->textPrototype.value();
ScopedObject p(scope, v4->newObject());
ScopedObject pp(scope);
p->setPrototype((pp = Text::prototype(v4)));
- d->cdataPrototype = p;
+ d->cdataPrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
return d->cdataPrototype.value();
p->defineAccessorProperty(QStringLiteral("xmlEncoding"), method_xmlEncoding, 0);
p->defineAccessorProperty(QStringLiteral("xmlStandalone"), method_xmlStandalone, 0);
p->defineAccessorProperty(QStringLiteral("documentElement"), method_documentElement, 0);
- d->documentPrototype = p;
+ d->documentPrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
return d->documentPrototype.value();
void QQmlXMLHttpRequest::setMe(const ValueRef me)
{
- m_me = me;
+ m_me.set(v4, me);
}
void QQmlXMLHttpRequest::readyRead()
QV4::ScopedFunctionObject result(scope, QV4::Script::evaluate(m_v4Engine, QString::fromUtf8(FREEZE_SOURCE), 0));
Q_ASSERT(!!result);
- m_freezeObject = result;
+ m_freezeObject.set(scope.engine, result);
#undef FREEZE_SOURCE
}
}
p->setSetter(0);
proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
}
- modelItemProto = proto;
+ modelItemProto.set(v4, proto);
}
int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const
proto->defineAccessorProperty(QStringLiteral("index"), QQmlDelegateModelGroupChange::method_get_index, 0);
proto->defineAccessorProperty(QStringLiteral("count"), QQmlDelegateModelGroupChange::method_get_count, 0);
proto->defineAccessorProperty(QStringLiteral("moveId"), QQmlDelegateModelGroupChange::method_get_moveId, 0);
- changeProto = proto;
+ changeProto.set(v4, proto);
}
QQmlDelegateModelEngineData::~QQmlDelegateModelEngineData()
QV4::Scope scope(m_v4Engine);
QV4::ScopedContext globalContext(scope, scope.engine->rootContext());
- onmessage = QV4::Script(globalContext, QString::fromUtf8(CALL_ONMESSAGE_SCRIPT)).run(); // do not use QStringLiteral here, MSVC2012 cannot apply this cleanly to the macro
+ onmessage.set(scope.engine, QV4::Script(globalContext, QString::fromUtf8(CALL_ONMESSAGE_SCRIPT)).run()); // do not use QStringLiteral here, MSVC2012 cannot apply this cleanly to the macro
Q_ASSERT(!scope.engine->hasException);
QV4::Script createsendscript(globalContext, QString::fromUtf8(SEND_MESSAGE_CREATE_SCRIPT)); // do not use QStringLiteral here, MSVC2012 cannot apply this cleanly to the macro
QV4::ScopedFunctionObject createsendconstructor(scope, createsendscript.run());
QV4::ScopedCallData callData(scope, 1);
callData->args[0] = function;
callData->thisObject = global();
- createsend = createsendconstructor->call(callData);
+ createsend.set(scope.engine, createsendconstructor->call(callData));
}
// Requires handle and context scope
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
QV4::Scope scope(v4);
- script->object = QV4::QmlContextWrapper::urlScope(v4, script->source);
+ script->object.set(v4, QV4::QmlContextWrapper::urlScope(v4, script->source));
QV4::Scoped<QV4::QmlContextWrapper> w(scope, script->object.value());
Q_ASSERT(!!w);
p->setSetter(s);
proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
}
- prototype = proto;
+ prototype.set(v4, proto);
}
// QAbstractDynamicMetaObject
proto->defineAccessorProperty(QStringLiteral("index"), get_index, 0);
proto->defineAccessorProperty(QStringLiteral("modelData"),
QQmlDMListAccessorData::get_modelData, QQmlDMListAccessorData::set_modelData);
- listItemProto = proto;
+ listItemProto.set(v4, proto);
}
QQmlAdaptorModelEngineData::~QQmlAdaptorModelEngineData()
static int id = 0;
- d->animationCallbacks.insert(++id, QV4::PersistentValue(f));
+ d->animationCallbacks.insert(++id, QV4::PersistentValue(scope.engine, f));
if (isVisible())
polish();
if (color.isValid()) {
r->d()->context->state.fillStyle = color;
r->d()->context->buffer()->setFillStyle(color);
- r->d()->context->m_fillStyle = value;
+ r->d()->context->m_fillStyle.set(scope.engine, value);
} else {
QV4::Scoped<QQuickContext2DStyle> style(scope, value->as<QQuickContext2DStyle>());
if (style && style->d()->brush != r->d()->context->state.fillStyle) {
r->d()->context->state.fillStyle = style->d()->brush;
r->d()->context->buffer()->setFillStyle(style->d()->brush, style->d()->patternRepeatX, style->d()->patternRepeatY);
- r->d()->context->m_fillStyle = value;
+ r->d()->context->m_fillStyle.set(scope.engine, value);
r->d()->context->state.fillPatternRepeatX = style->d()->patternRepeatX;
r->d()->context->state.fillPatternRepeatY = style->d()->patternRepeatY;
}
if (color.isValid() && r->d()->context->state.fillStyle != QBrush(color)) {
r->d()->context->state.fillStyle = QBrush(color);
r->d()->context->buffer()->setFillStyle(r->d()->context->state.fillStyle);
- r->d()->context->m_fillStyle = value;
+ r->d()->context->m_fillStyle.set(scope.engine, value);
}
}
return QV4::Encode::undefined();
if (color.isValid()) {
r->d()->context->state.fillStyle = color;
r->d()->context->buffer()->setStrokeStyle(color);
- r->d()->context->m_strokeStyle = value;
+ r->d()->context->m_strokeStyle.set(scope.engine, value);
} else {
QV4::Scoped<QQuickContext2DStyle> style(scope, value->as<QQuickContext2DStyle>());
if (style && style->d()->brush != r->d()->context->state.strokeStyle) {
r->d()->context->state.strokeStyle = style->d()->brush;
r->d()->context->buffer()->setStrokeStyle(style->d()->brush, style->d()->patternRepeatX, style->d()->patternRepeatY);
- r->d()->context->m_strokeStyle = value;
+ r->d()->context->m_strokeStyle.set(scope.engine, value);
r->d()->context->state.strokePatternRepeatX = style->d()->patternRepeatX;
r->d()->context->state.strokePatternRepeatY = style->d()->patternRepeatY;
if (color.isValid() && r->d()->context->state.strokeStyle != QBrush(color)) {
r->d()->context->state.strokeStyle = QBrush(color);
r->d()->context->buffer()->setStrokeStyle(r->d()->context->state.strokeStyle);
- r->d()->context->m_strokeStyle = value;
+ r->d()->context->m_strokeStyle.set(scope.engine, value);
}
}
return QV4::Encode::undefined();
QString path =value->toQStringNoThrow();
QQuickSvgParser::parsePathDataFast(path, r->d()->context->m_path);
}
- r->d()->context->m_v4path = value;
+ r->d()->context->m_v4path.set(scope.engine, value);
return QV4::Encode::undefined();
}
d->component = comp;
if (comp) {
if (QQmlData *ddata = QQmlData::get(comp))
- d->componentStrongReference = ddata->jsWrapper.value();
+ d->componentStrongReference = ddata->jsWrapper;
}
d->loadingFromSource = false;
QUrl sourceUrl = d->resolveSourceUrl(args);
if (!ipv->isUndefined()) {
d->disposeInitialPropertyValues();
- d->initialPropertyValues = ipv.asReturnedValue();
- d->qmlGlobalForIpv = args->qmlGlobal();
+ d->initialPropertyValues.set(args->v4engine(), ipv);
+ d->qmlGlobalForIpv.set(args->v4engine(), args->qmlGlobal());
}
setSource(sourceUrl, false); // already cleared and set ipv above.
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine.data());
QV4::Scope scope(v4);
QV4::Scoped<QV4::QQuickRootItemMarker> v(scope, QV4::QQuickRootItemMarker::create(engine.data(), q));
- rootItemMarker = v;
+ rootItemMarker.set(v4, v);
}
if (QQmlDebugService::isDebuggingEnabled())
// XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
// public function which can return us a handle to something in the varProperties array.
QV4::ReturnedValue tmp = icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"));
- icoCanaryHandle = tmp;
+ icoCanaryHandle.set(QQmlEnginePrivate::getV4Engine(&engine), tmp);
tmp = ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ"));
- ccoCanaryHandle = tmp;
+ ccoCanaryHandle.set(QQmlEnginePrivate::getV4Engine(&engine), tmp);
tmp = QV4::Encode::null();
QVERIFY(!icoCanaryHandle.isUndefined());
QVERIFY(!ccoCanaryHandle.isUndefined());
QCOMPARE(childObject->property("textCanary").toInt(), 10);
QV4::WeakValue childObjectVarArrayValueHandle;
{
- childObjectVarArrayValueHandle = QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp"));
+ childObjectVarArrayValueHandle.set(QQmlEnginePrivate::getV4Engine(&engine),
+ QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
QVERIFY(!childObjectVarArrayValueHandle.isUndefined());
gc(engine);
QVERIFY(!childObjectVarArrayValueHandle.isUndefined()); // should not have been collected yet.