Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Question on subtyping and TCI UnionValue::getVariantNames

Question on subtyping and TCI UnionValue::getVariantNames 15 Jul 2004 13:05 #6736

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hello everyone

I have a question on the TCI operations of UnionValue, and the union type,
and subtyping within structured types. Here's what the TCI standard
says:

"
TCI: 7.2.2.2.15 The abstract data type UnionValue

Value getVariant(in TString variantName)

Returns the value of the TTCN-3 union variantName, variantName equals
the result of getPresentVariantName, the distinct otherwise.
variantName denotes the name variant as defined in TTCN-3

void setVariant(in TString variantName, in Value value)

Sets variantName of the union to value. If is not defined for this
union this operation is variant was selected the new variant is
selected

TString getPresentVariantName()

Returns a String representing the currently selected name in the given
TTCN-3 union. The distinct returned if no variant is selected

TStringSeq getVariantNames()

Returns a sequence of string of variant names, null, if the union has
no fields. If the UnionValue represents the TTCN-3 anytype, i.e. the
type obtained by getType() is ANYTYPE, all user-defined TTCN-3 types is
returned
"

What are the "variant names"? Are they the field names, or the field
types? From the definition of getVariantNames() I get the idea, that it
returns type identifiers, not field names. For the RecordValue type, the
TStringSeq getFieldNames() operation returns field names, not types.

If getVariantNames() returns type identifiers, then consider the following
union definition, which is legal according to BNF and not prohibited by
the core standard. At least I could not find any mention.

type union myUnion
{
integer smallNumber (1),
integer greatNumber (100)
} with
{
encode (smallNumber) "smallRule";
encode (greatNumber) "greatRule";
}
Now, how does one set value for the field smallNumbers with setVariant(),
if it takes as a parameter the field type? Both choices have the same
type identifier but they are different subtypes.

You could say that the TE/tool has given them different internal type
identifiers, and those are returned with getVariantNames().

But I don't see any reason why this would be illegal either:

type union myUnion
{
integer smallNumber,
integer greatNumber
} with
{
encode (smallNumber) "smallRule";
encode (greatNumber) "greatRule";
}

or

type union myUnion
{
integer smallNumber,
integer greatNumber
}

For the last one there is an example in the standard.

I guess the TE/tool could again give them different internal type
identifiers, but it has to also store the information, that these types
are just aliases for the integer type, and they are compatible with it.

If the TE/tool generates new type identifiers for the field types,
then type identifier specific codecs cannot be used, or they can
be used, but they become tool spesific, since they have to know
the tool spesific rule how the type identifiers are generated.

Summa summarum:

1. Should it be illegal to define new subtypes within structured types?

2. Should it be illegal to have fields of the same (sub)type within a
structured type?

3. Should there be the operation TStringSeq getFieldNames() for the
unionValue also?

4. Something else should be changed?

I don't expect yes to all of them :)

BR
Antti
The administrator has disabled public write access.

Question on subtyping and TCI UnionValue::getVariantNames 15 Jul 2004 13:48 #6737

Antti,

getVariantNames() returns all union field names, not type identifiers.
Field names of a special TTCN-3 type 'anytype' (which is defined as a
union) correspond to all type identifiers defined in the module, so
that could be a confusing part of getVariantNames() definition in TCI.

Hope this helps,
Alexey

Antti Hyrkkanen wrote:

>What are the "variant names"? Are they the field names, or the field
>types? From the definition of getVariantNames() I get the idea, that it
>returns type identifiers, not field names. For the RecordValue type, the
>TStringSeq getFieldNames() operation returns field names, not types.
>
>
The administrator has disabled public write access.

Question on subtyping and TCI UnionValue::getVariantNames 16 Jul 2004 06:20 #6738

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hi Alexey

Thanks for the response, it makes sense now.
All my previous reasoning was based on that it would return type
identifiers for also all the other types than anytype, so nothing
I wrote is valid anymore :)

Antti

Original Message
From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Alexey Mednonogov
Sent: Thursday, July 15, 2004 15:48 PM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Question on subtyping and TCI UnionValue::getVariantNames


Antti,

getVariantNames() returns all union field names, not type identifiers.
Field names of a special TTCN-3 type 'anytype' (which is defined as a
union) correspond to all type identifiers defined in the module, so
that could be a confusing part of getVariantNames() definition in TCI.

Hope this helps,
Alexey

Antti Hyrkkanen wrote:

>What are the "variant names"? Are they the field names, or the field
>types? From the definition of getVariantNames() I get the idea, that it
>returns type identifiers, not field names. For the RecordValue type, the
>TStringSeq getFieldNames() operation returns field names, not types.
>
>
The administrator has disabled public write access.

Question on subtyping and TCI UnionValue::getVariantNames 16 Jul 2004 07:50 #6739

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Commenting my own posting, is there still a problem with subtyping
within structured types with the currently available operations,
if it is not accepted, that decoder may set values that do not honor
subtype restrictions?

> > > type union myUnion
> > > {
> > > integer smallNumber (1),
> > > integer greatNumber (100)
> > > } with
> > > {
> > > encode (smallNumber) "smallRule";
> > > encode (greatNumber) "greatRule";
> > > }

Where does the decoder get the in-parameter "Value value" of
right type for

setVariant(in TString variantName, in Value value)?

It does not know the identifiers of the subtypes that
are used for the fields.

Even if the fields were not subtyped, how can the decoder
get the encode attributes? (This one I also asked in
my posting "Questions on attributes and structures types"
for which I have not had any responses so far").

> >
Original Message
> > From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> > [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Alexey Mednonogov
> > Sent: Thursday, July 15, 2004 15:48 PM
> > To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> > Subject: Re: Question on subtyping and TCI UnionValue::getVariantNames
> >
> >
> > Antti,
> >
> > getVariantNames() returns all union field names, not type identifiers.
> > Field names of a special TTCN-3 type 'anytype' (which is defined as a
> > union) correspond to all type identifiers defined in the module, so
> that could be a confusing part of getVariantNames() definition in TCI.

> Hi Alexey
>
> Thanks for the response, it makes sense now.
> All my previous reasoning was based on that it would return type
> identifiers for also all the other types than anytype, so nothing
> I wrote is valid anymore :)
>
> Antti
The administrator has disabled public write access.

Question on subtyping and TCI UnionValue::getVariantNames 16 Jul 2004 07:57 #6740

Hi antti,

your example is not a subtype of a union .. but (implicit) basic type subtypes _used in_ a union type. That's a different issue. The only place I can think of subtyping for structured types is length restrictions for record of or set of types.

Moikka,
stephan


>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Antti Hyrkkanen
> Sent: 16 July, 2004 10:51
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Question on subtyping and TCI UnionValue::getVariantNames
>
>
> Commenting my own posting, is there still a problem with subtyping
> within structured types with the currently available operations,
> if it is not accepted, that decoder may set values that do not honor
> subtype restrictions?
>
> > > > type union myUnion
> > > > {
> > > > integer smallNumber (1),
> > > > integer greatNumber (100)
> > > > } with
> > > > {
> > > > encode (smallNumber) "smallRule";
> > > > encode (greatNumber) "greatRule";
> > > > }
>
> Where does the decoder get the in-parameter "Value value" of
> right type for
>
> setVariant(in TString variantName, in Value value)?
>
> It does not know the identifiers of the subtypes that
> are used for the fields.
>
> Even if the fields were not subtyped, how can the decoder
> get the encode attributes? (This one I also asked in
> my posting "Questions on attributes and structures types"
> for which I have not had any responses so far").
>
> > >
Original Message
> > > From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only
> > > [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Alexey Mednonogov
> > > Sent: Thursday, July 15, 2004 15:48 PM
> > > To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> > > Subject: Re: Question on subtyping and TCI
> UnionValue::getVariantNames
> > >
> > >
> > > Antti,
> > >
> > > getVariantNames() returns all union field names, not type
> identifiers.
> > > Field names of a special TTCN-3 type 'anytype' (which is
> defined as a
> > > union) correspond to all type identifiers defined in the
> module, so
> > that could be a confusing part of getVariantNames()
> definition in TCI.
>
> > Hi Alexey
> >
> > Thanks for the response, it makes sense now.
> > All my previous reasoning was based on that it would return type
> > identifiers for also all the other types than anytype, so nothing
> > I wrote is valid anymore :)
> >
> > Antti
>
The administrator has disabled public write access.

Question on subtyping and TCI UnionValue::getVariantNames 16 Jul 2004 08:23 #6741

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hi Stephan

You are right. But with "subtyping within structured types" I meant the
"(implicit) basic type subtypes _used in_ a union type."

When I construct that a value of for the union type in my example,
does the field value I set have to be of the particular
"implicit basic subtype", or may I use the basic type?

Is this legal:

Type fieldType = getInteger();
Value fieldValue = fieldType.newInstance();
fieldValue = setInteger(1);
setVariant("smallNumber", fieldValue);

I set the field to a value of type "integer", and not to that
"implicit_integer_subtype", so is there a problem? The number
that is contained with fieldValue is compatible to the
implicit subtype though.

Original Message
From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Dr. Schulz Stephan
Sent: Friday, July 16, 2004 09:58 AM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Question on subtyping and TCI UnionValue::getVariantNames


Hi antti,

your example is not a subtype of a union .. but (implicit) basic type
subtypes _used in_ a union type. That's a different issue. The only place I
can think of subtyping for structured types is length restrictions for
record of or set of types.

Moikka,
stephan


>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Antti Hyrkkanen
> Sent: 16 July, 2004 10:51
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Question on subtyping and TCI UnionValue::getVariantNames
>
>
> Commenting my own posting, is there still a problem with subtyping
> within structured types with the currently available operations,
> if it is not accepted, that decoder may set values that do not honor
> subtype restrictions?
>
> > > > type union myUnion
> > > > {
> > > > integer smallNumber (1),
> > > > integer greatNumber (100)
> > > > } with
> > > > {
> > > > encode (smallNumber) "smallRule";
> > > > encode (greatNumber) "greatRule";
> > > > }
>
> Where does the decoder get the in-parameter "Value value" of
> right type for
>
> setVariant(in TString variantName, in Value value)?
>
> It does not know the identifiers of the subtypes that
> are used for the fields.
>
> Even if the fields were not subtyped, how can the decoder
> get the encode attributes? (This one I also asked in
> my posting "Questions on attributes and structures types"
> for which I have not had any responses so far").
>
> > >
Original Message
> > > From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only
> > > [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Alexey Mednonogov
> > > Sent: Thursday, July 15, 2004 15:48 PM
> > > To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> > > Subject: Re: Question on subtyping and TCI
> UnionValue::getVariantNames
> > >
> > >
> > > Antti,
> > >
> > > getVariantNames() returns all union field names, not type
> identifiers.
> > > Field names of a special TTCN-3 type 'anytype' (which is
> defined as a
> > > union) correspond to all type identifiers defined in the
> module, so
> > that could be a confusing part of getVariantNames()
> definition in TCI.
>
> > Hi Alexey
> >
> > Thanks for the response, it makes sense now.
> > All my previous reasoning was based on that it would return type
> > identifiers for also all the other types than anytype, so nothing
> > I wrote is valid anymore :)
> >
> > Antti
>
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin