Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xbase] LValue-like expressions in DSL
[Xbase] LValue-like expressions in DSL [message #1005779] Mon, 28 January 2013 17:11 Go to next message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
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
Re: [Xbase] LValue-like expressions in DSL [message #1005873 is a reply to message #1005779] Tue, 29 January 2013 07:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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
Re: [Xbase] LValue-like expressions in DSL [message #1007051 is a reply to message #1005873] Mon, 04 February 2013 09:15 Go to previous message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 112
Registered: July 2009
Senior Member
Hello Sebastian,


Thank you very much for the reply!
Currently I solved this problem by redesigning the DSL Smile
Hope to get away with it til 2.4 is out.


Regards,
Boris
Previous Topic:How to build multiple entities in one rule?
Next Topic:Model serialization is very slow
Goto Forum:
  


Current Time: Thu Mar 28 19:36:29 GMT 2024

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

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

Back to the top