base/config/kconfig/expr.h

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 00003 * Released under the terms of the GNU GPL v2.0. 00004 */ 00005 00006 #ifndef EXPR_H 00007 #define EXPR_H 00008 00009 #ifdef __cplusplus 00010 extern "C" { 00011 #endif 00012 00013 #include <stdio.h> 00014 #ifndef __cplusplus 00015 #include <stdbool.h> 00016 #endif 00017 00018 struct file { 00019 struct file *next; 00020 struct file *parent; 00021 char *name; 00022 int lineno; 00023 int flags; 00024 }; 00025 00026 #define FILE_BUSY 0x0001 00027 #define FILE_SCANNED 0x0002 00028 #define FILE_PRINTED 0x0004 00029 00030 typedef enum tristate { 00031 no, mod, yes 00032 } tristate; 00033 00034 enum expr_type { 00035 E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE 00036 }; 00037 00038 union expr_data { 00039 struct expr *expr; 00040 struct symbol *sym; 00041 }; 00042 00043 struct expr { 00044 enum expr_type type; 00045 union expr_data left, right; 00046 }; 00047 00048 #define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) 00049 #define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) 00050 #define E_NOT(dep) (2-(dep)) 00051 00052 struct expr_value { 00053 struct expr *expr; 00054 tristate tri; 00055 }; 00056 00057 struct symbol_value { 00058 void *val; 00059 tristate tri; 00060 }; 00061 00062 enum symbol_type { 00063 S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER 00064 }; 00065 00066 struct symbol { 00067 struct symbol *next; 00068 char *name; 00069 char *help; 00070 enum symbol_type type; 00071 struct symbol_value curr, user; 00072 tristate visible; 00073 int flags; 00074 struct property *prop; 00075 struct expr *dep, *dep2; 00076 struct expr_value rev_dep; 00077 }; 00078 00079 #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) 00080 00081 #define SYMBOL_YES 0x0001 00082 #define SYMBOL_MOD 0x0002 00083 #define SYMBOL_NO 0x0004 00084 #define SYMBOL_CONST 0x0007 00085 #define SYMBOL_CHECK 0x0008 00086 #define SYMBOL_CHOICE 0x0010 00087 #define SYMBOL_CHOICEVAL 0x0020 00088 #define SYMBOL_PRINTED 0x0040 00089 #define SYMBOL_VALID 0x0080 00090 #define SYMBOL_OPTIONAL 0x0100 00091 #define SYMBOL_WRITE 0x0200 00092 #define SYMBOL_CHANGED 0x0400 00093 #define SYMBOL_NEW 0x0800 00094 #define SYMBOL_AUTO 0x1000 00095 #define SYMBOL_CHECKED 0x2000 00096 #define SYMBOL_CHECK_DONE 0x4000 00097 #define SYMBOL_WARNED 0x8000 00098 00099 #define SYMBOL_MAXLENGTH 256 00100 #define SYMBOL_HASHSIZE 257 00101 #define SYMBOL_HASHMASK 0xff 00102 00103 enum prop_type { 00104 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE 00105 }; 00106 00107 struct property { 00108 struct property *next; 00109 struct symbol *sym; 00110 enum prop_type type; 00111 const char *text; 00112 struct expr_value visible; 00113 struct expr *expr; 00114 struct menu *menu; 00115 struct file *file; 00116 int lineno; 00117 }; 00118 00119 #define for_all_properties(sym, st, tok) \ 00120 for (st = sym->prop; st; st = st->next) \ 00121 if (st->type == (tok)) 00122 #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) 00123 #define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) 00124 #define for_all_prompts(sym, st) \ 00125 for (st = sym->prop; st; st = st->next) \ 00126 if (st->text) 00127 00128 struct menu { 00129 struct menu *next; 00130 struct menu *parent; 00131 struct menu *list; 00132 struct symbol *sym; 00133 struct property *prompt; 00134 struct expr *dep; 00135 unsigned int flags; 00136 //char *help; 00137 struct file *file; 00138 int lineno; 00139 void *data; 00140 }; 00141 00142 #define MENU_CHANGED 0x0001 00143 #define MENU_ROOT 0x0002 00144 00145 #ifndef SWIG 00146 00147 extern struct file *file_list; 00148 extern struct file *current_file; 00149 struct file *lookup_file(const char *name); 00150 00151 extern struct symbol symbol_yes, symbol_no, symbol_mod; 00152 extern struct symbol *modules_sym; 00153 extern int cdebug; 00154 struct expr *expr_alloc_symbol(struct symbol *sym); 00155 struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); 00156 struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); 00157 struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); 00158 struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); 00159 struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); 00160 struct expr *expr_copy(struct expr *org); 00161 void expr_free(struct expr *e); 00162 int expr_eq(struct expr *e1, struct expr *e2); 00163 void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); 00164 tristate expr_calc_value(struct expr *e); 00165 struct expr *expr_eliminate_yn(struct expr *e); 00166 struct expr *expr_trans_bool(struct expr *e); 00167 struct expr *expr_eliminate_dups(struct expr *e); 00168 struct expr *expr_transform(struct expr *e); 00169 int expr_contains_symbol(struct expr *dep, struct symbol *sym); 00170 bool expr_depends_symbol(struct expr *dep, struct symbol *sym); 00171 struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); 00172 struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); 00173 void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); 00174 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); 00175 00176 void expr_fprint(struct expr *e, FILE *out); 00177 void print_expr(int mask, struct expr *e, int prevtoken); 00178 00179 static inline int expr_is_yes(struct expr *e) 00180 { 00181 return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); 00182 } 00183 00184 static inline int expr_is_no(struct expr *e) 00185 { 00186 return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); 00187 } 00188 #endif 00189 00190 #ifdef __cplusplus 00191 } 00192 #endif 00193 00194 #endif /* EXPR_H */

Generated on Thu Nov 20 11:49:47 2008 for RTAI API by doxygen 1.3.8