aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativepropertycache_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativepropertycache_p.h')
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h77
1 files changed, 50 insertions, 27 deletions
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index 7e34748c6c..69e810aa97 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -57,6 +57,7 @@
#include "private/qdeclarativecleanup_p.h"
#include "private/qdeclarativenotifier_p.h"
+#include "private/qhashedstring_p.h"
#include <QtCore/qvector.h>
#include <QtScript/private/qscriptdeclarativeclass_p.h>
@@ -64,6 +65,8 @@ QT_BEGIN_NAMESPACE
class QDeclarativeEngine;
class QMetaProperty;
+class QV8Engine;
+class QV8QObjectWrapper;
class Q_AUTOTEST_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup
{
@@ -80,29 +83,45 @@ public:
NoFlags = 0x00000000,
// Can apply to all properties, except IsFunction
- IsConstant = 0x00000001,
- IsWritable = 0x00000002,
- IsResettable = 0x00000004,
- IsAlias = 0x00000008,
- IsFinal = 0x00000010,
+ 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 = 0x00000020,
- IsQObjectDerived = 0x00000040,
- IsEnumType = 0x00000080,
- IsQList = 0x00000100,
- IsQmlBinding = 0x00000200,
- IsQScriptValue = 0x00000400,
+ 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*
+ IsQScriptValue = 0x00000800, // Property type is a QScriptValue
+ IsV8Handle = 0x00001000, // Property type is a QDeclarativeV8Handle
// Apply only to IsFunctions
- IsVMEFunction = 0x00000800,
- HasArguments = 0x00001000,
- IsSignal = 0x00002000,
- IsVMESignal = 0x00004000
+ IsVMEFunction = 0x00002000, // Function was added by QML
+ HasArguments = 0x00004000, // Function takes arguments
+ IsSignal = 0x00008000, // Function is a signal
+ IsVMESignal = 0x00010000, // Signal was added by QML
+ IsV8Function = 0x00020000 // Function takes QDeclarativeV8Function* args
};
Q_DECLARE_FLAGS(Flags, Flag)
bool isValid() const { return coreIndex != -1; }
+ bool isConstant() const { return flags & IsConstant; }
+ bool isWritable() const { return flags & IsWritable; }
+ bool isResettable() const { return flags & IsResettable; }
+ bool isAlias() const { return flags & IsAlias; }
+ bool isFinal() const { return flags & IsFinal; }
+ bool isDirect() const { return flags & IsDirect; }
+ bool isFunction() const { return flags & IsFunction; }
+ bool isQObject() const { return flags & IsQObjectDerived; }
+ bool isEnum() const { return flags & IsEnumType; }
+ bool isQList() const { return flags & IsQList; }
+ bool isQmlBinding() const { return flags & IsQmlBinding; }
+ bool isQScriptValue() const { return flags & IsQScriptValue; }
+ bool isV8Handle() const { return flags & IsV8Handle; }
Flags flags;
int propType;
@@ -141,7 +160,7 @@ public:
static Data create(const QMetaObject *, const QString &);
- inline Data *property(const QScriptDeclarativeClass::Identifier &id) const;
+ inline Data *property(const QHashedV8String &) const;
Data *property(const QString &) const;
Data *property(int) const;
Data *method(int) const;
@@ -151,22 +170,26 @@ public:
inline bool isAllowedInRevision(Data *) const;
inline QDeclarativeEngine *qmlEngine() const;
- static Data *property(QDeclarativeEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
static Data *property(QDeclarativeEngine *, QObject *, const QString &, Data &);
+ static Data *property(QDeclarativeEngine *, QObject *, const QHashedV8String &, Data &);
+ static bool isDynamicMetaObject(const QMetaObject *);
protected:
virtual void clear();
private:
friend class QDeclarativeEnginePrivate;
+ friend class QV8QObjectWrapper;
+ // Implemented in v8/qv8qobjectwrapper.cpp
+ v8::Local<v8::Object> newQObject(QObject *, QV8Engine *);
+
+ // XXX is this worth it anymore?
struct RData : public Data, public QDeclarativeRefCount {
- QScriptDeclarativeClass::PersistentIdentifier identifier;
};
typedef QVector<RData *> IndexCache;
- typedef QHash<QString, RData *> StringCache;
- typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache;
+ typedef QStringHash<RData *> StringCache;
typedef QVector<int> AllowedRevisionCache;
void updateRecur(QDeclarativeEngine *, const QMetaObject *);
@@ -175,8 +198,8 @@ private:
IndexCache indexCache;
IndexCache methodIndexCache;
StringCache stringCache;
- IdentifierCache identifierCache;
AllowedRevisionCache allowedRevisionCache;
+ v8::Persistent<v8::Function> constructor;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyCache::Data::Flags);
@@ -207,12 +230,6 @@ QDeclarativePropertyCache::overrideData(Data *data) const
return methodIndexCache.at(data->overrideIndex);
}
-QDeclarativePropertyCache::Data *
-QDeclarativePropertyCache::property(const QScriptDeclarativeClass::Identifier &id) const
-{
- return identifierCache.value(id);
-}
-
QDeclarativePropertyCache::ValueTypeData::ValueTypeData()
: flags(QDeclarativePropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0)
{
@@ -236,6 +253,12 @@ QDeclarativeEngine *QDeclarativePropertyCache::qmlEngine() const
return engine;
}
+QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(const QHashedV8String &str) const
+{
+ QDeclarativePropertyCache::RData **rv = stringCache.value(str);
+ return rv?*rv:0;
+}
+
QT_END_NAMESPACE
#endif // QDECLARATIVEPROPERTYCACHE_P_H