Re: [kbuild-devel] [PATCH 1/4] kconfig: implement setter/getter functions and change callback for sym_change_count

2006-10-06 Thread Karsten Wiese
Am Freitag, 29. September 2006 00:34 schrieb Roman Zippel:
 Hi,
 
 On Thu, 28 Sep 2006, karsten wiese wrote:
 
  enable/disable the qt- and gtk-gui configurator's
   save toolbar-button/menu-entry.
  
  The qt-configurator asks the user, if he want's to save the changed
  .config if sym_change_count!=0.
 
 Ok, then please split the patch a bit differently.
 1. Introduce and use the getter for the change information, which is 
 actually a boolean, so something like sym_get_changed() would be a better 
 name.
 2. Cleanup how the change information is managed, e.g. via 
 sym_set_changed(). This is an internal function, so it doesn't has to be 
 exported.
 3. Add the callback, but please make the function and object static to the 
 class.
 

Just gave it a try and stumbled over already existing sym_set_changed().

find output (see below) shows the most hits
for sym_change_count in confdata.c.

So how about replacing
sym_change_count by bool conf_dirty
and adding
bool conf_get_dirty(void),
void conf_set_dirty(bool)
?

I'd place bool conf_dirty, bool conf_get_dirty(void)
 and void conf_set_dirty(bool) in confdata.c then.

  Karsten



find . -type f -print0 | xargs -0 -e grep -nH -e sym_change_count
./conf.c:603:   } else if (sym_change_count) {
./confdata.c:103:   sym_change_count++;
./confdata.c:311:   sym_change_count = 0;
./confdata.c:363:   sym_change_count += conf_warnings || conf_unsaved;
./confdata.c:431:   if (!sym_change_count)
./confdata.c:527:   sym_change_count = 0;
./lkc_proto.h:19:P(sym_change_count,int,);
./qconf.cc:1587:if (!sym_change_count) {
./symbol.c:33:int sym_change_count;
./symbol.c:382: sym_change_count++;
./zconf.tab.c_shipped:2138: sym_change_count = 1;
./zconf.y:507:  sym_change_count = 1;


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel


Re: [kbuild-devel] [PATCH 1/4] kconfig: implement setter/getter functions and change callback for sym_change_count

2006-10-06 Thread Sam Ravnborg
On Fri, Oct 06, 2006 at 08:44:29PM +0200, Karsten Wiese wrote:
 
 Just gave it a try and stumbled over already existing sym_set_changed().
 
 find output (see below) shows the most hits
 for sym_change_count in confdata.c.
 
 So how about replacing
   sym_change_count by bool conf_dirty
 and adding
   bool conf_get_dirty(void),
   void conf_set_dirty(bool)
Naming is always of difficult...
In kconfig we use changed when somethign is changed - we do not use dirty.
And sym refers to a symbol - so that is not adequate.

conf refer to a full config (at least in some cases).
So I would suggest:
bool conf_changed(void)
void conf_set_changed()

or something like that.

Sam

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel


[kbuild-devel] [PATCH 1/4] kconfig: implement setter/getter functions and change callback for sym_change_count

2006-09-24 Thread Karsten Wiese
Make sym_change_count static, implement
void sym_change_count_set(int)
and
int sym_change_count(void)
 to set or get its value;
sym_change_count is only changed by void sym_change_count_set(int).
the latter can call a callback function, if a fn-pointer is set by
also new function
void sym_change_count_changed_set(void (*fn)(int))
.

Signed-off-by: Karsten Wiese [EMAIL PROTECTED]


--- 2.6.18/scripts/kconfig/conf.c   2006-09-23 20:03:17.0 +0200
+++ 2.6.18-kw/scripts/kconfig/conf.c2006-09-24 14:24:58.0 +0200
@@ -600,7 +600,7 @@ int main(int ac, char **av)
input_mode = ask_silent;
valid_stdin = 1;
}
-   } else if (sym_change_count) {
+   } else if (sym_change_count()) {
name = getenv(KCONFIG_NOSILENTUPDATE);
if (name  *name) {
fprintf(stderr, _(\n*** Kernel configuration requires 
explicit update.\n\n));
diff -pur 2.6.18/scripts/kconfig/confdata.c rt3-kw/scripts/kconfig/confdata.c
--- 2.6.18/scripts/kconfig/confdata.c   2006-09-23 20:03:17.0 +0200
+++ 2.6.18-kw/scripts/kconfig/confdata.c2006-09-23 22:31:30.0 
+0200
@@ -100,7 +100,7 @@ int conf_read_simple(const char *name, i
in = zconf_fopen(name);
if (in)
goto load;
-   sym_change_count++;
+   sym_change_count_set(sym_change_count() + 1);
if (!sym_defconfig_list)
return 1;
 
@@ -308,7 +308,7 @@ int conf_read(const char *name)
struct expr *e;
int i, flags;
 
-   sym_change_count = 0;
+   sym_change_count_set(0);
 
if (conf_read_simple(name, S_DEF_USER))
return 1;
@@ -360,7 +360,7 @@ int conf_read(const char *name)
sym-flags = flags | ~SYMBOL_DEF_USER;
}
 
-   sym_change_count += conf_warnings || conf_unsaved;
+   sym_change_count_set(sym_change_count() + (conf_warnings || 
conf_unsaved));
 
return 0;
 }
@@ -428,7 +428,7 @@ int conf_write(const char *name)
 use_timestamp ? #  : ,
 use_timestamp ? ctime(now) : );
 
-   if (!sym_change_count)
+   if (!sym_change_count())
sym_clear_all_valid();
 
menu = rootmenu.list;
@@ -524,7 +524,7 @@ int conf_write(const char *name)
 # configuration written to %s\n
 #\n), newname);
 
-   sym_change_count = 0;
+   sym_change_count_set(0);
 
return 0;
 }
diff -pur 2.6.18/scripts/kconfig/lkc_proto.h rt3-kw/scripts/kconfig/lkc_proto.h
--- 2.6.18/scripts/kconfig/lkc_proto.h  2006-09-23 20:03:17.0 +0200
+++ 2.6.18-kw/scripts/kconfig/lkc_proto.h   2006-09-24 14:22:19.0 
+0200
@@ -16,7 +16,9 @@ P(menu_get_parent_menu,struct menu *,(st
 
 /* symbol.c */
 P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
-P(sym_change_count,int,);
+P(sym_change_count,int,(void));
+P(sym_change_count_set,void,(int));
+P(sym_change_count_changed_set,void,(void (*fn)(int)));
 
 P(sym_lookup,struct symbol *,(const char *name, int isconst));
 P(sym_find,struct symbol *,(const char *name));
diff -pur 2.6.18/scripts/kconfig/symbol.c rt3-kw/scripts/kconfig/symbol.c
--- 2.6.18/scripts/kconfig/symbol.c 2006-09-23 20:03:17.0 +0200
+++ 2.6.18-kw/scripts/kconfig/symbol.c  2006-09-24 14:23:37.0 +0200
@@ -30,7 +30,26 @@ struct symbol symbol_yes = {
.flags = SYMBOL_VALID,
 };
 
-int sym_change_count;
+static int _sym_change_count;
+
+static void (*sym_change_count_changed)(int count);
+
+void sym_change_count_changed_set(void (*fn)(int))
+{
+   sym_change_count_changed = fn;
+}
+
+void sym_change_count_set(int count)
+{
+   _sym_change_count = count;
+   if (sym_change_count_changed)
+   sym_change_count_changed(_sym_change_count);
+}
+int sym_change_count(void)
+{
+   return _sym_change_count;
+}
+
 struct symbol *sym_defconfig_list;
 struct symbol *modules_sym;
 tristate modules_val;
@@ -379,7 +398,7 @@ void sym_clear_all_valid(void)
 
for_all_symbols(i, sym)
sym-flags = ~SYMBOL_VALID;
-   sym_change_count++;
+   sym_change_count_set(sym_change_count() + 1);
if (modules_sym)
sym_calc_value(modules_sym);
 }
diff -pur 2.6.18/scripts/kconfig/zconf.tab.c_shipped 
rt3-kw/scripts/kconfig/zconf.tab.c_shipped
--- 2.6.18/scripts/kconfig/zconf.tab.c_shipped  2006-09-23 20:03:17.0 
+0200
+++ 2.6.18-kw/scripts/kconfig/zconf.tab.c_shipped   2006-09-23 
22:28:35.0 +0200
@@ -2135,7 +2135,7 @@ void conf_parse(const char *name)
sym_check_deps(sym);
 }
 
-   sym_change_count = 1;
+   sym_change_count_set(1);
 }
 
 const char *zconf_tokenname(int token)
diff -pur 2.6.18/scripts/kconfig/zconf.y rt3-kw/scripts/kconfig/zconf.y
--- 2.6.18/scripts/kconfig/zconf.y  2006-09-23