aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativepropertycache_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-10-11 11:09:17 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-17 01:05:43 +0200
commit063c08ab8230249ad01c1698ba243b9bb3b238e5 (patch)
tree38cd315aaddafc8d3eb93c2acf754d48bba1099c /src/declarative/qml/qdeclarativepropertycache_p.h
parent576e7ae3360632a981177800e758679ee4105950 (diff)
Merge PropertyCache::Data and ValueTypeData
Change-Id: I22cbb159d009151dd77ecbcdad16f27ecb9d6dba Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativepropertycache_p.h')
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h138
1 files changed, 83 insertions, 55 deletions
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index c1610f8db8..f1161b2e6f 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -74,45 +74,48 @@ public:
QDeclarativePropertyCache(QDeclarativeEngine *, const QMetaObject *);
virtual ~QDeclarativePropertyCache();
- struct Data {
- inline Data();
- inline bool operator==(const Data &);
-
+ // We have this somewhat aweful split between RawData and Data so that RawData can be
+ // used in unions. In normal code, you should always use Data which initializes RawData
+ // to an invalid state on construction.
+ struct Data;
+ struct RawData {
enum Flag {
NoFlags = 0x00000000,
+ ValueTypeFlagMask = 0x0000FFFF, // Flags in valueTypeFlags must fit in this mask
// Can apply to all properties, except IsFunction
- IsConstant = 0x00000001, // Has CONST flag
- IsWritable = 0x00000002, // Has WRITE function
- IsResettable = 0x00000004, // Has RESET function
- IsAlias = 0x00000008, // Is a QML alias to another property
- IsFinal = 0x00000010, // Has FINAL flag
- IsDirect = 0x00000020, // Exists on a C++ QMetaObject
+ IsConstant = 0x00000001, // Has CONST flag
+ IsWritable = 0x00000002, // Has WRITE function
+ IsResettable = 0x00000004, // Has RESET function
+ IsAlias = 0x00000008, // Is a QML alias to another property
+ IsFinal = 0x00000010, // Has FINAL flag
+ IsDirect = 0x00000020, // Exists on a C++ QMetaObject
// These are mutualy exclusive
- IsFunction = 0x00000040, // Is an invokable
- IsQObjectDerived = 0x00000080, // Property type is a QObject* derived type
- IsEnumType = 0x00000100, // Property type is an enum
- IsQList = 0x00000200, // Property type is a QML list
- IsQmlBinding = 0x00000400, // Property type is a QDeclarativeBinding*
- IsQJSValue = 0x00000800, // Property type is a QScriptValue
- IsV8Handle = 0x00001000, // Property type is a QDeclarativeV8Handle
- IsVMEProperty = 0x00002000, // Property type is a "var" property of VMEMO
+ IsFunction = 0x00000040, // Is an invokable
+ IsQObjectDerived = 0x00000080, // Property type is a QObject* derived type
+ IsEnumType = 0x00000100, // Property type is an enum
+ IsQList = 0x00000200, // Property type is a QML list
+ IsQmlBinding = 0x00000400, // Property type is a QDeclarativeBinding*
+ IsQJSValue = 0x00000800, // Property type is a QScriptValue
+ IsV8Handle = 0x00001000, // Property type is a QDeclarativeV8Handle
+ IsVMEProperty = 0x00002000, // Property type is a "var" property of VMEMO
+ IsValueTypeVirtual = 0x00004000, // Property is a value type "virtual" property
// Apply only to IsFunctions
- IsVMEFunction = 0x00004000, // Function was added by QML
- HasArguments = 0x00008000, // Function takes arguments
- IsSignal = 0x00010000, // Function is a signal
- IsVMESignal = 0x00020000, // Signal was added by QML
- IsV8Function = 0x00040000, // Function takes QDeclarativeV8Function* args
- IsSignalHandler = 0x00080000, // Function is a signal handler
+ IsVMEFunction = 0x00008000, // Function was added by QML
+ HasArguments = 0x00010000, // Function takes arguments
+ IsSignal = 0x00020000, // Function is a signal
+ IsVMESignal = 0x00040000, // Signal was added by QML
+ IsV8Function = 0x00080000, // Function takes QDeclarativeV8Function* args
+ IsSignalHandler = 0x00100000, // Function is a signal handler
// Internal QDeclarativePropertyCache flags
- NotFullyResolved = 0x00100000 // True if the type data is to be lazily resolved
+ NotFullyResolved = 0x00200000 // True if the type data is to be lazily resolved
};
Q_DECLARE_FLAGS(Flags, Flag)
- Flags getFlags() const { return flags; }
+ Flags getFlags() const { return Flag(flags); }
void setFlags(Flags f) { flags = f; }
bool isValid() const { return coreIndex != -1; }
@@ -131,6 +134,7 @@ public:
bool isQJSValue() const { return flags & IsQJSValue; }
bool isV8Handle() const { return flags & IsV8Handle; }
bool isVMEProperty() const { return flags & IsVMEProperty; }
+ bool isValueTypeVirtual() const { return flags & IsValueTypeVirtual; }
bool isVMEFunction() const { return flags & IsVMEFunction; }
bool hasArguments() const { return flags & HasArguments; }
bool isSignal() const { return flags & IsSignal; }
@@ -144,34 +148,51 @@ public:
};
int coreIndex;
union {
- int notifyIndex; // When !IsFunction
+ int notifyIndex; // When !IsFunction
int relatedIndex; // When IsFunction
};
- uint overrideIndexIsProperty : 1;
- int overrideIndex : 31;
+ union {
+ struct { // When !IsValueTypeVirtual
+ uint overrideIndexIsProperty : 1;
+ signed int overrideIndex : 31;
+ };
+ struct { // When IsValueTypeVirtual
+ quint16 valueTypeFlags; // flags of the access property on the value type proxy object
+ quint8 valueTypePropType; // The QVariant::Type of access property on the value type
+ // proxy object
+ quint8 valueTypeCoreIndex; // The prop index of the access property on the value type
+ //proxy object
+ };
+ };
int revision;
int metaObjectOffset;
+ private:
+ friend struct Data;
+ friend class QDeclarativePropertyCache;
+ quint32 flags;
+ };
+
+ struct Data : public RawData {
+ inline Data();
+ inline Data(const RawData &);
+
+ inline bool operator==(const RawData &);
+
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
void load(const QMetaMethod &);
QString name(QObject *);
QString name(const QMetaObject *);
+ // Returns -1 if not a value type virtual property
+ inline int getValueTypeCoreIndex() const;
+
private:
+ friend class QDeclarativePropertyCache;
void lazyLoad(const QMetaProperty &, QDeclarativeEngine *engine = 0);
void lazyLoad(const QMetaMethod &);
bool notFullyResolved() const { return flags & NotFullyResolved; }
- friend class QDeclarativePropertyCache;
- Flags flags;
- };
-
- struct ValueTypeData {
- inline ValueTypeData();
- inline bool operator==(const ValueTypeData &);
- Data::Flags flags; // flags of the access property on the value type proxy object
- int valueTypeCoreIdx; // The prop index of the access property on the value type proxy object
- int valueTypePropType; // The QVariant::Type of access property on the value type proxy object
};
void update(QDeclarativeEngine *, const QMetaObject *);
@@ -235,18 +256,37 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags);
QDeclarativePropertyCache::Data::Data()
-: propType(0), coreIndex(-1), notifyIndex(-1), overrideIndexIsProperty(false), overrideIndex(-1),
- revision(0), metaObjectOffset(-1), flags(0)
{
+ propType = 0;
+ coreIndex = -1;
+ notifyIndex = -1;
+ overrideIndexIsProperty = false;
+ overrideIndex = -1;
+ revision = 0;
+ metaObjectOffset = -1;
+ flags = 0;
}
-bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::Data &other)
+QDeclarativePropertyCache::Data::Data(const QDeclarativePropertyCache::RawData &d)
+{
+ *(static_cast<RawData *>(this)) = d;
+}
+
+bool QDeclarativePropertyCache::Data::operator==(const QDeclarativePropertyCache::RawData &other)
{
return flags == other.flags &&
propType == other.propType &&
coreIndex == other.coreIndex &&
notifyIndex == other.notifyIndex &&
- revision == other.revision;
+ revision == other.revision &&
+ (!isValueTypeVirtual() ||
+ (valueTypeCoreIndex == other.valueTypeCoreIndex &&
+ valueTypePropType == other.valueTypePropType));
+}
+
+int QDeclarativePropertyCache::Data::getValueTypeCoreIndex() const
+{
+ return isValueTypeVirtual()?valueTypeCoreIndex:-1;
}
QDeclarativePropertyCache::Data *
@@ -261,18 +301,6 @@ QDeclarativePropertyCache::overrideData(Data *data) const
return method(data->overrideIndex);
}
-QDeclarativePropertyCache::ValueTypeData::ValueTypeData()
-: flags(QDeclarativePropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0)
-{
-}
-
-bool QDeclarativePropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
-{
- return flags == o.flags &&
- valueTypeCoreIdx == o.valueTypeCoreIdx &&
- valueTypePropType == o.valueTypePropType;
-}
-
bool QDeclarativePropertyCache::isAllowedInRevision(Data *data) const
{
return (data->metaObjectOffset == -1 && data->revision == 0) ||