Remove context argument from Object::get/putValue
authorLars Knoll <lars.knoll@digia.com>
Fri, 21 Jun 2013 22:52:47 +0000 (00:52 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Sat, 22 Jun 2013 20:02:54 +0000 (22:02 +0200)
Change-Id: I981b95e30b7761574ddd7891b5dfc24a0136af7f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/v4/qv4arrayobject.cpp
src/qml/qml/v4/qv4debugging.cpp
src/qml/qml/v4/qv4lookup.cpp
src/qml/qml/v4/qv4object.cpp
src/qml/qml/v4/qv4object_p.h
src/qml/qml/v4/qv4objectiterator.cpp
src/qml/qml/v4/qv4objectproto.cpp
src/qml/qml/v4/qv4runtime.cpp
src/qml/qml/v4/qv4string.cpp
src/qml/qml/v8/qjsvalueiterator.cpp

index bae2e03..9ceb460 100644 (file)
@@ -283,7 +283,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
     PropertyAttributes attrs;
     Property *pd  = wrapper->__getOwnProperty__(name, &attrs);
     if (pd) {
-        wrapper->putValue(v4->current, pd, attrs, value);
+        wrapper->putValue(pd, attrs, value);
         return;
     }
 
index 26ee41d..4734fbc 100644 (file)
@@ -340,7 +340,7 @@ Value ArrayPrototype::method_shift(SimpleCallContext *ctx)
     if (pidx < UINT_MAX && (!instance->arrayAttributes || !instance->arrayAttributes[0].isGeneric()))
             front = instance->arrayData + pidx;
 
-    Value result = front ? instance->getValue(ctx, front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data) : Value::undefinedValue();
+    Value result = front ? instance->getValue(front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data) : Value::undefinedValue();
 
     bool protoHasArray = false;
     Object *p = instance;
index b68f387..32beec7 100644 (file)
@@ -296,7 +296,7 @@ static void realDumpValue(QV4::Value v, QV4::ExecutionContext *ctx, std::string
         cout << prefix << "\t\"" << qPrintable(name.stringValue()->toQString()) << "\"" << endl;
         PropertyAttributes attrs;
         Property *d = o->__getOwnProperty__(name.stringValue(), &attrs);
-        Value pval = o->getValue(ctx, d, attrs);
+        Value pval = o->getValue(d, attrs);
         cout << prefix << "\tvalue:" << endl;
         realDumpValue(pval, ctx, prefix + "\t");
     }
index b462777..305d1ea 100644 (file)
@@ -238,7 +238,7 @@ void Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx, Value *result
                 l->globalGetter = globalGetterAccessor1;
             else if (l->level == 2)
                 l->globalGetter = globalGetterAccessor2;
-            Value res = o->getValue(ctx, p, attrs);
+            Value res = o->getValue(p, attrs);
             if (result)
                 *result = res;
             return;
index 639cb4f..967dcb2 100644 (file)
@@ -131,7 +131,7 @@ void Object::put(ExecutionContext *ctx, const QString &name, const Value &value)
     put(ctx->engine->newString(name), value);
 }
 
-Value Object::getValue(const Value &thisObject, ExecutionContext *ctx, const Property *p, PropertyAttributes attrs)
+Value Object::getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs)
 {
     if (!attrs.isAccessor())
         return p->value;
@@ -139,16 +139,16 @@ Value Object::getValue(const Value &thisObject, ExecutionContext *ctx, const Pro
     if (!getter)
         return Value::undefinedValue();
 
-    return getter->call(ctx, thisObject, 0, 0);
+    return getter->call(getter->engine()->current, thisObject, 0, 0);
 }
 
-void Object::putValue(ExecutionContext *ctx, Property *pd, PropertyAttributes attrs, const Value &value)
+void Object::putValue(Property *pd, PropertyAttributes attrs, const Value &value)
 {
     if (attrs.isAccessor()) {
         if (pd->set) {
             Value args[1];
             args[0] = value;
-            pd->set->call(ctx, Value::fromObject(this), args, 1);
+            pd->set->call(engine()->current, Value::fromObject(this), args, 1);
             return;
         }
         goto reject;
@@ -161,8 +161,8 @@ void Object::putValue(ExecutionContext *ctx, Property *pd, PropertyAttributes at
     return;
 
   reject:
-    if (ctx->strictMode)
-        ctx->throwTypeError();
+    if (engine()->current->strictMode)
+        engine()->current->throwTypeError();
 
 }
 
@@ -486,7 +486,7 @@ void Object::getLookup(Managed *m, Lookup *l, Value *result)
                 l->getter = Lookup::getterAccessor2;
             if (result)
                 *result = p->value;
-            Value res = o->getValue(o->engine()->current, p, attrs);
+            Value res = o->getValue(p, attrs);
             if (result)
                 *result = res;
             return;
@@ -511,7 +511,7 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value)
         }
 
         if (idx != UINT_MAX) {
-            o->putValue(o->engine()->current, o->memberData + idx, o->internalClass->propertyData[idx], value);
+            o->putValue(o->memberData + idx, o->internalClass->propertyData[idx], value);
             return;
         }
     }
@@ -596,7 +596,7 @@ Value Object::internalGet(String *name, bool *hasProperty)
         if (idx < UINT_MAX) {
             if (hasProperty)
                 *hasProperty = true;
-            return getValue(engine()->current, o->memberData + idx, o->internalClass->propertyData.at(idx));
+            return getValue(o->memberData + idx, o->internalClass->propertyData.at(idx));
         }
 
         o = o->prototype;
@@ -635,7 +635,7 @@ Value Object::internalGetIndexed(uint index, bool *hasProperty)
     if (pd) {
         if (hasProperty)
             *hasProperty = true;
-        return getValue(engine()->current, pd, attrs);
+        return getValue(pd, attrs);
     }
 
     if (hasProperty)
@@ -1060,7 +1060,7 @@ Value Object::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionCont
         }
     } else if (sparseArray) {
         for (SparseArrayNode *n = sparseArray->lowerBound(fromIndex); n != sparseArray->end() && n->key() < endIndex; n = n->nextNode()) {
-            Value value = o->getValue(ctx, arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data);
+            Value value = o->getValue(arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data);
             if (__qmljs_strict_equal(value, v))
                 return Value::fromDouble(n->key());
         }
@@ -1072,7 +1072,7 @@ Value Object::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionCont
         pd += fromIndex;
         while (pd < end) {
             if (!arrayAttributes || !arrayAttributes[pd - arrayData].isGeneric()) {
-                Value value = o->getValue(ctx, pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data);
+                Value value = o->getValue(pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data);
                 if (__qmljs_strict_equal(value, v))
                     return Value::fromDouble(pd - arrayData);
             }
@@ -1154,11 +1154,11 @@ void Object::arraySort(ExecutionContext *context, Object *thisObject, const Valu
                 while (--len > i)
                     if (!arrayAttributes[len].isGeneric())
                         break;
-                arrayData[i].value = getValue(context, arrayData + len, arrayAttributes[len]);
+                arrayData[i].value = getValue(arrayData + len, arrayAttributes[len]);
                 arrayAttributes[i] = Attr_Data;
                 arrayAttributes[len].clear();
             } else if (arrayAttributes[i].isAccessor()) {
-                arrayData[i].value = getValue(context, arrayData + i, arrayAttributes[i]);
+                arrayData[i].value = getValue(arrayData + i, arrayAttributes[i]);
                 arrayAttributes[i] = Attr_Data;
             }
         }
index dcdeca1..aeef708 100644 (file)
@@ -155,12 +155,12 @@ struct Q_QML_EXPORT Object: Managed {
     //
     void put(ExecutionContext *ctx, const QString &name, const Value &value);
 
-    static Value getValue(const Value &thisObject, ExecutionContext *ctx, const Property *p, PropertyAttributes attrs);
-    Value getValue(ExecutionContext *ctx, const Property *p, PropertyAttributes attrs) const {
-        return getValue(Value::fromObject(const_cast<Object *>(this)), ctx, p, attrs);
+    static Value getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs);
+    Value getValue(const Property *p, PropertyAttributes attrs) const {
+        return getValue(Value::fromObject(const_cast<Object *>(this)), p, attrs);
     }
 
-    void putValue(ExecutionContext *ctx, Property *pd, PropertyAttributes attrs, const Value &value);
+    void putValue(Property *pd, PropertyAttributes attrs, const Value &value);
 
     void inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const Value &rhs);
     void inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value &index, const Value &rhs);
index 984d470..cc3319e 100644 (file)
@@ -102,7 +102,7 @@ Value ObjectIterator::nextPropertyName(Value *value)
         return Value::nullValue();
 
     if (value)
-        *value = object->getValue(object->engine()->current, p, attrs);
+        *value = object->getValue(p, attrs);
 
     if (name)
         return Value::fromString(name);
@@ -120,7 +120,7 @@ Value ObjectIterator::nextPropertyNameAsString(Value *value)
         return Value::nullValue();
 
     if (value)
-        *value = object->getValue(object->engine()->current, p, attrs);
+        *value = object->getValue(p, attrs);
 
     if (name)
         return Value::fromString(name);
index 517d733..1d6eda4 100644 (file)
@@ -220,7 +220,7 @@ Value ObjectPrototype::method_defineProperties(SimpleCallContext *ctx)
             break;
         Property n;
         PropertyAttributes nattrs;
-        toPropertyDescriptor(ctx, o->getValue(ctx, pd, attrs), &n, &nattrs);
+        toPropertyDescriptor(ctx, o->getValue(pd, attrs), &n, &nattrs);
         bool ok;
         if (name)
             ok = O.objectValue()->__defineOwnProperty__(ctx, name, n, nattrs);
index 2cff28b..774abb6 100644 (file)
@@ -846,7 +846,7 @@ void __qmljs_call_property_lookup(ExecutionContext *context, Value *result, cons
     Property *p = l->lookup(baseObject, &attrs);
     if (!p)
         context->throwTypeError();
-    Value func = attrs.isData() ? p->value : baseObject->getValue(context, p, attrs);
+    Value func = attrs.isData() ? p->value : baseObject->getValue(p, attrs);
     FunctionObject *o = func.asFunctionObject();
     if (!o)
         context->throwTypeError();
index 8807326..f96876d 100644 (file)
@@ -120,7 +120,7 @@ Value String::get(Managed *m, String *name, bool *hasProperty)
     }
     if (hasProperty)
         *hasProperty = true;
-    return v4->stringPrototype->getValue(Value::fromString(that), v4->current, pd, attrs);
+    return v4->stringPrototype->getValue(Value::fromString(that), pd, attrs);
 }
 
 Value String::getIndexed(Managed *m, uint index, bool *hasProperty)
@@ -141,7 +141,7 @@ Value String::getIndexed(Managed *m, uint index, bool *hasProperty)
     }
     if (hasProperty)
         *hasProperty = true;
-    return engine->stringPrototype->getValue(Value::fromString(that), engine->current, pd, attrs);
+    return engine->stringPrototype->getValue(Value::fromString(that), pd, attrs);
 }
 
 void String::put(Managed *m, String *name, const Value &value)
index 6f09bc7..a6fba11 100644 (file)
@@ -180,7 +180,7 @@ QJSValue QJSValueIterator::value() const
     QV4::ExecutionEngine *engine = o->internalClass->engine;
     QV4::ExecutionContext *ctx = engine->current;
     try {
-        QV4::Value v = o->getValue(ctx, d_ptr->currentValue, d_ptr->currentAttributes);
+        QV4::Value v = o->getValue(d_ptr->currentValue, d_ptr->currentAttributes);
         return new QJSValuePrivate(engine, v);
     } catch (QV4::Exception &e) {
         e.accept(ctx);