| ASN.1 recursive types should be better covered | Index | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ST5 | Author: Javier Lopez-Martin | Opened: Feb 24th, 97 Closed: Oct 27th, 97 |
CLOSED | ||||||||||||||||||||
| Description: | For the ASN.1 types that create
recursion, the current algorithm only solves a minimum amount. Extending
the covered cases should be considered and discussed.
Tom Thuneby of UH Communications suggests the use of ANYs to add support for recursive ASN1 types in the cases not currently covered by the standard. Here is his proposal: Mutually recursive ASN.1 types could be modelled by replacing the occurrence(s) of the second type in the first with any, which would in practice always contain a value of the second type. The programmer needs to be aware of this, and use the appropriate operations on the any. When a type refers to itself (inside e.g. CHIOCE), the rules for inline expansion are not applicable. The solution for mutually recursive types above may also be applied here. |
||||||||||||||||||||||
| Resolution: | Recursion will be treated exactly
in the same way it is now for the cases that are currently solved, and
will be broken by means of introducing a minimum number of ANYs so that
no recursion happens in the remaining recursive cases.
Voting: 5 votes for, none against |
||||||||||||||||||||||
| Text change: |
- If recursion is found, apply rules decribed in Section 2.9 on page ??.
Note that if recursion is detected, the rules described in section 2.9 Mapping of Recursive Types apply.
2.9 Mapping of Recursive Types We call recursive types those constructed types that contain an element/item of its own type. Direct recursion is when the element/item is explicitly of the container type or the element/item is a SET OF/SEQUENCE OF the container type, while indirect recursion is when the element/item is of another type, which contains a direct or indirect reference to the initial type. We call nested recusive types those types where indirect recursion happens within an element/item of a composite type (see section 2.8.1 for further definitions). Unlike ASN.1, IDL does not support recursive type definitions, except direct recursions when they are used in sequences. Indirect mutual recursion is explicitly prohibited in IDL. The only solution to indirect mutual recursion, then, is to loose type safety by introducing an IDL any, and semantically restricting its contents to those of the recursive type (applications are responsible to enforce the semantics). 2.9.1 Resolution of direct recursion ASN.1 direct recursive type definitions are mapped by converting the recursive type reference to an IDL sequence. If such reference occurs directly in a SET OF or SEQUENCE OF, then the sequence is unbounded (or bounded according to size constraints), otherwise, it is bounded to size 1. ASN.1 direct recursive type definitions are expanded in place. Note that if the element has the OPTIONAL or DEFAULT property, then the mapping is also done in place, as specified in the following clauses. For the ASN.1 clause: <type> ::= SEQUENCE { <identifier> <type> OPTIONAL }
the resultant IDL would be: struct <mapped type name> {
union <mapped identifier name>Opt switch (boolean) {
case TRUE: sequence<<mapped type name>, 1> value; } <mapped identifier name>; }; And for the ASN.1 clause: <type> ::= SEQUENCE { <identifier> [SET|SEQUENCE] OF <type> OPTIONAL }
the resultant IDL would be: struct <mapped type name> {
union <mapped identifier name>Opt switch (boolean) {
case TRUE: sequence<<mapped type name>> value; } <mapped identifier name>; }; Note: if in this case, the SET/SEQUENCE OF has a size contraint, this constraint should be applied inside the generated IDL sequence, making it bounded, as described in the section on Constrained Types. These same rules apply when a named type has the DEFAULT property, changing the "Opt" suffix of the IDL union to "Def". 2.9.1.1 Examples:
2.9.2 Resolution of indirect recursion When mapping the ASN.1 type assignment corresponding to an indirectly recursive type, all ASN.1 recursive references to this type should be considereded from this moment as references to the ASN.1 ANY type. Because of this substitution, recursion is broken, and therefore the general mapping rules are applied. Note that types must be considered in their ASN.1 input order, and that only recursive references to the type being considered are substituted by this rule. The references substituted by this rule should be mapped to the IDL type named "ASN1_Recursive", defined in the ASN1Types.idl file as: typedef any ASN1_Recursive; A comment is added to identify the IDL type corresponding to the substituted reference. Only values of this IDL type are allowed in the ASN1_Recursive. If a value of a different type is inserted, unexpected results can happen (behaviour is undefined). 2.9.2.1 Examples:
|
||||||||||||||||||||||