aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-27 17:04:42 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-30 08:05:51 +0200
commitc0ec918787068fcf269925b13a34115ff77c3126 (patch)
tree9e1a511baf5f7e1ff53a102294b28a839d2f10f5
parente57c2c8a0adef8949f69195573d149237814bed1 (diff)
Remove some uses of raw Object pointers
Change-Id: I7c715f33d197ebbf6f0c00040099b27ed7221d42 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/imports/localstorage/plugin.cpp8
-rw-r--r--src/qml/jsapi/qjsvalue.cpp12
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp26
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp40
-rw-r--r--src/qml/jsruntime/qv4arrayobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4context.cpp30
-rw-r--r--src/qml/jsruntime/qv4context_p.h10
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp13
-rw-r--r--src/qml/jsruntime/qv4script.cpp8
-rw-r--r--src/qml/jsruntime/qv4script_p.h4
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp4
12 files changed, 82 insertions, 79 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 0060613e93..267b2b6395 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -268,13 +268,15 @@ static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx)
if (query.prepare(sql)) {
if (ctx->callData->argc > 1) {
ScopedValue values(scope, ctx->callData->args[1]);
- if (ArrayObject *array = values->asArrayObject()) {
+ if (values->asArrayObject()) {
+ ScopedArrayObject array(scope, values);
quint32 size = array->arrayLength();
QV4::ScopedValue v(scope);
for (quint32 ii = 0; ii < size; ++ii)
query.bindValue(ii, engine->toVariant((v = array->getIndexed(ii)), -1));
- } else if (Object *object = values->asObject()) {
- ObjectIterator it(object, ObjectIterator::WithProtoChain|ObjectIterator::EnumerableOnly);
+ } else if (values->asObject()) {
+ ScopedObject object(scope, values);
+ ObjectIterator it(object.getPointer(), ObjectIterator::WithProtoChain|ObjectIterator::EnumerableOnly);
ScopedValue key(scope);
while (1) {
Value value;
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 5805b6a78f..8bcdccc507 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -690,7 +690,11 @@ QJSValue QJSValue::prototype() const
*/
void QJSValue::setPrototype(const QJSValue& prototype)
{
- Object *o = d->value.asObject();
+ ExecutionEngine *v4 = d->engine;
+ if (!v4)
+ return;
+ Scope scope(v4);
+ ScopedObject o(scope, d->value);
if (!o)
return;
if (prototype.d->value.isNull()) {
@@ -698,14 +702,14 @@ void QJSValue::setPrototype(const QJSValue& prototype)
return;
}
- Object *p = prototype.d->value.asObject();
+ ScopedObject p(scope, prototype.d->value);
if (!p)
return;
if (o->engine() != p->engine()) {
qWarning("QJSValue::setPrototype() failed: cannot set a prototype created in a different engine");
return;
}
- if (!o->setPrototype(p))
+ if (!o->setPrototype(p.getPointer()))
qWarning("QJSValue::setPrototype() failed: cyclic prototype value");
}
@@ -841,7 +845,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
return QJSValue();
QV4::Scope scope(engine);
- Object *o = d->value.asObject();
+ ScopedObject o(scope, d->value);
if (!o)
return QJSValue();
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index cf72cdef68..70adb1f152 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -147,15 +147,14 @@ DEFINE_MANAGED_VTABLE(ArgumentsGetterFunction);
ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData)
{
- ArgumentsGetterFunction *g = static_cast<ArgumentsGetterFunction *>(getter);
- Object *that = callData->thisObject.asObject();
- if (!that)
- getter->engine()->current->throwTypeError();
- ArgumentsObject *o = that->asArgumentsObject();
+ ExecutionEngine *v4 = getter->engine();
+ Scope scope(v4);
+ Scoped<ArgumentsGetterFunction> g(scope, static_cast<ArgumentsGetterFunction *>(getter));
+ Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
if (!o)
- getter->engine()->current->throwTypeError();
+ v4->current->throwTypeError();
- assert(g->index < o->context->callData->argc);
+ Q_ASSERT(g->index < o->context->callData->argc);
return o->context->argument(g->index);
}
@@ -163,15 +162,14 @@ DEFINE_MANAGED_VTABLE(ArgumentsSetterFunction);
ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData)
{
- ArgumentsSetterFunction *s = static_cast<ArgumentsSetterFunction *>(setter);
- Object *that = callData->thisObject.asObject();
- if (!that)
- setter->engine()->current->throwTypeError();
- ArgumentsObject *o = that->asArgumentsObject();
+ ExecutionEngine *v4 = setter->engine();
+ Scope scope(v4);
+ Scoped<ArgumentsSetterFunction> s(scope, static_cast<ArgumentsSetterFunction *>(setter));
+ Scoped<ArgumentsObject> o(scope, callData->thisObject.as<ArgumentsObject>());
if (!o)
- setter->engine()->current->throwTypeError();
+ v4->current->throwTypeError();
- assert(s->index < o->context->callData->argc);
+ Q_ASSERT(s->index < o->context->callData->argc);
o->context->callData->args[s->index] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined();
return Encode::undefined();
}
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 3ad3ec6f32..8687ca48ce 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -122,7 +122,7 @@ void ArrayPrototype::init(ExecutionEngine *engine, ObjectRef ctor)
defineDefaultProperty(QStringLiteral("reduceRight"), method_reduceRight, 1);
}
-uint ArrayPrototype::getLength(ExecutionContext *ctx, Object *o)
+uint ArrayPrototype::getLength(ExecutionContext *ctx, ObjectRef o)
{
if (o->isArrayObject())
return o->arrayLength();
@@ -159,7 +159,7 @@ ReturnedValue ArrayPrototype::method_toLocaleString(SimpleCallContext *ctx)
ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx)
{
Scope scope(ctx);
- Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject());
+ ScopedObject result(scope, ctx->engine->newArrayObject());
ScopedObject thisObject(scope, ctx->callData->thisObject.toObject(ctx));
ScopedArrayObject instance(scope, thisObject);
@@ -175,7 +175,7 @@ ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx)
if (elt)
result->arrayConcat(elt.getPointer());
else
- result->arraySet(getLength(ctx, result.getPointer()), ctx->callData->args[i]);
+ result->arraySet(getLength(ctx, result), ctx->callData->args[i]);
}
return result.asReturnedValue();
@@ -240,7 +240,7 @@ ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
if (!len) {
if (!instance->isArrayObject())
@@ -262,7 +262,7 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
if (len + ctx->callData->argc < len) {
// ughh...
@@ -314,7 +314,7 @@ ReturnedValue ArrayPrototype::method_reverse(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint length = getLength(ctx, instance.getPointer());
+ uint length = getLength(ctx, instance);
int lo = 0, hi = length - 1;
@@ -340,7 +340,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
if (!len) {
if (!instance->isArrayObject())
@@ -396,7 +396,7 @@ ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx)
ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx));
Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject());
- uint len = getLength(ctx, o.getPointer());
+ uint len = getLength(ctx, o);
double s = ScopedValue(scope, ctx->argument(0))->toInteger();
uint start;
if (s < 0)
@@ -434,7 +434,7 @@ ReturnedValue ArrayPrototype::method_sort(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
ScopedValue comparefn(scope, ctx->argument(0));
instance->arraySort(ctx, instance, comparefn, len);
@@ -445,7 +445,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<ArrayObject> newArray(scope, ctx->engine->newArrayObject());
@@ -505,7 +505,7 @@ ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx)
{
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
ScopedValue v(scope);
if (!instance->protoHasArray() && instance->arrayDataLen <= len) {
@@ -556,7 +556,7 @@ ReturnedValue ArrayPrototype::method_indexOf(SimpleCallContext *ctx)
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
if (!len)
return Encode(-1);
@@ -596,7 +596,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx)
Scope scope(ctx);
ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
if (!len)
return Encode(-1);
@@ -636,7 +636,7 @@ ReturnedValue ArrayPrototype::method_every(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -668,7 +668,7 @@ ReturnedValue ArrayPrototype::method_some(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -700,7 +700,7 @@ ReturnedValue ArrayPrototype::method_forEach(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -729,7 +729,7 @@ ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -764,7 +764,7 @@ ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -803,7 +803,7 @@ ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
@@ -851,7 +851,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(SimpleCallContext *ctx)
Scope scope(ctx);
Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
- uint len = getLength(ctx, instance.getPointer());
+ uint len = getLength(ctx, instance);
Scoped<FunctionObject> callback(scope, ctx->argument(0));
if (!callback)
diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h
index 121e0dd344..933939e279 100644
--- a/src/qml/jsruntime/qv4arrayobject_p.h
+++ b/src/qml/jsruntime/qv4arrayobject_p.h
@@ -64,7 +64,7 @@ struct ArrayPrototype: ArrayObject
void init(ExecutionEngine *engine, ObjectRef ctor);
- static uint getLength(ExecutionContext *ctx, Object *o);
+ static uint getLength(ExecutionContext *ctx, ObjectRef o);
static ReturnedValue method_isArray(SimpleCallContext *ctx);
static ReturnedValue method_toString(SimpleCallContext *ctx);
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index ff17754b8b..f229ad6742 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -135,7 +135,7 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData
return c;
}
-WithContext *ExecutionContext::newWithContext(Object *with)
+WithContext *ExecutionContext::newWithContext(ObjectRef with)
{
WithContext *w = static_cast<WithContext *>(engine->memoryManager->allocContext(sizeof(WithContext)));
engine->current = w;
@@ -151,7 +151,7 @@ CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const
return c;
}
-CallContext *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml)
+CallContext *ExecutionContext::newQmlContext(FunctionObject *f, ObjectRef qml)
{
CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocContext(requiredMemoryForExecutionContect(f, 0)));
@@ -168,7 +168,7 @@ void ExecutionContext::createMutableBinding(const StringRef name, bool deletable
Scope scope(this);
// find the right context to create the binding on
- Object *activation = engine->globalObject;
+ ScopedObject activation(scope, engine->globalObject);
ExecutionContext *ctx = this;
while (ctx) {
if (ctx->type >= Type_CallContext) {
@@ -220,7 +220,7 @@ void GlobalContext::initGlobalContext(ExecutionEngine *eng)
global = 0;
}
-void WithContext::initWithContext(ExecutionContext *p, Object *with)
+void WithContext::initWithContext(ExecutionContext *p, ObjectRef with)
{
initBaseContext(Type_WithContext, p->engine, p);
callData = p->callData;
@@ -228,7 +228,7 @@ void WithContext::initWithContext(ExecutionContext *p, Object *with)
lookups = p->lookups;
compilationUnit = p->compilationUnit;
- withObject = with;
+ withObject = with.getPointer();
}
void CatchContext::initCatchContext(ExecutionContext *p, String *exceptionVarName, const Value &exceptionValue)
@@ -244,7 +244,7 @@ void CatchContext::initCatchContext(ExecutionContext *p, String *exceptionVarNam
this->exceptionValue = exceptionValue;
}
-void CallContext::initQmlContext(ExecutionContext *parentContext, Object *qml, FunctionObject *function)
+void CallContext::initQmlContext(ExecutionContext *parentContext, ObjectRef qml, FunctionObject *function)
{
initBaseContext(Type_QmlContext, parentContext->engine, parentContext);
@@ -261,7 +261,7 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, Object *qml, F
assert(outer->next != (ExecutionContext *)0x1);
#endif
- activation = qml;
+ activation = qml.getPointer();
if (function->function) {
compilationUnit = function->function->compilationUnit;
@@ -357,7 +357,7 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
Scope scope(this);
for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
if (ctx->type == Type_WithContext) {
- Object *w = static_cast<WithContext *>(ctx)->withObject;
+ ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
if (w->__hasProperty__(name)) {
w->put(name, value);
return;
@@ -366,7 +366,7 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
static_cast<CatchContext *>(ctx)->exceptionValue = *value;
return;
} else {
- Object *activation = 0;
+ ScopedObject activation(scope, (Object *)0);
if (ctx->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
for (unsigned int i = 0; i < c->function->varCount; ++i)
@@ -410,7 +410,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name)
bool hasCatchScope = false;
for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
if (ctx->type == Type_WithContext) {
- Object *w = static_cast<WithContext *>(ctx)->withObject;
+ ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
hasWith = true;
bool hasProperty = false;
v = w->get(name, &hasProperty);
@@ -475,7 +475,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name)
bool hasCatchScope = false;
for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
if (ctx->type == Type_WithContext) {
- Object *w = static_cast<WithContext *>(ctx)->withObject;
+ ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
hasWith = true;
bool hasProperty = false;
v = w->get(name, &hasProperty);
@@ -525,11 +525,11 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name)
return Encode::undefined();
}
-ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object **base)
+ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectRef base)
{
Scope scope(this);
ScopedValue v(scope);
- *base = 0;
+ base = (Object *)0;
name->makeIdentifier();
if (name->isEqualTo(engine->id_this))
@@ -544,7 +544,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object
bool hasProperty = false;
v = w->get(name, &hasProperty);
if (hasProperty) {
- *base = w;
+ base = w;
return v.asReturnedValue();
}
continue;
@@ -573,7 +573,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object
v = c->activation->get(name, &hasProperty);
if (hasProperty) {
if (ctx->type == Type_QmlContext)
- *base = c->activation;
+ base = c->activation;
return v.asReturnedValue();
}
}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index f8d5620ec6..7f9ef77b40 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -114,9 +114,9 @@ struct Q_QML_EXPORT ExecutionContext
CallContext *newCallContext(void *stackSpace, Value *locals, FunctionObject *f, CallData *callData);
CallContext *newCallContext(FunctionObject *f, CallData *callData);
- WithContext *newWithContext(Object *with);
+ WithContext *newWithContext(ObjectRef with);
CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue);
- CallContext *newQmlContext(FunctionObject *f, Object *qml);
+ CallContext *newQmlContext(FunctionObject *f, ObjectRef qml);
String * const *formals() const;
unsigned int formalCount() const;
@@ -140,7 +140,7 @@ struct Q_QML_EXPORT ExecutionContext
void setProperty(const StringRef name, const ValueRef value);
ReturnedValue getProperty(const StringRef name);
ReturnedValue getPropertyNoThrow(const StringRef name);
- ReturnedValue getPropertyAndBase(const StringRef name, Object **base);
+ ReturnedValue getPropertyAndBase(const StringRef name, ObjectRef base);
bool deleteProperty(const StringRef name);
void mark();
@@ -160,7 +160,7 @@ struct SimpleCallContext : public ExecutionContext
struct CallContext : public SimpleCallContext
{
- void initQmlContext(ExecutionContext *parentContext, Object *qml, QV4::FunctionObject *function);
+ void initQmlContext(ExecutionContext *parentContext, ObjectRef qml, QV4::FunctionObject *function);
bool needsOwnArguments() const;
Value *locals;
@@ -186,7 +186,7 @@ struct WithContext : public ExecutionContext
{
Object *withObject;
- void initWithContext(ExecutionContext *p, Object *with);
+ void initWithContext(ExecutionContext *p, ObjectRef with);
};
inline CallContext *ExecutionContext::asCallContext()
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index e17b1d7585..59b23bebbf 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -328,7 +328,7 @@ ReturnedValue FunctionPrototype::method_apply(SimpleCallContext *ctx)
ScopedValue arg(scope, ctx->argument(1));
- Scoped<Object> arr(scope, arg);
+ ScopedObject arr(scope, arg);
quint32 len;
if (!arr) {
@@ -338,7 +338,7 @@ ReturnedValue FunctionPrototype::method_apply(SimpleCallContext *ctx)
return Encode::undefined();
}
} else {
- len = ArrayPrototype::getLength(ctx, arr.getPointer());
+ len = ArrayPrototype::getLength(ctx, arr);
}
ScopedCallData callData(scope, len);
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index dabd9ad84b..09fe578c19 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -959,18 +959,16 @@ ReturnedValue __qmljs_call_activation_property(ExecutionContext *context, const
Q_ASSERT(callData->thisObject.isUndefined());
Scope scope(context);
- Object *base;
- ScopedValue func(scope, context->getPropertyAndBase(name, &base));
+ ScopedObject base(scope);
+ ScopedValue func(scope, context->getPropertyAndBase(name, base));
if (base)
callData->thisObject = base;
FunctionObject *o = func->asFunctionObject();
if (!o) {
QString objectAsString = QStringLiteral("[null]");
- if (base) {
- ScopedValue b(scope, base);
- objectAsString = b->toQStringNoThrow();
- }
+ if (base)
+ objectAsString = ScopedValue(scope, base.asReturnedValue())->toQStringNoThrow();
QString msg = QStringLiteral("Property '%1' of object %2 is not a function").arg(name->toQString()).arg(objectAsString);
context->throwTypeError(msg);
}
@@ -1148,7 +1146,8 @@ QV4::ReturnedValue __qmljs_builtin_typeof_element(ExecutionContext *context, con
ExecutionContext *__qmljs_builtin_push_with_scope(const ValueRef o, ExecutionContext *ctx)
{
- Object *obj = o->toObject(ctx);
+ Scope scope(ctx);
+ ScopedObject obj(scope, o->toObject(ctx));
return ctx->newWithContext(obj);
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index d2963dff8c..c2d35d5926 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -60,7 +60,7 @@
using namespace QV4;
-QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Object *qml)
+QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml)
: FunctionObject(scope, scope->engine->id_eval)
, qml(qml)
{
@@ -75,7 +75,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec
scope->engine->popContext();
}
-QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Object *qml)
+QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml)
: FunctionObject(scope, scope->engine->id_eval)
, qml(qml)
{
@@ -250,7 +250,7 @@ ReturnedValue Script::run()
} else {
ScopedObject qmlObj(valueScope, qml.value());
- FunctionObject *f = new (engine->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj.getPointer());
+ FunctionObject *f = new (engine->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj);
ScopedCallData callData(valueScope, 0);
callData->thisObject = Primitive::undefinedValue();
return f->call(callData);
@@ -271,7 +271,7 @@ ReturnedValue Script::qmlBinding()
ExecutionEngine *v4 = scope->engine;
Scope valueScope(v4);
ScopedObject qmlObj(valueScope, qml.value());
- ScopedObject v(valueScope, new (v4->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj.getPointer()));
+ ScopedObject v(valueScope, new (v4->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj));
return v.asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 030622cf72..5442e265fd 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -54,9 +54,9 @@ struct ExecutionContext;
struct QmlBindingWrapper : FunctionObject {
Q_MANAGED
- QmlBindingWrapper(ExecutionContext *scope, Function *f, Object *qml);
+ QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml);
// Constructor for QML functions and signal handlers, resulting binding wrapper is not callable!
- QmlBindingWrapper(ExecutionContext *scope, Object *qml);
+ QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml);
static ReturnedValue call(Managed *that, CallData *);
static void markObjects(Managed *m);
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 65fc2a40d5..5d29a57441 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -1373,8 +1373,8 @@ bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope valueScope(v4);
- QV4::ScopedValue scopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _qobjectForBindings));
- QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, scopeObject->asObject()));
+ QV4::ScopedObject scopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _qobjectForBindings));
+ QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, scopeObject));
QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context();
qSwap(_qmlContext, qmlContext);