[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL] generating ECore!EString or ECore!EInt, ...

Olivier PATRY a écrit :
Hello,

I'm trying to transform a model conform to a personal metamodel to ECore.

In my metamodel, I had an enumeration PrimitiveType with literals String, Integer, Boolean, Float

I want to transform these personnal types into corresponding ECore types.

I try with
eType <- ECore!EString

wich works well, but I didn't know how to test the "source" type to choose the ECore type (ECore!EString, ECore!EInt, ...)

I try with an helper or lazy rule like

helper context MM!PrimitiveType def : getEType : ECore!???? =
    if String then ECore!EString
    else ...
;

lazy rule getEType
{
    from type :MM!PrimitiveType
    to etype: ECore!????(
    ??? <- EString -- how to choose the right type ?
    )
}

How can I do that, and what is the type of ECore!EString or ECore!EInt ?

Thank you.

(if there is a better way to make the correspondance between ECore primitive types (all) and personnal PrimitiveType, I'm interested ;) )

Bye.


Hello,

Have you try to do it with a guarded matching rule like :

rule primitiveTypeString2EString {
from
type : MM!PrimitiveType ( type.value = 'String' )
-- I put value for the identifier of your primitive type -- because I do not know the corresponding propêrty in -- your metamodel
to
etype: ECore!EString
}


and you can do the same thing for all other primitive type.

I do not know if this is what you expect ?

Hope this helps...

Best regards.


Guillaume Doux