Commit 3a12a2ca authored by Andi Fischer's avatar Andi Fischer
Browse files

Patch is rather big and it:

- creates new subdirectories for every language in directory codegenerators and moves files to their directory.
- moves files belonging to codegeneration from umbrello-dir to codegenerators.
- removes the inheritance from QObject in TextBlock.
- applies many style guide cleanups. 


svn path=/trunk/KDE/kdesdk/umbrello/; revision=839212
parent e890e8ec
This diff is collapsed.
......@@ -15,43 +15,48 @@
#include "adawriter.h"
#include "umldoc.h"
#include "uml.h"
#include "classifier.h"
#include "enum.h"
#include "classifierlistitem.h"
#include "umlclassifierlistitemlist.h"
#include "umltemplatelist.h"
#include "folder.h"
#include "association.h"
#include "attribute.h"
#include "operation.h"
#include "template.h"
#include "umlnamespace.h"
#include <kdebug.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <qfile.h>
#include <qregexp.h>
#include <qtextstream.h>
#include "../umldoc.h"
#include "../uml.h"
#include "../classifier.h"
#include "../enum.h"
#include "../classifierlistitem.h"
#include "../umlclassifierlistitemlist.h"
#include "../umltemplatelist.h"
#include "../folder.h"
#include "../association.h"
#include "../attribute.h"
#include "../operation.h"
#include "../template.h"
#include "../umlnamespace.h"
#include <QtCore/QFile>
#include <QtCore/QRegExp>
#include <QtCore/QTextStream>
const QString AdaWriter::defaultPackageSuffix = "_Holder";
AdaWriter::AdaWriter() {
AdaWriter::AdaWriter()
{
}
AdaWriter::~AdaWriter() {}
AdaWriter::~AdaWriter()
{
}
/**
* returns "Ada"
*/
Uml::Programming_Language AdaWriter::getLanguage() {
Uml::Programming_Language AdaWriter::getLanguage()
{
return Uml::pl_Ada;
}
bool AdaWriter::isOOClass(UMLClassifier *c) {
bool AdaWriter::isOOClass(UMLClassifier *c)
{
Uml::Object_Type ot = c->getBaseType();
if (ot == Uml::ot_Interface)
return true;
......@@ -70,7 +75,8 @@ bool AdaWriter::isOOClass(UMLClassifier *c) {
return true;
}
QString AdaWriter::className(UMLClassifier *c, bool inOwnScope) {
QString AdaWriter::className(UMLClassifier *c, bool inOwnScope)
{
// If the class has an enclosing package then it is assumed that
// the class name is the type name; if the class does not have an
// enclosing package then the class name acts as the Ada package
......@@ -90,7 +96,8 @@ QString AdaWriter::className(UMLClassifier *c, bool inOwnScope) {
return retval;
}
QString AdaWriter::packageName(UMLPackage *p) {
QString AdaWriter::packageName(UMLPackage *p)
{
// If the class has an enclosing package then it is assumed that
// the class name is the type name; if the class does not have an
// enclosing package then the class name acts as the Ada package
......@@ -115,7 +122,8 @@ QString AdaWriter::packageName(UMLPackage *p) {
void AdaWriter::computeAssocTypeAndRole(UMLClassifier *c,
UMLAssociation *a,
QString& typeName, QString& roleName) {
QString& typeName, QString& roleName)
{
UMLClassifier* assocEnd = dynamic_cast<UMLClassifier*>(a->getObject(Uml::B));
if (assocEnd == NULL)
return;
......@@ -145,7 +153,8 @@ void AdaWriter::computeAssocTypeAndRole(UMLClassifier *c,
typeName.append("_Ptr");
}
void AdaWriter::writeClass(UMLClassifier *c) {
void AdaWriter::writeClass(UMLClassifier *c)
{
if (!c) {
uDebug() << "Cannot write class of NULL concept!";
return;
......@@ -207,7 +216,7 @@ void AdaWriter::writeClass(UMLClassifier *c) {
// Check whether it's a data type.
UMLClassifier *typeObj = t->getType();
if (typeObj == NULL) {
uError() << "template_param " << typeName << ": typeObj is NULL" << endl;
uError() << "template_param " << typeName << ": typeObj is NULL";
ada << getIndent() << "type " << formalName << " is new " << typeName
<< " with private; -- CHECK: codegen error"
<< m_endl;
......@@ -464,7 +473,8 @@ void AdaWriter::writeClass(UMLClassifier *c) {
}
void AdaWriter::writeOperation(UMLOperation *op, QTextStream &ada, bool is_comment) {
void AdaWriter::writeOperation(UMLOperation *op, QTextStream &ada, bool is_comment)
{
UMLAttributeList atl = op->getParmList();
QString rettype = op->getTypeName();
bool use_procedure = (rettype.isEmpty() || rettype == "void");
......@@ -517,7 +527,8 @@ void AdaWriter::writeOperation(UMLOperation *op, QTextStream &ada, bool is_comme
ada << ";" << m_endl << m_endl;
}
QStringList AdaWriter::defaultDatatypes() {
QStringList AdaWriter::defaultDatatypes()
{
QStringList l;
l.append("Boolean");
l.append("Character");
......@@ -539,23 +550,24 @@ QStringList AdaWriter::defaultDatatypes() {
*
* @param rPossiblyReservedKeyword The string to check.
*/
bool AdaWriter::isReservedKeyword(const QString & rPossiblyReservedKeyword) {
bool AdaWriter::isReservedKeyword(const QString & rPossiblyReservedKeyword)
{
const QStringList keywords = reservedKeywords();
QStringList::ConstIterator it;
for (it = keywords.begin(); it != keywords.end(); ++it)
if ((*it).toLower() == rPossiblyReservedKeyword.toLower())
for (it = keywords.begin(); it != keywords.end(); ++it) {
if ((*it).toLower() == rPossiblyReservedKeyword.toLower()) {
return true;
}
}
return false;
}
/**
* get list of reserved keywords
*/
const QStringList AdaWriter::reservedKeywords() const {
const QStringList AdaWriter::reservedKeywords() const
{
static QStringList keywords;
if ( keywords.isEmpty() ) {
......
......@@ -23,14 +23,16 @@
class UMLAssociation;
class UMLOperation;
class QTextStream;
/**
* class AdaWriter is a code generator for UMLClassifier objects.
* Create an instance of this class, and feed it a UMLClassifier when
* calling writeClass and it will generate an Ada package spec for
* that concept
*/
class AdaWriter : public SimpleCodeGenerator {
* Class AdaWriter is a code generator for UMLClassifier objects.
* Create an instance of this class, and feed it a UMLClassifier when
* calling writeClass and it will generate an Ada package spec for
* that concept.
*/
class AdaWriter : public SimpleCodeGenerator
{
Q_OBJECT
public:
......@@ -45,7 +47,7 @@ public:
virtual ~AdaWriter ();
/**
* call this method to generate Ada code for a UMLClassifier
* Call this method to generate Ada code for a UMLClassifier.
* @param c the class to generate code for
*/
virtual void writeClass (UMLClassifier *c);
......@@ -59,7 +61,7 @@ public:
/**
* Check whether the given string is a reserved word for the
* language of this code generator
* language of this code generator.
*
* @param rPossiblyReservedKeyword The string to check.
* @return true if the keyword is reserved
......@@ -67,14 +69,14 @@ public:
virtual bool isReservedKeyword(const QString & rPossiblyReservedKeyword);
/**
* get list of reserved keywords
* Get list of reserved keywords.
*/
virtual const QStringList reservedKeywords() const;
private:
/**
* write one operation
* Write one operation.
* @param op the class for which we are generating code
* @param ada the stream associated with the output file
*/
......
......@@ -5,7 +5,6 @@
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
......@@ -16,15 +15,17 @@
***************************************************************************/
#include "aswriter.h"
#include "../association.h"
#include "../classifier.h"
#include "../operation.h"
#include "../umldoc.h"
#include "../attribute.h"
#include "association.h"
#include "attribute.h"
#include "classifier.h"
#include "operation.h"
#include "umldoc.h"
#include <kdebug.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <QtCore/QRegExp>
#include <QtCore/QTextStream>
ASWriter::ASWriter()
{
......
......@@ -19,8 +19,10 @@
#define ASWRITER_H
#include "simplecodegenerator.h"
#include "../umloperationlist.h"
#include "../umlassociationlist.h"
#include "umloperationlist.h"
#include "umlassociationlist.h"
class QTextStream;
/**
* Class ASWriter is a ActionScript code generator for UMLClassifier objects.
......
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2008 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Wed Jun 18 2003
*/
#include "codeblock.h"
#include "kdebug.h"
#include "codedocument.h"
#include "kdebug.h"
CodeBlock::CodeBlock ( CodeDocument * doc, const QString & body )
: TextBlock ( doc, body )
......@@ -94,6 +88,3 @@ QTextStream& operator<<(QTextStream& str, const CodeBlock& obj)
<< ", ..." << static_cast<TextBlock*>(const_cast<CodeBlock*>(&obj));
return str;
}
#include "codeblock.moc"
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2008 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Wed Jun 18 2003
*/
#ifndef CODEBLOCK_H
#define CODEBLOCK_H
#include "textblock.h"
/**
* A "chunk" of code within the code document.
*/
class CodeBlock : public TextBlock
{
Q_OBJECT
public:
/**
......
......@@ -4,21 +4,17 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2008 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Wed Jun 18 2003
*/
// own header
#include "codeblockwithcomments.h"
// local includes
#include "codedocument.h"
#include "codegenerators/codegenfactory.h"
#include "codegenfactory.h"
// kde includes
#include <kdebug.h>
......@@ -137,5 +133,3 @@ void CodeBlockWithComments::setOverallIndentationLevel ( int level )
setIndentationLevel(level);
getComment()->setIndentationLevel(level);
}
#include "codeblockwithcomments.moc"
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2008 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Wed Jun 18 2003
*/
#ifndef CODEBLOCKWITHCOMMENTS_H
#define CODEBLOCKWITHCOMMENTS_H
#include "codeblock.h"
#include "codecomment.h"
class HierarchicalCodeBlock;
/**
* class CodeBlockWithComments
* A very common type of text block in any type of code.
*/
* class CodeBlockWithComments
* A very common type of text block in any type of code.
*/
class CodeBlockWithComments : public CodeBlock
{
Q_OBJECT
public:
/**
......
......@@ -4,15 +4,11 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2008 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Fri Jun 20 2003
*/
// own header
#include "codeclassfield.h"
......@@ -131,12 +127,9 @@ CodeClassField::ClassFieldType CodeClassField::getClassFieldType() const
return m_classFieldType;
}
/**
* Get the value of m_dialog.
* @return the value of m_dialog
*/
/*
CodeClassFieldDialog * CodeClassField::getDialog ( ) {
CodeClassFieldDialog * CodeClassField::getDialog ( )
{
return m_dialog;
}
*/
......@@ -245,7 +238,6 @@ void CodeClassField::setAttributesOnNode ( QDomDocument & doc, QDomElement & cfE
{
method->saveToXMI(doc,cfElem);
}
}
/**
......@@ -295,7 +287,6 @@ void CodeClassField::setAttributesFromNode ( QDomElement & root)
node = element.nextSibling();
element = node.toElement();
}
}
/**
......
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
* copyright (C) 2004-2006 *
* Umbrello UML Modeller Authors <uml-devel@uml.sf.net> *
***************************************************************************/
/* This code generated by:
* Author : thomas
* Date : Fri Jun 20 2003
*/
#ifndef CODECLASSFIELD_H
#define CODECLASSFIELD_H
......@@ -24,19 +17,15 @@
#include "codeparameter.h"
#include "codeaccessormethod.h"
// #include "codeclassfielddialog.h"
class ClassifierCodeDocument;
class UMLAttribute;
class UMLObject;
class UMLRole;
/**
* class CodeClassField
* a special type of parameter.. occurs on class declarations.
*/
* class CodeClassField
* a special type of parameter.. occurs on class declarations.
*/
class CodeClassField : public CodeParameter
{
Q_OBJECT
......@@ -44,9 +33,6 @@ public:
enum ClassFieldType { Attribute, PlainAssociation, Self, Aggregation, Composition, Unknown_Assoc };
// Constructors/Destructors
//
/**
* Constructors
*/
......@@ -70,17 +56,11 @@ public:
*/
virtual ~CodeClassField ( );
// Public attributes
//
// Public attribute accessor methods
//
/**
* Get the value of m_dialog
* @return the value of m_dialog
*/
// CodeClassFieldDialog getDialog ( );
// /**
// * Get the value of m_dialog
// * @return the value of m_dialog
// */
// CodeClassFieldDialog getDialog ( );
// Determine if this cf is attribute or some type of association
QString getTypeName ( );
......@@ -97,14 +77,16 @@ public:
*/
CodeAccessorMethodList getMethodList() const;
/** Utility method to allow finding particular accessor method of this
* code class field by its type identifier.
/**
* Utility method to allow finding particular accessor method of this
* code class field by its type identifier.
*/
CodeAccessorMethod * findMethodByType(CodeAccessorMethod::AccessorType type, int role_id = -1);
/** Determine whether the parent object in this classfield indicates that it is
* a single variable or a List (Vector). One day this will be done correctly with special
* multiplicity object.
/**
* Determine whether the parent object in this classfield indicates that it is
* a single variable or a List (Vector). One day this will be done correctly with special
* multiplicity object.
*/
bool fieldIsSingleValue ( );
......@@ -120,30 +102,34 @@ public:
// of objects (as per specification of associations)
QString getListObjectType();
/** determine if we will *allow* methods to be viewable.
/**
* Determine if we will *allow* methods to be viewable.
* this flag is often used to toggle autogeneration of accessor
* methods in the code class field.
*/
bool getWriteOutMethods () const;
/** determine if we will *allow* methods to be viewable.
/**
* Determine if we will *allow* methods to be viewable.
* this flag is often used to toggle autogeneration of accessor
* methods in the code class field.
*/
void setWriteOutMethods( bool val);
/** Find the minimum number of things that can occur in an association
* If mistakenly called on attribute CF's the default value of is "0"
* is returned. Similarly, if the association (role) CF doesn't have a multiplicty
* 0 is returned.
*/
/**
* Find the minimum number of things that can occur in an association
* If mistakenly called on attribute CF's the default value of is "0"
* is returned. Similarly, if the association (role) CF doesn't have a multiplicty
* 0 is returned.
*/
int minimumListOccurances( );
/** Find the maximum number of things that can occur in an association
* If mistakenly called on attribute CF's the default value of is "1"
* is returned. If the association (role) CF doesn't have a multiplicty
* or has a "*" specified then '-1' (unbounded) is returned.
*/
/**
* Find the maximum number of things that can occur in an association
* If mistakenly called on attribute CF's the default value of is "1"
* is returned. If the association (role) CF doesn't have a multiplicty
* or has a "*" specified then '-1' (unbounded) is returned.
*/
int maximumListOccurances( );
/**
......@@ -156,8 +142,9 @@ public:
*/
virtual void loadFromXMI ( QDomElement & root );
/** Force the synchronization of the content (methods and declarations)
* of this class field.
/**
* Force the synchronization of the content (methods and declarations)
* of this class field.
*/
virtual void synchronize ();
......@@ -169,17 +156,20 @@ public:
protected:
/** Set the parent UMLobject appropriately.
/**
* Set the parent UMLobject appropriately.
*/
void setParentUMLObject (UMLObject * obj);
// CodeClassFieldDialog * m_dialog;
/** a little utility method to make life easier for code document programmers
/**
* A little utility method to make life easier for code document programmers
*/