with ASN1_Ada_Iterators.iterators; -- Generated by asn1scc using custom stg file use ASN1_Ada_Iterators.iterators; with TASTE_DataView; use TASTE_DataView; with ada.text_io; use ada.text_io; procedure test_generic is -- THIS IS HOW TO DO IT MANUALLY: -- -- create an Integer type with a range constraint -- package MyInteger is new Generic_Integer (1, 4); -- -- -- create an iterator for a variable size array of integers -- Package MyVarSeqOf_Pkg is new Generic_SeqOf (Min => 1, -- Max => 5, -- Basic => MyInteger.It); -- -- -- create an iterator for an array of integers as defined above -- Package MySeqOF_Pkg is new Generic_SeqOf (Min => 3, -- Max => 3, -- Basic => MyInteger.It); -- use MyInteger_Pkg; use MySeqOf_Pkg; use MyVarSeqOf_Pkg; use MyEnum_Pkg; use MySeqOfEnum_Pkg; -- Test cases MyIt : MyInteger_Pkg.Instance; Fixed_SeqOf : MySeqOf_Pkg.Instance; Var_SeqOf : MyVarSeqOf_Pkg.Instance; Enum : MyEnum_Pkg.Instance; SeqOfEnum : MySeqOfEnum_Pkg.Instance; SeqOfItm : asn1SccMySeqOf; VarSeqOfItm : asn1SccMyVarSeqOf; SeqOfEnumItm : asn1SccMySeqOfEnum; i : Natural := 1; begin -- test: compute all possible values of the integer type -- (equivalent to "for each in 1..3 loop put_line(each'img); end loop;") for each of MyIt loop --Put_Line(each'img); Put_Line(Image(each)); end loop; -- test: compute all combinations of values for the fixed-size array Put_Line ("Variable-size array:"); for each of Var_SeqOf loop To_ASN1 (From => each, To => VarSeqOfItm); Put(Image(VarSeqOfItm)); i := (if i mod 10 = 0 then 1 else i + 1); if i = 1 then New_Line; end if; end loop; -- test: compute all combination of values for the variable-size array New_Line; Put_Line ("Fixed-size array:"); i := 1; for each of Fixed_SeqOf loop To_ASN1 (From => each, To => SeqOfItm); Put(Image(SeqOfItm)); i := (if i mod 10 = 0 then 1 else i + 1); if i = 1 then New_Line; end if; end loop; New_Line; Put_Line ("Enumerated type"); for Each of Enum loop Put_Line (Image (Each)); end loop; New_Line; Put_Line ("Sequence of Enumerated type"); for Each of SeqOfEnum loop To_ASN1 (From => Each, To => SeqOfEnumItm); Put (Image (SeqOfEnumItm) & " "); end loop; New_Line; end;