Remove the context argument from Managed::delete(Indexed)Property
authorLars Knoll <lars.knoll@digia.com>
Fri, 21 Jun 2013 18:33:39 +0000 (20:33 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 21 Jun 2013 20:21:39 +0000 (22:21 +0200)
It's not required, as we can always get the current context from
the Managed object for the cases we need it.

Change-Id: I29fb9861a73ece1b3d5aa45f3bc350d8a5f76fa9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
14 files changed:
src/qml/qml/v4/qv4arrayobject.cpp
src/qml/qml/v4/qv4context.cpp
src/qml/qml/v4/qv4managed_p.h
src/qml/qml/v4/qv4object.cpp
src/qml/qml/v4/qv4object_p.h
src/qml/qml/v4/qv4regexp.cpp
src/qml/qml/v4/qv4regexp_p.h
src/qml/qml/v4/qv4runtime.cpp
src/qml/qml/v4/qv4sequenceobject.cpp
src/qml/qml/v4/qv4string.cpp
src/qml/qml/v4/qv4string_p.h
src/qml/qml/v4/qv4stringobject.cpp
src/qml/qml/v4/qv4stringobject_p.h
src/qml/qml/v8/qjsvalue.cpp

index b1226a3..5ab8dc8 100644 (file)
@@ -234,7 +234,7 @@ Value ArrayPrototype::method_pop(SimpleCallContext *ctx)
 
     Value result = instance->getIndexed(ctx, len - 1);
 
-    instance->deleteIndexedProperty(ctx, len - 1);
+    instance->deleteIndexedProperty(len - 1);
     if (instance->isArrayObject())
         instance->setArrayLengthUnchecked(len - 1);
     else
@@ -315,11 +315,11 @@ Value ArrayPrototype::method_reverse(SimpleCallContext *ctx)
         if (hiExists)
             instance->putIndexed(ctx, lo, hval);
         else
-            instance->deleteIndexedProperty(ctx, lo);
+            instance->deleteIndexedProperty(lo);
         if (loExists)
             instance->putIndexed(ctx, hi, lval);
         else
-            instance->deleteIndexedProperty(ctx, hi);
+            instance->deleteIndexedProperty(hi);
     }
     return Value::fromObject(instance);
 }
@@ -370,9 +370,9 @@ Value ArrayPrototype::method_shift(SimpleCallContext *ctx)
             if (exists)
                 instance->putIndexed(ctx, k - 1, v);
             else
-                instance->deleteIndexedProperty(ctx, k - 1);
+                instance->deleteIndexedProperty(k - 1);
         }
-        instance->deleteIndexedProperty(ctx, len - 1);
+        instance->deleteIndexedProperty(len - 1);
     }
 
     if (instance->isArrayObject())
@@ -464,10 +464,10 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx)
             if (exists)
                 instance->putIndexed(k + itemCount, v);
             else
-                instance->deleteIndexedProperty(ctx, k + itemCount);
+                instance->deleteIndexedProperty(k + itemCount);
         }
         for (uint k = len; k > len - deleteCount + itemCount; --k)
-            instance->deleteIndexedProperty(ctx, k - 1);
+            instance->deleteIndexedProperty(k - 1);
     } else if (itemCount > deleteCount) {
         uint k = len - deleteCount;
         while (k > start) {
@@ -476,7 +476,7 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx)
             if (exists)
                 instance->putIndexed(k + itemCount - 1, v);
             else
-                instance->deleteIndexedProperty(ctx, k + itemCount - 1);
+                instance->deleteIndexedProperty(k + itemCount - 1);
             --k;
         }
     }
@@ -529,7 +529,7 @@ Value ArrayPrototype::method_unshift(SimpleCallContext *ctx)
             if (exists)
                 instance->putIndexed(ctx, k + ctx->argumentCount - 1, v);
             else
-                instance->deleteIndexedProperty(ctx, k + ctx->argumentCount - 1);
+                instance->deleteIndexedProperty(k + ctx->argumentCount - 1);
         }
         for (uint i = 0; i < ctx->argumentCount; ++i)
             instance->putIndexed(ctx, i, ctx->argument(i));
index ad8e071..5d4d941 100644 (file)
@@ -235,7 +235,7 @@ bool ExecutionContext::deleteProperty(String *name)
             hasWith = true;
             WithContext *w = static_cast<WithContext *>(ctx);
             if (w->withObject->__hasProperty__(name))
-                return w->withObject->deleteProperty(this, name);
+                return w->withObject->deleteProperty(name);
         } else if (ctx->type == Type_CatchContext) {
             CatchContext *c = static_cast<CatchContext *>(ctx);
             if (c->exceptionVarName->isEqualTo(name))
@@ -252,11 +252,11 @@ bool ExecutionContext::deleteProperty(String *name)
                         return false;
             }
             if (c->activation && c->activation->__hasProperty__(name))
-                return c->activation->deleteProperty(this, name);
+                return c->activation->deleteProperty(name);
         } else if (ctx->type == Type_GlobalContext) {
             GlobalContext *g = static_cast<GlobalContext *>(ctx);
             if (g->global->__hasProperty__(name))
-                return g->global->deleteProperty(this, name);
+                return g->global->deleteProperty(name);
         }
     }
 
index f3acdad..74efc76 100644 (file)
@@ -111,8 +111,8 @@ struct ManagedVTable
     void (*putIndexed)(Managed *, ExecutionContext *ctx, uint index, const Value &value);
     PropertyAttributes (*query)(const Managed *, String *name);
     PropertyAttributes (*queryIndexed)(const Managed *, uint index);
-    bool (*deleteProperty)(Managed *m, ExecutionContext *ctx, String *name);
-    bool (*deleteIndexedProperty)(Managed *m, ExecutionContext *ctx, uint index);
+    bool (*deleteProperty)(Managed *m, String *name);
+    bool (*deleteIndexedProperty)(Managed *m, uint index);
     void (*getLookup)(Managed *m, ExecutionContext *ctx, Lookup *l, Value *result);
     void (*setLookup)(Managed *m, ExecutionContext *ctx, Lookup *l, const Value &v);
     bool (*isEqualTo)(Managed *m, Managed *other);
@@ -273,10 +273,10 @@ public:
     PropertyAttributes queryIndexed(uint index) const
     { return vtbl->queryIndexed(this, index); }
 
-    bool deleteProperty(ExecutionContext *ctx, String *name)
-    { return vtbl->deleteProperty(this, ctx, name); }
-    bool deleteIndexedProperty(ExecutionContext *ctx, uint index)
-    { return vtbl->deleteIndexedProperty(this, ctx, index); }
+    bool deleteProperty(String *name)
+    { return vtbl->deleteProperty(this, name); }
+    bool deleteIndexedProperty(uint index)
+    { return vtbl->deleteIndexedProperty(this, index); }
     void getLookup(ExecutionContext *ctx, Lookup *l, Value *result)
     { vtbl->getLookup(this, ctx, l, result); }
     void setLookup(ExecutionContext *ctx, Lookup *l, const Value &v)
index 5bb556b..e9c5505 100644 (file)
@@ -451,14 +451,14 @@ PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
     return Attr_Invalid;
 }
 
-bool Object::deleteProperty(Managed *m, ExecutionContext *ctx, String *name)
+bool Object::deleteProperty(Managed *m, String *name)
 {
-    return static_cast<Object *>(m)->internalDeleteProperty(ctx, name);
+    return static_cast<Object *>(m)->internalDeleteProperty(name);
 }
 
-bool Object::deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index)
+bool Object::deleteIndexedProperty(Managed *m, uint index)
 {
-    return static_cast<Object *>(m)->internalDeleteIndexedProperty(ctx, index);
+    return static_cast<Object *>(m)->internalDeleteIndexedProperty(index);
 }
 
 void Object::getLookup(Managed *m, ExecutionContext *ctx, Lookup *l, Value *result)
@@ -796,13 +796,13 @@ void Object::internalPutIndexed(ExecutionContext *ctx, uint index, const Value &
 }
 
 // Section 8.12.7
-bool Object::internalDeleteProperty(ExecutionContext *ctx, String *name)
+bool Object::internalDeleteProperty(String *name)
 {
     uint idx = name->asArrayIndex();
     if (idx != UINT_MAX)
-        return deleteIndexedProperty(ctx, idx);
+        return deleteIndexedProperty(idx);
 
-    name->makeIdentifier(ctx);
+    name->makeIdentifier(engine()->current);
 
     uint memberIdx = internalClass->find(name);
     if (memberIdx != UINT_MAX) {
@@ -811,15 +811,15 @@ bool Object::internalDeleteProperty(ExecutionContext *ctx, String *name)
             memmove(memberData + memberIdx, memberData + memberIdx + 1, (internalClass->size - memberIdx)*sizeof(Property));
             return true;
         }
-        if (ctx->strictMode)
-            ctx->throwTypeError();
+        if (engine()->current->strictMode)
+            engine()->current->throwTypeError();
         return false;
     }
 
     return true;
 }
 
-bool Object::internalDeleteIndexedProperty(ExecutionContext *ctx, uint index)
+bool Object::internalDeleteIndexedProperty(uint index)
 {
     uint pidx = propertyIndexFromArrayIndex(index);
     if (pidx == UINT_MAX)
@@ -839,8 +839,8 @@ bool Object::internalDeleteIndexedProperty(ExecutionContext *ctx, uint index)
         return true;
     }
 
-    if (ctx->strictMode)
-        ctx->throwTypeError();
+    if (engine()->current->strictMode)
+        engine()->current->throwTypeError();
     return false;
 }
 
index 85faf8f..4a36a3c 100644 (file)
@@ -356,8 +356,8 @@ protected:
     static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
     static PropertyAttributes query(const Managed *m, String *name);
     static PropertyAttributes queryIndexed(const Managed *m, uint index);
-    static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
-    static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
+    static bool deleteProperty(Managed *m, String *name);
+    static bool deleteIndexedProperty(Managed *m, uint index);
     static void getLookup(Managed *m, ExecutionContext *ctx, Lookup *l, Value *result);
     static void setLookup(Managed *m, ExecutionContext *ctx, Lookup *l, const Value &v);
     static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes);
@@ -368,8 +368,8 @@ private:
     Value internalGetIndexed(ExecutionContext *ctx, uint index, bool *hasProperty);
     void internalPut(ExecutionContext *ctx, String *name, const Value &value);
     void internalPutIndexed(ExecutionContext *ctx, uint index, const Value &value);
-    bool internalDeleteProperty(ExecutionContext *ctx, String *name);
-    bool internalDeleteIndexedProperty(ExecutionContext *ctx, uint index);
+    bool internalDeleteProperty(String *name);
+    bool internalDeleteIndexedProperty(uint index);
 
     friend struct ObjectIterator;
     friend struct ObjectPrototype;
index aa20751..a698976 100644 (file)
@@ -164,12 +164,12 @@ PropertyAttributes RegExp::queryIndexed(const Managed *m, uint index)
     return Attr_Invalid;
 }
 
-bool RegExp::deleteProperty(Managed *m, ExecutionContext *ctx, String *name)
+bool RegExp::deleteProperty(Managed *, String *)
 {
     return false;
 }
 
-bool RegExp::deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index)
+bool RegExp::deleteIndexedProperty(Managed *m, uint index)
 {
     return false;
 }
index 4fb075e..9b9bd51 100644 (file)
@@ -117,8 +117,8 @@ protected:
     static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
     static PropertyAttributes query(const Managed *m, String *name);
     static PropertyAttributes queryIndexed(const Managed *m, uint index);
-    static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
-    static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
+    static bool deleteProperty(Managed *, String *);
+    static bool deleteIndexedProperty(Managed *m, uint index);
     static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes);
 
 private:
index 7aa4ad7..f3cbd89 100644 (file)
@@ -159,7 +159,7 @@ void __qmljs_delete_subscript(ExecutionContext *ctx, Value *result, const Value
     if (Object *o = base.asObject()) {
         uint n = index.asArrayIndex();
         if (n < UINT_MAX) {
-            Value res = Value::fromBoolean(o->deleteIndexedProperty(ctx, n));
+            Value res = Value::fromBoolean(o->deleteIndexedProperty(n));
             if (result)
                 *result = res;
             return;
@@ -173,7 +173,7 @@ void __qmljs_delete_subscript(ExecutionContext *ctx, Value *result, const Value
 void __qmljs_delete_member(ExecutionContext *ctx, Value *result, const Value &base, String *name)
 {
     Object *obj = base.toObject(ctx);
-    Value res = Value::fromBoolean(obj->deleteProperty(ctx, name));
+    Value res = Value::fromBoolean(obj->deleteProperty(name));
     if (result)
         *result = res;
 }
index 40f0c30..ef4b5c0 100644 (file)
@@ -298,7 +298,7 @@ public:
         return QV4::Object::advanceIterator(this, it, name, index, attrs);
     }
 
-    bool containerDeleteIndexedProperty(QV4::ExecutionContext *ctx, uint index)
+    bool containerDeleteIndexedProperty(uint index)
     {
         /* Qt containers have int (rather than uint) allowable indexes. */
         if (index > INT_MAX)
@@ -490,8 +490,8 @@ private:
     { static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(ctx, index, value); }
     static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index)
     { return static_cast<const QQmlSequence<Container> *>(that)->containerQueryIndexed(index); }
-    static bool deleteIndexedProperty(QV4::Managed *that, QV4::ExecutionContext *ctx, uint index)
-    { return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(ctx, index); }
+    static bool deleteIndexedProperty(QV4::Managed *that, uint index)
+    { return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index); }
     static bool isEqualTo(Managed *that, Managed *other)
     { return static_cast<QQmlSequence<Container> *>(that)->containerIsEqualTo(other); }
     static Property *advanceIterator(Managed *that, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs)
index 3853371..bf68f5e 100644 (file)
@@ -170,12 +170,12 @@ PropertyAttributes String::queryIndexed(const Managed *m, uint index)
     return (index < that->_text.length()) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid;
 }
 
-bool String::deleteProperty(Managed *m, ExecutionContext *ctx, String *name)
+bool String::deleteProperty(Managed *, String *)
 {
     return false;
 }
 
-bool String::deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index)
+bool String::deleteIndexedProperty(Managed *m, uint index)
 {
     return false;
 }
index 1df4a97..95f6b40 100644 (file)
@@ -126,8 +126,8 @@ protected:
     static void putIndexed(Managed *m, ExecutionContext *ctx, uint index, const Value &value);
     static PropertyAttributes query(const Managed *m, String *name);
     static PropertyAttributes queryIndexed(const Managed *m, uint index);
-    static bool deleteProperty(Managed *m, ExecutionContext *ctx, String *name);
-    static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
+    static bool deleteProperty(Managed *, String *);
+    static bool deleteIndexedProperty(Managed *m, uint index);
 
     static const ManagedVTable static_vtbl;
 };
index 0dbd052..0596ea6 100644 (file)
@@ -99,15 +99,15 @@ Property *StringObject::getIndex(uint index) const
     return &tmpProperty;
 }
 
-bool StringObject::deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index)
+bool StringObject::deleteIndexedProperty(Managed *m, uint index)
 {
     StringObject *o = m->asStringObject();
     if (!o)
-        ctx->throwTypeError();
+        m->engine()->current->throwTypeError();
 
     if (index < o->value.stringValue()->toQString().length()) {
-        if (ctx->strictMode)
-            ctx->throwTypeError();
+        if (m->engine()->current->strictMode)
+            m->engine()->current->throwTypeError();
         return false;
     }
     return true;
index a4786d8..442cfa0 100644 (file)
@@ -58,7 +58,7 @@ struct StringObject: Object {
 
     Property *getIndex(uint index) const;
 
-    static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index);
+    static bool deleteIndexedProperty(Managed *m, uint index);
 
 protected:
     static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs);
index f3563a7..9b92019 100644 (file)
@@ -937,7 +937,7 @@ bool QJSValue::deleteProperty(const QString &name)
 
     ExecutionEngine *engine = d->engine;
     String *s = engine->newString(name);
-    return o->deleteProperty(engine->current, s);
+    return o->deleteProperty(s);
 }
 
 /*!