4#ifndef QQMLMETAOBJECT_P_H
5#define QQMLMETAOBJECT_P_H
18#include <private/qqmlpropertycache_p.h>
20#include <QtQml/qtqmlglobal.h>
21#include <QtCore/qvarlengtharray.h>
22#include <QtCore/qmetaobject.h>
32class QQmlEnginePrivate;
37 template<qsizetype Prealloc>
38 using ArgTypeStorage = QVarLengthArray<QMetaType, Prealloc>;
40 inline QQmlMetaObject() =
default;
41 inline QQmlMetaObject(
const QObject *);
42 inline QQmlMetaObject(
const QMetaObject *);
43 inline QQmlMetaObject(
const QQmlPropertyCache::ConstPtr &);
44 inline QQmlMetaObject(
const QQmlMetaObject &);
46 inline QQmlMetaObject &operator=(
const QQmlMetaObject &);
48 inline bool isNull()
const;
50 inline const char *className()
const;
51 inline int propertyCount()
const;
53 inline const QMetaObject *metaObject()
const;
55 QMetaType methodReturnType(
const QQmlPropertyData &data, QByteArray *unknownTypeError)
const;
58
59
60
61
62 template<
typename ArgTypeStorage>
63 bool methodParameterTypes(
64 int index, ArgTypeStorage *argStorage, QByteArray *unknownTypeError)
const
66 Q_ASSERT(_m && index >= 0);
68 QMetaMethod m = _m->method(index);
69 return methodParameterTypes(m, argStorage, unknownTypeError);
73
74
75
76
77 template<
typename ArgTypeStorage>
78 bool constructorParameterTypes(
79 int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError)
const
81 QMetaMethod m = _m->constructor(index);
82 return methodParameterTypes(m, dummy, unknownTypeError);
86 static bool canConvert(
const QQmlMetaObject &from,
const QQmlMetaObject &to)
88 Q_ASSERT(!from.isNull() && !to.isNull());
89 return from.metaObject()->inherits(to.metaObject());
94 static void resolveGadgetMethodOrPropertyIndex(
95 QMetaObject::Call type,
const QMetaObject **metaObject,
int *index);
97 template<
typename ArgTypeStorage>
98 static bool methodParameterTypes(
99 const QMetaMethod &method, ArgTypeStorage *argStorage, QByteArray *unknownTypeError)
101 Q_ASSERT(argStorage);
103 const int argc = method.parameterCount();
104 argStorage->resize(argc);
105 for (
int ii = 0; ii < argc; ++ii) {
106 if (!parameterType(method, ii, unknownTypeError, [argStorage](
int ii, QMetaType &&type) {
107 argStorage->operator[](ii) = std::forward<QMetaType>(type);
115 template<
typename ArgTypeStorage>
116 static bool methodReturnAndParameterTypes(
117 const QMetaMethod &method, ArgTypeStorage *argStorage, QByteArray *unknownTypeError)
119 Q_ASSERT(argStorage);
121 const int argc = method.parameterCount();
122 argStorage->resize(argc + 1);
124 QMetaType type = method.returnMetaType();
125 if (type.flags().testFlag(QMetaType::IsEnumeration))
126 type = type.underlyingType();
128 if (!type.isValid()) {
129 if (unknownTypeError)
130 *unknownTypeError =
"return type";
134 argStorage->operator[](0) = type;
136 for (
int ii = 0; ii < argc; ++ii) {
138 method, ii, unknownTypeError, [argStorage](
int ii, QMetaType &&type) {
139 argStorage->operator[](ii + 1) = std::forward<QMetaType>(type);
149 template<
typename Store>
150 static bool parameterType(
151 const QMetaMethod &method,
int ii, QByteArray *unknownTypeError,
const Store &store)
153 QMetaType type = method.parameterMetaType(ii);
156 if (type.flags().testFlag(QMetaType::IsEnumeration))
157 type = type.underlyingType();
159 if (!type.isValid()) {
160 if (unknownTypeError)
161 *unknownTypeError = method.parameterTypeName(ii);
165 store(ii, std::move(type));
170 const QMetaObject *_m =
nullptr;
174QQmlMetaObject::QQmlMetaObject(
const QObject *o)
177 _m = o->metaObject();
180QQmlMetaObject::QQmlMetaObject(
const QMetaObject *m)
185QQmlMetaObject::QQmlMetaObject(
const QQmlPropertyCache::ConstPtr &m)
188 _m = m->createMetaObject();
191QQmlMetaObject::QQmlMetaObject(
const QQmlMetaObject &o)
196QQmlMetaObject &QQmlMetaObject::operator=(
const QQmlMetaObject &o)
202bool QQmlMetaObject::isNull()
const
207const char *QQmlMetaObject::className()
const
211 return metaObject()->className();
214int QQmlMetaObject::propertyCount()
const
218 return metaObject()->propertyCount();
221const QMetaObject *QQmlMetaObject::metaObject()
const
reference operator*() const
pointer(const QQmlListIterator *iter)
QQmlListIterator operator->() const
reference(const QQmlListIterator *iter)
reference(reference &&)=default
reference & operator=(reference &&value)
reference & operator=(const reference &value)
reference & operator=(T *value)
reference(const reference &)=default
friend void swap(reference a, reference b)
friend QQmlListIterator operator+(qsizetype i, const QQmlListIterator &j)
friend bool operator<=(const QQmlListIterator &i, const QQmlListIterator &j)
QQmlListIterator operator-(qsizetype j)
reference operator*() const
friend qsizetype operator-(const QQmlListIterator &i, const QQmlListIterator &j)
pointer operator->() const
friend bool operator==(const QQmlListIterator &a, const QQmlListIterator &b)
QQmlListIterator(QQmlListProperty< T > *list, qsizetype i)
friend bool operator>=(const QQmlListIterator &i, const QQmlListIterator &j)
QQmlListIterator operator+(qsizetype j)
QQmlListIterator & operator++()
friend bool operator>(const QQmlListIterator &i, const QQmlListIterator &j)
friend bool operator<(const QQmlListIterator &i, const QQmlListIterator &j)
QQmlListIterator & operator-=(qsizetype j)
QQmlListIterator operator++(int)
friend bool operator!=(const QQmlListIterator &a, const QQmlListIterator &b)
QQmlListIterator()=default
QQmlListIterator & operator--()
QQmlListIterator & operator+=(qsizetype j)
QQmlListIterator operator--(int)
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
T *(*)(QQmlListProperty< T > *, qsizetype) AtFunction
Synonym for {T *(*)(QQmlListProperty<T> *property, qsizetype index)}.
QQmlListProperty(QObject *o, QList< T * > *list)
bool operator==(const QQmlListProperty &o) const
Returns true if this QQmlListProperty is equal to other, otherwise false.
QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r)
Construct a QQmlListProperty from a set of operation functions append, count, at, and clear.
QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction a)
Construct a readonly QQmlListProperty from a set of operation functions count and at.
void(*)(QQmlListProperty< T > *) RemoveLastFunction
Synonym for {void (*)(QQmlListProperty<T> *property)}.
QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r, ReplaceFunction s, RemoveLastFunction p)
Construct a QQmlListProperty from a set of operation functions append, count, at, clear,...
void(*)(QQmlListProperty< T > *, qsizetype, T *) ReplaceFunction
Synonym for {void (*)(QQmlListProperty<T> *property, qsizetype index, T *value)}.
RemoveLastFunction removeLast
void(*)(QQmlListProperty< T > *, T *) AppendFunction
Synonym for {void (*)(QQmlListProperty<T> *property, T *value)}.
QQmlListProperty()=default
\macro QML_LIST_PROPERTY_ASSIGN_BEHAVIOR_APPEND
void(*)(QQmlListProperty< T > *) ClearFunction
Synonym for {void (*)(QQmlListProperty<T> *property)}.
static QQmlListReference init(const QQmlListProperty< QObject > &, QMetaType)
const QMetaObject * elementType()
QPointer< QObject > object
QQmlListProperty< QObject > property
static QQmlListReferencePrivate * get(QQmlListReference *ref)
QQmlListReferencePrivate()
The QQmlListReference class allows the manipulation of \l QQmlListProperty properties.
static QT_BEGIN_NAMESPACE bool isObjectCompatible(QObject *object, QQmlListReferencePrivate *d)
QQmlListIterator< T > end(QQmlListProperty< T > &list)
QQmlListIterator< T > begin(QQmlListProperty< T > &list)