comparison generator/typesystem.cpp @ 361:beaf4a2974d7

Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
author Max Samukha <maxter@maxter.com>
date Wed, 09 Jun 2010 11:08:56 +0300
parents 08c1ca7975ab
children
comparison
equal deleted inserted replaced
360:49d0a43433e7 361:beaf4a2974d7
777 attributes["modifier"] = QString(); 777 attributes["modifier"] = QString();
778 break; 778 break;
779 case StackElement::Include: 779 case StackElement::Include:
780 attributes["file-name"] = QString(); 780 attributes["file-name"] = QString();
781 attributes["location"] = QString(); 781 attributes["location"] = QString();
782 attributes["protection"] = QString();
782 break; 783 break;
783 case StackElement::CustomMetaConstructor: 784 case StackElement::CustomMetaConstructor:
784 attributes["name"] = topElement.entry->name().toLower() + "_create"; 785 attributes["name"] = topElement.entry->name().toLower() + "_create";
785 attributes["param-name"] = "copy"; 786 attributes["param-name"] = "copy";
786 break; 787 break;
1404 locationNames["global"] = Include::IncludePath; 1405 locationNames["global"] = Include::IncludePath;
1405 locationNames["local"] = Include::LocalPath; 1406 locationNames["local"] = Include::LocalPath;
1406 locationNames["java"] = Include::TargetLangImport; 1407 locationNames["java"] = Include::TargetLangImport;
1407 } 1408 }
1408 1409
1410 if (locationNames.isEmpty()) {
1411 locationNames["global"] = Include::IncludePath;
1412 locationNames["local"] = Include::LocalPath;
1413 locationNames["java"] = Include::TargetLangImport;
1414 }
1415
1409 if (!locationNames.contains(location)) { 1416 if (!locationNames.contains(location)) {
1410 m_error = QString("Location not recognized: '%1'").arg(location); 1417 m_error = QString("Location not recognized: '%1'").arg(location);
1411 return false; 1418 return false;
1412 } 1419 }
1413 1420
1414 Include::IncludeType loc = locationNames[location]; 1421 Include::IncludeType loc = locationNames[location];
1415 Include inc(loc, attributes["file-name"]); 1422
1423 QString protection = attributes["protection"];
1424 if (!protection.isEmpty()) {
1425 if (loc != Include::TargetLangImport) {
1426 m_error = QString("Protection attribute is allowed only if 'java' location is specified");
1427 return false;
1428 }
1429
1430 if (protection != "public"
1431 || protection != "private"
1432 || protection != "package") {
1433 m_error = QString("Import protection is not recognized: '%1'").arg(protection);
1434 }
1435 }
1436
1437 Include inc(loc, protection, attributes["file-name"]);
1416 1438
1417 ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry); 1439 ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry);
1418 if (topElement.type & StackElement::ComplexTypeEntryMask) { 1440 if (topElement.type & StackElement::ComplexTypeEntryMask) {
1419 ctype->setInclude(inc); 1441 ctype->setInclude(inc);
1420 } else if (topElement.type == StackElement::ExtraIncludes) { 1442 } else if (topElement.type == StackElement::ExtraIncludes) {
1643 { 1665 {
1644 if (type == IncludePath) 1666 if (type == IncludePath)
1645 return "#include <" + name + '>'; 1667 return "#include <" + name + '>';
1646 else if (type == LocalPath) 1668 else if (type == LocalPath)
1647 return "#include \"" + name + "\""; 1669 return "#include \"" + name + "\"";
1648 else 1670 else {
1649 return "import " + name + ";"; 1671 QString result;
1672 if (!protection.isEmpty())
1673 result += protection + " ";
1674 return result + "import " + name + ";";
1675 }
1650 } 1676 }
1651 1677
1652 QString Modification::accessModifierString() const 1678 QString Modification::accessModifierString() const
1653 { 1679 {
1654 if (isPrivate()) return "private"; 1680 if (isPrivate()) return "private";