ReactOS 0.4.16-dev-306-g647d351
wpp_private.h
Go to the documentation of this file.
1/*
2 * Copyright 1998 Bertho A. Stultiens (BS)
3 * Copyright 2002 Alexandre Julliard
4 *
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.
9 *
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.
14 *
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
18 */
19
20#ifndef __WPP_PRIVATE_H
21#define __WPP_PRIVATE_H
22
23#include <stdio.h>
24#include <string.h>
25#include <stdarg.h>
26#include "windef.h"
27
28/* Return value == 0 means successful execution */
29extern int wpp_add_define( const char *name, const char *value );
30extern void wpp_del_define( const char *name );
31extern char *wpp_lookup(const char *filename, int type, const char *parent_name);
32extern void *wpp_open(const char *filename, int type);
33extern void wpp_close(void *file);
34extern int wpp_read(void *file, char *buffer, unsigned int len);
35extern void wpp_write(const char *buffer, unsigned int len);
36extern int wpp_parse( const char *input, FILE *output );
37
38struct pp_entry; /* forward */
39/*
40 * Include logic
41 * A stack of files which are already included and
42 * are protected in the #ifndef/#endif way.
43 */
44typedef struct includelogicentry {
47 struct pp_entry *ppp; /* The define which protects the file */
48 char *filename; /* The filename of the include */
50
51/*
52 * The arguments of a macrodefinition
53 */
54typedef enum {
58
59typedef struct marg {
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 */
64
65/*
66 * The expansiontext of a macro
67 */
68typedef enum {
69 exp_text, /* Simple text substitution */
70 exp_concat, /* Concat (##) operator requested */
71 exp_stringize, /* Stringize (#) operator requested */
72 exp_subst /* Substitute argument */
74
75typedef struct mtext {
76 struct mtext *next;
77 struct mtext *prev;
79 union {
80 char *text;
81 int argidx; /* For exp_subst and exp_stringize reference */
84
85/*
86 * The define descriptor
87 */
88typedef enum {
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__ */
94
95typedef 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 */
101 int nargs;
102 union {
103 mtext_t *mtext; /* The substitution sequence or NULL if none */
104 char *text;
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 */
111
112
113/*
114 * If logic
115 */
116#define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
117
118typedef enum {
127
128
129/*
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.
133 * States:
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
138 */
139typedef struct
140{
141 int state;
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 */
146
147#define SIZE_CHAR 1
148#define SIZE_SHORT 2
149#define SIZE_INT 3
150#define SIZE_LONG 4
151#define SIZE_LONGLONG 5
152#define SIZE_MASK 0x00ff
153#define FLAG_SIGNED 0x0100
154
155typedef enum {
156#if 0
157 cv_schar = SIZE_CHAR + FLAG_SIGNED,
158 cv_uchar = SIZE_CHAR,
159 cv_sshort = SIZE_SHORT + FLAG_SIGNED,
160 cv_ushort = SIZE_SHORT,
161#endif
169
170typedef struct cval {
172 union {
173#if 0
174 signed char sc; /* Explicitly signed because compilers are stupid */
175 unsigned char uc;
176 short ss;
177 unsigned short us;
178#endif
179 int si;
180 unsigned int ui;
181 long sl;
182 unsigned long ul;
184 unsigned __int64 ull;
187
188
189
190void *pp_xmalloc(size_t);
191void *pp_xrealloc(void *, size_t);
192char *pp_xstrdup(const char *str);
193pp_entry_t *pplookup(const char *ident);
194int pp_push_define_state(void);
195void pp_pop_define_state(void);
196pp_entry_t *pp_add_define(const char *def, const char *text);
197pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
198void pp_del_define(const char *name);
199void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
201void pp_next_if_state(int);
204int pp_get_if_depth(void);
205
206#ifndef __GNUC__
207#define __attribute__(x) /*nothing*/
208#endif
209
210extern const struct wpp_callbacks *wpp_callbacks;
211
212int WINAPIV ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
214void WINAPIV pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
215
216/* current preprocessor state */
217/* everything is in this structure to avoid polluting the global symbol space */
219{
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 */
226};
227
228extern struct pp_status pp_status;
231
232/*
233 * From ppl.l
234 */
235extern FILE *ppy_out;
236extern char *ppy_text;
237int ppy_lex(void);
238
239void pp_do_include(char *fname, int type);
242
243void WINAPIV pp_writestring(const char *format, ...) __attribute__((format (printf, 1, 2)));
244
245/*
246 * From ppy.y
247 */
248int ppy_parse(void);
249
250#endif /* __WPP_PRIVATE_H */
#define __int64
Definition: basetyps.h:16
void * pp_xmalloc(size_t)
Definition: preproc.c:45
struct mtext mtext_t
pp_entry_t * pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp)
Definition: preproc.c:252
void * wpp_open(const char *filename, int type)
Definition: compiler.c:195
void pp_push_ignore_state(void)
#define SIZE_SHORT
Definition: wpp_private.h:148
struct pp_entry pp_entry_t
struct marg marg_t
void pp_next_if_state(int)
Definition: preproc.c:414
void wpp_write(const char *buffer, unsigned int len)
Definition: compiler.c:284
void * pp_xrealloc(void *, size_t)
Definition: preproc.c:59
pp_entry_t * pp_add_define(const char *def, const char *text)
Definition: preproc.c:194
pp_if_state_t pp_if_state(void)
Definition: preproc.c:405
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
#define FLAG_SIGNED
Definition: wpp_private.h:153
pp_if_state_t
Definition: wpp_private.h:118
@ if_true
Definition: wpp_private.h:120
@ if_elif
Definition: wpp_private.h:121
@ if_elsefalse
Definition: wpp_private.h:122
@ if_elsetrue
Definition: wpp_private.h:123
@ if_error
Definition: wpp_private.h:125
@ if_false
Definition: wpp_private.h:119
@ if_ignore
Definition: wpp_private.h:124
int pp_get_if_depth(void)
Definition: preproc.c:433
void pp_pop_ignore_state(void)
int WINAPIV int WINAPIV ppy_warning(const char *s,...) __attribute__((format(printf
void * pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
Definition: preproc.c:290
struct includelogicentry includelogicentry_t
int wpp_add_define(const char *name, const char *value)
Definition: compiler.c:377
void wpp_close(void *file)
Definition: compiler.c:258
#define SIZE_LONGLONG
Definition: wpp_private.h:151
void pp_do_include(char *fname, int type)
void wpp_del_define(const char *name)
Definition: compiler.c:420
#define SIZE_INT
Definition: wpp_private.h:149
int wpp_parse(const char *input, FILE *output)
Definition: compiler.c:437
void WINAPIV int ppy_parse(void)
int pp_push_define_state(void)
Definition: preproc.c:148
char * ppy_text
const struct wpp_callbacks * wpp_callbacks
Definition: preproc.c:733
#define SIZE_LONG
Definition: wpp_private.h:150
int WINAPIV int WINAPIV void WINAPIV pp_internal_error(const char *file, int line, const char *s,...) __attribute__((format(printf
def_arg_t
Definition: wpp_private.h:54
@ arg_single
Definition: wpp_private.h:55
@ arg_list
Definition: wpp_private.h:56
void pp_push_if(pp_if_state_t s)
Definition: preproc.c:357
ctype_t
Definition: wpp_private.h:155
@ cv_sint
Definition: wpp_private.h:162
@ cv_uint
Definition: wpp_private.h:163
@ cv_ulong
Definition: wpp_private.h:165
@ cv_sll
Definition: wpp_private.h:166
@ cv_slong
Definition: wpp_private.h:164
@ cv_ull
Definition: wpp_private.h:167
int wpp_read(void *file, char *buffer, unsigned int len)
Definition: compiler.c:274
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:95
FILE * ppy_out
void pp_pop_define_state(void)
Definition: preproc.c:161
def_exp_t
Definition: wpp_private.h:68
@ exp_stringize
Definition: wpp_private.h:71
@ exp_text
Definition: wpp_private.h:69
@ exp_subst
Definition: wpp_private.h:72
@ exp_concat
Definition: wpp_private.h:70
includelogicentry_t * pp_includelogiclist
struct cval cval_t
char * wpp_lookup(const char *filename, int type, const char *parent_name)
Definition: compiler.c:162
int WINAPIV ppy_error(const char *s,...) __attribute__((format(printf
def_type_t
Definition: wpp_private.h:88
@ def_none
Definition: wpp_private.h:89
@ def_define
Definition: wpp_private.h:90
@ def_macro
Definition: wpp_private.h:91
@ def_special
Definition: wpp_private.h:92
include_state_t pp_incl_state
pp_if_state_t pp_pop_if(void)
Definition: preproc.c:380
void WINAPIV pp_writestring(const char *format,...) __attribute__((format(printf
#define SIZE_CHAR
Definition: wpp_private.h:147
int ppy_lex(void)
void pp_del_define(const char *name)
Definition: preproc.c:176
const WCHAR * text
Definition: package.c:1794
#define printf
Definition: freeldr.h:97
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
GLenum GLenum GLenum input
Definition: glext.h:9031
#define ss
Definition: i386-dis.c:441
const char * filename
Definition: ioapi.h:137
static const BYTE us[]
Definition: encode.c:689
DWORD exp
Definition: msg.c:16058
const WCHAR * str
#define WINAPIV
Definition: sdbpapi.h:64
def_arg_t
Definition: wpp_private.h:46
ctype_t
Definition: wpp_private.h:166
def_exp_t
Definition: wpp_private.h:60
def_type_t
Definition: wpp_private.h:80
Definition: match.c:390
int si
Definition: wpp_private.h:179
__int64 sll
Definition: wpp_private.h:183
unsigned long ul
Definition: wpp_private.h:182
unsigned __int64 ull
Definition: wpp_private.h:184
unsigned int ui
Definition: wpp_private.h:180
long sl
Definition: wpp_private.h:181
ctype_t type
Definition: wpp_private.h:171
Definition: fci.c:127
Definition: format.c:58
struct pp_entry * ppp
Definition: wpp_private.h:47
struct includelogicentry * next
Definition: wpp_private.h:45
struct includelogicentry * prev
Definition: wpp_private.h:46
Definition: parser.c:49
char * arg
Definition: wpp_private.h:61
int nnl
Definition: wpp_private.h:62
def_arg_t type
Definition: wpp_private.h:60
char * text
Definition: wpp_private.h:80
struct mtext * prev
Definition: wpp_private.h:77
int argidx
Definition: wpp_private.h:81
def_exp_t type
Definition: wpp_private.h:78
union mtext::@239 subst
struct mtext * next
Definition: wpp_private.h:76
Definition: name.c:39
Definition: wpp_private.h:95
struct pp_entry * next
Definition: wpp_private.h:96
mtext_t * mtext
Definition: wpp_private.h:103
int linenumber
Definition: wpp_private.h:108
marg_t ** margs
Definition: wpp_private.h:100
int nargs
Definition: wpp_private.h:101
includelogicentry_t * iep
Definition: wpp_private.h:109
char * text
Definition: wpp_private.h:104
union pp_entry::@240 subst
char * filename
Definition: wpp_private.h:107
def_type_t type
Definition: wpp_private.h:98
struct pp_entry * prev
Definition: wpp_private.h:97
int expanding
Definition: wpp_private.h:106
char * ident
Definition: wpp_private.h:99
int pedantic
Definition: wpp_private.h:225
void * file
Definition: wpp_private.h:221
int char_number
Definition: wpp_private.h:223
char * input
Definition: wpp_private.h:220
int line_number
Definition: wpp_private.h:222
Definition: pdh_main.c:94
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define const
Definition: zconf.h:233