Changeset 846 for trunk/src/tools/moc
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/tools/moc/generator.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 174 174 fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData()); 175 175 fprintf(out, "\n // content:\n"); 176 fprintf(out, " %4d, // revision\n", 4);176 fprintf(out, " %4d, // revision\n", 5); 177 177 fprintf(out, " %4d, // classname\n", strreg(cdef->qualified)); 178 178 fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0); … … 483 483 void Generator::generateProperties() 484 484 { 485 //486 // specify get function, for compatibiliy we accept functions487 // returning pointers, or const char * for QByteArray.488 //489 for (int i = 0; i < cdef->propertyList.count(); ++i) {490 PropertyDef &p = cdef->propertyList[i];491 if (p.read.isEmpty())492 continue;493 for (int j = 0; j < cdef->publicList.count(); ++j) {494 const FunctionDef &f = cdef->publicList.at(j);495 if (f.name != p.read)496 continue;497 if (!f.isConst) // get functions must be const498 continue;499 if (f.arguments.size()) // and must not take any arguments500 continue;501 PropertyDef::Specification spec = PropertyDef::ValueSpec;502 QByteArray tmp = f.normalizedType;503 if (p.type == "QByteArray" && tmp == "const char *")504 tmp = "QByteArray";505 if (tmp.left(6) == "const ")506 tmp = tmp.mid(6);507 if (p.type != tmp && tmp.endsWith('*')) {508 tmp.chop(1);509 spec = PropertyDef::PointerSpec;510 } else if (f.type.name.endsWith('&')) { // raw type, not normalized type511 spec = PropertyDef::ReferenceSpec;512 }513 if (p.type != tmp)514 continue;515 p.gspec = spec;516 break;517 }518 if(!p.notify.isEmpty()) {519 int notifyId = -1;520 for (int j = 0; j < cdef->signalList.count(); ++j) {521 const FunctionDef &f = cdef->signalList.at(j);522 if(f.name != p.notify) {523 continue;524 } else {525 notifyId = j /* Signal indexes start from 0 */;526 break;527 }528 }529 p.notifyId = notifyId;530 }531 }532 533 485 // 534 486 // Create meta data -
trunk/src/tools/moc/generator.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/keywords.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/main.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 362 362 363 363 if (autoInclude) { 364 int spos = filename.lastIndexOf(QDir::separator().toLatin1()); 364 365 int ppos = filename.lastIndexOf('.'); 365 moc.noInclude = (ppos >= 0 366 && tolower(filename[ppos + 1]) != 'h' 367 && tolower(filename[ppos + 1]) != QDir::separator().toLatin1() 368 ); 366 // spos >= -1 && ppos > spos => ppos >= 0 367 moc.noInclude = (ppos > spos && tolower(filename[ppos + 1]) != 'h'); 369 368 } 370 369 if (moc.includeFiles.isEmpty()) { -
trunk/src/tools/moc/moc.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 231 231 } 232 232 while (test(CONST) || test(VOLATILE) || test(SIGNED) || test(UNSIGNED) 233 || test(STAR) || test(AND) ) {233 || test(STAR) || test(AND) || test(ANDAND)) { 234 234 type.name += ' '; 235 235 type.name += lexem(); 236 236 if (lookup(0) == AND) 237 237 type.referenceType = Type::Reference; 238 else if (lookup(0) == ANDAND) 239 type.referenceType = Type::RValueReference; 238 240 else if (lookup(0) == STAR) 239 241 type.referenceType = Type::Pointer; … … 726 728 727 729 checkSuperClasses(&def); 730 checkProperties(&def); 728 731 729 732 classList += def; … … 1207 1210 } 1208 1211 } 1212 1213 //when searching commas within the default argument, we should take care of template depth (anglecount) 1214 // unfortunatelly, we do not have enough semantic information to know if '<' is the operator< or 1215 // the beginning of a template type. so we just use heuristics. 1216 int possible = -1; 1217 1209 1218 while (index < symbols.size()) { 1210 1219 Token t = symbols.at(index++).token; … … 1225 1234 && brackCount <= 0 1226 1235 && parenCount <= 0 1227 && (target != RANGLE || angleCount <= 0)) 1236 && (target != RANGLE || angleCount <= 0)) { 1237 if (target != COMMA || angleCount <= 0) 1238 return true; 1239 possible = index; 1240 } 1241 1242 if (target == COMMA && t == EQ && possible != -1) { 1243 index = possible; 1228 1244 return true; 1245 } 1229 1246 1230 1247 if (braceCount < 0 || brackCount < 0 || parenCount < 0 … … 1234 1251 } 1235 1252 } 1253 1254 if(target == COMMA && angleCount != 0 && possible != -1) { 1255 index = possible; 1256 return true; 1257 } 1258 1236 1259 return false; 1237 1260 } … … 1291 1314 } 1292 1315 1316 void Moc::checkProperties(ClassDef *cdef) 1317 { 1318 // 1319 // specify get function, for compatibiliy we accept functions 1320 // returning pointers, or const char * for QByteArray. 1321 // 1322 for (int i = 0; i < cdef->propertyList.count(); ++i) { 1323 PropertyDef &p = cdef->propertyList[i]; 1324 if (p.read.isEmpty()) 1325 continue; 1326 for (int j = 0; j < cdef->publicList.count(); ++j) { 1327 const FunctionDef &f = cdef->publicList.at(j); 1328 if (f.name != p.read) 1329 continue; 1330 if (!f.isConst) // get functions must be const 1331 continue; 1332 if (f.arguments.size()) // and must not take any arguments 1333 continue; 1334 PropertyDef::Specification spec = PropertyDef::ValueSpec; 1335 QByteArray tmp = f.normalizedType; 1336 if (p.type == "QByteArray" && tmp == "const char *") 1337 tmp = "QByteArray"; 1338 if (tmp.left(6) == "const ") 1339 tmp = tmp.mid(6); 1340 if (p.type != tmp && tmp.endsWith('*')) { 1341 tmp.chop(1); 1342 spec = PropertyDef::PointerSpec; 1343 } else if (f.type.name.endsWith('&')) { // raw type, not normalized type 1344 spec = PropertyDef::ReferenceSpec; 1345 } 1346 if (p.type != tmp) 1347 continue; 1348 p.gspec = spec; 1349 break; 1350 } 1351 if(!p.notify.isEmpty()) { 1352 int notifyId = -1; 1353 for (int j = 0; j < cdef->signalList.count(); ++j) { 1354 const FunctionDef &f = cdef->signalList.at(j); 1355 if(f.name != p.notify) { 1356 continue; 1357 } else { 1358 notifyId = j /* Signal indexes start from 0 */; 1359 break; 1360 } 1361 } 1362 p.notifyId = notifyId; 1363 if (notifyId == -1) { 1364 QByteArray msg = "NOTIFY signal '" + p.notify + "' of property '" + p.name 1365 + "' does not exist in class " + cdef->classname + "."; 1366 error(msg.constData()); 1367 } 1368 } 1369 } 1370 } 1371 1372 1293 1373 1294 1374 QT_END_NAMESPACE -
trunk/src/tools/moc/moc.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 struct Type 57 57 { 58 enum ReferenceType { NoReference, Reference, Pointer };58 enum ReferenceType { NoReference, Reference, RValueReference, Pointer }; 59 59 60 60 inline Type() : isVolatile(false), isScoped(false), firstToken(NOTOKEN), referenceType(NoReference) {} … … 239 239 240 240 void checkSuperClasses(ClassDef *def); 241 void checkProperties(ClassDef* cdef); 241 242 }; 242 243 243 244 inline QByteArray noRef(const QByteArray &type) 244 245 { 245 if (type.endsWith('&')) 246 if (type.endsWith('&')) { 247 if (type.endsWith("&&")) 248 return type.left(type.length()-2); 246 249 return type.left(type.length()-1); 250 } 247 251 return type; 248 252 } -
trunk/src/tools/moc/mwerks_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/mwerks_mac.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/outputrevision.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/parser.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/parser.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/ppkeywords.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/preprocessor.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/preprocessor.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/symbols.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/token.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/token.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/util/generate.sh
r651 r846 2 2 ############################################################################# 3 3 ## 4 ## Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).4 ## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 5 5 ## All rights reserved. 6 6 ## Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/util/generate_keywords.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/util/generate_keywords.pro
r2 r846 11 11 SOURCES += generate_keywords.cpp 12 12 CONFIG += qt create_prl link_prl 13 OBJECTS_DIR=.obj/debug-shared -
trunk/src/tools/moc/util/licenseheader.txt
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/tools/moc/utils.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.