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