dbghelp: Properly fail on PDB files generated by MSVC compiler version 14.31.
[wine.git] / tools / wrc / wpp_private.h
blob435dbcc005a697afdc00699fdb546b1cc2d2bbdb
1 /*
2 * Copyright 1998 Bertho A. Stultiens (BS)
3 * Copyright 2002 Alexandre Julliard
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_WPP_PRIVATE_H
21 #define __WINE_WPP_PRIVATE_H
23 #include <stdio.h>
24 #include <string.h>
25 #include "wine/list.h"
27 extern void wpp_del_define( const char *name );
28 extern void wpp_add_cmdline_define( const char *value );
29 extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug );
30 extern void wpp_add_include_path( const char *path );
31 extern char *wpp_find_include( const char *name, const char *parent_name );
32 /* Return value == 0 means successful execution */
33 extern int wpp_parse( const char *input, FILE *output );
35 struct pp_entry; /* forward */
37 * Include logic
38 * A stack of files which are already included and
39 * are protected in the #ifndef/#endif way.
41 typedef struct includelogicentry {
42 struct list entry;
43 struct pp_entry *ppp; /* The define which protects the file */
44 char *filename; /* The filename of the include */
45 } includelogicentry_t;
48 * The expansiontext of a macro
50 typedef enum {
51 exp_text, /* Simple text substitution */
52 exp_concat, /* Concat (##) operator requested */
53 exp_stringize, /* Stringize (#) operator requested */
54 exp_subst /* Substitute argument */
55 } def_exp_t;
57 typedef struct mtext {
58 struct mtext *next;
59 struct mtext *prev;
60 def_exp_t type;
61 union {
62 char *text;
63 int argidx; /* For exp_subst and exp_stringize reference */
64 } subst;
65 } mtext_t;
68 * The define descriptor
70 typedef enum {
71 def_none, /* Not-a-define; used as return value */
72 def_define, /* Simple defines */
73 def_macro, /* Macro defines */
74 def_special /* Special expansions like __LINE__ and __FILE__ */
75 } def_type_t;
77 typedef struct pp_entry {
78 struct list entry;
79 def_type_t type; /* Define or macro */
80 char *ident; /* The key */
81 char **margs; /* Macro arguments array or NULL if none */
82 int nargs;
83 union {
84 mtext_t *mtext; /* The substitution sequence or NULL if none */
85 char *text;
86 } subst;
87 int expanding; /* Set when feeding substitution into the input */
88 char *filename; /* Filename where it was defined */
89 int linenumber; /* Linenumber where it was defined */
90 includelogicentry_t *iep; /* Points to the include it protects */
91 } pp_entry_t;
95 * If logic
97 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
99 typedef enum {
100 if_false,
101 if_true,
102 if_elif,
103 if_elsefalse,
104 if_elsetrue,
105 if_ignore,
106 if_error
107 } pp_if_state_t;
111 * Trace the include files to prevent double reading.
112 * This save 20..30% of processing time for most stuff
113 * that uses complex includes.
114 * States:
115 * -1 Don't track or seen junk
116 * 0 New include, waiting for "#ifndef __xxx_h"
117 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
118 * 2 Seen #endif, waiting for EOF
120 typedef struct
122 int state;
123 char *ppp; /* The define to be set from the #ifndef */
124 int ifdepth; /* The level of ifs at the #ifdef */
125 int seen_junk; /* Set when junk is seen */
126 } include_state_t;
128 #define SIZE_INT 1
129 #define SIZE_LONG 2
130 #define SIZE_LONGLONG 3
131 #define SIZE_MASK 0x00ff
132 #define FLAG_SIGNED 0x0100
134 typedef enum {
135 cv_sint = SIZE_INT + FLAG_SIGNED,
136 cv_uint = SIZE_INT,
137 cv_slong = SIZE_LONG + FLAG_SIGNED,
138 cv_ulong = SIZE_LONG,
139 cv_sll = SIZE_LONGLONG + FLAG_SIGNED,
140 cv_ull = SIZE_LONGLONG
141 } ctype_t;
143 typedef struct cval {
144 ctype_t type;
145 union {
146 int si;
147 unsigned int ui;
148 long sl;
149 unsigned long ul;
150 __int64 sll;
151 unsigned __int64 ull;
152 } val;
153 } cval_t;
157 pp_entry_t *pplookup(const char *ident);
158 pp_entry_t *pp_add_define(const char *def, const char *text);
159 pp_entry_t *pp_add_macro(char *ident, char *args[], int nargs, mtext_t *exp);
160 void pp_del_define(const char *name);
161 void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
162 void pp_push_if(pp_if_state_t s);
163 void pp_next_if_state(int);
164 pp_if_state_t pp_pop_if(void);
165 pp_if_state_t pp_if_state(void);
166 int pp_get_if_depth(void);
168 int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
169 int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
171 /* current preprocessor state */
172 /* everything is in this structure to avoid polluting the global symbol space */
173 struct pp_status
175 char *input; /* current input file name */
176 FILE *file; /* current input file descriptor */
177 int line_number; /* current line number */
178 int char_number; /* current char number in line */
179 int debug; /* debug messages flag */
182 extern struct pp_status pp_status;
183 extern include_state_t pp_incl_state;
184 extern int pedantic;
187 * From ppl.l
189 extern FILE *ppy_in;
190 extern FILE *ppy_out;
191 extern char *ppy_text;
192 extern int pp_flex_debug;
193 int ppy_lex(void);
195 void pp_do_include(char *fname, int type);
196 void pp_push_ignore_state(void);
197 void pp_pop_ignore_state(void);
200 * From ppy.y
202 int ppy_parse(void);
203 extern int ppy_debug;
205 #endif /* __WINE_WPP_PRIVATE_H */