diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-25 16:00:47 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-25 16:00:47 (GMT) |
commit | 913ea0d5cdee3a182a811db2bb9440aee679ae08 (patch) | |
tree | 79708faf5c379948eb5aa2f84cb24488a9cb0c4f /src/tools/moc/moc.cpp | |
parent | 5c45c66b1743645b77826ad61508a79eadd48414 (diff) | |
parent | d9dd68c4400c3ca590ea425d6f3d070ea6094099 (diff) | |
download | Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.zip Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.gz Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
qmake/generators/win32/msbuild_objectmodel.cpp
src/declarative/qml/qdeclarativexmlhttprequest.cpp
src/opengl/opengl.pro
src/opengl/qgl_p.h
src/plugins/bearer/connman/qconnmanservice_linux.cpp
tests/auto/qpainter/tst_qpainter.cpp
tools/assistant/tools/assistant/helpviewer_qwv.h
tools/assistant/tools/assistant/openpageswidget.h
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r-- | src/tools/moc/moc.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
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 |