[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: interesting links
On Thu, Aug 30, 2007 at 06:19:14PM +0100, Peter Clifton wrote:
>
> I'm not sure what the performance hit might be in removing it, and using
> a test on the object's type.
You've basically hit on the two techniques that have been used extensively
in UNIX kernels:
struct foo_operations {
int (*func)(args);
};
struct thing {
struct foo_operations *foo_ops; /* size independent of num of ops */
};
Then some code spells out thinginstance->foo_ops->func(), but sometimes
people make macros to hide that and it looks like FUNC(thinginstance, ...)
which can also enforce passing thinginstance as the first arg.
The other is the devswitch, where you have a global table
struct foo_operations devsw[ntypes];
struct thing {
char type; /* or int or whatever */
}
Then you get devsw[thinginstance->type]->func(). Again wrapped in a macro
to hide all that.
--
Ben Jackson AD7GD
<ben@xxxxxxx>
http://www.ben.com/
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user