3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that a public grandchild can utilize its ancestor unit's visible
31 -- Declare a public package, public child package, and public
32 -- grandchild package and library unit function. Within the
33 -- grandchild package and function, make use of components that are
34 -- declared in the ancestor packages, both parent and grandparent.
36 -- Use the following ancestral components in the grandchildren library
47 -- 06 Dec 94 SAIC ACVC 2.0
48 -- 21 Dec 94 SAIC Modified procedure Create_File
49 -- 15 Nov 95 SAIC Update and repair for ACVC 2.0.1
53 package CA11003_0
is -- Package OS
55 type File_Descriptor
is new Integer;
56 type File_Mode
is (Read_Only
, Write_Only
, Read_Write
);
58 Null_File
: constant File_Descriptor
:= 0;
59 Default_Mode
: constant File_Mode
:= Read_Only
;
60 File_Data_Error
: exception;
62 type File_Type
is tagged
64 Descriptor
: File_Descriptor
:= Null_File
;
65 Mode
: File_Mode
:= Read_Write
;
68 System_File
: File_Type
;
70 function Next_Available_File
return File_Descriptor
;
72 procedure Reclaim_File_Descriptor
;
74 end CA11003_0
; -- Package OS
76 --=================================================================--
78 package body CA11003_0
is -- Package body OS
80 File_Count
: Integer := 0;
82 function Next_Available_File
return File_Descriptor
is
84 File_Count
:= File_Count
+ 1;
85 return (File_Descriptor
(File_Count
));
86 end Next_Available_File
;
87 --------------------------------------------------
88 procedure Reclaim_File_Descriptor
is
90 null; -- Dummy processing unit.
91 end Reclaim_File_Descriptor
;
93 end CA11003_0
; -- Package body OS
95 --=================================================================--
97 package CA11003_0
.CA11003_1
is -- Child package OS.Operations
99 subtype File_Length_Type
is Integer range 0 .. 1000;
100 Min_File_Size
: File_Length_Type
:= File_Length_Type
'First;
101 Max_File_Size
: File_Length_Type
:= File_Length_Type
'Last;
103 File_Duplication_Error
: exception;
105 type Extended_File_Type
is new File_Type
with private;
107 procedure Create_File
(Mode
: in File_Mode
;
108 File
: out Extended_File_Type
);
110 procedure Duplicate_File
(Original
: in Extended_File_Type
;
111 Duplicate
: out Extended_File_Type
);
114 type Extended_File_Type
is new File_Type
with
116 Blocks
: File_Length_Type
:= Min_File_Size
;
119 System_Extended_File
: Extended_File_Type
;
121 end CA11003_0
.CA11003_1
; -- Child Package OS.Operations
123 --=================================================================--
125 package body CA11003_0
.CA11003_1
is -- Child package body OS.Operations
127 procedure Create_File
128 (Mode
: in File_Mode
;
129 File
: out Extended_File_Type
) is
131 File
.Descriptor
:= Next_Available_File
; -- Parent subprogram.
132 File
.Mode
:= Default_Mode
; -- Parent constant.
133 File
.Blocks
:= Min_File_Size
;
135 --------------------------------------------------
136 procedure Duplicate_File
(Original
: in Extended_File_Type
;
137 Duplicate
: out Extended_File_Type
) is
139 Duplicate
.Descriptor
:= Next_Available_File
; -- Parent subprogram.
140 Duplicate
.Mode
:= Original
.Mode
;
141 Duplicate
.Blocks
:= Original
.Blocks
;
144 end CA11003_0
.CA11003_1
; -- Child package body OS.Operations
146 --=================================================================--
148 -- This package contains menu selectable operations for manipulating files.
149 -- This abstraction builds on the capabilities available from ancestor
152 package CA11003_0
.CA11003_1
.CA11003_2
is
154 procedure News
(Mode
: in File_Mode
;
155 File
: out Extended_File_Type
);
157 procedure Copy
(Original
: in Extended_File_Type
;
158 Duplicate
: out Extended_File_Type
);
160 procedure Delete
(File
: in Extended_File_Type
);
162 end CA11003_0
.CA11003_1
.CA11003_2
; -- Grandchild package OS.Operations.Menu
164 --=================================================================--
166 -- Grandchild subprogram Validate
167 function CA11003_0
.CA11003_1
.CA11003_3
(File
: in Extended_File_Type
)
170 --=================================================================--
172 -- Grandchild subprogram Validate
173 function CA11003_0
.CA11003_1
.CA11003_3
174 (File
: in Extended_File_Type
) -- Parent type.
177 function New_File_Validated
(File
: Extended_File_Type
)
180 if (File
.Descriptor
> System_File
.Descriptor
) and -- Grandparent
181 (File
.Mode
in File_Mode
) and -- object and type
182 not ((File
.Blocks
< System_Extended_File
.Blocks
) or
183 (File
.Blocks
> Max_File_Size
)) -- Parent object
184 then -- and constant.
189 end New_File_Validated
;
192 return (New_File_Validated
(File
)) and
193 (File
.Descriptor
/= Null_File
); -- Grandparent constant.
195 end CA11003_0
.CA11003_1
.CA11003_3
; -- Grandchild subprogram Validate
197 --=================================================================--
199 with CA11003_0
.CA11003_1
.CA11003_3
;
200 -- Grandchild package body OS.Operations.Menu
201 package body CA11003_0
.CA11003_1
.CA11003_2
is
203 procedure News
(Mode
: in File_Mode
;
204 File
: out Extended_File_Type
) is -- Parent type.
206 Create_File
(Mode
, File
); -- Parent subprogram.
207 if not CA11003_0
.CA11003_1
.CA11003_3
(File
) then
208 raise File_Data_Error
; -- Grandparent exception.
211 --------------------------------------------------
212 procedure Copy
(Original
: in Extended_File_Type
;
213 Duplicate
: out Extended_File_Type
) is
215 Duplicate_File
(Original
, Duplicate
); -- Parent subprogram.
217 if Original
.Descriptor
= Duplicate
.Descriptor
then
218 raise File_Duplication_Error
; -- Parent exception.
222 --------------------------------------------------
223 procedure Delete
(File
: in Extended_File_Type
) is
225 Reclaim_File_Descriptor
; -- Grandparent
226 end Delete
; -- subprogram.
228 end CA11003_0
.CA11003_1
.CA11003_2
;
230 --=================================================================--
232 with CA11003_0
.CA11003_1
.CA11003_2
; -- Grandchild Pkg OS.Operations.Menu
233 with CA11003_0
.CA11003_1
.CA11003_3
; -- Grandchild Ftn OS.Operations.Validate
238 package Menu
renames CA11003_0
.CA11003_1
.CA11003_2
;
242 Report
.Test
("CA11003", "Check that a public grandchild can utilize " &
243 "its ancestor unit's visible definitions");
245 File_Processing
: -- Validate all of the capabilities contained in
246 -- the Menu package by exercising them on specific
247 -- files. This will demonstrate the use of child
248 -- and grandchild functionality based on components
249 -- that have been declared in the
250 -- parent/grandparent package.
253 function Validate
(File
: CA11003_0
.CA11003_1
.Extended_File_Type
)
254 return Boolean renames CA11003_0
.CA11003_1
.CA11003_3
;
257 Backup_Copy
: CA11003_0
.CA11003_1
.Extended_File_Type
;
258 MacWrite_File_Mode
: CA11003_0
.File_Mode
:= CA11003_0
.Read_Write
;
262 Menu
.News
(MacWrite_File_Mode
, MacWrite_File
);
264 if not Validate
(MacWrite_File
) then
265 Report
.Failed
("Incorrect initialization of files");
268 Menu
.Copy
(MacWrite_File
, Backup_Copy
);
270 if not (Validate
(MacWrite_File
) and
271 Validate
(Backup_Copy
))
273 Report
.Failed
("Incorrect duplication of files");
276 Menu
.Delete
(Backup_Copy
);
279 when CA11003_0
.File_Data_Error
=>
280 Report
.Failed
("Exception raised during file validation");
281 when CA11003_0
.CA11003_1
.File_Duplication_Error
=>
282 Report
.Failed
("Exception raised during file duplication");
284 Report
.Failed
("Unexpected exception in test procedure");