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

Oliver Kellogg okellogg at users.sourceforge.net
Fri Mar 26 18:25:01 UTC 2004


CVS commit by okellogg: 

writeClass(): Don't generate with clauses for UMLDatatypes, and
 don't crash on generating code for interfaces.


  M +29 -29    adawriter.cpp   1.19


--- kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp  #1.18:1.19
@@ -74,5 +74,5 @@ bool AdaWriter::isOOClass(UMLClassifier 
                 return false;
         if (ot != Uml::ot_Class) {
-                kdWarning() << "AdaWriter::isOOClass: unknown object type " << ot << endl;
+                kdDebug() << "AdaWriter::isOOClass: unknown object type " << ot << endl;
                 return false;
         }
@@ -177,6 +177,8 @@ void AdaWriter::writeClass(UMLClassifier
         findObjectsRelated(c, imports);
         if (imports.count()) {
-                for (UMLClassifier *con = imports.first(); con; con = imports.next())
+                for (UMLClassifier *con = imports.first(); con; con = imports.next()) {
+                        if (con->getBaseType() != Uml::ot_Datatype)
                         ada << "with " << qualifiedName(con) << "; \n";
+                }
                 ada << "\n";
         }
@@ -275,5 +277,5 @@ void AdaWriter::writeClass(UMLClassifier
 
         // Generate accessors for public attributes.
-        UMLAttributeList *atl;
+        UMLAttributeList *atl = NULL;
         if(myClass) {
                 UMLAttributeList atpub;
@@ -300,7 +302,4 @@ void AdaWriter::writeClass(UMLClassifier
                         ada << " return " << at->getTypeName() << ";\n\n";
                 }
-        } else {
-                kdWarning() << "atl not initialised in writeClass()" << endl;
-                atl = 0;
         }
 
@@ -387,5 +386,5 @@ void AdaWriter::writeClass(UMLClassifier
         }
 
-        if (forceSections() || atl->count()) {
+        if (myClass && (forceSections() || atl->count())) {
                 ada << spc() << "-- Attributes:\n";
                 UMLAttribute *at;
@@ -400,11 +399,12 @@ void AdaWriter::writeClass(UMLClassifier
                 }
         }
-        if (aggregations.isEmpty() && compositions.isEmpty() && !atl->count())
+        bool haveAttrs = (myClass && atl->count());
+        if (aggregations.isEmpty() && compositions.isEmpty() && !haveAttrs)
                 ada << spc() << "null;\n";
         indentlevel--;
         ada << spc() << "end record;\n\n";
+        if (haveAttrs) {
         bool seen_static_attr = false;
-        UMLAttribute *at;
-        for (at = atl->first(); at; at = atl->next()) {
+                for (UMLAttribute *at = atl->first(); at; at = atl->next()) {
                 if (! at->getStatic())
                         continue;
@@ -423,5 +423,5 @@ void AdaWriter::writeClass(UMLClassifier
         if (seen_static_attr)
                 ada << "\n";
-
+        }
         // Generate protected operations.
         UMLOperationList opprot;
@@ -492,5 +492,5 @@ void AdaWriter::writeOperation(UMLOperat
                                 ada << "out ";
                         else if (pk == Uml::pk_InOut)
-                                ada << "inout ";
+                                ada << "in out ";
                         else
                                 ada << "in ";






More information about the umbrello-devel mailing list