Natools

Check-in [df682ad54a]
Login
Overview
Comment:s_expressions-special_descriptors: new package that provide empty and erroneous descriptors
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: df682ad54a530741541e53b12a6a9fc0f16de90d
User & Date: nat on 2015-03-19 18:01:13
Other Links: manifest | tags
Context
2015-03-27
22:09
time_statistics-generic_timers: fix stupid sign mistake check-in: 74297c4cff user: nat tags: trunk
2015-03-19
18:01
s_expressions-special_descriptors: new package that provide empty and erroneous descriptors check-in: df682ad54a user: nat tags: trunk
2015-03-18
20:25
constant_indefinite_ordered_map_tests: add a fully covering test suite for the new "mutation" constructors check-in: 6a2a4d94a0 user: nat tags: trunk
Changes

Added src/natools-s_expressions-special_descriptors.adb version [19d2e7e2ca].

































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
30
31
32
33
34
35
36
37
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
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
------------------------------------------------------------------------------
-- Copyright (c) 2015, 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.           --
------------------------------------------------------------------------------

package body Natools.S_Expressions.Special_Descriptors is

   overriding function Current_Event
     (Object : in Constant_Descriptor) return Events.Event is
   begin
      return Object.Event;
   end Current_Event;


   overriding function Current_Atom (Object : in Constant_Descriptor)
     return Atom
   is
      pragma Unreferenced (Object);
   begin
      raise Program_Error with "Current_Atom called on a special descriptor";
      return Null_Atom;
   end Current_Atom;


   overriding function Current_Level (Object : in Constant_Descriptor)
     return Natural
   is
      pragma Unreferenced (Object);
   begin
      raise Program_Error with "Current_Level called on a special descriptor";
      return 0;
   end Current_Level;

   overriding procedure Query_Atom
     (Object : in Constant_Descriptor;
      Process : not null access procedure (Data : in Atom))
   is
      pragma Unreferenced (Object, Process);
   begin
      raise Program_Error with "Query_Atom called on a special descriptor";
   end Query_Atom;


   overriding procedure Read_Atom
     (Object : in Constant_Descriptor;
      Data : out Atom;
      Length : out Count)
   is
      pragma Unreferenced (Object, Data, Length);
   begin
      raise Program_Error with "Read_Atom called on a special descriptor";
   end Read_Atom;


   overriding procedure Next
     (Object : in out Constant_Descriptor;
      Event : out Events.Event)
   is
      pragma Unmodified (Object);
   begin
      Event := Object.Event;
   end Next;


   overriding procedure Lock
     (Object : in out Constant_Descriptor;
      State : out Lockable.Lock_State)
   is
      pragma Unreferenced (Object, State);
   begin
      raise Program_Error with "Lock called on a special descriptor";
   end Lock;


   overriding procedure Unlock
     (Object : in out Constant_Descriptor;
      State : in out Lockable.Lock_State;
      Finish : in Boolean := True)
   is
      pragma Unreferenced (Object, State, Finish);
   begin
      raise Program_Error with "Unlock called on a special descriptor";
   end Unlock;

end Natools.S_Expressions.Special_Descriptors;

Added src/natools-s_expressions-special_descriptors.ads version [c7ae277282].













































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
30
31
32
33
34
35
36
37
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
70
------------------------------------------------------------------------------
-- Copyright (c) 2015, 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.Special_Descriptors provides descriptors blocked   --
-- in End_Of_Input or Error states.                                         --
-- The global variables should be task-safe, since there is no actual       --
-- change in any of the primitives.                                         --
------------------------------------------------------------------------------

with Natools.S_Expressions.Lockable;

package Natools.S_Expressions.Special_Descriptors is
   pragma Preelaborate;

   subtype Control_Event is Events.Event with Static_Predicate
     => Control_Event in Events.Error | Events.End_Of_Input;

   type Constant_Descriptor (Event : Control_Event) is new Lockable.Descriptor
     with null record;

   overriding function Current_Event (Object : in Constant_Descriptor)
     return Events.Event;

   overriding function Current_Atom (Object : in Constant_Descriptor)
     return Atom;

   overriding function Current_Level (Object : in Constant_Descriptor)
     return Natural;

   overriding procedure Query_Atom
     (Object : in Constant_Descriptor;
      Process : not null access procedure (Data : in Atom));

   overriding procedure Read_Atom
     (Object : in Constant_Descriptor;
      Data : out Atom;
      Length : out Count);

   overriding procedure Next
     (Object : in out Constant_Descriptor;
      Event : out Events.Event);

   overriding procedure Lock
     (Object : in out Constant_Descriptor;
      State : out Lockable.Lock_State);

   overriding procedure Unlock
     (Object : in out Constant_Descriptor;
      State : in out Lockable.Lock_State;
      Finish : in Boolean := True);


   Empty_Descriptor : Constant_Descriptor (Events.End_Of_Input);
   Error_Descriptor : Constant_Descriptor (Events.Error);

end Natools.S_Expressions.Special_Descriptors;