|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
| Arnaud Cuccuru
Registered: April 2010
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.
Powered by FUDForum
. Page generated in 0.05276 seconds