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

Better handling of mixed case in sequences

parent a683085a
......@@ -1364,8 +1364,10 @@ def _sequence(seq):
for elem, value in seq.value.viewitems():
# Set the type of the field - easy thanks to ASN.1 flattened AST
delem = elem.replace('_', '-')
# XXX not sure the case is well handled
elem_spec = type_children[delem]
for each in type_children:
if each.lower() == delem.lower():
elem_spec = type_children[each]
break
elem_specty = elem_spec.type
value_stmts, value_str, local_var = expression(value)
if isinstance(value, (ogAST.PrimSequenceOf, ogAST.PrimStringLiteral)):
......
......@@ -692,10 +692,6 @@ def check_type_compatibility(primary, type_ref, context):
for field, val in basic_type.Children.viewitems()
if val.Optional == 'True']
user_fields = [field.lower() for field in primary.value.keys()]
# if user_nb_elem != type_nb_elem:
# raise TypeError('Wrong number of fields in SEQUENCE of type {}'
# .format(type_name(type_ref)))
# else:
for field, fd_data in basic_type.Children.viewitems():
ufield = field.replace('-', '_')
if ufield.lower() not in optional_fields \
......@@ -709,14 +705,19 @@ def check_type_compatibility(primary, type_ref, context):
continue
else:
# If the user field is a raw value
if primary.value[ufield].is_raw:
check_type_compatibility(primary.value[ufield],
casefield = ufield
for each in primary.value:
if each.lower() == ufield.lower():
casefield = each
break
if primary.value[casefield].is_raw:
check_type_compatibility(primary.value[casefield],
fd_data.type, context)
else:
# Compare the types for semantic equivalence
try:
compare_types(
primary.value[ufield].exprType, fd_data.type)
primary.value[casefield].exprType, fd_data.type)
except TypeError as err:
raise TypeError('Field ' + ufield +
' is not of the proper type, i.e. ' +
......
......@@ -2,7 +2,7 @@
PROCESS orchestrator
/* CIF COMMENT (405, 192), (71, 35) */
COMMENT 'Hello';
/* CIF TEXT (39, 94), (389, 293) */
/* CIF TEXT (39, 94), (398, 293) */
dcl seq tastE_Peek_id_list;
dcl fixed FixedString := 'Hello';
......@@ -21,16 +21,16 @@ dcl check tasTE_Peek_id;
dcl choice choice;
dcl opt SeqOpt := { a TRUE, b FALSE }; -- test optional fields
dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields
/* CIF ENDTEXT */
/* CIF PROCEDURE (727, 175), (106, 35) */
PROCEDURE emptyproc;
ENDPROCEDURE;
/* CIF START (502, 224), (80, 36) */
START;
/* CIF TASK (474, 275), (136, 35) */
TASK opt := { b TRUE }
/* CIF COMMENT (630, 275), (155, 35) */
/* CIF TASK (470, 275), (144, 35) */
TASK opt := { B TRUE }
/* CIF COMMENT (634, 275), (155, 35) */
COMMENT 'Test optional fields';
/* CIF DECISION (492, 325), (99, 50) */
DECISION 'informal'
......
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