1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . S T R E A M _ A T T R I B U T E S --
9 -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
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. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
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.
43 with System.Unsigned_Types;
46 package System.Stream_Attributes is
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
71 type Fat_Pointer is 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.
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
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;
124 function I_WWC (Stream : not null access RST) return Wide_Wide_Character;
126 -----------------------
127 -- Output Procedures --
128 -----------------------
130 -- Procedures for S'Write attribute. These procedures are also used
131 -- for 'Output, since for elementary types there is no difference
132 -- between 'Write and 'Output because there are no discriminants
133 -- or bounds to be written.
135 procedure W_AD (Stream : not null access RST; Item : Fat_Pointer);
136 procedure W_AS (Stream : not null access RST; Item : Thin_Pointer);
137 procedure W_B (Stream : not null access RST; Item : Boolean);
138 procedure W_C (Stream : not null access RST; Item : Character);
139 procedure W_F (Stream : not null access RST; Item : Float);
140 procedure W_I (Stream : not null access RST; Item : Integer);
141 procedure W_LF (Stream : not null access RST; Item : Long_Float);
142 procedure W_LI (Stream : not null access RST; Item : Long_Integer);
143 procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float);
144 procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer);
145 procedure W_LLU (Stream : not null access RST;
146 Item : UST.Long_Long_Unsigned);
147 procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned);
148 procedure W_SF (Stream : not null access RST; Item : Short_Float);
149 procedure W_SI (Stream : not null access RST; Item : Short_Integer);
150 procedure W_SSI (Stream : not null access RST;
151 Item : Short_Short_Integer);
152 procedure W_SSU (Stream : not null access RST;
153 Item : UST.Short_Short_Unsigned);
154 procedure W_SU (Stream : not null access RST;
155 Item : UST.Short_Unsigned);
156 procedure W_U (Stream : not null access RST; Item : UST.Unsigned);
157 procedure W_WC (Stream : not null access RST; Item : Wide_Character);
158 procedure W_WWC (Stream : not null access RST; Item : Wide_Wide_Character);
160 function Block_IO_OK return Boolean;
161 -- Package System.Stream_Attributes has several bodies - the default one
162 -- distributed with GNAT, s-strxdr.adb which is based on the XDR standard
163 -- and s-stratt.adb for Garlic. All three bodies share the same spec. The
164 -- role of this function is to determine whether the current version of
165 -- System.Stream_Attributes is able to support block IO.
168 pragma Inline (I_AD);
169 pragma Inline (I_AS);
174 pragma Inline (I_LF);
175 pragma Inline (I_LI);
176 pragma Inline (I_LLF);
177 pragma Inline (I_LLI);
178 pragma Inline (I_LLU);
179 pragma Inline (I_LU);
180 pragma Inline (I_SF);
181 pragma Inline (I_SI);
182 pragma Inline (I_SSI);
183 pragma Inline (I_SSU);
184 pragma Inline (I_SU);
186 pragma Inline (I_WC);
187 pragma Inline (I_WWC);
189 pragma Inline (W_AD);
190 pragma Inline (W_AS);
195 pragma Inline (W_LF);
196 pragma Inline (W_LI);
197 pragma Inline (W_LLF);
198 pragma Inline (W_LLI);
199 pragma Inline (W_LLU);
200 pragma Inline (W_LU);
201 pragma Inline (W_SF);
202 pragma Inline (W_SI);
203 pragma Inline (W_SSI);
204 pragma Inline (W_SSU);
205 pragma Inline (W_SU);
207 pragma Inline (W_WC);
208 pragma Inline (W_WWC);
210 pragma Inline (Block_IO_OK);
212 end System.Stream_Attributes;