aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-20 12:15:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-21 08:18:41 +0100
commitc1c9ce91b35e445f8c4cece1e994882c2293cd3f (patch)
treef95246e9eeda97aac2976cea9786de3106ed43d8
parent65ec0ab2e432139a2befe887ed9af4603ee1ae03 (diff)
Adjust method naming to be closer to Managed
Also make markObjects() virtual, to be in line with Managed. Change-Id: I3e7682216660e2027c02c9181e541b12310902f3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp35
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h21
-rw-r--r--src/qml/jsruntime/qv4object.cpp2
3 files changed, 37 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 360aa8be99..933449b96e 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -47,7 +47,8 @@ using namespace QV4;
const ArrayVTable SimpleArrayData::static_vtbl =
{
SimpleArrayData::Simple,
- SimpleArrayData::freeData,
+ SimpleArrayData::destroy,
+ SimpleArrayData::markObjects,
SimpleArrayData::reserve,
SimpleArrayData::get,
SimpleArrayData::put,
@@ -64,7 +65,8 @@ const ArrayVTable SimpleArrayData::static_vtbl =
const ArrayVTable SparseArrayData::static_vtbl =
{
ArrayData::Sparse,
- SparseArrayData::freeData,
+ SparseArrayData::destroy,
+ SparseArrayData::markObjects,
SparseArrayData::reserve,
SparseArrayData::get,
SparseArrayData::put,
@@ -139,7 +141,7 @@ void ArrayData::ensureAttributes()
}
-void SimpleArrayData::freeData(ArrayData *d)
+void SimpleArrayData::destroy(ArrayData *d)
{
SimpleArrayData *dd = static_cast<SimpleArrayData *>(d);
delete [] (dd->data - dd->offset);
@@ -148,6 +150,13 @@ void SimpleArrayData::freeData(ArrayData *d)
delete dd;
}
+void SimpleArrayData::markObjects(ArrayData *d, ExecutionEngine *e)
+{
+ uint l = static_cast<SimpleArrayData *>(d)->len;
+ for (uint i = 0; i < l; ++i)
+ d->data[i].mark(e);
+}
+
ReturnedValue SimpleArrayData::get(const ArrayData *d, uint index)
{
const SimpleArrayData *dd = static_cast<const SimpleArrayData *>(d);
@@ -289,7 +298,7 @@ void SparseArrayData::free(ArrayData *d, uint idx)
}
-void SparseArrayData::freeData(ArrayData *d)
+void SparseArrayData::destroy(ArrayData *d)
{
delete static_cast<SparseArrayData *>(d)->sparse;
delete [] d->data;
@@ -298,6 +307,13 @@ void SparseArrayData::freeData(ArrayData *d)
delete d;
}
+void SparseArrayData::markObjects(ArrayData *d, ExecutionEngine *e)
+{
+ uint l = d->alloc;
+ for (uint i = 0; i < l; ++i)
+ d->data[i].mark(e);
+}
+
void SparseArrayData::reserve(ArrayData *d, uint n)
{
if (n < 8)
@@ -453,7 +469,7 @@ ReturnedValue SparseArrayData::pop_front(ArrayData *d)
ReturnedValue v;
if (idx != UINT_MAX) {
v = d->data[idx].asReturnedValue();
- SparseArrayData::free(d, idx);
+ free(d, idx);
} else {
v = Encode::undefined();
}
@@ -563,13 +579,6 @@ Property *ArrayData::insert(Object *o, uint index, bool isAccessor)
return reinterpret_cast<Property *>(o->arrayData->data + n->value);
}
-void ArrayData::markObjects(ExecutionEngine *e)
-{
- uint l = (type == Simple) ? static_cast<SimpleArrayData *>(this)->len : alloc;
- for (uint i = 0; i < l; ++i)
- data[i].mark(e);
-}
-
void ArrayData::sort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint len)
{
if (!len)
@@ -637,7 +646,7 @@ void ArrayData::sort(ExecutionContext *context, ObjectRef thisObject, const Valu
}
- sparse->ArrayData::free();
+ sparse->ArrayData::destroy();
} else {
SimpleArrayData *d = static_cast<SimpleArrayData *>(thisObject->arrayData);
if (len > d->len)
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index f82b45c14c..9d9e5705d6 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -55,7 +55,8 @@ struct ArrayData;
struct ArrayVTable
{
uint type;
- void (*freeData)(ArrayData *d);
+ void (*destroy)(ArrayData *d);
+ void (*markObjects)(ArrayData *, ExecutionEngine *e);
void (*reserve)(ArrayData *d, uint n);
ReturnedValue (*get)(const ArrayData *d, uint index);
bool (*put)(ArrayData *d, uint index, ValueRef value);
@@ -126,8 +127,12 @@ struct Q_QML_EXPORT ArrayData
}
- inline void free() {
- vtable->freeData(this);
+ inline void destroy() {
+ vtable->destroy(this);
+ }
+
+ inline void markObjects(ExecutionEngine *e) {
+ vtable->markObjects(this, e);
}
inline void push_front(SafeValue *values, uint nValues) {
@@ -164,8 +169,6 @@ struct Q_QML_EXPORT ArrayData
static void sort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint dataLen);
static uint append(Object *obj, const ArrayObject *otherObj, uint n);
static Property *insert(Object *o, uint index, bool isAccessor = false);
- void markObjects(ExecutionEngine *e);
-
};
struct Q_QML_EXPORT SimpleArrayData : public ArrayData
@@ -182,7 +185,9 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData
static void getHeadRoom(ArrayData *d);
static void reserve(ArrayData *d, uint n);
- static void freeData(ArrayData *d);
+ static void destroy(ArrayData *d);
+ static void markObjects(ArrayData *d, ExecutionEngine *e);
+
static ReturnedValue get(const ArrayData *d, uint index);
static bool put(ArrayData *d, uint index, ValueRef value);
static bool putArray(ArrayData *d, uint index, SafeValue *values, uint n);
@@ -211,7 +216,9 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData
static uint allocate(ArrayData *d, bool doubleSlot = false);
static void free(ArrayData *d, uint idx);
- static void freeData(ArrayData *d);
+ static void destroy(ArrayData *d);
+ static void markObjects(ArrayData *d, ExecutionEngine *e);
+
static void reserve(ArrayData *d, uint n);
static ReturnedValue get(const ArrayData *d, uint index);
static bool put(ArrayData *d, uint index, ValueRef value);
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 5c6a648a94..43e0808a24 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -92,7 +92,7 @@ Object::~Object()
if (memberData != inlineProperties)
delete [] memberData;
if (arrayData)
- arrayData->free();
+ arrayData->destroy();
_data = 0;
}