[Uml-devel] Code generation with entered code fragments

Andi Fischer andi.fischer at hispeed.ch
Sun Nov 25 20:15:00 UTC 2007


Commit 741510 implements the possibility to add source code, code 
fragments, or pseudo code to every operation and not only documentation.
The new elements are a tab widget and a text edit widget in the 
operations section.
The entered code (the body of the operation) is stored into the xmi-file 
and when starting code generation written to the generated source file.
For now only Python and C# are done, the other languages will follow soon.

Note: I don't know yet the right tag for the xmi-file. Can you help, Oliver?
As you can see in the following example I use <UML:SourceCode value=.... />

      <UML:Class visibility="public" isSpecification="false" 
namespace="Logical View" isAbstract="false" isLeaf="false" 
isRoot="false" xmi.id="MJCTtfsEoxQq" name="Person" >
       <UML:Classifier.feature>
        <UML:Attribute visibility="private" isSpecification="false" 
xmi.id="uiXzpj5EmpFC" type="ajFMBLpOzGgV" name="name_" />
        <UML:Attribute visibility="private" isSpecification="false" 
xmi.id="YcswJOXvn7Tn" type="ajFMBLpOzGgV" comment="Vorname" 
name="firstName_" />
        <UML:Attribute visibility="private" isSpecification="false" 
xmi.id="4v9Yf4emnhMd" type="ajFMBLpOzGgV" comment="Geschlecht" 
name="sex_" />
        <UML:Operation visibility="public" isSpecification="false" 
isQuery="false" isAbstract="false" isLeaf="false" isRoot="false" 
xmi.id="aHo5uvcmFtyg" comment="gets the name of the person." 
name="getName" >
         <UML:BehavioralFeature.parameter>
          <UML:Parameter kind="return" xmi.id="Er1p6o7oCp1Y" 
type="ajFMBLpOzGgV" />
         </UML:BehavioralFeature.parameter>
         <UML:SourceCode value="if (name_ == "TEST") {&#xa;    
return;&#xa;}" />
        </UML:Operation>

If you use this feature now then be warned, that this may change in the 
near future and could make your xmi-file unreadable.
But I don't think that there are a lot of users working with KDE4 - 
umbrello right now ;-).

Thanks!

Andi





More information about the umbrello-devel mailing list