27#define V4_ARRAYDATA(DataClass)
30 typedef QV4::Heap::DataClass Data;
31 static const QV4::ArrayVTable static_vtbl;
32 static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; }
34 const Data *d() const { return static_cast<const Data *>(m()); }
35 Data *d() { return static_cast<Data *>(m()); }
44 Heap::ArrayData *(*reallocate)(Object *o, uint n,
bool enforceAttributes);
46 bool (*
put)(Object *o, uint index,
const Value &value);
47 bool (*
putArray)(Object *o, uint index,
const Value *values, uint n);
48 bool (*
del)(Object *o, uint index);
49 void (*
setAttribute)(Object *o, uint index, PropertyAttributes attrs);
50 void (*
push_front)(Object *o,
const Value *values, uint n);
52 uint (*truncate)(Object *o, uint newLen);
53 uint (*length)(
const Heap::ArrayData *d);
58#define ArrayDataMembers(class, Member)
59 Member(class, NoMark, ushort, type)
60 Member(class, NoMark, ushort, unused)
61 Member(class, NoMark, uint, offset)
62 Member(class, NoMark, PropertyAttributes *, attrs)
63 Member(class, NoMark, SparseArray *, sparse)
64 Member(class, ValueArray, ValueArray, values)
67 static void markObjects(
Heap::Base *base, MarkStack *stack);
69 enum Type { Simple = 0, Sparse = 1, Custom = 2 };
71 bool isSparse()
const {
return type == Sparse; }
73 const ArrayVTable *vtable()
const {
return reinterpret_cast<
const ArrayVTable *>(internalClass->vtable); }
75 inline ReturnedValue get(uint i)
const {
76 return vtable()->get(
this, i);
78 inline bool getProperty(uint index,
Property *p, PropertyAttributes *attrs);
79 inline void setProperty(EngineBase *e, uint index,
const Property *p);
80 inline PropertyIndex getValueOrSetter(uint index, PropertyAttributes *attrs);
81 inline PropertyAttributes attributes(uint i)
const;
83 bool isEmpty(uint i)
const {
84 return get(i) == Value::emptyValue().asReturnedValue();
87 inline uint length()
const {
88 return vtable()->length(
this);
91 void setArrayData(EngineBase *e, uint index, Value newVal) {
92 values.set(e, index, newVal);
95 uint mappedIndex(uint index)
const;
100 uint
mappedIndex(uint index)
const { index += offset;
if (index >= values.alloc) index -= values.alloc;
return index; }
101 const Value &
data(uint index)
const {
return values[mappedIndex(index)]; }
102 void setData(EngineBase *e, uint index, Value newVal) {
103 values.set(e, mappedIndex(index), newVal);
107 return attrs ? attrs[i] : Attr_Data;
115 ArrayData::destroy();
129 return index < UINT_MAX ? attrs[index] : Attr_Data;
240 : m_engine(engine), m_comparefn(comparefn) {}
242 bool operator()(Value v1, Value v2)
const;
245 ExecutionEngine *m_engine;
246 const Value &m_comparefn;
249template <
typename RandomAccessIterator,
typename LessThan>
250void sortHelper(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
255 int span =
int(end - start);
260 RandomAccessIterator low = start, high = end - 1;
261 RandomAccessIterator pivot = start + span / 2;
263 if (lessThan(*end, *start))
268 if (lessThan(*pivot, *start))
269 swap(*pivot, *start);
270 if (lessThan(*end, *pivot))
278 while (low < high && lessThan(*low, *end))
281 while (high > low && lessThan(*end, *high))
293 if (lessThan(*low, *end))
297 sortHelper(start, low, lessThan);
354 return {
nullptr,
nullptr };
ArrayElementLessThan(ExecutionEngine *engine, const Value &comparefn)
bool operator()(Value v1, Value v2) const
ReturnedValue operator*() const
OptionalReturnedValue(ReturnedValue v)
ReturnedValue operator->() const
DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object)
DECLARE_EXPORTED_HEAP_OBJECT(Object, Base)
DECLARE_HEAP_OBJECT(ArgumentsObject, Object)
DECLARE_HEAP_OBJECT(MemberData, Base)
DECLARE_HEAP_OBJECT(ArrayData, Base)
Q_STATIC_ASSERT(std::is_trivial_v< ArrayData >)
Scoped< FunctionObject > ScopedFunctionObject
void sortHelper(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
QVector< StackFrame > StackTrace
int qYouForgotTheQ_MANAGED_Macro(T, T)
Scoped< Object > ScopedObject
ReturnedValue value_convert(ExecutionEngine *e, const Value &v)
Scoped< ArrayObject > ScopedArrayObject
Scoped< String > ScopedString
Scoped< StringOrSymbol > ScopedStringOrSymbol
void qYouForgotTheQ_MANAGED_Macro(T1, T2)
@ Attr_ReadOnly_ButConfigurable
Q_STATIC_ASSERT(sizeof(CppStackFrame)==sizeof(JSTypesStackFrame))
Scoped< ExecutionContext > ScopedContext
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
DEFINE_OBJECT_VTABLE(StrictArgumentsObject)
DEFINE_OBJECT_VTABLE(ArgumentsObject)
#define V4_ARRAYDATA(DataClass)
#define V4_MANAGED(DataClass, superClass)
#define V4_MANAGED_SIZE_TEST
#define V4_MANAGED_ITSELF(DataClass, superClass)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
static qint64 virtualGetLength(const Managed *m)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs)
Heap::CallContext * context() const
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
static bool isNonStrictArgumentsObject(Managed *m)
static bool virtualDeleteProperty(Managed *m, PropertyKey id)
bool fullyCreated() const
void removeMapping(uint arg)
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
bool isMapped(uint arg) const
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
static qint64 virtualGetLength(const Managed *m)
QStringList toQStringList() const
void(* setAttribute)(Object *o, uint index, PropertyAttributes attrs)
bool(* putArray)(Object *o, uint index, const Value *values, uint n)
bool(* put)(Object *o, uint index, const Value &value)
void(* push_front)(Object *o, const Value *values, uint n)
ReturnedValue(* get)(const Heap::ArrayData *d, uint index)
bool(* del)(Object *o, uint index)
ReturnedValue(* pop_front)(Object *o)
static constexpr size_t offset
void set(EngineBase *e, HeapBasePtr b)
void set(EngineBase *e, const Value &newVal)
void init(const QStringList &list)
PropertyAttributes attributes(uint i) const
uint mappedIndex(uint index) const
void setData(EngineBase *e, uint index, Value newVal)
const Value & data(uint index) const
uint mappedIndex(uint index) const
PropertyAttributes attributes(uint i) const
static Heap::MemberData * allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old=nullptr)
const Value * data() const
void set(EngineBase *e, uint index, Value v)
const Value & operator[](uint idx) const
void set(EngineBase *e, uint index, Heap::Base *b)
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
const Value * data() const
void set(EngineBase *e, uint index, Value v)
void set(EngineBase *e, uint index, Value::HeapBasePtr b)
void mark(MarkStack *markStack)
Value::HeapBasePtr base()
const Value & operator[](uint index) const
static constexpr size_t offset