Method to save and edit values in ACCELEO templates [message #1699136] |
Sun, 21 June 2015 22:46  |
Martin Gruber Messages: 6 Registered: May 2015 |
Junior Member |
|
|
Hello together,
I have a question which - as i read here - is not new. But the answers on the other threads did not really help me in my usecase.
What do I wan't to do:
I wan't to use ACCELEO templates to generate embedded code (ANSI C) from complex software architecture models.
In this case, most concepts of ACCELEO work perfect for my needs.
But a really important thing the possibility to create and edit temporary variables while generation. Why is it neccessary? I will give you one example:
I have to iterate through two lists and find corresponding objects (works very well with acceleo). But in addition, I have to count the loops in two cascaded for loops and here is the first problem.
Is there a possibility to get access to the outer "i" variable in two cascaded for loops?
And the second problem: When I have found corresponding objects, I have to fill a bitmask (using the outer "i" loop variable as index). I have written some java services to provide bit operations.
But as far as I can see, I have no possibility to save this bitmask as f.e. integer and edit it while iterating through the model. After the iteration, I want to print out the integer as HEX (also done via java service).
After long blabla, here the two questions:
- Is there a possibility to have access to the outer "i" of two cascaded for loops?
- Is there any possibility to create variables and edit them while generation?
This is very important for us, cause it's a important usecase.
I understand that ACCELEO tries to implement the MOFM2T, but from my point of view that are important functionalities for templating languages.
Thank you for any idea!
Kind Regards,
Martin
|
|
|
Re: Method to save and edit values in ACCELEO templates [message #1699152 is a reply to message #1699136] |
Mon, 22 June 2015 07:24   |
Ed Willink Messages: 7635 Registered: July 2009 |
Senior Member |
|
|
Hi
You have moved from simple template code generation to serious
algorithmic code generation. A pure M2T tool is not suitable for this.
If you want to retain the purity of models, I recommend that you do an
initial M2M in which you gather the significant auxiliary
characteristics that assist in your code generation. Once you have
introduced this extra stage you will gain tremendous benefits as you no
longer have to shoehorn your requirements into an unsuitable technology.
Alternatively use an impure approach such as pure Java or an enhanced
Java such as Xtend that has useful M2T template expressions.
Regards
Ed Willink
On 21/06/2015 23:46, Martin Gruber wrote:
> Hello together,
>
> I have a question which - as i read here - is not new. But the answers
> on the other threads did not really help me in my usecase.
>
> What do I wan't to do:
> I wan't to use ACCELEO templates to generate embedded code (ANSI C)
> from complex software architecture models.
> In this case, most concepts of ACCELEO work perfect for my needs.
>
> But a really important thing the possibility to create and edit
> temporary variables while generation. Why is it neccessary? I will
> give you one example:
>
> I have to iterate through two lists and find corresponding objects
> (works very well with acceleo). But in addition, I have to count the
> loops in two cascaded for loops and here is the first problem.
> Is there a possibility to get access to the outer "i" variable in two
> cascaded for loops?
>
> And the second problem: When I have found corresponding objects, I
> have to fill a bitmask (using the outer "i" loop variable as index). I
> have written some java services to provide bit operations.
> But as far as I can see, I have no possibility to save this bitmask as
> f.e. integer and edit it while iterating through the model. After the
> iteration, I want to print out the integer as HEX (also done via java
> service).
>
> After long blabla, here the two questions:
> - Is there a possibility to have access to the outer "i" of two
> cascaded for loops?
> - Is there any possibility to create variables and edit them while
> generation?
>
> This is very important for us, cause it's a important usecase.
>
> I understand that ACCELEO tries to implement the MOFM2T, but from my
> point of view that are important functionalities for templating
> languages.
>
> Thank you for any idea!
>
> Kind Regards,
> Martin
|
|
|
|
Re: Method to save and edit values in ACCELEO templates [message #1699175 is a reply to message #1699174] |
Mon, 22 June 2015 10:26  |
Martin Gruber Messages: 6 Registered: May 2015 |
Junior Member |
|
|
Hello Ed,
as short workaround (only for a try) I implemented some java services to provide the functionality (after disabling query cache).
Is there a possibility to execute a query without any return value? I tried to use "oclAny" but in this case, the generator pasts a new line on this place.
Can I avoid this?
Kind Regards,
Martin
Cause this is a seperate question, I started a new topic.
[Updated on: Tue, 23 June 2015 04:34] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02182 seconds