diff options
author | Zack Weinberg <zackw@panix.com> | 2007-03-26 21:04:59 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2007-03-26 21:04:59 +0000 |
commit | 065ae6117579cc9a089c238207b42f5a1470423a (patch) | |
tree | 0a7175b4448ec3facb884c40c5169621bbe9bbe8 /gcc/gengtype.h | |
parent | 17defa6a13ef4f317e22dcb3827b4e8ea1b37541 (diff) | |
download | gcc-065ae6117579cc9a089c238207b42f5a1470423a.tar.gz |
gengtype.h: Remove all type definitions to gengtype.c...
* gengtype.h: Remove all type definitions to gengtype.c; leave
only definitions of options_p, type_p, and pair_p as opaque
pointers. Update prototypes.
* gengtype.c: Many type definitions moved here from gengtype.h.
Consolidate type definitions at the top of the file.
(xvasprintf): Delete.
(xasprintf): Make static.
(create_nested_pointer_option): Add 'next' parameter.
(create_field_all, create_field_at): New functions.
(create_field): Now a thin wrapper around create_field_all.
(create_optional_field): Rename create_optional_field_ and add
line argument. Original name is now a macro which supplies
__LINE__.
(oprintf): Use vsnprintf directly.
(close_output_files): Use fatal rather than perror/exit.
(note_def_vec, note_def_vec_alloc): Use create_field_at.
(main): Set progname. Don't use exit.
* gengtype-yacc.y (struct_fields): Use create_field_at.
(option, optionseqopt): Delete.
(optionseq): Consolidate productions from option here so we
can use the first argument to create_option.
From-SVN: r123233
Diffstat (limited to 'gcc/gengtype.h')
-rw-r--r-- | gcc/gengtype.h | 136 |
1 files changed, 10 insertions, 126 deletions
diff --git a/gcc/gengtype.h b/gcc/gengtype.h index f803ad3c1ee..345d80d9022 100644 --- a/gcc/gengtype.h +++ b/gcc/gengtype.h @@ -18,6 +18,9 @@ along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef GCC_GENGTYPE_H +#define GCC_GENGTYPE_H + /* A file position, mostly for error messages. The FILE element may be compared using pointer equality. */ struct fileloc { @@ -25,92 +28,10 @@ struct fileloc { int line; }; -/* Kinds of types we can understand. */ -enum typekind { - TYPE_SCALAR, - TYPE_STRING, - TYPE_STRUCT, - TYPE_UNION, - TYPE_POINTER, - TYPE_ARRAY, - TYPE_LANG_STRUCT, - TYPE_PARAM_STRUCT -}; - +/* Data types handed around within, but opaque to, the lexer and parser. */ typedef struct pair *pair_p; typedef struct type *type_p; -typedef unsigned lang_bitmap; - -/* Option data for the 'nested_ptr' option. */ -struct nested_ptr_data { - type_p type; - const char *convert_to; - const char *convert_from; -}; - -/* A way to pass data through to the output end. */ -typedef struct options { - struct options *next; - const char *name; - const char *info; -} *options_p; - -/* A name and a type. */ -struct pair { - pair_p next; - const char *name; - type_p type; - struct fileloc line; - options_p opt; -}; - -#define NUM_PARAM 10 - -/* A description of a type. */ -enum gc_used_enum - { - GC_UNUSED = 0, - GC_USED, - GC_MAYBE_POINTED_TO, - GC_POINTED_TO - }; - -struct type { - enum typekind kind; - type_p next; - type_p pointer_to; - enum gc_used_enum gc_used; - union { - type_p p; - struct { - const char *tag; - struct fileloc line; - pair_p fields; - options_p opt; - lang_bitmap bitmap; - type_p lang_struct; - } s; - bool scalar_is_char; - struct { - type_p p; - const char *len; - } a; - struct { - type_p stru; - type_p param[NUM_PARAM]; - struct fileloc line; - } param_struct; - } u; -}; - -#define UNION_P(x) \ - ((x)->kind == TYPE_UNION || \ - ((x)->kind == TYPE_LANG_STRUCT \ - && (x)->u.s.lang_struct->kind == TYPE_UNION)) -#define UNION_OR_STRUCT_P(x) \ - ((x)->kind == TYPE_UNION \ - || (x)->kind == TYPE_STRUCT \ - || (x)->kind == TYPE_LANG_STRUCT) +typedef struct options *options_p; /* Variables used to communicate between the lexer and the parser. */ extern int lexer_toplevel_done; @@ -120,13 +41,6 @@ extern struct fileloc lexer_line; extern void error_at_line (struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2; -/* Combines xmalloc() and vasprintf(). */ -extern int xvasprintf (char **, const char *, va_list) - ATTRIBUTE_PRINTF (2, 0); -/* Like the above, but more convenient for quick coding. */ -extern char * xasprintf (const char *, ...) - ATTRIBUTE_PRINTF_1; - /* Constructor routines for types. */ extern void do_typedef (const char *s, type_p t, struct fileloc *pos); extern void do_scalar_typedef (const char *s, struct fileloc *pos); @@ -139,8 +53,10 @@ extern type_p create_scalar_type (const char *name); extern type_p create_pointer (type_p t); extern type_p create_array (type_p t, const char *len); extern options_p create_option (options_p, const char *name, const void *info); -extern options_p create_nested_ptr_option (type_p t, const char *from, - const char *to); +extern options_p create_nested_ptr_option (options_p, type_p t, + const char *from, const char *to); +extern pair_p create_field_at (pair_p next, type_p type, const char *name, + options_p opt, struct fileloc *pos); extern type_p adjust_field_type (type_p, options_p); extern void note_variable (const char *s, type_p t, options_p o, struct fileloc *pos); @@ -155,36 +71,4 @@ extern void yyerror (const char *); extern int yyparse (void); extern void parse_file (const char *name); -/* Output file handling. */ - -/* Structure representing an output file. */ -struct outf -{ - struct outf *next; - const char *name; - size_t buflength; - size_t bufused; - char *buf; -}; - -typedef struct outf * outf_p; - -/* An output file, suitable for definitions, that can see declarations - made in INPUT_FILE and is linked into every language that uses - INPUT_FILE. */ -extern outf_p get_output_file_with_visibility - (const char *input_file); -const char *get_output_file_name (const char *); - -/* A list of output files suitable for definitions. There is one - BASE_FILES entry for each language. */ -extern outf_p base_files[]; - -/* A bitmap that specifies which of BASE_FILES should be used to - output a definition that is different for each language and must be - defined once in each language that uses INPUT_FILE. */ -extern lang_bitmap get_base_file_bitmap (const char *input_file); - -/* Print, like fprintf, to O. */ -extern void oprintf (outf_p o, const char *S, ...) - ATTRIBUTE_PRINTF_2; +#endif |