6#include <private/qqmlengine_p.h>
7#include <private/qqmlbinding_p.h>
8#include <private/qqmlvmemetaobject_p.h>
10#include <private/qmetaobject_p.h>
11#include <private/qmetaobjectbuilder_p.h>
12#include <private/qqmlpropertycachemethodarguments_p.h>
14#include <private/qv4value_p.h>
16#include <QtCore/qdebug.h>
17#include <QtCore/QCryptographicHash>
18#include <QtCore/private/qtools_p.h>
25# pragma warning( disable : 4200 )
30#define Q_INT16_MAX 32767
46 flags.setIsWritable(
p.isWritable());
47 flags.setIsResettable(
p.isResettable());
48 flags.setIsFinal(
p.isFinal());
49 flags.setIsRequired(
p.isRequired());
50 flags.setIsBindable(
p.isBindable());
56 flags.type = QQmlPropertyData::Flags::EnumType;
58 flags.type = QQmlPropertyData::Flags::QObjectDerivedType;
60 flags.type = QQmlPropertyData::Flags::QVariantType;
63 }
else if (
propType == qMetaTypeId<QJSValue>()) {
64 flags.type = QQmlPropertyData::Flags::QJSValueType;
66 flags.type = QQmlPropertyData::Flags::QListType;
74 Q_ASSERT(
p.revision() <= std::numeric_limits<quint16>::max());
90 m_flags.
type = Flags::FunctionType;
99 const int paramCount =
m.parameterCount();
102 if ((paramCount == 1) && (
m.parameterMetaType(0) == QMetaType::fromType<QQmlV4Function *>()))
109 Q_ASSERT(
m.revision() <= std::numeric_limits<quint16>::max());
138 for (
int metaObjectOffset = 0; metaObjectOffset <
result->allowedRevisionCache.size();
139 ++metaObjectOffset) {
140 result->allowedRevisionCache[metaObjectOffset] = metaObjectRevision;
166 cache->_parent.reset(
this);
167 cache->propertyIndexCacheStart = propertyIndexCache.
size() + propertyIndexCacheStart;
168 cache->methodIndexCacheStart = methodIndexCache.
size() + methodIndexCacheStart;
169 cache->signalHandlerIndexCacheStart = signalHandlerIndexCache.
size() + signalHandlerIndexCacheStart;
170 cache->stringCache.linkAndReserve(stringCache,
reserve);
171 cache->allowedRevisionCache = allowedRevisionCache;
172 cache->_defaultPropertyName = _defaultPropertyName;
173 cache->_listPropertyAssignBehavior = _listPropertyAssignBehavior;
180 return copy(_metaObject, 0);
184 int propertyCount,
int methodCount,
int signalCount,
int enumCount)
const
191 rv->enumCache.reserve(enumCount);
205 data.setPropType(propType);
206 data.setCoreIndex(coreIndex);
207 data.setNotifyIndex(notifyIndex);
209 data.setTypeVersion(version);
211 const OverrideResult overrideResult = handleOverride(
name, &
data);
212 if (overrideResult == InvalidOverride)
227 data.setCoreIndex(coreIndex);
229 data.setArguments(
nullptr);
235 const auto argumentCount =
names.size();
242 const OverrideResult overrideResult = handleOverride(
name, &
data);
243 if (overrideResult == InvalidOverride)
246 int methodIndex = methodIndexCache.
size();
249 int signalHandlerIndex = signalHandlerIndexCache.
size();
250 signalHandlerIndexCache.
append(handler);
253 handlerName[2] = handlerName.
at(2).
toUpper();
256 setNamedProperty(handlerName, signalHandlerIndex +
signalOffset(),
257 signalHandlerIndexCache.
data() + signalHandlerIndex);
265 int argumentCount =
names.size();
268 data.setPropType(returnType);
269 data.setCoreIndex(coreIndex);
271 const OverrideResult overrideResult = handleOverride(
name, &
data);
272 if (overrideResult == InvalidOverride)
277 for (
int ii = 0; ii < argumentCount; ++ii)
281 int methodIndex = methodIndexCache.
size();
292 enumCache.append(
data);
298 if (_metaObject.
isNull()) {
314 if (
index < propertyIndexCacheStart)
315 return _parent->maybeUnresolvedProperty(
index);
328 if (_parent != newParent)
329 _parent = std::move(newParent);
350 rv->append(
metaObject, typeVersion, propertyFlags, methodFlags, signalFlags);
368 if (classInfoCount) {
370 for (
int ii = 0; ii < classInfoCount; ++ii) {
371 int idx = ii + classInfoOffset;
376 }
else if (0 ==
qstrcmp(
name,
"qt_QmlJSWrapperFactoryMethod")) {
377 const char *
const factoryMethod = mci.
value();
379 if (_jsFactoryMethodIndex != -1)
381 }
else if (0 ==
qstrcmp(
name,
"QML.ListPropertyAssignBehavior")) {
382 _listPropertyAssignBehavior = mci.
value();
388 static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal(
"destroyed(QObject*)");
389 static const int destroyedIdx2 = QObject::staticMetaObject.indexOfSignal(
"destroyed()");
390 static const int deleteLaterIdx = QObject::staticMetaObject.indexOfSlot(
"deleteLater()");
394 const bool preventDestruction = (
metaObject == &QObject::staticMetaObject);
405 if (preventDestruction && (ii == destroyedIdx1 || ii == destroyedIdx2 || ii == deleteLaterIdx))
414 const char *rawName =
m.name().constData();
415 const char *cptr = rawName;
418 utf8 |= *cptr & 0x80;
428 data->setFlags(methodFlags);
433 data->setMetaObjectOffset(allowedRevisionCache.
size() - 1);
435 if (
data->isSignal()) {
436 sigdata = &signalHandlerIndexCache[signalHandlerIndex - signalHandlerIndexCacheStart];
446 if (handleOverride(
methodName,
data, (old =
it->second)) == InvalidOverride)
451 if (
data->isSignal()) {
453 setNamedProperty(on, ii, sigdata);
454 ++signalHandlerIndex;
459 if (handleOverride(
methodName,
data, (old =
it->second)) == InvalidOverride)
464 if (
data->isSignal()) {
472 memcpy(&
str[3], &rawName[1],
length - 1);
476 setNamedProperty(on, ii,
data);
477 ++signalHandlerIndex;
484 data->m_flags.setIsOverload(
true);
494 for (
int ii = propOffset; ii <
propCount; ++ii) {
496 if (!
p.isScriptable())
499 const char *
str =
p.name();
501 const char *cptr =
str;
503 utf8 |= *cptr & 0x80;
509 data->setFlags(propertyFlags);
511 data->setTypeVersion(typeVersion);
514 data->setMetaObjectOffset(allowedRevisionCache.
size() - 1);
521 if (handleOverride(propName,
data, (old =
it->second)) == InvalidOverride)
524 setNamedProperty(propName, ii,
data);
528 if (handleOverride(propName,
data, (old =
it->second)) == InvalidOverride)
531 setNamedProperty(propName, ii,
data);
534 bool isGadget =
true;
536 if (
it == &QObject::staticMetaObject)
557 propertyIndexCache.
reserve(pc - propertyIndexCacheStart);
558 methodIndexCache.
reserve(mc - methodIndexCacheStart);
559 signalHandlerIndexCache.
reserve(sc - signalHandlerIndexCacheStart);
563 stringCache.reserve(pc + mc + sc);
575 propertyIndexCache.
clear();
576 methodIndexCache.
clear();
577 signalHandlerIndexCache.
clear();
579 argumentsCache =
nullptr;
587 propertyIndexCacheStart =
parent()->propertyIndexCache.size() +
parent()->propertyIndexCacheStart;
588 methodIndexCacheStart =
parent()->methodIndexCache.size() +
parent()->methodIndexCacheStart;
589 signalHandlerIndexCacheStart =
parent()->signalHandlerIndexCache.size() +
parent()->signalHandlerIndexCacheStart;
593 propertyIndexCacheStart = 0;
594 methodIndexCacheStart = 0;
595 signalHandlerIndexCacheStart = 0;
601 StringCache::ConstIterator
it,
QObject *
object,
606 if (
data &&
data->hasVMEMetaObject) {
623inline int maximumIndexForProperty(
const QQmlPropertyData *prop,
const int methodCount,
const int signalCount,
const int propertyCount)
728 args->next = argumentsCache;
729 argumentsCache =
args;
735 bool unnamedParameter =
false;
740 if (
count > std::numeric_limits<quint16>::max())
747 if (
param.isEmpty()) {
748 unnamedParameter =
true;
749 }
else if (unnamedParameter) {
800 static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal(
"destroyed(QObject*)");
801 static const int destroyedIdx2 = QObject::staticMetaObject.indexOfSignal(
"destroyed()");
802 static const int deleteLaterIdx = QObject::staticMetaObject.indexOfSlot(
"deleteLater()");
804 const bool preventDestruction =
metaObject->superClass() ||
metaObject == &QObject::staticMetaObject;
807 for (
int ii = methodCount - 1; ii >= 0; --ii) {
808 if (preventDestruction && (ii == destroyedIdx1 || ii == destroyedIdx2 || ii == deleteLaterIdx))
814 if (
m.name() == propertyName) {
826 if (
p.isScriptable()) {
830 bool changed =
false;
837 if (!changed) cmo =
nullptr;
849 return string.data();
854 return string.toUtf8();
859 return string->toQString().toUtf8();
874 cache = newCache.data();
896 return qQmlPropertyCacheProperty<const QV4::String *>(
obj,
name,
context, local);
903 return qQmlPropertyCacheProperty<const QStringView &>(
obj,
name,
context, local);
910 return qQmlPropertyCacheProperty<const QLatin1String &>(
obj,
name,
context, local);
918 const char *
string =
reinterpret_cast<const char *
>(
mo->d.stringdata) +
offset;
925 return mo->className();
934 return lhs.second->coreIndex() < rhs.second->coreIndex();
941 if (
data->isSignalHandler())
944 if (
data->isFunction()) {
945 if (
data->coreIndex() < This->methodIndexCacheStart)
955 if (
data->coreIndex() < This->propertyIndexCacheStart)
982 for (
int ii = 0; ii <
properties.size(); ++ii) {
986 if (
data->notifyIndex() != -1)
987 notifierId =
data->notifyIndex() - signalHandlerIndexCacheStart;
995 property.setWritable(
data->isWritable());
996 property.setResettable(
data->isResettable());
997 property.setBindable(
data->isBindable());
998 property.setAlias(
data->isAlias());
1001 for (
int ii = 0; ii <
methods.size(); ++ii) {
1005 if (
data->propType().isValid())
1006 returnType =
data->propType().name();
1010 signature +=
methods.at(ii).first.toUtf8() +
'(';
1013 if (
data->hasArguments()) {
1018 signature.append(
',');
1019 signature.append(
arguments->types[1 + ii].name());
1023 signature.append(
')');
1026 if (
data->isSignal()) {
1037 method.setReturnType(returnType);
1040 for (
int ii = 0; ii < enumCache.size(); ++ii) {
1044 for (
int jj = 0; jj < enumData.
values.size(); ++jj) {
1050 if (!_defaultPropertyName.
isEmpty()) {
1052 if (dp && dp->
coreIndex() >= propertyIndexCacheStart) {
1058 if (!_listPropertyAssignBehavior.
isEmpty())
1059 builder.
addClassInfo(
"QML.ListPropertyAssignBehavior", _listPropertyAssignBehavior);
1063template <
typename StringVisitor,
typename TypeInfoVisitor>
1064int visitMethods(
const QMetaObject &
mo,
int methodOffset,
int methodCount,
1065 StringVisitor visitString, TypeInfoVisitor visitTypeInfo)
1067 int fieldsForParameterData = 0;
1069 bool hasRevisionedMethods =
false;
1071 for (
int i = 0;
i < methodCount; ++
i) {
1076 hasRevisionedMethods =
true;
1078 visitString(
mo.d.data[
handle + 0]);
1079 visitString(
mo.d.data[
handle + 3]);
1081 const int argc =
mo.d.data[
handle + 1];
1082 const int paramIndex =
mo.d.data[
handle + 2];
1084 fieldsForParameterData += argc * 2;
1085 fieldsForParameterData += 1;
1088 for (
int i = 0;
i < 1 + argc; ++
i) {
1090 visitTypeInfo(
mo.d.data[paramIndex +
i]);
1094 visitString(
mo.d.data[paramIndex + argc +
i]);
1098 int fieldsForRevisions = 0;
1099 if (hasRevisionedMethods)
1100 fieldsForRevisions = methodCount;
1103 + fieldsForRevisions + fieldsForParameterData;
1106template <
typename StringVisitor,
typename TypeInfoVisitor>
1107int visitProperties(
const QMetaObject &
mo, StringVisitor visitString, TypeInfoVisitor visitTypeInfo)
1115 visitTypeInfo(
mo.d.data[
handle + 1]);
1121template <
typename StringVisitor>
1122int visitClassInfo(
const QMetaObject &
mo, StringVisitor visitString)
1125 const int intsPerClassInfo = 2;
1131 visitString(
mo.d.data[
handle + 1]);
1137template <
typename StringVisitor>
1138int visitEnumerations(
const QMetaObject &
mo, StringVisitor visitString)
1147 const uint keyCount = enumeratorData[3];
1148 fieldCount += keyCount * 2;
1150 visitString(enumeratorData[0]);
1151 visitString(enumeratorData[1]);
1153 const uint keyOffset = enumeratorData[4];
1155 for (
uint j = 0;
j < keyCount; ++
j) {
1156 visitString(
mo.d.data[keyOffset + 2 *
j]);
1163template <
typename StringVisitor>
1164int countMetaObjectFields(
const QMetaObject &
mo, StringVisitor stringVisitor)
1168 const auto typeInfoVisitor = [&stringVisitor](
uint typeInfo) {
1180 fieldCount += visitProperties(
mo, stringVisitor, typeInfoVisitor);
1181 fieldCount += visitClassInfo(
mo, stringVisitor);
1182 fieldCount += visitEnumerations(
mo, stringVisitor);
1198 uint highestStringIndex = 0;
1199 const auto stringIndexVisitor = [&highestStringIndex](
uint index) {
1200 highestStringIndex =
qMax(highestStringIndex,
index);
1203 *fieldCount = countMetaObjectFields(
mo, stringIndexVisitor);
1204 *stringCount = highestStringIndex + 1;
1212 int stringCount = 0;
1217 hash.addData({
reinterpret_cast<const char *
>(
mo.d.data),
qsizetype(fieldCount *
sizeof(
uint))});
1218 for (
int i = 0;
i < stringCount; ++
i) {
1242 hash.addData(_parent->checksum(checksums,
ok));
1272 return *
args->names;
1274 return method.parameterNames();
static JNINativeMethod methods[]
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
QChar toUpper() const noexcept
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
ConstIterator end() const
typename QStringHash< T >::template Iterator< ConstIteratorData, const T > ConstIterator
ConstIterator begin() const
T * value(const ConstIterator &iter)
void linkAndReserve(const QLinkedStringHash< T > &other, int additionalReserve)
ConstIterator findNext(const ConstIterator &iter) const
typename QLinkedStringHash< QPair< int, QQmlPropertyData * > >::ConstIterator ConstIterator
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void resize(qsizetype size)
void append(parameter_type t)
QDynamicMetaObjectData * metaObject
static QObjectPrivate * get(QObject *o)
QQmlPropertyCache::ConstPtr propertyCache
static QQmlData * get(QObjectPrivate *priv, bool create)
QQmlRefPointer< QQmlContextData > contextData() const
QByteArray checksum(QHash< quintptr, QByteArray > *checksums, bool *ok) const
static bool addToHash(QCryptographicHash &hash, const QMetaObject &mo)
void invalidate(const QMetaObject *)
QQmlPropertyCache::Ptr copyAndAppend(const QMetaObject *, QTypeRevision typeVersion, QQmlPropertyData::Flags propertyFlags=QQmlPropertyData::Flags(), QQmlPropertyData::Flags methodFlags=QQmlPropertyData::Flags(), QQmlPropertyData::Flags signalFlags=QQmlPropertyData::Flags()) const
QQmlPropertyCache()=default
const QQmlPropertyData * maybeUnresolvedProperty(int) const
void appendSignal(const QString &, QQmlPropertyData::Flags, int coreIndex, const QMetaType *types=nullptr, const QList< QByteArray > &names=QList< QByteArray >())
QQmlRefPointer< QQmlPropertyCache > Ptr
void appendEnum(const QString &, const QVector< QQmlEnumValue > &)
QList< QByteArray > signalParameterNames(int index) const
static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList< QByteArray > ¶meterNameList, QString *errorString=nullptr)
const QQmlPropertyData * property(const K &key, QObject *object, const QQmlRefPointer< QQmlContextData > &context) const
const QQmlPropertyData * overrideData(const QQmlPropertyData *) const
const QQmlPropertyData * defaultProperty() const
QQmlPropertyCache::Ptr copy() const
const QMetaObject * metaObject() const
static bool determineMetaObjectSizes(const QMetaObject &mo, int *fieldCount, int *stringCount)
void setParent(QQmlPropertyCache::ConstPtr newParent)
int propertyOffset() const
int propertyCount() const
QQmlPropertyCache::Ptr copyAndReserve(int propertyCount, int methodCount, int signalCount, int enumCount) const
void update(const QMetaObject *)
void toMetaObjectBuilder(QMetaObjectBuilder &) const
const QQmlPropertyCache::ConstPtr & parent() const
const QMetaObject * firstCppMetaObject() const
void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, QMetaType returnType, const QList< QByteArray > &names, const QVector< QMetaType > ¶meterTypes)
void appendProperty(const QString &, QQmlPropertyData::Flags flags, int coreIndex, QMetaType propType, QTypeRevision revision, int notifyIndex)
const char * className() const
QString defaultPropertyName() const
static Ptr createStandalone(const QMetaObject *, QTypeRevision metaObjectRevision=QTypeRevision::zero())
Creates a standalone QQmlPropertyCache of metaObject.
const QMetaObject * createMetaObject() const
int originalClone(int index) const
bool isOverridden() const
void setRevision(QTypeRevision revision)
void setNotifyIndex(int idx)
bool hasArguments() const
QMetaType propType() const
void setOverrideIndexIsProperty(bool onoff)
void setCoreIndex(int idx)
void setArguments(QQmlPropertyCacheMethodArguments *args)
void setPropType(QMetaType pt)
bool markAsOverrideOf(QQmlPropertyData *predecessor)
void setOverrideIndex(int idx)
QQmlPropertyCacheMethodArguments * arguments() const
static Flags flagsForProperty(const QMetaProperty &)
void load(const QMetaProperty &)
bool isSignalHandler() const
QString name(QObject *) const
QQmlRefPointer< T > & adopt(T *)
Takes ownership of other.
bool contains(const T &value) const
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QChar * data()
Returns a pointer to the data stored in the QString.
QByteArray toUtf8() const &
qsizetype length() const
Returns the number of characters in this string.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
QHash< int, QWidget * > hash
[35multi]
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
QList< QVariant > arguments
Combined button and popup list for selecting options.
constexpr char toAsciiUpper(char ch) noexcept
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
std::pair< T1, T2 > QPair
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static QString methodName(const QDBusIntrospection::Method &method)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
GLenum GLsizei GLsizei GLint * values
[15]
GLuint64 GLenum void * handle
GLsizei GLenum GLenum * types
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const GLint * param
GLenum GLuint GLintptr offset
GLenum GLuint GLsizei propCount
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
const QQmlPropertyData * qQmlPropertyCacheProperty(QObject *obj, T name, const QQmlRefPointer< QQmlContextData > &context, QQmlPropertyData *local)
static const QByteArray stringData(const QMetaObject *mo, int index)
static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const T &propertyName)
static const char * qQmlPropertyCacheToString(QLatin1String string)
static int metaObjectSignalCount(const QMetaObject *metaObject)
QLatin1StringView QLatin1String
obj metaObject() -> className()
\inmodule QtCore \reentrant
QVector< QQmlEnumValue > values
void setIsConstant(bool b)
void setHasArguments(bool b)
void setIsOverridden(bool b)
void setIsV4Function(bool b)
void setIsConstructor(bool b)
void setIsSignalHandler(bool b)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent