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

Oliver Kellogg okellogg at users.sourceforge.net
Tue Jan 9 21:55:00 UTC 2007


SVN commit 621845 by okellogg:

m_classesDefinedInThisScope: New. Keeps track of tagged types declared in the
current scope. This is required in order to distinguish object-bound from non
object-bound operations. (Before, every op was blindly considered primitive.)


 M  +18 -17    adaimport.cpp  
 M  +3 -0      adaimport.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/adaimport.cpp #621844:621845
@@ -35,6 +35,7 @@
 
 void AdaImport::initVars() {
     m_inGenericFormalPart = false;
+    m_classesDefinedInThisScope.clear();
 }
 
 /// Split the line so that a string is returned as a single element of the list,
@@ -207,7 +208,8 @@
         }
         if (m_source[m_srcIndex] == ";") {
             // forward declaration
-            // To Be Done
+            Import_Utils::createUMLObject(Uml::ot_Class, name, m_scope[m_scopeIndex],
+                                          m_comment);
             return true;
         }
         if (m_source[m_srcIndex] != "is") {
@@ -233,10 +235,6 @@
             m_srcIndex++;
         }
         if (m_source[m_srcIndex] == "tagged") {
-            UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Class,
-                            name, m_scope[m_scopeIndex], m_comment);
-            ns->setAbstract(m_isAbstract);
-            m_isAbstract = false;
             m_srcIndex++;
             isTaggedType = true;
         }
@@ -244,21 +242,23 @@
             m_srcIndex++;  // we can't (yet?) represent that
         }
         if (m_source[m_srcIndex] == "private" ||
+            m_source[m_srcIndex] == "record" ||
             (m_source[m_srcIndex] == "null" &&
              m_source[m_srcIndex+1] == "record")) {
-            skipStmt();
-            return true;
-        }
-        if (m_source[m_srcIndex] == "record") {
-            // If it's a tagged record then the class was already created
-            // above (see processing for "tagged".) Doesn't matter;
-            // in that case Import_Utils::createUMLObject() just returns
-            // the existing class instead of creating a new one.
             UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Class,
                             name, m_scope[m_scopeIndex], m_comment);
-            if (! isTaggedType)
+            ns->setAbstract(m_isAbstract);
+            m_isAbstract = false;
+            if (isTaggedType) {
+                if (! m_classesDefinedInThisScope.contains(ns))
+                    m_classesDefinedInThisScope.append(ns);
+            } else {
                 ns->setStereotype("record");
-            m_klass = static_cast<UMLClassifier*>(ns);
+            }
+            if (m_source[m_srcIndex] == "record")
+                m_klass = static_cast<UMLClassifier*>(ns);
+            else
+                skipStmt();
             return true;
         }
         if (m_source[m_srcIndex] == "new") {
@@ -385,8 +385,9 @@
                      ****/
                 }
                 Uml::Object_Type t = type->getBaseType();
-                if (t != Uml::ot_Interface &&
-                    (t != Uml::ot_Class || type->getStereotype() == "record")) {
+                if ((t != Uml::ot_Interface &&
+                     (t != Uml::ot_Class || type->getStereotype() == "record")) ||
+                    !m_classesDefinedInThisScope.contains(type)) {
                     // Not an instance bound method - we cannot represent it.
                     skipStmt(")");
                     break;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/adaimport.h #621844:621845
@@ -13,6 +13,7 @@
 #define ADAIMPORT_H
 
 #include "nativeimportbase.h"
+#include "../umlobjectlist.h"
 
 /**
  * Ada code import
@@ -50,6 +51,8 @@
     void fillSource(const QString& word);
 
     bool m_inGenericFormalPart; ///< auxiliary variable
+
+    UMLObjectList m_classesDefinedInThisScope;
 };
 
 #endif




More information about the umbrello-devel mailing list