Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] use of macro / let(loop)
[Acceleo] use of macro / let(loop) [message #667644] Sat, 30 April 2011 14:21 Go to next message
the_ch40s is currently offline the_ch40sFriend
Messages: 14
Registered: April 2011
Junior Member
Hello,
im trying do use a macro, but it simply wont work.

For Example, the following will return something like
" org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2f1e34 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@167ed25 (name: OclInvalid_Class) (instanceClassName: null) (abstract: false, interface: false)) "

code:
[comment encoding = UTF-8 /]
[module generate('http://www.test.com/test/1.0')/]

[template public generate(aClass : Class)]
[comment @main /]
	
     [test(aClass)/]

[/template]

[macro public test(arg : Class) : String]
    [arg.name/]
[/macro]


i'm trying to use macros, so the code of the template gets clearer. What have i done wrong ^^?

Also, im trying to use a let block in a for loop, something like:
for[ aClass : Class | package.eContents(Class)]
  [let var: String = aClass.name]
    [var/]
  [/let]
[/for]


This returns same "error" as above, although all classes have names. If i do aClass.name "manually" it works.

I have a working template to generate vhdl code, but it is really hard to read, since a lot of code is just copy paste of really long expressions. would be nice to be able to tidy up.

Thanks for any help Smile

greetz
Re: [Acceleo] use of macro / let(loop) [message #667830 is a reply to message #667644] Mon, 02 May 2011 11:49 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

Macros are not currently implemented in Acceleo, I am surprised the compiler does not give you any compilation error on your [macro] block.

Furthermore, macros do not (would not) work as you seem to expect. Please read the specification for details... But I really don't think macros are what you need.

The two concepts available are Templates and Queries, queries being designed for small, reusable OCL queries. We thought that those two would be sufficient to enable the use of Acceleo for most (if not all) use cases; and we decided to implement them and stabilize the whole tooling before aiming at 100% implementation of the specification.

Queries should be able to help you divide your template in small dedicated expressions ... and you may want to look at dividing your module in more than one module too.

Laurent Goubet
Obeo
Re: [Acceleo] use of macro / let(loop) [message #667927 is a reply to message #667830] Mon, 02 May 2011 19:21 Go to previous message
the_ch40s is currently offline the_ch40sFriend
Messages: 14
Registered: April 2011
Junior Member
Thanks a lot for the answer Smile

I figured i just had a semantic error in the [let] expression :\

It now works as intended, code got much smaller Smile
Previous Topic:[Acceleo] Generation templates not working with run-time meta-models and dynamic instances
Next Topic:Strange result in query
Goto Forum:
  


Current Time: Sat Apr 27 01:04:44 GMT 2024

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

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

Back to the top