* target.h (struct gcc_target): Add new field to struct cxx: import_export_class.
[official-gcc.git] / gcc / gengtype.h
blobbf3c5624ced69483fd7f8e9320f63c17ea874b03
1 /* Process source files and output type information.
2 Copyright (C) 2002, 2003, 2004 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 2, 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 COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 /* A file position, mostly for error messages.
22 The FILE element may be compared using pointer equality. */
23 struct fileloc {
24 const char *file;
25 int line;
28 /* Kinds of types we can understand. */
29 enum typekind {
30 TYPE_SCALAR,
31 TYPE_STRING,
32 TYPE_STRUCT,
33 TYPE_UNION,
34 TYPE_POINTER,
35 TYPE_ARRAY,
36 TYPE_LANG_STRUCT,
37 TYPE_PARAM_STRUCT
40 typedef struct pair *pair_p;
41 typedef struct type *type_p;
42 typedef unsigned lang_bitmap;
44 /* Option data for the 'nested_ptr' option. */
45 struct nested_ptr_data {
46 type_p type;
47 const char *convert_to;
48 const char *convert_from;
49 };
51 /* A way to pass data through to the output end. */
52 typedef struct options {
53 struct options *next;
54 const char *name;
55 const void *info;
56 } *options_p;
58 /* A name and a type. */
59 struct pair {
60 pair_p next;
61 const char *name;
62 type_p type;
63 struct fileloc line;
64 options_p opt;
67 #define NUM_PARAM 10
69 /* A description of a type. */
70 struct type {
71 enum typekind kind;
72 type_p next;
73 type_p pointer_to;
74 enum gc_used_enum {
75 GC_UNUSED = 0,
76 GC_USED,
77 GC_MAYBE_POINTED_TO,
78 GC_POINTED_TO
79 } gc_used;
80 union {
81 type_p p;
82 struct {
83 const char *tag;
84 struct fileloc line;
85 pair_p fields;
86 options_p opt;
87 lang_bitmap bitmap;
88 type_p lang_struct;
89 } s;
90 char *sc;
91 struct {
92 type_p p;
93 const char *len;
94 } a;
95 struct {
96 type_p stru;
97 type_p param[NUM_PARAM];
98 struct fileloc line;
99 } param_struct;
100 } u;
103 #define UNION_P(x) \
104 ((x)->kind == TYPE_UNION || \
105 ((x)->kind == TYPE_LANG_STRUCT \
106 && (x)->u.s.lang_struct->kind == TYPE_UNION))
107 #define UNION_OR_STRUCT_P(x) \
108 ((x)->kind == TYPE_UNION \
109 || (x)->kind == TYPE_STRUCT \
110 || (x)->kind == TYPE_LANG_STRUCT)
112 /* The one and only TYPE_STRING. */
113 extern struct type string_type;
115 /* Variables used to communicate between the lexer and the parser. */
116 extern int lexer_toplevel_done;
117 extern struct fileloc lexer_line;
119 /* Print an error message. */
120 extern void error_at_line
121 (struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
123 /* Combines xmalloc() and vasprintf(). */
124 extern int xvasprintf (char **, const char *, va_list)
125 ATTRIBUTE_PRINTF (2, 0);
126 /* Like the above, but more convenient for quick coding. */
127 extern char * xasprintf (const char *, ...)
128 ATTRIBUTE_PRINTF_1;
130 /* Constructor routines for types. */
131 extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
132 extern type_p resolve_typedef (const char *s, struct fileloc *pos);
133 extern void new_structure (const char *name, int isunion,
134 struct fileloc *pos, pair_p fields,
135 options_p o);
136 extern type_p find_structure (const char *s, int isunion);
137 extern type_p create_scalar_type (const char *name, size_t name_len);
138 extern type_p create_pointer (type_p t);
139 extern type_p create_array (type_p t, const char *len);
140 extern options_p create_option (const char *name, void *info);
141 extern type_p adjust_field_type (type_p, options_p);
142 extern void note_variable (const char *s, type_p t, options_p o,
143 struct fileloc *pos);
144 extern void note_yacc_type (options_p o, pair_p fields,
145 pair_p typeinfo, struct fileloc *pos);
147 /* Lexer and parser routines, most automatically generated. */
148 extern int yylex (void);
149 extern void yyerror (const char *);
150 extern int yyparse (void);
151 extern void parse_file (const char *name);
153 /* Output file handling. */
155 /* Structure representing an output file. */
156 struct outf
158 struct outf *next;
159 const char *name;
160 size_t buflength;
161 size_t bufused;
162 char *buf;
165 typedef struct outf * outf_p;
167 /* An output file, suitable for definitions, that can see declarations
168 made in INPUT_FILE and is linked into every language that uses
169 INPUT_FILE. */
170 extern outf_p get_output_file_with_visibility
171 (const char *input_file);
172 const char *get_output_file_name (const char *);
174 /* A list of output files suitable for definitions. There is one
175 BASE_FILES entry for each language. */
176 extern outf_p base_files[];
178 /* A bitmap that specifies which of BASE_FILES should be used to
179 output a definition that is different for each language and must be
180 defined once in each language that uses INPUT_FILE. */
181 extern lang_bitmap get_base_file_bitmap (const char *input_file);
183 /* Print, like fprintf, to O. */
184 extern void oprintf (outf_p o, const char *S, ...)
185 ATTRIBUTE_PRINTF_2;