Binding for a function receiving a C callback without arguments


I need to write the bindings for a C function that receives a callback which has to arguments. Here's the C declaration:

typedef ChamplainMapSource * (*ChamplainMapSourceConstructor) ();
#define CHAMPLAIN_MAP_SOURCE_CONSTRUCTOR (f) ((ChamplainMapSourceConstructor) (f))

gboolean champlain_map_source_factory_register (ChamplainMapSourceFactory *factory,
ÂÂÂ const gchar *id,
ÂÂÂ ChamplainMapSourceConstructor callback);

I've been reading the perldoc of GClosure.xs ( and I've peeked a ClutterEffect.xs which has also some closures and tried to implement this by my self but I'm stock. From what I understand the magic of GPerlCallback requires that the C callback accepts a gpointer data. At least, this is how all examples that I've seen so far are doing it. Since my C callback has no argumetns I don't see how I can get it to work. Furthermore the library that I'm binding doesn't have a method that lets me register the C callback with a (GDestroyNotify) so even if I succeed I will be leaking some memory. Note that this isn't so critical as the fuction that I try to bind registers a global factory method which should persist forever unitil the program finishes.

Someome knows of an exisinting C API that has a similar callback and how I can overcome this?

Emmanuel Rodriguez

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]