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

Brian Thomas thomas at mail630.gsfc.nasa.gov
Tue Apr 13 17:59:07 UTC 2004


CVS commit by thomas: 

bug fix/cleanup: move fixTypeName to java code generator..and further fix type name declarations in output code..was missing from java operations declarations


  M +3 -11     javacodeclassfield.cpp   1.9
  M +0 -1      javacodeclassfield.h   1.4
  M +10 -0     javacodegenerator.cpp   1.16
  M +7 -0      javacodegenerator.h   1.10
  M +4 -1      javacodeoperation.cpp   1.12


--- kdesdk/umbrello/umbrello/codegenerators/javacodeclassfield.cpp  #1.8:1.9
@@ -20,4 +20,5 @@
 #include "javacodeclassfield.h"
 #include "javacodecomment.h"
+#include "javacodegenerator.h"
 
 #include "../attribute.h"
@@ -52,14 +53,4 @@ JavaCodeClassField::~JavaCodeClassField 
 //  
 
-// 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"
-QString JavaCodeClassField::fixTypeName(QString string)
-{
-        string.replace(QRegExp("^string$"),"String");
-        string.replace(QRegExp("^bool$"),"boolean");
-        return cleanName(string);
-}
-
 QString JavaCodeClassField::getFieldName() {
         if (parentIsAttribute()) 
@@ -103,5 +94,6 @@ QString JavaCodeClassField::getInitialVa
 QString JavaCodeClassField::getTypeName ( ) 
 {
-        return fixTypeName(CodeClassField::getTypeName());
+        JavaCodeGenerator * gen = dynamic_cast<JavaCodeGenerator*>(getParentGenerator());
+        return gen->fixTypeName(CodeClassField::getTypeName());
 }
 

--- kdesdk/umbrello/umbrello/codegenerators/javacodeclassfield.h  #1.3:1.4
@@ -44,5 +44,4 @@ public:
         virtual ~JavaCodeClassField ( );
 
-        QString fixTypeName(QString string); 
         QString getFieldType();
         QString getFieldName();

--- kdesdk/umbrello/umbrello/codegenerators/javacodegenerator.cpp  #1.15:1.16
@@ -134,4 +134,14 @@ QString JavaCodeGenerator::capitalizeFir
 }
 
+// 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"
+QString JavaCodeGenerator::fixTypeName(QString string)
+{
+        string.replace(QRegExp("^string$"),"String");
+        string.replace(QRegExp("^bool$"),"boolean");
+        return cleanName(string);
+}
+
 /**
  * @return      JavaANTCodeDocument

--- kdesdk/umbrello/umbrello/codegenerators/javacodegenerator.h  #1.9:1.10
@@ -126,4 +126,11 @@ public:
         virtual void createDefaultDatatypes();
 
+        /**
+         * 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". 
+         */
+        QString fixTypeName(QString string); 
+
 protected:
 

--- kdesdk/umbrello/umbrello/codegenerators/javacodeoperation.cpp  #1.11:1.12
@@ -18,4 +18,5 @@
 #include "javaclassifiercodedocument.h"
 #include "javacodedocumentation.h"
+#include "javacodegenerator.h"
 
 // Constructors/Destructors
@@ -40,4 +41,5 @@ void JavaCodeOperation::updateMethodDecl
         JavaClassifierCodeDocument * javadoc = dynamic_cast<JavaClassifierCodeDocument*>(doc);
         UMLOperation * o = getParentOperation();
+        JavaCodeGenerator * gen = dynamic_cast<JavaCodeGenerator*>(doc->getParentGenerator());
         bool isInterface = javadoc->getParentClassifier()->isInterface();
         QString endLine = getNewLineEndingChars();
@@ -55,5 +57,6 @@ void JavaCodeOperation::updateMethodDecl
         QString strVis = javadoc->scopeToJavaDecl(o->getScope());
         // no return type for constructors
-        QString returnType = o->isConstructorOperation() ? QString("") : (o->getReturnType() + QString(" "));
+        QString fixedReturn = gen->fixTypeName(o->getReturnType());
+        QString returnType = o->isConstructorOperation() ? QString("") : (fixedReturn + QString(" "));
         QString methodName = o->getName();
         QString paramStr = QString("");






More information about the umbrello-devel mailing list