aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats-4/support/f416a00.a
blob: 1003d906cdb61b8f6299fba1d88ae91e123a01f3 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
-- F416A00.A
--
--                             Grant of Unlimited Rights
--
--     The Ada Conformity Assessment Authority (ACAA) holds unlimited
--     rights in the software and documentation contained herein. Unlimited
--     rights are the same as those granted by the U.S. Government for older
--     parts of the Ada Conformity Assessment Test Suite, and are defined
--     in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
--     intends to confer upon all recipients unlimited rights equal to those
--     held by the ACAA. These rights include rights to use, duplicate,
--     release or disclose the released technical data and computer software
--     in whole or in part, in any manner and for any purpose whatsoever, and
--     to have or permit others to do so.
--
--                                    DISCLAIMER
--
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     DISCLOSED ARE AS IS. THE ACAA MAKES NO EXPRESS OR IMPLIED
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--
--                                     Notice
--
--     The ACAA has created and maintains the Ada Conformity Assessment Test
--     Suite for the purpose of conformity assessments conducted in accordance
--     with the International Standard ISO/IEC 18009 - Ada: Conformity
--     assessment of a language processor. This test suite should not be used
--     to make claims of conformance unless used in accordance with
--     ISO/IEC 18009 and any applicable ACAA procedures.
--*
--
-- FOUNDATION DESCRIPTION:
--     This foundation provides basic operations to test the declaration and
--     use of the generalized indexing aspects Constant_Indexing and
--     Variable_Indexing.
--
--     The foundation is intended to demonstrate a sprite-drawing package,
--     where sprites are defined in a window object, and can either be
--     accessed by name or by location (where the location is given with
--     X and Y coordinates) in a particular window object. Constant_Indexings
--     and Variable_Indexings are defined to access the sprites in a window.
--
-- CHANGE HISTORY:
--     11 May 2015   RLB   Created foundation.
--     14 May 2015   RLB   Fixed bug in by location routines.

package F416A00 is
   type Window is tagged private
      with Constant_Indexing => CRef,
           Variable_Indexing => VRef;

   type Kind is (Player, Ghost, Power_Pill);

   type Color is (White, Yellow, Orange, Pink, Red, Cyan, Blue, Green, Violet);

   type Sprite is record
      K : aliased Kind;
      C : Color;
      X, Y : Natural;
   end record;

   subtype Name is String(1..6);

   Missing_Error : exception;

   type Ref_Rec (D : access Sprite) is null record
      with Implicit_Dereference => D;

   function CRef (W : in Window; N : in Name) return Sprite;

   function VRef (W : aliased in out Window; N : in Name) return Ref_Rec;

   function CRef (W : in Window; X, Y : in Natural) return Sprite;

   function VRef (W : aliased in out Window; X, Y : in Natural)
      return Ref_Rec;

   procedure Create_Sprite (W : in out Window;
                            N : in Name;
                            X : in Natural;
                            Y : in Natural;
                            K : in Kind;
                            C : in Color);

private

   type Tuple is record
       N : Name;
       S : aliased Sprite;
   end record;

   type SArray is array (1..10) of Tuple;
   type Window is tagged record
      Count : Natural := 0;
      Sprites : SArray;
   end record;

end F416A00;

with TcTouch;
package body F416A00 is

   function CRef (W : in Window; N : in Name) return Sprite is
   begin
      TcTouch.Touch('c'); TcTouch.Touch(N(1));  ---------------
      for I in 1 .. W.Count loop
         if W.Sprites(I).N = N then
            return W.Sprites(I).S;
         end if;
      end loop;
      raise Missing_Error;
   end CRef;

   function VRef (W : aliased in out Window; N : in Name) return Ref_Rec is
   begin
      TcTouch.Touch('v'); TcTouch.Touch(N(1));  ---------------
      for I in 1 .. W.Count loop
         if W.Sprites(I).N = N then
            return (D => W.Sprites(I).S'Access);
         end if;
      end loop;
      raise Missing_Error;
   end VRef;

   function CRef (W : in Window; X, Y : in Natural) return Sprite is
   begin
      TcTouch.Touch('d');                       ---------------
      TcTouch.Touch(Character'Val(X - 1 + Character'Pos('A')));
      TcTouch.Touch(Character'Val(Y - 1 + Character'Pos('A')));
      for I in 1 .. W.Count loop
         if W.Sprites(I).S.X = X and then
            W.Sprites(I).S.Y = Y then
            return W.Sprites(I).S;
         end if;
      end loop;
      raise Missing_Error;
   end CRef;

   function VRef (W : aliased in out Window; X, Y : in Natural)
      return Ref_Rec is
   begin
      TcTouch.Touch('w');                       ---------------
      TcTouch.Touch(Character'Val(X - 1 + Character'Pos('A')));
      TcTouch.Touch(Character'Val(Y - 1 + Character'Pos('A')));
      for I in 1 .. W.Count loop
         if W.Sprites(I).S.X = X and then
            W.Sprites(I).S.Y = Y then
            return (D => W.Sprites(I).S'Access);
         end if;
      end loop;
      raise Missing_Error;
   end VRef;

   procedure Create_Sprite (W : in out Window;
                            N : in Name;
                            X : in Natural;
                            Y : in Natural;
                            K : in Kind;
                            C : in Color) is
   begin
      W.Count := W.Count + 1;
      W.Sprites(W.Count) := (N => N, S => (K, C, X, Y));
   end Create_Sprite;

end F416A00;