Mercurial > projects > qtd
comparison generator/typesystem.cpp @ 42:eb3b5bbffc8f
CMake: generator is not running multiple times.
generator: packages can have dependencies now (but this do not used in real code yet).
author | SokoL_SD |
---|---|
date | Sun, 17 May 2009 15:53:27 +0000 |
parents | a9626891eca6 |
children | 3cb15c92ac28 |
comparison
equal
deleted
inserted
replaced
41:691e68637348 | 42:eb3b5bbffc8f |
---|---|
93 TemplateInstanceEnum = 0xe00, | 93 TemplateInstanceEnum = 0xe00, |
94 Replace = 0xf00, | 94 Replace = 0xf00, |
95 SimpleMask = 0xf00, | 95 SimpleMask = 0xf00, |
96 // qtd stuff | 96 // qtd stuff |
97 AddClass = 0x1100, | 97 AddClass = 0x1100, |
98 PackageDepend = 0x1200, | |
98 | 99 |
99 // Code snip tags (0x1000, 0x2000, ... , 0xf000) | 100 // Code snip tags (0x1000, 0x2000, ... , 0xf000) |
100 InjectCode = 0x1000, | 101 InjectCode = 0x1000, |
101 InjectCodeInFunction = 0x2000, | 102 InjectCodeInFunction = 0x2000, |
102 CodeSnipMask = 0xf000, | 103 CodeSnipMask = 0xf000, |
179 tagNames["no-null-pointer"] = StackElement::NoNullPointers; | 180 tagNames["no-null-pointer"] = StackElement::NoNullPointers; |
180 tagNames["reference-count"] = StackElement::ReferenceCount; | 181 tagNames["reference-count"] = StackElement::ReferenceCount; |
181 // qtd | 182 // qtd |
182 tagNames["add-class"] = StackElement::AddClass; | 183 tagNames["add-class"] = StackElement::AddClass; |
183 tagNames["store-result"] = StackElement::StoreResult; | 184 tagNames["store-result"] = StackElement::StoreResult; |
185 | |
186 tagNames["package-depend"] = StackElement::PackageDepend; | |
184 } | 187 } |
185 | 188 |
186 bool startElement(const QString &namespaceURI, const QString &localName, | 189 bool startElement(const QString &namespaceURI, const QString &localName, |
187 const QString &qName, const QXmlAttributes &atts); | 190 const QString &qName, const QXmlAttributes &atts); |
188 bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); | 191 bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); |
215 FieldModificationList m_field_mods; | 218 FieldModificationList m_field_mods; |
216 | 219 |
217 QHash<QString, StackElement::ElementType> tagNames; | 220 QHash<QString, StackElement::ElementType> tagNames; |
218 | 221 |
219 QString m_source_dir; | 222 QString m_source_dir; |
223 QStringList m_defaultDepends; | |
220 }; | 224 }; |
221 | 225 |
222 bool Handler::error(const QXmlParseException &e) | 226 bool Handler::error(const QXmlParseException &e) |
223 { | 227 { |
224 qWarning("Error: line=%d, column=%d, message=%s\n", | 228 qWarning("Error: line=%d, column=%d, message=%s\n", |
563 new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), | 567 new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), |
564 names.last()); | 568 names.last()); |
565 element->entry = m_current_enum; | 569 element->entry = m_current_enum; |
566 m_current_enum->setCodeGeneration(m_generate); | 570 m_current_enum->setCodeGeneration(m_generate); |
567 m_current_enum->setTargetLangPackage(m_defaultPackage); | 571 m_current_enum->setTargetLangPackage(m_defaultPackage); |
572 //m_current_enum->setDepends(m_defaultDepends); // For enums its not needed? | |
568 m_current_enum->setUpperBound(attributes["upper-bound"]); | 573 m_current_enum->setUpperBound(attributes["upper-bound"]); |
569 m_current_enum->setLowerBound(attributes["lower-bound"]); | 574 m_current_enum->setLowerBound(attributes["lower-bound"]); |
570 m_current_enum->setForceInteger(convertBoolean(attributes["force-integer"], "force-integer", false)); | 575 m_current_enum->setForceInteger(convertBoolean(attributes["force-integer"], "force-integer", false)); |
571 m_current_enum->setExtensible(convertBoolean(attributes["extensible"], "extensible", false)); | 576 m_current_enum->setExtensible(convertBoolean(attributes["extensible"], "extensible", false)); |
572 | 577 |
631 element->entry = new ValueTypeEntry(name); | 636 element->entry = new ValueTypeEntry(name); |
632 } | 637 } |
633 | 638 |
634 ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry); | 639 ComplexTypeEntry *ctype = static_cast<ComplexTypeEntry *>(element->entry); |
635 ctype->setTargetLangPackage(attributes["package"]); | 640 ctype->setTargetLangPackage(attributes["package"]); |
641 //ctype->setDepends(m_defaultDepends); | |
636 ctype->setDefaultSuperclass(attributes["default-superclass"]); | 642 ctype->setDefaultSuperclass(attributes["default-superclass"]); |
637 ctype->setGenericClass(convertBoolean(attributes["generic-class"], "generic-class", false)); | 643 ctype->setGenericClass(convertBoolean(attributes["generic-class"], "generic-class", false)); |
638 | 644 |
639 // qtd | 645 // qtd |
640 QString wrap = attributes["wrap"]; | 646 QString wrap = attributes["wrap"]; |
681 static_cast<ComplexTypeEntry *>(element->entry)->setTargetType(targetType); | 687 static_cast<ComplexTypeEntry *>(element->entry)->setTargetType(targetType); |
682 | 688 |
683 // ctype->setInclude(Include(Include::IncludePath, ctype->name())); | 689 // ctype->setInclude(Include(Include::IncludePath, ctype->name())); |
684 ctype = ctype->designatedInterface(); | 690 ctype = ctype->designatedInterface(); |
685 if (ctype != 0) | 691 if (ctype != 0) |
692 { | |
686 ctype->setTargetLangPackage(attributes["package"]); | 693 ctype->setTargetLangPackage(attributes["package"]); |
694 ctype->setDepends(m_defaultDepends); | |
695 } | |
687 } | 696 } |
688 break; | 697 break; |
689 default: | 698 default: |
690 Q_ASSERT(false); | 699 Q_ASSERT(false); |
691 }; | 700 }; |
699 bool topLevel = element->type == StackElement::Root | 708 bool topLevel = element->type == StackElement::Root |
700 || element->type == StackElement::SuppressedWarning | 709 || element->type == StackElement::SuppressedWarning |
701 || element->type == StackElement::Rejection | 710 || element->type == StackElement::Rejection |
702 || element->type == StackElement::LoadTypesystem | 711 || element->type == StackElement::LoadTypesystem |
703 || element->type == StackElement::InjectCode | 712 || element->type == StackElement::InjectCode |
704 || element->type == StackElement::Template; | 713 || element->type == StackElement::Template |
714 || element->type == StackElement::PackageDepend; | |
705 | 715 |
706 if (!topLevel && current->type == StackElement::Root) { | 716 if (!topLevel && current->type == StackElement::Root) { |
707 m_error = QString("Tag requires parent: '%1'").arg(tagName); | 717 m_error = QString("Tag requires parent: '%1'").arg(tagName); |
708 return false; | 718 return false; |
709 } | 719 } |
816 attributes["conditional"] = QString(""); | 826 attributes["conditional"] = QString(""); |
817 break; | 827 break; |
818 // qtd | 828 // qtd |
819 case StackElement::AddClass: | 829 case StackElement::AddClass: |
820 attributes["name"] = QString(); | 830 attributes["name"] = QString(); |
831 break; | |
832 case StackElement::PackageDepend: | |
833 attributes["package"] = QString(); | |
821 break; | 834 break; |
822 default: | 835 default: |
823 ; // nada | 836 ; // nada |
824 }; | 837 }; |
825 | 838 |
1442 m_error = "Can only insert replace rules into insert-template."; | 1455 m_error = "Can only insert replace rules into insert-template."; |
1443 return false; | 1456 return false; |
1444 } | 1457 } |
1445 element->parent->value.templateInstance->addReplaceRule(attributes["from"],attributes["to"]); | 1458 element->parent->value.templateInstance->addReplaceRule(attributes["from"],attributes["to"]); |
1446 break; | 1459 break; |
1460 case StackElement::PackageDepend: | |
1461 { | |
1462 QString package = attributes["package"]; | |
1463 if (package.isEmpty()) { | |
1464 m_error = "bad package depend entry"; | |
1465 return false; | |
1466 } | |
1467 m_defaultDepends << package; | |
1468 } | |
1469 break; | |
1447 default: | 1470 default: |
1448 break; // nada | 1471 break; // nada |
1449 }; | 1472 }; |
1450 } | 1473 } |
1451 | 1474 |