Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » [Alf Editor] How to use custom primitive type in Alf?
icon5.gif  [Alf Editor] How to use custom primitive type in Alf? [message #872181] Tue, 15 May 2012 15:48 Go to next message
Jean Baucher is currently offline Jean BaucherFriend
Messages: 3
Registered: May 2012
Junior Member
I'm trying to use custom primitive types in Alf (for example: INT32) but I don't understand how to use them:
-I can't do an assignment:
Let myvar : INT32 = 42; // typing error : 42 is an integer! But I can't cast the expression.

-I can't use basics operations:
myvar = myvar + myvar; // typing error: operator '+' undefined for INT32!

I have tried to inherit INT32 from Integer, but that doesn't solve the problem. How to solve it?
Re: [Alf Editor] How to use custom primitive type in Alf? [message #875677 is a reply to message #872181] Wed, 23 May 2012 07:04 Go to previous message
Arnaud Cuccuru is currently offline Arnaud CuccuruFriend
Messages: 33
Registered: April 2010
Hello Jean,

The problem you are facing is related to automatic type conversion. The Alf specification gives a few rules about that, which concerns both Primitive types and collections.

If you consider a variable declaration like the following:
String myString = "prefix" + 4 ;

This should be automatically interprated as:
String myString = "prefix" + ToString(4) ;

where ToString (which is defined in standard Alf libraries) has the following prototype:
ToString(in p : Integer) : String.

This mechanism is not correctly implemented in the current version of the Alf editor for Papyrus. Moreover, our intuition is that it should probably be generalized to allow what you want to do. In your specific case, it would probably imply that, in addition to your primitive type INT32, you would also have to define the following FunctionBehavior somewhere in a library:
ToINT32(in p : Integer) : INT32,

which should be invoked implicitly invoked when you write something like:
INT32 myVar = 42 (i.e., INT32 myVar = ToINT32(42)

I have not checked if there is already a bug about that in the bugzilla. If not, could you please fill a bug?

Waiting for this to be supported, the only solution I see for your problem is that you define this FunctionBehavior in your model or in a model library imported by your model, and explicitly call it in your Alf statements.
Previous Topic:profile references in uml file
Next Topic:Eclipse freezing when changing to the Papyrus perspective
Goto Forum:

Current Time: Wed Aug 23 12:08:45 GMT 2017

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

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