gdi32: PATH_ExtTextOut remove incorrect shift to DC origin.
[wine/hacks.git] / libs / wpp / wpp_private.h
blob24ed6b844b5543a01ec87c5f6721d1d6337f1c3a
1 /*
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
23 #ifndef __WINE_CONFIG_H
24 # error You must include config.h to use this header
25 #endif
27 #include <stdio.h>
28 #include <string.h>
30 struct pp_entry; /* forward */
32 * Include logic
33 * A stack of files which are already included and
34 * are protected in the #ifndef/#endif way.
36 typedef 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 */
41 } includelogicentry_t;
44 * The arguments of a macrodefinition
46 typedef enum {
47 arg_single,
48 arg_list
49 } def_arg_t;
51 typedef 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 */
55 } marg_t;
58 * The expansiontext of a macro
60 typedef enum {
61 exp_text, /* Simple text substitution */
62 exp_concat, /* Concat (##) operator requested */
63 exp_stringize, /* Stringize (#) operator requested */
64 exp_subst /* Substitute argument */
65 } def_exp_t;
67 typedef struct mtext {
68 struct mtext *next;
69 struct mtext *prev;
70 def_exp_t type;
71 union {
72 char *text;
73 int argidx; /* For exp_subst and exp_stringize reference */
74 } subst;
75 } mtext_t;
78 * The define descriptor
80 typedef 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__ */
85 } def_type_t;
87 typedef 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;
97 } subst;
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 */
102 } pp_entry_t;
106 * If logic
108 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
110 typedef enum {
111 if_false,
112 if_true,
113 if_elif,
114 if_elsefalse,
115 if_elsetrue,
116 if_ignore
117 } pp_if_state_t;
121 * Trace the include files to prevent double reading.
122 * This save 20..30% of processing time for most stuff
123 * that uses complex includes.
124 * States:
125 * -1 Don't track or seen junk
126 * 0 New include, waiting for "#ifndef __xxx_h"
127 * 1 Seen #ifndef, waiting for "#define __xxx_h ..."
128 * 2 Seen #endif, waiting for EOF
130 typedef struct
132 int state;
133 char *ppp; /* The define to be set from the #ifndef */
134 int ifdepth; /* The level of ifs at the #ifdef */
135 int seen_junk; /* Set when junk is seen */
136 } include_state_t;
140 * If the configure says we have long long then we can use it. Presumably
141 * if we have long long then we have strtoull and strtoll too. If that is
142 * not the case we will need to add to the configure tests.
143 * If we do not have long long , then we revert to a simple 'long' for now.
144 * This should prevent most unexpected things with other compilers than
145 * gcc and egcs for now.
146 * In the future it should be possible to use another way, like a
147 * structure, so that we can emulate the MS compiler.
149 #ifdef HAVE_LONG_LONG
150 typedef long long wrc_sll_t;
151 typedef unsigned long long wrc_ull_t;
152 #else
153 typedef long wrc_sll_t;
154 typedef unsigned long wrc_ull_t;
155 #endif
157 #define SIZE_CHAR 1
158 #define SIZE_SHORT 2
159 #define SIZE_INT 3
160 #define SIZE_LONG 4
161 #define SIZE_LONGLONG 5
162 #define SIZE_MASK 0x00ff
163 #define FLAG_SIGNED 0x0100
165 typedef enum {
166 #if 0
167 cv_schar = SIZE_CHAR + FLAG_SIGNED,
168 cv_uchar = SIZE_CHAR,
169 cv_sshort = SIZE_SHORT + FLAG_SIGNED,
170 cv_ushort = SIZE_SHORT,
171 #endif
172 cv_sint = SIZE_INT + FLAG_SIGNED,
173 cv_uint = SIZE_INT,
174 cv_slong = SIZE_LONG + FLAG_SIGNED,
175 cv_ulong = SIZE_LONG,
176 cv_sll = SIZE_LONGLONG + FLAG_SIGNED,
177 cv_ull = SIZE_LONGLONG
178 } ctype_t;
180 typedef struct cval {
181 ctype_t type;
182 union {
183 #if 0
184 signed char sc; /* Explicitly signed because compilers are stupid */
185 unsigned char uc;
186 short ss;
187 unsigned short us;
188 #endif
189 int si;
190 unsigned int ui;
191 long sl;
192 unsigned long ul;
193 wrc_sll_t sll;
194 wrc_ull_t ull;
195 } val;
196 } cval_t;
200 void *pp_xmalloc(size_t);
201 void *pp_xrealloc(void *, size_t);
202 char *pp_xstrdup(const char *str);
203 pp_entry_t *pplookup(const char *ident);
204 void pp_push_define_state(void);
205 void pp_pop_define_state(void);
206 pp_entry_t *pp_add_define(char *def, char *text);
207 pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
208 void pp_del_define(const char *name);
209 FILE *pp_open_include(const char *name, const char *parent_name, char **newpath);
210 void pp_push_if(pp_if_state_t s);
211 void pp_next_if_state(int);
212 pp_if_state_t pp_pop_if(void);
213 pp_if_state_t pp_if_state(void);
214 int pp_get_if_depth(void);
216 #ifndef __GNUC__
217 #define __attribute__(x) /*nothing*/
218 #endif
220 int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
221 int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
222 void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
224 /* current preprocessor state */
225 /* everything is in this structure to avoid polluting the global symbol space */
226 struct pp_status
228 const char *input; /* current input file name */
229 int line_number; /* current line number */
230 int char_number; /* current char number in line */
231 int pedantic; /* pedantic option */
232 int debug; /* debug messages flag */
235 extern struct pp_status pp_status;
236 extern include_state_t pp_incl_state;
237 extern includelogicentry_t *pp_includelogiclist;
240 * From ppl.l
242 extern FILE *ppy_in;
243 extern FILE *ppy_out;
244 extern char *ppy_text;
245 extern int pp_flex_debug;
246 int ppy_lex(void);
248 void pp_do_include(char *fname, int type);
249 void pp_push_ignore_state(void);
250 void pp_pop_ignore_state(void);
254 * From ppy.y
256 int ppy_parse(void);
257 extern int ppy_debug;
259 #endif /* __WINE_WPP_PRIVATE_H */