Commit bb720820 authored by Maxime Perrotin's avatar Maxime Perrotin

Add iterators for boolean types

parent 5c9b2aad
......@@ -175,6 +175,15 @@ def enum_adb_template (sort: str) -> str:
end {sort}_Pkg;'''
def boolean_adb_template (sort: str) -> str:
''' Template for the image function of a boolean '''
return f'''package body {sort}_Pkg is
function Image (Elm : asn1Scc{sort}) return String is (Elm'Img);
end {sort}_Pkg;'''
def fields_adb_init (fields : dict) -> List [str]:
'''
Template for the fields of a sequence used in the Initialize function
......@@ -325,7 +334,6 @@ def choice_adb_iterate (options: Dict[str, Tuple[str, str]]) -> List [str]:
for field, (EnumID, sort) in options.items():
result.append(f'''when {EnumID} =>
Cursor_{field} := Position.{field}_it.Next (Cursor_{field});''')
#if field != last_choice:
result.append(f''' if not P_{field}.Has_Element (Cursor_{field}) then
Cursor_Selector := Position.kind_it.Next (Cursor_Selector);
end if;''')
......@@ -709,9 +717,12 @@ def run(options):
signed_int_adb_template(name,
int(basic.Min),
int(basic.Max)))
elif basic.kind == "EnumeratedType":
elif basic.kind in ("EnumeratedType", "BooleanType"):
packages_ads.append(enum_ads_template(name))
packages_adb.append(enum_adb_template(name))
if basic.kind == "EnumeratedType":
packages_adb.append(enum_adb_template(name))
else:
packages_adb.append(boolean_adb_template(name))
elif basic.kind == "SequenceOfType":
inner=basic.type.ReferencedTypeName.replace("-", "_")
packages_ads.append(
......
......@@ -35,6 +35,8 @@ MyChoice ::= CHOICE {
choice-a MyInteger,
choice-b MySeqOf
}
Boolean ::= BOOLEAN
END
......@@ -33,6 +33,7 @@ procedure test_generic is
use MySeq3_Pkg;
use MySeq4_Pkg;
use MyChoice_Pkg;
use Boolean_Pkg;
-- Test cases
MyIt : MyInteger_Pkg.Instance;
......@@ -45,6 +46,7 @@ procedure test_generic is
Seq2 : MySeqi2_Pkg.Instance;
Seq3 : MySeq3_Pkg.Instance;
Seq4 : MySeq4_Pkg.Instance;
Bool : Boolean_Pkg.Instance;
SeqOfItm : asn1SccMySeqOf;
VarSeqOfItm : asn1SccMyVarSeqOf;
......@@ -172,6 +174,9 @@ begin
Put_Line ("total: " & count'img & " values were computed");
New_Line;
Put_Line ("BOOLEAN");
for each of Bool loop
Put (Each'Img & " ");
end loop;
New_Line;
end test_generic;
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