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 struct pp_entry
; /* forward */
30 * A stack of files which are already included and
31 * are protected in the #ifndef/#endif way.
33 typedef struct includelogicentry
{
35 struct pp_entry
*ppp
; /* The define which protects the file */
36 char *filename
; /* The filename of the include */
37 } includelogicentry_t
;
40 * The expansiontext of a macro
43 exp_text
, /* Simple text substitution */
44 exp_concat
, /* Concat (##) operator requested */
45 exp_stringize
, /* Stringize (#) operator requested */
46 exp_subst
/* Substitute argument */
49 typedef struct mtext
{
55 int argidx
; /* For exp_subst and exp_stringize reference */
60 * The define descriptor
63 def_none
, /* Not-a-define; used as return value */
64 def_define
, /* Simple defines */
65 def_macro
, /* Macro defines */
66 def_special
/* Special expansions like __LINE__ and __FILE__ */
69 typedef struct pp_entry
{
71 def_type_t type
; /* Define or macro */
72 char *ident
; /* The key */
73 char **margs
; /* Macro arguments array or NULL if none */
76 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
79 int expanding
; /* Set when feeding substitution into the input */
80 char *filename
; /* Filename where it was defined */
81 int linenumber
; /* Linenumber where it was defined */
82 includelogicentry_t
*iep
; /* Points to the include it protects */
89 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
103 * Trace the include files to prevent double reading.
104 * This save 20..30% of processing time for most stuff
105 * that uses complex includes.
107 * -1 Don't track or seen junk
108 * 0 New include, waiting for "#ifndef __xxx_h"
109 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
110 * 2 Seen #endif, waiting for EOF
115 char *ppp
; /* The define to be set from the #ifndef */
116 int ifdepth
; /* The level of ifs at the #ifdef */
117 int seen_junk
; /* Set when junk is seen */
122 #define SIZE_LONGLONG 3
123 #define SIZE_MASK 0x00ff
124 #define FLAG_SIGNED 0x0100
127 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
129 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
130 cv_ulong
= SIZE_LONG
,
131 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
132 cv_ull
= SIZE_LONGLONG
135 typedef struct cval
{
143 unsigned __int64 ull
;
149 void *pp_xmalloc(size_t);
150 void *pp_xrealloc(void *, size_t);
151 char *pp_xstrdup(const char *str
);
152 pp_entry_t
*pplookup(const char *ident
);
153 void pp_init_define_state(void);
154 void pp_free_define_state(void);
155 pp_entry_t
*pp_add_define(const char *def
, const char *text
);
156 pp_entry_t
*pp_add_macro(char *ident
, char *args
[], int nargs
, mtext_t
*exp
);
157 void pp_del_define(const char *name
);
158 void *pp_open_include(const char *name
, int type
, const char *parent_name
, char **newpath
);
159 void pp_push_if(pp_if_state_t s
);
160 void pp_next_if_state(int);
161 pp_if_state_t
pp_pop_if(void);
162 pp_if_state_t
pp_if_state(void);
163 int pp_get_if_depth(void);
164 char *wpp_lookup(const char *name
, int type
, const char *parent_name
,
165 char **include_path
, int include_path_count
);
168 #define __attribute__(x) /*nothing*/
171 int ppy_error(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
172 int ppy_warning(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
173 void pp_internal_error(const char *file
, int line
, const char *s
, ...) __attribute__((format (printf
, 3, 4)));
175 /* current preprocessor state */
176 /* everything is in this structure to avoid polluting the global symbol space */
179 char *input
; /* current input file name */
180 FILE *file
; /* current input file descriptor */
181 int line_number
; /* current line number */
182 int char_number
; /* current char number in line */
183 int pedantic
; /* pedantic option */
184 int debug
; /* debug messages flag */
187 extern struct pp_status pp_status
;
188 extern include_state_t pp_incl_state
;
189 extern struct list pp_includelogiclist
;
195 extern FILE *ppy_out
;
196 extern char *ppy_text
;
197 extern int pp_flex_debug
;
200 void pp_do_include(char *fname
, int type
);
201 void pp_push_ignore_state(void);
202 void pp_pop_ignore_state(void);
204 void pp_writestring(const char *format
, ...) __attribute__((format (printf
, 1, 2)));
210 extern int ppy_debug
;
212 #endif /* __WINE_WPP_PRIVATE_H */