Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [Solved] Using an extended set of primitive ECore types
[Solved] Using an extended set of primitive ECore types [message #1831937] Thu, 03 September 2020 10:12 Go to next message
Michael Relby is currently offline Michael RelbyFriend
Messages: 9
Registered: November 2013
Junior Member
Hello. Some types in my metamodel contains attributes of types like EByte, EFloat, which is unsupported by OCL spec. In the ATL rules (with EMFTVM compiler) I sometime need to assign a static values to such attributes like
SomeFloatAttribute <- 10.0,

This doesn't work, because at runtime this value treated as Double which produces ClassCastException when assigning to the attribute of type Float.

I did some research but as far found only two ways:


  • change metamodel, limit use of types only supported by OCL
  • use some sort of calls to a native java helper class to convert types


I hope I miss the clean and convenient way to solve this. Any help is appreciated :)

[Updated on: Fri, 04 September 2020 13:50]

Report message to a moderator

Re: Using an extended set of primitive ECore types [message #1831960 is a reply to message #1831937] Thu, 03 September 2020 17:38 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Primitive types can be obtained by using native Java methods on Integer, Double, and String:
-- @atlcompiler emftvm
module PrimitiveTypeTest;
create OUT : PTT from IN : PTT;

rule Entity {
	from
		s : PTT!Entity
	to
		t : PTT!Entity (
			byte <- 15.byteValue(),
			char <- 't'.charAt(0),
			double <- 15.8,
			float <- 15.8.floatValue(),
			int <- 31,
			long <- 31.longValue(),
			name <- 'Entity',
			short <- 31.shortValue()
		)
}


Cheers,
Dennis
Re: Using an extended set of primitive ECore types [message #1832005 is a reply to message #1831960] Fri, 04 September 2020 13:49 Go to previous message
Michael Relby is currently offline Michael RelbyFriend
Messages: 9
Registered: November 2013
Junior Member
This is exactly what I wanted! Thanks a lot, Dennis.
Previous Topic:Need help with thisModule.resolveTemp(...)
Next Topic:Run refining transformation programatically
Goto Forum:
  


Current Time: Fri Apr 19 16:35:05 GMT 2024

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

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

Back to the top