[Uml-devel] kdesdk/umbrello/umbrello/codegenerators

Oliver Kellogg okellogg at users.sourceforge.net
Thu Dec 30 01:38:01 UTC 2004


CVS commit by okellogg: 

Clean up code generation for template parameters.


  M +7 -7      adawriter.cpp   1.38
  M +8 -15     cppwriter.cpp   1.26


--- kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp  #1.37:1.38
@@ -31,8 +31,10 @@
 #include "../classifierlistitem.h"
 #include "../umlclassifierlistitemlist.h"
+#include "../umltemplatelist.h"
 #include "../package.h"
 #include "../association.h"
 #include "../attribute.h"
 #include "../operation.h"
+#include "../template.h"
 #include "../umlnamespace.h"
 
@@ -183,13 +185,11 @@ void AdaWriter::writeClass(UMLClassifier
 
         // Generate generic formals.
-        UMLClassifierListItemList template_params = c->getFilteredList(Uml::ot_Template);
+        UMLTemplateList template_params = c->getTemplateList();
         if (template_params.count()) {
                 ada << getIndent() << "generic" << m_endl;
                 m_indentLevel++;
-                for (UMLClassifierListItemListIt lit(template_params); lit.current(); ++lit) {
-                        UMLClassifierListItem *listItem = lit.current();
-                        // UMLTemplate tmpl = static_cast<UMLTemplate*>(listItem);  // not needed
-                        QString typeName = listItem->getTypeName();
-                        QString formalName = listItem->getName();
+                for (UMLTemplate *t = template_params.first(); t; t = template_params.next()) {
+                        QString formalName = t->getName();
+                        QString typeName = t->getTypeName();
                         if (typeName == "class") {
                                 ada << getIndent() << "type " << formalName << " is tagged private;"
@@ -197,5 +197,5 @@ void AdaWriter::writeClass(UMLClassifier
                         } else {
                                 // Check whether it's a data type.
-                                UMLClassifier *typeObj = listItem->getType();
+                                UMLClassifier *typeObj = t->getType();
                                 if (typeObj == NULL) {
                                         kdError() << "AdaWriter::writeClass(template_param "

--- kdesdk/umbrello/umbrello/codegenerators/cppwriter.cpp  #1.25:1.26
@@ -33,4 +33,6 @@
 #include "../interface.h"
 #include "../operation.h"
+#include "../template.h"
+#include "../umltemplatelist.h"
 #include "../umlclassifierlistitemlist.h"
 #include "../classifierlistitem.h"
@@ -269,21 +271,12 @@ void CppWriter::writeHeaderFile (UMLClas
 
         // Generate template parameters.
-        UMLClassifierListItemList template_params = c->getFilteredList(Uml::ot_Template);
+        UMLTemplateList template_params = c->getTemplateList();
         if (template_params.count()) {
                 h << "template<";
-                for (UMLClassifierListItem *li = template_params.first(); li; ) {
-                        QString formalName = li->getName();
-                        QString typeName = li->getTypeName();
-                        UMLClassifier *typeObj = li->getType();
-                        if (typeName == "class") {
-                                h << "class";
-                        } else if (typeObj == NULL) {
-                                kdError() << "CppWriter::writeClass(" << classifierInfo->className
-                                          << "): typeObj is NULL" << endl;
-                        } else {
-                                h << li->getTypeName();
-                        }
-                        h << " " << formalName;
-                        if ((li = template_params.next()) != NULL)
+                for (UMLTemplate *t = template_params.first(); t; ) {
+                        QString formalName = t->getName();
+                        QString typeName = t->getTypeName();
+                        h << typeName << " " << formalName;
+                        if ((t = template_params.next()) != NULL)
                                 h << ", ";
                 }






More information about the umbrello-devel mailing list