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
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... */
118 * Trace the include files to prevent double reading.
119 * This save 20..30% of processing time for most stuff
120 * that uses complex includes.
122 * -1 Don't track or seen junk
123 * 0 New include, waiting for "#ifndef __xxx_h"
124 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
125 * 2 Seen #endif, waiting for EOF
130 char *ppp
; /* The define to be set from the #ifndef */
131 int ifdepth
; /* The level of ifs at the #ifdef */
132 int seen_junk
; /* Set when junk is seen */
139 #define SIZE_LONGLONG 5
140 #define SIZE_MASK 0x00ff
141 #define FLAG_SIGNED 0x0100
145 cv_schar
= SIZE_CHAR
+ FLAG_SIGNED
,
146 cv_uchar
= SIZE_CHAR
,
147 cv_sshort
= SIZE_SHORT
+ FLAG_SIGNED
,
148 cv_ushort
= SIZE_SHORT
,
150 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
152 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
153 cv_ulong
= SIZE_LONG
,
154 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
155 cv_ull
= SIZE_LONGLONG
158 typedef struct cval
{
162 signed char sc
; /* Explicitly signed because compilers are stupid */
172 unsigned __int64 ull
;
178 void *pp_xmalloc(size_t);
179 void *pp_xrealloc(void *, size_t);
180 char *pp_xstrdup(const char *str
);
181 pp_entry_t
*pplookup(const char *ident
);
182 int pp_push_define_state(void);
183 void pp_pop_define_state(void);
184 pp_entry_t
*pp_add_define(const char *def
, const char *text
);
185 pp_entry_t
*pp_add_macro(char *ident
, marg_t
*args
[], int nargs
, mtext_t
*exp
);
186 void pp_del_define(const char *name
);
187 void *pp_open_include(const char *name
, int type
, const char *parent_name
, char **newpath
);
188 void pp_push_if(pp_if_state_t s
);
189 void pp_next_if_state(int);
190 pp_if_state_t
pp_pop_if(void);
191 pp_if_state_t
pp_if_state(void);
192 int pp_get_if_depth(void);
195 #define __attribute__(x) /*nothing*/
198 extern const struct wpp_callbacks
*wpp_callbacks
;
200 int ppy_error(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
201 int ppy_warning(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
202 void pp_internal_error(const char *file
, int line
, const char *s
, ...) __attribute__((format (printf
, 3, 4)));
204 /* current preprocessor state */
205 /* everything is in this structure to avoid polluting the global symbol space */
208 char *input
; /* current input file name */
209 void *file
; /* current input file descriptor */
210 int line_number
; /* current line number */
211 int char_number
; /* current char number in line */
212 int state
; /* current error state */
213 int pedantic
; /* pedantic option */
214 int debug
; /* debug messages flag */
217 extern struct pp_status pp_status
;
218 extern include_state_t pp_incl_state
;
219 extern includelogicentry_t
*pp_includelogiclist
;
225 extern FILE *ppy_out
;
226 extern char *ppy_text
;
227 extern int pp_flex_debug
;
230 void pp_do_include(char *fname
, int type
);
231 void pp_push_ignore_state(void);
232 void pp_pop_ignore_state(void);
234 void pp_writestring(const char *format
, ...) __attribute__((format (printf
, 1, 2)));
240 extern int ppy_debug
;
242 #endif /* __WINE_WPP_PRIVATE_H */