aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4persistent.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-15 11:36:57 +0100
committerLars Knoll <lars.knoll@digia.com>2015-01-23 08:07:32 +0100
commit002a5d4303b3b182ae4abc4a752c49787c1c2821 (patch)
tree69c7666ed1061c7acacee1d76597c06405459c80 /src/qml/jsruntime/qv4persistent.cpp
parentfddc75e862032163af36d2282051758647b62d15 (diff)
Get rid of most uses of ValueRef
Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4persistent.cpp')
-rw-r--r--src/qml/jsruntime/qv4persistent.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp
index 1b191f3384..0b3c7a4da0 100644
--- a/src/qml/jsruntime/qv4persistent.cpp
+++ b/src/qml/jsruntime/qv4persistent.cpp
@@ -216,7 +216,7 @@ PersistentValue::PersistentValue(const PersistentValue &other)
}
}
-PersistentValue::PersistentValue(ExecutionEngine *engine, const ValueRef value)
+PersistentValue::PersistentValue(ExecutionEngine *engine, const Value &value)
{
val = engine->memoryManager->m_persistentValues->allocate();
*val = value;
@@ -228,6 +228,16 @@ PersistentValue::PersistentValue(ExecutionEngine *engine, ReturnedValue value)
*val = value;
}
+PersistentValue::PersistentValue(ExecutionEngine *engine, Object *object)
+ : val(0)
+{
+ if (!object)
+ return;
+
+ val = engine->memoryManager->m_persistentValues->allocate();
+ *val = object;
+}
+
PersistentValue::~PersistentValue()
{
PersistentValueStorage::free(val);
@@ -274,7 +284,7 @@ PersistentValue &PersistentValue::operator=(Object *object)
return *this;
}
-void PersistentValue::set(ExecutionEngine *engine, const ValueRef value)
+void PersistentValue::set(ExecutionEngine *engine, const Value &value)
{
if (!val)
val = engine->memoryManager->m_persistentValues->allocate();
@@ -323,7 +333,7 @@ WeakValue::~WeakValue()
PersistentValueStorage::free(val);
}
-void WeakValue::set(ExecutionEngine *engine, const ValueRef value)
+void WeakValue::set(ExecutionEngine *engine, const Value &value)
{
if (!val)
val = engine->memoryManager->m_weakValues->allocate();