Skip to main content



      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 06:12 Go to next message
Eclipse UserFriend
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 09:50] by Moderator

Re: Using an extended set of primitive ECore types [message #1831960 is a reply to message #1831937] Thu, 03 September 2020 13:38 Go to previous messageGo to next message
Eclipse UserFriend
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()
		)
}
Re: Using an extended set of primitive ECore types [message #1832005 is a reply to message #1831960] Fri, 04 September 2020 09:49 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 22:20:53 EDT 2025

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

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

Back to the top