1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . W W D _ E N U M --
9 -- Copyright (C) 1992-2005 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 with System.WCh_StW; use System.WCh_StW;
35 with System.WCh_Con; use System.WCh_Con;
37 with Unchecked_Conversion;
39 package body System.WWd_Enum is
41 -----------------------------------
42 -- Wide_Wide_Width_Enumeration_8 --
43 -----------------------------------
45 function Wide_Wide_Width_Enumeration_8
47 Indexes : System.Address;
49 EM : WC_Encoding_Method) return Natural
53 type Natural_8 is range 0 .. 2 ** 7 - 1;
54 type Index_Table is array (Natural) of Natural_8;
55 type Index_Table_Ptr is access Index_Table;
57 function To_Index_Table_Ptr is
58 new Unchecked_Conversion (System.Address, Index_Table_Ptr);
60 IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
64 for J in Lo .. Hi loop
66 WS : constant Wide_Wide_String :=
67 String_To_Wide_Wide_String
68 (Names (Natural (IndexesT (J)) ..
69 Natural (IndexesT (J + 1)) - 1), EM);
71 W := Natural'Max (W, WS'Length);
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 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 WS : constant Wide_Wide_String :=
104 String_To_Wide_Wide_String
105 (Names (Natural (IndexesT (J)) ..
106 Natural (IndexesT (J + 1)) - 1), EM);
108 W := Natural'Max (W, WS'Length);
113 end Wide_Wide_Width_Enumeration_16;
115 ------------------------------------
116 -- Wide_Wide_Width_Enumeration_32 --
117 ------------------------------------
119 function Wide_Wide_Width_Enumeration_32
121 Indexes : System.Address;
123 EM : WC_Encoding_Method) return Natural
127 type Natural_32 is range 0 .. 2 ** 31 - 1;
128 type Index_Table is array (Natural) of Natural_32;
129 type Index_Table_Ptr is access Index_Table;
131 function To_Index_Table_Ptr is
132 new Unchecked_Conversion (System.Address, Index_Table_Ptr);
134 IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
138 for J in Lo .. Hi loop
140 WS : constant Wide_Wide_String :=
141 String_To_Wide_Wide_String
142 (Names (Natural (IndexesT (J)) ..
143 Natural (IndexesT (J + 1)) - 1), EM);
145 W := Natural'Max (W, WS'Length);
150 end Wide_Wide_Width_Enumeration_32;
152 ------------------------------
153 -- Wide_Width_Enumeration_8 --
154 ------------------------------
156 function Wide_Width_Enumeration_8
158 Indexes : System.Address;
160 EM : WC_Encoding_Method) return Natural
164 type Natural_8 is range 0 .. 2 ** 7 - 1;
165 type Index_Table is array (Natural) of Natural_8;
166 type Index_Table_Ptr is access Index_Table;
168 function To_Index_Table_Ptr is
169 new Unchecked_Conversion (System.Address, Index_Table_Ptr);
171 IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
175 for J in Lo .. Hi loop
177 WS : constant Wide_String :=
178 String_To_Wide_String
179 (Names (Natural (IndexesT (J)) ..
180 Natural (IndexesT (J + 1)) - 1), EM);
182 W := Natural'Max (W, WS'Length);
187 end Wide_Width_Enumeration_8;
189 -------------------------------
190 -- Wide_Width_Enumeration_16 --
191 -------------------------------
193 function Wide_Width_Enumeration_16
195 Indexes : System.Address;
197 EM : WC_Encoding_Method) return Natural
201 type Natural_16 is range 0 .. 2 ** 15 - 1;
202 type Index_Table is array (Natural) of Natural_16;
203 type Index_Table_Ptr is access Index_Table;
205 function To_Index_Table_Ptr is
206 new Unchecked_Conversion (System.Address, Index_Table_Ptr);
208 IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
212 for J in Lo .. Hi loop
214 WS : constant Wide_String :=
215 String_To_Wide_String
216 (Names (Natural (IndexesT (J)) ..
217 Natural (IndexesT (J + 1)) - 1), EM);
219 W := Natural'Max (W, WS'Length);
224 end Wide_Width_Enumeration_16;
226 -------------------------------
227 -- Wide_Width_Enumeration_32 --
228 -------------------------------
230 function Wide_Width_Enumeration_32
232 Indexes : System.Address;
234 EM : WC_Encoding_Method) return Natural
238 type Natural_32 is range 0 .. 2 ** 31 - 1;
239 type Index_Table is array (Natural) of Natural_32;
240 type Index_Table_Ptr is access Index_Table;
242 function To_Index_Table_Ptr is
243 new Unchecked_Conversion (System.Address, Index_Table_Ptr);
245 IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
249 for J in Lo .. Hi loop
251 WS : constant Wide_String :=
252 String_To_Wide_String
253 (Names (Natural (IndexesT (J)) ..
254 Natural (IndexesT (J + 1)) - 1), EM);
256 W := Natural'Max (W, WS'Length);
261 end Wide_Width_Enumeration_32;