Index: src/natools-s_expressions-atom_buffers.adb ================================================================== --- src/natools-s_expressions-atom_buffers.adb +++ src/natools-s_expressions-atom_buffers.adb @@ -79,22 +79,22 @@ begin return Buffer.Used; end Length; - function Query (Buffer : Atom_Buffer) return Atom is + function Data (Buffer : Atom_Buffer) return Atom is begin if Buffer.Ref.Is_Empty then pragma Assert (Buffer.Available = 0 and Buffer.Used = 0); return Null_Atom; else return Buffer.Ref.Query.Data.all; end if; - end Query; + end Data; - function Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor is + function Raw_Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor is function Create return Atom; function Create return Atom is begin return Null_Atom; @@ -103,11 +103,11 @@ if Buffer.Ref.Is_Empty then return Atom_Refs.Create (Create'Access).Query; else return Buffer.Ref.Query; end if; - end Query; + end Raw_Query; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom)) is @@ -118,11 +118,11 @@ Buffer.Ref.Query (Process); end if; end Query; - procedure Query + procedure Read (Buffer : in Atom_Buffer; Data : out Atom; Length : out Count) is Transmit : constant Count := Count'Min (Data'Length, Buffer.Used); @@ -134,11 +134,11 @@ null; else Data (Data'First .. Data'First + Transmit - 1) := Buffer.Ref.Query.Data.all (1 .. Transmit); end if; - end Query; + end Read; function Element (Buffer : Atom_Buffer; Position : Count) return Octet is begin return Buffer.Ref.Query.Data.all (Position); Index: src/natools-s_expressions-atom_buffers.ads ================================================================== --- src/natools-s_expressions-atom_buffers.ads +++ src/natools-s_expressions-atom_buffers.ads @@ -42,21 +42,23 @@ procedure Append (Buffer : in out Atom_Buffer; Data : in Atom); procedure Append (Buffer : in out Atom_Buffer; Data : in Octet); -- Append Data after the end of Buffer function Length (Buffer : Atom_Buffer) return Count; - function Query (Buffer : Atom_Buffer) return Atom; - function Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor; + function Data (Buffer : Atom_Buffer) return Atom; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom)); - procedure Query + procedure Read (Buffer : in Atom_Buffer; Data : out Atom; Length : out Count); function Element (Buffer : Atom_Buffer; Position : Count) return Octet; -- Accessors to the whole buffer as an Atom + + function Raw_Query (Buffer : Atom_Buffer) return Atom_Refs.Accessor; + -- Accessor to the whole allocated memory procedure Hard_Reset (Buffer : in out Atom_Buffer); -- Clear buffer and release internal memory procedure Soft_Reset (Buffer : in out Atom_Buffer); Index: src/natools-s_expressions-parsers.adb ================================================================== --- src/natools-s_expressions-parsers.adb +++ src/natools-s_expressions-parsers.adb @@ -32,11 +32,11 @@ begin if P.Latest /= Events.Add_Atom then raise Program_Error; end if; - return P.Buffer.Query; + return P.Buffer.Data; end Current_Atom; function Current_Level (P : in Parser) return Natural is begin @@ -63,11 +63,11 @@ begin if P.Latest /= Events.Add_Atom then raise Program_Error; end if; - P.Buffer.Query (Data, Length); + P.Buffer.Read (Data, Length); end Read_Atom; procedure Next_Event (P : in out Parser; @@ -171,11 +171,11 @@ (Encodings.Decode_Base64 (P.Internal.Chunk.Data (0 .. P.Internal.Chunk.Length - 1))); if P.Internal.State = Base64_Atom then P.Latest := Events.Add_Atom; else - P.Override.Append (P.Buffer.Query); + P.Override.Append (P.Buffer.Data); P.Buffer.Soft_Reset; end if; P.Internal := (State => Waiting); end if; Index: tests/natools-s_expressions-atom_buffers-tests.adb ================================================================== --- tests/natools-s_expressions-atom_buffers-tests.adb +++ tests/natools-s_expressions-atom_buffers-tests.adb @@ -53,11 +53,11 @@ Buffer.Append (Data (11 .. 11)); Buffer.Append (Data (12 .. 101)); Buffer.Append (Data (102 .. 101)); Buffer.Append (Data (102 .. 255)); - Test_Tools.Test_Atom (Report, Name, Data, Buffer.Query.Data.all); + Test_Tools.Test_Atom (Report, Name, Data, Buffer.Data); end; exception when Error : others => Report.Report_Exception (Name, Error); end Test_Block_Append; @@ -75,11 +75,11 @@ begin for O in Octet loop Buffer.Append (O); end loop; - Test_Tools.Test_Atom (Report, Name, Data, Buffer.Query.Data.all); + Test_Tools.Test_Atom (Report, Name, Data, Buffer.Data); end; exception when Error : others => Report.Report_Exception (Name, Error); end Test_Octet_Append; @@ -91,27 +91,27 @@ Buffer : Atom_Buffer; begin Buffer.Preallocate (256); declare - Old_Accessor : Atom_Refs.Accessor := Buffer.Query; + Old_Accessor : Atom_Refs.Accessor := Buffer.Raw_Query; begin for O in Octet loop Buffer.Append (O); end loop; Report.Item (Name, - NT.To_Result (Old_Accessor.Data = Buffer.Query.Data)); + NT.To_Result (Old_Accessor.Data = Buffer.Raw_Query.Data)); end; end; exception when Error : others => Report.Report_Exception (Name, Error); end Test_Preallocate; procedure Test_Query (Report : in out NT.Reporter'Class) is - Name : constant String := "Query in all its variants"; + Name : constant String := "Accessors"; Data : Atom (0 .. 255); begin for O in Octet loop Data (Count (O)) := O; end loop; @@ -126,42 +126,42 @@ Report.Info ("Buffer.Length returned" & Count'Image (Buffer.Length) & ", expected" & Count'Image (Data'Length)); return; end if; - if Buffer.Query /= Data then + if Buffer.Data /= Data then Report.Item (Name, NT.Fail); - Report.Info ("Query returning an Atom"); - Test_Tools.Dump_Atom (Report, Buffer.Query, "Found"); + Report.Info ("Data, returning an Atom"); + Test_Tools.Dump_Atom (Report, Buffer.Data, "Found"); Test_Tools.Dump_Atom (Report, Data, "Expected"); return; end if; - if Buffer.Query.Data.all /= Data then + if Buffer.Raw_Query.Data.all /= Data then Report.Item (Name, NT.Fail); - Report.Info ("Query returning an accessor"); - Test_Tools.Dump_Atom (Report, Buffer.Query.Data.all, "Found"); + Report.Info ("Raw_Query, returning an accessor"); + Test_Tools.Dump_Atom (Report, Buffer.Raw_Query.Data.all, "Found"); Test_Tools.Dump_Atom (Report, Data, "Expected"); return; end if; if Buffer.Element (25) /= Data (24) then Report.Item (Name, NT.Fail); - Report.Info ("Query returning an octet"); + Report.Info ("Element, returning an octet"); return; end if; declare Retrieved : Atom (10 .. 310); Length : Count; begin - Buffer.Query (Retrieved, Length); + Buffer.Read (Retrieved, Length); if Length /= Data'Length or else Retrieved (10 .. Length + 9) /= Data then Report.Item (Name, NT.Fail); - Report.Info ("Query into an existing buffer"); + Report.Info ("Read into an existing buffer"); Report.Info ("Length returned" & Count'Image (Length) & ", expected" & Count'Image (Data'Length)); Test_Tools.Dump_Atom (Report, Retrieved (10 .. Length + 9), "Found"); Test_Tools.Dump_Atom (Report, Data, "Expected"); @@ -171,14 +171,14 @@ declare Retrieved : Atom (20 .. 50); Length : Count; begin - Buffer.Query (Retrieved, Length); + Buffer.Read (Retrieved, Length); if Length /= Data'Length or else Retrieved /= Data (0 .. 30) then Report.Item (Name, NT.Fail); - Report.Info ("Query into a buffer too small"); + Report.Info ("Read into a buffer too small"); Report.Info ("Length returned" & Count'Image (Length) & ", expected" & Count'Image (Data'Length)); Test_Tools.Dump_Atom (Report, Retrieved, "Found"); Test_Tools.Dump_Atom (Report, Data (0 .. 30), "Expected"); return; @@ -209,37 +209,37 @@ when Error : others => Report.Report_Exception (Name, Error); end Test_Query; procedure Test_Query_Null (Report : in out NT.Reporter'Class) is - Name : constant String := "Query variants against a null buffer"; + Name : constant String := "Accessor variants against a null buffer"; begin declare Buffer : Atom_Buffer; begin - if Buffer.Query /= Null_Atom then + if Buffer.Data /= Null_Atom then Report.Item (Name, NT.Fail); - Report.Info ("Query returning an Atom"); - Test_Tools.Dump_Atom (Report, Buffer.Query, "Found"); + Report.Info ("Data, returning an Atom"); + Test_Tools.Dump_Atom (Report, Buffer.Data, "Found"); return; end if; - if Buffer.Query.Data.all /= Null_Atom then + if Buffer.Raw_Query.Data.all /= Null_Atom then Report.Item (Name, NT.Fail); - Report.Info ("Query returning an accessor"); - Test_Tools.Dump_Atom (Report, Buffer.Query.Data.all, "Found"); + Report.Info ("Raw_Query, returning an accessor"); + Test_Tools.Dump_Atom (Report, Buffer.Raw_Query.Data.all, "Found"); return; end if; declare Retrieved : Atom (1 .. 10); Length : Count; begin - Buffer.Query (Retrieved, Length); + Buffer.Read (Retrieved, Length); if Length /= 0 then Report.Item (Name, NT.Fail); - Report.Info ("Query into an existing buffer"); + Report.Info ("Read into an existing buffer"); Report.Info ("Length returned" & Count'Image (Length) & ", expected 0"); return; end if; end; @@ -278,11 +278,11 @@ for O in Octet loop Buffer.Append (O); end loop; declare - Accessor : Atom_Refs.Accessor := Buffer.Query; + Accessor : Atom_Refs.Accessor := Buffer.Raw_Query; begin Buffer.Soft_Reset; if Buffer.Length /= 0 then Report.Item (Name, NT.Fail); @@ -289,21 +289,21 @@ Report.Info ("Soft reset left length" & Count'Image (Buffer.Length)); return; end if; - if Buffer.Query.Data /= Accessor.Data then + if Buffer.Raw_Query.Data /= Accessor.Data then Report.Item (Name, NT.Fail); Report.Info ("Soft reset changed storage area"); return; end if; - if Buffer.Query.Data.all'Length /= Buffer.Available then + if Buffer.Raw_Query.Data.all'Length /= Buffer.Available then Report.Item (Name, NT.Fail); Report.Info ("Available length inconsistency, recorded" & Count'Image (Buffer.Available) & ", actual" - & Count'Image (Buffer.Query.Data.all'Length)); + & Count'Image (Buffer.Raw_Query.Data.all'Length)); return; end if; end; for O in Octet'(10) .. Octet'(50) loop Index: tests/natools-s_expressions-test_tools.adb ================================================================== --- tests/natools-s_expressions-test_tools.adb +++ tests/natools-s_expressions-test_tools.adb @@ -209,18 +209,18 @@ end Write; function Get_Data (Stream : Memory_Stream) return Atom is begin - return Stream.Internal.Query; + return Stream.Internal.Data; end Get_Data; function Unread_Data (Stream : Memory_Stream) return Atom is begin if Stream.Read_Pointer < Stream.Internal.Length then - return Stream.Internal.Query.Data.all + return Stream.Internal.Raw_Query.Data.all (Stream.Read_Pointer + 1 .. Stream.Internal.Length); else return Null_Atom; end if; end Unread_Data; @@ -236,11 +236,11 @@ function Unread_Expected (Stream : Memory_Stream) return Atom is begin if Stream.Expect_Pointer < Stream.Expected.Length then - return Stream.Expected.Query.Data.all + return Stream.Expected.Raw_Query.Data.all (Stream.Expect_Pointer + 1 .. Stream.Expected.Length); else return Null_Atom; end if; end Unread_Expected;