Accessing Data Type Converters [message #986426] |
Tue, 20 November 2012 11:47 |
|
I have an ecore metamodel that defines an EDatatype 'Integer', whose underlying type is a primitive java long. I need to create an instance of this datatype in ATL. The assignment below:
range: UML!MultiplicityRange (
lower <- 1,
upper <- -1
)
provokes the following error:
org.eclipse.m2m.atl.engine.emfvm.VMException: java.lang.Integer cannot be cast to java.lang.Long
I believe that I have to call the type conversion or constructor explicitly, but could not find anything in the syntax that allows me to do this.
[Updated on: Tue, 20 November 2012 11:47] Report message to a moderator
|
|
|
|
Re: Accessing Data Type Converters [message #986555 is a reply to message #986436] |
Tue, 20 November 2012 22:20 |
|
Thanks for this advice, however, the error is raised on the first line. Sorry, I should have made that clear in the test case. Again: How do I declare a value to be a java long, so the type cast error does not occur?
|
|
|
Re: Accessing Data Type Converters [message #986585 is a reply to message #986555] |
Wed, 21 November 2012 05:10 |
|
I should point out that this is a special case where a transformation needs to set a feature of a user-defined EDatatype, whose value is created by a data type conversion from a string. This should be a fairly common operation, and has also been present via reflection in JMI. If this does not exist, the use of ATL is limited quite substantially, w.r.t. practical models (where custom datatypes are common).
|
|
|
|
Re: Accessing Data Type Converters [message #986656 is a reply to message #986641] |
Wed, 21 November 2012 10:10 |
|
Thanks. This is what I had feared. I have no control over the metamodel, and can not add any methods. This seems to imply that ATL is not fit as a general purpose language for Ecore. Sad about the time invested
|
|
|
Re: Accessing Data Type Converters [message #986658 is a reply to message #986656] |
Wed, 21 November 2012 10:13 |
|
I also do not believe that this would help, as you would need to add this to every context class you are using. Can I edit the wiki to add this. I really believe this deserves a warning to spare people from disappointment. I have spent about three days learning the language, and now I will have to go back all the way...
|
|
|
|
Re: Accessing Data Type Converters [message #988760 is a reply to message #986701] |
Sun, 02 December 2012 22:48 |
|
Thanks Gunnar, that does not work. I have patched /org.eclipse.m2m.atl.engine.emfvm/src/org/eclipse/m2m/atl/engine/emfvm/adapter/EMFModelAdapter.java:576ff to get it to do the trick, however this is only for longs, as this is what I needed.
@Hugo: do you think such a patch is worth contributing? I also think using the converter should not be too hard, however I do not understand if the weaver code may not be doing something similar, so I am hesitant to 'just hack it in'.
|
|
|
Re: Accessing Data Type Converters [message #988817 is a reply to message #988760] |
Mon, 03 December 2012 10:36 |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hello Jörn,
I think it is totally relevant to raise a bug proposing to improve the support for custom datatypes.
I also encourage you to attach to it any patch bringing a concrete (even if partial) solution to that problem.
Best regards,
Hugo
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Powered by
FUDForum. Page generated in 0.03448 seconds