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

Oliver Kellogg okellogg at users.sourceforge.net
Wed Aug 10 11:20:37 UTC 2005


SVN commit 445237 by okellogg:

Code import cleanup, take 3: New class NativeImportBase factors common parts
for future Umbrello native code import implementations.


 M  +1 -0      Makefile.am  
 M  +5 -25     idlimport.cpp  
 M  +9 -21     idlimport.h  
 A             nativeimportbase.cpp   [License: GPL (v2+)]
 A             nativeimportbase.h   [License: GPL (v2+)]


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/Makefile.am #445236:445237
@@ -57,6 +57,7 @@
 main.cpp \
 messagewidget.cpp \
 model_utils.cpp \
+nativeimportbase.cpp \
 node.cpp \
 nodewidget.cpp \
 notewidget.cpp \
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/idlimport.cpp #445236:445237
@@ -30,24 +30,14 @@
 #include "operation.h"
 #include "attribute.h"
 
-IDLImport::IDLImport() {
-    m_srcIndex = 0;
-    m_scopeIndex = 0;  // index 0 is reserved for global scope
-    m_klass = NULL;
+IDLImport::IDLImport() : NativeImportBase("//") {
     m_isAbstract = m_isOneway = m_isReadonly = m_isAttribute = false;
-    m_currentAccess = Uml::Public;
     m_inComment = false;
 }
 
 IDLImport::~IDLImport() {
 }
 
-void IDLImport::skipStmt(QString until /* = ";" */) {
-    const int srcLength = m_source.count();
-    while (m_srcIndex < srcLength && m_source[m_srcIndex] != until)
-        m_srcIndex++;
-}
-
 /// Check for split type names (e.g. unsigned long long)
 QString IDLImport::joinTypename() {
     QString typeName = m_source[m_srcIndex];
@@ -76,7 +66,7 @@
             QString text = line.mid(0, pos - 1);
             m_comment += text.stripWhiteSpace();
         }
-        m_source.append("//" + m_comment);  // "//" denotes comments in `m_source'
+        m_source.append(m_singleLineCommentIntro + m_comment);  // denotes comments in `m_source'
         m_comment = "";
         m_inComment = false;
         pos++;  // pos now points at the slash in the "*/"
@@ -103,7 +93,7 @@
                 QString cmnt = line.mid(pos + 2, endpos - pos - 2);
                 cmnt = cmnt.stripWhiteSpace();
                 if (!cmnt.isEmpty())
-                    m_source.append("//" + cmnt);
+                    m_source.append(m_singleLineCommentIntro + cmnt);
             }
             endpos++;  // endpos now points at the slash of "*/"
             QString pre;
@@ -116,7 +106,7 @@
         }
     }
     // Check for single line comment.
-    pos = line.find("//");
+    pos = line.find(m_singleLineCommentIntro);
     if (pos != -1) {
         QString cmnt = line.mid(pos);
         m_source.append(cmnt);
@@ -196,7 +186,7 @@
     for (m_srcIndex = 0; m_srcIndex < srcLength; m_srcIndex++) {
         const QString& keyword = m_source[m_srcIndex];
         kdDebug() << '"' << keyword << '"' << endl;
-        if (keyword.startsWith("//")) {
+        if (keyword.startsWith(m_singleLineCommentIntro)) {
             m_comment = keyword.mid(2);
             continue;
         }
@@ -421,13 +411,3 @@
 }
 
 
-void IDLImport::importFiles(QStringList idlFileList) {
-    UMLDoc *umldoc = UMLApp::app()->getDocument();
-    for (QStringList::Iterator fileIT = idlFileList.begin();
-            fileIT != idlFileList.end(); ++fileIT) {
-        QString fileName = (*fileIT);
-        umldoc->writeToStatusBar(i18n("Importing file: %1").arg(fileName));
-        IDLImport::parseFile(fileName);
-    }
-}
-
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/idlimport.h #445236:445237
@@ -12,44 +12,32 @@
  *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                  *
  ***************************************************************************/
 
-#include <qstring.h>
-#include <qstringlist.h>
-#include "classimport.h"
-#include "umlnamespace.h"
+#include "nativeimportbase.h"
 
-class UMLPackage;
-class UMLClassifier;
-
 /**
  * CORBA IDL code import
  * @author Oliver Kellogg
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-class IDLImport : public ClassImport {
+class IDLImport : public NativeImportBase {
 public:
     IDLImport();
     virtual ~IDLImport();
 
     /**
-     * Implement abstract operation from ClassImport for IDL.
+     * Implement abstract operation from NativeImportBase.
      */
-    void importFiles(QStringList idlFiles);
+    void parseFile(QString file);
 
-protected:
-    void skipStmt(QString until = ";");
-    QString joinTypename();
+    /**
+     * Implement abstract operation from NativeImportBase.
+     */
     void scan(QString line);
-    void parseFile(QString file);
 
-    QStringList m_source;
-    int m_srcIndex;
-    UMLPackage *m_scope[32];
-    int m_scopeIndex;  // index 0 is reserved for global scope
-    UMLClassifier *m_klass;
+protected:
+    QString joinTypename();
     bool m_isAbstract, m_isOneway, m_isReadonly, m_isAttribute;
-    Uml::Scope m_currentAccess;
     bool m_inComment;
-    QString m_comment;
 };
 
 #endif




More information about the umbrello-devel mailing list