2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / s-stratt.ads
bloba62feba078f2bebe97f4a7d728db38462554ee83
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- S Y S T E M . S T R E A M _ A T T R I B U T E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This package contains the implementations of the stream attributes for
35 -- elementary types. These are the subprograms that are directly accessed
36 -- by occurrences of the stream attributes where the type is elementary.
38 -- We only provide the subprograms for the standard base types. For user
39 -- defined types, the subprogram for the corresponding root type is called
40 -- with an appropriate conversion.
42 with System;
43 with System.Unsigned_Types;
44 with Ada.Streams;
46 package System.Stream_Attributes is
47 pragma Preelaborate (Stream_Attributes);
49 pragma Suppress (Accessibility_Check, Stream_Attributes);
50 -- No need to check accessibility on arguments of subprograms
52 package UST renames System.Unsigned_Types;
54 subtype RST is Ada.Streams.Root_Stream_Type'Class;
56 subtype SEC is Ada.Streams.Stream_Element_Count;
58 -- Enumeration types are usually transferred using the routine for the
59 -- corresponding integer. The exception is that special routines are
60 -- provided for Boolean and the character types, in case the protocol
61 -- in use provides specially for these types.
63 -- Access types use either a thin pointer (single address) or fat pointer
64 -- (double address) form. The following types are used to hold access
65 -- values using unchecked conversions.
67 type Thin_Pointer is record
68 P1 : System.Address;
69 end record;
71 type Fat_Pointer is record
72 P1 : System.Address;
73 P2 : System.Address;
74 end record;
76 ------------------------------------
77 -- Treatment of enumeration types --
78 ------------------------------------
80 -- In this interface, there are no specific routines for general input
81 -- or output of enumeration types. Generally, enumeration types whose
82 -- representation is unsigned (no negative representation values) are
83 -- treated as unsigned integers, and enumeration types that do have
84 -- negative representation values are treated as signed integers.
86 -- An exception is that there are specialized routines for Boolean,
87 -- Character, and Wide_Character types, but these specialized routines
88 -- are used only if the type in question has a standard representation.
89 -- For the case of a non-standard representation (one where the size of
90 -- the first subtype is specified, or where an enumeration representation
91 -- clause is given, these three types are treated like any other cases
92 -- of enumeration types, as described above.
93 -- for
95 ---------------------
96 -- Input Functions --
97 ---------------------
99 -- Functions for S'Input attribute. These functions are also used for
100 -- S'Read, with the obvious transformation, since the input operation
101 -- is the same for all elementary types (no bounds or discriminants
102 -- are involved).
104 function I_AD (Stream : access RST) return Fat_Pointer;
105 function I_AS (Stream : access RST) return Thin_Pointer;
106 function I_B (Stream : access RST) return Boolean;
107 function I_C (Stream : access RST) return Character;
108 function I_F (Stream : access RST) return Float;
109 function I_I (Stream : access RST) return Integer;
110 function I_LF (Stream : access RST) return Long_Float;
111 function I_LI (Stream : access RST) return Long_Integer;
112 function I_LLF (Stream : access RST) return Long_Long_Float;
113 function I_LLI (Stream : access RST) return Long_Long_Integer;
114 function I_LLU (Stream : access RST) return UST.Long_Long_Unsigned;
115 function I_LU (Stream : access RST) return UST.Long_Unsigned;
116 function I_SF (Stream : access RST) return Short_Float;
117 function I_SI (Stream : access RST) return Short_Integer;
118 function I_SSI (Stream : access RST) return Short_Short_Integer;
119 function I_SSU (Stream : access RST) return UST.Short_Short_Unsigned;
120 function I_SU (Stream : access RST) return UST.Short_Unsigned;
121 function I_U (Stream : access RST) return UST.Unsigned;
122 function I_WC (Stream : access RST) return Wide_Character;
124 -----------------------
125 -- Output Procedures --
126 -----------------------
128 -- Procedures for S'Write attribute. These procedures are also used
129 -- for 'Output, since for elementary types there is no difference
130 -- between 'Write and 'Output because there are no discriminants
131 -- or bounds to be written.
133 procedure W_AD (Stream : access RST; Item : in Fat_Pointer);
134 procedure W_AS (Stream : access RST; Item : in Thin_Pointer);
135 procedure W_B (Stream : access RST; Item : in Boolean);
136 procedure W_C (Stream : access RST; Item : in Character);
137 procedure W_F (Stream : access RST; Item : in Float);
138 procedure W_I (Stream : access RST; Item : in Integer);
139 procedure W_LF (Stream : access RST; Item : in Long_Float);
140 procedure W_LI (Stream : access RST; Item : in Long_Integer);
141 procedure W_LLF (Stream : access RST; Item : in Long_Long_Float);
142 procedure W_LLI (Stream : access RST; Item : in Long_Long_Integer);
143 procedure W_LLU (Stream : access RST; Item : in UST.Long_Long_Unsigned);
144 procedure W_LU (Stream : access RST; Item : in UST.Long_Unsigned);
145 procedure W_SF (Stream : access RST; Item : in Short_Float);
146 procedure W_SI (Stream : access RST; Item : in Short_Integer);
147 procedure W_SSI (Stream : access RST; Item : in Short_Short_Integer);
148 procedure W_SSU (Stream : access RST; Item : in UST.Short_Short_Unsigned);
149 procedure W_SU (Stream : access RST; Item : in UST.Short_Unsigned);
150 procedure W_U (Stream : access RST; Item : in UST.Unsigned);
151 procedure W_WC (Stream : access RST; Item : in Wide_Character);
153 ----------------------------
154 -- Composite Input/Output --
155 ----------------------------
157 -- The following Boolean constant is defined and set to True only if the
158 -- stream representation of a series of elementary items of the same
159 -- type (one of the types handled by the above procedures) has the same
160 -- representation as an array of such items in memory. This allows such
161 -- a series of items to be read or written as a block, instead of
162 -- element by element.
164 -- If the stream representation does not have this property for all the
165 -- above types, then this constant can be omitted or set to False,
166 -- and the front end will generate element-by-element operations.
168 -- This interface assumes that a Stream_Element has the same size as
169 -- a Storage_Unit. If that is not the case, then this flag should
170 -- also be omitted (or set to False).
172 Block_Stream_Ops_OK : constant Boolean := True;
173 -- Set to False if block stream operations not permitted
175 private
176 pragma Inline (I_AD);
177 pragma Inline (I_AS);
178 pragma Inline (I_B);
179 pragma Inline (I_C);
180 pragma Inline (I_F);
181 pragma Inline (I_I);
182 pragma Inline (I_LF);
183 pragma Inline (I_LI);
184 pragma Inline (I_LLF);
185 pragma Inline (I_LLI);
186 pragma Inline (I_LLU);
187 pragma Inline (I_LU);
188 pragma Inline (I_SF);
189 pragma Inline (I_SI);
190 pragma Inline (I_SSI);
191 pragma Inline (I_SSU);
192 pragma Inline (I_SU);
193 pragma Inline (I_U);
194 pragma Inline (I_WC);
196 pragma Inline (W_AD);
197 pragma Inline (W_AS);
198 pragma Inline (W_B);
199 pragma Inline (W_C);
200 pragma Inline (W_F);
201 pragma Inline (W_I);
202 pragma Inline (W_LF);
203 pragma Inline (W_LI);
204 pragma Inline (W_LLF);
205 pragma Inline (W_LLI);
206 pragma Inline (W_LLU);
207 pragma Inline (W_LU);
208 pragma Inline (W_SF);
209 pragma Inline (W_SI);
210 pragma Inline (W_SSI);
211 pragma Inline (W_SSU);
212 pragma Inline (W_SU);
213 pragma Inline (W_U);
214 pragma Inline (W_WC);
216 end System.Stream_Attributes;