Summary: | Ada95 Code Generation Errors for Aggregation | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | Mark Gardinier <mark> |
Component: | general | Assignee: | Oliver Kellogg <okellogg> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Fedora RPMs | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
Ada95 class code generated by Umbrello
Ada95 code generated by Umbrello Ada95 code generated by Umbrello Ada95 code generated by 3rd party tool Ada95 code generated by 3rd party tool Ada95 code generated by 3rd party tool Umbrello XMl example Ada multiplicity from another UML tool |
Description
Mark Gardinier
2007-02-13 19:52:30 UTC
Created attachment 19669 [details]
Ada95 class code generated by Umbrello
Created attachment 19670 [details]
Ada95 code generated by Umbrello
Created attachment 19671 [details]
Ada95 code generated by Umbrello
Created attachment 19672 [details]
Ada95 code generated by 3rd party tool
Created attachment 19673 [details]
Ada95 code generated by 3rd party tool
Created attachment 19674 [details]
Ada95 code generated by 3rd party tool
Created attachment 19675 [details]
Umbrello XMl
Commit 141644 on branches/KDE/3.5 restored the AdaWriter::computeAssocTypeAndRole() which was completely broken. Basic handling of associations is back, up next is some refining. SVN commit 633667 by okellogg: className(): New. 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 name, and an artifical name "Object" is used as the name for the tagged type. Ideally this should be adjustable by a menu setting (later, on trunk.) CCBUG:141644 M +34 -11 adawriter.cpp M +2 -0 adawriter.h --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp #633666:633667 @@ -70,7 +70,34 @@ return true; } +QString AdaWriter::className(UMLPackage *pkgOrClass, 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 + // name. + QString retval; + QString className = cleanName(pkgOrClass->getName()); + UMLClassifier *c = dynamic_cast<UMLClassifier*>(pkgOrClass); + UMLPackage *umlPkg = pkgOrClass->getUMLPackage(); + if (umlPkg == UMLApp::app()->getDocument()->getRootFolder(Uml::mt_Logical)) { + if (! inOwnScope) + retval = className + '.'; + retval.append("Object"); + } else { + if (! inOwnScope) + retval = umlPkg->getFullyQualifiedName(".") + '.'; + retval.append(className); + } + return retval; +} + +//QString AdaWriter::scopeName(UMLPackage *pkgOrClass, bool inOwnScope) { + QString AdaWriter::qualifiedName(UMLPackage *p, bool withType, bool byValue) { + // 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 + // name. UMLPackage *umlPkg = p->getUMLPackage(); QString className = cleanName(p->getName()); QString retval; @@ -134,11 +161,6 @@ typeName = assocEnd->getFullyQualifiedName("."); UMLPackage *enclosingPkg = c->getUMLPackage(); UMLDoc *umldoc = UMLApp::app()->getDocument(); - // @todo 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 - // name. This rule should be applied consistently throughout the - // entire code generation. if (enclosingPkg == umldoc->getRootFolder(Uml::mt_Logical)) typeName.append(".Object"); if (hasNonUnityMultiplicity) @@ -292,7 +314,8 @@ UMLClassifierList superclasses = c->getSuperClasses(); - ada << getIndent() << "type Object is "; + const QString name = className(c); + ada << getIndent() << "type " << name << " is "; if (c->getAbstract()) ada << "abstract "; if (superclasses.isEmpty()) { @@ -300,12 +323,12 @@ } else { // FIXME: Multiple inheritance is not yet supported UMLClassifier* parent = superclasses.first(); - ada << "new " << qualifiedName(parent) << ".Object with "; + ada << "new " << className(parent, false) << " with "; } ada << "private;" << m_endl << m_endl; - ada << getIndent() << "type Object_Ptr is access all Object'Class;" << m_endl << m_endl; - ada << getIndent() << "type Object_Array is array Positive range <> of Object_Ptr;" << m_endl << m_endl; - ada << getIndent() << "type Object_Array_Ptr is access Object_Array;" << m_endl << m_endl; + ada << getIndent() << "type " << name << "_Ptr is access all " << name << "'Class;" << m_endl << m_endl; + ada << getIndent() << "type " << name << "_Array is array (Positive range <>) of " << name << "_Ptr;" << m_endl << m_endl; + ada << getIndent() << "type " << name << "_Array_Ptr is access " << name << "_Array;" << m_endl << m_endl; // Generate accessors for public attributes. UMLAttributeList atl; @@ -365,7 +388,7 @@ } else { // FIXME: Multiple inheritance is not yet supported UMLClassifier* parent = superclasses.first(); - ada << "new " << qualifiedName(parent) << ".Object with "; + ada << "new " << className(parent, false) << " with "; } ada << "record" << m_endl; m_indentLevel++; --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/adawriter.h #633666:633667 @@ -93,6 +93,8 @@ bool isOOClass (UMLClassifier *c); + QString className(UMLPackage *pkgOrClass, bool inOwnScope = true); + QString qualifiedName (UMLPackage *p, bool withType = false, bool byValue = false); Created attachment 19693 [details]
example Ada multiplicity from another UML tool
I just thought I would show how Rational Rose handles unspecified multiplicity
(i.e., 1..n) when generating Ada95 code. Look at the spec to Friend
(friend.1.ada). Inside it declares an unbounded array of type Handle
(Array_of_Handle) which is an access type to the class. Next it declares an
access type (Access_Array_Of_Handle) to Array_Of_Handle. Then, in class Child
(child.1.ada), it uses this type when declaring the Friend aggregation
attribute.
If only Umbrello was written in Ada. I could then help you and code this
myself.
SVN commit 633967 by okellogg: computeAssocTypeAndRole(): Fix computation of type name. Mark, is this working for you? CCBUG:141644 M +3 -1 ChangeLog M +2 -9 umbrello/codegenerators/adawriter.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #633966:633967 @@ -4,6 +4,7 @@ * Relationships for entities do not live outside of an entity relationship diagram (125146) * Javascript Code Generation creates bad format methods (135540) * Crash when deleting the link between a package and a class (141602) +* Ada95 Code Generation Errors for Aggregation (141644) Version 1.5.61 @@ -13,6 +14,7 @@ * Bugs fixed from http://bugs.kde.org: * Crash on creating various types of associations (140693, 141073, 141106, 141277) * Unclickable use case diagram (140870) +* Crash on opening xmi file produced by previous version (141279) Version 1.5.6 @@ -101,7 +103,7 @@ * Java import: method and class visibility ignored (130794) * Java import - static not handled correctly (130926) * Java import - package visibility incorrectly represented (130932) -* Java import - random import order can result in interface being teated as class (131006) +* Java import - random import order can result in interface being treated as class (131006) * Java import - associations not setup correctly, duplicate classes created (131270) Version 1.5.3 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp #633966:633967 @@ -123,7 +123,7 @@ if (assocType != Uml::at_Aggregation && assocType != Uml::at_Composition) return; const QString multi = a->getMulti(Uml::B); - bool hasNonUnityMultiplicity = !multi.isEmpty(); + bool hasNonUnityMultiplicity = (!multi.isEmpty() && multi != "1"); hasNonUnityMultiplicity &= !multi.contains(QRegExp("^1 *\\.\\. *1$")); roleName = cleanName(a->getRoleName(Uml::B)); if (roleName.isEmpty()) @@ -138,14 +138,7 @@ roleName.append(artificialName); } } - if (assocEnd == c) - typeName = assocEnd->getName(); - else - typeName = assocEnd->getFullyQualifiedName("."); - UMLPackage *enclosingPkg = c->getUMLPackage(); - UMLDoc *umldoc = UMLApp::app()->getDocument(); - if (enclosingPkg == umldoc->getRootFolder(Uml::mt_Logical)) - typeName.append(".Object"); + typeName = className(assocEnd, (assocEnd == c)); if (hasNonUnityMultiplicity) typeName.append("_Array_Ptr"); else if (assocType == Uml::at_Aggregation) Yes, thank you. It works great. But there is one more annoying bug I'm going to submit when I get a chance having to do with naming and association and then being unable to delete the name. No matter how you remove the name field, an underscore is created as an attribute. Oliver Kellogg <okellogg@users.sourceforge.net> wrote: ------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter. http://bugs.kde.org/show_bug.cgi?id=141644 ------- Additional Comments From okellogg users sourceforge net 2007-02-15 23:07 ------- SVN commit 633967 by okellogg: computeAssocTypeAndRole(): Fix computation of type name. Mark, is this working for you? CCBUG:141644 M +3 -1 ChangeLog M +2 -9 umbrello/codegenerators/adawriter.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #633966:633967 @ -4,6 +4,7 @ * Relationships for entities do not live outside of an entity relationship diagram (125146) * Javascript Code Generation creates bad format methods (135540) * Crash when deleting the link between a package and a class (141602) +* Ada95 Code Generation Errors for Aggregation (141644) Version 1.5.61 @ -13,6 +14,7 @ * Bugs fixed from http://bugs.kde.org: * Crash on creating various types of associations (140693, 141073, 141106, 141277) * Unclickable use case diagram (140870) +* Crash on opening xmi file produced by previous version (141279) Version 1.5.6 @ -101,7 +103,7 @ * Java import: method and class visibility ignored (130794) * Java import - static not handled correctly (130926) * Java import - package visibility incorrectly represented (130932) -* Java import - random import order can result in interface being teated as class (131006) +* Java import - random import order can result in interface being treated as class (131006) * Java import - associations not setup correctly, duplicate classes created (131270) Version 1.5.3 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp #633966:633967 @ -123,7 +123,7 @ if (assocType != Uml::at_Aggregation && assocType != Uml::at_Composition) return; const QString multi = a->getMulti(Uml::B); - bool hasNonUnityMultiplicity = !multi.isEmpty(); + bool hasNonUnityMultiplicity = (!multi.isEmpty() && multi != "1"); hasNonUnityMultiplicity &= !multi.contains(QRegExp("^1 *\\.\\. *1$")); roleName = cleanName(a->getRoleName(Uml::B)); if (roleName.isEmpty()) @ -138,14 +138,7 @ roleName.append(artificialName); } } - if (assocEnd == c) - typeName = assocEnd->getName(); - else - typeName = assocEnd->getFullyQualifiedName("."); - UMLPackage *enclosingPkg = c->getUMLPackage(); - UMLDoc *umldoc = UMLApp::app()->getDocument(); - if (enclosingPkg == umldoc->getRootFolder(Uml::mt_Logical)) - typeName.append(".Object"); + typeName = className(assocEnd, (assocEnd == c)); if (hasNonUnityMultiplicity) typeName.append("_Array_Ptr"); else if (assocType == Uml::at_Aggregation) Yes, thank you. It works great. But there is one more annoying bug I'm going to submit when I get a chance having to do with naming and association and then being unable to delete the name. No matter how you remove the name field, an underscore is created as an attribute.<br><br><b><i>Oliver Kellogg <okellogg@users.sourceforge.net></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> ------- You are receiving this mail because: -------<br>You reported the bug, or are watching the reporter.<br> <br>http://bugs.kde.org/show_bug.cgi?id=141644 <br><br><br><br><br>------- Additional Comments From okellogg users sourceforge net 2007-02-15 23:07 -------<br>SVN commit 633967 by okellogg:<br><br>computeAssocTypeAndRole(): Fix computation of type name.<br>Mark, is this working for you?<br>CCBUG:141644<br><br><br> M +3 -1 ChangeLog <br> M +2 -9 umbrello/codegenerators/adawriter.cpp <br><br><br>--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #633966:633967<br> @ -4,6 +4,7 @<br> * Relationships for entities do not live outside of an entity relationship diagram (125146)<br> * Javascript Code Generation creates bad format methods (135540)<br> * Crash when deleting the link between a package and a class (141602)<br>+* Ada95 Code Generation Errors for Aggregation (141644)<br> <br> Version 1.5.61<br> <br> @ -13,6 +14,7 @<br> * Bugs fixed from http://bugs.kde.org:<br> * Crash on creating various types of associations (140693, 141073, 141106, 141277)<br> * Unclickable use case diagram (140870)<br>+* Crash on opening xmi file produced by previous version (141279)<br> <br> Version 1.5.6<br> <br> @ -101,7 +103,7 @<br> * Java import: method and class visibility ignored (130794)<br> * Java import - static not handled correctly (130926)<br> * Java import - package visibility incorrectly represented (130932)<br>-* Java import - random import order can result in interface being teated as class (131006)<br>+* Java import - random import order can result in interface being treated as class (131006)<br> * Java import - associations not setup correctly, duplicate classes created (131270)<br> <br> Version 1.5.3<br>--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/adawriter.cpp #633966:633967<br> @ -123,7 +123,7 @<br> if (assocType != Uml::at_Aggregation && assocType != Uml::at_Composition)<br> return;<br> const QString multi = a->getMulti(Uml::B);<br>- bool hasNonUnityMultiplicity = !multi.isEmpty();<br>+ bool hasNonUnityMultiplicity = (!multi.isEmpty() && multi != "1");<br> hasNonUnityMultiplicity &= !multi.contains(QRegExp("^1 *\\.\\. *1$"));<br> roleName = cleanName(a->getRoleName(Uml::B));<br> if (roleName.isEmpty())<br> @ -138,14 +138,7 @<br> roleName.append(artificialName);<br> }<br> }<br>- if (assocEnd == c)<br>- typeName = assocEnd->getName();<br>- else<br>- typeName = assocEnd->getFullyQualifiedName(".");<br>- UMLPackage *enclosingPkg = c->getUMLPackage();<br>- UMLDoc *umldoc = UMLApp::app()->getDocument();<br>- if (enclosingPkg == umldoc->getRootFolder(Uml::mt_Logical))<br>- typeName.append(".Object");<br>+ typeName = className(assocEnd, (assocEnd == c));<br> if (hasNonUnityMultiplicity)<br> typeName.append("_Array_Ptr");<br> else if (assocType == Uml::at_Aggregation)<br><br></blockquote><br> Closing with okay from OP. |