Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwpp_private.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 1998 Bertho A. Stultiens (BS) 00003 * Copyright 2002 Alexandre Julliard 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00018 */ 00019 00020 #ifndef __WINE_WPP_PRIVATE_H 00021 #define __WINE_WPP_PRIVATE_H 00022 00023 #ifndef __WINE_CONFIG_H 00024 # error You must include config.h to use this header 00025 #endif 00026 00027 #include <stdio.h> 00028 #include <string.h> 00029 00030 struct pp_entry; /* forward */ 00031 /* 00032 * Include logic 00033 * A stack of files which are already included and 00034 * are protected in the #ifndef/#endif way. 00035 */ 00036 typedef struct includelogicentry { 00037 struct includelogicentry *next; 00038 struct includelogicentry *prev; 00039 struct pp_entry *ppp; /* The define which protects the file */ 00040 char *filename; /* The filename of the include */ 00041 } includelogicentry_t; 00042 00043 /* 00044 * The arguments of a macrodefinition 00045 */ 00046 typedef enum { 00047 arg_single, 00048 arg_list 00049 } def_arg_t; 00050 00051 typedef struct marg { 00052 def_arg_t type; /* Normal or ... argument */ 00053 char *arg; /* The textual argument */ 00054 int nnl; /* Number of newlines in the text to subst */ 00055 } marg_t; 00056 00057 /* 00058 * The expansiontext of a macro 00059 */ 00060 typedef enum { 00061 exp_text, /* Simple text substitution */ 00062 exp_concat, /* Concat (##) operator requested */ 00063 exp_stringize, /* Stringize (#) operator requested */ 00064 exp_subst /* Substitute argument */ 00065 } def_exp_t; 00066 00067 typedef struct mtext { 00068 struct mtext *next; 00069 struct mtext *prev; 00070 def_exp_t type; 00071 union { 00072 char *text; 00073 int argidx; /* For exp_subst and exp_stringize reference */ 00074 } subst; 00075 } mtext_t; 00076 00077 /* 00078 * The define descriptor 00079 */ 00080 typedef enum { 00081 def_none, /* Not-a-define; used as return value */ 00082 def_define, /* Simple defines */ 00083 def_macro, /* Macro defines */ 00084 def_special /* Special expansions like __LINE__ and __FILE__ */ 00085 } def_type_t; 00086 00087 typedef struct pp_entry { 00088 struct pp_entry *next; 00089 struct pp_entry *prev; 00090 def_type_t type; /* Define or macro */ 00091 char *ident; /* The key */ 00092 marg_t **margs; /* Macro arguments array or NULL if none */ 00093 int nargs; 00094 union { 00095 mtext_t *mtext; /* The substitution sequence or NULL if none */ 00096 char *text; 00097 } subst; 00098 int expanding; /* Set when feeding substitution into the input */ 00099 char *filename; /* Filename where it was defined */ 00100 int linenumber; /* Linenumber where it was defined */ 00101 includelogicentry_t *iep; /* Points to the include it protects */ 00102 } pp_entry_t; 00103 00104 00105 /* 00106 * If logic 00107 */ 00108 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */ 00109 00110 typedef enum { 00111 if_false, 00112 if_true, 00113 if_elif, 00114 if_elsefalse, 00115 if_elsetrue, 00116 if_ignore, 00117 if_error 00118 } pp_if_state_t; 00119 00120 00121 /* 00122 * Trace the include files to prevent double reading. 00123 * This save 20..30% of processing time for most stuff 00124 * that uses complex includes. 00125 * States: 00126 * -1 Don't track or seen junk 00127 * 0 New include, waiting for "#ifndef __xxx_h" 00128 * 1 Seen #ifndef, waiting for "#define __xxx_h ..." 00129 * 2 Seen #endif, waiting for EOF 00130 */ 00131 typedef struct 00132 { 00133 int state; 00134 char *ppp; /* The define to be set from the #ifndef */ 00135 int ifdepth; /* The level of ifs at the #ifdef */ 00136 int seen_junk; /* Set when junk is seen */ 00137 } include_state_t; 00138 00139 00140 /* 00141 * If the configure says we have long long then we can use it. Presumably 00142 * if we have long long then we have strtoull and strtoll too. If that is 00143 * not the case we will need to add to the configure tests. 00144 * If we do not have long long , then we revert to a simple 'long' for now. 00145 * This should prevent most unexpected things with other compilers than 00146 * gcc and egcs for now. 00147 * In the future it should be possible to use another way, like a 00148 * structure, so that we can emulate the MS compiler. 00149 */ 00150 #ifdef HAVE_LONG_LONG 00151 typedef long long wrc_sll_t; 00152 typedef unsigned long long wrc_ull_t; 00153 #else 00154 typedef long wrc_sll_t; 00155 typedef unsigned long wrc_ull_t; 00156 #endif 00157 00158 #define SIZE_CHAR 1 00159 #define SIZE_SHORT 2 00160 #define SIZE_INT 3 00161 #define SIZE_LONG 4 00162 #define SIZE_LONGLONG 5 00163 #define SIZE_MASK 0x00ff 00164 #define FLAG_SIGNED 0x0100 00165 00166 typedef enum { 00167 #if 0 00168 cv_schar = SIZE_CHAR + FLAG_SIGNED, 00169 cv_uchar = SIZE_CHAR, 00170 cv_sshort = SIZE_SHORT + FLAG_SIGNED, 00171 cv_ushort = SIZE_SHORT, 00172 #endif 00173 cv_sint = SIZE_INT + FLAG_SIGNED, 00174 cv_uint = SIZE_INT, 00175 cv_slong = SIZE_LONG + FLAG_SIGNED, 00176 cv_ulong = SIZE_LONG, 00177 cv_sll = SIZE_LONGLONG + FLAG_SIGNED, 00178 cv_ull = SIZE_LONGLONG 00179 } ctype_t; 00180 00181 typedef struct cval { 00182 ctype_t type; 00183 union { 00184 #if 0 00185 signed char sc; /* Explicitly signed because compilers are stupid */ 00186 unsigned char uc; 00187 short ss; 00188 unsigned short us; 00189 #endif 00190 int si; 00191 unsigned int ui; 00192 long sl; 00193 unsigned long ul; 00194 wrc_sll_t sll; 00195 wrc_ull_t ull; 00196 } val; 00197 } cval_t; 00198 00199 00200 00201 void *pp_xmalloc(size_t); 00202 void *pp_xrealloc(void *, size_t); 00203 char *pp_xstrdup(const char *str); 00204 pp_entry_t *pplookup(const char *ident); 00205 int pp_push_define_state(void); 00206 void pp_pop_define_state(void); 00207 pp_entry_t *pp_add_define(const char *def, const char *text); 00208 pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp); 00209 void pp_del_define(const char *name); 00210 void *pp_open_include(const char *name, const char *parent_name, char **newpath); 00211 void pp_push_if(pp_if_state_t s); 00212 void pp_next_if_state(int); 00213 pp_if_state_t pp_pop_if(void); 00214 pp_if_state_t pp_if_state(void); 00215 int pp_get_if_depth(void); 00216 00217 #ifndef __GNUC__ 00218 #define __attribute__(x) /*nothing*/ 00219 #endif 00220 00221 extern const struct wpp_callbacks *wpp_callbacks; 00222 00223 int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2))); 00224 int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2))); 00225 void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4))); 00226 00227 /* current preprocessor state */ 00228 /* everything is in this structure to avoid polluting the global symbol space */ 00229 struct pp_status 00230 { 00231 const char *input; /* current input file name */ 00232 void *file; /* current input file descriptor */ 00233 int line_number; /* current line number */ 00234 int char_number; /* current char number in line */ 00235 int state; /* current error state */ 00236 int pedantic; /* pedantic option */ 00237 int debug; /* debug messages flag */ 00238 }; 00239 00240 extern struct pp_status pp_status; 00241 extern include_state_t pp_incl_state; 00242 extern includelogicentry_t *pp_includelogiclist; 00243 00244 /* 00245 * From ppl.l 00246 */ 00247 extern FILE *ppy_in; 00248 extern FILE *ppy_out; 00249 extern char *ppy_text; 00250 extern int pp_flex_debug; 00251 int ppy_lex(void); 00252 00253 void pp_do_include(char *fname, int type); 00254 void pp_push_ignore_state(void); 00255 void pp_pop_ignore_state(void); 00256 00257 void pp_writestring(const char *format, ...) __attribute__((format (printf, 1, 2))); 00258 00259 /* 00260 * From ppy.y 00261 */ 00262 int ppy_parse(void); 00263 extern int ppy_debug; 00264 00265 #endif /* __WINE_WPP_PRIVATE_H */ Generated on Sun May 27 2012 04:38:06 for ReactOS by
1.7.6.1
|