Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Convert Float to Double - by refInvokeOperation?
Convert Float to Double - by refInvokeOperation? [message #987622] Tue, 27 November 2012 10:56 Go to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Hi members,

I'm trying to assign a Float value from a source model object to a Double attribute of the matching target model object:

rule Real2Term {
    from
    	source: transformate!RealTransformer
    to
    	otxTerm: otx!FloatLiteral (
    		value <- source.value -> refInvokeOperation('doubleValue', Sequence{})
    	)
}

which produces the error
org.eclipse.m2m.atl.engine.emfvm.VMException: Wrong use of refInvokeOperation
.
otxTerm.value is Double, source.value is Float. There is no doubleValue helper (similar to longValue), so I'm trying to access the Java method, which fails.
Thanks for helping.
Re: Convert Float to Double - by refInvokeOperation? [message #987635 is a reply to message #987622] Tue, 27 November 2012 11:42 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
This seems to do the required transformation from Float to Double:
rule Real2Term {
    from
    	source: transformate!RealTransformer
    to
    	otxTerm: otx!FloatLiteral (
    		value <- 1.0 * source.value
    	)
}


However, I would be glad if you could provide an example on how to use refInvokeOperation. I have tried to do that several times unsuccessfully.
Thank you.
Re: Convert Float to Double - by refInvokeOperation? [message #987655 is a reply to message #987635] Tue, 27 November 2012 13:05 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 604
Registered: July 2009
Senior Member
The refInvokeOperation allows to call an operation of a given element type.
For instance considering an operation SampleOperation defined for the type transformate!RealTransformer in your example, it could be called like this:
source.refInvokeOperation('SampleOperation',Sequence{})

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Convert Float to Double - by refInvokeOperation? [message #987666 is a reply to message #987622] Tue, 27 November 2012 13:53 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Hugo,

do I understand correctly that refInvokeOperation can only be used for model elements, but not - as I tried to do - for their attributes of 'plain' Java types, like Float in the given example?
Re: Convert Float to Double - by refInvokeOperation? [message #987671 is a reply to message #987666] Tue, 27 November 2012 14:21 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
refInvokeOperation has no sense if the method name is a contant.
This method is to be used with a variable method name otherwise you can call the method directly.
Re: Convert Float to Double - by refInvokeOperation? [message #987678 is a reply to message #987622] Tue, 27 November 2012 14:46 Go to previous message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Sylvain, I'm still not getting it - does that mean an ATL method (= a helper), or a Java method?
In other words: How to call a method 'directly'?
Previous Topic:ATL plugin in Eclipse
Next Topic:EDate in the transformations
Goto Forum:
  


Current Time: Tue Sep 23 16:28:22 GMT 2014

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

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