Login | Register
My pages Projects Community openCollabNet

Discussions > modules-dev > Code generation

argouml
Discussion topic

Hide all messages in topic

All messages in topic

Re: [argouml-modules-dev] Code generation

Author Frank Raiser <frank dot raiser at uni-ulm dot de>
Full name Frank Raiser <frank dot raiser at uni-ulm dot de>
Date 2005-07-30 05:27:37 PDT
Message On Wed, Jul 27, 2005 at 11:42:21PM +0100, Luis Sergio Oliveira wrote:
> I'm interested in your interest in working with the java RTE modules.
> Java 5
> features support is one big must that we (ArgoUML) must do. One
> big thing for this is the support of parameterized classes in ArgoUML.
> After finishing
> some things in the C++ module I must tackle this
> (http://argouml.tigri​s.org/issues/show_bu​g.cgi?id=1446) for being used
> in the
> C++ module. It is reused without effort in the java module.
> Upgrading to ANTLR 2.7.5 and aligning the java grammar with the latest
> found in
> the ANTLR sharing zone is another. This is java specific.
>
> That said, this work, if it is done the way others did it isn't very
> interesting for
> a thesis. One thing that could be different is to make reverse
> engineering by
> AST (Abstract Syntax Tree) processing instead of callbacks from the
> parser. Much more decoupled and
> gets you more flexibility in handling the context. The context is
> something that
> could be taken care using AOP (Aspect Oriented Programming). This is a
> production
> use of AOP instead of the common trace, logging or simple debugging uses.

Ok. So let me get into some more details about what I had in mind.
For about the past 2 years I've been working on the SrcML library
( http://www.srcml.de ) which is - as a short summary - a library for
converting source code into a XML representation and it helps out on
writing programs to modify this code (or creating new code).
Of course it also provides a mean to recreate original source code from
the XML version (which if I understood you correctly would come close to
what a Notation is?)

However the interesting bit is that it should be possible to generate the
source code using SrcML without knowing too much about the target language.
SrcML is a language independent markup and the actual language is only relevant
when outputting or reading source code directly. I do have to point out though,
that this is more of an experiment, as right now it's still very java centric,
as we still lack other parsers.
So in my imagination the code generation looks like: instance.addClass("MyClass");
which would work for Java just as well as for other languages. The tricky part is
of course working with language elements the target doesn't support (like interfaces
and C++) in which case the idea behind SrcML is to have the ability of querying the
capabilities of your target language (something like language.hasInterfaces().)

One substantial difference to the existing RTE from what you described would
however be the loss of whitespace. Our XML representation is concentrating on
the semantics of source code as syntax is not influencing the program behavior
(unless of course you have a language like python where whitespace is significant.)
The actual source code produced looks different depending on the plugin chosen to
output it. The overall idea behind this is: store source code on semantic level,
but work with it in exactly the formatting you prefer. If someone else needs to
read your code it'll get reformatted to their preferred kind of syntax again.

I don't know what is involved in upgrading the java grammar for ArgoUML, but
for SrcML the switch from the 1.3 to 1.5 ANTLR grammar went rather painless.

> The above isn't certainly something really new, many people have done it...
> You may also play around with MDA concepts and development.
> In my blog I describe this idea of
> MDA specification and development of programming languages. It might be
> overkill
> as a diploma thesis, but, it is certainly something new! (See
> http://argonauts-lif​e.blogspot.com/index​.html#2005-05-04).
>
> Well, don't know if this line of discourse helps or confuses ;-))...
> Just take them as
> proposes of a person who wished to have more time to explore his crazy
> ideas and
> is trying to push them to a poor victim that was just inquiring about
> some module
> workings!

I'll check it out anyways, but I can't promise you that I'm going to
tackle these issues.. as you said.. there's so many ideas and so little
time :)

--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)

Thud. Thud. Thud. Splat.
        -- (Terry Pratchett & Neil Gaiman, Good Omens)

Re: [argouml-modules-dev] Code generation

Author Frank Raiser <frank dot raiser at uni-ulm dot de>
Full name Frank Raiser <frank dot raiser at uni-ulm dot de>
Date 2005-07-30 05:02:38 PDT
Message On Wed, Jul 27, 2005 at 10:38:10PM +0200, Linus Tolke wrote:
> Hello Frank!
>
> It is kind of refreshing that you ask all these questions. I will answer and
> then you can help me by describing where in the Cookbook the answers would
> fit best.
>
> Answers below...

> You can't mix the concepts. The new module loader uses
> org.argouml.modulelo​ader.ModuleInterface​ called when enabling and disabling
> and the old module loader uses Pluggable called when used.

Does it matter which ModuleLoader is loading my module? Or do I have
to use Pluggable in order to register the code generator?
As for the Cookbook this will fit best into the section for the module loading,
i.e. sections 5.18 and 6.2. However there are a few other places where you
mention these things like in the code generation subsystem 5.7, where it gets
into the details about how to register it with org.argouml.language.Language

--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)

Falls auf Ihrer Tastatur noch keine "any key"-Taste vorhanden sein sollte,
k�nnen Sie die Funktion erreichen, indem Sie folgende Tasten gleichzeitig
gedr�ckt halten: <Linke STRG> <ALT> <F1> <ESC> <ALTGR> <P> <I> <PAUSE>
(aus der Spielanleitung f�r "Das Hexagon-Kartell")

Re: [argouml-modules-dev] Code generation

Author Luis Sergio Oliveira <euluis at zmail dot pt>
Full name Luis Sergio Oliveira <euluis at zmail dot pt>
Date 2005-07-27 15:42:21 PDT
Message Hi Frank,

Frank Raiser wrote:

>
>What I did now was implementing org.argouml.modulelo​ader.ModuleInterface​
>instead of Pluggable. Apparently there is at least half of an implementation
>for the new loader, as it did accept my module. Makes me wonder if the concepts
>can be mixed. Could I use my current module and subclass Generator2 and
>implement FileGenerator to get it working (similar to the CSharp generator?)
>
>
>
I don't know, give it a try... My feeling is that it will just use the
first it finds
or show duplicate modules. Either would be OK for getting started.

>
>>The ArgoUML java RTE is already implemented, altough a bit limited, in
>>the sence
>>the code generation may be in my opinium much improved (lack of javadoc
>>support)
>>and the RTE dialog isn't very functional. That said, I think you may
>>start from there!
>>The GeneratorJava and JavaImport are in the argouml/src_new directory.
>>The RTE
>>module is in the argouml/modules/java_rte directory. Install this RTE
>>module
>>and make some tests. This might be the best path to start.
>>
>>
>
>I know about the existence of the java generator and import. In the java_rte
>directory however I can only see code for the dialog and an empty rte/
>directory. Where's the actual logic? Or is the RTE supposed to simply regenerate
>code when the diagram changed and vice versa? Or is the generator more intelligent
>than I thought and it works incrementally?
>
>
The thing is that they have implemented it according to the JSR 26 (see
http://argonauts-lif​e.blogspot.com/index​.html#2005-05-31). For this they
store
everything the first time you reverse and then, when the code is generated
again, only delta stuff is generated. So, the logic in RTE is "in what
direction
do you want to sync this file / class?" The generation uses everything that
was first reversed, including "generation" of the previously reversed
methods,
which should be equal to the original content - to the white space.

>PS: Is there a place where the concept of the 'Notation's occuring everywhere in
>modules is explained? I currently can't figure out what a Notation is, what it's
>good for and why I have to care about it all.
>
>
Notation shows the diagrams according to the chosen notation: UML, java,
C++,
etc.

I'm interested in your interest in working with the java RTE modules.
Java 5
features support is one big must that we (ArgoUML) must do. One
big thing for this is the support of parameterized classes in ArgoUML.
After finishing
some things in the C++ module I must tackle this
 (http://argouml.tigri​s.org/issues/show_bu​g.cgi?id=1446) for being used
in the
C++ module. It is reused without effort in the java module.
Upgrading to ANTLR 2.7.5 and aligning the java grammar with the latest
found in
the ANTLR sharing zone is another. This is java specific.

That said, this work, if it is done the way others did it isn't very
interesting for
a thesis. One thing that could be different is to make reverse
engineering by
AST (Abstract Syntax Tree) processing instead of callbacks from the
parser. Much more decoupled and
gets you more flexibility in handling the context. The context is
something that
could be taken care using AOP (Aspect Oriented Programming). This is a
production
use of AOP instead of the common trace, logging or simple debugging uses.

The above isn't certainly something really new, many people have done it...
You may also play around with MDA concepts and development.
In my blog I describe this idea of
MDA specification and development of programming languages. It might be
overkill
as a diploma thesis, but, it is certainly something new! (See
http://argonauts-lif​e.blogspot.com/index​.html#2005-05-04).

Well, don't know if this line of discourse helps or confuses ;-))...
Just take them as
proposes of a person who wished to have more time to explore his crazy
ideas and
is trying to push them to a poor victim that was just inquiring about
some module
workings!

--
Luis Sergio Oliveira

RE: [argouml-modules-dev] Code generation

Author linus
Full name Linus Tolke
Date 2005-07-27 13:38:10 PDT
Message Hello Frank!

It is kind of refreshing that you ask all these questions. I will answer and
then you can help me by describing where in the Cookbook the answers would
fit best.

Answers below...

Frank Raiser wrote:
> > Of course this is the old style modules, as I don't know these new style
> > you're referring...
>
> What I did now was implementing org.argouml.modulelo​ader.ModuleInterface​
> instead of Pluggable. Apparently there is at least half of an
> implementation
> for the new loader, as it did accept my module. Makes me wonder
> if the concepts
> can be mixed. Could I use my current module and subclass Generator2 and
> implement FileGenerator to get it working (similar to the CSharp
> generator?)

You can't mix the concepts. The new module loader uses
org.argouml.modulelo​ader.ModuleInterface​ called when enabling and disabling
and the old module loader uses Pluggable called when used.

[...]
> PS: Is there a place where the concept of the 'Notation's
> occuring everywhere in
> modules is explained? I currently can't figure out what a
> Notation is, what it's
> good for and why I have to care about it all.

Notations are for displaying code segments in the diagrams.

    /Linus

Re: [argouml-modules-dev] Code generation

Author Frank Raiser <frank dot raiser at uni-ulm dot de>
Full name Frank Raiser <frank dot raiser at uni-ulm dot de>
Date 2005-07-27 02:30:47 PDT
Message On Tue, Jul 26, 2005 at 11:34:17PM +0100, Luis Sergio Oliveira wrote:
> Hi Frank,

Hello Luis,

> the best way to get moving is to check the other code generation
> modules sources, available through CVS.

I already looked at them, however I got confused with the new vs old
module loader and apparently all modules in CVS use the old loader.

> Now, to get the code generator working it must make available a
> manifest which publishes the class that implements the Pluggable
> interface. I.e., in the argouml/modules/cpp/​src/manifest.mf you
> find the entries:
>
[...]
>
> Of course this is the old style modules, as I don't know these new style
> you're referring...

What I did now was implementing org.argouml.modulelo​ader.ModuleInterface​
instead of Pluggable. Apparently there is at least half of an implementation
for the new loader, as it did accept my module. Makes me wonder if the concepts
can be mixed. Could I use my current module and subclass Generator2 and
implement FileGenerator to get it working (similar to the CSharp generator?)

> Check the unit tests in the C++ Generator module. There we create models to
> test code generation. The model API is excercised in a very simple way
> there.
> (modules/cpp/tests)

Thanks. I'll take a look at it.

> The ArgoUML java RTE is already implemented, altough a bit limited, in
> the sence
> the code generation may be in my opinium much improved (lack of javadoc
> support)
> and the RTE dialog isn't very functional. That said, I think you may
> start from there!
> The GeneratorJava and JavaImport are in the argouml/src_new directory.
> The RTE
> module is in the argouml/modules/java_rte directory. Install this RTE
> module
> and make some tests. This might be the best path to start.

I know about the existence of the java generator and import. In the java_rte
directory however I can only see code for the dialog and an empty rte/
directory. Where's the actual logic? Or is the RTE supposed to simply regenerate
code when the diagram changed and vice versa? Or is the generator more intelligent
than I thought and it works incrementally?

PS: Is there a place where the concept of the 'Notation's occuring everywhere in
modules is explained? I currently can't figure out what a Notation is, what it's
good for and why I have to care about it all.

Thanks,
--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)

I don't see the logic of rejecting data just because they seem incredible.
(Fred Hoyle)

Re: [argouml-modules-dev] Code generation

Author Frank Raiser <frank dot raiser at uni-ulm dot de>
Full name Frank Raiser <frank dot raiser at uni-ulm dot de>
Date 2005-07-27 01:55:10 PDT
Message On Wed, Jul 27, 2005 at 06:46:48AM +0200, Linus Tolke wrote:
> Hello Frank!

Hello Linus,

> The advice depends on your patience and your willingness to involve yourself
> in the project.
>
> If you are impatient you should use the existing interfaces, using the old
> module loader, and register yourself in the same way as the PHP, C++,
> Csharp, IDL modules have registered themselves. Look at how those modules do
> it.
>
> Otherwize you should wait for the new solution as described in the Cookbook,
> or better yet implement and contribute to the project.

Is there any ETA? The problem is that if I choose to work on this for my thesis
I won't really be able to spend my time with waiting (thanks to the lovely time
schedule.)

In the impatient case I will at least try to separate the registration of the
module as far as possible to make it easier to switch to the new module loader
later.

Thanks for the answer,
--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)

It is a bad plan that admits of no modifications. (Publius Syrus)

RE: [argouml-modules-dev] Code generation

Author linus
Full name Linus Tolke
Date 2005-07-26 21:46:48 PDT
Message Hello Frank!

The advice depends on your patience and your willingness to involve yourself
in the project.

If you are impatient you should use the existing interfaces, using the old
module loader, and register yourself in the same way as the PHP, C++,
Csharp, IDL modules have registered themselves. Look at how those modules do
it.

Otherwize you should wait for the new solution as described in the Cookbook,
or better yet implement and contribute to the project.

Good luck!

    /Linus

> -----Original Message-----
> From: Frank Raiser [mailto:frank.raiser​@uni-ulm.de]
> Sent: den 26 juli 2005 01:07
> To: modules-dev at argouml dot tigris dot org
> Subject: [argouml-modules-dev] Code generation
>
>
> Hello,
>
> I'm trying to implement an ArgoUML module for code generation and I got
> as far as getting my module to load properly and add a JMenu to
> the menubar.
>
> However I'm having big troubles finding the entry point for where to tell
> ArgoUML that my module can do code generation. I've seen the FileGenerator
> interface and the Generator2 class which I assume my module has
> to work with.
>
> But I could not find any place where I can add my class so that
> it is shown
> in the corresponding generator dialogs next to the java and
> csharp entries.
> I read in the cookbook that the generator handling is about to be
> changed and
> that modules should register in org.argouml.language.Language,
> but from what I
> can see this doesn't yet seem to be implemented.
>
> So here's a list of my current questions:
>
> - how do you register a code generator class?
> - is it adviceable to register it 'the old way' or is the abovementioned
> implementation coming anytime soon?
> - what amount of effort is needed to change the code from the
> old to the new
> way of registering the class?
>
> - where can I find documentation on the Action* classes and how
> to use them?
> (f.ex. to trigger XMI exporting with ActionExportXMI)
>
> - is there a way to to modify the .uml file for a diagram (with
> support from the
> ArgoUML API even?) and have the changes or the complete file
> displayed again?
> Or what is the preferred way to tackle round-trip engineering
> in ArgoUML?
>
> I'm currently trying to investigate generating and reverse
> engineering Java 1.5
> source code for ArgoUML and whether it might work out as a
> diploma thesis, so any
> help and warnings on the matter are appreciated.
>
> --
> Raiser, Frank
> Student @ University of Ulm (www.uni-ulm.de)
>
> Present to inform, not to impress; if you inform, you will impress.
> (Frederick P Brooks)
>
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
> For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org
>

Re: [argouml-modules-dev] Code generation

Author Luis Sergio Oliveira <euluis at zmail dot pt>
Full name Luis Sergio Oliveira <euluis at zmail dot pt>
Date 2005-07-26 15:34:17 PDT
Message Hi Frank,

the best way to get moving is to check the other code generation
modules sources, available through CVS.

Frank Raiser wrote:

>Hello,
>
>I'm trying to implement an ArgoUML module for code generation and I got
>as far as getting my module to load properly and add a JMenu to the menubar.
>
>However I'm having big troubles finding the entry point for where to tell
>ArgoUML that my module can do code generation. I've seen the FileGenerator
>interface and the Generator2 class which I assume my module has to work with.
>
>But I could not find any place where I can add my class so that it is shown
>in the corresponding generator dialogs next to the java and csharp entries.
>I read in the cookbook that the generator handling is about to be changed and
>that modules should register in org.argouml.language.Language, but from what I
>can see this doesn't yet seem to be implemented.
>
>So here's a list of my current questions:
>
>- how do you register a code generator class?
> - is it adviceable to register it 'the old way' or is the abovementioned
> implementation coming anytime soon?
> - what amount of effort is needed to change the code from the old to the new
> way of registering the class?
>
>
Now, to get the code generator working it must make available a
manifest which publishes the class that implements the Pluggable
interface. I.e., in the argouml/modules/cpp/​src/manifest.mf you
find the entries:

Manifest-Version: 2.0
Class-Path: argouml.jar
Created-By: 1.3.1 (Sun Microsystems Inc.)

Name: org/argouml/language​/cpp/generator/Gener​atorCpp.class
Extension-name: module.language.generator.cpp
Specification-Title: ArgoUML Dynamic Load Module
Specification-Version: 0.17.1
Specification-Vendor: University of California
Implementation-Vendor: Achim Spangler
Implementation-Version: 0.17.1
Implementation-Title: ArgoUML C++ code generator plugin for JDK 1.2+

Of course this is the old style modules, as I don't know these new style
you're referring...

>- where can I find documentation on the Action* classes and how to use them?
> (f.ex. to trigger XMI exporting with ActionExportXMI)
>
>
[sorry, I'm not very confidant about the following:] An Action is something
you instantiate from a (e.g.) GUI event handler, which contains logic to
perform
some action, such as making some operation on the model.

>- is there a way to to modify the .uml file for a diagram (with support from the
> ArgoUML API even?) and have the changes or the complete file displayed again?
> Or what is the preferred way to tackle round-trip engineering in ArgoUML?
>
>
Check the unit tests in the C++ Generator module. There we create models to
test code generation. The model API is excercised in a very simple way
there.
(modules/cpp/tests)

>I'm currently trying to investigate generating and reverse engineering Java 1.5
>source code for ArgoUML and whether it might work out as a diploma thesis, so any
>help and warnings on the matter are appreciated.
>
>
>
The ArgoUML java RTE is already implemented, altough a bit limited, in
the sence
the code generation may be in my opinium much improved (lack of javadoc
support)
and the RTE dialog isn't very functional. That said, I think you may
start from there!
The GeneratorJava and JavaImport are in the argouml/src_new directory.
The RTE
module is in the argouml/modules/java_rte directory. Install this RTE
module
and make some tests. This might be the best path to start.

Good luck :-)

--
Luis Sergio Oliveira

Code generation

Author Frank Raiser <frank dot raiser at uni-ulm dot de>
Full name Frank Raiser <frank dot raiser at uni-ulm dot de>
Date 2005-07-25 16:06:38 PDT
Message Hello,

I'm trying to implement an ArgoUML module for code generation and I got
as far as getting my module to load properly and add a JMenu to the menubar.

However I'm having big troubles finding the entry point for where to tell
ArgoUML that my module can do code generation. I've seen the FileGenerator
interface and the Generator2 class which I assume my module has to work with.

But I could not find any place where I can add my class so that it is shown
in the corresponding generator dialogs next to the java and csharp entries.
I read in the cookbook that the generator handling is about to be changed and
that modules should register in org.argouml.language.Language, but from what I
can see this doesn't yet seem to be implemented.

So here's a list of my current questions:

- how do you register a code generator class?
  - is it adviceable to register it 'the old way' or is the abovementioned
    implementation coming anytime soon?
  - what amount of effort is needed to change the code from the old to the new
    way of registering the class?

- where can I find documentation on the Action* classes and how to use them?
  (f.ex. to trigger XMI exporting with ActionExportXMI)

- is there a way to to modify the .uml file for a diagram (with support from the
  ArgoUML API even?) and have the changes or the complete file displayed again?
  Or what is the preferred way to tackle round-trip engineering in ArgoUML?

I'm currently trying to investigate generating and reverse engineering Java 1.5
source code for ArgoUML and whether it might work out as a diploma thesis, so any
help and warnings on the matter are appreciated.

--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)

Present to inform, not to impress; if you inform, you will impress.
(Frederick P Brooks)
Messages per page: