ReactOS 0.4.16-dev-1946-g52006dd
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#include <stdio.h>
24#include <string.h>
25#include "wine/list.h"
26
27extern void wpp_del_define( const char *name );
28extern void wpp_add_cmdline_define( const char *value );
29extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug );
30extern void wpp_add_include_path( const char *path );
31extern char *wpp_find_include( const char *name, const char *parent_name );
32/* Return value == 0 means successful execution */
33extern int wpp_parse( const char *input, FILE *output );
34
35struct pp_entry; /* forward */
36/*
37 * Include logic
38 * A stack of files which are already included and
39 * are protected in the #ifndef/#endif way.
40 */
41typedef struct includelogicentry {
42 struct list entry;
43 struct pp_entry *ppp; /* The define which protects the file */
44 char *filename; /* The filename of the include */
46
47/*
48 * The expansiontext of a macro
49 */
50typedef enum {
51 exp_text, /* Simple text substitution */
52 exp_concat, /* Concat (##) operator requested */
53 exp_stringize, /* Stringize (#) operator requested */
54 exp_subst /* Substitute argument */
56
57typedef struct mtext {
58 struct mtext *next;
59 struct mtext *prev;
61 union {
62 char *text;
63 int argidx; /* For exp_subst and exp_stringize reference */
66
67/*
68 * The define descriptor
69 */
70typedef enum {
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__ */
76
77typedef struct pp_entry {
78 struct list entry;
79 def_type_t type; /* Define or macro */
80 char *ident; /* The key */
81 char **margs; /* Macro arguments array or NULL if none */
82 int nargs;
84 union {
85 mtext_t *mtext; /* The substitution sequence or NULL if none */
86 char *text;
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 */
93
94
95/*
96 * If logic
97 */
98#define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
99
100typedef enum {
109
110
111/*
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.
115 * States:
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
120 */
121typedef struct
122{
123 int state;
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 */
128
129#define SIZE_INT 1
130#define SIZE_LONG 2
131#define SIZE_LONGLONG 3
132#define SIZE_MASK 0x00ff
133#define FLAG_SIGNED 0x0100
134
135typedef enum {
143
144typedef struct cval {
146 union {
147 int si;
148 unsigned int ui;
149 long sl;
150 unsigned long ul;
151 __int64 sll;
152 unsigned __int64 ull;
155
156
157
158pp_entry_t *pplookup(const char *ident);
159pp_entry_t *pp_add_define(const char *def, const char *text);
160pp_entry_t *pp_add_macro(char *ident, char *args[], int nargs, int variadic, mtext_t *exp);
161void pp_del_define(const char *name);
162void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath);
164void pp_next_if_state(int);
167int pp_get_if_depth(void);
168
169#ifdef __REACTOS__
170#ifndef __GNUC__
171#define __attribute__(x) /*nothing*/
172#endif
173#endif
174
175int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
176int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
177
178/* current preprocessor state */
179/* everything is in this structure to avoid polluting the global symbol space */
181{
182 char *input; /* current input file name */
183 FILE *file; /* current input file descriptor */
184 int line_number; /* current line number */
185 int char_number; /* current char number in line */
186 int debug; /* debug messages flag */
187};
188
189extern struct pp_status pp_status;
191extern int pedantic;
192
193/*
194 * From ppl.l
195 */
196extern FILE *ppy_in;
197extern FILE *ppy_out;
198extern char *ppy_text;
199extern int pp_flex_debug;
200int ppy_lex(void);
201
202void pp_do_include(char *fname, int type);
205
206/*
207 * From ppy.y
208 */
209int ppy_parse(void);
210extern int ppy_debug;
211
212#endif /* __WINE_WPP_PRIVATE_H */
static int state
Definition: maze.c:121
#define __int64
Definition: basetyps.h:16
Definition: list.h:37
int const char const *const int const line_number
Definition: debug_heap.cpp:499
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)
struct pp_entry pp_entry_t
void pp_next_if_state(int)
Definition: preproc.c:414
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
#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)
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)
char * ppy_text
#define SIZE_LONG
Definition: wpp_private.h:150
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
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
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
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
DWORD exp
Definition: msg.c:16058
UINT ui
Definition: oleauto.h:49
int parser_debug
Definition: widl.c:95
int pp_flex_debug
Definition: wpp.c:47
void wpp_add_cmdline_define(const char *value)
Definition: wpp.c:588
void wpp_set_debug(int lex_debug, int parser_debug, int msg_debug)
Definition: wpp.c:601
char * wpp_find_include(const char *name, const char *parent_name)
Definition: wpp.c:315
def_type_t
Definition: wpp_private.h:70
FILE * ppy_in
int ppy_debug
Definition: wpp.c:47
void wpp_add_include_path(const char *path)
Definition: wpp.c:298
int pedantic
Definition: widl.c:97
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
long sl
Definition: wpp_private.h:181
Definition: format.c:58
struct pp_entry * ppp
Definition: wpp_private.h:47
struct list entry
Definition: wpp_private.h:42
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::@275 subst
struct mtext * next
Definition: wpp_private.h:76
Definition: name.c:39
Definition: wpp_private.h:95
int variadic
Definition: wpp_private.h:83
int linenumber
Definition: wpp_private.h:108
struct list entry
Definition: wpp_private.h:78
int nargs
Definition: wpp_private.h:101
includelogicentry_t * iep
Definition: wpp_private.h:109
union pp_entry::@276 subst
char * filename
Definition: wpp_private.h:107
def_type_t type
Definition: wpp_private.h:98
int expanding
Definition: wpp_private.h:106
char * ident
Definition: wpp_private.h:99
char ** margs
Definition: wpp_private.h:81
FILE * file
Definition: wpp_private.h:183
Definition: pdh_main.c:96
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994
#define const
Definition: zconf.h:233