Commit 40c02b44 authored by Maxime Perrotin's avatar Maxime Perrotin

work on sequence iterators

parent 59f28dba
......@@ -147,7 +147,6 @@ ChoiceChild(sName, sCName, nLine, nPos, sChildContent, sNamePresent ) ::= <<
ChoiceType(arrsChildren) ::= <<
-- $arrsChildren;separator=",\n"$
}
>>
......@@ -159,7 +158,6 @@ SequenceChild(sName, sCName, bOptional, sDefVal, nLine, nPos, sChildContent ) ::
/* Full sequence (record) type */
SequenceType(arrsChildren) ::= <<
-- $arrsChildren;separator=",\n"$
}
>>
......
......@@ -170,8 +170,7 @@ SequenceChild(sName, sCName, bOptional, sDefVal, nLine, nPos, sChildContent ) ::
/* Full sequence (record) type */
SequenceType(arrsChildren) ::= <<
-- $arrsChildren;separator=",\n"$
}
Sequence;
>>
......
......@@ -9,7 +9,7 @@ package body ASN1_Iterators.MySeq is
end;
function Has_Element_MySeq (Ptr: Cursor) return Boolean is
(P.Has_Element(P.Ptr(Ptr.FirstIt)));
(P_a.Has_Element(P_a.Ptr(Ptr.a_it)));
function Iterate (Self : ASN1_MySeq)
return ASN1_MySeq'Class is --Iterators_MySeq.Forward_Iterator'Class is
......@@ -20,46 +20,37 @@ package body ASN1_Iterators.MySeq is
end;
function First (Item : ASN1_MySeq) return Cursor is
Ptr_Elem : P.Iterator_Ptr := P.Ptr (Item.Ptr.FirstIt);
function First (Item : ASN1_MySeq_It) return Cursor is
Cursor_a : P_a.Iterator_Ptr := P_a.Ptr (Item.Ptr.a_it);
Cursor_b : P_b.Iterator_Ptr := P_b.Ptr (Item.Ptr.b_it);
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,
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);
end if;
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;
function Next (Item : ASN1_MySeq_It;
Ptr : Cursor) return Cursor is
pragma Unreferenced (Item);
Ptr_elem : P.Iterator_Ptr := P.Ptr (Ptr.FirstIt);
Ptr_elem_a : P_a.Iterator_Ptr := P_a.Ptr (Ptr.a_it); -- ? (checkme)
Ptr_elem_b : P_b.Iterator_Ptr := P_b.Ptr (Ptr.b_it); -- ?
begin
if Ptr.Length > 1 then
Ptr.RestIt.Ptr := Ptr.RestIt.Next (Ptr.RestIt.Ptr);
if Has_Element_MySeq (Ptr.RestIt.Ptr) then
Ptr.Value.Data (2 .. Ptr.Length) :=
Ptr.RestIt.Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Value.Length);
else
Ptr.RestIt.Ptr := Ptr.RestIt.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.RestIt.Ptr.Value.Data (1 .. Ptr.RestIt.Ptr.Length);
end if;
end if;
-- Exhaust b first, then a...
Ptr.b_it.Ptr := Ptr.b_it.Next (Ptr.b_it.Ptr);
if Has_Element_MyEnum (Ptr.b_it.Ptr) then
Ptr.Value.b := Ptr.b_it.Ptr.Value.b;
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);
-- 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;
......
......@@ -12,18 +12,18 @@ with TASTE_DataView;
package ASN1_Iterators.MySeq is
package a_Pkg renames MyInteger.Pkg;
package b_Pkg renames MyEnum_Pkg;
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 : a_Pkg.It.Basic_ASN1_Iterator;
a_it : a_Pkg.It.Iterator;
b_val : b_Pkg.It.Basic_ASN1_Iterator;
b_i : B_Pkg.It.Iterator;
a_val : P_a.Basic_ASN1_Iterator;
a_it : P_a.Iterator;
b_val : P_b.Basic_ASN1_Iterator;
b_i : P_b.Iterator;
Value : asn1SccMySeq;
-- First value
-- FirstVal : P.Basic_ASN1_Iterator;
......@@ -52,7 +52,7 @@ package ASN1_Iterators.MySeq is
Ptr : Cursor) return Cursor;
function Iterate (self : ASN1_MySeq)
return ASN1_MySeq_It'Class; -- Iterators_SeqOf.Forward_Iterator'Class;
return ASN1_MySeq_It'Class;
function Element_MySeq_Value (Self : ASN1_MySeq;
Ptr : Cursor)
......
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