1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT RUN-TIME COMPONENTS                         --
4--                                                                          --
5--                      S Y S T E M . W W D _ E N U M                       --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10--                                                                          --
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.                                     --
17--                                                                          --
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.               --
21--                                                                          --
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/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32--  This package contains routines used for Enumeration_Type'Wide_[Wide_]Width
33
34with System.WCh_Con;
35
36package System.WWd_Enum is
37   pragma Pure;
38
39   function Wide_Width_Enumeration_8
40     (Names   : String;
41      Indexes : System.Address;
42      Lo, Hi  : Natural;
43      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
44   --  Used to compute Enum'Wide_Width where Enum is an enumeration subtype
45   --  other than those defined in package Standard. Names is a string with
46   --  a lower bound of 1 containing the characters of all the enumeration
47   --  literals concatenated together in sequence. Indexes is the address
48   --  of an array of type array (0 .. N) of Natural_8, where N is the
49   --  number of enumeration literals in the type. The Indexes values are
50   --  the starting subscript of each enumeration literal, indexed by Pos
51   --  values, with an extra entry at the end containing Names'Length + 1.
52   --  The reason that Indexes is passed by address is that the actual type
53   --  is created on the fly by the expander.
54   --
55   --  Lo and Hi are the Pos values of the lower and upper bounds of the
56   --  subtype. The result is the value of Width, i.e. the maximum value
57   --  of the length of any enumeration literal in the given range. The
58   --  fifth parameter, EM, is the wide character encoding method used in
59   --  the Names table.
60
61   function Wide_Width_Enumeration_16
62     (Names   : String;
63      Indexes : System.Address;
64      Lo, Hi  : Natural;
65      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
66   --  Identical to Wide_Width_Enumeration_8 except that it handles types
67   --  using array (0 .. Num) of Natural_16 for the Indexes table.
68
69   function Wide_Width_Enumeration_32
70     (Names   : String;
71      Indexes : System.Address;
72      Lo, Hi  : Natural;
73      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
74   --  Identical to Wide_Width_Enumeration_8 except that it handles types
75   --  using array (0 .. Num) of Natural_32 for the Indexes table.
76
77   function Wide_Wide_Width_Enumeration_8
78     (Names   : String;
79      Indexes : System.Address;
80      Lo, Hi  : Natural;
81      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
82   --  Same function for Wide_Wide_Width attribute
83
84   function Wide_Wide_Width_Enumeration_16
85     (Names   : String;
86      Indexes : System.Address;
87      Lo, Hi  : Natural;
88      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
89   --  Same function for Wide_Wide_Width attribute
90
91   function Wide_Wide_Width_Enumeration_32
92     (Names   : String;
93      Indexes : System.Address;
94      Lo, Hi  : Natural;
95      EM      : System.WCh_Con.WC_Encoding_Method) return Natural;
96   --  Same function for Wide_Wide_Width attribute
97
98end System.WWd_Enum;
99