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

Oliver Kellogg okellogg at users.sourceforge.net
Wed Dec 27 22:27:53 UTC 2006


SVN commit 617069 by okellogg:

Model_Utils::parseOperation(): Special case "operator()" into desc.m_name.
UMLOperation::toString(): Remove tests like s.contains("(") or s.contains(")"),
 they disturb the handling of "operator()".
BUG:139147


 M  +1 -0      ChangeLog  
 M  +18 -12    umbrello/model_utils.cpp  
 M  +18 -14    umbrello/operation.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #617068:617069
@@ -18,6 +18,7 @@
 * XML scheme: mixup of attribute names: *color and *colour (136061)
 * Artifacts of a component diagram are wrongly placed in Deployment View folder (137564)
 * Incorrect export to SQL (138139)
+* Parentheses do not appear around the parameters of the C++ operator() (139147)
 
 Version 1.5.52
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #617068:617069
@@ -468,19 +468,25 @@
     m = m.simplifyWhiteSpace();
     if (m.isEmpty())
         return PS_Empty;
-    /**
-     * The search pattern includes everything until the opening parenthesis
-     * because UML also permits non programming-language oriented designs
-     * using narrative names, for example "check water temperature".
-     */
-    QRegExp pat( "^([^\\(]+)" );
+    if (m.contains(QRegExp("operator *()"))) {
+        // C++ special case: two sets of parentheses
+        desc.m_name = "operator()";
+        m.remove(QRegExp("operator *()"));
+    } else {
+        /**
+         * The search pattern includes everything up to the opening parenthesis
+         * because UML also permits non programming-language oriented designs
+         * using narrative names, for example "check water temperature".
+         */
+        QRegExp beginningUpToOpenParenth( "^([^\\(]+)" );
+        int pos = beginningUpToOpenParenth.search(m);
+        if (pos == -1)
+            return PS_Illegal_MethodName;
+        desc.m_name = beginningUpToOpenParenth.cap(1);
+    }
+    desc.m_pReturnType = NULL;
+    QRegExp pat = QRegExp("\\) *:(.*)$");
     int pos = pat.search(m);
-    if (pos == -1)
-        return PS_Illegal_MethodName;
-    desc.m_name = pat.cap(1);
-    desc.m_pReturnType = NULL;
-    pat = QRegExp("\\) *:(.*)$");
-    pos = pat.search(m);
     if (pos != -1) {  // return type is optional
         QString retType = pat.cap(1);
         retType = retType.stripWhiteSpace();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/operation.cpp #617068:617069
@@ -131,24 +131,28 @@
           s = m_Vis.toString(true) + " ";
     
     s += getName();
-    if (!s.contains("("))
-        s.append("(");
+    Uml::Programming_Language pl = UMLApp::app()->getActiveLanguage();
+    bool parameterlessOpNeedsParentheses = (pl != Uml::pl_Pascal && pl != Uml::pl_Ada);
 
-    if(sig == Uml::st_NoSig || sig == Uml::st_NoSigNoVis) {
-        if (!s.contains(")"))
-            s.append(")");
+    if (sig == Uml::st_NoSig || sig == Uml::st_NoSigNoVis) {
+        if (parameterlessOpNeedsParentheses)
+            s.append("()");
         return s;
     }
-    UMLAttribute * obj=0;
-    int last = m_List.count(), i = 0;
-    for(obj=m_List.first();obj != 0;obj=m_List.next()) {
-        i++;
-        s.append(obj -> toString(Uml::st_SigNoVis));
-        if(i < last)
-            s.append(", ");
+    int last = m_List.count();
+    if (last) {
+        s.append("(");
+        int i = 0;
+        for (UMLAttribute *param = m_List.first(); param; param = m_List.next()) {
+            i++;
+            s.append(param->toString(Uml::st_SigNoVis));
+            if (i < last)
+                s.append(", ");
+        }
+        s.append(")");
+    } else if (parameterlessOpNeedsParentheses) {
+        s.append("()");
     }
-    if (!s.contains(")"))
-        s.append(")");
     UMLClassifier *ownParent = static_cast<UMLClassifier*>(parent());
     QString returnType;
     UMLClassifier *retType = UMLClassifierListItem::getType();




More information about the umbrello-devel mailing list