kconfig/expr.h
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Oct 17 12:47:53 2008 +0000 (2008-10-17)
changeset 943 1cca90ce0481
parent 1 eeea35fbf182
child 1234 20da13326d14
permissions -rw-r--r--
Update the kconfig stuff to match the one in the linux-2.6.27 version.

/trunk/kconfig/zconf.hash.c | 225 110 115 0 +++----
/trunk/kconfig/lkc_proto.h | 4 3 1 0 +
/trunk/kconfig/mconf.c | 217 110 107 0 +++---
/trunk/kconfig/menu.c | 86 60 26 0 ++-
/trunk/kconfig/symbol.c | 212 156 56 0 ++++--
/trunk/kconfig/kconfig.mk | 24 9 15 0 -
/trunk/kconfig/lex.zconf.c | 97 80 17 0 ++-
/trunk/kconfig/util.c | 38 30 8 0 +
/trunk/kconfig/lkc.h | 22 18 4 0 +
/trunk/kconfig/expr.c | 32 19 13 0 +
/trunk/kconfig/confdata.c | 254 172 82 0 +++++---
/trunk/kconfig/lxdialog/dialog.h | 12 9 3 0 +
/trunk/kconfig/lxdialog/inputbox.c | 6 3 3 0
/trunk/kconfig/lxdialog/checklist.c | 4 2 2 0
/trunk/kconfig/lxdialog/menubox.c | 6 3 3 0
/trunk/kconfig/lxdialog/textbox.c | 2 1 1 0
/trunk/kconfig/lxdialog/util.c | 47 30 17 0 +
/trunk/kconfig/lxdialog/yesno.c | 4 2 2 0
/trunk/kconfig/expr.h | 20 10 10 0
/trunk/kconfig/zconf.tab.c | 1441 793 648 0 ++++++++++++++++++++++++-------------------
/trunk/kconfig/conf.c | 276 124 152 0 ++++----
/trunk/kconfig/check-gettext.sh | 14 14 0 0 +
/trunk/ct-ng.in | 2 1 1 0
23 files changed, 1759 insertions(+), 1286 deletions(-)
yann@1
     1
/*
yann@1
     2
 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
yann@1
     3
 * Released under the terms of the GNU GPL v2.0.
yann@1
     4
 */
yann@1
     5
yann@1
     6
#ifndef EXPR_H
yann@1
     7
#define EXPR_H
yann@1
     8
yann@1
     9
#ifdef __cplusplus
yann@1
    10
extern "C" {
yann@1
    11
#endif
yann@1
    12
yann@1
    13
#include <stdio.h>
yann@1
    14
#ifndef __cplusplus
yann@1
    15
#include <stdbool.h>
yann@1
    16
#endif
yann@1
    17
yann@1
    18
struct file {
yann@1
    19
	struct file *next;
yann@1
    20
	struct file *parent;
yann@1
    21
	char *name;
yann@1
    22
	int lineno;
yann@1
    23
	int flags;
yann@1
    24
};
yann@1
    25
yann@1
    26
#define FILE_BUSY		0x0001
yann@1
    27
#define FILE_SCANNED		0x0002
yann@1
    28
yann@1
    29
typedef enum tristate {
yann@1
    30
	no, mod, yes
yann@1
    31
} tristate;
yann@1
    32
yann@1
    33
enum expr_type {
yann@943
    34
	E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE
yann@1
    35
};
yann@1
    36
yann@1
    37
union expr_data {
yann@1
    38
	struct expr *expr;
yann@1
    39
	struct symbol *sym;
yann@1
    40
};
yann@1
    41
yann@1
    42
struct expr {
yann@1
    43
	enum expr_type type;
yann@1
    44
	union expr_data left, right;
yann@1
    45
};
yann@1
    46
yann@943
    47
#define EXPR_OR(dep1, dep2)	(((dep1)>(dep2))?(dep1):(dep2))
yann@943
    48
#define EXPR_AND(dep1, dep2)	(((dep1)<(dep2))?(dep1):(dep2))
yann@943
    49
#define EXPR_NOT(dep)		(2-(dep))
yann@943
    50
yann@943
    51
#define expr_list_for_each_sym(l, e, s) \
yann@943
    52
	for (e = (l); e && (s = e->right.sym); e = e->left.expr)
yann@1
    53
yann@1
    54
struct expr_value {
yann@1
    55
	struct expr *expr;
yann@1
    56
	tristate tri;
yann@1
    57
};
yann@1
    58
yann@1
    59
struct symbol_value {
yann@1
    60
	void *val;
yann@1
    61
	tristate tri;
yann@1
    62
};
yann@1
    63
yann@1
    64
enum symbol_type {
yann@1
    65
	S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
yann@1
    66
};
yann@1
    67
yann@1
    68
enum {
yann@1
    69
	S_DEF_USER,		/* main user value */
yann@1
    70
	S_DEF_AUTO,
yann@1
    71
};
yann@1
    72
yann@1
    73
struct symbol {
yann@1
    74
	struct symbol *next;
yann@1
    75
	char *name;
yann@1
    76
	enum symbol_type type;
yann@1
    77
	struct symbol_value curr;
yann@1
    78
	struct symbol_value def[4];
yann@1
    79
	tristate visible;
yann@1
    80
	int flags;
yann@1
    81
	struct property *prop;
yann@1
    82
	struct expr_value rev_dep;
yann@1
    83
};
yann@1
    84
yann@1
    85
#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)
yann@1
    86
yann@1
    87
#define SYMBOL_CONST		0x0001
yann@1
    88
#define SYMBOL_CHECK		0x0008
yann@1
    89
#define SYMBOL_CHOICE		0x0010
yann@1
    90
#define SYMBOL_CHOICEVAL	0x0020
yann@1
    91
#define SYMBOL_VALID		0x0080
yann@1
    92
#define SYMBOL_OPTIONAL		0x0100
yann@1
    93
#define SYMBOL_WRITE		0x0200
yann@1
    94
#define SYMBOL_CHANGED		0x0400
yann@1
    95
#define SYMBOL_AUTO		0x1000
yann@1
    96
#define SYMBOL_CHECKED		0x2000
yann@1
    97
#define SYMBOL_WARNED		0x8000
yann@1
    98
#define SYMBOL_DEF		0x10000
yann@1
    99
#define SYMBOL_DEF_USER		0x10000
yann@1
   100
#define SYMBOL_DEF_AUTO		0x20000
yann@1
   101
#define SYMBOL_DEF3		0x40000
yann@1
   102
#define SYMBOL_DEF4		0x80000
yann@1
   103
yann@1
   104
#define SYMBOL_MAXLENGTH	256
yann@1
   105
#define SYMBOL_HASHSIZE		257
yann@1
   106
#define SYMBOL_HASHMASK		0xff
yann@1
   107
yann@1
   108
enum prop_type {
yann@943
   109
	P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
yann@943
   110
	P_SELECT, P_RANGE, P_ENV
yann@1
   111
};
yann@1
   112
yann@1
   113
struct property {
yann@1
   114
	struct property *next;
yann@1
   115
	struct symbol *sym;
yann@1
   116
	enum prop_type type;
yann@1
   117
	const char *text;
yann@1
   118
	struct expr_value visible;
yann@1
   119
	struct expr *expr;
yann@1
   120
	struct menu *menu;
yann@1
   121
	struct file *file;
yann@1
   122
	int lineno;
yann@1
   123
};
yann@1
   124
yann@1
   125
#define for_all_properties(sym, st, tok) \
yann@1
   126
	for (st = sym->prop; st; st = st->next) \
yann@1
   127
		if (st->type == (tok))
yann@1
   128
#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
yann@1
   129
#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
yann@1
   130
#define for_all_prompts(sym, st) \
yann@1
   131
	for (st = sym->prop; st; st = st->next) \
yann@1
   132
		if (st->text)
yann@1
   133
yann@1
   134
struct menu {
yann@1
   135
	struct menu *next;
yann@1
   136
	struct menu *parent;
yann@1
   137
	struct menu *list;
yann@1
   138
	struct symbol *sym;
yann@1
   139
	struct property *prompt;
yann@1
   140
	struct expr *dep;
yann@1
   141
	unsigned int flags;
yann@943
   142
	char *help;
yann@1
   143
	struct file *file;
yann@1
   144
	int lineno;
yann@1
   145
	void *data;
yann@1
   146
};
yann@1
   147
yann@1
   148
#define MENU_CHANGED		0x0001
yann@1
   149
#define MENU_ROOT		0x0002
yann@1
   150
yann@1
   151
#ifndef SWIG
yann@1
   152
yann@1
   153
extern struct file *file_list;
yann@1
   154
extern struct file *current_file;
yann@1
   155
struct file *lookup_file(const char *name);
yann@1
   156
yann@1
   157
extern struct symbol symbol_yes, symbol_no, symbol_mod;
yann@1
   158
extern struct symbol *modules_sym;
yann@1
   159
extern struct symbol *sym_defconfig_list;
yann@1
   160
extern int cdebug;
yann@1
   161
struct expr *expr_alloc_symbol(struct symbol *sym);
yann@1
   162
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
yann@1
   163
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
yann@1
   164
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
yann@1
   165
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
yann@1
   166
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
yann@1
   167
struct expr *expr_copy(struct expr *org);
yann@1
   168
void expr_free(struct expr *e);
yann@1
   169
int expr_eq(struct expr *e1, struct expr *e2);
yann@1
   170
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
yann@1
   171
tristate expr_calc_value(struct expr *e);
yann@1
   172
struct expr *expr_eliminate_yn(struct expr *e);
yann@1
   173
struct expr *expr_trans_bool(struct expr *e);
yann@1
   174
struct expr *expr_eliminate_dups(struct expr *e);
yann@1
   175
struct expr *expr_transform(struct expr *e);
yann@1
   176
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
yann@1
   177
bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
yann@1
   178
struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
yann@1
   179
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
yann@1
   180
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
yann@1
   181
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
yann@1
   182
yann@1
   183
void expr_fprint(struct expr *e, FILE *out);
yann@1
   184
struct gstr; /* forward */
yann@1
   185
void expr_gstr_print(struct expr *e, struct gstr *gs);
yann@1
   186
yann@1
   187
static inline int expr_is_yes(struct expr *e)
yann@1
   188
{
yann@1
   189
	return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
yann@1
   190
}
yann@1
   191
yann@1
   192
static inline int expr_is_no(struct expr *e)
yann@1
   193
{
yann@1
   194
	return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
yann@1
   195
}
yann@1
   196
#endif
yann@1
   197
yann@1
   198
#ifdef __cplusplus
yann@1
   199
}
yann@1
   200
#endif
yann@1
   201
yann@1
   202
#endif /* EXPR_H */