1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                                N A M E T                                 *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *            Copyright (C) 1992-2019, 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.  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 COPYING3.  If not, go to *
19  * http://www.gnu.org/licenses for a complete copy of the license.          *
20  *                                                                          *
21  * GNAT was originally developed  by the GNAT team at  New York University. *
22  * Extensive contributions were provided by Ada Core Technologies Inc.      *
23  *                                                                          *
24  ****************************************************************************/
25 
26 /* This is the C header that corresponds to the Ada package specification for
27    Namet.  It also contains the implementation of inlined functions from the
28    package body for Namet.  It was created manually from namet.ads and
29    namet.adb and must be kept synchronized with changes in these files.  */
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* Structure defining a names table entry.  */
36 
37 struct Name_Entry
38 {
39   Int Name_Chars_Index; /* Starting location of char in Name_Chars table. */
40   Short Name_Len;         /* Length of this name in characters. */
41   Byte Byte_Info;       /* Byte value associated with this name */
42   Byte Spare;           /* Unused */
43   Name_Id Hash_Link;    /* Link to next entry in names table for same hash
44                            code. Not accessed by C routines.  */
45   Int Int_Info;         /* Int value associated with this name */
46 };
47 
48 /* Pointer to names table vector. */
49 #define Names_Ptr namet__name_entries__table
50 extern struct Name_Entry *Names_Ptr;
51 
52 /* Pointer to name characters table. */
53 #define Name_Chars_Ptr namet__name_chars__table
54 extern char *Name_Chars_Ptr;
55 
56 /* This is Hostparm.Max_Line_Length.  */
57 #define Max_Line_Length (32767 - 1)
58 
59 /* The global name buffer.  */
60 struct Bounded_String
61 {
62   Nat Max_Length;
63   Nat Length;
64   char Chars[4 * Max_Line_Length]; /* Exact value for overflow detection.  */
65 };
66 
67 #define Global_Name_Buffer namet__global_name_buffer
68 extern struct Bounded_String Global_Name_Buffer;
69 
70 #define Name_Buffer Global_Name_Buffer.Chars
71 #define Name_Len Global_Name_Buffer.Length
72 
73 /* Get_Name_String returns a NUL terminated C string for the specified name.
74    We could use the official Ada routine for this purpose, but since the
75    strings we want are sitting in the name strings table in exactly the form
76    we need them (NUL terminated), we just point to the name directly. */
77 
78 static char *Get_Name_String (Name_Id);
79 
80 INLINE char *
Get_Name_String(Name_Id Id)81 Get_Name_String (Name_Id Id)
82 {
83   return Name_Chars_Ptr + Names_Ptr[Id - First_Name_Id].Name_Chars_Index + 1;
84 }
85 
86 #define Name_Equals namet__name_equals
87 extern Boolean Name_Equals (Name_Id, Name_Id);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92