comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Ada and UML
Date: Sat, 04 Sep 2010 16:51:51 +0200
Date: 2010-09-04T16:51:51+02:00	[thread overview]
Message-ID: <op.viijkpmxule2fv@garhos> (raw)
In-Reply-To: 1ae9ef14-22a1-447a-836b-9db185439a85@h37g2000pro.googlegroups.com

Le Fri, 03 Sep 2010 18:14:47 +0200, Matteo Bordin  
<matteo.bordin@gmail.com> a écrit:
> You should use Acceleo 3, which complies with the OMG model-to-text
> spec.
That was because I first get into trouble with version 3, now it is solved.

To not give erroneous picture, here is the same with the relevant version.  
Indeed, this is different. Still did not found a way to have a nicer  
output (I did the best, but still not nice).


Transormation:

    [comment encoding = UTF-8 /]
    [module Generate('http://www.eclipse.org/uml2/3.0.0/UML')/]

    [template lined(s : String)]
    [s.trim().replaceAll('\\s+', ' ')/]
    [/template]

    [template indented(s : String)]
    [s.trim().replaceAll('(\\n)\\s+', '$0 ')/]
    [/template]

    [template asTypeName(e : NamedElement) post(lined())]
       [e.name/]_Type
    [/template]

    [template asParameter(p : Parameter) post(lined())]
       [p.name/] : [p.type.asTypeName()/]
    [/template]

    [template asNextParameter(p : Parameter) post(indented())]
    ;
    [p.asParameter()/]
    [/template]

    [template asFirstParameter(p : Parameter) post(lined())]
       [p.asParameter()/]
    [/template]

    [template asSelfParameter(o : Operation) post(lined())]
       Self : [o.ancestors(Class).asTypeName()/]
    [/template]

    [template asParameterList(o: Operation) post(indented())]
       ([o.asSelfParameter()/]
       [for (p : Parameter | o.eAllContents(Parameter))]
          [if (not p.name.equalsIgnoreCase('return'))]
             [p.asNextParameter()/]
          [/if]
       [/for])
    [/template]

    [template asSignature(o: Operation) post(indented())]
       [if (o.type = null)]
          procedure [o.name/]
          [o.asParameterList()/];
       [/if]
       [if (o.type <> null)]
          function [o.name/]
          [o.asParameterList()/]
          return [o.type.asTypeName()/];
       [/if]
    [/template]

    [template publicPart(pkg: Package) post(indented())]
       [for (c : Class | pkg.eAllContents(Class))]
          type [c.asTypeName()/] is private;

          [for (o : Operation | c.eAllContents(Operation))]
             [if (o.visibility = VisibilityKind::public)]
                [o.asSignature()/]
             [/if]
          [/for]
       [/for]
    [/template]

    [template privatePart(pkg: Package) post(indented())]
       [for (c : Class | pkg.eAllContents(Class))]
          type [c.asTypeName()/] is record
             [for (p : Property | c.eAllContents(Property))]
                [p.name/] : [p.type.asTypeName()/];
             [/for]
          end record; --  [c.asTypeName()/]

          [for (o : Operation | c.eAllContents(Operation))]
             [if (o.visibility <> VisibilityKind::public)]
                [o.asSignature()/]
             [/if]
          [/for]
       [/for]
    [/template]

    [template packageSpecification(pkg : Package) post(trim())]
    package [pkg.name/] is
       [pkg.publicPart()/]
    private
       [pkg.privatePart()/]
    end [pkg.name/];
    [/template]

    [template public Generate(pkg : Package)]
       [file (pkg.name + '.ads', false, 'UTF-8')]
    [pkg.packageSpecification()/]
       [/file]
    [/template]



Sample output, using the same UML model as for the prior example (the  
“indented” method does not seem to be enough).

    package Greetings is
       type Greeting_Box_Type is private;

                    procedure Say_Hi
                           (Self : Greeting_Box_Type
                           );
                    procedure Set_Greeting_Counter
                           (Self : Greeting_Box_Type
                                     ;
                                     Value : Natural_Type
                           );
                    function Get_Greeting_Counter
                           (Self : Greeting_Box_Type
                           )
                           return Natural_Type;
    private
       type Greeting_Box_Type is record
                    Greating_Counter : Natural_Type;
              end record; --  Greeting_Box_Type

                    procedure Have_A_Private_Time
                           (Self : Greeting_Box_Type
                           );
    end Greetings;


Useful link in this context:

    http://www.omg.org/spec/MOFM2T/1.0/
    for references about MTL (you will see indeed Acceleo 3 conforms to  
this, while 2.7 was not)

-- 
“Dual licensing is the Perl's way to disinfect the GNU General Public  
Virus!” (anonymous)



  reply	other threads:[~2010-09-04 14:51 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-31 10:12 Ada and UML Yannick Duchêne (Hibou57)
2010-08-31 11:05 ` Yannick Duchêne (Hibou57)
2010-08-31 11:54   ` Yannick Duchêne (Hibou57)
2010-08-31 16:34     ` Matteo Bordin
2010-08-31 21:20       ` nobody
2010-09-02  0:19         ` Yannick Duchêne (Hibou57)
2010-09-02  6:14           ` Simon Wright
2010-09-02 20:33           ` nobody
2010-08-31 23:14       ` Yannick Duchêne (Hibou57)
2010-08-31 23:31         ` Yannick Duchêne (Hibou57)
2010-09-01  8:20         ` Matteo Bordin
2010-09-01 18:44           ` Simon Wright
2010-09-01 21:56             ` Simon Wright
2010-09-02  1:18             ` Yannick Duchêne (Hibou57)
2010-09-02 10:25               ` Brian Drummond
2010-09-02  0:43           ` Yannick Duchêne (Hibou57)
2010-09-02  7:50             ` Georg Bauhaus
2010-09-02 23:05               ` Yannick Duchêne (Hibou57)
2010-09-03  4:19                 ` Yannick Duchêne (Hibou57)
2010-09-03  6:54                   ` Matteo Bordin
2010-09-03 10:20                     ` Yannick Duchêne (Hibou57)
2010-09-03 11:33                       ` sjw
2010-09-03 13:18                   ` Hibou57 (Yannick Duchêne)
2010-09-03 16:14                     ` Matteo Bordin
2010-09-04 14:51                       ` Yannick Duchêne (Hibou57) [this message]
2010-09-06  9:21                         ` Matteo Bordin
2010-09-07 18:25                         ` Yannick Duchêne (Hibou57)
2010-09-03 16:16                     ` Matteo Bordin
2010-09-03 19:39                       ` Simon Wright
2010-08-31 18:25 ` Martin Krischik
2010-09-01  8:40   ` sjw
2010-09-02  0:22   ` Yannick Duchêne (Hibou57)
2010-09-02  4:48     ` J-P. Rosen
2010-09-02 10:34       ` Brian Drummond
2010-09-02 13:00         ` Robert A Duff
2010-09-02 13:24           ` Yannick Duchêne (Hibou57)
2010-09-10 20:13 ` Yannick Duchêne (Hibou57)
  -- strict thread matches above, loose matches on Subject: below --
2001-08-04  9:55 Paul Foster
2001-07-10 10:54 Death by analogy Part 2 (was Re: is ada dead?) Robert C. Leif, Ph.D.
2001-07-10 16:58 ` Al Christians
2001-07-10 18:39   ` Michael P. Card
2001-07-10 20:39     ` Al Christians
2001-07-10 21:11       ` Michael P. Card
2001-07-11  5:25         ` Ada and UML raj
2001-07-11  9:40           ` David C. Hoos, Sr.
2001-07-13 19:00           ` Nick Williams
2001-07-13 19:46             ` Ted Dennison
2001-07-17  8:25               ` David Humphris
2001-07-16  0:56             ` Ken Garlington
2001-07-17 18:59               ` Simon Wright
2001-07-23 14:38                 ` John Kern
2001-08-04  6:29                   ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox