On Wed, Aug 28, 2002 at 11:07:29PM -0500, Dave Trollope wrote:
> Hi Domonik
> 
> I was returning to the discussion we had at the start of the month where 
> you wanted to replace the if/else chain with a bsearch. We had a 
> detailed discussion about changing the data structures etc and I see you 
> have modified the macros along some of the lines we discussed, but the 
> bsearch problem hasn't been implemented yet and I had another perhaps 
> simpler idea.
> 
> Instead of trying to get the bitfield address of the field(s) to change 
> and storing that in a bsearchable array, perhaps a simpler solution 
> would be this - and this is flexible to complex styles as well as simple 
> styles.
> 
> For each style, create a simple static function to set the data 
> appropriately, then in the array of names, use a function pointer. E.G.
> 
> Instead of:
> 
> if(StrEquals(token,"Sticky))
> { S_SET_STICKY(MCF(...),on)
>    S_SET_STICKY(MCM...,1)
>    S_SET ....
> }else if(StrEquals.....
> 
> You could do this:
> 
> static void f_Set_Sticky(int on) {
>    S_SET_STICKY(MCF(...),on)
>    S_SET_STICKY(MCM...),1)
>    S_SET ....
> }
> 
> struct setstyle { char *name; void (*func)(int on); } = {
> ..... { "Sticky", f_Set_Sticky }, ...
> }
> 
> 
> ss = bsearch(setstyle,token)
> if(ss) ss->func(on)
> else { /* do other style checking */ }
> 
> This retains the whole data model, and avoids the whole bit mask address 
> problem while also being flexible to more complex processing for some 
> styles. This does create a lot of functions, but if they are static, 
> they should be minimum overhead.
> 
> What do you think?

I've thought about this approach too.  It has one big weakness:
it doesn't reduce the amount of code.  Instead, it even creates
more code.  I'd grudgingly take the approach that requires
generating the sources - if I could think of a way to get names on
the individual bits that are displayed by a debugger.

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to