|
Re: [Xbase] LValue-like expressions in DSL [message #1005873 is a reply to message #1005779] |
Tue, 29 January 2013 07:23 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Boris,
if I understood you correctly, you'd like to map a single feature call
to two different features. I'm afraid this is not straight forward and
cannot be done easily. You'd have to customize scoping heavily (sort of
introduce an artificial mapping feature that points to the getter and
setter where the feature call (id / number) points to that artificial
thing. Nevertheless you'd have to deal with a lot of stuff regarding
creation of children on demand et al.
To put a long story short: A lot of effort and deep digging into the
scoping thing. I recommend to wait for 2.4 before you start serious
efforts on this one.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 28.01.13 18:11, schrieb Boris Brodski:
> Hello,
>
> I develop a little xbase-language, that should specify mapping between
> DTO classes. Example:
>
> Java:
> ----
>
> class MyOldDTO {
> private long id;
> public long getId() {return id;}
> public void setId(long id) {this.id=id;}
> }
> class MyOldDTO {
> private long number;
> public long getNumber() {return number;}
> public void setNumber(long id) {this.number=number;}
> }
>
>
> Mapping-DSL:
> ------------
>
> mapping(MyNewDTO n, MyOldDTO o) {
> n.id <===> o.number
>
> // Could also be:
> // n.child.otherDTO.value <===> o.nodes.value
> }
>
>
> From this model I would like to generate following java snippets:
>
> // Old to New
> n.setId(o.getNumber());
>
> // New to Old
> o.setNumber(n.getId());
>
>
>
> So, the idea of grammar is to accept something like
>
> left=XAssignable '<===>' right=XAssignable
>
> where XAssignable is an 'lvalue'-like Xbase-expression (expression, that
> can be read and assigned).
>
> Do you have any ideas, how this could be implemented?
>
>
> Thanks a lot!
>
>
> Regards,
> Boris Brodski
|
|
|
|
Powered by
FUDForum. Page generated in 0.03500 seconds