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

Oliver Kellogg okellogg at users.sourceforge.net
Sun Aug 12 00:07:57 UTC 2007


SVN commit 699092 by okellogg:

apply r699079 from branches/KDE/3.5

 M  +6 -1      codegen_utils.cpp  
 M  +5 -0      codegen_utils.h  
 M  +4 -12     cppwriter.cpp  
 M  +0 -5      cppwriter.h  
 M  +3 -7      dwriter.cpp  
 M  +0 -5      dwriter.h  
 M  +2 -6      javaclassifiercodedocument.cpp  
 M  +0 -1      javaclassifiercodedocument.h  
 M  +6 -6      javacodeaccessormethod.cpp  
 M  +0 -8      javacodegenerator.cpp  
 M  +0 -3      javacodegenerator.h  
 M  +3 -11     javawriter.cpp  
 M  +0 -5      javawriter.h  
 M  +2 -8      rubyclassifiercodedocument.cpp  
 M  +0 -1      rubyclassifiercodedocument.h  
 M  +4 -4      rubycodeaccessormethod.cpp  
 M  +0 -8      rubycodegenerator.cpp  
 M  +0 -3      rubycodegenerator.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/codegen_utils.cpp #699091:699092
@@ -395,7 +395,7 @@
     return keywords;
 }
 
-void createCppStereotypes(){
+void createCppStereotypes() {
     UMLDoc *umldoc = UMLApp::app()->getDocument();
     umldoc->findOrCreateStereotype("constructor");
     // declares an operation as friend
@@ -404,5 +404,10 @@
     umldoc->findOrCreateStereotype("virtual");
 }
 
+QString capitalizeFirstLetter(const QString &string) {
+    QChar firstChar = string.at(0);
+    return firstChar.upper() + string.mid(1);
+}
+
 }  // end namespace Codegen_Utils
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/codegen_utils.h #699091:699092
@@ -31,6 +31,11 @@
  */
 void createCppStereotypes();
 
+/**
+ * Return the input string with the first letter capitalized.
+ */
+QString capitalizeFirstLetter(const QString &string);
+
 }
 
 #endif  // CODEGEN_UTILS_H
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppwriter.cpp #699091:699092
@@ -506,7 +506,7 @@
     //write documentation
     if(forceDoc() || list->count() > 0)
     {
-        QString strVis = capitalizeFirstLetter(visibility.toString());
+        QString strVis = Codegen_Utils::capitalizeFirstLetter(visibility.toString());
         QString strStatic = writeStatic ? "Static ":"";
         writeComment(strStatic + strVis + " attributes",getIndent(), stream);
         writeComment(" ",getIndent(), stream);
@@ -604,7 +604,7 @@
 
     if (forceDoc() || attribs->count() > 0)
     {
-        QString strVis = capitalizeFirstLetter(visibility.toString());
+        QString strVis = Codegen_Utils::capitalizeFirstLetter(visibility.toString());
         QString strStatic = (isStatic ? " static" : "");
         writeBlankLine(stream);
         writeComment(strVis + strStatic + " attribute accessor methods",getIndent(),stream);
@@ -847,7 +847,7 @@
 {
 
     QString className = fixTypeName(fieldClassName);
-    QString fldName = capitalizeFirstLetter(fieldName);
+    QString fldName = Codegen_Utils::capitalizeFirstLetter(fieldName);
     QString indent = getIndent();
 
     // ONLY IF changeability is NOT Frozen
@@ -932,7 +932,7 @@
         return;
 
     QString className = fixTypeName(fieldClassName);
-    QString fldName = capitalizeFirstLetter(fieldName);
+    QString fldName = Codegen_Utils::capitalizeFirstLetter(fieldName);
     QString indent = getIndent();
 
     // set method
@@ -1252,14 +1252,6 @@
     return(obj!=0)?obj->getName():QString("NULL");
 }
 
-QString CppWriter::capitalizeFirstLetter(const QString &string)
-{
-    // we could lowercase everything tostart and then capitalize? Nah, it would
-    // screw up formatting like getMyRadicalVariable() to getMyradicalvariable(). Bah.
-    QChar firstChar = string.at(0);
-    return firstChar + string.mid(1);
-}
-
 void CppWriter::writeBlankLine(QTextStream &stream)
 {
     stream << m_endl;
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppwriter.h #699091:699092
@@ -244,11 +244,6 @@
     QString getUMLObjectName(UMLObject *obj);
 
     /**
-     * Raises the case of the first letter in the given string
-     */
-    QString capitalizeFirstLetter(const QString &string);
-
-    /**
      * Replaces `string' with STRING_TYPENAME.
      */
     QString fixTypeName(const QString &string);
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/dwriter.cpp #699091:699092
@@ -32,6 +32,7 @@
 #include "../association.h"
 #include "../template.h"
 #include "../umltemplatelist.h"
+#include "codegen_utils.h"
 
 DWriter::DWriter() {
     startline = m_endl + m_indentation;
@@ -603,7 +604,7 @@
 
     fieldClassName = fixTypeName(fieldClassName);
     QString fieldNameUP = unPluralize(fieldName);
-    QString fieldNameUC = capitaliseFirstLetter(fieldNameUP);
+    QString fieldNameUC = Codegen_Utils::capitalizeFirstLetter(fieldNameUP);
 
     // ONLY IF changeability is NOT Frozen
     if (changeType != Uml::chg_Frozen) {
@@ -650,7 +651,7 @@
      Uml::Changeability_Type change, bool isFinal, QTextStream &d) {
 
     fieldClassName = fixTypeName(fieldClassName);
-    QString fieldNameUC = capitaliseFirstLetter(fieldName);
+    QString fieldNameUC = Codegen_Utils::capitalizeFirstLetter(fieldName);
     if (fieldName.left(2) == "m_") fieldName = fieldName.right(fieldName.count()-2);
 
     // set method
@@ -940,11 +941,6 @@
     return(obj!=0)?obj->getName():QString("NULL");
 }
 
-QString DWriter::capitaliseFirstLetter(QString string) {
-    string.replace( 0, 1, string[0].upper());
-    return string;
-}
-
 QString DWriter::deCapitaliseFirstLetter(QString string) {
     string.replace( 0, 1, string[0].lower());
     return string;
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/dwriter.h #699091:699092
@@ -225,11 +225,6 @@
     QString getUMLObjectName(UMLObject *obj);
 
     /**
-     * Raises the case of the first letter in the given string
-     */
-    QString capitaliseFirstLetter(QString string);
-    
-    /**
      * Lowers the case of the first letter in the given string
      */
     QString deCapitaliseFirstLetter(QString string);
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javaclassifiercodedocument.cpp #699091:699092
@@ -36,6 +36,7 @@
 #include "javacodecomment.h"
 #include "javaclassdeclarationblock.h"
 #include "javacodeclassfielddeclarationblock.h"
+#include "codegen_utils.h"
 #include "../classifier.h"
 #include "../codegenerationpolicy.h"
 #include "../uml.h"
@@ -103,13 +104,8 @@
 // Other methods
 //
 
-QString JavaClassifierCodeDocument::capitalizeFirstLetter(const QString &string)
-{
-    return JavaCodeGenerator::capitalizeFirstLetter(string);
-}
-
 QString JavaClassifierCodeDocument::getJavaClassName (const QString &name) {
-    return capitalizeFirstLetter(CodeGenerator::cleanName(name));
+    return Codegen_Utils::capitalizeFirstLetter(CodeGenerator::cleanName(name));
 }
 
 // Initialize this java classifier code document
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javaclassifiercodedocument.h #699091:699092
@@ -62,7 +62,6 @@
     //CodeDocumentDialog getDialog ( );
 
     QString scopeToJavaDecl(Uml::Visibility scope);
-    QString capitalizeFirstLetter(const QString &string);
 
     // Make it easier on ourselves
     JavaCodeGenerationPolicy * getJavaPolicy();
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javacodeaccessormethod.cpp #699091:699092
@@ -28,7 +28,7 @@
 #include "../umlobject.h"
 #include "../umlrole.h"
 #include "../uml.h"
-
+#include "codegen_utils.h"
 #include "javaclassifiercodedocument.h"
 #include "javacodegenerationpolicy.h"
 #include "javacodeclassfield.h"
@@ -171,29 +171,29 @@
 
     switch(getType()) {
     case CodeAccessorMethod::ADD:
-        methodName = "add"+javadoc->capitalizeFirstLetter(fieldType);
+        methodName = "add" + Codegen_Utils::capitalizeFirstLetter(fieldType);
         methodReturnType = "void";
         methodParams = objectType+" value ";
         headerText = "Add an object of type "+objectType+" to the List "+fieldName+endLine+getParentObject()->getDoc()+endLine+"@return void";
         break;
     case CodeAccessorMethod::GET:
-        methodName = "get"+javadoc->capitalizeFirstLetter(fieldName);
+        methodName = "get" + Codegen_Utils::capitalizeFirstLetter(fieldName);
         methodReturnType = fieldType;
         headerText = "Get the value of "+fieldName+endLine+getParentObject()->getDoc()+endLine+"@return the value of "+fieldName;
         break;
     case CodeAccessorMethod::LIST:
-        methodName = "get"+javadoc->capitalizeFirstLetter(fieldType)+"List";
+        methodName = "get" + Codegen_Utils::capitalizeFirstLetter(fieldType)+"List";
         methodReturnType = "List";
         headerText = "Get the list of "+fieldName+endLine+getParentObject()->getDoc()+endLine+"@return List of "+fieldName;
         break;
     case CodeAccessorMethod::REMOVE:
-        methodName = "remove"+javadoc->capitalizeFirstLetter(fieldType);
+        methodName = "remove" + Codegen_Utils::capitalizeFirstLetter(fieldType);
         methodReturnType = "void";
         methodParams = objectType+" value ";
         headerText = "Remove an object of type "+objectType+" from the List "+fieldName+endLine+getParentObject()->getDoc();
         break;
     case CodeAccessorMethod::SET:
-        methodName = "set"+javadoc->capitalizeFirstLetter(fieldName);
+        methodName = "set" + Codegen_Utils::capitalizeFirstLetter(fieldName);
         methodReturnType = "void";
         methodParams = fieldType + " value ";
         headerText = "Set the value of "+fieldName+endLine+getParentObject()->getDoc()+endLine;
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javacodegenerator.cpp #699091:699092
@@ -110,14 +110,6 @@
 // Other methods
 //
 
-QString JavaCodeGenerator::capitalizeFirstLetter(const QString &string)
-{
-    // we could lowercase everything tostart and then capitalize? Nah, it would
-    // screw up formatting like getMyRadicalVariable() to getMyradicalvariable(). Bah.
-    QChar firstChar = string.at(0);
-    return firstChar.upper() + string.mid(1);
-}
-
 // IF the type is "string" we need to declare it as
 // the Java Object "String" (there is no string primative in Java).
 // Same thing again for "bool" to "boolean"
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javacodegenerator.h #699091:699092
@@ -95,9 +95,6 @@
     // Other methods
     //
 
-    // general purpose function we may reuse for all types of Java code documents
-    static QString capitalizeFirstLetter(const QString &string);
-
     /**
      * Utility function for getting the java code generation policy.
      */
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javawriter.cpp #699091:699092
@@ -26,6 +26,7 @@
 // kde includes
 #include <kdebug.h>
 // app includes
+#include "codegen_utils.h"
 #include "../umldoc.h"
 #include "../classifier.h"
 #include "../operation.h"
@@ -608,7 +609,7 @@
 {
 
     fieldClassName = fixTypeName(fieldClassName);
-    fieldName = capitaliseFirstLetter(fieldName);
+    fieldName = Codegen_Utils::capitalizeFirstLetter(fieldName);
     QString strVis = scopeToJavaDecl(visibility);
 
     // ONLY IF changeability is NOT Frozen
@@ -647,7 +648,7 @@
 
     QString strVis = scopeToJavaDecl(visibility);
     fieldClassName = fixTypeName(fieldClassName);
-    fieldName = capitaliseFirstLetter(fieldName);
+    fieldName = Codegen_Utils::capitalizeFirstLetter(fieldName);
 
     // set method
     if (change == Uml::chg_Changeable && !isFinal) {
@@ -927,15 +928,6 @@
     return(obj!=0)?obj->getName():QString("NULL");
 }
 
-QString JavaWriter::capitaliseFirstLetter(QString string)
-{
-    // we could lowercase everything tostart and then capitalize? Nah, it would
-    // screw up formatting like getMyRadicalVariable() to getMyradicalvariable(). Bah.
-    QChar firstChar = string.at(0);
-    string.replace( 0, 1, firstChar.upper());
-    return string;
-}
-
 void JavaWriter::writeBlankLine(QTextStream &java)
 {
     java<<m_endl;
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javawriter.h #699091:699092
@@ -200,11 +200,6 @@
     QString getUMLObjectName(UMLObject *obj);
 
     /**
-     * Raises the case of the first letter in the given string
-     */
-    QString capitaliseFirstLetter(QString string);
-
-    /**
      * Replaces `string' with `String' and `bool' with `boolean'
      */
     QString fixTypeName(const QString& string);
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubyclassifiercodedocument.cpp #699091:699092
@@ -38,6 +38,7 @@
 #include "rubyclassdeclarationblock.h"
 #include "rubycodeclassfielddeclarationblock.h"
 #include "rubycodeoperation.h"
+#include "codegen_utils.h"
 #include "../classifier.h"
 #include "../uml.h"
 
@@ -100,16 +101,9 @@
 // Other methods
 //
 
-QString RubyClassifierCodeDocument::capitalizeFirstLetter(const QString &string)
-{
-    CodeGenerator *g = UMLApp::app()->getGenerator();
-    RubyCodeGenerator * gen = dynamic_cast<RubyCodeGenerator *>(g);
-    return gen->capitalizeFirstLetter(string);
-}
-
 QString RubyClassifierCodeDocument::getRubyClassName (const QString &name) {
     CodeGenerator *g = UMLApp::app()->getGenerator();
-    return capitalizeFirstLetter(g->cleanName(name));
+    return Codegen_Utils::capitalizeFirstLetter(g->cleanName(name));
 }
 
 // Initialize this ruby classifier code document
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubyclassifiercodedocument.h #699091:699092
@@ -64,7 +64,6 @@
     //CodeDocumentDialog getDialog ( );
 
     QString scopeToRubyDecl(Uml::Visibility scope);
-    QString capitalizeFirstLetter(const QString &string);
 
     // Make it easier on ourselves
     RubyCodeGenerationPolicy * getRubyPolicy();
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodeaccessormethod.cpp #699091:699092
@@ -31,7 +31,7 @@
 #include "../umlobject.h"
 #include "../umlrole.h"
 #include "../uml.h"
-
+#include "codegen_utils.h"
 #include "rubyclassifiercodedocument.h"
 #include "rubycodegenerationpolicy.h"
 #include "rubycodegenerator.h"
@@ -179,7 +179,7 @@
 
     switch(getType()) {
     case CodeAccessorMethod::ADD:
-        methodName = "add"+rubydoc->capitalizeFirstLetter(fieldType);
+        methodName = "add" + Codegen_Utils::capitalizeFirstLetter(fieldType);
         methodReturnType = "";
         methodParams = objectType+" value ";
         headerText = "Add an object of type "+objectType+" to the Array "+fieldName+endLine+description+endLine+"@return nil";
@@ -192,14 +192,14 @@
         setEndMethodText("");
         break;
     case CodeAccessorMethod::LIST:
-        methodName = "get"+rubydoc->capitalizeFirstLetter(fieldType)+"List";
+        methodName = "get" + Codegen_Utils::capitalizeFirstLetter(fieldType)+"List";
         methodReturnType = "";
         headerText = "Get the list of "+fieldName+endLine+description+endLine+"_returns_ List of "+fieldName;
         setStartMethodText("def "+ methodName + '(' + methodParams + ')');
         setEndMethodText("end");
         break;
     case CodeAccessorMethod::REMOVE:
-        methodName = "remove"+rubydoc->capitalizeFirstLetter(fieldType);
+        methodName = "remove" + Codegen_Utils::capitalizeFirstLetter(fieldType);
         methodReturnType = "";
         methodParams = objectType+" value ";
         headerText = "Remove an object of type "+objectType+" from the List "+fieldName+endLine+description;
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodegenerator.cpp #699091:699092
@@ -88,14 +88,6 @@
 // Other methods
 //
 
-QString RubyCodeGenerator::capitalizeFirstLetter(const QString &string)
-{
-    // we could lowercase everything tostart and then capitalize? Nah, it would
-    // screw up formatting like getMyRadicalVariable() to getMyradicalvariable(). Bah.
-    QChar firstChar = string.at(0);
-    return firstChar.toUpper() + string.mid(1);
-}
-
 QString RubyCodeGenerator::cppToRubyType(const QString &typeStr) {
     QString type = cleanName(typeStr);
     type.replace("const ", "");
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodegenerator.h #699091:699092
@@ -82,9 +82,6 @@
     // Other methods
     //
 
-    // general purpose function we may reuse for all types of Ruby code documents
-    QString capitalizeFirstLetter(const QString &string);
-
     /**
      * Utility function for getting the ruby code generation policy.
      */




More information about the umbrello-devel mailing list