OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-stratt.ads
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 --                                                                          --
10 --          Copyright (C) 1992-2000 Free Software Foundation, Inc.
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 --  This package contains the implementations of the stream attributes for
36 --  elementary types. These are the subprograms that are directly accessed
37 --  by occurrences of the stream attributes where the type is elementary.
38
39 --  We only provide the subprograms for the standard base types. For user
40 --  defined types, the subprogram for the corresponding root type is called
41 --  with an appropriate conversion.
42
43 with System;
44 with System.Unsigned_Types;
45 with Ada.Streams;
46
47 package System.Stream_Attributes is
48 pragma Preelaborate (Stream_Attributes);
49
50    pragma Suppress (Accessibility_Check, Stream_Attributes);
51    --  No need to check accessibility on arguments of subprograms
52
53    package UST renames System.Unsigned_Types;
54
55    subtype RST is Ada.Streams.Root_Stream_Type'Class;
56
57    --  Enumeration types are usually transferred using the routine for the
58    --  corresponding integer. The exception is that special routines are
59    --  provided for Boolean and the character types, in case the protocol
60    --  in use provides specially for these types.
61
62    --  Access types use either a thin pointer (single address) or fat pointer
63    --  (double address) form. The following types are used to hold access
64    --  values using unchecked conversions.
65
66    type Thin_Pointer is record
67       P1 : System.Address;
68    end record;
69
70    type Fat_Pointer is record
71       P1 : System.Address;
72       P2 : System.Address;
73    end record;
74
75    ------------------------------------
76    -- Treatment of enumeration types --
77    ------------------------------------
78
79    --  In this interface, there are no specific routines for general input
80    --  or output of enumeration types. Generally, enumeration types whose
81    --  representation is unsigned (no negative representation values) are
82    --  treated as unsigned integers, and enumeration types that do have
83    --  negative representation values are treated as signed integers.
84
85    --  An exception is that there are specialized routines for Boolean,
86    --  Character, and Wide_Character types, but these specialized routines
87    --  are used only if the type in question has a standard representation.
88    --  For the case of a non-standard representation (one where the size of
89    --  the first subtype is specified, or where an enumeration representation
90    --  clause is given, these three types are treated like any other cases
91    --  of enumeration types, as described above.
92    --  for
93
94    ---------------------
95    -- Input Functions --
96    ---------------------
97
98    --  Functions for S'Input attribute. These functions are also used for
99    --  S'Read, with the obvious transformation, since the input operation
100    --  is the same for all elementary types (no bounds or discriminants
101    --  are involved).
102
103    function I_AD  (Stream : access RST) return Fat_Pointer;
104    function I_AS  (Stream : access RST) return Thin_Pointer;
105    function I_B   (Stream : access RST) return Boolean;
106    function I_C   (Stream : access RST) return Character;
107    function I_F   (Stream : access RST) return Float;
108    function I_I   (Stream : access RST) return Integer;
109    function I_LF  (Stream : access RST) return Long_Float;
110    function I_LI  (Stream : access RST) return Long_Integer;
111    function I_LLF (Stream : access RST) return Long_Long_Float;
112    function I_LLI (Stream : access RST) return Long_Long_Integer;
113    function I_LLU (Stream : access RST) return UST.Long_Long_Unsigned;
114    function I_LU  (Stream : access RST) return UST.Long_Unsigned;
115    function I_SF  (Stream : access RST) return Short_Float;
116    function I_SI  (Stream : access RST) return Short_Integer;
117    function I_SSI (Stream : access RST) return Short_Short_Integer;
118    function I_SSU (Stream : access RST) return UST.Short_Short_Unsigned;
119    function I_SU  (Stream : access RST) return UST.Short_Unsigned;
120    function I_U   (Stream : access RST) return UST.Unsigned;
121    function I_WC  (Stream : access RST) return Wide_Character;
122
123    -----------------------
124    -- Output Procedures --
125    -----------------------
126
127    --  Procedures for S'Write attribute. These procedures are also used
128    --  for 'Output, since for elementary types there is no difference
129    --  between 'Write and 'Output because there are no discriminants
130    --  or bounds to be written.
131
132    procedure W_AD  (Stream : access RST; Item : in Fat_Pointer);
133    procedure W_AS  (Stream : access RST; Item : in Thin_Pointer);
134    procedure W_B   (Stream : access RST; Item : in Boolean);
135    procedure W_C   (Stream : access RST; Item : in Character);
136    procedure W_F   (Stream : access RST; Item : in Float);
137    procedure W_I   (Stream : access RST; Item : in Integer);
138    procedure W_LF  (Stream : access RST; Item : in Long_Float);
139    procedure W_LI  (Stream : access RST; Item : in Long_Integer);
140    procedure W_LLF (Stream : access RST; Item : in Long_Long_Float);
141    procedure W_LLI (Stream : access RST; Item : in Long_Long_Integer);
142    procedure W_LLU (Stream : access RST; Item : in UST.Long_Long_Unsigned);
143    procedure W_LU  (Stream : access RST; Item : in UST.Long_Unsigned);
144    procedure W_SF  (Stream : access RST; Item : in Short_Float);
145    procedure W_SI  (Stream : access RST; Item : in Short_Integer);
146    procedure W_SSI (Stream : access RST; Item : in Short_Short_Integer);
147    procedure W_SSU (Stream : access RST; Item : in UST.Short_Short_Unsigned);
148    procedure W_SU  (Stream : access RST; Item : in UST.Short_Unsigned);
149    procedure W_U   (Stream : access RST; Item : in UST.Unsigned);
150    procedure W_WC  (Stream : access RST; Item : in Wide_Character);
151
152 private
153    pragma Inline (I_AD);
154    pragma Inline (I_AS);
155    pragma Inline (I_B);
156    pragma Inline (I_C);
157    pragma Inline (I_F);
158    pragma Inline (I_I);
159    pragma Inline (I_LF);
160    pragma Inline (I_LI);
161    pragma Inline (I_LLF);
162    pragma Inline (I_LLI);
163    pragma Inline (I_LLU);
164    pragma Inline (I_LU);
165    pragma Inline (I_SF);
166    pragma Inline (I_SI);
167    pragma Inline (I_SSI);
168    pragma Inline (I_SSU);
169    pragma Inline (I_SU);
170    pragma Inline (I_U);
171    pragma Inline (I_WC);
172
173    pragma Inline (W_AD);
174    pragma Inline (W_AS);
175    pragma Inline (W_B);
176    pragma Inline (W_C);
177    pragma Inline (W_F);
178    pragma Inline (W_I);
179    pragma Inline (W_LF);
180    pragma Inline (W_LI);
181    pragma Inline (W_LLF);
182    pragma Inline (W_LLI);
183    pragma Inline (W_LLU);
184    pragma Inline (W_LU);
185    pragma Inline (W_SF);
186    pragma Inline (W_SI);
187    pragma Inline (W_SSI);
188    pragma Inline (W_SSU);
189    pragma Inline (W_SU);
190    pragma Inline (W_U);
191    pragma Inline (W_WC);
192
193 end System.Stream_Attributes;