Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Method to save and edit values in ACCELEO templates(I wan't to generate some embedded code with ACCELEO templates. I need a way to save and edit values)
Method to save and edit values in ACCELEO templates [message #1699136] Sun, 21 June 2015 22:46 Go to next message
Martin Gruber is currently offline Martin GruberFriend
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5843
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 #1699174 is a reply to message #1699152] Mon, 22 June 2015 10:21 Go to previous messageGo to next message
Martin Gruber is currently offline Martin GruberFriend
Messages: 6
Registered: May 2015
Junior Member
Hello Ed,
thank you for the fast answer.

We evaluated different technologys. In our usecase, we have to provide a generator which allows the compatiblity for 5 to 10 years. And we wanted to be implementation language independend as far as possible.
That's why we thought about MOFM2T and decided to go in this direction.

Would be really sadden if we won't be able to use MOFM2T only cause of this problems.

But I understand your arguments ... perhaps we find a solution.

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 Go to previous message
Martin Gruber is currently offline Martin GruberFriend
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

Previous Topic:[XTEND] can i call a xtend template from java
Next Topic:Trouble in loading model from Action Handler
Goto Forum:
  


Current Time: Thu Apr 26 17:43:37 GMT 2018

Powered by FUDForum. Page generated in 0.02008 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software