|
Re: [Acceleo] How to override templates [message #64093 is a reply to message #64070] |
Thu, 09 July 2009 16:08 |
|
This is a multi-part message in MIME format.
--------------000509050008020809090905
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi Robert,
The extension point should only be used if you're overriding module is
contained in a different plugin that the overriden one, and both plugins
are not working together (M1 explicitely calls M2, both plugins are
bundled together, ...). This extension point indicates that another
plugin (either in the workspace or the installed plugin) provides an
override of a given module without having the original generator call
this overriding module explicitely.
If what your trying to do is simply have a module override another, you
only need to tell M2 that it 'extends' M1, and that template
overriding_base 'overrides' base.
----------8<----------
[module M1(<metamodel>)/]
[template public base(arg : <type>)]
[/template]
[module M2(<metamodel>) extends M1/]
[template public base(arg : <type>) overrides base]
[/template]
---------->8----------
Whether this overriding module is 'dynamic' or not, the above is what's
needed. The plugin containing M2 must have a dependency on the module
containing M1. Iff your override is a dynamic override, you need to use
the extension point in addition. The only attribute of this extension
point is the path of the dynamic templates (the more precise it is, the
more efficient; but you can very well tell the overriding modules are in
"/", they'll be sought recursively).
Regards,
Laurent Goubet
Obeo
Robert Walter a
|
|
|
|
Re: [Acceleo] How to override templates [message #64531 is a reply to message #64160] |
Wed, 15 July 2009 10:16 |
|
This is a multi-part message in MIME format.
--------------070501080609030404030704
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Robert,
I don't really understand your issue here but with what you listed, in
any module that extends or imports M3 (that is, M3::base() is
accessible), M3.base() will be called insteads of M2::base() and
M1::base(). In any module that does not import or extend M3, the first
accessible template will be called.
----------8<----------
[module M4(<metamodel)]
[import M2]
[import M1]
....
---------->8----------
----------8<----------
[module M5(<metamodel)]
[import M1]
[import M2]
....
---------->8----------
In M4, calling "base" will call M2::base(), in M5, calling "base" will
call M1::base(). Of course if either "base()" has a more specific type
for the passed argument, it will be called instead if the runtime class
of this argument is the most specific ...
Section 8.1.3 of the specification (
http://www.omg.org/spec/MOFM2T/1.0/PDF ), though ambiguous for most
cases, describes the general idea of how we resolve template calls.
Laurent Goubet
Obeo
Robert Walter a
|
|
|
|
Powered by
FUDForum. Page generated in 0.04238 seconds