rubycodegenerator.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "rubycodegenerator.h"
00022
00023
00024 #include <qregexp.h>
00025 #include <kconfig.h>
00026 #include <kdebug.h>
00027 #include <klocale.h>
00028 #include <kmessagebox.h>
00029
00030
00031 #include "rubycodecomment.h"
00032 #include "codeviewerdialog.h"
00033 #include "../uml.h"
00034
00035
00036
00037
00038 RubyCodeGenerator::RubyCodeGenerator (QDomElement & elem )
00039 : CodeGenerator(elem)
00040 {
00041 }
00042
00043 RubyCodeGenerator::RubyCodeGenerator ()
00044 {
00045 }
00046
00047 RubyCodeGenerator::~RubyCodeGenerator ( ) { }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 Uml::Programming_Language RubyCodeGenerator::getLanguage() {
00058 return Uml::pl_Ruby;
00059 }
00060
00061
00062 CodeViewerDialog * RubyCodeGenerator::getCodeViewerDialog ( QWidget* parent, CodeDocument *doc,
00063 Settings::CodeViewerState state)
00064 {
00065 CodeViewerDialog *dialog = new CodeViewerDialog(parent, doc, state);
00066 return dialog;
00067 }
00068
00069
00070 RubyCodeGenerationPolicy * RubyCodeGenerator::getRubyPolicy() {
00071 return dynamic_cast<RubyCodeGenerationPolicy*>(UMLApp::app()->getPolicyExt());
00072 }
00073
00074 bool RubyCodeGenerator::getAutoGenerateAttribAccessors ( )
00075 {
00076 return getRubyPolicy()->getAutoGenerateAttribAccessors ();
00077 }
00078
00079 bool RubyCodeGenerator::getAutoGenerateAssocAccessors ( )
00080 {
00081 return getRubyPolicy()->getAutoGenerateAssocAccessors ();
00082 }
00083
00084 QString RubyCodeGenerator::getListFieldClassName () {
00085 return QString("Array");
00086 }
00087
00088
00089
00090
00091 QString RubyCodeGenerator::capitalizeFirstLetter(const QString &string)
00092 {
00093
00094
00095 QChar firstChar = string.at(0);
00096 return firstChar.upper() + string.mid(1);
00097 }
00098
00099 QString RubyCodeGenerator::cppToRubyType(const QString &typeStr) {
00100 QString type = cleanName(typeStr);
00101 type.replace("const ", "");
00102 type.replace(QRegExp("[*&\\s]"), "");
00103 type.replace(QRegExp("[<>]"), "_");
00104 type.replace("QStringList", "Array");
00105 type.replace(QRegExp("^string$"),"String");
00106 type.replace("QString", "String");
00107 type.replace("bool", "true|false");
00108 type.replace(QRegExp("^(uint|int|ushort|short|ulong|long)$"), "Integer");
00109 type.replace(QRegExp("^(float|double)$"), "Float");
00110 type.replace(QRegExp("^Q(?=[A-Z])"), "Qt::");
00111 type.replace(QRegExp("^K(?!(DE|Parts|IO)"), "KDE::");
00112
00113 return type;
00114 }
00115
00116 QString RubyCodeGenerator::cppToRubyName(const QString &nameStr) {
00117 QString name = cleanName(nameStr);
00118 name.replace(QRegExp("^m_"), "");
00119 name.replace(QRegExp("^[pbn](?=[A-Z])"), "");
00120 name = name.mid(0, 1).lower() + name.mid(1);
00121 return name;
00122 }
00123
00128 CodeDocument * RubyCodeGenerator::newClassifierCodeDocument ( UMLClassifier * c)
00129 {
00130 RubyClassifierCodeDocument * doc = new RubyClassifierCodeDocument(c);
00131 doc->initCodeClassFields();
00132 return doc;
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 const QStringList RubyCodeGenerator::reservedKeywords() const {
00144
00145 static QStringList keywords;
00146
00147 if (keywords.isEmpty()) {
00148 keywords << "__FILE__"
00149 << "__LINE__"
00150 << "BEGIN"
00151 << "END"
00152 << "alias"
00153 << "and"
00154 << "begin"
00155 << "break"
00156 << "case"
00157 << "class"
00158 << "def"
00159 << "defined?"
00160 << "do"
00161 << "else"
00162 << "elsif"
00163 << "end"
00164 << "ensure"
00165 << "false"
00166 << "for"
00167 << "if"
00168 << "in"
00169 << "module"
00170 << "next"
00171 << "nil"
00172 << "not"
00173 << "or"
00174 << "redo"
00175 << "rescue"
00176 << "retry"
00177 << "return"
00178 << "self"
00179 << "super"
00180 << "then"
00181 << "true"
00182 << "undef"
00183 << "unless"
00184 << "until"
00185 << "when"
00186 << "while"
00187 << "yield";
00188 }
00189
00190 return keywords;
00191 }
00192
00193 #include "rubycodegenerator.moc"
00194
This file is part of the documentation for umbrello Version 3.1.0.