Natools

Check-in [86680251f9]
Login
Overview
Comment:s_expressions-generic_caches: add Move functions to build a cache directly from a descriptor
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 86680251f9e10a8b2c456f70d323ea7ea8d90784
User & Date: nat on 2014-09-11 19:19:40
Other Links: manifest | tags
Context
2014-09-12
21:41
s_expressions-cache_tests: test the new Move functions check-in: ef36376c9f user: nat tags: trunk
2014-09-11
19:19
s_expressions-generic_caches: add Move functions to build a cache directly from a descriptor check-in: 86680251f9 user: nat tags: trunk
2014-09-10
19:08
s_expressions-printers: add an option for Transfer to stay in the current nesting level check-in: 02db3410f5 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-generic_caches.adb from [64adc939bb] to [500eb58670].

177
178
179
180
181
182
183













184
185
186
187
188
189
190
      begin
         return Duplicate (Cache.Exp.Query.Data.all);
      end Dup_Tree;
   begin
      return Reference'(Exp => Trees.Create (Dup_Tree'Access));
   end Duplicate;
















   -----------------------
   -- Printer Interface --
   -----------------------

   overriding procedure Open_List (Output : in out Reference) is







>
>
>
>
>
>
>
>
>
>
>
>
>







177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
      begin
         return Duplicate (Cache.Exp.Query.Data.all);
      end Dup_Tree;
   begin
      return Reference'(Exp => Trees.Create (Dup_Tree'Access));
   end Duplicate;


   function Move (Source : in out S_Expressions.Descriptor'Class)
     return Reference
   is
      Result : Reference;
   begin
      Printers.Transfer
        (Source => Source,
         Target => Result,
         Check_Level => True);
      return Result;
   end Move;



   -----------------------
   -- Printer Interface --
   -----------------------

   overriding procedure Open_List (Output : in out Reference) is

Modified src/natools-s_expressions-generic_caches.ads from [869771231b] to [00246a7ed7].

51
52
53
54
55
56
57




58
59
60
61
62
63
64
   overriding procedure Append_Atom
     (Output : in out Reference; Data : in Atom);
   overriding procedure Close_List (Output : in out Reference);

   function Duplicate (Cache : Reference) return Reference;
      --  Create a new copy of the S-expression held in Cache and return it






   type Cursor is new Lockable.Descriptor and Replayable.Descriptor
     with private;
   pragma Preelaborable_Initialization (Cursor);

   overriding function Current_Event (Object : in Cursor) return Events.Event;
   overriding function Current_Atom (Object : in Cursor) return Atom;







>
>
>
>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
   overriding procedure Append_Atom
     (Output : in out Reference; Data : in Atom);
   overriding procedure Close_List (Output : in out Reference);

   function Duplicate (Cache : Reference) return Reference;
      --  Create a new copy of the S-expression held in Cache and return it

   function Move (Source : in out S_Expressions.Descriptor'Class)
     return Reference;
      --  Build a new cache by (destructively) reading Original


   type Cursor is new Lockable.Descriptor and Replayable.Descriptor
     with private;
   pragma Preelaborable_Initialization (Cursor);

   overriding function Current_Event (Object : in Cursor) return Events.Event;
   overriding function Current_Atom (Object : in Cursor) return Atom;
82
83
84
85
86
87
88





89
90
91
92
93
94
95
      State : in out Lockable.Lock_State;
      Finish : in Boolean := True);

   overriding function Duplicate (Object : Cursor) return Cursor;

   function First (Cache : Reference'Class) return Cursor;
      --  Create a new Cursor pointing at the beginning of Cache






private

   type Atom_Access is access Atom;
   for Atom_Access'Storage_Pool use Atom_Pool;
   procedure Unchecked_Free is new Ada.Unchecked_Deallocation
     (Atom, Atom_Access);







>
>
>
>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
      State : in out Lockable.Lock_State;
      Finish : in Boolean := True);

   overriding function Duplicate (Object : Cursor) return Cursor;

   function First (Cache : Reference'Class) return Cursor;
      --  Create a new Cursor pointing at the beginning of Cache

   function Move (Source : in out S_Expressions.Descriptor'Class) return Cursor
     is (Move (Source).First);
      --  Return a cursor holding a copy of Original (which is
      --  destructively read)

private

   type Atom_Access is access Atom;
   for Atom_Access'Storage_Pool use Atom_Pool;
   procedure Unchecked_Free is new Ada.Unchecked_Deallocation
     (Atom, Atom_Access);