Re: [xml] Feature request: callbacks
- From: robert <robert xml 00008 org>
- To: xml gnome org
- Subject: Re: [xml] Feature request: callbacks
- Date: Thu, 15 Mar 2001 11:46:06 +0100
+ considering there is multiple callbacks, should the API
be at the registration of a single callback or a callback set ?
I would think a 'callback' datastructure (a 'struct') might be defined,
with which someone interested in registring callbacks can 'fill in the
blanks'. This should be forward-compatible too, since adding new callbacks
in future release will only add to the structure instead of changing it.
A small example of what I mean:
struct xmlCallbacks
{
int (*nodecreation)(void *context, XXX);
int (*nodedeletion)(void *context, XXX);
...
};
+ scope of the registration, I'm leaning toward an application wide
registration, but some may argue that this must be done on a
document per document basis (and would require a structure change
for the document nodes :-( it also makes the lookup more costly
or even impossible in some obscure cases I would rather avoid this).
If you want thread-safety, it should be done (or atleast should be
_possible_ to be done) at document-basis.
As I pointed out before, some obscure projects (one of which I'm working
on ;) might not be able to do an application-wide registration which is
thread-safe (in other words, which is carried out before the process goes
multi-threaded).
- Callback signature:
a few week ago I would have used
void (*xmlTreeChangeCallback) (xmlNodePtr node);
but it's clear that Perl binding would require something like
void (*xmlTreeChangeCallback) (void *user_data, xmlNodePtr node);
is that sufficient ? I assume user_data would be registered at the
same time as the set of callbacks.
The latter is indeed much more usable than the former :) Because no
context-pointers can be passed by libxml's I/O callbacks, I had to resort
to gcc-specific extensions to be able to reach context-data, so I'd say new
callbacks should atleast have that possibility.
I will let this brew till the end of the week and may spend time
implementing it during the week-end.
All work and no play? :)
<shame>
Euro's one or dollar's ?
</shame>
Dollars are worth more ;)
robert
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]