Overview
Comment: | s_expressions-atom_buffers: add primitives to use atom buffers as octet stacks |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7b0544e9fcc62a1f30ef3346d5a95df1 |
User & Date: | nat on 2014-01-19 22:04:59 |
Other Links: | manifest | tags |
Context
2014-01-20
| ||
19:48 | s_expressions-atom_buffers-tests: add tests for the new octet stack interface check-in: 71a9406a61 user: nat tags: trunk | |
2014-01-19
| ||
22:04 | s_expressions-atom_buffers: add primitives to use atom buffers as octet stacks check-in: 7b0544e9fc user: nat tags: trunk | |
2014-01-18
| ||
11:12 | s_expressions-parsers-tests: add more subexpression test cases check-in: 2e81806813 user: nat tags: trunk | |
Changes
Modified src/natools-s_expressions-atom_buffers.adb from [3eff901ca5] to [497d821f36].
︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 | procedure Append (Buffer : in out Atom_Buffer; Data : in Octet) is begin Preallocate (Buffer, 1); Buffer.Ref.Update.Data.all (Buffer.Used + 1) := Data; Buffer.Used := Buffer.Used + 1; end Append; function Length (Buffer : Atom_Buffer) return Count is begin return Buffer.Used; end Length; | > > > > > > > > > > > > > > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | procedure Append (Buffer : in out Atom_Buffer; Data : in Octet) is begin Preallocate (Buffer, 1); Buffer.Ref.Update.Data.all (Buffer.Used + 1) := Data; Buffer.Used := Buffer.Used + 1; end Append; procedure Append_Reverse (Buffer : in out Atom_Buffer; Data : in Atom) is procedure Process (Target : in out Atom); procedure Process (Target : in out Atom) is begin for I in reverse Data'Range loop Buffer.Used := Buffer.Used + 1; Target (Buffer.Used) := Data (I); end loop; end Process; begin Preallocate (Buffer, Data'Length); Buffer.Ref.Update (Process'Access); end Append_Reverse; function Length (Buffer : Atom_Buffer) return Count is begin return Buffer.Used; end Length; |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | function Element (Buffer : Atom_Buffer; Position : Count) return Octet is begin return Buffer.Ref.Query.Data.all (Position); end Element; procedure Hard_Reset (Buffer : in out Atom_Buffer) is begin Buffer.Ref.Reset; Buffer.Available := 0; Buffer.Used := 0; end Hard_Reset; | > > > > > > > | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | function Element (Buffer : Atom_Buffer; Position : Count) return Octet is begin return Buffer.Ref.Query.Data.all (Position); end Element; procedure Pop (Buffer : in out Atom_Buffer; Data : out Octet) is begin Data := Buffer.Ref.Query.Data.all (Buffer.Used); Buffer.Used := Buffer.Used - 1; end Pop; procedure Hard_Reset (Buffer : in out Atom_Buffer) is begin Buffer.Ref.Reset; Buffer.Available := 0; Buffer.Used := 0; end Hard_Reset; |
︙ | ︙ |
Modified src/natools-s_expressions-atom_buffers.ads from [73413c8038] to [b0af66da8f].
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | procedure Preallocate (Buffer : in out Atom_Buffer; Length : in Count); -- Preallocate enough memory to append Length octets without -- any further allocation. 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 Data (Buffer : Atom_Buffer) return Atom; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom)); 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 | > > > > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | procedure Preallocate (Buffer : in out Atom_Buffer; Length : in Count); -- Preallocate enough memory to append Length octets without -- any further allocation. 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 procedure Append_Reverse (Buffer : in out Atom_Buffer; Data : in Atom); -- Append bytes from Atom from last to first function Length (Buffer : Atom_Buffer) return Count; function Data (Buffer : Atom_Buffer) return Atom; procedure Query (Buffer : in Atom_Buffer; Process : not null access procedure (Data : in Atom)); 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 procedure Pop (Buffer : in out Atom_Buffer; Data : out Octet); -- Remove last octet from Buffer and store it in Data 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 |
︙ | ︙ |