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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef __WINE_WPP_PRIVATE_H
21 #define __WINE_WPP_PRIVATE_H
26 struct pp_entry; /* forward */
29 * A stack of files which are already included and
30 * are protected in the #ifndef/#endif way.
32 typedef struct includelogicentry {
33 struct includelogicentry *next;
34 struct includelogicentry *prev;
35 struct pp_entry *ppp; /* The define which protects the file */
36 char *filename; /* The filename of the include */
37 } includelogicentry_t;
40 * The arguments of a macrodefinition
48 def_arg_t type; /* Normal or ... argument */
49 char *arg; /* The textual argument */
50 int nnl; /* Number of newlines in the text to subst */
54 * The expansiontext of a macro
57 exp_text, /* Simple text substitution */
58 exp_concat, /* Concat (##) operator requested */
59 exp_stringize, /* Stringize (#) operator requested */
60 exp_subst /* Substitute argument */
63 typedef struct mtext {
69 int argidx; /* For exp_subst and exp_stringize reference */
74 * The define descriptor
77 def_none, /* Not-a-define; used as return value */
78 def_define, /* Simple defines */
79 def_macro, /* Macro defines */
80 def_special /* Special expansions like __LINE__ and __FILE__ */
83 typedef struct pp_entry {
84 struct pp_entry *next;
85 struct pp_entry *prev;
86 def_type_t type; /* Define or macro */
87 char *ident; /* The key */
88 marg_t **margs; /* Macro arguments array or NULL if none */
91 mtext_t *mtext; /* The substitution sequence or NULL if none */
94 int expanding; /* Set when feeding substitution into the input */
95 char *filename; /* Filename where it was defined */
96 int linenumber; /* Linenumber where it was defined */
97 includelogicentry_t *iep; /* Points to the include it protects */
104 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
117 * Trace the include files to prevent double reading.
118 * This save 20..30% of processing time for most stuff
119 * that uses complex includes.
121 * -1 Don't track or seen junk
122 * 0 New include, waiting for "#ifndef __xxx_h"
123 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
124 * 2 Seen #endif, waiting for EOF
129 char *ppp; /* The define to be set from the #ifndef */
130 int ifdepth; /* The level of ifs at the #ifdef */
131 int seen_junk; /* Set when junk is seen */
136 * I assume that 'long long' exists in the compiler when it has a size
137 * of 8 or bigger. If not, then we revert to a simple 'long' for now.
138 * This should prevent most unexpected things with other compilers than
139 * gcc and egcs for now.
140 * In the future it should be possible to use another way, like a
141 * structure, so that we can emulate the MS compiler.
143 #if defined(SIZEOF_LONGLONG) && SIZEOF_LONGLONG >= 8
144 typedef long long wrc_sll_t;
145 typedef unsigned long long wrc_ull_t;
147 typedef long wrc_sll_t;
148 typedef unsigned long wrc_ull_t;
155 #define SIZE_LONGLONG 5
156 #define SIZE_MASK 0x00ff
157 #define FLAG_SIGNED 0x0100
161 cv_schar = SIZE_CHAR + FLAG_SIGNED,
162 cv_uchar = SIZE_CHAR,
163 cv_sshort = SIZE_SHORT + FLAG_SIGNED,
164 cv_ushort = SIZE_SHORT,
166 cv_sint = SIZE_INT + FLAG_SIGNED,
168 cv_slong = SIZE_LONG + FLAG_SIGNED,
169 cv_ulong = SIZE_LONG,
170 cv_sll = SIZE_LONGLONG + FLAG_SIGNED,
171 cv_ull = SIZE_LONGLONG
174 typedef struct cval {
178 signed char sc; /* Explicitely signed because compilers are stupid */
194 void *pp_xmalloc(size_t);
195 void *pp_xrealloc(void *, size_t);
196 char *pp_xstrdup(const char *str);
197 pp_entry_t *pplookup(char *ident);
198 pp_entry_t *pp_add_define(char *def, char *text);
199 pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
200 void pp_del_define(char *name);
201 FILE *pp_open_include(const char *name, int search, char **newpath);
202 void pp_push_if(pp_if_state_t s);
203 void pp_next_if_state(int);
204 pp_if_state_t pp_pop_if(void);
205 pp_if_state_t pp_if_state(void);
206 int pp_get_if_depth(void);
209 #define __attribute__(x) /*nothing*/
212 int pperror(const char *s, ...) __attribute__((format (printf, 1, 2)));
213 int ppwarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
214 void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
216 /* current preprocessor state */
217 /* everything is in this structure to avoid polluting the global symbol space */
220 const char *input; /* current input file name */
221 int line_number; /* current line number */
222 int char_number; /* current char number in line */
223 int pedantic; /* pedantic option */
224 int debug; /* debug messages flag */
227 extern struct pp_status pp_status;
228 extern include_state_t pp_incl_state;
229 extern includelogicentry_t *pp_includelogiclist;
237 extern int pp_flex_debug;
240 void pp_do_include(char *fname, int type);
241 void pp_push_ignore_state(void);
242 void pp_pop_ignore_state(void);
251 #endif /* __WINE_WPP_PRIVATE_H */