Commit 0687f5a8 authored by Maxime Perrotin's avatar Maxime Perrotin

Use standard "Cursor" and "Position" names

parent d20683a4
......@@ -16,33 +16,33 @@ package body ASN1_Iterators.Generic_Basic is
Self.Is_Valid := True;
end;
function Has_Element (Ptr : Cursor) return Boolean is
(Ptr.Value.Has_Element and Ptr.Is_Valid);
function Has_Element (Position : Cursor) return Boolean is
(Position.Value.Has_Element and Position.Is_Valid);
function First (Item : Iterator) return Cursor is
begin
Item.Ptr.Value.First;
Item.Position.Value.First;
-- Reset validity flag
Item.Ptr.Is_Valid := True;
return Item.Ptr;
Item.Position.Is_Valid := True;
return Item.Position;
end;
function Next (Item : Iterator;
Ptr : Cursor) return Cursor is
Position : Cursor) return Cursor is
pragma Unreferenced (Item);
begin
Ptr.Value.Next;
return Ptr;
Position.Value.Next;
return Position;
exception
when Stop_Iteration => Ptr.Is_Valid := False;
return Ptr;
when Stop_Iteration => Position.Is_Valid := False;
return Position;
end;
function Iterate (Self : Basic_ASN1_Iterator)
return Forward_Iterator is
begin
return I: Iterator do
I.Ptr := Self'Unrestricted_Access;
I.Position := Self'Unrestricted_Access;
end return;
end;
end;
......@@ -22,26 +22,26 @@ package ASN1_Iterators.Generic_Basic is
type Cursor is access all Basic_ASN1_Iterator;
function Has_Element (Ptr : Cursor) return Boolean;
function Has_Element (Position : Cursor) return Boolean;
package Iterators is
new Ada.Iterator_Interfaces (Cursor, Has_Element);
type Iterator is new Iterators.Forward_Iterator with record
Ptr : Cursor;
Position : Cursor;
end record;
function Ptr (Item : Iterator) return Cursor is (Item.Ptr);
function Get_Cursor (Item : Iterator) return Cursor is (Item.Position);
overriding function First (Item : Iterator) return Cursor;
overriding function Next (Item : Iterator;
Ptr : Cursor) return Cursor;
Position : Cursor) return Cursor;
subtype Forward_Iterator is Iterators.Forward_Iterator'Class;
function Iterate (Self : Basic_ASN1_Iterator) return Forward_Iterator;
function Elem_Value (Self : Basic_ASN1_Iterator;
Ptr : Cursor)
return P.Sort is (Ptr.Value.Element_Value);
Position : Cursor)
return P.Sort is (Position.Value.Element_Value);
end ASN1_Iterators.Generic_Basic;
......@@ -8,65 +8,65 @@ package body ASN1_Iterators.Generic_Fixed_SeqOf is
if Self.Length > 1 then
Self.Rest := new ASN1_SeqOf (self.Length - 1);
Self.RestIt := new ASN1_SeqOf_It'(ASN1_SeqOf_It (Self.Rest.Iterate));
Self.RestIt.Ptr := Self.RestIt.First;
Self.RestIt.Position := Self.RestIt.First;
end if;
end;
function Has_Element_SeqOf (Ptr: ASN1_SeqOf_Ptr) return Boolean is
(P.Has_Element(P.Ptr(Ptr.FirstIt)));
function Has_Element_SeqOf (Position: Cursor) return Boolean is
(P.Has_Element(P.Get_Cursor (Position.FirstIt)));
function Iterate (Self : ASN1_SeqOf)
return ASN1_SeqOf_It'Class is --Iterators_SeqOf.Forward_Iterator'Class is
begin
return I: ASN1_SeqOf_It do
I.Ptr := Self'Unrestricted_Access;
I.Position := Self'Unrestricted_Access;
end return;
end;
function First (Item : ASN1_SeqOf_It) return ASN1_SeqOf_Ptr is
Ptr_Elem : P.Cursor := P.Ptr (Item.Ptr.FirstIt);
function First (Item : ASN1_SeqOf_It) return Cursor is
Ptr_Elem : P.Cursor := P.Get_Cursor (Item.Position.FirstIt);
begin
-- Initialize the iterator (Compute first value)
Item.Ptr.FirstIt := P.Iterator (Item.Ptr.FirstVal.Iterate);
Ptr_Elem := P.First (Item.Ptr.FirstIt);
Item.Ptr.Value.Data (1) := P.Elem_Value (Item.Ptr.FirstVal,
Item.Position.FirstIt := P.Iterator (Item.Position.FirstVal.Iterate);
Ptr_Elem := P.First (Item.Position.FirstIt);
Item.Position.Value.Data (1) := P.Elem_Value (Item.Position.FirstVal,
Ptr_elem);
if Item.Ptr.Length > 1 then
Item.Ptr.Value.Data (2 .. Item.Ptr.Length) :=
Item.Ptr.RestIt.Ptr.Value.Data (1 .. Item.Ptr.RestIt.Ptr.Length);
if Item.Position.Length > 1 then
Item.Position.Value.Data (2 .. Item.Position.Length) :=
Item.Position.RestIt.Position.Value.Data (1 .. Item.Position.RestIt.Position.Length);
end if;
return Item.Ptr;
return Item.Position;
end;
function Next (Item : ASN1_SeqOf_It;
Ptr : ASN1_SeqOf_Ptr) return ASN1_SeqOf_Ptr is
Position : Cursor) return Cursor is
pragma Unreferenced (Item);
Ptr_elem : P.Cursor := P.Ptr (Ptr.FirstIt);
Ptr_elem : P.Cursor := P.Get_Cursor (Position.FirstIt);
begin
if Ptr.Length > 1 then
Ptr.RestIt.Ptr := Ptr.RestIt.Next (Ptr.RestIt.Ptr);
if Has_Element_SeqOf (Ptr.RestIt.Ptr) then
Ptr.Value.Data (2 .. Ptr.Length) :=
Ptr.RestIt.Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Value.Length);
if Position.Length > 1 then
Position.RestIt.Position := Position.RestIt.Next (Position.RestIt.Position);
if Has_Element_SeqOf (Position.RestIt.Position) then
Position.Value.Data (2 .. Position.Length) :=
Position.RestIt.Position.Value.Data (1 .. Position.RestIt.Position.Value.Length);
else
Ptr.RestIt.Ptr := Ptr.RestIt.First;
Position.RestIt.Position := Position.RestIt.First;
-- Exhausted "rest": iterate on the first item
Ptr_elem := P.Next(Ptr.FirstIt, Ptr_elem);
Ptr_elem := P.Next(Position.FirstIt, Ptr_elem);
if P.Has_Element (Ptr_elem) then
Ptr.Value.Data (1) := P.Elem_Value (Ptr.FirstVal, Ptr_elem);
Ptr.Value.Data (2 .. Ptr.Length) :=
Ptr.RestIt.Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Length);
Position.Value.Data (1) := P.Elem_Value (Position.FirstVal, Ptr_elem);
Position.Value.Data (2 .. Position.Length) :=
Position.RestIt.Position.Value.Data (1 .. Position.RestIt.Position.Length);
end if;
end if;
else
-- Size is 0 or 1
Ptr_elem := P.Next (Ptr.FirstIt, Ptr_elem);
Ptr_elem := P.Next (Position.FirstIt, Ptr_elem);
if P.Has_Element (Ptr_elem) then
Ptr.Value.Data (1) := P.Elem_Value (Ptr.FirstVal, Ptr_elem);
Position.Value.Data (1) := P.Elem_Value (Position.FirstVal, Ptr_elem);
end if;
end if;
return Ptr;
return Position;
end;
end;
......@@ -17,7 +17,7 @@ package ASN1_Iterators.Generic_Fixed_SeqOf is
Data : DataArray (1 .. Max);
end record;
type ASN1_SeqOf_Ptr;
type Cursor;
type ASN1_SeqOf_It;
type ASN1_SeqOf (Size : Natural) is new Controlled
......@@ -35,28 +35,28 @@ package ASN1_Iterators.Generic_Fixed_SeqOf is
Iterator_Element => SeqOf,
Constant_Indexing => Element_SeqOf_Value;
type ASN1_SeqOf_Ptr is access all ASN1_SeqOf;
type Cursor is access all ASN1_SeqOf;
-- Constructor (called automatically)
procedure Initialize (Self : in out ASN1_SeqOf);
function Has_Element_SeqOf (Ptr : ASN1_SeqOf_Ptr) return Boolean;
function Has_Element_SeqOf (Position : Cursor) return Boolean;
package Iterators_SeqOf is
new Ada.Iterator_Interfaces (ASN1_SeqOf_Ptr, Has_Element_SeqOf);
new Ada.Iterator_Interfaces (Cursor, Has_Element_SeqOf);
type ASN1_SeqOf_It is new Iterators_SeqOf.Forward_Iterator with record
Ptr : ASN1_SeqOf_Ptr;
Position : Cursor;
end record;
overriding function First (Item : ASN1_SeqOf_It) return ASN1_SeqOf_Ptr;
overriding function First (Item : ASN1_SeqOf_It) return Cursor;
overriding function Next (Item : ASN1_SeqOf_It;
Ptr : ASN1_SeqOf_Ptr) return ASN1_SeqOf_Ptr;
Position : Cursor) return Cursor;
function Iterate (self : ASN1_SeqOf)
return ASN1_SeqOf_It'Class;
function Element_SeqOf_Value (Self : ASN1_SeqOf;
Ptr : ASN1_SeqOf_Ptr)
Position : Cursor)
return SeqOf is (self.Value);
end ASN1_Iterators.Generic_Fixed_SeqOf;
......@@ -7,18 +7,18 @@ package body ASN1_Iterators.Generic_Iterator is
-- end;
function First (Item : Iterator) return Cursor is
C: constant Cursor := Item.Ptr;
C: constant Cursor := Item.Position;
begin
C.Item.Value := ASN1_Iterable.First(ASN1_Iterable.Iterable'Class(Item.Ptr.all.Item));
C.Item.Value := ASN1_Iterable.First(ASN1_Iterable.Iterable'Class(Item.Position.all.Item));
return C;
end;
function Next (Item : Iterator;
Ptr : Cursor)
Position : Cursor)
return Cursor is
C: constant Cursor := Item.Ptr;
C: constant Cursor := Item.Position;
begin
C.Item.Value := ASN1_Iterable.Next(ASN1_Iterable.Iterable'Class(Ptr.all.Item));
C.Item.Value := ASN1_Iterable.Next(ASN1_Iterable.Iterable'Class(Position.all.Item));
return C;
end;
......@@ -26,7 +26,7 @@ package body ASN1_Iterators.Generic_Iterator is
return Iterators.Forward_Iterator'Class is
begin
return I: Iterator do
I.Ptr := self'Unrestricted_Access;
I.Position := self'Unrestricted_Access;
end return;
end;
......
......@@ -19,16 +19,16 @@ package ASN1_Iterators.Generic_Iterator is
type Cursor is access all Generic_Iterator_Type;
function Elem (Self : Generic_Iterator_Type; Ptr : Cursor)
return ASN1_Type is (Ptr.Item.Element);
function Elem (Self : Generic_Iterator_Type; Position : Cursor)
return ASN1_Type is (Position.Item.Element);
function Has_Element (Ptr : Cursor) return Boolean is
(ASN1_Iterable.Has_Element(ASN1_Iterable.Iterable'Class(Ptr.all.Item)));
function Has_Element (Position : Cursor) return Boolean is
(ASN1_Iterable.Has_Element(ASN1_Iterable.Iterable'Class(Position.all.Item)));
package Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element);
type Iterator is new Iterators.Forward_Iterator with record
Ptr : Cursor;
Position : Cursor;
end record;
--overriding
......@@ -39,7 +39,7 @@ package ASN1_Iterators.Generic_Iterator is
overriding
function Next (Item : Iterator;
Ptr : Cursor)
Position : Cursor)
return Cursor;
function Iterate (self : Generic_Iterator_Type)
......
......@@ -7,60 +7,68 @@ package body ASN1_Iterators.Generic_SeqOf is
self.RestVal := new P.ASN1_SeqOf(Self.Length);
self.RestIt :=
new P.ASN1_SeqOf_It'(P.ASN1_SeqOf_It(Self.RestVal.Iterate));
self.RestIt.Ptr := self.RestIt.First;
self.RestIt.Position := self.RestIt.First;
end if;
end;
function Has_Element_Variable_SeqOf (Ptr: ASN1_Variable_SeqOf_Ptr)
return Boolean is (Length_Pkg.Has_Element(Length_Pkg.Ptr(Ptr.LenIt)));
function Has_Element_Variable_SeqOf
(Position : Cursor)
return Boolean is
(Length_Pkg.Has_Element(Length_Pkg.Get_Cursor (Position.LenIt)));
function Iterate (self : ASN1_Variable_SeqOf)
return Iterators_Variable_SeqOf.Forward_Iterator'Class is
begin
return I: ASN1_Variable_SeqOf_It do
I.Ptr := Self'Unrestricted_Access;
I.Position := Self'Unrestricted_Access;
end return;
end;
function First (Item : ASN1_Variable_SeqOf_It)
return ASN1_Variable_SeqOf_Ptr is
return Cursor is
begin
-- Initialize the iterator (Compute first value)
Item.Ptr.LenIt := Length_Pkg.Iterator(Item.Ptr.LenVal.Iterate);
Item.Position.LenIt :=
Length_Pkg.Iterator(Item.Position.LenVal.Iterate);
-- Copy only the actual size, since the arrays may be different in size
Item.Ptr.Value.Data (1 .. Item.Ptr.RestIt.Ptr.Value.Data'Length) :=
Item.Ptr.RestIt.Ptr.Value.Data;
return Item.Ptr;
Item.Position.Value.Data
(1 .. Item.Position.RestIt.Position.Value.Data'Length) :=
Item.Position.RestIt.Position.Value.Data;
return Item.Position;
end;
function Next (Item : ASN1_Variable_SeqOf_It;
Ptr : ASN1_Variable_SeqOf_Ptr)
return ASN1_Variable_SeqOf_Ptr
is
pragma Unreferenced (Item);
Ptr_elem : Length_Pkg.Cursor := Length_Pkg.Ptr(Ptr.LenIt);
begin
Ptr.RestIt.Ptr := Ptr.RestIt.Next (Ptr.RestIt.Ptr);
if P.Has_Element_SeqOf (Ptr.RestIt.Ptr) then
Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Value.Data'Length) :=
Ptr.RestIt.Ptr.Value.Data;
function Next (Item : ASN1_Variable_SeqOf_It;
Position : Cursor)
return Cursor
is
pragma Unreferenced (Item);
Position_elem : Length_Pkg.Cursor :=
Length_Pkg.Get_Cursor (Position.LenIt);
begin
Position.RestIt.Position := Position.RestIt.Next (Position.RestIt.Position);
if P.Has_Element_SeqOf (Position.RestIt.Position) then
Position.Value.Data
(1 .. Position.RestIt.Position.Value.Data'Length) :=
Position.RestIt.Position.Value.Data;
else
Ptr.RestIt.Ptr := Ptr.RestIt.First;
-- Exhausted "rest": iterate on the first item
Ptr_elem := Ptr.LenIt.Next (Ptr_elem);
if Length_Pkg.Has_Element (Ptr_elem) then
Ptr.Value.Length := Integer (Ptr_Elem.Value.Value);
Ptr.Length := Ptr.Value.Length;
Ptr.RestVal := new P.ASN1_SeqOf(Ptr.Value.Length);
Ptr.RestIt :=
new P.ASN1_SeqOf_It'(P.ASN1_SeqOf_It (Ptr.RestVal.Iterate));
Ptr.RestIt.Ptr := Ptr.RestIt.First;
Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Value.Data'Length) :=
Ptr.RestIt.Ptr.Value.Data;
end if;
end if;
return Ptr;
end;
end;
Position.RestIt.Position := Position.RestIt.First;
-- Exhausted "rest": iterate on the first item
Position_elem := Position.LenIt.Next (Position_elem);
if Length_Pkg.Has_Element (Position_elem) then
Position.Value.Length := Integer (Position_Elem.Value.Value);
Position.Length := Position.Value.Length;
Position.RestVal := new P.ASN1_SeqOf(Position.Value.Length);
Position.RestIt :=
new P.ASN1_SeqOf_It'(P.ASN1_SeqOf_It
(Position.RestVal.Iterate));
Position.RestIt.Position := Position.RestIt.First;
Position.Value.Data
(1 .. Position.RestIt.Position.Value.Data'Length) :=
Position.RestIt.Position.Value.Data;
end if;
end if;
return Position;
end;
end ASN1_Iterators.Generic_SeqOF;
......@@ -24,7 +24,7 @@ package ASN1_Iterators.Generic_SeqOf is
-- Instantiate the package to iterate on the integer for the length
package Length_Pkg renames Length_ty.It;
type ASN1_Variable_SeqOf_Ptr is private;
type Cursor is private;
subtype MySeqOf is P.SeqOf (Max);
type ASN1_Variable_SeqOf is new Controlled
with record
......@@ -44,37 +44,37 @@ package ASN1_Iterators.Generic_SeqOf is
-- Constructor (called automatically)
procedure Initialize (Self : in out ASN1_Variable_SeqOf);
function Has_Element_Variable_SeqOf (Ptr : ASN1_Variable_SeqOf_Ptr)
function Has_Element_Variable_SeqOf (Position : Cursor)
return Boolean;
package Iterators_Variable_SeqOf is
new Ada.Iterator_Interfaces (ASN1_Variable_SeqOf_Ptr,
new Ada.Iterator_Interfaces (Cursor,
Has_Element_Variable_SeqOf);
type ASN1_Variable_SeqOf_It
is new Iterators_Variable_SeqOf.Forward_Iterator with record
Ptr : ASN1_Variable_SeqOf_Ptr;
Position : Cursor;
end record;
overriding
function First (Item : ASN1_Variable_SeqOf_It)
return ASN1_Variable_SeqOf_Ptr;
return Cursor;
overriding
function Next (Item : ASN1_Variable_SeqOf_It;
Ptr : ASN1_Variable_SeqOf_Ptr)
return ASN1_Variable_SeqOf_Ptr;
Position : Cursor)
return Cursor;
function Iterate (self : ASN1_Variable_SeqOf)
return Iterators_Variable_SeqOf.Forward_Iterator'Class;
function Element_Variable_SeqOf_Value (Self : ASN1_Variable_SeqOf;
Ptr : ASN1_Variable_SeqOf_Ptr)
Position : Cursor)
return MySeqOf is (Self.Value);
subtype Instance is ASN1_Variable_SeqOf;
private
type ASN1_Variable_SeqOf_Ptr is access all ASN1_Variable_SeqOf;
type Cursor is access all ASN1_Variable_SeqOf;
end ASN1_Iterators.Generic_SeqOF;
......@@ -34,6 +34,6 @@ package ASN1_Iterators.Iterable_Integer is
-- If it is needed to iterate manually, provide Cursor and Iterator:
subtype Cursor is Custom_Iterator.Cursor;
subtype Iterator is Custom_Iterator.Iterators.Forward_Iterator'Class;
function Has_Element (Ptr: Cursor) return Boolean
function Has_Element (Position : Cursor) return Boolean
renames Custom_Iterator.Has_Element;
end;
......@@ -11,13 +11,11 @@ package body ASN1_Iterators.Iterable_SeqOF is
end;
function Has_Element (It: ASN1_SequenceOf) return Boolean is
-- (P.Has_Element(P.Ptr(Ptr.FirstIt)));
begin
return False;
end;
function First (It: in out ASN1_SequenceOf) return Generic_SeqOf is
-- Ptr_elem : P.Cursor := P.Ptr(Item.Ptr.FirstIt);
Ret : constant Generic_SeqOf := It.Value;
begin
It.Value.Length := It.Length;
......@@ -30,48 +28,14 @@ package body ASN1_Iterators.Iterable_SeqOF is
It.Rest_It :=
new Cust_Iterator'(Custom_Iterator.Iterator (It.Rest.Iterate)
with others => <>);
It.Rest_It.Ptr := It.Rest_It.First;
It.Rest_It.Position := It.Rest_It.First;
end if;
-- Initialize the iterator (Compute first value)
-- Item.Ptr.FirstIt := P.Iterator(Item.Ptr.FirstVal.Iterate);
-- Ptr_elem := P.First(Item.Ptr.FirstIt);
-- Item.Ptr.Value.Data(1) := P.Elem_Value(Item.Ptr.FirstVal,
-- Ptr_elem);
-- if Item.Ptr.Length > 1 then
-- Item.Ptr.Value.Data(2 .. Item.Ptr.Length) :=
-- Item.Ptr.Rest_It.Ptr.Value.Data(1..Item.Ptr.Rest_It.Ptr.Length);
-- end if;
-- return Item.Ptr;
return Ret;
end;
function Next (It: ASN1_SequenceOf) return Generic_SeqOf is
--Ptr_elem : P.Cursor := P.Ptr(Ptr.FirstIt);
Temp : constant Generic_SeqOf := It.Value;
begin
-- if Ptr.Length > 1 then
-- Ptr.Rest_It.Ptr := Ptr.Rest_It.Next (Ptr.Rest_It.Ptr);
-- if Has_Element_SeqOf (Ptr.Rest_It.Ptr) then
-- Ptr.Value.Data (2..Ptr.Length) :=
-- Ptr.Rest_It.Ptr.Value.Data (1..Ptr.Rest_It.Ptr.Value.Length);
-- else
-- Ptr.Rest_It.Ptr := Ptr.Rest_It.First;
-- -- Exhausted "rest": iterate on the first item
-- Ptr_elem := P.Next(Ptr.FirstIt, Ptr_elem);
-- if P.Has_Element (Ptr_elem) then
-- Ptr.Value.Data(1) := P.Elem_Value(Ptr.FirstVal, Ptr_elem);
-- Ptr.Value.Data(2..Ptr.Length) := Ptr.Rest_It.Ptr.Value.Data (1..Ptr.Rest_It.Ptr.Length);
-- end if;
-- end if;
-- else
-- -- Size is 0 or 1
-- Ptr_elem := P.Next(Ptr.FirstIt, Ptr_elem);
-- if P.Has_Element (Ptr_elem) then
-- Ptr.Value.Data(1) := P.Elem_Value(Ptr.FirstVal, Ptr_elem);
-- end if;
-- end if;
-- return Ptr;
return Temp;
end;
end;
......@@ -55,7 +55,7 @@ package ASN1_Iterators.Iterable_SeqOF is
subtype Iterator is Custom_Iterator.Iterators.Forward_Iterator'Class;
type Cust_Iterator is new Custom_Iterator.Iterator with null record;
function Has_Element (Ptr: Cursor) return Boolean
function Has_Element (Position : Cursor) return Boolean
renames Custom_Iterator.Has_Element;
......
with Ada.Unchecked_Conversion;
package body ASN1_Iterators.MySeq is
procedure Initialize (Self: in out ASN1_MySeq) is
begin
-- Self.Value.a :=
-- Self.Value.b :=
end;
function Has_Element_MySeq (Ptr: Cursor) return Boolean is
(P_a.Has_Element(P_a.Ptr(Ptr.a_it)));
function Iterate (Self : ASN1_MySeq)
return ASN1_MySeq_It'Class is --Iterators_MySeq.Forward_Iterator'Class is
begin
return I: ASN1_MySeq_It do
I.Ptr := Self'Unrestricted_Access;
end return;
end;
function First (Item : ASN1_MySeq_It) return Cursor is
Cursor_a : P_a.Cursor := P_a.Ptr (Item.Ptr.a_it);
Cursor_b : P_b.Cursor := P_b.Ptr (Item.Ptr.b_it);
begin
-- Initialize the iterator (Compute first value)
Item.Ptr.a_it := P_a.Iterator (Item.Ptr.a_val.Iterate);
Item.Ptr.b_it := P_b.Iterator (Item.Ptr.b_val.Iterate);
Cursor_a := P_a.First (Item.Ptr.a_it);
Cursor_b := P_b.First (Item.Ptr.b_it);
Item.Ptr.Value.a := P_a.Elem_Value (Item.Ptr.a_val, Cursor_a);
Item.Ptr.Value.b := P_b.Elem_Value (Item.Ptr.b_val, Cursor_b);
return Item.Ptr;
end;
function Next (Item : ASN1_MySeq_It;
Ptr : Cursor) return Cursor is
pragma Unreferenced (Item);
Ptr_elem_a : P_a.Cursor := P_a.Ptr (Ptr.a_it);
Ptr_elem_b : P_b.Cursor := P_b.Ptr (Ptr.b_it);
begin
-- Exhaust b first, then a...
Ptr.b_it.Ptr := Ptr.b_it.Next (Ptr.b_it.Ptr);
if P_b.Has_Element (Ptr_elem_b) then
Ptr.Value.b := P_b.Elem_Value (Ptr.b_val, Ptr_elem_b);
else
-- Exhausted b: reset it, and iterate a by one element
Ptr.b_it.Ptr := Ptr.b_it.First;
Ptr_elem_a := P_a.Next(Ptr.a_it, Ptr_elem_a);
if P_a.Has_Element (Ptr_elem_a) then
Ptr.Value.a := P_a.Elem_Value (Ptr.a_val, Ptr_elem_a);
Ptr.Value.b := P_b.Elem_Value (Ptr.b_val, Ptr_elem_b);
end if;
end if;
return Ptr;
end;
end;
with Ada.Iterator_Interfaces;
with Ada.Finalization;
use Ada.Finalization;
with ASN1_Iterators.Generic_Basic;
with ASN1_Iterators.SimpleTypes;
with ASN1_Ada_Iterators.Iterators;
use ASN1_Ada_Iterators.Iterators;
with TASTE_DataView;
package ASN1_Iterators.MySeq is
package P_a renames MyInteger_Pkg.It;
package P_b renames MyEnum_Pkg.It;
type ASN1_MySeq_Ptr;
type ASN1_MySeq_It;
type ASN1_MySeq is new Controlled
with record
a_val : P_a.Basic_ASN1_Iterator;
a_it : P_a.Iterator;
b_val : P_b.Basic_ASN1_Iterator;
b_it : P_b.Iterator;
Value : asn1SccMySeq;
end record
with Default_Iterator => Iterate,
Iterator_Element => asn1SccMySeq,
Constant_Indexing => Element_MySeq_Value;
type Cursor is access all ASN1_MySeq;
-- Constructor (called automatically)
procedure Initialize (Self : in out ASN1_MySeq);
function Has_Element_MySeq (Ptr : Cursor) return Boolean;
package Iterators_MySeq is
new Ada.Iterator_Interfaces (Cursor, Has_Element_MySeq);
type ASN1_MySeq_It is new Iterators_MySeq.Forward_Iterator with record
Ptr : Cursor;</