annotate gcc/ada/libgnat/a-wtcoio.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . W I D E _ T E X T _ IO . C O M P L E X _ I O --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Ada.Wide_Text_IO.Complex_Aux;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 with System.WCh_Con; use System.WCh_Con;
kono
parents:
diff changeset
35 with System.WCh_WtS; use System.WCh_WtS;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 package body Ada.Wide_Text_IO.Complex_IO is
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 package Aux renames Ada.Wide_Text_IO.Complex_Aux;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 subtype LLF is Long_Long_Float;
kono
parents:
diff changeset
44 -- Type used for calls to routines in Aux
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 function TFT is new
kono
parents:
diff changeset
47 Ada.Unchecked_Conversion (File_Type, Ada.Wide_Text_IO.File_Type);
kono
parents:
diff changeset
48 -- This unchecked conversion is to get around a visibility bug in
kono
parents:
diff changeset
49 -- GNAT version 2.04w. It should be possible to simply use the
kono
parents:
diff changeset
50 -- subtype declared above and do normal checked conversions.
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 ---------
kono
parents:
diff changeset
53 -- Get --
kono
parents:
diff changeset
54 ---------
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 procedure Get
kono
parents:
diff changeset
57 (File : File_Type;
kono
parents:
diff changeset
58 Item : out Complex;
kono
parents:
diff changeset
59 Width : Field := 0)
kono
parents:
diff changeset
60 is
kono
parents:
diff changeset
61 Real_Item : Real'Base;
kono
parents:
diff changeset
62 Imag_Item : Real'Base;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 begin
kono
parents:
diff changeset
65 Aux.Get (TFT (File), LLF (Real_Item), LLF (Imag_Item), Width);
kono
parents:
diff changeset
66 Item := (Real_Item, Imag_Item);
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 exception
kono
parents:
diff changeset
69 when Constraint_Error => raise Data_Error;
kono
parents:
diff changeset
70 end Get;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 ---------
kono
parents:
diff changeset
73 -- Get --
kono
parents:
diff changeset
74 ---------
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 procedure Get
kono
parents:
diff changeset
77 (Item : out Complex;
kono
parents:
diff changeset
78 Width : Field := 0)
kono
parents:
diff changeset
79 is
kono
parents:
diff changeset
80 begin
kono
parents:
diff changeset
81 Get (Current_Input, Item, Width);
kono
parents:
diff changeset
82 end Get;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 ---------
kono
parents:
diff changeset
85 -- Get --
kono
parents:
diff changeset
86 ---------
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 procedure Get
kono
parents:
diff changeset
89 (From : Wide_String;
kono
parents:
diff changeset
90 Item : out Complex;
kono
parents:
diff changeset
91 Last : out Positive)
kono
parents:
diff changeset
92 is
kono
parents:
diff changeset
93 Real_Item : Real'Base;
kono
parents:
diff changeset
94 Imag_Item : Real'Base;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 S : constant String := Wide_String_To_String (From, WCEM_Upper);
kono
parents:
diff changeset
97 -- String on which we do the actual conversion. Note that the method
kono
parents:
diff changeset
98 -- used for wide character encoding is irrelevant, since if there is
kono
parents:
diff changeset
99 -- a character outside the Standard.Character range then the call to
kono
parents:
diff changeset
100 -- Aux.Gets will raise Data_Error in any case.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 begin
kono
parents:
diff changeset
103 Aux.Gets (S, LLF (Real_Item), LLF (Imag_Item), Last);
kono
parents:
diff changeset
104 Item := (Real_Item, Imag_Item);
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 exception
kono
parents:
diff changeset
107 when Data_Error => raise Constraint_Error;
kono
parents:
diff changeset
108 end Get;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 ---------
kono
parents:
diff changeset
111 -- Put --
kono
parents:
diff changeset
112 ---------
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 procedure Put
kono
parents:
diff changeset
115 (File : File_Type;
kono
parents:
diff changeset
116 Item : Complex;
kono
parents:
diff changeset
117 Fore : Field := Default_Fore;
kono
parents:
diff changeset
118 Aft : Field := Default_Aft;
kono
parents:
diff changeset
119 Exp : Field := Default_Exp)
kono
parents:
diff changeset
120 is
kono
parents:
diff changeset
121 begin
kono
parents:
diff changeset
122 Aux.Put (TFT (File), LLF (Re (Item)), LLF (Im (Item)), Fore, Aft, Exp);
kono
parents:
diff changeset
123 end Put;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 ---------
kono
parents:
diff changeset
126 -- Put --
kono
parents:
diff changeset
127 ---------
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 procedure Put
kono
parents:
diff changeset
130 (Item : Complex;
kono
parents:
diff changeset
131 Fore : Field := Default_Fore;
kono
parents:
diff changeset
132 Aft : Field := Default_Aft;
kono
parents:
diff changeset
133 Exp : Field := Default_Exp)
kono
parents:
diff changeset
134 is
kono
parents:
diff changeset
135 begin
kono
parents:
diff changeset
136 Put (Current_Output, Item, Fore, Aft, Exp);
kono
parents:
diff changeset
137 end Put;
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 ---------
kono
parents:
diff changeset
140 -- Put --
kono
parents:
diff changeset
141 ---------
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 procedure Put
kono
parents:
diff changeset
144 (To : out Wide_String;
kono
parents:
diff changeset
145 Item : Complex;
kono
parents:
diff changeset
146 Aft : Field := Default_Aft;
kono
parents:
diff changeset
147 Exp : Field := Default_Exp)
kono
parents:
diff changeset
148 is
kono
parents:
diff changeset
149 S : String (To'First .. To'Last);
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 begin
kono
parents:
diff changeset
152 Aux.Puts (S, LLF (Re (Item)), LLF (Im (Item)), Aft, Exp);
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 for J in S'Range loop
kono
parents:
diff changeset
155 To (J) := Wide_Character'Val (Character'Pos (S (J)));
kono
parents:
diff changeset
156 end loop;
kono
parents:
diff changeset
157 end Put;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 end Ada.Wide_Text_IO.Complex_IO;