ReactOS 0.4.16-dev-125-g798ea90
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 __WINE_WPP_PRIVATE_H
21#define __WINE_WPP_PRIVATE_H
22
23#ifndef __WINE_CONFIG_H
24# error You must include config.h to use this header
25#endif
26
27#include <stdio.h>
28#include <string.h>
29
30struct pp_entry; /* forward */
31/*
32 * Include logic
33 * A stack of files which are already included and
34 * are protected in the #ifndef/#endif way.
35 */
36typedef struct includelogicentry {
37 struct includelogicentry *next;
38 struct includelogicentry *prev;
39 struct pp_entry *ppp; /* The define which protects the file */
40 char *filename; /* The filename of the include */
42
43/*
44 * The arguments of a macrodefinition
45 */
46typedef enum {
50
51typedef struct marg {
52 def_arg_t type; /* Normal or ... argument */
53 char *arg; /* The textual argument */
54 int nnl; /* Number of newlines in the text to subst */
56
57/*
58 * The expansiontext of a macro
59 */
60typedef enum {
61 exp_text, /* Simple text substitution */
62 exp_concat, /* Concat (##) operator requested */
63 exp_stringize, /* Stringize (#) operator requested */
64 exp_subst /* Substitute argument */
66
67typedef struct mtext {
68 struct mtext *next;
69 struct mtext *prev;
71 union {
72 char *text;
73 int argidx; /* For exp_subst and exp_stringize reference */
76
77/*
78 * The define descriptor
79 */
80typedef enum {
81 def_none, /* Not-a-define; used as return value */
82 def_define, /* Simple defines */
83 def_macro, /* Macro defines */
84 def_special /* Special expansions like __LINE__ and __FILE__ */
86
87typedef struct pp_entry {
88 struct pp_entry *next;
89 struct pp_entry *prev;
90 def_type_t type; /* Define or macro */
91 char *ident; /* The key */
92 marg_t **margs; /* Macro arguments array or NULL if none */
93 int nargs;
94 union {
95 mtext_t *mtext; /* The substitution sequence or NULL if none */
96 char *text;
98 int expanding; /* Set when feeding substitution into the input */
99 char *filename; /* Filename where it was defined */
100 int linenumber; /* Linenumber where it was defined */
101 includelogicentry_t *iep; /* Points to the include it protects */
103
104
105/*
106 * If logic
107 */
108#define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
109
110typedef enum {
119
120
121/*
122 * Trace the include files to prevent double reading.
123 * This save 20..30% of processing time for most stuff
124 * that uses complex includes.
125 * States:
126 * -1 Don't track or seen junk
127 * 0 New include, waiting for "#ifndef __xxx_h"
128 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
129 * 2 Seen #endif, waiting for EOF
130 */
131typedef struct
132{
133 int state;
134 char *ppp; /* The define to be set from the #ifndef */
135 int ifdepth; /* The level of ifs at the #ifdef */
136 int seen_junk; /* Set when junk is seen */
138
139
140/*
141 * If the configure says we have long long then we can use it. Presumably
142 * if we have long long then we have strtoull and strtoll too. If that is
143 * not the case we will need to add to the configure tests.
144 * If we do not have long long , then we revert to a simple 'long' for now.
145 * This should prevent most unexpected things with other compilers than
146 * gcc and egcs for now.
147 * In the future it should be possible to use another way, like a
148 * structure, so that we can emulate the MS compiler.
149 */
150#ifdef HAVE_LONG_LONG
151typedef long long wrc_sll_t;
152typedef unsigned long long wrc_ull_t;
153#else
154typedef long wrc_sll_t;
155typedef unsigned long wrc_ull_t;
156#endif
157
158#define SIZE_CHAR 1
159#define SIZE_SHORT 2
160#define SIZE_INT 3
161#define SIZE_LONG 4
162#define SIZE_LONGLONG 5
163#define SIZE_MASK 0x00ff
164#define FLAG_SIGNED 0x0100
165
166typedef enum {
167#if 0
168 cv_schar = SIZE_CHAR + FLAG_SIGNED,
169 cv_uchar = SIZE_CHAR,
170 cv_sshort = SIZE_SHORT + FLAG_SIGNED,
171 cv_ushort = SIZE_SHORT,
172#endif
180
181typedef struct cval {
183 union {
184#if 0
185 signed char sc; /* Explicitly signed because compilers are stupid */
186 unsigned char uc;
187 short ss;
188 unsigned short us;
189#endif
190 int si;
191 unsigned int ui;
192 long sl;
193 unsigned long ul;
198
199
200
201void *pp_xmalloc(size_t);
202void *pp_xrealloc(void *, size_t);
203char *pp_xstrdup(const char *str);
204pp_entry_t *pplookup(const char *ident);
205int pp_push_define_state(void);
206void pp_pop_define_state(void);
207pp_entry_t *pp_add_define(const char *def, const char *text);
208pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
209void pp_del_define(const char *name);
210void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
212void pp_next_if_state(int);
215int pp_get_if_depth(void);
216
217#ifndef __GNUC__
218#define __attribute__(x) /*nothing*/
219#endif
220
221extern const struct wpp_callbacks *wpp_callbacks;
222
223int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
224int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
225void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
226
227/* current preprocessor state */
228/* everything is in this structure to avoid polluting the global symbol space */
230{
231 char *input; /* current input file name */
232 void *file; /* current input file descriptor */
233 int line_number; /* current line number */
234 int char_number; /* current char number in line */
235 int state; /* current error state */
236 int pedantic; /* pedantic option */
237 int debug; /* debug messages flag */
238};
239
240extern struct pp_status pp_status;
243
244/*
245 * From ppl.l
246 */
247extern FILE *ppy_in;
248extern FILE *ppy_out;
249extern char *ppy_text;
250extern int pp_flex_debug;
251int ppy_lex(void);
252
253void pp_do_include(char *fname, int type);
256
257void pp_writestring(const char *format, ...) __attribute__((format (printf, 1, 2)));
258
259/*
260 * From ppy.y
261 */
262int ppy_parse(void);
263extern int ppy_debug;
264
265#endif /* __WINE_WPP_PRIVATE_H */
static int state
Definition: maze.c:121
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 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 * 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
#define SIZE_LONGLONG
Definition: wpp_private.h:151
void pp_do_include(char *fname, int type)
#define SIZE_INT
Definition: wpp_private.h:149
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
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
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 GLfloat * val
Definition: glext.h:7180
GLenum GLenum GLenum input
Definition: glext.h:9031
#define ss
Definition: i386-dis.c:441
static const BYTE us[]
Definition: encode.c:689
DWORD exp
Definition: msg.c:16058
UINT ui
Definition: oleauto.h:49
const WCHAR * str
static long line_number
Definition: main.cpp:17
int pp_flex_debug
Definition: wpp.c:31
long wrc_sll_t
Definition: wpp_private.h:154
FILE * ppy_in
unsigned long wrc_ull_t
Definition: wpp_private.h:155
int ppy_debug
Definition: wpp.c:31
Definition: match.c:390
wrc_ull_t ull
Definition: wpp_private.h:195
int si
Definition: wpp_private.h:179
unsigned long ul
Definition: wpp_private.h:182
wrc_sll_t sll
Definition: wpp_private.h:194
long sl
Definition: wpp_private.h:181
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: widl.c:113
int char_number
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define const
Definition: zconf.h:233