3#ifndef QV4PROPERTYDESCRIPTOR_H
4#define QV4PROPERTYDESCRIPTOR_H
32 if (!attrs->hasType()) {
33 value = Value::undefinedValue();
35 if (attrs->type() == PropertyAttributes::Accessor) {
36 attrs->clearWritable();
38 value = Value::undefinedValue();
40 set = Value::undefinedValue();
48 value = Encode::undefined();
49 if (attrs->isGeneric() || attrs->isData()) {
50 attrs->setType(PropertyAttributes::Data);
51 if (!attrs->hasWritable())
52 attrs->setWritable(
false);
55 set = Encode::undefined();
57 if (!attrs->hasEnumerable())
58 attrs->setEnumerable(
false);
59 if (!attrs->hasConfigurable())
60 attrs->setConfigurable(
false);
63 inline bool isSubset(
const PropertyAttributes &attrs,
const Property *other, PropertyAttributes otherAttrs)
const;
64 inline void merge(PropertyAttributes &attrs,
const Property *other, PropertyAttributes otherAttrs);
66 inline Heap::FunctionObject *
getter()
const {
return reinterpret_cast<Heap::FunctionObject *>(value.heapObject()); }
67 inline Heap::FunctionObject *
setter()
const {
return reinterpret_cast<Heap::FunctionObject *>(set.heapObject()); }
68 inline void setGetter(FunctionObject *g) { value =
reinterpret_cast<Managed *>(g); }
69 inline void setSetter(FunctionObject *s) { set = (s ?
reinterpret_cast<Managed *>(s) :
nullptr); }
73 if (attrs.isAccessor())
79 if (otherAttrs.isEmpty())
81 if (!attrs.isConfigurable()) {
82 if (otherAttrs.hasConfigurable() && otherAttrs.isConfigurable())
84 if (otherAttrs.hasEnumerable() && otherAttrs.isEnumerable() != attrs.isEnumerable())
87 if (otherAttrs.isGeneric())
89 if (attrs.isData() != otherAttrs.isData()) {
90 if (!attrs.isConfigurable())
92 }
else if (attrs.isData() && otherAttrs.isData()) {
93 if (!attrs.isConfigurable() && !attrs.isWritable()) {
94 if (otherAttrs.hasWritable() && otherAttrs.isWritable())
96 if (!other->value.isEmpty() && !value.sameValue(other->value))
99 }
else if (attrs.isAccessor() && otherAttrs.isAccessor()) {
100 if (!attrs.isConfigurable()) {
101 if (!other->value.isEmpty() && !value.sameValue(other->value))
103 if (!other->set.isEmpty() && !set.sameValue(other->set))
111 explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(
nullptr); }
113 value.setM(
reinterpret_cast<Heap::Base *>(getter));
114 set.setM(
reinterpret_cast<Heap::Base *>(setter));
122 if (attrs.type() != PropertyAttributes::Generic && attrs.type() != otherAttrs.type())
124 if (attrs.hasEnumerable() && attrs.isEnumerable() != otherAttrs.isEnumerable())
126 if (attrs.hasConfigurable() && attrs.isConfigurable() != otherAttrs.isConfigurable())
128 if (attrs.hasWritable() && attrs.isWritable() != otherAttrs.isWritable())
130 if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other->value))
132 if (attrs.type() == PropertyAttributes::Accessor) {
133 if (value.heapObject() != other->value.heapObject())
135 if (set.heapObject() != other->set.heapObject())
143 if (otherAttrs.hasEnumerable())
144 attrs.setEnumerable(otherAttrs.isEnumerable());
145 if (otherAttrs.hasConfigurable())
146 attrs.setConfigurable(otherAttrs.isConfigurable());
147 if (otherAttrs.hasWritable())
148 attrs.setWritable(otherAttrs.isWritable());
149 if (otherAttrs.type() == PropertyAttributes::Accessor) {
150 attrs.setType(PropertyAttributes::Accessor);
151 if (!other->value.isEmpty())
152 value = other->value;
153 if (!other->set.isEmpty())
155 }
else if (otherAttrs.type() == PropertyAttributes::Data){
156 attrs.setType(PropertyAttributes::Data);
157 value = other->value;
165 void set(EngineBase *e, Value newVal) {
166 WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue());
bool isString() const
Returns true if the type of this QJSManagedValue is string, or false otherwise.
QJSEngine * engine() const
Returns the QJSEngine this QJSManagedValue belongs to.
bool deleteProperty(quint32 arrayIndex)
Deletes the value stored at arrayIndex from this QJSManagedValue.
QJSValue toJSValue() const
Copies this QJSManagedValue into a new QJSValue.
QJSManagedValue jsMetaType() const
bool isBoolean() const
Returns true if the type of this QJSManagedValue is boolean, or false otherwise.
const QMetaObject * toQMetaObject() const
If this QJSManagedValue holds a QMetaObject pointer, returns it.
QStringList jsMetaMembers() const
bool isArray() const
Returns true if this value represents a JavaScript Array object, or false otherwise.
bool isError() const
Returns true if this value represents a JavaScript Error object, or false otherwise.
bool strictlyEquals(const QJSManagedValue &other) const
Invokes the JavaScript '===' operator on this QJSManagedValue and other, and returns the result.
bool hasProperty(const QString &name) const
Returns true if this QJSManagedValue has a property name, otherwise returns false.
QJSValue call(const QJSValueList &arguments={}) const
If this QJSManagedValue represents a JavaScript FunctionObject, calls it with the given arguments,...
QObject * toQObject() const
If this QJSManagedValue holds a QObject pointer, returns it.
bool isRegularExpression() const
Returns true if this value represents a JavaScript regular expression object, or false otherwise.
QJSValue property(const QString &name) const
Returns the property name of this QJSManagedValue.
QJSManagedValue jsMetaInstantiate(const QJSValueList &values={}) const
bool hasOwnProperty(quint32 arrayIndex) const
Returns true if this QJSManagedValue has an array index arrayIndex, otherwise returns false.
QVariant toVariant() const
Copies this QJSManagedValue into a new QVariant.
bool hasProperty(quint32 arrayIndex) const
Returns true if this QJSManagedValue has an array index arrayIndex, otherwise returns false.
double toNumber() const
Converts the manged value to a number.
QJSManagedValue & operator=(QJSManagedValue &&other)
Move-assigns a QJSManagedValue from other.
QJSValue callAsConstructor(const QJSValueList &arguments={}) const
If this QJSManagedValue represents a JavaScript FunctionObject, calls it as constructor with the give...
bool isVariant() const
Returns true if this value represents a QVariant managed on the JavaScript heap, or false otherwise.
bool isFunction() const
Returns true if the type of this QJSManagedValue is function, false otherwise.
QRegularExpression toRegularExpression() const
If this QJSManagedValue holds a JavaScript regular expression object, returns an equivalent QRegularE...
QJSManagedValue prototype() const
Returns the prototype for this QJSManagedValue.
bool isUndefined() const
Returns true if the type of this QJSManagedValue is undefined, or false otherwise.
bool isDate() const
Returns true if this value represents a JavaScript Date object, or false otherwise.
bool equals(const QJSManagedValue &other) const
Invokes the JavaScript '==' operator on this QJSManagedValue and other, and returns the result.
~QJSManagedValue()
Destroys the QJSManagedValue.
QJSPrimitiveValue toPrimitive() const
Converts the manged value to a QJSPrimitiveValue.
bool deleteProperty(const QString &name)
Deletes the property name from this QJSManagedValue.
bool isQMetaObject() const
Returns true if this value represents a QMetaObject pointer managed on the JavaScript heap,...
QDateTime toDateTime() const
If this QJSManagedValue holds a JavaScript Date object, returns an equivalent QDateTime.
int toInteger() const
Converts the manged value to an integer.
QString toString() const
Converts the manged value to a string.
QUrl toUrl() const
If this QJSManagedValue holds a JavaScript Url object, returns an equivalent QUrl.
bool isQObject() const
Returns true if this value represents a QObject pointer managed on the JavaScript heap,...
bool hasOwnProperty(const QString &name) const
Returns true if this QJSManagedValue has a property name, otherwise returns false.
void setPrototype(const QJSManagedValue &prototype)
Sets the prototype of this QJSManagedValue to prototype.
bool isUrl() const
Returns true if this value represents a JavaScript Url object, or false otherwise.
bool isInteger() const
Returns true if this QJSManagedValue holds an integer value, or false otherwise.
bool isNumber() const
Returns true if the type of this QJSManagedValue is number, or false otherwise.
bool isNull() const
Returns true if this QJSManagedValue holds the JavaScript null value, or false otherwise.
bool isSymbol() const
Returns true if the type of this QJSManagedValue is symbol, or false otherwise.
bool isObject() const
Returns true if the type of this QJSManagedValue is object, or false otherwise.
void setProperty(const QString &name, const QJSValue &value)
Sets the property name to value on this QJSManagedValue.
void setProperty(quint32 arrayIndex, const QJSValue &value)
Stores the value at arrayIndex in this QJSManagedValue.
bool toBoolean() const
Converts the manged value to a boolean.
QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &arguments={}) const
If this QJSManagedValue represents a JavaScript FunctionObject, calls it on instance with the given a...
bool isJsMetaType() const
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
static QV4::ExecutionEngine * engine(const QJSValue *jsval)
The QJSValue class acts as a container for Qt/JavaScript data types.
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
ArrayElementLessThan(ExecutionEngine *engine, const Value &comparefn)
bool operator()(Value v1, Value v2) const
ReturnedValue operator*() const
OptionalReturnedValue(ReturnedValue v)
ReturnedValue operator->() const
Combined button and popup list for selecting options.
DECLARE_EXPORTED_HEAP_OBJECT(Object, Base)
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(std::is_trivial_v< Value >)
Scoped< ExecutionContext > ScopedContext
T caughtResult(const QJSValue *v, T(QV4::Value::*convert)() const)
static bool js_equal(const QString &string, const QV4::Value &value)
QDataStream & operator<<(QDataStream &stream, const QJSValue &jsv)
QDataStream & operator>>(QDataStream &stream, QJSValue &jsv)
QList< QJSValue > QJSValueList
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
#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 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 * operator->() const
const Value & operator*() const
void set(EngineBase *e, Value newVal)
void setGetter(FunctionObject *g)
Heap::FunctionObject * getter() const
bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void setSetter(FunctionObject *s)
void fullyPopulated(PropertyAttributes *attrs)
bool isCompatible(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void copy(const Property *other, PropertyAttributes attrs)
void completed(PropertyAttributes *attrs)
Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter)
Heap::FunctionObject * setter() const
void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs)
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