Natools

Check-in [4627abed57]
Login
Overview
Comment:s_expressions-atom_refs: new package for atom references, taken out from Atom_Buffers
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4627abed579fb132599256bb4af72732c71b8316
User & Date: nat on 2014-05-10 20:43:18
Other Links: manifest | tags
Context
2014-05-11
20:04
s_expressions-interpreters: add a String-based command addition, since it's the overwhelmingly most common use case check-in: 179da1f3db user: nat tags: trunk
2014-05-10
20:43
s_expressions-atom_refs: new package for atom references, taken out from Atom_Buffers check-in: 4627abed57 user: nat tags: trunk
2014-05-08
18:36
Move atom comparison function from Natools.S_Expressions.Interpreters to Natools.S_Expressions check-in: 6f257a4f4d user: nat tags: trunk
Changes

Modified src/natools-s_expressions-atom_buffers.ads from [8b05d08348] to [977a8a6da9].

18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
18
19
20
21
22
23
24


25
26
27
28
29





30
31
32
33
34
35
36







-
-
+




-
-
-
-
-







-- Natools.S_Expressions.Atom_Buffers implements an unbounded Atom designed --
-- to be used as an input buffer, accumulating data and extracting it as a  --
-- single Atom object.                                                      --
-- It also provides an individual Octet accessor, used in parser internal   --
-- recursive buffer.                                                        --
------------------------------------------------------------------------------

with Natools.References;
with Natools.Storage_Pools;
with Natools.S_Expressions.Atom_Refs;

package Natools.S_Expressions.Atom_Buffers is
   pragma Preelaborate (Atom_Buffers);

   package Atom_Refs is new Natools.References
     (Atom,
      Storage_Pools.Access_In_Default_Pool'Storage_Pool,
      Storage_Pools.Access_In_Default_Pool'Storage_Pool);

   type Atom_Buffer is tagged private;

   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);

Added src/natools-s_expressions-atom_refs.ads version [6020b8b107].






























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-- Natools.S_Expressions.Atom_Refs provides a common instance of default    --
-- reference-counted atoms.                                                 --
------------------------------------------------------------------------------

with Natools.References;
with Natools.Storage_Pools;

package Natools.S_Expressions.Atom_Refs is new Natools.References
  (Natools.S_Expressions.Atom,
   Natools.Storage_Pools.Access_In_Default_Pool'Storage_Pool,
   Natools.Storage_Pools.Access_In_Default_Pool'Storage_Pool);
pragma Preelaborate (Natools.S_Expressions.Atom_Refs);

Modified src/natools-s_expressions-interpreters.ads from [1b48f8fb9a] to [4923890aab].

24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
24
25
26
27
28
29
30

31
32
33
34
35
36
37
38







-
+







-- Formal types represent common objets for all the command, Shared_State   --
-- begin read/write while Shared_Context is read-only.                      --
------------------------------------------------------------------------------

with Natools.S_Expressions.Lockable;

private with Ada.Containers.Indefinite_Ordered_Maps;
private with Natools.S_Expressions.Atom_Buffers;
private with Natools.S_Expressions.Atom_Refs;

generic
   type Shared_State (<>) is limited private;
   type Shared_Context (<>) is limited private;

package Natools.S_Expressions.Interpreters is
   pragma Preelaborate (Interpreters);
117
118
119
120
121
122
123
124

125
126
127
117
118
119
120
121
122
123

124
125
126
127







-
+




   package Command_Maps is new Ada.Containers.Indefinite_Ordered_Maps
     (Atom, Command'Class, Less_Than);

   type Interpreter is new Command with record
      Commands : Command_Maps.Map;
      Max_Length : Count := 0;
      Fallback_Name : Atom_Buffers.Atom_Refs.Reference;
      Fallback_Name : Atom_Refs.Reference;
   end record;

end Natools.S_Expressions.Interpreters;