|Re: [Acceleo3] Generating code for nested elements [message #558124 is a reply to message #558102]
||Fri, 10 September 2010 08:51
|| Laurent Goubet
Registered: July 2009
This is a multi-part message in MIME format.|
Content-Type: text/plain; charset=UTF-8; format=flowed
I had some trouble spotting "wrong" things in your templates, yet I do
have some things to mention :
The default Java generator considers there is a single "root" element in
your resource. This seem to be the case for you (one "root" container
that contains a number of others), but if it isn't, you'll have to alter
the "generate" method of the generated launcher in order to take into
account the other roots.
That set aside, you have an infinite loop in your "createVariables"
template. When you launch the generation that gives you an empty file,
are you sure there is nothing logged in the error log view (Window ->
show view -> Error log)? I believe you should get a
StackOverflowException. The reason is :
[template public createVariables(container : ContainerBlock)]
[for (block: PLCOpenBlock | container.blocks) ?
[container.createVariables()/] <= should be "block.createVariables()"
I don't think there are other mistakes in your templates, they seem fine
to me. Please let me know if fixing this loop doesn't help (and if you
do have something in your error log which is not a StackOverflow, please
copy the stack trace :)).
> I am developping a graphical editor with GMF in which the user is able
> to create blocks (with input and output ports) and link the ports
> together with connectors. A special type of block is a container block
> which can contain other blocks (and which opens in a separate diagram to
> reduce complexity). The main diagram is in fact just a container block.
> The final purpose will be to generate C code that evaluates all the
> blocks and assign the different input and output ports (which are just
> For now, what I am trying to achieve is to generate one file containing
> the declaration of all blocks which are not container blocks. For this,
> my first restriction is that I want to call my main template only for
> the top level container block, and not for all container blocks which
> are further down in the chain. I solved this by having a pre condition
> on the template.
> My module code looks like this:
> [comment encoding = UTF-8 /]
> [module generate(....)/]
> [template public generate(container : ContainerBlock)?
> (container.eContainer() = null)]
> [comment @main /]
> [file (container.name, false, 'UTF-8')]
> [template public createVariables(container : ContainerBlock)]
> [for (block: PLCOpenBlock | container.blocks) ? (not
> [block.type/] [block.name/];
> [for (block: PLCOpenBlock | container.blocks) ?
> This works fine only when I have one container block at the root and no
> other container blocks contained in this root container.
> As soon as I have another container block inside the root container, my
> output file is empty. It seems the "createVariables" template is not
> event called, because I added some testing output text which is not
> printed in the output file.
> What could be the reason of such a behavior ?
Content-Type: text/x-vcard; charset=utf-8;
Powered by FUDForum
. Page generated in 0.02602 seconds