[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport

Oliver Kellogg okellogg at users.sourceforge.net
Fri Aug 11 18:19:32 UTC 2006


SVN commit 572137 by okellogg:

improve import of derived data types

 M  +17 -13    adaimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/adaimport.cpp #572136:572137
@@ -5,7 +5,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *  copyright (C) 2005                                                     *
+ *  copyright (C) 2005-2006                                                *
  *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                  *
  ***************************************************************************/
 
@@ -123,8 +123,8 @@
     }
     if (keyword == "package") {
         const QString& name = advance();
-        UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Package,
-                        name, m_scope[m_scopeIndex], m_comment);
+        UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Package, name,
+                                                      m_scope[m_scopeIndex], m_comment);
         if (advance() == "is") {
             if (m_source[m_srcIndex + 1] == "new") {
                 // generic package instantiation: TBD
@@ -147,6 +147,10 @@
         if (advance() == "(") {
             kdDebug() << "AdaImport::parseFile(" << name << "): "
                 << "discriminant handling is not yet implemented" << endl;
+            // @todo Find out how to map discriminated record to UML.
+            //       For now, we just create a pro forma empty record.
+            Import_Utils::createUMLObject(Uml::ot_Class, name, m_scope[m_scopeIndex],
+                                          m_comment, "record");
             skipStmt("end");
             if (m_source[++m_srcIndex] == "case")
                 m_srcIndex += 2;  // skip "case" ";"
@@ -187,7 +191,6 @@
                             name, m_scope[m_scopeIndex], m_comment);
             ns->setAbstract(m_isAbstract);
             m_isAbstract = false;
-            m_comment = QString::null;
             m_srcIndex++;
             isTaggedType = true;
         }
@@ -214,14 +217,14 @@
         }
         if (m_source[m_srcIndex] == "new") {
             QString base = advance();
-            UMLClassifier *parent = NULL;
-            if (advance() == "with") {
-                UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Class,
-                                base, NULL);
-                parent = static_cast<UMLClassifier*>(ns);
-                ns = Import_Utils::createUMLObject(Uml::ot_Class, name,
-                                       m_scope[m_scopeIndex], m_comment);
-                m_comment = QString::null;
+            const bool isExtension = (advance() == "with");
+            Uml::Object_Type t = (isExtension || m_isAbstract ? Uml::ot_Class
+                                                              : Uml::ot_Datatype);
+            UMLObject *ns = Import_Utils::createUMLObject(t, base, NULL);
+            UMLClassifier *parent = static_cast<UMLClassifier*>(ns);
+            ns = Import_Utils::createUMLObject(Uml::ot_Class, name,
+                                               m_scope[m_scopeIndex], m_comment);
+            if (isExtension) {
                 QString nextLexeme = advance();
                 if (nextLexeme == "null" || nextLexeme == "record") {
                     UMLClassifier *klass = static_cast<UMLClassifier*>(ns);
@@ -229,10 +232,11 @@
                     if (nextLexeme == "record") {
                         // Set the m_klass for attributes.
                         m_klass = klass;
-                        return true;
                     }
                 }
             }
+            skipStmt();
+            return true;
         }
         // Datatypes: TO BE DONE
         return false;




More information about the umbrello-devel mailing list