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
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 */
38 * A stack of files which are already included and
39 * are protected in the #ifndef/#endif way.
41 typedef struct includelogicentry
{
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
51 exp_text
, /* Simple text substitution */
52 exp_concat
, /* Concat (##) operator requested */
53 exp_stringize
, /* Stringize (#) operator requested */
54 exp_subst
/* Substitute argument */
57 typedef struct mtext
{
63 int argidx
; /* For exp_subst and exp_stringize reference */
68 * The define descriptor
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__ */
77 typedef struct pp_entry
{
79 def_type_t type
; /* Define or macro */
80 char *ident
; /* The key */
81 char **margs
; /* Macro arguments array or NULL if none */
84 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
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 */
97 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
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.
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
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 */
130 #define SIZE_LONGLONG 3
131 #define SIZE_MASK 0x00ff
132 #define FLAG_SIGNED 0x0100
135 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
137 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
138 cv_ulong
= SIZE_LONG
,
139 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
140 cv_ull
= SIZE_LONGLONG
143 typedef struct cval
{
151 unsigned __int64 ull
;
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 */
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
;
190 extern FILE *ppy_out
;
191 extern char *ppy_text
;
192 extern int pp_flex_debug
;
195 void pp_do_include(char *fname
, int type
);
196 void pp_push_ignore_state(void);
197 void pp_pop_ignore_state(void);
203 extern int ppy_debug
;
205 #endif /* __WINE_WPP_PRIVATE_H */