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 __WPP_PRIVATE_H
21 #define __WPP_PRIVATE_H
28 /* Return value == 0 means successful execution */
29 extern int wpp_add_define( const char *name
, const char *value
);
30 extern void wpp_del_define( const char *name
);
31 extern char *wpp_lookup(const char *filename
, int type
, const char *parent_name
);
32 extern void *wpp_open(const char *filename
, int type
);
33 extern void wpp_close(void *file
);
34 extern int wpp_read(void *file
, char *buffer
, unsigned int len
);
35 extern void wpp_write(const char *buffer
, unsigned int len
);
36 extern int wpp_parse( const char *input
, FILE *output
);
38 struct pp_entry
; /* forward */
41 * A stack of files which are already included and
42 * are protected in the #ifndef/#endif way.
44 typedef struct includelogicentry
{
45 struct includelogicentry
*next
;
46 struct includelogicentry
*prev
;
47 struct pp_entry
*ppp
; /* The define which protects the file */
48 char *filename
; /* The filename of the include */
49 } includelogicentry_t
;
52 * The arguments of a macrodefinition
60 def_arg_t type
; /* Normal or ... argument */
61 char *arg
; /* The textual argument */
62 int nnl
; /* Number of newlines in the text to subst */
66 * The expansiontext of a macro
69 exp_text
, /* Simple text substitution */
70 exp_concat
, /* Concat (##) operator requested */
71 exp_stringize
, /* Stringize (#) operator requested */
72 exp_subst
/* Substitute argument */
75 typedef struct mtext
{
81 int argidx
; /* For exp_subst and exp_stringize reference */
86 * The define descriptor
89 def_none
, /* Not-a-define; used as return value */
90 def_define
, /* Simple defines */
91 def_macro
, /* Macro defines */
92 def_special
/* Special expansions like __LINE__ and __FILE__ */
95 typedef struct pp_entry
{
96 struct pp_entry
*next
;
97 struct pp_entry
*prev
;
98 def_type_t type
; /* Define or macro */
99 char *ident
; /* The key */
100 marg_t
**margs
; /* Macro arguments array or NULL if none */
103 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
106 int expanding
; /* Set when feeding substitution into the input */
107 char *filename
; /* Filename where it was defined */
108 int linenumber
; /* Linenumber where it was defined */
109 includelogicentry_t
*iep
; /* Points to the include it protects */
116 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
130 * Trace the include files to prevent double reading.
131 * This save 20..30% of processing time for most stuff
132 * that uses complex includes.
134 * -1 Don't track or seen junk
135 * 0 New include, waiting for "#ifndef __xxx_h"
136 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
137 * 2 Seen #endif, waiting for EOF
142 char *ppp
; /* The define to be set from the #ifndef */
143 int ifdepth
; /* The level of ifs at the #ifdef */
144 int seen_junk
; /* Set when junk is seen */
151 #define SIZE_LONGLONG 5
152 #define SIZE_MASK 0x00ff
153 #define FLAG_SIGNED 0x0100
157 cv_schar
= SIZE_CHAR
+ FLAG_SIGNED
,
158 cv_uchar
= SIZE_CHAR
,
159 cv_sshort
= SIZE_SHORT
+ FLAG_SIGNED
,
160 cv_ushort
= SIZE_SHORT
,
162 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
164 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
165 cv_ulong
= SIZE_LONG
,
166 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
167 cv_ull
= SIZE_LONGLONG
170 typedef struct cval
{
174 signed char sc
; /* Explicitly signed because compilers are stupid */
184 unsigned __int64 ull
;
190 void *pp_xmalloc(size_t);
191 void *pp_xrealloc(void *, size_t);
192 char *pp_xstrdup(const char *str
);
193 pp_entry_t
*pplookup(const char *ident
);
194 int pp_push_define_state(void);
195 void pp_pop_define_state(void);
196 pp_entry_t
*pp_add_define(const char *def
, const char *text
);
197 pp_entry_t
*pp_add_macro(char *ident
, marg_t
*args
[], int nargs
, mtext_t
*exp
);
198 void pp_del_define(const char *name
);
199 void *pp_open_include(const char *name
, int type
, const char *parent_name
, char **newpath
);
200 void pp_push_if(pp_if_state_t s
);
201 void pp_next_if_state(int);
202 pp_if_state_t
pp_pop_if(void);
203 pp_if_state_t
pp_if_state(void);
204 int pp_get_if_depth(void);
207 #define __attribute__(x) /*nothing*/
210 extern const struct wpp_callbacks
*wpp_callbacks
;
212 int WINAPIV
ppy_error(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
213 int WINAPIV
ppy_warning(const char *s
, ...) __attribute__((format (printf
, 1, 2)));
214 void WINAPIV
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 char *input
; /* current input file name */
221 void *file
; /* current input file descriptor */
222 int line_number
; /* current line number */
223 int char_number
; /* current char number in line */
224 int state
; /* current error state */
225 int pedantic
; /* pedantic option */
228 extern struct pp_status pp_status
;
229 extern include_state_t pp_incl_state
;
230 extern includelogicentry_t
*pp_includelogiclist
;
235 extern FILE *ppy_out
;
236 extern char *ppy_text
;
239 void pp_do_include(char *fname
, int type
);
240 void pp_push_ignore_state(void);
241 void pp_pop_ignore_state(void);
243 void WINAPIV
pp_writestring(const char *format
, ...) __attribute__((format (printf
, 1, 2)));
250 #endif /* __WPP_PRIVATE_H */