aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine_p.h4
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp2
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4object.cpp16
-rw-r--r--src/qml/jsruntime/qv4object_p.h16
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
-rw-r--r--src/qml/jsruntime/qv4sparsearray.cpp6
-rw-r--r--src/qml/jsruntime/qv4sparsearray_p.h7
-rw-r--r--src/qml/jsruntime/qv4string.cpp16
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp2
13 files changed, 49 insertions, 38 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 1ff64830ae..aa9b6af728 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -440,7 +440,7 @@ ReturnedValue ArrayPrototype::method_sort(SimpleCallContext *ctx)
uint len = getLength(ctx, instance.getPointer());
ScopedValue comparefn(scope, ctx->argument(0));
- instance->arraySort(ctx, instance.getPointer(), comparefn, len);
+ instance->arraySort(ctx, instance, comparefn, len);
return ctx->thisObject.asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index d85f4294ce..44188e535c 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -53,8 +53,10 @@ BooleanCtor::BooleanCtor(ExecutionContext *scope)
ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData)
{
+ Scope scope(m->engine());
bool n = callData->argc ? callData->args[0].toBoolean() : false;
- return Encode(m->engine()->newBooleanObject(Value::fromBoolean(n)));
+ ScopedValue b(scope, QV4::Value::fromBoolean(n));
+ return Encode(m->engine()->newBooleanObject(b));
}
ReturnedValue BooleanCtor::call(Managed *, CallData *callData)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 7e68f41883..8d85ffd4fc 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -399,13 +399,13 @@ Returned<Object> *ExecutionEngine::newStringObject(const Value &value)
return object->asReturned<Object>();
}
-Returned<Object> *ExecutionEngine::newNumberObject(const Value &value)
+Returned<Object> *ExecutionEngine::newNumberObject(const ValueRef value)
{
NumberObject *object = new (memoryManager) NumberObject(this, value);
return object->asReturned<Object>();
}
-Returned<Object> *ExecutionEngine::newBooleanObject(const Value &value)
+Returned<Object> *ExecutionEngine::newBooleanObject(const ValueRef value)
{
Object *object = new (memoryManager) BooleanObject(this, value);
return object->asReturned<Object>();
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 470bebf4c6..ec2c6f394d 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -274,8 +274,8 @@ struct Q_QML_EXPORT ExecutionEngine
String *newIdentifier(const QString &text);
Returned<Object> *newStringObject(const Value &value);
- Returned<Object> *newNumberObject(const Value &value);
- Returned<Object> *newBooleanObject(const Value &value);
+ Returned<Object> *newNumberObject(const ValueRef value);
+ Returned<Object> *newBooleanObject(const ValueRef value);
Returned<ArrayObject> *newArrayObject(int count = 0);
Returned<ArrayObject> *newArrayObject(const QStringList &list);
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 50e56edcbd..601b5b9e4b 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -131,7 +131,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object)
l->getter = Lookup::primitiveGetterAccessor0;
else if (l->level == 1)
l->getter = Lookup::primitiveGetterAccessor1;
- return proto->getValue(*object, p, attrs);
+ return proto->getValue(object, p, attrs);
}
}
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 75824d7ee5..8fbc2f4d11 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -58,8 +58,10 @@ NumberCtor::NumberCtor(ExecutionContext *scope)
ReturnedValue NumberCtor::construct(Managed *m, CallData *callData)
{
+ Scope scope(m->engine());
double dbl = callData->argc ? callData->args[0].toNumber() : 0.;
- return Encode(m->engine()->newNumberObject(Value::fromDouble(dbl)));
+ ScopedValue d(scope, QV4::Value::fromDouble(dbl));
+ return Encode(m->engine()->newNumberObject(d));
}
ReturnedValue NumberCtor::call(Managed *, CallData *callData)
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 77c755e413..e356b653e6 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -129,7 +129,7 @@ void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef valu
put(n, value);
}
-ReturnedValue Object::getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs)
+ReturnedValue Object::getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs)
{
if (!attrs.isAccessor())
return p->value.asReturnedValue();
@@ -139,17 +139,17 @@ ReturnedValue Object::getValue(const Value &thisObject, const Property *p, Prope
Scope scope(getter->engine());
ScopedCallData callData(scope, 0);
- callData->thisObject = thisObject;
+ callData->thisObject = *thisObject;
return getter->call(callData);
}
-void Object::putValue(Property *pd, PropertyAttributes attrs, const Value &value)
+void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef value)
{
if (attrs.isAccessor()) {
if (pd->set) {
Scope scope(pd->set->engine());
ScopedCallData callData(scope, 1);
- callData->args[0] = value;
+ callData->args[0] = *value;
callData->thisObject = Value::fromObject(this);
pd->set->call(callData);
return;
@@ -160,7 +160,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const Value &value
if (!attrs.isWritable())
goto reject;
- pd->value = value;
+ pd->value = *value;
return;
reject:
@@ -558,7 +558,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value)
}
if (idx != UINT_MAX) {
- o->putValue(o->memberData + idx, o->internalClass->propertyData[idx], *value);
+ o->putValue(o->memberData + idx, o->internalClass->propertyData[idx], value);
return;
}
}
@@ -1223,7 +1223,7 @@ void Object::arrayConcat(const ArrayObject *other)
setArrayLengthUnchecked(newLen);
}
-void Object::arraySort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint len)
+void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint len)
{
if (!arrayDataLen)
return;
@@ -1256,7 +1256,7 @@ void Object::arraySort(ExecutionContext *context, Object *thisObject, const Valu
}
}
- if (!(comparefn.isUndefined() || comparefn.asObject()))
+ if (!(comparefn->isUndefined() || comparefn->asObject()))
context->throwTypeError();
ArrayElementLessThan lessThan(context, thisObject, comparefn);
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 03cc56ac79..ad06ffb552 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -45,12 +45,12 @@
#include "qv4runtime_p.h"
#include "qv4engine_p.h"
#include "qv4context_p.h"
-#include "qv4sparsearray_p.h"
#include "qv4string_p.h"
#include "qv4managed_p.h"
#include "qv4property_p.h"
#include "qv4internalclass_p.h"
#include "qv4objectiterator_p.h"
+#include "qv4sparsearray_p.h"
#include <QtCore/QString>
#include <QtCore/QHash>
@@ -147,12 +147,14 @@ struct Q_QML_EXPORT Object: Managed {
//
void put(ExecutionContext *ctx, const QString &name, const ValueRef value);
- static ReturnedValue getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs);
+ static ReturnedValue getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs);
ReturnedValue getValue(const Property *p, PropertyAttributes attrs) const {
- return getValue(Value::fromObject(const_cast<Object *>(this)), p, attrs);
+ Scope scope(this->engine());
+ ScopedValue t(scope, Value::fromObject(const_cast<Object *>(this)));
+ return getValue(t, p, attrs);
}
- void putValue(Property *pd, PropertyAttributes attrs, const Value &value);
+ void putValue(Property *pd, PropertyAttributes attrs, const ValueRef value);
void inplaceBinOp(ExecutionContext *, BinOp op, const StringRef name, const ValueRef rhs);
void inplaceBinOpValue(ExecutionContext *ctx, BinOp op, const ValueRef index, const ValueRef rhs);
@@ -267,7 +269,7 @@ public:
SparseArrayNode *sparseArrayEnd() { return sparseArray ? sparseArray->end() : 0; }
void arrayConcat(const ArrayObject *other);
- void arraySort(ExecutionContext *context, Object *thisObject, const Value &comparefn, uint arrayDataLen);
+ void arraySort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint arrayDataLen);
ReturnedValue arrayIndexOf(Value v, uint fromIndex, uint arrayDataLen, ExecutionContext *ctx, Object *o);
void arrayReserve(uint n);
@@ -349,14 +351,14 @@ protected:
struct BooleanObject: Object {
Value value;
- BooleanObject(ExecutionEngine *engine, const Value &value): Object(engine->booleanClass), value(value) { type = Type_BooleanObject; }
+ BooleanObject(ExecutionEngine *engine, const ValueRef value): Object(engine->booleanClass), value(*value) { type = Type_BooleanObject; }
protected:
BooleanObject(InternalClass *ic): Object(ic), value(Value::fromBoolean(false)) { type = Type_BooleanObject; }
};
struct NumberObject: Object {
Value value;
- NumberObject(ExecutionEngine *engine, const Value &value): Object(engine->numberClass), value(value) { type = Type_NumberObject; }
+ NumberObject(ExecutionEngine *engine, const ValueRef value): Object(engine->numberClass), value(*value) { type = Type_NumberObject; }
protected:
NumberObject(InternalClass *ic): Object(ic), value(Value::fromInt32(0)) { type = Type_NumberObject; }
};
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 21ada92f32..687f083a80 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -619,13 +619,13 @@ Returned<Object> *__qmljs_convert_to_object(ExecutionContext *ctx, const ValueRe
case Value::Null_Type:
ctx->throwTypeError();
case Value::Boolean_Type:
- return ctx->engine->newBooleanObject(*value);
+ return ctx->engine->newBooleanObject(value);
case Value::Managed_Type:
Q_ASSERT(value->isString());
return ctx->engine->newStringObject(*value);
case Value::Integer_Type:
default: // double
- return ctx->engine->newNumberObject(*value);
+ return ctx->engine->newNumberObject(value);
}
}
diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp
index faa2f310ed..a001dc276b 100644
--- a/src/qml/jsruntime/qv4sparsearray.cpp
+++ b/src/qml/jsruntime/qv4sparsearray.cpp
@@ -55,19 +55,21 @@ using namespace QV4;
bool ArrayElementLessThan::operator()(const Property &p1, const Property &p2) const
{
+ Scope scope(m_context);
if (p1.value.isUndefined())
return false;
if (p2.value.isUndefined())
return true;
- if (Object *o = m_comparefn.asObject()) {
+ ScopedObject o(scope, m_comparefn);
+ if (o) {
Scope scope(o->engine());
ScopedValue result(scope);
ScopedCallData callData(scope, 2);
callData->thisObject = Value::undefinedValue();
callData->args[0] = p1.value;
callData->args[1] = p2.value;
- result = __qmljs_call_value(m_context, QV4::ValueRef::fromRawValue(&m_comparefn), callData);
+ result = __qmljs_call_value(m_context, m_comparefn, callData);
return result->toNumber() <= 0;
}
diff --git a/src/qml/jsruntime/qv4sparsearray_p.h b/src/qml/jsruntime/qv4sparsearray_p.h
index 384d2ef045..4746498963 100644
--- a/src/qml/jsruntime/qv4sparsearray_p.h
+++ b/src/qml/jsruntime/qv4sparsearray_p.h
@@ -45,6 +45,7 @@
#include "qv4global_p.h"
#include <QtCore/qmap.h>
#include "qv4value_p.h"
+#include "qv4scopedvalue_p.h"
#include "qv4property_p.h"
#include <assert.h>
@@ -63,15 +64,15 @@ struct SparseArray;
class ArrayElementLessThan
{
public:
- inline ArrayElementLessThan(ExecutionContext *context, Object *thisObject, const Value &comparefn)
+ inline ArrayElementLessThan(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn)
: m_context(context), thisObject(thisObject), m_comparefn(comparefn) {}
bool operator()(const Property &v1, const Property &v2) const;
private:
ExecutionContext *m_context;
- Object *thisObject;
- Value m_comparefn;
+ ObjectRef thisObject;
+ const ValueRef m_comparefn;
};
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 7995e37a6f..e70bf7d626 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -131,10 +131,10 @@ void String::destroy(Managed *that)
ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty)
{
- Scope scope(m->engine());
-
- String *that = static_cast<String *>(m);
ExecutionEngine *v4 = m->engine();
+ Scope scope(v4);
+ ScopedString that(scope, static_cast<String *>(m));
+
if (name->isEqualTo(v4->id_length)) {
if (hasProperty)
*hasProperty = true;
@@ -149,13 +149,15 @@ ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty)
}
if (hasProperty)
*hasProperty = true;
- return v4->stringClass->prototype->getValue(Value::fromString(that), pd, attrs);
+ return v4->stringClass->prototype->getValue(that, pd, attrs);
}
ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty)
{
- String *that = static_cast<String *>(m);
- ExecutionEngine *engine = that->engine();
+ ExecutionEngine *engine = m->engine();
+ Scope scope(engine);
+ ScopedString that(scope, static_cast<String *>(m));
+
if (index < that->_text.length()) {
if (hasProperty)
*hasProperty = true;
@@ -170,7 +172,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty)
}
if (hasProperty)
*hasProperty = true;
- return engine->stringClass->prototype->getValue(Value::fromString(that), pd, attrs);
+ return engine->stringClass->prototype->getValue(that, pd, attrs);
}
void String::put(Managed *m, const StringRef name, const ValueRef value)
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index e1c75f2f26..425c19a090 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -295,7 +295,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
PropertyAttributes attrs;
Property *pd = wrapper->__getOwnProperty__(name, &attrs);
if (pd) {
- wrapper->putValue(pd, attrs, *value);
+ wrapper->putValue(pd, attrs, value);
return;
}