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

Oliver Kellogg okellogg at users.sourceforge.net
Sun Nov 9 13:41:11 UTC 2003


CVS commit by okellogg: 

writeClass(): Generate code for UMLEnum.


  M +34 -10    adawriter.cpp   1.15


--- kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp  #1.14:1.15
@@ -29,4 +29,6 @@
 #include "../class.h"
 #include "../enum.h"
+#include "../enumliteral.h"
+#include "../umlenumliterallist.h"
 #include "../package.h"
 #include "../association.h"
@@ -91,15 +93,19 @@ bool AdaWriter::isType (QString & type)
 
 bool AdaWriter::isOOClass(UMLClassifier *c) {
-        QString stype = c->getStereotype();
-        if (stype == "CORBAConstant" ||
-                stype == "CORBAStruct" || stype == "CORBAUnion" ||
-                stype == "CORBATypedef")
+        Uml::UMLObject_Type ot = c->getBaseType();
+        if (ot == Uml::ot_Interface)
+                return true;
+        if (ot == Uml::ot_Enum)
                 return false;
-        if (dynamic_cast<UMLEnum*>(c))
+        if (ot != Uml::ot_Class) {
+                kdWarning() << "AdaWriter::isOOClass: unknown object type " << ot << endl;
                 return false;
-        if (! dynamic_cast<UMLClass*>(c))
-                return true;
-        UMLClass *cl = dynamic_cast<UMLClass *>(c);
-        if (cl && cl->isEnumeration())
+        }
+        QString stype = c->getStereotype();
+        if (stype == "CORBAConstant" || stype == "CORBATypedef" ||
+            stype == "CORBAStruct" || stype == "CORBAUnion")
+                return false;
+        UMLClass *cl = static_cast<UMLClass *>(c);
+        if (cl->isEnumeration())
                 return false;
 
@@ -204,4 +210,22 @@ void AdaWriter::writeClass(UMLClassifier
         ada << spc() << "package " << pkg << " is\n\n";
         indentlevel++;
+        if (c->getBaseType() == Uml::ot_Enum) {
+                UMLEnum *ue = static_cast<UMLEnum*>(c);
+                UMLEnumLiteralList litList = ue->getFilteredEnumLiteralList();
+                uint i = 0;
+                ada << spc() << "type " << classname << " is (\n";
+                indentlevel++;
+                for (UMLEnumLiteral *lit = litList.first(); lit; lit = litList.next()) {
+                        QString enumLiteral = cleanName(lit->getName());
+                        ada << spc() << enumLiteral;
+                        if (++i < litList.count())
+                                ada << ",\n";
+                }
+                indentlevel--;
+                ada << ");\n\n";
+                indentlevel--;
+                ada << spc() << "end " << pkg << ";\n\n";
+                return;
+        }
         if (! isOOClass(c)) {
                 QString stype = c->getStereotype();
@@ -217,5 +241,5 @@ void AdaWriter::writeClass(UMLClassifier
                                 QString enumLiteral = cleanName(at->getName());
                                 ada << spc() << enumLiteral;
-                                if (++i < atl->count()) //FIXME warning
+                                if (++i < atl->count())
                                         ada << ",\n";
                         }






More information about the umbrello-devel mailing list