summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-05-12 13:46:17 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-05-16 13:50:52 +0200
commitb3bc19772daae85fe46d875923d3db8a126809f2 (patch)
treea243afbcecd2906a71726e4114e1d28de518ad26
parentdfb11ea64ec71c6598c790861b3464fe4ae2db0c (diff)
downloadqtdeclarative-b3bc19772daae85fe46d875923d3db8a126809f2.tar.gz
V4: Discern between named builtins and optimizations for common types
The named builtins include void and regexp. The optimizations for other types are useful, but should be a separate enum. Change-Id: I06220cf4a6d3449deca89a26c4f5db0e41d32765 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/common/qv4compileddata_p.h89
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp46
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h2
-rw-r--r--src/qml/jsruntime/qv4function.cpp16
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h13
-rw-r--r--src/qml/qml/ftw/qbipointer_p.h2
-rw-r--r--src/qml/qml/qqmlpropertycachecreator.cpp72
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h31
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp93
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h35
10 files changed, 239 insertions, 160 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index db2b027bf0..3a30938de4 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
// Also change the comment behind the number to describe the latest change. This has the added
// benefit that if another patch changes the version too, it will result in a merge conflict, and
// not get removed silently.
-#define QV4_DATA_STRUCTURE_VERSION 0x3B // Add isList flag to method parameters and return types
+#define QV4_DATA_STRUCTURE_VERSION 0x3C // Restructured builtin type enums
class QIODevice;
class QQmlTypeNameCache;
@@ -268,31 +268,48 @@ struct Block
};
static_assert(sizeof(Block) == 12, "Block structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
-enum class BuiltinType : unsigned int {
- Var = 0, Int, Bool, Real, String, Url,
- Time, Date, DateTime, Rect, Point, Size,
- InvalidBuiltin
+enum class NamedBuiltin: unsigned int {
+ Void, Var, Int, Bool, Real, String, Url, DateTime, RegExp
+};
+
+enum class CommonType : unsigned int {
+ // Actual named builtins
+ Void = uint(NamedBuiltin::Void),
+ Var = uint(NamedBuiltin::Var),
+ Int = uint(NamedBuiltin::Int),
+ Bool = uint(NamedBuiltin::Bool),
+ Real = uint(NamedBuiltin::Real),
+ String = uint(NamedBuiltin::String),
+ Url = uint(NamedBuiltin::Url),
+ DateTime = uint(NamedBuiltin::DateTime),
+ RegExp = uint(NamedBuiltin::RegExp),
+
+ // Optimization for very common other types
+ Time, Date, Rect, Point, Size,
+
+ // No type specified or not recognized
+ Invalid
};
struct ParameterType
{
enum Flag {
NoFlag = 0x0,
- Builtin = 0x1,
+ Common = 0x1,
List = 0x2,
};
Q_DECLARE_FLAGS(Flags, Flag);
- void set(Flags flags, quint32 typeNameIndexOrBuiltinType)
+ void set(Flags flags, quint32 typeNameIndexOrCommonType)
{
m_data.set<IsListField>(flags.testFlag(List) ? 1 : 0);
- m_data.set<IndexIsBuiltinTypeField>(flags.testFlag(Builtin) ? 1 : 0);
- m_data.set<TypeNameIndexOrBuiltinTypeField>(typeNameIndexOrBuiltinType);
+ m_data.set<IndexIsCommonTypeField>(flags.testFlag(Common) ? 1 : 0);
+ m_data.set<TypeNameIndexOrCommonTypeField>(typeNameIndexOrCommonType);
}
- bool indexIsBuiltinType() const
+ bool indexIsCommonType() const
{
- return m_data.get<IndexIsBuiltinTypeField>() != 0;
+ return m_data.get<IndexIsCommonTypeField>() != 0;
}
bool isList() const
@@ -300,16 +317,16 @@ struct ParameterType
return m_data.get<IsListField>() != 0;
}
- quint32 typeNameIndexOrBuiltinType() const
+ quint32 typeNameIndexOrCommonType() const
{
- return m_data.get<TypeNameIndexOrBuiltinTypeField>();
+ return m_data.get<TypeNameIndexOrCommonTypeField>();
}
private:
- using IndexIsBuiltinTypeField = quint32_le_bitfield_member<0, 1>;
+ using IndexIsCommonTypeField = quint32_le_bitfield_member<0, 1>;
using IsListField = quint32_le_bitfield_member<1, 1>;
- using TypeNameIndexOrBuiltinTypeField = quint32_le_bitfield_member<2, 30>;
- quint32_le_bitfield_union<IndexIsBuiltinTypeField, IsListField, TypeNameIndexOrBuiltinTypeField> m_data;
+ using TypeNameIndexOrCommonTypeField = quint32_le_bitfield_member<2, 30>;
+ quint32_le_bitfield_union<IndexIsCommonTypeField, IsListField, TypeNameIndexOrCommonTypeField> m_data;
};
static_assert(sizeof(ParameterType) == 4, "ParameterType structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
@@ -748,47 +765,47 @@ static_assert(sizeof(Signal) == 12, "Signal structure needs to have the expected
struct Property
{
private:
- using BuiltinTypeOrTypeNameIndexField = quint32_le_bitfield_member<0, 28>;
+ using CommonTypeOrTypeNameIndexField = quint32_le_bitfield_member<0, 28>;
using IsRequiredField = quint32_le_bitfield_member<28, 1>;
- using IsBuiltinTypeField = quint32_le_bitfield_member<29, 1>;
+ using IsCommonTypeField = quint32_le_bitfield_member<29, 1>;
using IsListField = quint32_le_bitfield_member<30, 1>;
using IsReadOnlyField = quint32_le_bitfield_member<31, 1>;
public:
quint32_le nameIndex;
quint32_le_bitfield_union<
- BuiltinTypeOrTypeNameIndexField,
+ CommonTypeOrTypeNameIndexField,
IsRequiredField,
- IsBuiltinTypeField,
+ IsCommonTypeField,
IsListField,
IsReadOnlyField> data;
Location location;
- void setBuiltinType(BuiltinType t)
+ void setCommonType(CommonType t)
{
- data.set<BuiltinTypeOrTypeNameIndexField>(static_cast<quint32>(t));
- data.set<IsBuiltinTypeField>(true);
+ data.set<CommonTypeOrTypeNameIndexField>(static_cast<quint32>(t));
+ data.set<IsCommonTypeField>(true);
}
- BuiltinType builtinType() const {
- if (data.get<IsBuiltinTypeField>() != 0)
- return BuiltinType(data.get<BuiltinTypeOrTypeNameIndexField>());
- return BuiltinType::InvalidBuiltin;
+ CommonType commonType() const {
+ if (data.get<IsCommonTypeField>() != 0)
+ return CommonType(data.get<CommonTypeOrTypeNameIndexField>());
+ return CommonType::Invalid;
}
- void setCustomType(int nameIndex)
+ void setTypeNameIndex(int nameIndex)
{
- data.set<BuiltinTypeOrTypeNameIndexField>(nameIndex);
- data.set<IsBuiltinTypeField>(false);
+ data.set<CommonTypeOrTypeNameIndexField>(nameIndex);
+ data.set<IsCommonTypeField>(false);
}
- int customType() const
+ int typeNameIndex() const
{
- return data.get<IsBuiltinTypeField>() ? -1 : data.get<BuiltinTypeOrTypeNameIndexField>();
+ return data.get<IsCommonTypeField>() ? -1 : data.get<CommonTypeOrTypeNameIndexField>();
}
- bool isBuiltinType() const { return data.get<IsBuiltinTypeField>(); }
- uint builtinTypeOrTypeNameIndex() const { return data.get<BuiltinTypeOrTypeNameIndexField>(); }
+ bool isCommonType() const { return data.get<IsCommonTypeField>(); }
+ uint commonTypeOrTypeNameIndex() const { return data.get<CommonTypeOrTypeNameIndexField>(); }
bool isList() const { return data.get<IsListField>(); }
void setIsList(bool isList) { data.set<IsListField>(isList); }
@@ -1357,8 +1374,8 @@ struct TypeReferenceMap : QHash<int, TypeReference>
auto prop = obj->propertiesBegin();
auto const propEnd = obj->propertiesEnd();
for ( ; prop != propEnd; ++prop) {
- if (!prop->isBuiltinType()) {
- TypeReference &r = this->add(prop->builtinTypeOrTypeNameIndex(), prop->location);
+ if (!prop->isCommonType()) {
+ TypeReference &r = this->add(prop->commonTypeOrTypeNameIndex(), prop->location);
r.errorWhenNotFound = true;
}
}
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 7bca65bb0a..7a1ea6905a 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -59,7 +59,7 @@ bool Parameter::initType(
QV4::CompiledData::ParameterType::Flag listFlag)
{
auto builtinType = stringToBuiltinType(typeName);
- if (builtinType == QV4::CompiledData::BuiltinType::InvalidBuiltin) {
+ if (builtinType == QV4::CompiledData::CommonType::Invalid) {
if (typeName.isEmpty()) {
paramType->set(listFlag, 0);
return false;
@@ -68,31 +68,33 @@ bool Parameter::initType(
paramType->set(listFlag, typeNameIndex);
} else {
Q_ASSERT(quint32(builtinType) < (1u << 31));
- paramType->set(listFlag | QV4::CompiledData::ParameterType::Builtin,
+ paramType->set(listFlag | QV4::CompiledData::ParameterType::Common,
static_cast<quint32>(builtinType));
}
return true;
}
-QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typeName)
+QV4::CompiledData::CommonType Parameter::stringToBuiltinType(const QString &typeName)
{
static const struct TypeNameToType {
const char *name;
size_t nameLength;
- QV4::CompiledData::BuiltinType type;
+ QV4::CompiledData::CommonType type;
} propTypeNameToTypes[] = {
- { "int", strlen("int"), QV4::CompiledData::BuiltinType::Int },
- { "bool", strlen("bool"), QV4::CompiledData::BuiltinType::Bool },
- { "double", strlen("double"), QV4::CompiledData::BuiltinType::Real },
- { "real", strlen("real"), QV4::CompiledData::BuiltinType::Real },
- { "string", strlen("string"), QV4::CompiledData::BuiltinType::String },
- { "url", strlen("url"), QV4::CompiledData::BuiltinType::Url },
- { "date", strlen("date"), QV4::CompiledData::BuiltinType::DateTime },
- { "rect", strlen("rect"), QV4::CompiledData::BuiltinType::Rect },
- { "point", strlen("point"), QV4::CompiledData::BuiltinType::Point },
- { "size", strlen("size"), QV4::CompiledData::BuiltinType::Size },
- { "variant", strlen("variant"), QV4::CompiledData::BuiltinType::Var },
- { "var", strlen("var"), QV4::CompiledData::BuiltinType::Var }
+ { "void", strlen("void"), QV4::CompiledData::CommonType::Void },
+ { "int", strlen("int"), QV4::CompiledData::CommonType::Int },
+ { "bool", strlen("bool"), QV4::CompiledData::CommonType::Bool },
+ { "double", strlen("double"), QV4::CompiledData::CommonType::Real },
+ { "real", strlen("real"), QV4::CompiledData::CommonType::Real },
+ { "string", strlen("string"), QV4::CompiledData::CommonType::String },
+ { "url", strlen("url"), QV4::CompiledData::CommonType::Url },
+ { "date", strlen("date"), QV4::CompiledData::CommonType::DateTime },
+ { "regexp", strlen("regexp"), QV4::CompiledData::CommonType::RegExp },
+ { "rect", strlen("rect"), QV4::CompiledData::CommonType::Rect },
+ { "point", strlen("point"), QV4::CompiledData::CommonType::Point },
+ { "size", strlen("size"), QV4::CompiledData::CommonType::Size },
+ { "variant", strlen("variant"), QV4::CompiledData::CommonType::Var },
+ { "var", strlen("var"), QV4::CompiledData::CommonType::Var }
};
static const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
sizeof(propTypeNameToTypes[0]);
@@ -103,7 +105,7 @@ QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typ
return t->type;
}
}
- return QV4::CompiledData::BuiltinType::InvalidBuiltin;
+ return QV4::CompiledData::CommonType::Invalid;
}
void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex,
@@ -1091,12 +1093,12 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
property->setIsReadOnly(node->isReadonly());
property->setIsRequired(node->isRequired());
- const QV4::CompiledData::BuiltinType builtinPropertyType
+ const QV4::CompiledData::CommonType builtinPropertyType
= Parameter::stringToBuiltinType(memberType);
- if (builtinPropertyType != QV4::CompiledData::BuiltinType::InvalidBuiltin)
- property->setBuiltinType(builtinPropertyType);
+ if (builtinPropertyType != QV4::CompiledData::CommonType::Invalid)
+ property->setCommonType(builtinPropertyType);
else
- property->setCustomType(registerString(memberType));
+ property->setTypeNameIndex(registerString(memberType));
QStringView typeModifier = node->typeModifier;
if (typeModifier == QLatin1String("list")) {
@@ -1653,7 +1655,7 @@ bool IRBuilder::isStatementNodeScript(QQmlJS::AST::Statement *statement)
bool IRBuilder::isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement)
{
- if (property->isBuiltinType() || property->isList())
+ if (property->isCommonType() || property->isList())
return false;
QQmlJS::AST::ExpressionStatement *exprStmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(statement);
if (!exprStmt)
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index 890c7f088a..4b37f48ab9 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -227,7 +227,7 @@ struct Parameter : public QV4::CompiledData::Parameter
return initType(type, annotationString, idGenerator(annotationString), Flag::NoFlag);
}
- static QV4::CompiledData::BuiltinType stringToBuiltinType(const QString &typeName);
+ static QV4::CompiledData::CommonType stringToBuiltinType(const QString &typeName);
private:
static bool initType(
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 1017ef9cd9..c2f23279ba 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -117,8 +117,8 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit,
ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i].nameIndex]), Attr_NotConfigurable);
if (enforcesSignature
&& !hasTypes
- && formalsIndices[i].type.typeNameIndexOrBuiltinType()
- != quint32(QV4::CompiledData::BuiltinType::InvalidBuiltin)) {
+ && formalsIndices[i].type.typeNameIndexOrCommonType()
+ != quint32(QV4::CompiledData::CommonType::Invalid)) {
hasTypes = true;
}
}
@@ -130,8 +130,8 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit,
return;
if (!hasTypes
- && compiledFunction->returnType.typeNameIndexOrBuiltinType()
- == quint32(QV4::CompiledData::BuiltinType::InvalidBuiltin)) {
+ && compiledFunction->returnType.typeNameIndexOrCommonType()
+ == quint32(QV4::CompiledData::CommonType::Invalid)) {
return;
}
@@ -139,14 +139,14 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit,
QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine->qmlEngine());
auto findMetaType = [&](const CompiledData::ParameterType &param) {
- const quint32 type = param.typeNameIndexOrBuiltinType();
- if (param.indexIsBuiltinType()) {
+ const quint32 type = param.typeNameIndexOrCommonType();
+ if (param.indexIsCommonType()) {
if (param.isList()) {
return QQmlPropertyCacheCreatorBase::listTypeForPropertyType(
- QV4::CompiledData::BuiltinType(type));
+ QV4::CompiledData::CommonType(type));
}
return QQmlPropertyCacheCreatorBase::metaTypeForPropertyType(
- QV4::CompiledData::BuiltinType(type));
+ QV4::CompiledData::CommonType(type));
}
if (type == 0)
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 3f94cc7798..a161d31838 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -15,16 +15,17 @@
// We mean it.
//
+#include <private/qbipointer_p.h>
+#include <private/qintrusivelist_p.h>
+#include <private/qqmldata_p.h>
+#include <private/qv4functionobject_p.h>
+#include <private/qv4lookup_p.h>
+#include <private/qv4value_p.h>
+
#include <QtCore/qglobal.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qpair.h>
#include <QtCore/qhash.h>
-#include <private/qqmldata_p.h>
-#include <private/qintrusivelist_p.h>
-
-#include <private/qv4value_p.h>
-#include <private/qv4functionobject_p.h>
-#include <private/qv4lookup_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qml/ftw/qbipointer_p.h b/src/qml/qml/ftw/qbipointer_p.h
index 4039d6b60d..b06b5bbc01 100644
--- a/src/qml/qml/ftw/qbipointer_p.h
+++ b/src/qml/qml/ftw/qbipointer_p.h
@@ -17,6 +17,8 @@
#include <QtCore/private/qglobal_p.h>
+#include <QtCore/qhashfunctions.h>
+
QT_BEGIN_NAMESPACE
namespace QtPrivate {
diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp
index 4bc903c22e..d71a2d0086 100644
--- a/src/qml/qml/qqmlpropertycachecreator.cpp
+++ b/src/qml/qml/qqmlpropertycachecreator.cpp
@@ -5,47 +5,63 @@
#include <private/qqmlengine_p.h>
+#if QT_CONFIG(regularexpression)
+#include <QtCore/qregularexpression.h>
+#endif
+
QT_BEGIN_NAMESPACE
QAtomicInt QQmlPropertyCacheCreatorBase::classIndexCounter(0);
-QMetaType QQmlPropertyCacheCreatorBase::metaTypeForPropertyType(QV4::CompiledData::BuiltinType type)
+QMetaType QQmlPropertyCacheCreatorBase::metaTypeForPropertyType(QV4::CompiledData::CommonType type)
{
switch (type) {
- case QV4::CompiledData::BuiltinType::Var: return QMetaType::fromType<QVariant>();
- case QV4::CompiledData::BuiltinType::Int: return QMetaType::fromType<int>();
- case QV4::CompiledData::BuiltinType::Bool: return QMetaType::fromType<bool>();
- case QV4::CompiledData::BuiltinType::Real: return QMetaType::fromType<qreal>();
- case QV4::CompiledData::BuiltinType::String: return QMetaType::fromType<QString>();
- case QV4::CompiledData::BuiltinType::Url: return QMetaType::fromType<QUrl>();
- case QV4::CompiledData::BuiltinType::Time: return QMetaType::fromType<QTime>();
- case QV4::CompiledData::BuiltinType::Date: return QMetaType::fromType<QDate>();
- case QV4::CompiledData::BuiltinType::DateTime: return QMetaType::fromType<QDateTime>();
- case QV4::CompiledData::BuiltinType::Rect: return QMetaType::fromType<QRectF>();
- case QV4::CompiledData::BuiltinType::Point: return QMetaType::fromType<QPointF>();
- case QV4::CompiledData::BuiltinType::Size: return QMetaType::fromType<QSizeF>();
- case QV4::CompiledData::BuiltinType::InvalidBuiltin: break;
+ case QV4::CompiledData::CommonType::Void: return QMetaType();
+ case QV4::CompiledData::CommonType::Var: return QMetaType::fromType<QVariant>();
+ case QV4::CompiledData::CommonType::Int: return QMetaType::fromType<int>();
+ case QV4::CompiledData::CommonType::Bool: return QMetaType::fromType<bool>();
+ case QV4::CompiledData::CommonType::Real: return QMetaType::fromType<qreal>();
+ case QV4::CompiledData::CommonType::String: return QMetaType::fromType<QString>();
+ case QV4::CompiledData::CommonType::Url: return QMetaType::fromType<QUrl>();
+ case QV4::CompiledData::CommonType::Time: return QMetaType::fromType<QTime>();
+ case QV4::CompiledData::CommonType::Date: return QMetaType::fromType<QDate>();
+ case QV4::CompiledData::CommonType::DateTime: return QMetaType::fromType<QDateTime>();
+#if QT_CONFIG(regularexpression)
+ case QV4::CompiledData::CommonType::RegExp: return QMetaType::fromType<QRegularExpression>();
+#else
+ case QV4::CompiledData::CommonType::RegExp: return QMetaType();
+#endif
+ case QV4::CompiledData::CommonType::Rect: return QMetaType::fromType<QRectF>();
+ case QV4::CompiledData::CommonType::Point: return QMetaType::fromType<QPointF>();
+ case QV4::CompiledData::CommonType::Size: return QMetaType::fromType<QSizeF>();
+ case QV4::CompiledData::CommonType::Invalid: break;
};
return QMetaType {};
}
-QMetaType QQmlPropertyCacheCreatorBase::listTypeForPropertyType(QV4::CompiledData::BuiltinType type)
+QMetaType QQmlPropertyCacheCreatorBase::listTypeForPropertyType(QV4::CompiledData::CommonType type)
{
switch (type) {
- case QV4::CompiledData::BuiltinType::Var: return QMetaType::fromType<QList<QVariant>>();
- case QV4::CompiledData::BuiltinType::Int: return QMetaType::fromType<QList<int>>();
- case QV4::CompiledData::BuiltinType::Bool: return QMetaType::fromType<QList<bool>>();
- case QV4::CompiledData::BuiltinType::Real: return QMetaType::fromType<QList<qreal>>();
- case QV4::CompiledData::BuiltinType::String: return QMetaType::fromType<QList<QString>>();
- case QV4::CompiledData::BuiltinType::Url: return QMetaType::fromType<QList<QUrl>>();
- case QV4::CompiledData::BuiltinType::Time: return QMetaType::fromType<QList<QTime>>();
- case QV4::CompiledData::BuiltinType::Date: return QMetaType::fromType<QList<QDate>>();
- case QV4::CompiledData::BuiltinType::DateTime: return QMetaType::fromType<QList<QDateTime>>();
- case QV4::CompiledData::BuiltinType::Rect: return QMetaType::fromType<QList<QRectF>>();
- case QV4::CompiledData::BuiltinType::Point: return QMetaType::fromType<QList<QPointF>>();
- case QV4::CompiledData::BuiltinType::Size: return QMetaType::fromType<QList<QSizeF>>();
- case QV4::CompiledData::BuiltinType::InvalidBuiltin: break;
+ case QV4::CompiledData::CommonType::Void: return QMetaType();
+ case QV4::CompiledData::CommonType::Var: return QMetaType::fromType<QList<QVariant>>();
+ case QV4::CompiledData::CommonType::Int: return QMetaType::fromType<QList<int>>();
+ case QV4::CompiledData::CommonType::Bool: return QMetaType::fromType<QList<bool>>();
+ case QV4::CompiledData::CommonType::Real: return QMetaType::fromType<QList<qreal>>();
+ case QV4::CompiledData::CommonType::String: return QMetaType::fromType<QList<QString>>();
+ case QV4::CompiledData::CommonType::Url: return QMetaType::fromType<QList<QUrl>>();
+ case QV4::CompiledData::CommonType::Time: return QMetaType::fromType<QList<QTime>>();
+ case QV4::CompiledData::CommonType::Date: return QMetaType::fromType<QList<QDate>>();
+ case QV4::CompiledData::CommonType::DateTime: return QMetaType::fromType<QList<QDateTime>>();
+#if QT_CONFIG(regularexpression)
+ case QV4::CompiledData::CommonType::RegExp: return QMetaType::fromType<QList<QRegularExpression>>();
+#else
+ case QV4::CompiledData::CommonType::RegExp: return QMetaType();
+#endif
+ case QV4::CompiledData::CommonType::Rect: return QMetaType::fromType<QList<QRectF>>();
+ case QV4::CompiledData::CommonType::Point: return QMetaType::fromType<QList<QPointF>>();
+ case QV4::CompiledData::CommonType::Size: return QMetaType::fromType<QList<QSizeF>>();
+ case QV4::CompiledData::CommonType::Invalid: break;
};
return QMetaType {};
}
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index 99a64802c1..1dcf169ecc 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -66,8 +66,8 @@ struct QQmlPropertyCacheCreatorBase
public:
static QAtomicInt Q_AUTOTEST_EXPORT classIndexCounter;
- static QMetaType metaTypeForPropertyType(QV4::CompiledData::BuiltinType type);
- static QMetaType listTypeForPropertyType(QV4::CompiledData::BuiltinType type);
+ static QMetaType metaTypeForPropertyType(QV4::CompiledData::CommonType type);
+ static QMetaType listTypeForPropertyType(QV4::CompiledData::CommonType type);
static QByteArray createClassNameTypeByUrl(const QUrl &url);
@@ -592,24 +592,25 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(
QTypeRevision propertyTypeVersion = QTypeRevision::zero();
QQmlPropertyData::Flags propertyFlags;
- const QV4::CompiledData::BuiltinType type = p->builtinType();
+ const QV4::CompiledData::CommonType type = p->commonType();
if (p->isList())
propertyFlags.type = QQmlPropertyData::Flags::QListType;
- else if (type == QV4::CompiledData::BuiltinType::Var)
+ else if (type == QV4::CompiledData::CommonType::Var)
propertyFlags.type = QQmlPropertyData::Flags::VarPropertyType;
- if (type != QV4::CompiledData::BuiltinType::InvalidBuiltin) {
+ if (type != QV4::CompiledData::CommonType::Invalid) {
propertyType = p->isList()
? listTypeForPropertyType(type)
: metaTypeForPropertyType(type);
} else {
- Q_ASSERT(!p->isBuiltinType());
+ Q_ASSERT(!p->isCommonType());
QQmlType qmltype;
bool selfReference = false;
- if (!imports->resolveType(stringAt(p->builtinTypeOrTypeNameIndex()), &qmltype, nullptr, nullptr,
- nullptr, QQmlType::AnyRegistrationType, &selfReference)) {
+ if (!imports->resolveType(
+ stringAt(p->commonTypeOrTypeNameIndex()), &qmltype, nullptr, nullptr,
+ nullptr, QQmlType::AnyRegistrationType, &selfReference)) {
return qQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Invalid property type"));
}
@@ -679,19 +680,19 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(
}
template <typename ObjectContainer>
-inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter(const QV4::CompiledData::ParameterType &param,
- QString *customTypeName)
+inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter(
+ const QV4::CompiledData::ParameterType &param, QString *customTypeName)
{
- const quint32 typeId = param.typeNameIndexOrBuiltinType();
- if (param.indexIsBuiltinType()) {
+ const quint32 typeId = param.typeNameIndexOrCommonType();
+ if (param.indexIsCommonType()) {
// built-in type
if (param.isList())
- return listTypeForPropertyType(QV4::CompiledData::BuiltinType(typeId));
- return metaTypeForPropertyType(QV4::CompiledData::BuiltinType(typeId));
+ return listTypeForPropertyType(QV4::CompiledData::CommonType(typeId));
+ return metaTypeForPropertyType(QV4::CompiledData::CommonType(typeId));
}
// lazily resolved type
- const QString typeName = stringAt(param.typeNameIndexOrBuiltinType());
+ const QString typeName = stringAt(param.typeNameIndexOrCommonType());
if (customTypeName)
*customTypeName = typeName;
QQmlType qmltype;
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index c625d2fa20..08e89f7e91 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -588,6 +588,22 @@ QDateTime QQmlVMEMetaObject::readPropertyAsDateTime(int id) const
return v->d()->data().value<QDateTime>();
}
+#if QT_CONFIG(regularexpression)
+QRegularExpression QQmlVMEMetaObject::readPropertyAsRegularExpression(int id) const
+{
+ QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
+ if (!md)
+ return QRegularExpression();
+
+ QV4::Scope scope(engine);
+ QV4::ScopedValue sv(scope, *(md->data() + id));
+ const QV4::VariantObject *v = sv->as<QV4::VariantObject>();
+ if (!v || v->d()->data().userType() != QMetaType::QRegularExpression)
+ return QRegularExpression();
+ return v->d()->data().value<QRegularExpression>();
+}
+#endif
+
QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
@@ -683,7 +699,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
// if we reach this point, propertyCount must have been > 0, and thus compiledObject != nullptr
Q_ASSERT(compiledObject);
const QV4::CompiledData::Property &property = compiledObject->propertyTable()[id];
- const QV4::CompiledData::BuiltinType t = property.builtinType();
+ const QV4::CompiledData::CommonType t = property.commonType();
// the context can be null if accessing var properties from cpp after re-parenting an item.
QQmlEnginePrivate *ep = (ctxt.isNull() || ctxt->engine() == nullptr)
@@ -744,40 +760,48 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
}
} else {
switch (t) {
- case QV4::CompiledData::BuiltinType::Int:
+ case QV4::CompiledData::CommonType::Void:
+ break;
+ case QV4::CompiledData::CommonType::Int:
*reinterpret_cast<int *>(a[0]) = readPropertyAsInt(id);
break;
- case QV4::CompiledData::BuiltinType::Bool:
+ case QV4::CompiledData::CommonType::Bool:
*reinterpret_cast<bool *>(a[0]) = readPropertyAsBool(id);
break;
- case QV4::CompiledData::BuiltinType::Real:
+ case QV4::CompiledData::CommonType::Real:
*reinterpret_cast<double *>(a[0]) = readPropertyAsDouble(id);
break;
- case QV4::CompiledData::BuiltinType::String:
+ case QV4::CompiledData::CommonType::String:
*reinterpret_cast<QString *>(a[0]) = readPropertyAsString(id);
break;
- case QV4::CompiledData::BuiltinType::Url:
+ case QV4::CompiledData::CommonType::Url:
*reinterpret_cast<QUrl *>(a[0]) = readPropertyAsUrl(id);
break;
- case QV4::CompiledData::BuiltinType::Date:
+ case QV4::CompiledData::CommonType::Date:
*reinterpret_cast<QDate *>(a[0]) = readPropertyAsDate(id);
break;
- case QV4::CompiledData::BuiltinType::DateTime:
+ case QV4::CompiledData::CommonType::DateTime:
*reinterpret_cast<QDateTime *>(a[0]) = readPropertyAsDateTime(id);
break;
- case QV4::CompiledData::BuiltinType::Rect:
+ case QV4::CompiledData::CommonType::RegExp:
+#if QT_CONFIG(regularexpression)
+ *reinterpret_cast<QRegularExpression *>(a[0])
+ = readPropertyAsRegularExpression(id);
+#endif
+ break;
+ case QV4::CompiledData::CommonType::Rect:
*reinterpret_cast<QRectF *>(a[0]) = readPropertyAsRectF(id);
break;
- case QV4::CompiledData::BuiltinType::Size:
+ case QV4::CompiledData::CommonType::Size:
*reinterpret_cast<QSizeF *>(a[0]) = readPropertyAsSizeF(id);
break;
- case QV4::CompiledData::BuiltinType::Point:
+ case QV4::CompiledData::CommonType::Point:
*reinterpret_cast<QPointF *>(a[0]) = readPropertyAsPointF(id);
break;
- case QV4::CompiledData::BuiltinType::Time:
+ case QV4::CompiledData::CommonType::Time:
*reinterpret_cast<QTime *>(a[0]) = readPropertyAsTime(id);
break;
- case QV4::CompiledData::BuiltinType::Var:
+ case QV4::CompiledData::CommonType::Var:
if (ep) {
*reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
} else {
@@ -786,7 +810,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
*reinterpret_cast<QVariant *>(a[0]) = QVariant();
}
break;
- case QV4::CompiledData::BuiltinType::InvalidBuiltin:
+ case QV4::CompiledData::CommonType::Invalid:
if (QV4::MemberData *md = propertyAndMethodStorageAsMemberData()) {
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
@@ -855,55 +879,64 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
}
} else {
switch (t) {
- case QV4::CompiledData::BuiltinType::Int:
+ case QV4::CompiledData::CommonType::Void:
+ break;
+ case QV4::CompiledData::CommonType::Int:
needActivate = *reinterpret_cast<int *>(a[0]) != readPropertyAsInt(id);
writeProperty(id, *reinterpret_cast<int *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Bool:
+ case QV4::CompiledData::CommonType::Bool:
needActivate = *reinterpret_cast<bool *>(a[0]) != readPropertyAsBool(id);
writeProperty(id, *reinterpret_cast<bool *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Real:
+ case QV4::CompiledData::CommonType::Real:
needActivate = *reinterpret_cast<double *>(a[0]) != readPropertyAsDouble(id);
writeProperty(id, *reinterpret_cast<double *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::String:
+ case QV4::CompiledData::CommonType::String:
needActivate = *reinterpret_cast<QString *>(a[0]) != readPropertyAsString(id);
writeProperty(id, *reinterpret_cast<QString *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Url:
+ case QV4::CompiledData::CommonType::Url:
needActivate = *reinterpret_cast<QUrl *>(a[0]) != readPropertyAsUrl(id);
writeProperty(id, *reinterpret_cast<QUrl *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Date:
+ case QV4::CompiledData::CommonType::Date:
needActivate = *reinterpret_cast<QDate *>(a[0]) != readPropertyAsDate(id);
writeProperty(id, *reinterpret_cast<QDate *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::DateTime:
+ case QV4::CompiledData::CommonType::DateTime:
needActivate = *reinterpret_cast<QDateTime *>(a[0]) != readPropertyAsDateTime(id);
writeProperty(id, *reinterpret_cast<QDateTime *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Rect:
+ case QV4::CompiledData::CommonType::RegExp:
+#if QT_CONFIG(regularexpression)
+ needActivate = *reinterpret_cast<QRegularExpression *>(a[0])
+ != readPropertyAsRegularExpression(id);
+ writeProperty(id, *reinterpret_cast<QRegularExpression *>(a[0]));
+#endif
+ break;
+ case QV4::CompiledData::CommonType::Rect:
needActivate = *reinterpret_cast<QRectF *>(a[0]) != readPropertyAsRectF(id);
writeProperty(id, *reinterpret_cast<QRectF *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Size:
+ case QV4::CompiledData::CommonType::Size:
needActivate = *reinterpret_cast<QSizeF *>(a[0]) != readPropertyAsSizeF(id);
writeProperty(id, *reinterpret_cast<QSizeF *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Point:
+ case QV4::CompiledData::CommonType::Point:
needActivate = *reinterpret_cast<QPointF *>(a[0]) != readPropertyAsPointF(id);
writeProperty(id, *reinterpret_cast<QPointF *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Time:
+ case QV4::CompiledData::CommonType::Time:
needActivate = *reinterpret_cast<QTime *>(a[0]) != readPropertyAsTime(id);
writeProperty(id, *reinterpret_cast<QTime *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::Var:
+ case QV4::CompiledData::CommonType::Var:
if (ep)
writeProperty(id, *reinterpret_cast<QVariant *>(a[0]));
break;
- case QV4::CompiledData::BuiltinType::InvalidBuiltin:
+ case QV4::CompiledData::CommonType::Invalid:
if (QV4::MemberData *md = propertyAndMethodStorageAsMemberData()) {
QV4::Scope scope(engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
@@ -1118,7 +1151,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index) const
QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) const
{
- Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::BuiltinType::Var);
+ Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].commonType() == QV4::CompiledData::CommonType::Var);
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
@@ -1143,7 +1176,7 @@ QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) const
void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
{
- Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::BuiltinType::Var);
+ Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].commonType() == QV4::CompiledData::CommonType::Var);
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -1204,7 +1237,7 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
{
- if (compiledObject && compiledObject->propertyTable()[id].builtinType() == QV4::CompiledData::BuiltinType::Var) {
+ if (compiledObject && compiledObject->propertyTable()[id].commonType() == QV4::CompiledData::CommonType::Var) {
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
return;
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index f679a2483b..afbe77c4de 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -16,23 +16,25 @@
// We mean it.
//
-#include <QtCore/QMetaObject>
-#include <QtCore/QBitArray>
-#include <QtCore/QPair>
-#include <QtCore/QDate>
-#include <QtCore/qlist.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include "qqmlguard_p.h"
-
-#include <private/qqmlguardedcontextdata_p.h>
#include <private/qbipointer_p.h>
-
+#include <private/qqmlguard_p.h>
+#include <private/qqmlguardedcontextdata_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
#include <private/qv4object_p.h>
#include <private/qv4value_p.h>
-#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+#include <QtCore/private/qobject_p.h>
+
+#if QT_CONFIG(regularexpression)
+#include <QtCore/qregularexpression.h>
+#endif
+
+#include <QtCore/qbitarray.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qpair.h>
QT_BEGIN_NAMESPACE
@@ -201,6 +203,11 @@ public:
QDate readPropertyAsDate(int id) const;
QTime readPropertyAsTime(int id) const;
QDateTime readPropertyAsDateTime(int id) const;
+
+#if QT_CONFIG(regularexpression)
+ QRegularExpression readPropertyAsRegularExpression(int id) const;
+#endif
+
QRectF readPropertyAsRectF(int id) const;
QObject *readPropertyAsQObject(int id) const;
QVector<QQmlGuard<QObject> > *readPropertyAsList(int id) const;