const ArrayVTable SimpleArrayData::static_vtbl =
{
SimpleArrayData::Simple,
- SimpleArrayData::freeData,
+ SimpleArrayData::destroy,
+ SimpleArrayData::markObjects,
SimpleArrayData::reserve,
SimpleArrayData::get,
SimpleArrayData::put,
const ArrayVTable SparseArrayData::static_vtbl =
{
ArrayData::Sparse,
- SparseArrayData::freeData,
+ SparseArrayData::destroy,
+ SparseArrayData::markObjects,
SparseArrayData::reserve,
SparseArrayData::get,
SparseArrayData::put,
}
-void SimpleArrayData::freeData(ArrayData *d)
+void SimpleArrayData::destroy(ArrayData *d)
{
SimpleArrayData *dd = static_cast<SimpleArrayData *>(d);
delete [] (dd->data - dd->offset);
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);
}
-void SparseArrayData::freeData(ArrayData *d)
+void SparseArrayData::destroy(ArrayData *d)
{
delete static_cast<SparseArrayData *>(d)->sparse;
delete [] d->data;
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)
ReturnedValue v;
if (idx != UINT_MAX) {
v = d->data[idx].asReturnedValue();
- SparseArrayData::free(d, idx);
+ free(d, idx);
} else {
v = Encode::undefined();
}
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)
}
- sparse->ArrayData::free();
+ sparse->ArrayData::destroy();
} else {
SimpleArrayData *d = static_cast<SimpleArrayData *>(thisObject->arrayData);
if (len > d->len)
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);
}
- 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) {
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
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);
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);