I've considerably refined my earlier approach to libevent delegates /
psuedo-lambda expressions.
I've abstracted out function pointer delegation -- delegate() & invoke() --
and then built the libevent wrapper -- event_delegate() -- around that.
Other changes:
- No more exponential pre-processor expansion (i.e. no more 2MB expansions).
- invoke() can proxy return values (ignored from libevent wrapper).
- Static detection of libevent's void(*)(int, short, void *) callback
signature by event_delegate(); no libffi overhead. Useful for
micro-optimizing without having to dramatically change code.
- Supporting more than 7 arguments should be a snap to add. The C99 macro
"magic" has been re-written to use recursive'ish techniques.
GCC and libffi are, of course, still required.
Code available at:
http://25thandclement.com/~william/projects/delegate.c.html
I've been using this in a recent project and am quite happy. Only headache
is that it can be a pain to locate libffi headers, even if manually
installed.
_______________________________________________
Libevent-users mailing list
[email protected]
http://monkeymail.org/mailman/listinfo/libevent-users