[Uml-devel] KDE/kdesdk/umbrello/umbrello/codegenerators
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Jul 26 03:58:01 UTC 2005
SVN commit 438865 by rdale:
* C++ operator methods were not being converted to ruby ones correctly
* If a method returns 'void', the return type shouldn't be shown in
the RDOC comment
CCMAIL: umbrello-devel at kde.org
M +3 -3 rubycodedocumentation.cpp
M +13 -10 rubycodeoperation.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodedocumentation.cpp #438864:438865
@@ -67,17 +67,17 @@
// simple output method
if(getWriteOutText())
{
- bool useDoubleDashOutput = true;
+ bool useHashOutput = true;
// need to figure out output type from ruby policy
RubyCodeGenerationPolicy * p = ((RubyClassifierCodeDocument*)getParentDocument())->getRubyPolicy();
if(p->getCommentStyle() == RubyCodeGenerationPolicy::BeginEnd)
- useDoubleDashOutput = false;
+ useHashOutput = false;
QString indent = getIndentationString();
QString endLine = getNewLineEndingChars();
QString body = getText();
- if(useDoubleDashOutput)
+ if( useHashOutput)
{
if(!body.isEmpty())
output.append(formatMultiLineText (body, indent +"# ", endLine));
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodeoperation.cpp #438864:438865
@@ -61,10 +61,7 @@
// Skip destructors, and operator methods which
// can't be defined in ruby
if ( methodName.startsWith("~")
- || methodName == "operator ="
- || methodName == "operator --"
- || methodName == "operator ++"
- || methodName == "operator !=" )
+ || QRegExp("operator\\s*(=|--|\\+\\+|!=)$").exactMatch(methodName) )
{
getComment()->setText("");
return;
@@ -74,6 +71,9 @@
methodName = "initialize";
}
+ methodName.replace(QRegExp("operator\\s*"), "");
+ methodName = methodName.mid(0, 1).lower() + methodName.mid(1);
+
QString paramStr = QString("");
QStringList commentedParams;
@@ -114,14 +114,14 @@
if (comment.isEmpty()) {
if (getContentType() == CodeBlock::AutoGenerated) {
- UMLAttributeList* paramaters = o->getParmList();
- for(UMLAttributeListIt iterator(*paramaters); iterator.current(); ++iterator) {
+ UMLAttributeList* parameters = o->getParmList();
+ for(UMLAttributeListIt iterator(*parameters); iterator.current(); ++iterator) {
comment += endLine + "* _" + iterator.current()->getName() + "_ ";
- comment += (" " + iterator.current()->getDoc().replace( QRegExp("[\\n\\r]+[\\t ]*"),
+ comment += (" " + iterator.current()->getDoc().replace( QRegExp("[\\n\\r]+[\\t ]*"),
endLine + " " ) );
}
// add a returns statement too
- if(!returnType.isEmpty())
+ if(!returnType.isEmpty() && !QRegExp("^void\\s*$").exactMatch(returnType))
comment += endLine + "* _returns_ " + returnType + " ";
getComment()->setText(comment);
}
@@ -181,7 +181,10 @@
}
QString typeStr = gen->cppToRubyType(o->getTypeName());
- if (typeStr != "" && typeStr != "void" && comment.contains("_returns_") == 0) {
+ if ( typeStr != ""
+ && !QRegExp("^void\\s*$").exactMatch(typeStr)
+ && comment.contains("_returns_") == 0 )
+ {
comment += endLine + "* _returns_ " + typeStr;
}
@@ -206,7 +209,7 @@
return 0;
}
-void RubyCodeOperation::init (RubyClassifierCodeDocument * doc )
+void RubyCodeOperation::init(RubyClassifierCodeDocument * doc )
{
// lets not go with the default comment and instead use
// full-blown ruby documentation object instead
More information about the umbrello-devel
mailing list