chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] C callback with SWIG


From: Bastian Müller
Subject: [Chicken-users] C callback with SWIG
Date: Sat, 18 Aug 2007 20:57:10 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

after getting the C callback to work with the normal C interface method
I got stuck and tired of doing this all by hand. I saw that gtk-2 and
wx-chicken both use SWIG. So I wrote a simple ode.i, included all header
files, gave it a shot and it works pretty well.

The only problem I have, are the C callbacks. I looked into the gtk-2 egg
and saw that they just use normal functions or lambdas and don't do any
special voodoo.

Definitions:
// GTK
typedef void  (*GCallback) (void);
// ODE
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);

// GTK
gulong g_signal_connect_data (gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags);
// ODE
void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);

Call:
// GTK
(g-signal-connect *window* "destroy" (lambda () ... ))

// ODE
(ode-space-collide space #f (lambda (foo bar baz) ... ))

The gtk one works, my try with ode results in an:
Error: Type error in argument #3: expected void (*)(void *,struct dxGeom *,struct dxGeom *)|dNearCallback *: "bad argument type"

Anonymous functions and even normal ones don't work. How can I get this to work?

Thanks in advance!

- --
Bastian Müller - http://turbolent.com/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFGx0EQUFTPKTPeTPURAuG4AJ99GTMcebuVoewultL4O7SUO3JM+gCfap4R
D0TIbYr8xMjW1P2QT4ms5YU=
=I8zO
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]