1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . W W D _ E N U M --
9 -- Copyright (C) 1992-2009, 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 with System
.WCh_StW
; use System
.WCh_StW
;
33 with System
.WCh_Con
; use System
.WCh_Con
;
35 with Ada
.Unchecked_Conversion
;
37 package body System
.WWd_Enum
is
39 -----------------------------------
40 -- Wide_Wide_Width_Enumeration_8 --
41 -----------------------------------
43 function Wide_Wide_Width_Enumeration_8
45 Indexes
: System
.Address
;
47 EM
: WC_Encoding_Method
) return Natural
51 type Natural_8
is range 0 .. 2 ** 7 - 1;
52 type Index_Table
is array (Natural) of Natural_8
;
53 type Index_Table_Ptr
is access Index_Table
;
55 function To_Index_Table_Ptr
is
56 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
58 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
62 for J
in Lo
.. Hi
loop
64 S
: constant String :=
65 Names
(Natural (IndexesT
(J
)) ..
66 Natural (IndexesT
(J
+ 1)) - 1);
67 WS
: Wide_Wide_String
(1 .. S
'Length);
70 String_To_Wide_Wide_String
(S
, WS
, L
, EM
);
71 W
:= Natural'Max (W
, L
);
76 end Wide_Wide_Width_Enumeration_8
;
78 ------------------------------------
79 -- Wide_Wide_Width_Enumeration_16 --
80 ------------------------------------
82 function Wide_Wide_Width_Enumeration_16
84 Indexes
: System
.Address
;
86 EM
: WC_Encoding_Method
) return Natural
90 type Natural_16
is range 0 .. 2 ** 15 - 1;
91 type Index_Table
is array (Natural) of Natural_16
;
92 type Index_Table_Ptr
is access Index_Table
;
94 function To_Index_Table_Ptr
is
95 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
97 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
101 for J
in Lo
.. Hi
loop
103 S
: constant String :=
104 Names
(Natural (IndexesT
(J
)) ..
105 Natural (IndexesT
(J
+ 1)) - 1);
106 WS
: Wide_Wide_String
(1 .. S
'Length);
109 String_To_Wide_Wide_String
(S
, WS
, L
, EM
);
110 W
:= Natural'Max (W
, L
);
115 end Wide_Wide_Width_Enumeration_16
;
117 ------------------------------------
118 -- Wide_Wide_Width_Enumeration_32 --
119 ------------------------------------
121 function Wide_Wide_Width_Enumeration_32
123 Indexes
: System
.Address
;
125 EM
: WC_Encoding_Method
) return Natural
129 type Natural_32
is range 0 .. 2 ** 31 - 1;
130 type Index_Table
is array (Natural) of Natural_32
;
131 type Index_Table_Ptr
is access Index_Table
;
133 function To_Index_Table_Ptr
is
134 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
136 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
140 for J
in Lo
.. Hi
loop
142 S
: constant String :=
143 Names
(Natural (IndexesT
(J
)) ..
144 Natural (IndexesT
(J
+ 1)) - 1);
145 WS
: Wide_Wide_String
(1 .. S
'Length);
148 String_To_Wide_Wide_String
(S
, WS
, L
, EM
);
149 W
:= Natural'Max (W
, L
);
154 end Wide_Wide_Width_Enumeration_32
;
156 ------------------------------
157 -- Wide_Width_Enumeration_8 --
158 ------------------------------
160 function Wide_Width_Enumeration_8
162 Indexes
: System
.Address
;
164 EM
: WC_Encoding_Method
) return Natural
168 type Natural_8
is range 0 .. 2 ** 7 - 1;
169 type Index_Table
is array (Natural) of Natural_8
;
170 type Index_Table_Ptr
is access Index_Table
;
172 function To_Index_Table_Ptr
is
173 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
175 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
179 for J
in Lo
.. Hi
loop
181 S
: constant String :=
182 Names
(Natural (IndexesT
(J
)) ..
183 Natural (IndexesT
(J
+ 1)) - 1);
184 WS
: Wide_String (1 .. S
'Length);
187 String_To_Wide_String
(S
, WS
, L
, EM
);
188 W
:= Natural'Max (W
, L
);
193 end Wide_Width_Enumeration_8
;
195 -------------------------------
196 -- Wide_Width_Enumeration_16 --
197 -------------------------------
199 function Wide_Width_Enumeration_16
201 Indexes
: System
.Address
;
203 EM
: WC_Encoding_Method
) return Natural
207 type Natural_16
is range 0 .. 2 ** 15 - 1;
208 type Index_Table
is array (Natural) of Natural_16
;
209 type Index_Table_Ptr
is access Index_Table
;
211 function To_Index_Table_Ptr
is
212 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
214 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
218 for J
in Lo
.. Hi
loop
220 S
: constant String :=
221 Names
(Natural (IndexesT
(J
)) ..
222 Natural (IndexesT
(J
+ 1)) - 1);
223 WS
: Wide_String (1 .. S
'Length);
226 String_To_Wide_String
(S
, WS
, L
, EM
);
227 W
:= Natural'Max (W
, L
);
232 end Wide_Width_Enumeration_16
;
234 -------------------------------
235 -- Wide_Width_Enumeration_32 --
236 -------------------------------
238 function Wide_Width_Enumeration_32
240 Indexes
: System
.Address
;
242 EM
: WC_Encoding_Method
) return Natural
246 type Natural_32
is range 0 .. 2 ** 31 - 1;
247 type Index_Table
is array (Natural) of Natural_32
;
248 type Index_Table_Ptr
is access Index_Table
;
250 function To_Index_Table_Ptr
is
251 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
253 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
257 for J
in Lo
.. Hi
loop
259 S
: constant String :=
260 Names
(Natural (IndexesT
(J
)) ..
261 Natural (IndexesT
(J
+ 1)) - 1);
262 WS
: Wide_String (1 .. S
'Length);
265 String_To_Wide_String
(S
, WS
, L
, EM
);
266 W
:= Natural'Max (W
, L
);
271 end Wide_Width_Enumeration_32
;