Commit d6036636 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fully support optional fields in ASN.1 types

parent 72aafa41
......@@ -1437,6 +1437,10 @@ def _prim_selector(prim):
field_name=field_name,
ada_string=ada_string))
else:
# SEQUENCE, check for field optionality first
child = child_spelling(field_name, receiver_bty)
if receiver_bty.Children[child].Optional == 'True':
stmts.append('{}.Exist.{} := 1;'.format(ada_string, field_name))
ada_string += '.' + field_name
return stmts, unicode(ada_string), local_decl
......@@ -2466,6 +2470,14 @@ def type_name(a_type, use_prefix=True):
raise NotImplementedError('Type name for {}'.format(a_type.kind))
def child_spelling(name, bty):
''' Return the index in Children with the proper spelling (case, dash) '''
for each in bty.Children:
if name.lower().replace('_', '-') == each.lower():
return each
raise TypeError('Child not found: {}'.format(name))
def find_var(var):
''' Return a variable from the scope, with proper case '''
for visible_var in VARIABLES.viewkeys():
......
TASTE-Dataview DEFINITIONS ::=
BEGIN
-- Data view with optional fields, including mixed case,
-- and dash
Seq ::= SEQUENCE {
a BOOLEAN OPTIONAL
a BOOLEAN OPTIONAL,
b SEQUENCE {
b-C BOOLEAN OPTIONAL
} OPTIONAL
}
--SeqPresent ::= Seq (WITH COMPONENTS {a PRESENT})
--SeqAbsent ::= Seq (WITH COMPONENTS {a ABSENT})
......
......@@ -26,17 +26,21 @@ dcl s2 Seq;
/* CIF ENDTEXT */
/* CIF START (97, 224), (70, 35) */
START;
/* CIF TASK (66, 274), (130, 35) */
/* CIF TASK (67, 274), (130, 35) */
TASK s2 := { a FALSE};
/* CIF TASK (74, 324), (114, 35) */
/* CIF TASK (75, 324), (114, 35) */
TASK s2!a := TRUE;
/* CIF NEXTSTATE (97, 374), (70, 35) */
/* CIF TASK (62, 374), (139, 35) */
TASK s2!b!b_c := TRUE;
/* CIF TASK (52, 424), (159, 35) */
TASK s2 :={ b { b_c TRUE }};
/* CIF NEXTSTATE (97, 474), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (97, 374), (70, 35) */
/* CIF STATE (97, 474), (70, 35) */
STATE wait;
/* CIF INPUT (89, 429), (84, 35) */
/* CIF INPUT (89, 529), (84, 35) */
INPUT run;
/* CIF NEXTSTATE (87, 479), (88, 35) */
/* CIF NEXTSTATE (87, 579), (88, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS og;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment