[Acceleo] use of macro / let(loop) [message #667644] |
Sat, 30 April 2011 14:21  |
the_ch40s 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 
greetz
|
|
|
Re: [Acceleo] use of macro / let(loop) [message #667830 is a reply to message #667644] |
Mon, 02 May 2011 11:49   |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02289 seconds