Merge from mainline
[official-gcc.git] / gcc / ada / s-stratt.ads
blobe0e9b0f5c6df1bb4160d7157c16447fd6c82da11
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME 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-2006, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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;
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 : not null access RST) return Fat_Pointer;
105 function I_AS (Stream : not null access RST) return Thin_Pointer;
106 function I_B (Stream : not null access RST) return Boolean;
107 function I_C (Stream : not null access RST) return Character;
108 function I_F (Stream : not null access RST) return Float;
109 function I_I (Stream : not null access RST) return Integer;
110 function I_LF (Stream : not null access RST) return Long_Float;
111 function I_LI (Stream : not null access RST) return Long_Integer;
112 function I_LLF (Stream : not null access RST) return Long_Long_Float;
113 function I_LLI (Stream : not null access RST) return Long_Long_Integer;
114 function I_LLU (Stream : not null access RST) return UST.Long_Long_Unsigned;
115 function I_LU (Stream : not null access RST) return UST.Long_Unsigned;
116 function I_SF (Stream : not null access RST) return Short_Float;
117 function I_SI (Stream : not null access RST) return Short_Integer;
118 function I_SSI (Stream : not null access RST) return Short_Short_Integer;
119 function I_SSU (Stream : not null access RST)
120 return UST.Short_Short_Unsigned;
121 function I_SU (Stream : not null access RST) return UST.Short_Unsigned;
122 function I_U (Stream : not null access RST) return UST.Unsigned;
123 function I_WC (Stream : not null access RST) return Wide_Character;
125 -----------------------
126 -- Output Procedures --
127 -----------------------
129 -- Procedures for S'Write attribute. These procedures are also used
130 -- for 'Output, since for elementary types there is no difference
131 -- between 'Write and 'Output because there are no discriminants
132 -- or bounds to be written.
134 procedure W_AD (Stream : not null access RST; Item : Fat_Pointer);
135 procedure W_AS (Stream : not null access RST; Item : Thin_Pointer);
136 procedure W_B (Stream : not null access RST; Item : Boolean);
137 procedure W_C (Stream : not null access RST; Item : Character);
138 procedure W_F (Stream : not null access RST; Item : Float);
139 procedure W_I (Stream : not null access RST; Item : Integer);
140 procedure W_LF (Stream : not null access RST; Item : Long_Float);
141 procedure W_LI (Stream : not null access RST; Item : Long_Integer);
142 procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float);
143 procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer);
144 procedure W_LLU (Stream : not null access RST;
145 Item : UST.Long_Long_Unsigned);
146 procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned);
147 procedure W_SF (Stream : not null access RST; Item : Short_Float);
148 procedure W_SI (Stream : not null access RST; Item : Short_Integer);
149 procedure W_SSI (Stream : not null access RST;
150 Item : Short_Short_Integer);
151 procedure W_SSU (Stream : not null access RST;
152 Item : UST.Short_Short_Unsigned);
153 procedure W_SU (Stream : not null access RST;
154 Item : UST.Short_Unsigned);
155 procedure W_U (Stream : not null access RST; Item : UST.Unsigned);
156 procedure W_WC (Stream : not null access RST; Item : Wide_Character);
158 ----------------------------
159 -- Composite Input/Output --
160 ----------------------------
162 -- The following Boolean constant is defined and set to True only if the
163 -- stream representation of a series of elementary items of the same
164 -- type (one of the types handled by the above procedures) has the same
165 -- representation as an array of such items in memory. This allows such
166 -- a series of items to be read or written as a block, instead of
167 -- element by element.
169 -- If the stream representation does not have this property for all the
170 -- above types, then this constant can be omitted or set to False,
171 -- and the front end will generate element-by-element operations.
173 -- This interface assumes that a Stream_Element has the same size as
174 -- a Storage_Unit. If that is not the case, then this flag should
175 -- also be omitted (or set to False).
177 Block_Stream_Ops_OK : constant Boolean := True;
178 -- Set to False if block stream operations not permitted
180 private
181 pragma Inline (I_AD);
182 pragma Inline (I_AS);
183 pragma Inline (I_B);
184 pragma Inline (I_C);
185 pragma Inline (I_F);
186 pragma Inline (I_I);
187 pragma Inline (I_LF);
188 pragma Inline (I_LI);
189 pragma Inline (I_LLF);
190 pragma Inline (I_LLI);
191 pragma Inline (I_LLU);
192 pragma Inline (I_LU);
193 pragma Inline (I_SF);
194 pragma Inline (I_SI);
195 pragma Inline (I_SSI);
196 pragma Inline (I_SSU);
197 pragma Inline (I_SU);
198 pragma Inline (I_U);
199 pragma Inline (I_WC);
201 pragma Inline (W_AD);
202 pragma Inline (W_AS);
203 pragma Inline (W_B);
204 pragma Inline (W_C);
205 pragma Inline (W_F);
206 pragma Inline (W_I);
207 pragma Inline (W_LF);
208 pragma Inline (W_LI);
209 pragma Inline (W_LLF);
210 pragma Inline (W_LLI);
211 pragma Inline (W_LLU);
212 pragma Inline (W_LU);
213 pragma Inline (W_SF);
214 pragma Inline (W_SI);
215 pragma Inline (W_SSI);
216 pragma Inline (W_SSU);
217 pragma Inline (W_SU);
218 pragma Inline (W_U);
219 pragma Inline (W_WC);
221 end System.Stream_Attributes;