aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-15 15:01:06 +0100
committerLars Knoll <lars.knoll@digia.com>2015-01-23 08:07:35 +0100
commit13cf87fa93b584091a51d775953074db9df1b453 (patch)
treedef0d8107e1a152faff71b31902eaade14531e12 /src/qml/jsruntime
parent002a5d4303b3b182ae4abc4a752c49787c1c2821 (diff)
Remove all remaining usages of ValueRef
Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp2
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4debugging_p.h2
-rw-r--r--src/qml/jsruntime/qv4global_p.h1
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp20
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp8
-rw-r--r--src/qml/jsruntime/qv4objectiterator_p.h4
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp6
-rw-r--r--src/qml/jsruntime/qv4persistent_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h21
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4value.cpp8
-rw-r--r--src/qml/jsruntime/qv4value_p.h57
15 files changed, 29 insertions, 110 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 3157a41d21..68c289a52d 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -587,7 +587,7 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
} else {
for (const SparseArrayNode *it = other->d()->sparse->begin();
it != os->sparse->end(); it = it->nextNode())
- obj->arraySet(oldSize + it->key(), ValueRef(os->arrayData[it->value]));
+ obj->arraySet(oldSize + it->key(), os->arrayData[it->value]);
}
} else {
Heap::SimpleArrayData *os = static_cast<Heap::SimpleArrayData *>(other->d());
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index d3c16bc2c0..e4403f5a57 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -166,7 +166,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
result->putIndexed(startIndex + i, entry);
}
} else {
- result->arraySet(result->getLength(), ValueRef(ctx->d()->callData->args[i]));
+ result->arraySet(result->getLength(), ctx->d()->callData->args[i]);
}
}
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index fde0818f0e..423c36963f 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -1292,7 +1292,7 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ValueRef(&ctx->d()->callData->thisObject)));
+ ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject));
ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT));
if (tv->isNumber() && !std::isfinite(tv->toNumber()))
diff --git a/src/qml/jsruntime/qv4debugging_p.h b/src/qml/jsruntime/qv4debugging_p.h
index 5780dc7c0d..a88b017019 100644
--- a/src/qml/jsruntime/qv4debugging_p.h
+++ b/src/qml/jsruntime/qv4debugging_p.h
@@ -104,7 +104,7 @@ public:
virtual void addNull(const QString &name) = 0;
virtual void addBoolean(const QString &name, bool value) = 0;
virtual void addString(const QString &name, const QString &value) = 0;
- virtual void addObject(const QString &name, ValueRef value) = 0;
+ virtual void addObject(const QString &name, const Value &value) = 0;
virtual void addInteger(const QString &name, int value) = 0;
virtual void addDouble(const QString &name, double value) = 0;
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 5378cc92df..0d1ed71da1 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -190,7 +190,6 @@ typedef quint64 ReturnedValue;
struct CallData;
struct Scope;
struct ScopedValue;
-struct ValueRef;
template<typename T> struct Scoped;
typedef Scoped<String> ScopedString;
typedef Scoped<Object> ScopedObject;
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index ffeaa1b1db..1423c4ac6a 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -77,8 +77,8 @@ private:
ReturnedValue parseArray();
bool parseMember(Object *o);
bool parseString(QString *string);
- bool parseValue(ValueRef val);
- bool parseNumber(ValueRef val);
+ bool parseValue(Value *val);
+ bool parseNumber(Value *val);
ExecutionEngine *engine;
const QChar *head;
@@ -344,7 +344,7 @@ value = false / null / true / object / array / number / string
*/
-bool JsonParser::parseValue(ValueRef val)
+bool JsonParser::parseValue(Value *val)
{
BEGIN << "parse Value" << *json;
@@ -401,7 +401,7 @@ bool JsonParser::parseValue(ValueRef val)
return false;
DEBUG << "value: string";
END;
- val = Value::fromHeapObject(engine->newString(value));
+ *val = Value::fromHeapObject(engine->newString(value));
return true;
}
case BeginArray: {
@@ -452,7 +452,7 @@ bool JsonParser::parseValue(ValueRef val)
*/
-bool JsonParser::parseNumber(ValueRef val)
+bool JsonParser::parseNumber(Value *val)
{
BEGIN << "parseNumber" << *json;
@@ -651,11 +651,11 @@ struct Stringify
Stringify(ExecutionContext *ctx) : ctx(ctx), replacerFunction(0) {}
- QString Str(const QString &key, ValueRef v);
+ QString Str(const QString &key, const Value &v);
QString JA(ArrayObject *a);
QString JO(Object *o);
- QString makeMember(const QString &key, ValueRef v);
+ QString makeMember(const QString &key, const Value &v);
};
static QString quote(const QString &str)
@@ -699,11 +699,11 @@ static QString quote(const QString &str)
return product;
}
-QString Stringify::Str(const QString &key, ValueRef v)
+QString Stringify::Str(const QString &key, const Value &v)
{
Scope scope(ctx);
- ScopedValue value(scope, *v);
+ ScopedValue value(scope, v);
ScopedObject o(scope, value);
if (o) {
ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toJSON")));
@@ -762,7 +762,7 @@ QString Stringify::Str(const QString &key, ValueRef v)
return QString();
}
-QString Stringify::makeMember(const QString &key, ValueRef v)
+QString Stringify::makeMember(const QString &key, const Value &v)
{
QString strP = Str(key, v);
if (!strP.isEmpty()) {
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index 2ce5c98316..641efc5615 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -129,7 +129,7 @@ void ObjectIterator::next(Heap::String **name, uint *index, Property *pd, Proper
*attrs = PropertyAttributes();
}
-ReturnedValue ObjectIterator::nextPropertyName(ValueRef value)
+ReturnedValue ObjectIterator::nextPropertyName(Value *value)
{
if (!object->asObject())
return Encode::null();
@@ -143,7 +143,7 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value)
if (attrs.isEmpty())
return Encode::null();
- value = object->objectValue()->getValue(p, attrs);
+ *value = object->objectValue()->getValue(p, attrs);
if (!!name)
return name->asReturnedValue();
@@ -151,7 +151,7 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value)
return Encode(index);
}
-ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value)
+ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
{
if (!object->asObject())
return Encode::null();
@@ -165,7 +165,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value)
if (attrs.isEmpty())
return Encode::null();
- value = object->objectValue()->getValue(p, attrs);
+ *value = object->objectValue()->getValue(p, attrs);
if (!!name)
return name->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h
index cee7024df8..1c65ac6c0d 100644
--- a/src/qml/jsruntime/qv4objectiterator_p.h
+++ b/src/qml/jsruntime/qv4objectiterator_p.h
@@ -60,8 +60,8 @@ struct Q_QML_EXPORT ObjectIterator
ObjectIterator(Scope &scope, Object *o, uint flags);
void init(Object *o);
void next(Heap::String **name, uint *index, Property *pd, PropertyAttributes *attributes = 0);
- ReturnedValue nextPropertyName(ValueRef value);
- ReturnedValue nextPropertyNameAsString(ValueRef value);
+ ReturnedValue nextPropertyName(Value *value);
+ ReturnedValue nextPropertyNameAsString(Value *value);
ReturnedValue nextPropertyNameAsString();
};
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index b3302d214d..64d5f5641c 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -66,7 +66,7 @@ ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData)
obj->setPrototype(proto);
return obj.asReturnedValue();
}
- return RuntimeHelpers::toObject(scope.engine, ValueRef(&callData->args[0]));
+ return RuntimeHelpers::toObject(scope.engine, callData->args[0]);
}
ReturnedValue ObjectCtor::call(Managed *m, CallData *callData)
@@ -75,7 +75,7 @@ ReturnedValue ObjectCtor::call(Managed *m, CallData *callData)
ExecutionEngine *v4 = ctor->engine();
if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull())
return v4->newObject()->asReturnedValue();
- return RuntimeHelpers::toObject(v4, ValueRef(&callData->args[0]));
+ return RuntimeHelpers::toObject(v4, callData->args[0]);
}
void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
@@ -390,7 +390,7 @@ ReturnedValue ObjectPrototype::method_toString(CallContext *ctx)
} else if (ctx->d()->callData->thisObject.isNull()) {
return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue();
} else {
- ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ValueRef(&ctx->d()->callData->thisObject)));
+ ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject));
QString className = obj->className();
return ctx->d()->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h
index 02d4007f62..b57d6398ed 100644
--- a/src/qml/jsruntime/qv4persistent_p.h
+++ b/src/qml/jsruntime/qv4persistent_p.h
@@ -114,8 +114,6 @@ public:
bool isEmpty() { return !val; }
private:
- friend struct ValueRef;
-
Value *val;
};
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index fdff79538c..73ae88f80c 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -960,7 +960,7 @@ ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, Call
return engine->throwTypeError(message);
}
- baseObject = RuntimeHelpers::convertToObject(scope.engine, ValueRef(&callData->thisObject));
+ baseObject = RuntimeHelpers::convertToObject(scope.engine, callData->thisObject);
if (!baseObject) // type error
return Encode::undefined();
callData->thisObject = baseObject.asReturnedValue();
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index d72d23bbe9..81b81f6c5c 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -105,8 +105,6 @@ private:
Q_DISABLE_COPY(Scope)
};
-struct ValueRef;
-
struct ScopedValue
{
ScopedValue(const Scope &scope)
@@ -460,25 +458,6 @@ inline TypedValue<T> &TypedValue<T>::operator=(const TypedValue<T> &t)
return *this;
}
-inline ValueRef::ValueRef(const ScopedValue &v)
- : ptr(v.ptr)
-{}
-
-template <typename T>
-inline ValueRef::ValueRef(const Scoped<T> &v)
- : ptr(v.ptr)
-{}
-
-inline ValueRef::ValueRef(const PersistentValue &v)
- : ptr(v.val)
-{}
-
-inline ValueRef &ValueRef::operator=(const ScopedValue &o)
-{
- *ptr = *o.ptr;
- return *this;
-}
-
struct ScopedProperty
{
ScopedProperty(Scope &scope)
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index ed4d70270c..dad3cf0ebc 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -287,7 +287,7 @@ ReturnedValue StringPrototype::method_concat(CallContext *context)
ScopedValue v(scope);
for (int i = 0; i < context->d()->callData->argc; ++i) {
- v = RuntimeHelpers::toString(scope.engine, ValueRef(&context->d()->callData->args[i]));
+ v = RuntimeHelpers::toString(scope.engine, context->d()->callData->args[i]);
if (scope.hasException())
return Encode::undefined();
Q_ASSERT(v->isString());
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 0f81c94f24..b3ca1fb268 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -128,7 +128,7 @@ QString Value::toQStringNoThrow() const
Scope scope(objectValue()->engine());
ScopedValue ex(scope);
bool caughtException = false;
- ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
+ ScopedValue prim(scope, RuntimeHelpers::toPrimitive(*this, STRING_HINT));
if (scope.hasException()) {
ex = scope.engine->catchException();
caughtException = true;
@@ -179,7 +179,7 @@ QString Value::toQString() const
{
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
- ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
+ ScopedValue prim(scope, RuntimeHelpers::toPrimitive(*this, STRING_HINT));
return prim->toQString();
}
case Value::Integer_Type: {
@@ -271,14 +271,14 @@ Heap::String *Value::toString(ExecutionEngine *e) const
{
if (isString())
return stringValue()->d();
- return RuntimeHelpers::convertToString(e, ValueRef::fromRawValue(this));
+ return RuntimeHelpers::convertToString(e, *this);
}
Heap::Object *Value::toObject(ExecutionEngine *e) const
{
if (isObject())
return objectValue()->d();
- return RuntimeHelpers::convertToObject(e, ValueRef::fromRawValue(this));
+ return RuntimeHelpers::convertToObject(e, *this);
}
#endif // V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 22f0e1e4d5..3bd986ff8e 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -420,8 +420,6 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value
static double toInteger(double fromNumber);
static int toInt32(double value);
static unsigned int toUInt32(double value);
-
- inline operator ValueRef();
};
inline Primitive Primitive::undefinedValue()
@@ -518,61 +516,6 @@ private:
Encode(void *);
};
-struct ValueRef {
- ValueRef(const ScopedValue &v);
- template <typename T>
- ValueRef(const Scoped<T> &v);
- ValueRef(const PersistentValue &v);
- ValueRef(Value &v) { ptr = &v; }
- // Important: Do NOT add a copy constructor to this class
- // adding a copy constructor actually changes the calling convention, ie.
- // is not even binary compatible. Adding it would break assumptions made
- // in the jit'ed code.
- ValueRef &operator=(const ScopedValue &o);
- ValueRef &operator=(const Value &v)
- { *ptr = v; return *this; }
- ValueRef &operator=(const ReturnedValue &v) {
- ptr->val = v;
- return *this;
- }
-
- operator const Value *() const {
- return ptr;
- }
- const Value *operator->() const {
- return ptr;
- }
-
- operator Value &() { return *ptr; }
- operator const Value &() const { return *ptr; }
-
- operator Value *() {
- return ptr;
- }
- Value *operator->() {
- return ptr;
- }
-
- static ValueRef fromRawValue(Value *v) {
- return ValueRef(v);
- }
- static const Value &fromRawValue(const Value *v) {
- return ValueRef(const_cast<Value *>(v));
- }
-
- ReturnedValue asReturnedValue() const { return ptr->val; }
-
- // ### get rid of this one!
- ValueRef(Value *v) { ptr = v; }
-private:
- Value *ptr;
-};
-
-inline Primitive::operator ValueRef()
-{
- return ValueRef(this);
-}
-
inline
ReturnedValue Heap::Base::asReturnedValue() const
{