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

Oliver Kellogg okellogg at users.sourceforge.net
Sun May 16 22:10:01 UTC 2004


CVS commit by okellogg: 

Partial fix for bugs.kde.org/80999 (code generation with nested packages.)
This can in principle be applied to the other code generators.
The directory structure is still wrong.


  M +19 -6     idlwriter.cpp   1.14


--- kdesdk/umbrello/umbrello/codegenerators/idlwriter.cpp  #1.13:1.14
@@ -156,7 +156,17 @@ void IDLWriter::writeClass(UMLClassifier
         }
 
-        QString pkg = c->getPackage();
-        if (! pkg.isEmpty()) {
-                idl << spc() << "module " << pkg << " {\n\n";
+        // Construct a "forward" list of the packages in which we are
+        // embedded (using the UMLObject::getUMLPackage() back pointers.)
+        QPtrList<UMLPackage> pkgList;
+        UMLPackage* pkg = c->getUMLPackage();
+        while (pkg != NULL) {
+                pkgList.prepend(pkg);
+                pkg = pkg->getUMLPackage();
+        }
+
+        // Generate the module declaration(s) for the package(s) in which
+        // we are embedded.
+        for (pkg = pkgList.first(); pkg != NULL; pkg = pkgList.next()) {
+                idl << spc() << "module " << pkg->getName() << " {\n\n";
                 indentlevel++;
         }
@@ -185,5 +195,6 @@ void IDLWriter::writeClass(UMLClassifier
                 indentlevel--;
                 idl << spc() << "};\n\n";
-                if (! pkg.isEmpty()) {
+                // Close the modules inside which we might be nested.
+                for (pkg = pkgList.first(); pkg != NULL; pkg = pkgList.next()) {
                         indentlevel--;
                         idl << spc() << "};\n\n";
@@ -242,5 +253,6 @@ void IDLWriter::writeClass(UMLClassifier
                         idl << spc() << "// " << stype << ": Unknown stereotype\n\n";
                 }
-                if (! pkg.isEmpty()) {
+                // Close the modules inside which we might be nested.
+                for (pkg = pkgList.first(); pkg != NULL; pkg = pkgList.next()) {
                         indentlevel--;
                         idl << spc() << "};\n\n";
@@ -358,5 +370,6 @@ void IDLWriter::writeClass(UMLClassifier
         idl << spc() << "};\n\n";
 
-        if (!pkg.isEmpty()) {
+        // Close the modules inside which we might be nested.
+        for (pkg = pkgList.first(); pkg != NULL; pkg = pkgList.next()) {
                 indentlevel--;
                 idl << spc() << "};\n\n";






More information about the umbrello-devel mailing list