home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume29 / cproto / part02 / cproto.h < prev    next >
C/C++ Source or Header  |  1992-04-06  |  5KB  |  142 lines

  1. /* $Id: cproto.h 3.4 92/04/04 13:59:08 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 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 temporary file */
  40. } DeclSpec;
  41.  
  42. /* Styles of function definitions */
  43. #define FUNC_NONE        0    /* not a function definition */
  44. #define FUNC_TRADITIONAL    1    /* traditional style */
  45. #define FUNC_ANSI        2    /* ANSI style */
  46. typedef int FuncDefStyle;
  47.  
  48. /* This structure stores information about a declarator. */
  49. typedef struct declarator {
  50.     char *name;             /* name of variable or function */
  51.     char *text;             /* source text */
  52.     long begin;             /* offset in temporary file */
  53.     long begin_comment;         /* begin offset of comment */
  54.     long end_comment;            /* end offset of comment */
  55.     FuncDefStyle func_def;        /* style of function definition */
  56.     ParameterList params;        /* function parameters */
  57.     struct declarator *head;        /* head function declarator */
  58.     struct declarator *func_stack;    /* stack of function declarators */
  59.     struct declarator *next;        /* next declarator in list */
  60. } Declarator;
  61.  
  62. /* This is a list of declarators. */
  63. typedef struct declarator_list {
  64.     Declarator *first;        /* pointer to first declarator in list */
  65.     Declarator *last;        /* pointer to last declarator in list */  
  66. } DeclaratorList;
  67.  
  68. /* This structure stores information about a function parameter. */
  69. typedef struct parameter {
  70.     struct parameter *next;    /* next parameter in list */
  71.     DeclSpec decl_spec;
  72.     Declarator *declarator;
  73.     char *comment;        /* comment following the parameter */
  74. } Parameter;
  75.  
  76. /* parser stack entry type */
  77. typedef union {
  78.     Text text;
  79.     DeclSpec decl_spec;
  80.     Parameter parameter;
  81.     ParameterList param_list;
  82.     Declarator *declarator;
  83.     DeclaratorList decl_list;
  84. } YYSTYPE;
  85.  
  86. /* Prototype styles */
  87. #define PROTO_NONE        0    /* do not output any prototypes */
  88. #define PROTO_TRADITIONAL    1    /* comment out parameters */
  89. #define PROTO_ABSTRACT        2    /* comment out parameter names */
  90. #define PROTO_ANSI        3    /* ANSI C prototype */
  91. #define PROTO_MACRO        4    /* macro around parameters */
  92. typedef int PrototypeStyle;
  93.  
  94. /* The role of a function declarator */
  95. #define FUNC_OTHER    0    /* miscellaneous declaration */
  96. #define FUNC_PROTO    1    /* prototype */
  97. #define FUNC_DEF    2    /* function definition */
  98. typedef int FuncDeclRole;
  99.  
  100. /* Prototype/function definition output formats */
  101. #define FMT_OTHER        0    /* miscellaneous */
  102. #define FMT_PROTO        1    /* prototype */
  103. #define FMT_FUNC        2    /* function definition */
  104. #define FMT_FUNC_COMMENT    3    /* func. def. with parameter comments */
  105. typedef int FuncFormatType;
  106.  
  107. /* Prototype/function definition output format */
  108. typedef struct {
  109.     char *decl_spec_prefix;    /* output before declaration specifier */
  110.     char *declarator_prefix;    /* output before declarator name */
  111.     char *declarator_suffix;    /* output before '(' of parameter list */
  112.     char *first_param_prefix;    /* output before first parameter */
  113.     char *middle_param_prefix;    /* output before each subsequent parameter */
  114.     char *last_param_suffix;    /* output after last parameter */
  115. } FuncFormat;
  116.  
  117. /* Program options */
  118. extern boolean extern_out;
  119. extern boolean static_out;
  120. extern boolean variables_out;
  121. extern boolean promote_param;
  122. extern PrototypeStyle proto_style;
  123. extern FuncDefStyle func_style;
  124. extern boolean define_macro;
  125. extern char *macro_name;
  126. extern boolean proto_comments;
  127. extern int num_inc_dir;
  128. extern char *inc_dir[];
  129. extern FuncFormat fmt[4];
  130.  
  131. /* Global declarations */
  132. extern char progname[];
  133.  
  134. extern char *xmalloc(), *xstrdup(), *trim_path_sep();
  135. extern void put_error();
  136. extern void init_parser(), process_file(), pop_file();
  137. extern char *cur_file_name();
  138. extern unsigned cur_line_num();
  139. extern FILE *cur_tmp_file();
  140. extern void cur_file_changed();
  141. extern long cur_begin_comment();
  142.