summaryrefslogtreecommitdiff
path: root/src/qml/common/qv4compileddata_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/common/qv4compileddata_p.h')
-rw-r--r--src/qml/common/qv4compileddata_p.h89
1 files changed, 53 insertions, 36 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;
}
}