summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h321
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp9
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp34
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h2
7 files changed, 223 insertions, 152 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5a2f3b5..3c6c949 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -561,9 +561,11 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
QDeclarativeCompositeTypeData::TypeReference &tref = unit->types[ii];
QDeclarativeCompiledData::TypeReference ref;
QDeclarativeScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
- if (tref.type)
+ if (tref.type) {
ref.type = tref.type;
- else if (tref.unit) {
+ if (!ref.type->isCreatable())
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), QCoreApplication::translate("QDeclarativeCompiler", "Element is not creatable."));
+ } else if (tref.unit) {
ref.component = tref.unit->toComponent(engine);
if (ref.component->isError()) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 7ce2d0b..1e60df4 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -167,6 +167,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
QDeclarativeItemModule::defineModule();
QDeclarativeUtilModule::defineModule();
QDeclarativeEnginePrivate::defineModule();
+ QDeclarativeValueTypeFactory::registerValueTypes();
}
globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index c41b14f..ec32b35 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -161,155 +161,180 @@ public:
Type type;
unsigned short line;
+
+ struct InitInstruction {
+ int bindingsSize;
+ int parserStatusSize;
+ int contextCache;
+ int compiledBinding;
+ };
+ struct CreateInstruction {
+ int type;
+ int data;
+ int bindingBits;
+ ushort column;
+ };
+ struct StoreMetaInstruction {
+ int data;
+ int aliasData;
+ int propertyCache;
+ };
+ struct SetIdInstruction {
+ int value;
+ int index;
+ };
+ struct AssignValueSourceInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignValueInterceptorInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignBindingInstruction {
+ unsigned int property;
+ int value;
+ short context;
+ short owner;
+ };
+ struct FetchInstruction {
+ int property;
+ };
+ struct FetchValueInstruction {
+ int property;
+ int type;
+ };
+ struct FetchQmlListInstruction {
+ int property;
+ int type;
+ };
+ struct BeginInstruction {
+ int castValue;
+ };
+ struct StoreFloatInstruction {
+ int propertyIndex;
+ float value;
+ };
+ struct StoreDoubleInstruction {
+ int propertyIndex;
+ double value;
+ };
+ struct StoreIntegerInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreBoolInstruction {
+ int propertyIndex;
+ bool value;
+ };
+ struct StoreStringInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreScriptStringInstruction {
+ int propertyIndex;
+ int value;
+ int scope;
+ };
+ struct StoreScriptInstruction {
+ int value;
+ };
+ struct StoreUrlInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreColorInstruction {
+ int propertyIndex;
+ unsigned int value;
+ };
+ struct StoreDateInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreDateTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRealPairInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRectInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreVector3DInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreObjectInstruction {
+ int propertyIndex;
+ };
+ struct AssignCustomTypeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreSignalInstruction {
+ int signalIndex;
+ int value;
+ int context;
+ };
+ struct AssignSignalObjectInstruction {
+ int signal;
+ };
+ struct CreateComponentInstruction {
+ int count;
+ ushort column;
+ int endLine;
+ int metaObject;
+ };
+ struct FetchAttachedInstruction {
+ int id;
+ };
+ struct DeferInstruction {
+ int deferCount;
+ };
+
union {
- struct {
- int bindingsSize;
- int parserStatusSize;
- int contextCache;
- int compiledBinding;
- } init;
- struct {
- int type;
- int data;
- int bindingBits;
- ushort column;
- } create;
- struct {
- int data;
- int aliasData;
- int propertyCache;
- } storeMeta;
- struct {
- int value;
- int index;
- } setId;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueSource;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueInterceptor;
- struct {
- unsigned int property;
- int value;
- short context;
- short owner;
- } assignBinding;
- struct {
- int property;
- int id;
- } assignIdOptBinding;
- struct {
- int property;
- int contextIdx;
- short context;
- short notifyIdx;
- } assignObjPropBinding;
- struct {
- int property;
- } fetch;
- struct {
- int property;
- int type;
- } fetchValue;
- struct {
- int property;
- int type;
- } fetchQmlList;
- struct {
- int castValue;
- } begin;
- struct {
- int propertyIndex;
- float value;
- } storeFloat;
- struct {
- int propertyIndex;
- double value;
- } storeDouble;
- struct {
- int propertyIndex;
- int value;
- } storeInteger;
- struct {
- int propertyIndex;
- bool value;
- } storeBool;
- struct {
- int propertyIndex;
- int value;
- } storeString;
- struct {
- int propertyIndex;
- int value;
- int scope;
- } storeScriptString;
- struct {
- int value;
- } storeScript;
- struct {
- int propertyIndex;
- int value;
- } storeUrl;
- struct {
- int propertyIndex;
- unsigned int value;
- } storeColor;
- struct {
- int propertyIndex;
- int value;
- } storeDate;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeDateTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRealPair;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRect;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeVector3D;
- struct {
- int propertyIndex;
- } storeObject;
- struct {
- int propertyIndex;
- int valueIndex;
- } assignCustomType;
- struct {
- int signalIndex;
- int value;
- int context;
- } storeSignal;
- struct {
- int signal;
- } assignSignalObject;
- struct {
- int count;
- ushort column;
- int endLine;
- int metaObject;
- } createComponent;
- struct {
- int id;
- } fetchAttached;
- struct {
- int deferCount;
- } defer;
+ InitInstruction init;
+ CreateInstruction create;
+ StoreMetaInstruction storeMeta;
+ SetIdInstruction setId;
+ AssignValueSourceInstruction assignValueSource;
+ AssignValueInterceptorInstruction assignValueInterceptor;
+ AssignBindingInstruction assignBinding;
+ FetchInstruction fetch;
+ FetchValueInstruction fetchValue;
+ FetchQmlListInstruction fetchQmlList;
+ BeginInstruction begin;
+ StoreFloatInstruction storeFloat;
+ StoreDoubleInstruction storeDouble;
+ StoreIntegerInstruction storeInteger;
+ StoreBoolInstruction storeBool;
+ StoreStringInstruction storeString;
+ StoreScriptStringInstruction storeScriptString;
+ StoreScriptInstruction storeScript;
+ StoreUrlInstruction storeUrl;
+ StoreColorInstruction storeColor;
+ StoreDateInstruction storeDate;
+ StoreTimeInstruction storeTime;
+ StoreDateTimeInstruction storeDateTime;
+ StoreRealPairInstruction storeRealPair;
+ StoreRectInstruction storeRect;
+ StoreVector3DInstruction storeVector3D;
+ StoreObjectInstruction storeObject;
+ AssignCustomTypeInstruction assignCustomType;
+ StoreSignalInstruction storeSignal;
+ AssignSignalObjectInstruction assignSignalObject;
+ CreateComponentInstruction createComponent;
+ FetchAttachedInstruction fetchAttached;
+ DeferInstruction defer;
};
void dump(QDeclarativeCompiledData *);
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index abbb9d6..50ab56b 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -286,6 +286,11 @@ QDeclarativeCustomParser *QDeclarativeType::customParser() const
return d->m_customParser;
}
+bool QDeclarativeType::isCreatable() const
+{
+ return d->m_newFunc != 0;
+}
+
bool QDeclarativeType::isInterface() const
{
return d->m_isInterface;
@@ -402,7 +407,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
data->types.append(dtype);
data->idToType.insert(dtype->typeId(), dtype);
- data->idToType.insert(dtype->qListTypeId(), dtype);
+ if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
if (!dtype->qmlTypeName().isEmpty())
data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
@@ -414,7 +419,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
if (data->lists.size() <= type.listId)
data->lists.resize(type.listId + 16);
data->objects.setBit(type.typeId, true);
- data->lists.setBit(type.listId, true);
+ if (type.listId) data->lists.setBit(type.listId, true);
return index;
}
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index ec5c045..cf8946d 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -114,6 +114,8 @@ public:
QDeclarativeCustomParser *customParser() const;
+ bool isCreatable() const;
+
bool isInterface() const;
int typeId() const;
int qListTypeId() const;
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 34d3795..c070123 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -41,6 +41,8 @@
#include "qdeclarativevaluetype_p.h"
+#include "qdeclarativemetatype_p.h"
+
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -49,6 +51,32 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_METATYPE(QEasingCurve);
#endif
+template<typename T>
+int qmlRegisterValueTypeEnums(const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()), 0, 0,
+
+ "Qt", 4, 6, qmlName, &T::staticMetaObject,
+
+ 0, 0,
+
+ 0, 0, 0,
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
{
// ### Optimize
@@ -80,6 +108,12 @@ bool QDeclarativeValueTypeFactory::isValueType(int idx)
return false;
}
+void QDeclarativeValueTypeFactory::registerValueTypes()
+{
+ qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>("Easing");
+ qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("Font");
+}
+
QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
{
#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index e69f161..ad2f6c4 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -84,6 +84,8 @@ public:
static bool isValueType(int);
static QDeclarativeValueType *valueType(int);
+ static void registerValueTypes();
+
QDeclarativeValueType *operator[](int idx) const;
private: