5#ifndef QQMLMETAOBJECT_P_H
6#define QQMLMETAOBJECT_P_H
19#include <private/qqmlpropertycache_p.h>
21#include <QtQml/qtqmlglobal.h>
22#include <QtCore/qvarlengtharray.h>
23#include <QtCore/qmetaobject.h>
33class QQmlEnginePrivate;
38 template<qsizetype Prealloc>
39 using ArgTypeStorage = QVarLengthArray<QMetaType, Prealloc>;
41 inline QQmlMetaObject() =
default;
42 inline QQmlMetaObject(
const QObject *);
43 inline QQmlMetaObject(
const QMetaObject *);
44 inline QQmlMetaObject(
const QQmlPropertyCache::ConstPtr &);
45 inline QQmlMetaObject(
const QQmlMetaObject &);
47 inline QQmlMetaObject &operator=(
const QQmlMetaObject &);
49 inline bool isNull()
const;
51 inline const char *className()
const;
52 inline int propertyCount()
const;
54 inline const QMetaObject *metaObject()
const;
56 QMetaType methodReturnType(
57 const QQmlPropertyData &data, QString *unknownTypeError =
nullptr)
const;
60
61
62
63
64 template<
typename ArgTypeStorage>
65 bool methodParameterTypes(
66 const QQmlPropertyData &data, ArgTypeStorage *argStorage,
67 QString *unknownTypeError =
nullptr)
const
69 Q_ASSERT(_m && data.coreIndex() >= 0);
71 QMetaMethod m = _m->method(data.coreIndex());
72 return methodParameterTypes(m, argStorage, unknownTypeError);
76
77
78
79
80 template<
typename ArgTypeStorage>
81 bool methodReturnAndParameterTypes(
82 const QQmlPropertyData &data, ArgTypeStorage *argStorage,
83 QString *unknownTypeError =
nullptr)
const
85 Q_ASSERT(_m && data.coreIndex() >= 0);
87 QMetaMethod m = _m->method(data.coreIndex());
88 return methodReturnAndParameterTypes(data, m, argStorage, unknownTypeError);
92
93
94
95
96 template<
typename ArgTypeStorage>
97 bool constructorParameterTypes(
98 const QQmlPropertyData &data, ArgTypeStorage *argStorarge,
99 QString *unknownTypeError =
nullptr)
const
101 Q_ASSERT(_m && data.coreIndex() >= 0);
103 QMetaMethod m = _m->constructor(data.coreIndex());
104 return methodParameterTypes(m, argStorarge, unknownTypeError);
108
109
110
111
112 template<
typename ArgTypeStorage>
113 bool constructorReturnAndParameterTypes(
114 const QQmlPropertyData &data, ArgTypeStorage *storage,
115 QString *unknownTypeError =
nullptr)
const
117 Q_ASSERT(_m && data.coreIndex() >= 0);
119 QMetaMethod m = _m->constructor(data.coreIndex());
120 return methodReturnAndParameterTypes(data, m, storage, unknownTypeError);
123 static bool canConvert(
const QQmlMetaObject &from,
const QQmlMetaObject &to)
125 Q_ASSERT(!from.isNull() && !to.isNull());
126 return from.metaObject()->inherits(to.metaObject());
131 static void resolveGadgetMethodOrPropertyIndex(
132 QMetaObject::Call type,
const QMetaObject **metaObject,
int *index);
134 template<
typename ArgTypeStorage>
135 static bool methodParameterTypes(
136 const QMetaMethod &method, ArgTypeStorage *argStorage,
137 QString *unknownTypeError =
nullptr)
139 Q_ASSERT(argStorage);
141 const int argc = method.parameterCount();
142 argStorage->resize(argc);
143 for (
int ii = 0; ii < argc; ++ii) {
144 if (!parameterType(method, ii, unknownTypeError,
145 [argStorage](
int ii, QMetaType &&type) {
146 argStorage->operator[](ii) = std::forward<QMetaType>(type);
154 template<
typename ArgTypeStorage>
155 bool methodReturnAndParameterTypes(
156 const QQmlPropertyData &data,
const QMetaMethod &method, ArgTypeStorage *argStorage,
157 QString *unknownTypeError =
nullptr)
const
159 Q_ASSERT(argStorage);
161 const int argc = method.parameterCount();
162 argStorage->resize(argc + 1);
164 QMetaType type = methodReturnType(data, unknownTypeError);
168 argStorage->operator[](0) = type;
170 for (
int ii = 0; ii < argc; ++ii) {
172 method, ii, unknownTypeError, [argStorage](
int ii, QMetaType &&type) {
173 argStorage->operator[](ii + 1) = std::forward<QMetaType>(type);
183 template<
typename Store>
184 static bool parameterType(
185 const QMetaMethod &method,
int ii, QString *unknownTypeError,
const Store &store)
187 QMetaType type = method.parameterMetaType(ii);
190 if (type.flags().testFlag(QMetaType::IsEnumeration))
191 type = type.underlyingType();
193 if (!type.isValid()) {
194 if (unknownTypeError)
195 *unknownTypeError = QLatin1String(
"Unknown method parameter type: ")
196 + QString::fromUtf8(method.parameterTypeName(ii));
200 store(ii, std::move(type));
205 const QMetaObject *_m =
nullptr;
209QQmlMetaObject::QQmlMetaObject(
const QObject *o)
212 _m = o->metaObject();
215QQmlMetaObject::QQmlMetaObject(
const QMetaObject *m)
220QQmlMetaObject::QQmlMetaObject(
const QQmlPropertyCache::ConstPtr &m)
223 _m = m->createMetaObject();
226QQmlMetaObject::QQmlMetaObject(
const QQmlMetaObject &o)
231QQmlMetaObject &QQmlMetaObject::operator=(
const QQmlMetaObject &o)
237bool QQmlMetaObject::isNull()
const
242const char *QQmlMetaObject::className()
const
246 return metaObject()->className();
249int QQmlMetaObject::propertyCount()
const
253 return metaObject()->propertyCount();
256const 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.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE bool isObjectCompatible(QObject *object, QQmlListReferencePrivate *d)
QQmlListIterator< T > end(QQmlListProperty< T > &list)
QQmlListIterator< T > begin(QQmlListProperty< T > &list)