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 */
85 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
88 int expanding
; /* Set when feeding substitution into the input */
89 char *filename
; /* Filename where it was defined */
90 int linenumber
; /* Linenumber where it was defined */
91 includelogicentry_t
*iep
; /* Points to the include it protects */
98 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
112 * Trace the include files to prevent double reading.
113 * This save 20..30% of processing time for most stuff
114 * that uses complex includes.
116 * -1 Don't track or seen junk
117 * 0 New include, waiting for "#ifndef __xxx_h"
118 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
119 * 2 Seen #endif, waiting for EOF
124 char *ppp
; /* The define to be set from the #ifndef */
125 int ifdepth
; /* The level of ifs at the #ifdef */
126 int seen_junk
; /* Set when junk is seen */
131 #define SIZE_LONGLONG 3
132 #define SIZE_MASK 0x00ff
133 #define FLAG_SIGNED 0x0100
136 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
138 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
139 cv_ulong
= SIZE_LONG
,
140 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
141 cv_ull
= SIZE_LONGLONG
144 typedef struct cval
{
152 unsigned __int64 ull
;
158 pp_entry_t
*pplookup(const char *ident
);
159 pp_entry_t
*pp_add_define(const char *def
, const char *text
);
160 pp_entry_t
*pp_add_macro(char *ident
, char *args
[], int nargs
, int variadic
, mtext_t
*exp
);
161 void pp_del_define(const char *name
);
162 void *pp_open_include(const char *name
, int type
, const char *parent_name
, char **newpath
);
163 void pp_push_if(pp_if_state_t s
);
164 void pp_next_if_state(int);
165 pp_if_state_t
pp_pop_if(void);
166 pp_if_state_t
pp_if_state(void);
167 int pp_get_if_depth(void);
169 int ppy_error(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
170 int ppy_warning(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
172 /* current preprocessor state */
173 /* everything is in this structure to avoid polluting the global symbol space */
176 char *input
; /* current input file name */
177 FILE *file
; /* current input file descriptor */
178 int line_number
; /* current line number */
179 int char_number
; /* current char number in line */
180 int debug
; /* debug messages flag */
183 extern struct pp_status pp_status
;
184 extern include_state_t pp_incl_state
;
191 extern FILE *ppy_out
;
192 extern char *ppy_text
;
193 extern int pp_flex_debug
;
196 void pp_do_include(char *fname
, int type
);
197 void pp_push_ignore_state(void);
198 void pp_pop_ignore_state(void);
204 extern int ppy_debug
;
206 #endif /* __WINE_WPP_PRIVATE_H */