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-2016, 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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package contains the implementations of the stream attributes for
33 -- elementary types. These are the subprograms that are directly accessed
34 -- by occurrences of the stream attributes where the type is elementary.
36 -- We only provide the subprograms for the standard base types. For user
37 -- defined types, the subprogram for the corresponding root type is called
38 -- with an appropriate conversion.
41 with System
.Unsigned_Types
;
44 package System
.Stream_Attributes
is
47 pragma Suppress
(Accessibility_Check
, Stream_Attributes
);
48 -- No need to check accessibility on arguments of subprograms
50 package UST
renames System
.Unsigned_Types
;
52 subtype RST
is Ada
.Streams
.Root_Stream_Type
'Class;
54 subtype SEC
is Ada
.Streams
.Stream_Element_Count
;
56 -- Enumeration types are usually transferred using the routine for the
57 -- corresponding integer. The exception is that special routines are
58 -- provided for Boolean and the character types, in case the protocol
59 -- in use provides specially for these types.
61 -- Access types use either a thin pointer (single address) or fat pointer
62 -- (double address) form. The following types are used to hold access
63 -- values using unchecked conversions.
65 type Thin_Pointer
is record
69 type Fat_Pointer
is record
74 ------------------------------------
75 -- Treatment of enumeration types --
76 ------------------------------------
78 -- In this interface, there are no specific routines for general input
79 -- or output of enumeration types. Generally, enumeration types whose
80 -- representation is unsigned (no negative representation values) are
81 -- treated as unsigned integers, and enumeration types that do have
82 -- negative representation values are treated as signed integers.
84 -- An exception is that there are specialized routines for Boolean,
85 -- Character, and Wide_Character types, but these specialized routines
86 -- are used only if the type in question has a standard representation.
87 -- For the case of a non-standard representation (one where the size of
88 -- the first subtype is specified, or where an enumeration representation
89 -- clause is given), these three types are treated like any other cases
90 -- of enumeration types, as described above.
96 -- Functions for S'Input attribute. These functions are also used for
97 -- S'Read, with the obvious transformation, since the input operation
98 -- is the same for all elementary types (no bounds or discriminants
101 function I_AD
(Stream
: not null access RST
) return Fat_Pointer
;
102 function I_AS
(Stream
: not null access RST
) return Thin_Pointer
;
103 function I_B
(Stream
: not null access RST
) return Boolean;
104 function I_C
(Stream
: not null access RST
) return Character;
105 function I_F
(Stream
: not null access RST
) return Float;
106 function I_I
(Stream
: not null access RST
) return Integer;
107 function I_LF
(Stream
: not null access RST
) return Long_Float;
108 function I_LI
(Stream
: not null access RST
) return Long_Integer;
109 function I_LLF
(Stream
: not null access RST
) return Long_Long_Float;
110 function I_LLI
(Stream
: not null access RST
) return Long_Long_Integer;
111 function I_LLU
(Stream
: not null access RST
) return UST
.Long_Long_Unsigned
;
112 function I_LU
(Stream
: not null access RST
) return UST
.Long_Unsigned
;
113 function I_SF
(Stream
: not null access RST
) return Short_Float;
114 function I_SI
(Stream
: not null access RST
) return Short_Integer;
115 function I_SSI
(Stream
: not null access RST
) return Short_Short_Integer;
116 function I_SSU
(Stream
: not null access RST
) return
117 UST
.Short_Short_Unsigned
;
118 function I_SU
(Stream
: not null access RST
) return UST
.Short_Unsigned
;
119 function I_U
(Stream
: not null access RST
) return UST
.Unsigned
;
120 function I_WC
(Stream
: not null access RST
) return Wide_Character;
121 function I_WWC
(Stream
: not null access RST
) return Wide_Wide_Character
;
123 -----------------------
124 -- Output Procedures --
125 -----------------------
127 -- Procedures for S'Write attribute. These procedures are also used for
128 -- 'Output, since for elementary types there is no difference between
129 -- 'Write and 'Output because there are no discriminants or bounds to
132 procedure W_AD
(Stream
: not null access RST
; Item
: Fat_Pointer
);
133 procedure W_AS
(Stream
: not null access RST
; Item
: Thin_Pointer
);
134 procedure W_B
(Stream
: not null access RST
; Item
: Boolean);
135 procedure W_C
(Stream
: not null access RST
; Item
: Character);
136 procedure W_F
(Stream
: not null access RST
; Item
: Float);
137 procedure W_I
(Stream
: not null access RST
; Item
: Integer);
138 procedure W_LF
(Stream
: not null access RST
; Item
: Long_Float);
139 procedure W_LI
(Stream
: not null access RST
; Item
: Long_Integer);
140 procedure W_LLF
(Stream
: not null access RST
; Item
: Long_Long_Float);
141 procedure W_LLI
(Stream
: not null access RST
; Item
: Long_Long_Integer);
142 procedure W_LLU
(Stream
: not null access RST
; Item
:
143 UST
.Long_Long_Unsigned
);
144 procedure W_LU
(Stream
: not null access RST
; Item
: UST
.Long_Unsigned
);
145 procedure W_SF
(Stream
: not null access RST
; Item
: Short_Float);
146 procedure W_SI
(Stream
: not null access RST
; Item
: Short_Integer);
147 procedure W_SSI
(Stream
: not null access RST
; Item
: Short_Short_Integer);
148 procedure W_SSU
(Stream
: not null access RST
; Item
:
149 UST
.Short_Short_Unsigned
);
150 procedure W_SU
(Stream
: not null access RST
; Item
: UST
.Short_Unsigned
);
151 procedure W_U
(Stream
: not null access RST
; Item
: UST
.Unsigned
);
152 procedure W_WC
(Stream
: not null access RST
; Item
: Wide_Character);
153 procedure W_WWC
(Stream
: not null access RST
; Item
: Wide_Wide_Character
);
155 function Block_IO_OK
return Boolean;
156 -- Package System.Stream_Attributes has several bodies - the default one
157 -- distributed with GNAT, and s-stratt-xdr.adb, which is based on the XDR
158 -- standard. Both bodies share the same spec. The role of this function is
159 -- to indicate whether the current version of System.Stream_Attributes
160 -- supports block IO. See System.Strings.Stream_Ops (s-ststop) for details.
163 pragma Inline
(I_AD
);
164 pragma Inline
(I_AS
);
169 pragma Inline
(I_LF
);
170 pragma Inline
(I_LI
);
171 pragma Inline
(I_LLF
);
172 pragma Inline
(I_LLI
);
173 pragma Inline
(I_LLU
);
174 pragma Inline
(I_LU
);
175 pragma Inline
(I_SF
);
176 pragma Inline
(I_SI
);
177 pragma Inline
(I_SSI
);
178 pragma Inline
(I_SSU
);
179 pragma Inline
(I_SU
);
181 pragma Inline
(I_WC
);
182 pragma Inline
(I_WWC
);
184 pragma Inline
(W_AD
);
185 pragma Inline
(W_AS
);
190 pragma Inline
(W_LF
);
191 pragma Inline
(W_LI
);
192 pragma Inline
(W_LLF
);
193 pragma Inline
(W_LLI
);
194 pragma Inline
(W_LLU
);
195 pragma Inline
(W_LU
);
196 pragma Inline
(W_SF
);
197 pragma Inline
(W_SI
);
198 pragma Inline
(W_SSI
);
199 pragma Inline
(W_SSU
);
200 pragma Inline
(W_SU
);
202 pragma Inline
(W_WC
);
203 pragma Inline
(W_WWC
);
205 pragma Inline
(Block_IO_OK
);
207 end System
.Stream_Attributes
;