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(
56 const QQmlPropertyData &data, QString *unknownTypeError =
nullptr)
const;
59
60
61
62
63 template<
typename ArgTypeStorage>
64 bool methodParameterTypes(
65 const QQmlPropertyData &data, ArgTypeStorage *argStorage,
66 QString *unknownTypeError =
nullptr)
const
68 Q_ASSERT(_m && data.coreIndex() >= 0);
70 QMetaMethod m = _m->method(data.coreIndex());
71 return methodParameterTypes(m, argStorage, unknownTypeError);
75
76
77
78
79 template<
typename ArgTypeStorage>
80 bool methodReturnAndParameterTypes(
81 const QQmlPropertyData &data, ArgTypeStorage *argStorage,
82 QString *unknownTypeError =
nullptr)
const
84 Q_ASSERT(_m && data.coreIndex() >= 0);
86 QMetaMethod m = _m->method(data.coreIndex());
87 return methodReturnAndParameterTypes(data, m, argStorage, unknownTypeError);
91
92
93
94
95 template<
typename ArgTypeStorage>
96 bool constructorParameterTypes(
97 const QQmlPropertyData &data, ArgTypeStorage *argStorarge,
98 QString *unknownTypeError =
nullptr)
const
100 Q_ASSERT(_m && data.coreIndex() >= 0);
102 QMetaMethod m = _m->constructor(data.coreIndex());
103 return methodParameterTypes(m, argStorarge, unknownTypeError);
107
108
109
110
111 template<
typename ArgTypeStorage>
112 bool constructorReturnAndParameterTypes(
113 const QQmlPropertyData &data, ArgTypeStorage *storage,
114 QString *unknownTypeError =
nullptr)
const
116 Q_ASSERT(_m && data.coreIndex() >= 0);
118 QMetaMethod m = _m->constructor(data.coreIndex());
119 return methodReturnAndParameterTypes(data, m, storage, unknownTypeError);
122 static bool canConvert(
const QQmlMetaObject &from,
const QQmlMetaObject &to)
124 Q_ASSERT(!from.isNull() && !to.isNull());
125 return from.metaObject()->inherits(to.metaObject());
130 static void resolveGadgetMethodOrPropertyIndex(
131 QMetaObject::Call type,
const QMetaObject **metaObject,
int *index);
133 template<
typename ArgTypeStorage>
134 static bool methodParameterTypes(
135 const QMetaMethod &method, ArgTypeStorage *argStorage,
136 QString *unknownTypeError =
nullptr)
138 Q_ASSERT(argStorage);
140 const int argc = method.parameterCount();
141 argStorage->resize(argc);
142 for (
int ii = 0; ii < argc; ++ii) {
143 if (!parameterType(method, ii, unknownTypeError,
144 [argStorage](
int ii, QMetaType &&type) {
145 argStorage->operator[](ii) = std::forward<QMetaType>(type);
153 template<
typename ArgTypeStorage>
154 bool methodReturnAndParameterTypes(
155 const QQmlPropertyData &data,
const QMetaMethod &method, ArgTypeStorage *argStorage,
156 QString *unknownTypeError =
nullptr)
const
158 Q_ASSERT(argStorage);
160 const int argc = method.parameterCount();
161 argStorage->resize(argc + 1);
163 QMetaType type = methodReturnType(data, unknownTypeError);
167 argStorage->operator[](0) = type;
169 for (
int ii = 0; ii < argc; ++ii) {
171 method, ii, unknownTypeError, [argStorage](
int ii, QMetaType &&type) {
172 argStorage->operator[](ii + 1) = std::forward<QMetaType>(type);
182 template<
typename Store>
183 static bool parameterType(
184 const QMetaMethod &method,
int ii, QString *unknownTypeError,
const Store &store)
186 QMetaType type = method.parameterMetaType(ii);
189 if (type.flags().testFlag(QMetaType::IsEnumeration))
190 type = type.underlyingType();
192 if (!type.isValid()) {
193 if (unknownTypeError)
194 *unknownTypeError = QLatin1String(
"Unknown method parameter type: ")
195 + QString::fromUtf8(method.parameterTypeName(ii));
199 store(ii, std::move(type));
204 const QMetaObject *_m =
nullptr;
208QQmlMetaObject::QQmlMetaObject(
const QObject *o)
211 _m = o->metaObject();
214QQmlMetaObject::QQmlMetaObject(
const QMetaObject *m)
219QQmlMetaObject::QQmlMetaObject(
const QQmlPropertyCache::ConstPtr &m)
222 _m = m->createMetaObject();
225QQmlMetaObject::QQmlMetaObject(
const QQmlMetaObject &o)
230QQmlMetaObject &QQmlMetaObject::operator=(
const QQmlMetaObject &o)
236bool QQmlMetaObject::isNull()
const
241const char *QQmlMetaObject::className()
const
245 return metaObject()->className();
248int QQmlMetaObject::propertyCount()
const
252 return metaObject()->propertyCount();
255const 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)