Commit dc4c6e87 authored by Maxime Perrotin's avatar Maxime Perrotin

Improve iteration of enumerated arrays

parent 43bca318
package body ASN1_Iterators.Generic_Basic is package body ASN1_Iterators.Generic_Basic is
procedure Initialize (self: in out Basic_ASN1_Iterator) is procedure Initialize (self: in out Basic_ASN1_Iterator) is
begin begin
--Self.Value := create;
Self.Value.Initialize; Self.Value.Initialize;
end; end;
......
...@@ -16,7 +16,7 @@ package ASN1_Iterators.Generic_Enumerated is ...@@ -16,7 +16,7 @@ package ASN1_Iterators.Generic_Enumerated is
function Has_Elem (Value: Sort) return Boolean; function Has_Elem (Value: Sort) return Boolean;
-- function Has_Elem (Value: Sort) return Boolean is (Value <= Sort'Last); -- function Has_Elem (Value: Sort) return Boolean is (Value <= Sort'Last);
function Elem_First return Sort is (Sort'First); function Elem_First return Sort is (Elem_Init); -- Sort'First);
function Elem_Next (Value: Sort) return Sort is function Elem_Next (Value: Sort) return Sort is
(if Is_Last then Sort'Last else Sort'Succ (Value)); (if Is_Last then Sort'Last else Sort'Succ (Value));
......
...@@ -25,18 +25,18 @@ package body ASN1_Iterators.Generic_Fixed_SeqOf is ...@@ -25,18 +25,18 @@ package body ASN1_Iterators.Generic_Fixed_SeqOf is
function First (Item : ASN1_SeqOf_It) return ASN1_SeqOf_Ptr is function First (Item : ASN1_SeqOf_It) return ASN1_SeqOf_Ptr is
Ptr_elem : P.Iterator_Ptr := P.Ptr(Item.Ptr.FirstIt); Ptr_elem : P.Iterator_Ptr := P.Ptr(Item.Ptr.FirstIt);
begin begin
-- Initialize the iterator (Compute first value) -- Initialize the iterator (Compute first value)
Item.Ptr.FirstIt := P.Iterator(Item.Ptr.FirstVal.Iterate); Item.Ptr.FirstIt := P.Iterator (Item.Ptr.FirstVal.Iterate);
Ptr_elem := P.First(Item.Ptr.FirstIt); Ptr_elem := P.First (Item.Ptr.FirstIt);
Item.Ptr.Value.Data(1) := P.Elem_Value(Item.Ptr.FirstVal, Item.Ptr.Value.Data(1) := P.Elem_Value (Item.Ptr.FirstVal,
Ptr_elem); Ptr_elem);
if Item.Ptr.Length > 1 then if Item.Ptr.Length > 1 then
Item.Ptr.Value.Data(2 .. Item.Ptr.Length) := Item.Ptr.Value.Data (2 .. Item.Ptr.Length) :=
Item.Ptr.RestIt.Ptr.Value.Data(1..Item.Ptr.RestIt.Ptr.Length); Item.Ptr.RestIt.Ptr.Value.Data (1 .. Item.Ptr.RestIt.Ptr.Length);
end if; end if;
return Item.Ptr; return Item.Ptr;
end; end;
function Next (Item : ASN1_SeqOf_It; function Next (Item : ASN1_SeqOf_It;
......
...@@ -3,7 +3,7 @@ with Ada.Iterator_Interfaces; ...@@ -3,7 +3,7 @@ with Ada.Iterator_Interfaces;
with Ada.Finalization; with Ada.Finalization;
use Ada.Finalization; use Ada.Finalization;
with ASN1_Iterators.Generic_Fixed_SeqOF, with ASN1_Iterators.Generic_Fixed_SeqOf,
ASN1_Iterators.Generic_Integer, ASN1_Iterators.Generic_Integer,
ASN1_Iterators.Generic_Basic; ASN1_Iterators.Generic_Basic;
......
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