18#include <QtQml/qjsprimitivevalue.h>
19#include <QtQml/qjsvalue.h>
20#include <QtQml/qqmllist.h>
21#include <QtQml/qqmlparserstatus.h>
22#include <QtQml/qqmlpropertyvaluesource.h>
23#include <QtQml/qtqmlglobal.h>
25#include <QtCore/qdatetime.h>
26#include <QtCore/qdebug.h>
27#include <QtCore/qglobal.h>
28#include <QtCore/qmetacontainer.h>
29#include <QtCore/qmetaobject.h>
30#include <QtCore/qpointer.h>
31#include <QtCore/qurl.h>
32#include <QtCore/qvariant.h>
33#include <QtCore/qversionnumber.h>
41class QQmlPropertyValueInterceptor;
43class QQmlFinalizerHook;
52struct ExecutionEngine;
54class ExecutableCompilationUnit;
64using QQmlAttachedPropertiesFunc = QQmlPrivate::QQmlAttachedPropertiesFunc<QObject>;
66inline size_t qHash(QQmlAttachedPropertiesFunc func, size_t seed = 0)
68 return qHash(quintptr(func), seed);
71template <
typename TYPE>
83class QQmlCustomParser;
100 class QQmlElement final :
public T
107 QQmlPrivate::qdeclarativeelement_destructor(
this);
115 ::operator
delete (ptr);
118 static void operator
delete(
void *,
void *) {
134 template<
typename T,
typename WrapperT =
T,
typename =
std::
void_t<>>
137 static constexpr bool value =
false;
150 template<
typename T,
typename WrapperT>
153 if constexpr (!std::is_base_of<QObject, T>::value)
155 if constexpr (!std::is_same_v<T, WrapperT> && HasSingletonFactory<T, WrapperT>::value)
157 if constexpr (
std::is_default_constructible<T>::value)
159 if constexpr (HasSingletonFactory<T>::value)
168 template<
typename Ret,
typename Class>
174 template<
typename T,
typename Marker>
178 void createInto(
void *memory,
void *) {
new (memory) QQmlElement<T>; }
188 return T::create(q, j);
190 return WrapperT::create(q, j);
203 template<
typename T,
typename WrapperT = T,
207 template<
typename T,
typename WrapperT>
217 template<
typename T,
typename WrapperT>
224 template<
typename T,
typename WrapperT>
233 template<
typename T,
typename WrapperT>
270 template<
typename F,
typename Result =
void>
273 static constexpr const Result (*create)(
const QJSValue &) =
nullptr;
285 template<
typename T,
typename F,
291 template<
typename T,
typename F>
297 template<
typename T,
typename F,
bool HasCtor>
302 return F::create(params);
306 template<
typename T,
typename F>
311 return QVariant::fromValue(T(params));
315 template<
class From,
class To,
int N>
318 static inline int cast() {
return -1; }
321 template<
class From,
class To>
324 static inline int cast() {
return int(
reinterpret_cast<quintptr>(
static_cast<To *>(
reinterpret_cast<From *>(0x10000000)))) - 0x10000000; }
327 template<
class From,
class To>
344 template<
class T,
class A>
419 return QQmlAttachedPropertiesFunc<QObject>(QmlAttached<T>::attachedPropertiesFunc());
424 return QmlAttached<T>::staticMetaObject();
519 QQmlCustomParser *(*customParserFactory)();
672#if QT_QML_REMOVED_SINCE(6
, 9
)
714#if QT_QML_REMOVED_SINCE(6
, 9
)
728#if QT_QML_REMOVED_SINCE(6
, 9
)
746#if QT_QML_REMOVED_SINCE(6
, 9
)
763#if QT_QML_REMOVED_SINCE(6
, 9
)
770#if QT_QML_REMOVED_SINCE(6
, 9
)
775#if QT_QML_REMOVED_SINCE(6
, 6
)
784#if QT_QML_REMOVED_SINCE(6
, 9
)
791#if QT_QML_REMOVED_SINCE(6
, 9
)
817 template<
typename Value>
824 void (*
signature)(
QV4::ExecutableCompilationUnit *unit, QMetaType *argTypes);
825 void (*
functionPtr)(
const AOTCompiledContext *context,
void **argv);
828#if QT_DEPRECATED_SINCE(6
, 6
)
839 typedef const CachedQmlUnit *(*QmlUnitCacheLookupFunction)(
const QUrl &url);
862#if QT_DEPRECATED_SINCE(6
, 3
)
885 if (!metaObject || !key)
888 const int offset = metaObject->classInfoOffset();
889 const int start = (startOffset == -1)
890 ? (metaObject->classInfoCount() + offset - 1)
892 for (
int i = start; i >= offset; --i)
893 if (qstrcmp(key, metaObject->classInfo(i).name()) == 0) {
899 inline const char *
classInfo(
const QMetaObject *metaObject,
const char *key)
901 return metaObject->classInfo(indexOfOwnClassInfo(metaObject, key)).value();
905 QTypeRevision defaultValue = QTypeRevision())
907 const int index = indexOfOwnClassInfo(metaObject, key);
908 return (index == -1) ? defaultValue
909 : QTypeRevision::fromEncodedVersion(
910 QLatin1StringView(metaObject->classInfo(index).value()).toInt());
916 bool defaultValue =
false)
918 const int index = indexOfOwnClassInfo(metaObject, key);
921 return qstrcmp(metaObject->classInfo(index).value(),
"true") == 0;
973 static constexpr bool Value =
false;
987 static constexpr bool Value =
false;
1013 template<
class T,
class =
std::
void_t<>>
1027 template<
class T,
class =
std::
void_t<>>
1039 template<
class T,
typename =
std::
void_t<>>
1056 if constexpr (!
std::is_default_constructible_v<T>)
1058 else if constexpr (std::is_base_of_v<QObject, T>)
1061 return std::is_copy_constructible_v<T>;
1066 if constexpr (std::is_base_of_v<QObject, T>)
1067 return QMetaType::fromType<T*>();
1069 return QMetaType::fromType<T>();
1074 if constexpr (std::is_base_of_v<QObject, T>)
1075 return QMetaType::fromType<QQmlListProperty<T>>();
1077 return QMetaType::fromType<QList<T>>();
1082 if constexpr (std::is_base_of_v<QObject, T>)
1083 return QMetaSequence();
1085 return QMetaSequence::fromContainer<QList<T>>();
1101 static constexpr int size() {
return 0; }
1104 template<
typename T,
typename E,
typename WrapperT = T>
1106 const QMetaObject *classInfoMetaObject,
1107 QVector<
int> *qmlTypeIds,
const QMetaObject *extension)
1109 static_assert(std::is_base_of_v<QObject, T>);
1114 QTypeRevision::fromMajorVersion(versionMajor),
1116 Constructors<T, WrapperT>::createSingletonInstance,
1118 StaticMetaObject<T>::staticMetaObject(),
1119 classInfoMetaObject,
1121 QmlMetaType<T>::self(),
1123 ExtendedType<E>::createParent,
1124 extension ? extension : ExtendedType<E>::staticMetaObject(),
1132 template<
typename T,
typename E>
1134 const QMetaObject *classInfoMetaObject,
1135 QVector<
int> *qmlTypeIds,
const QMetaObject *extension,
1136 bool forceAnonymous =
false)
1140 QmlMetaType<T>::self(),
1141 QmlMetaType<T>::list(),
1142 QmlMetaType<T>::size(),
1143 Constructors<T>::createInto,
1145 ValueType<T, E>::create,
1148 QTypeRevision::fromMajorVersion(versionMajor),
1150 StaticMetaObject<T>::staticMetaObject(),
1151 classInfoMetaObject,
1153 attachedPropertiesFunc<T>(),
1154 attachedPropertiesMetaObject<T>(),
1156 StaticCastSelector<T, QQmlParserStatus>::cast(),
1157 StaticCastSelector<T, QQmlPropertyValueSource>::cast(),
1158 StaticCastSelector<T, QQmlPropertyValueInterceptor>::cast(),
1160 ExtendedType<E>::createParent,
1161 extension ? extension : ExtendedType<E>::staticMetaObject(),
1163 &qmlCreateCustomParser<T>,
1165 StaticCastSelector<T, QQmlFinalizerHook>::cast(),
1168 QmlMetaType<T>::sequence(),
1177 template<
typename T>
1179 const QMetaObject *classInfoMetaObject,
1180 QVector<
int> *qmlTypeIds)
1185 QTypeRevision::fromMajorVersion(versionMajor),
1186 classInfoMetaObject,
1187 QMetaType::fromType<T>(),
1188 QMetaSequence::fromContainer<T>(),
1201 const QtPrivate::QMetaTypeInterface::MetaObjectFn &metaObjectFunction,
const char *name)
1247Q_DECLARE_OPAQUE_POINTER(QQmlV4FunctionPtr)
1248Q_DECLARE_OPAQUE_POINTER(QQmlV4ExecutionEnginePtr)
static void operator delete(void *ptr)
void qmlRegisterTypeAndRevisions(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds, const QMetaObject *extension, bool forceAnonymous=false)
QTypeRevision revisionClassInfo(const QMetaObject *metaObject, const char *key, QTypeRevision defaultValue=QTypeRevision())
QObject * createParent(QObject *p)
A *(*)(QObject *) QQmlAttachedPropertiesFunc
constexpr QtPrivate::QMetaTypeInterface metaTypeForNamespace(const QtPrivate::QMetaTypeInterface::MetaObjectFn &metaObjectFunction, const char *name)
void(*)(void *, void *) CreateIntoFunction
std::is_same< T, typename QmlMarkerFunction< Marker >::ClassType > QmlTypeHasMarker
QObject * createSingletonInstance(QQmlEngine *q, QJSEngine *j)
static int indexOfOwnClassInfo(const QMetaObject *metaObject, const char *key, int startOffset=-1)
void createInto(void *memory, void *)
void qmlRegisterSingletonAndRevisions(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds, const QMetaObject *extension)
Q_QML_EXPORT void qmlRegistrationWarning(QmlRegistrationWarning warning, QMetaType type)
@ CompositeSingletonRegistration
@ SequentialContainerRegistration
@ SequentialContainerAndRevisionsRegistration
@ QmlUnitCacheHookRegistration
@ SingletonAndRevisionsRegistration
@ TypeAndRevisionsRegistration
void qmlRegisterSequenceAndRevisions(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds)
SingletonConstructionMode
void Q_QML_EXPORT qmlRegisterTypeAndRevisions< QQmlTypeNotAvailable, void >(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds, const QMetaObject *, bool)
QQmlAttachedPropertiesFunc< QObject > attachedPropertiesFunc()
@ UnconstructibleSingleton
constexpr SingletonConstructionMode singletonConstructionMode()
const QMetaObject * attachedPropertiesMetaObject()
const char * classInfo(const QMetaObject *metaObject, const char *key)
bool boolClassInfo(const QMetaObject *metaObject, const char *key, bool defaultValue=false)
DECLARE_HEAP_OBJECT(DynamicFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(BoundFunction, JavaScriptFunctionObject)
DECLARE_HEAP_OBJECT(ConstructorFunction, ScriptFunction)
DECLARE_HEAP_OBJECT(FunctionObject, Object)
DECLARE_HEAP_OBJECT(JavaScriptFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(MemberFunction, ArrowFunction)
DECLARE_HEAP_OBJECT(ScriptFunction, ArrowFunction)
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
void(* IRLoaderFunction)(Document *, const QQmlPrivate::CachedQmlUnit *)
size_t qHash(QByteArrayView key, size_t seed) noexcept
QQmlCustomParser * qmlCreateCustomParser()
QV4::ExecutionEngine * QQmlV4ExecutionEnginePtr
QQmlV4Function * QQmlV4FunctionPtr
DEFINE_OBJECT_VTABLE(SharedArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBuffer)
DEFINE_OBJECT_VTABLE(SharedArrayBuffer)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
#define RETURN_UNDEFINED()
void(* functionPtr)(const AOTCompiledContext *context, void **argv)
void(* signature)(QV4::ExecutableCompilationUnit *unit, QMetaType *argTypes)
virtual ~AOTTrackedLocalsStorage()=default
virtual void markObjects(QV4::MarkStack *markStack) const =0
const AOTCompiledFunction * aotCompiledFunctions
const QV4::CompiledData::Unit * qmlData
static constexpr CreateIntoFunction createInto
static constexpr CreateSingletonFunction createSingletonInstance
static constexpr CreateIntoFunction createInto
static constexpr CreateSingletonFunction createSingletonInstance
static constexpr CreateSingletonFunction createSingletonInstance
static constexpr CreateIntoFunction createInto
static constexpr CreateSingletonFunction createSingletonInstance
static constexpr CreateIntoFunction createInto
static const QMetaObject * staticMetaObject()
static constexpr const CreateParentFunction createParent
static constexpr bool value
static constexpr bool Value
static QQmlAttachedPropertiesFunc< QObject > attachedPropertiesFunc()
static const QMetaObject * staticMetaObject()
static Func attachedPropertiesFunc()
static const QMetaObject * staticMetaObject()
static constexpr const QMetaObject * metaObject()
static constexpr bool Value
static constexpr bool Value
static constexpr bool Value
static constexpr bool Value
AutoParentFunction function
QmlUnitCacheLookupFunction lookupCachedQmlUnit
QVector< int > * qmlTypeIds
const QMetaObject * classInfoMetaObject
QMetaSequence metaSequence
QMetaSequence metaSequence
const QMetaObject * instanceMetaObject
const QMetaObject * classInfoMetaObject
std::function< QObject *(QQmlEngine *, QJSEngine *)> qObjectApi
const QMetaObject * extensionMetaObject
QVector< int > * qmlTypeIds
QObject *(* extensionObjectCreate)(QObject *)
std::function< QObject *(QQmlEngine *, QJSEngine *)> qObjectApi
QObject *(* extensionObjectCreate)(QObject *)
std::function< QJSValue(QQmlEngine *, QJSEngine *)> scriptApi
const QMetaObject * extensionMetaObject
const QMetaObject * instanceMetaObject
QObject *(* extensionObjectCreate)(QObject *)
QQmlAttachedPropertiesFunc< QObject > attachedPropertiesFunction
QVariant(* createValueType)(const QJSValue &)
const QMetaObject * extensionMetaObject
const QMetaObject * metaObject
void(* create)(void *, void *)
QMetaSequence listMetaSequence
const QMetaObject * classInfoMetaObject
const QMetaObject * attachedPropertiesMetaObject
QVector< int > * qmlTypeIds
QQmlCustomParser * customParser
void(* create)(void *, void *)
QQmlAttachedPropertiesFunc< QObject > attachedPropertiesFunction
QVariant(* createValueType)(const QJSValue &)
const QMetaObject * extensionMetaObject
QObject *(* extensionObjectCreate)(QObject *)
const QMetaObject * metaObject
const QMetaObject * attachedPropertiesMetaObject
bool has(StructVersion v) const
ValueTypeCreationMethod creationMethod
static no_type checkType(...)
static yes_type checkType(To *)
static QVariant create(const QJSValue ¶ms)
static constexpr const CreateValueTypeFunction create
static QVariant create(const QJSValue ¶ms)
static ReturnedValue method_isView(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static void virtualCallWithMetaTypes(const FunctionObject *f, QObject *thisObject, void **a, const QMetaType *types, int argc)
static ReturnedValue virtualCall(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static QQmlRefPointer< ExecutableCompilationUnit > parse(ExecutionEngine *engine, const Value *argv, int argc, Type t=Type_Function)
static ReturnedValue method_bind(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(QV4::ExecutionEngine *engine)
void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name=nullptr)
void init(QV4::ExecutionEngine *engine)
void init(QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call)
void init(QV4::ExecutionEngine *engine)
Heap::InternalClass * classForConstructor() const
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared)