[QVTO] Default initialization of * features [message #870776] |
Wed, 09 May 2012 11:32  |
Eclipse User |
|
|
|
A target EClass has a *-feature, i.e. cardinality is > 1. After instantiating the EClass within QVTO, the following queries lead to the following results:
(o.ref = null) is false, which implies that the feature has been initialized automatically
(o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does not return true or false in favor of an empty sequence. I do not assume that this is the intended behaviour?
(o.ref->size()) is 0, which makes sense
On intermediate class objects, the situation is even more weird. After creation of an intermediate class object:
(o.ref = null) is false, same behaviour as for default objects
(o.ref.oclIsUndefined()) is [true], obviously the result is a seqauence containing an instance of OclVoid
(o.ref->size()) is 1, which is normally not expected behaviour and caused serious problems in my case
Why does oclIsUndefined() return a sequence at all and why does the sequence contain an instance of OclVoid in case of an intermediate class?
|
|
|
Re: [QVTO] Default initialization of * features [message #870784 is a reply to message #870776] |
Wed, 09 May 2012 12:13   |
Eclipse User |
|
|
|
Hi
o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.
You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.
With QVTo you are using the Ecore binding of Eclipse OCL. This has some
problems in null/invalid/deep collection corner cases, which only
acquired a meaningful specification in OCL 2.3, which postdates QVTo 1.1.
Regards
Ed Willink
On 09/05/2012 16:33, Christopher G. wrote:
> A target EClass has a *-feature, i.e. cardinality is > 1. After
> instantiating the EClass within QVTO, the following queries lead to
> the following results:
>
> (o.ref = null) is false, which implies that the feature has been
> initialized automatically
> (o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does
> not return true or false in favor of an empty sequence. I do not
> assume that this is the intended behaviour?
>
> (o.ref->size()) is 0, which makes sense
>
>
> On intermediate class objects, the situation is even more weird. After
> creation of an intermediate class object:
>
> (o.ref = null) is false, same behaviour as for default objects
> (o.ref.oclIsUndefined()) is [true], obviously the result is a
> seqauence containing an instance of OclVoid
>
> (o.ref->size()) is 1, which is normally not expected behaviour and
> caused serious problems in my case
>
> Why does oclIsUndefined() return a sequence at all and why does the
> sequence contain an instance of OclVoid in case of an intermediate class?
|
|
|
Re: [QVTO] Default initialization of * features [message #870990 is a reply to message #870784] |
Thu, 10 May 2012 09:35   |
Eclipse User |
|
|
|
Edward Willink wrote on Wed, 09 May 2012 12:13Hi
o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.
Okay, this makes sense.
Edward Willink wrote on Wed, 09 May 2012 12:13
You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.
Size 1 is sensible, why? The object o is created via 'object' keyword. Without explicit initialization of the ref feature, the null check returns false. Obviously, the feature has been initialized automatically. For the automatic initialization I would assume an empty collection. Instead, there seems to be an instance of OclVoid inside the collection, which implies the size 1.
The actual problem is that the OclVoid instance remains during execution, i.e. when first adding to that collection, the size is 2 and so on...
|
|
|
Re: [QVTO] Default initialization of * features [message #871357 is a reply to message #870990] |
Sat, 12 May 2012 06:29   |
Eclipse User |
|
|
|
Hi
As I wrote: You don't say how you create your intermediate class object
.... seems very sensible to me.
Without a clear exposition of what you are actually doing, I cannot
explain the subtleties of null content to you.
Regards
Ed Willink
On 10/05/2012 14:35, Christopher G. wrote:
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> Hi
>>
>> o.ref.oclIsUndefined() is a shortform for
>> o.ref->collect(oclIsUndefined()) so you get a (empty) collection of
>> the element returns.
>
>
> Okay, this makes sense.
>
>
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> You don't say how you create your intermediate class object so a
>> response is possible. I suspect you are using the implicit ->
>> conversion. o.ref->size() = 1 seems very sensible to me.
>
>
> Size 1 is sensible, why? The object o is created via 'object' keyword.
> Without explicit initialization of the ref feature, the null check
> returns false. Obviously, the feature has been initialized
> automatically. For the automatic initialization I would assume an
> empty collection. Instead, there seems to be an instance of OclVoid
> inside the collection, which implies the size 1.
>
> The actual problem is that the OclVoid instance remains during
> execution, i.e. when first adding to that collection, the size is 2
> and so on...
>
>
>
>
|
|
|
|
|
|
|
|
|
|
Re: [QVTO] Default initialization of * features [message #874826 is a reply to message #874819] |
Mon, 21 May 2012 11:57  |
Eclipse User |
|
|
|
Hi
Sorry, but I think it's about time you started doing some work for
yourself; I have my own work to do.
If you look at the QVT specification you will find at least 20 examples
of the solution to your problem and no indication that what you have
done is sensible.
Regards
Ed Willink
On 21/05/2012 16:46, Christopher G. wrote:
> Sorry, this is how I changed my intermediate class definition:
>
>
> intermediate class O {
>
> ref : O ordered;
>
> }
>
>
> The += code below produces the compilation error "Property 'ref' must
> have collection type".
>
>
> object O {
>
> ref += ...
>
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.32662 seconds