summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/generator.h
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-08-16 02:19:56 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-28 18:30:32 +0200
commit62c2061a501563e7f2929c5883f01955af0f2fc1 (patch)
tree2a9b5d5a23496c565be38059dbfc7fe42dd92f89 /src/tools/moc/generator.h
parentf29896840ce9e93fde9e7c61b922ef71fa0c5590 (diff)
Add automatic metatype registration for Q_PROPERTY types.
In Qt 4, the user needs to call qRegisterMetaType if the property could otherwise be read before the type is registered with the metatype system. This patch makes that unnecessary and automatic by registering it when the first read indicates that it is not yet registered instead or when QMetaProperty::userType is called before it is registered. The types which are automatically registered exclude the built-in types, which do not need to be registered, and include metatypes which are automatically declared, such as pointers to QObject derived types and containers of existing metatypes. Change-Id: I0a06d8efdcb64121618e2378366d0142fa0771f5 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/tools/moc/generator.h')
-rw-r--r--src/tools/moc/generator.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h
index 8ebc00b100..873681ab88 100644
--- a/src/tools/moc/generator.h
+++ b/src/tools/moc/generator.h
@@ -52,9 +52,10 @@ class Generator
ClassDef *cdef;
QVector<uint> meta_data;
public:
- Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile = 0);
+ Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, const QSet<QByteArray> &knownQObjectClasses, FILE *outfile = 0);
void generateCode();
private:
+ bool registerableMetaType(const QByteArray &propertyType);
void registerClassInfoStrings();
void generateClassInfos();
void registerFunctionStrings(const QList<FunctionDef> &list);
@@ -70,12 +71,14 @@ private:
void generateStaticMetacall();
void generateSignal(FunctionDef *def, int index);
void generatePluginMetaData();
+ QMultiMap<QByteArray, int> automaticPropertyMetaTypesHelper();
void strreg(const QByteArray &); // registers a string
int stridx(const QByteArray &); // returns a string's id
QList<QByteArray> strings;
QByteArray purestSuperClass;
QList<QByteArray> metaTypes;
+ QSet<QByteArray> knownQObjectClasses;
};
QT_END_NAMESPACE