summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-18 16:10:01 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-19 13:21:26 (GMT)
commit6cf0ad80bb8a168115772aa5c3b4abec3e372ccc (patch)
tree653e5ca61f01394888122a9d6e6745a6618df7bb /src/tools
parent380b3dbd3ec3de31fb9be72a5cfd02543d291a62 (diff)
downloadQt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.zip
Qt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.tar.gz
Qt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.tar.bz2
moc: Error if the NOTIFY signal is invalid.
Previously, an invalid NOTIFY signal would be silently ignored. Now it throws an error Reviewed-by: Joao Task-number: QTBUG-7684
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/generator.cpp48
-rw-r--r--src/tools/moc/moc.cpp58
-rw-r--r--src/tools/moc/moc.h1
3 files changed, 59 insertions, 48 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 9a982d0..c3bbba1 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -483,54 +483,6 @@ void Generator::generateFunctions(QList<FunctionDef>& list, const char *functype
void Generator::generateProperties()
{
//
- // specify get function, for compatibiliy we accept functions
- // returning pointers, or const char * for QByteArray.
- //
- for (int i = 0; i < cdef->propertyList.count(); ++i) {
- PropertyDef &p = cdef->propertyList[i];
- if (p.read.isEmpty())
- continue;
- for (int j = 0; j < cdef->publicList.count(); ++j) {
- const FunctionDef &f = cdef->publicList.at(j);
- if (f.name != p.read)
- continue;
- if (!f.isConst) // get functions must be const
- continue;
- if (f.arguments.size()) // and must not take any arguments
- continue;
- PropertyDef::Specification spec = PropertyDef::ValueSpec;
- QByteArray tmp = f.normalizedType;
- if (p.type == "QByteArray" && tmp == "const char *")
- tmp = "QByteArray";
- if (tmp.left(6) == "const ")
- tmp = tmp.mid(6);
- if (p.type != tmp && tmp.endsWith('*')) {
- tmp.chop(1);
- spec = PropertyDef::PointerSpec;
- } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
- spec = PropertyDef::ReferenceSpec;
- }
- if (p.type != tmp)
- continue;
- p.gspec = spec;
- break;
- }
- if(!p.notify.isEmpty()) {
- int notifyId = -1;
- for (int j = 0; j < cdef->signalList.count(); ++j) {
- const FunctionDef &f = cdef->signalList.at(j);
- if(f.name != p.notify) {
- continue;
- } else {
- notifyId = j /* Signal indexes start from 0 */;
- break;
- }
- }
- p.notifyId = notifyId;
- }
- }
-
- //
// Create meta data
//
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index ac49d65..2c24165 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -727,6 +727,7 @@ void Moc::parse()
error("Class declarations lacks Q_OBJECT macro.");
checkSuperClasses(&def);
+ checkProperties(&def);
classList += def;
knownQObjectClasses.insert(def.classname);
@@ -1312,5 +1313,62 @@ void Moc::checkSuperClasses(ClassDef *def)
}
}
+void Moc::checkProperties(ClassDef *cdef)
+{
+ //
+ // specify get function, for compatibiliy we accept functions
+ // returning pointers, or const char * for QByteArray.
+ //
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ PropertyDef &p = cdef->propertyList[i];
+ if (p.read.isEmpty())
+ continue;
+ for (int j = 0; j < cdef->publicList.count(); ++j) {
+ const FunctionDef &f = cdef->publicList.at(j);
+ if (f.name != p.read)
+ continue;
+ if (!f.isConst) // get functions must be const
+ continue;
+ if (f.arguments.size()) // and must not take any arguments
+ continue;
+ PropertyDef::Specification spec = PropertyDef::ValueSpec;
+ QByteArray tmp = f.normalizedType;
+ if (p.type == "QByteArray" && tmp == "const char *")
+ tmp = "QByteArray";
+ if (tmp.left(6) == "const ")
+ tmp = tmp.mid(6);
+ if (p.type != tmp && tmp.endsWith('*')) {
+ tmp.chop(1);
+ spec = PropertyDef::PointerSpec;
+ } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
+ spec = PropertyDef::ReferenceSpec;
+ }
+ if (p.type != tmp)
+ continue;
+ p.gspec = spec;
+ break;
+ }
+ if(!p.notify.isEmpty()) {
+ int notifyId = -1;
+ for (int j = 0; j < cdef->signalList.count(); ++j) {
+ const FunctionDef &f = cdef->signalList.at(j);
+ if(f.name != p.notify) {
+ continue;
+ } else {
+ notifyId = j /* Signal indexes start from 0 */;
+ break;
+ }
+ }
+ p.notifyId = notifyId;
+ if (notifyId == -1) {
+ QByteArray msg = "NOTIFY signal '" + p.notify + "' of property '" + p.name
+ + "' does not exist in class " + cdef->classname + ".";
+ error(msg.constData());
+ }
+ }
+ }
+}
+
+
QT_END_NAMESPACE
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 9f349b5..5e47d9a 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -238,6 +238,7 @@ public:
bool testFunctionAttribute(Token tok, FunctionDef *def);
void checkSuperClasses(ClassDef *def);
+ void checkProperties(ClassDef* cdef);
};
inline QByteArray noRef(const QByteArray &type)