[Solved] Using an extended set of primitive ECore types [message #1831937] |
Thu, 03 September 2020 10:12 |
Michael Relby 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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01737 seconds