* gcc.pot: Regenerate.
[official-gcc.git] / gcc / gengtype.h
blobd8313e7c8900627b60567cca614838ebf954baff
1 /* Process source files and output type information.
2 Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* A file position, mostly for error messages.
21 The FILE element may be compared using pointer equality. */
22 struct fileloc {
23 const char *file;
24 int line;
27 /* Kinds of types we can understand. */
28 enum typekind {
29 TYPE_SCALAR,
30 TYPE_STRING,
31 TYPE_STRUCT,
32 TYPE_UNION,
33 TYPE_POINTER,
34 TYPE_ARRAY,
35 TYPE_LANG_STRUCT,
36 TYPE_PARAM_STRUCT
39 typedef struct pair *pair_p;
40 typedef struct type *type_p;
41 typedef unsigned lang_bitmap;
43 /* Option data for the 'nested_ptr' option. */
44 struct nested_ptr_data {
45 type_p type;
46 const char *convert_to;
47 const char *convert_from;
48 };
50 /* A way to pass data through to the output end. */
51 typedef struct options {
52 struct options *next;
53 const char *name;
54 const char *info;
55 } *options_p;
57 /* A name and a type. */
58 struct pair {
59 pair_p next;
60 const char *name;
61 type_p type;
62 struct fileloc line;
63 options_p opt;
66 #define NUM_PARAM 10
68 /* A description of a type. */
69 enum gc_used_enum
71 GC_UNUSED = 0,
72 GC_USED,
73 GC_MAYBE_POINTED_TO,
74 GC_POINTED_TO
77 struct type {
78 enum typekind kind;
79 type_p next;
80 type_p pointer_to;
81 enum gc_used_enum gc_used;
82 union {
83 type_p p;
84 struct {
85 const char *tag;
86 struct fileloc line;
87 pair_p fields;
88 options_p opt;
89 lang_bitmap bitmap;
90 type_p lang_struct;
91 } s;
92 char *sc;
93 struct {
94 type_p p;
95 const char *len;
96 } a;
97 struct {
98 type_p stru;
99 type_p param[NUM_PARAM];
100 struct fileloc line;
101 } param_struct;
102 } u;
105 #define UNION_P(x) \
106 ((x)->kind == TYPE_UNION || \
107 ((x)->kind == TYPE_LANG_STRUCT \
108 && (x)->u.s.lang_struct->kind == TYPE_UNION))
109 #define UNION_OR_STRUCT_P(x) \
110 ((x)->kind == TYPE_UNION \
111 || (x)->kind == TYPE_STRUCT \
112 || (x)->kind == TYPE_LANG_STRUCT)
114 /* The one and only TYPE_STRING. */
115 extern struct type string_type;
117 /* Variables used to communicate between the lexer and the parser. */
118 extern int lexer_toplevel_done;
119 extern struct fileloc lexer_line;
121 /* Print an error message. */
122 extern void error_at_line
123 (struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
125 /* Combines xmalloc() and vasprintf(). */
126 extern int xvasprintf (char **, const char *, va_list)
127 ATTRIBUTE_PRINTF (2, 0);
128 /* Like the above, but more convenient for quick coding. */
129 extern char * xasprintf (const char *, ...)
130 ATTRIBUTE_PRINTF_1;
132 /* Constructor routines for types. */
133 extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
134 extern type_p resolve_typedef (const char *s, struct fileloc *pos);
135 extern type_p new_structure (const char *name, int isunion,
136 struct fileloc *pos, pair_p fields,
137 options_p o);
138 extern type_p find_structure (const char *s, int isunion);
139 extern type_p create_scalar_type (const char *name, size_t name_len);
140 extern type_p create_pointer (type_p t);
141 extern type_p create_array (type_p t, const char *len);
142 extern options_p create_option (options_p, const char *name, const void *info);
143 extern type_p adjust_field_type (type_p, options_p);
144 extern void note_variable (const char *s, type_p t, options_p o,
145 struct fileloc *pos);
146 extern void note_yacc_type (options_p o, pair_p fields,
147 pair_p typeinfo, struct fileloc *pos);
149 /* Lexer and parser routines, most automatically generated. */
150 extern int yylex (void);
151 extern void yyerror (const char *);
152 extern int yyparse (void);
153 extern void parse_file (const char *name);
155 /* Output file handling. */
157 /* Structure representing an output file. */
158 struct outf
160 struct outf *next;
161 const char *name;
162 size_t buflength;
163 size_t bufused;
164 char *buf;
167 typedef struct outf * outf_p;
169 /* An output file, suitable for definitions, that can see declarations
170 made in INPUT_FILE and is linked into every language that uses
171 INPUT_FILE. */
172 extern outf_p get_output_file_with_visibility
173 (const char *input_file);
174 const char *get_output_file_name (const char *);
176 /* A list of output files suitable for definitions. There is one
177 BASE_FILES entry for each language. */
178 extern outf_p base_files[];
180 /* A bitmap that specifies which of BASE_FILES should be used to
181 output a definition that is different for each language and must be
182 defined once in each language that uses INPUT_FILE. */
183 extern lang_bitmap get_base_file_bitmap (const char *input_file);
185 /* Print, like fprintf, to O. */
186 extern void oprintf (outf_p o, const char *S, ...)
187 ATTRIBUTE_PRINTF_2;