home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / cproto / part02 / cproto.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-15  |  4.9 KB  |  146 lines

  1. /* $Id: cproto.h 3.3 92/03/14 11:57:14 cthuang Exp $
  2.  *
  3.  * Declarations for C function prototype generator
  4.  */
  5. #include "config.h"
  6.  
  7. /* Boolean type */
  8. typedef char boolean;
  9. #define FALSE    0
  10. #define TRUE    1
  11.  
  12. /* Source file text */
  13. typedef struct text {
  14.     char text[MAX_TEXT_SIZE];    /* source text */
  15.     long begin;         /* offset in temporary output file */
  16. } Text;
  17.  
  18. /* This is a list of function parameters. */
  19. typedef struct parameter_list {
  20.     struct parameter *first;    /* pointer to first parameter in list */
  21.     struct parameter *last;    /* pointer to last parameter in list */  
  22.     long begin_comment;     /* begin offset of comment */
  23.     long end_comment;        /* end offset of comment */
  24.     char *comment;        /* comment at start of parameter list */
  25. } ParameterList;
  26.  
  27. /* Declaration specifier flags */
  28. #define DS_EXTERN    0    /* default: external declaration */
  29. #define DS_STATIC    1    /* visible only in current file */
  30. #define DS_CHAR     2    /* "char" type specifier in declaration */
  31. #define DS_SHORT    4    /* "short" type specifier in declaration */
  32. #define DS_FLOAT    8    /* "float" type specifier in declaration */
  33. #define DS_JUNK     16    /* we're not interested in this declaration */
  34.  
  35. /* This structure stores information about a declaration specifier. */
  36. typedef struct decl_spec {
  37.     unsigned short flags;    /* flags defined above */
  38.     char *text;         /* source text */
  39.     long begin;         /* offset in output file */
  40. } DeclSpec;
  41.  
  42. /* Styles of function definitions */
  43. typedef enum {
  44.     FUNC_NONE,            /* not a function definition */
  45.     FUNC_TRADITIONAL,        /* traditional style */
  46.     FUNC_ANSI            /* ANSI style */
  47. } FuncDefStyle;
  48.  
  49. /* This structure stores information about a declarator. */
  50. typedef struct declarator {
  51.     char *name;             /* name of variable or function */
  52.     char *text;             /* source text */
  53.     long begin;             /* offset in temporary file */
  54.     long begin_comment;         /* begin offset of comment */
  55.     long end_comment;            /* end offset of comment */
  56.     FuncDefStyle func_def;        /* style of function definition */
  57.     ParameterList params;        /* function parameters */
  58.     struct declarator *head;        /* head function declarator */
  59.     struct declarator *func_stack;    /* stack of function declarators */
  60.     struct declarator *next;        /* next declarator in list */
  61. } Declarator;
  62.  
  63. /* This is a list of declarators. */
  64. typedef struct declarator_list {
  65.     Declarator *first;        /* pointer to first declarator in list */
  66.     Declarator *last;        /* pointer to last declarator in list */  
  67. } DeclaratorList;
  68.  
  69. /* This structure stores information about a function parameter. */
  70. typedef struct parameter {
  71.     struct parameter *next;    /* next parameter in list */
  72.     DeclSpec decl_spec;
  73.     Declarator *declarator;
  74.     char *comment;        /* comment following the parameter */
  75. } Parameter;
  76.  
  77. /* parser stack entry type */
  78. typedef union {
  79.     Text text;
  80.     DeclSpec decl_spec;
  81.     Parameter parameter;
  82.     ParameterList param_list;
  83.     Declarator *declarator;
  84.     DeclaratorList decl_list;
  85. } YYSTYPE;
  86.  
  87. /* Prototype styles */
  88. typedef enum {
  89.     PROTO_NONE,     /* do not output any prototypes */
  90.     PROTO_TRADITIONAL,    /* comment out parameters */
  91.     PROTO_ABSTRACT,    /* comment out parameter names */
  92.     PROTO_ANSI,     /* ANSI C prototype */
  93.     PROTO_MACRO,    /* preprocessor macro around parameters */
  94. } PrototypeStyle;
  95.  
  96. /* The role of a function declarator */
  97. typedef enum {
  98.     FUNC_OTHER,     /* declarator for a miscellaneous declaration */
  99.     FUNC_PROTO,     /* declarator for a prototype */
  100.     FUNC_DEF        /* declarator for a function definition */
  101. } FuncDeclRole;
  102.  
  103. /* Prototype/function definition output formats */
  104. typedef enum {
  105.     FMT_OTHER,        /* miscellaneous */
  106.     FMT_PROTO,        /* prototype */
  107.     FMT_FUNC,        /* function definition */
  108.     FMT_FUNC_COMMENT    /* function definition with parameter comments */
  109. } FuncFormatType;
  110.  
  111. /* Prototype/function definition output format */
  112. typedef struct {
  113.     char *decl_spec_prefix;    /* output before declaration specifier */
  114.     char *declarator_prefix;    /* output before declarator name */
  115.     char *declarator_suffix;    /* output before '(' of parameter list */
  116.     char *first_param_prefix;    /* output before first parameter */
  117.     char *middle_param_prefix;    /* output before each subsequent parameter */
  118.     char *last_param_suffix;    /* output after last parameter */
  119. } FuncFormat;
  120.  
  121. /* Program options */
  122. extern boolean extern_out;
  123. extern boolean static_out;
  124. extern boolean variables_out;
  125. extern boolean promote_param;
  126. extern PrototypeStyle proto_style;
  127. extern FuncDefStyle func_style;
  128. extern boolean define_macro;
  129. extern char *macro_name;
  130. extern boolean file_comment_out;
  131. extern int num_inc_dir;
  132. extern char *inc_dir[];
  133. extern FuncFormat fmt[4];
  134.  
  135. /* Global declarations */
  136. extern char progname[];
  137. extern long begin_comment, end_comment;
  138.  
  139. extern char *xmalloc(), *xstrdup(), *trim_path_sep();
  140. extern void put_error();
  141. extern void init_parser(), process_file(), pop_file();
  142. extern char *cur_file_name();
  143. extern unsigned cur_line_num();
  144. extern FILE *cur_tmp_file();
  145. extern void cur_file_changed();
  146.