Commit d282afeb authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] kconfig: symbol change notification

Add a changed flag to properties, which can be used by front ends to check
for changed symbols/properties.
parent 4cd4dbac
...@@ -166,12 +166,15 @@ struct menu { ...@@ -166,12 +166,15 @@ struct menu {
struct symbol *sym; struct symbol *sym;
struct property *prompt; struct property *prompt;
struct expr *dep; struct expr *dep;
unsigned int flags;
//char *help; //char *help;
struct file *file; struct file *file;
int lineno; int lineno;
void *data; void *data;
}; };
#define MENU_CHANGED 0x0001
#ifndef SWIG #ifndef SWIG
extern struct file *file_list; extern struct file *file_list;
......
...@@ -63,6 +63,7 @@ extern struct menu *current_menu; ...@@ -63,6 +63,7 @@ extern struct menu *current_menu;
/* symbol.c */ /* symbol.c */
void sym_init(void); void sym_init(void);
void sym_clear_all_valid(void); void sym_clear_all_valid(void);
void sym_set_changed(struct symbol *sym);
static inline tristate sym_get_tristate_value(struct symbol *sym) static inline tristate sym_get_tristate_value(struct symbol *sym)
{ {
......
...@@ -149,7 +149,7 @@ void sym_calc_visibility(struct symbol *sym) ...@@ -149,7 +149,7 @@ void sym_calc_visibility(struct symbol *sym)
visible = E_OR(visible, E_CALC(prop->visible)); visible = E_OR(visible, E_CALC(prop->visible));
if (oldvisible != visible) { if (oldvisible != visible) {
sym->visible = visible; sym->visible = visible;
sym->flags |= SYMBOL_CHANGED; sym_set_changed(sym);
} }
} }
...@@ -277,14 +277,17 @@ void sym_calc_value(struct symbol *sym) ...@@ -277,14 +277,17 @@ void sym_calc_value(struct symbol *sym)
} }
if (memcmp(&oldval, &newval, sizeof(newval))) if (memcmp(&oldval, &newval, sizeof(newval)))
sym->flags |= SYMBOL_CHANGED; sym_set_changed(sym);
sym->curr = newval; sym->curr = newval;
if (sym_is_choice(sym)) { if (sym_is_choice(sym)) {
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
for (e = prop->dep; e; e = e->left.expr) for (e = prop->dep; e; e = e->left.expr) {
e->right.sym->flags |= flags; e->right.sym->flags |= flags;
if (flags & SYMBOL_CHANGED)
sym_set_changed(e->right.sym);
}
} }
} }
...@@ -298,13 +301,24 @@ void sym_clear_all_valid(void) ...@@ -298,13 +301,24 @@ void sym_clear_all_valid(void)
sym_change_count++; sym_change_count++;
} }
void sym_set_changed(struct symbol *sym)
{
struct property *prop;
sym->flags |= SYMBOL_CHANGED;
for (prop = sym->prop; prop; prop = prop->next) {
if (prop->menu)
prop->menu->flags |= MENU_CHANGED;
}
}
void sym_set_all_changed(void) void sym_set_all_changed(void)
{ {
struct symbol *sym; struct symbol *sym;
int i; int i;
for_all_symbols(i, sym) for_all_symbols(i, sym)
sym->flags |= SYMBOL_CHANGED; sym_set_changed(sym);
} }
bool sym_tristate_within_range(struct symbol *sym, tristate val) bool sym_tristate_within_range(struct symbol *sym, tristate val)
...@@ -341,7 +355,7 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) ...@@ -341,7 +355,7 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
if (sym->flags & SYMBOL_NEW) { if (sym->flags & SYMBOL_NEW) {
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
sym->flags |= SYMBOL_CHANGED; sym_set_changed(sym);
} }
if (sym_is_choice_value(sym) && val == yes) { if (sym_is_choice_value(sym) && val == yes) {
struct property *prop = sym_get_choice_prop(sym); struct property *prop = sym_get_choice_prop(sym);
...@@ -461,7 +475,7 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) ...@@ -461,7 +475,7 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
if (sym->flags & SYMBOL_NEW) { if (sym->flags & SYMBOL_NEW) {
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
sym->flags |= SYMBOL_CHANGED; sym_set_changed(sym);
} }
oldval = S_VAL(sym->def); oldval = S_VAL(sym->def);
...@@ -526,7 +540,6 @@ struct symbol *sym_lookup(const char *name, int isconst) ...@@ -526,7 +540,6 @@ struct symbol *sym_lookup(const char *name, int isconst)
char *new_name; char *new_name;
int hash = 0; int hash = 0;
//printf("lookup: %s -> ", name);
if (name) { if (name) {
if (name[0] && !name[1]) { if (name[0] && !name[1]) {
switch (name[0]) { switch (name[0]) {
...@@ -542,10 +555,8 @@ struct symbol *sym_lookup(const char *name, int isconst) ...@@ -542,10 +555,8 @@ struct symbol *sym_lookup(const char *name, int isconst)
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
if (!strcmp(symbol->name, name)) { if (!strcmp(symbol->name, name)) {
if ((isconst && symbol->flags & SYMBOL_CONST) || if ((isconst && symbol->flags & SYMBOL_CONST) ||
(!isconst && !(symbol->flags & SYMBOL_CONST))) { (!isconst && !(symbol->flags & SYMBOL_CONST)))
//printf("h:%p\n", symbol);
return symbol; return symbol;
}
} }
} }
new_name = strdup(name); new_name = strdup(name);
...@@ -565,7 +576,6 @@ struct symbol *sym_lookup(const char *name, int isconst) ...@@ -565,7 +576,6 @@ struct symbol *sym_lookup(const char *name, int isconst)
symbol->next = symbol_hash[hash]; symbol->next = symbol_hash[hash];
symbol_hash[hash] = symbol; symbol_hash[hash] = symbol;
//printf("n:%p\n", symbol);
return symbol; return symbol;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment