GNOME Bugzilla – Bug 353816
PyGobject signals can't be used from C applications
Last modified: 2007-04-29 21:48:07 UTC
Signals created on PyGObject don't provide a C Marshaller: signal_id = g_signal_newv(signal_name, instance_type, signal_flags, pyg_signal_class_closure_get(), accumulator, accum_data, (GSignalCMarshaller)0, return_type, n_params, param_types); This means we can't connect to those signals from a C application.
The only way to fix this would be to have a generic marshaller, which would then use libffi to invoke the signal handler.
I agree on using libffi, I'm checking that right now.
A solution based on libffi would be generic enough for all programs and all language bindings, including C. So it probably belongs in GLib. Code generation for the marshallers would then become redundant. Also, there's some relation with gobject-introspection: they both need libffi.
Some people won't agree to using a libffi-based c_marshaller because it requires more computing than hardcoded ones, and is not guaranteed to work on all platforms. Maybe it could be used if no c_marshaller is specified.
What's the alternative to libffi?
Created attachment 81361 [details] [review] patch Inclusion of patch from bug 401080 against pygobject. Requires C/Invoke which can be fetched from http://www.nongnu.org/cinvoke/
Created attachment 81377 [details] [review] v2: conditional C/Invoke and libffi support with autotools-fu included. I'll commit this after we branch for glib 2.14 if there are no objections.
Comment on attachment 81377 [details] [review] v2: conditional C/Invoke and libffi support with autotools-fu included. >Index: gobject/Makefile.am >=================================================================== >--- gobject/Makefile.am (revision 636) >+++ gobject/Makefile.am (arbetskopia) >@@ -43,3 +43,11 @@ > if PLATFORM_WIN32 > _gobject_la_CFLAGS += -DPLATFORM_WIN32 > endif >+ >+if HAVE_LIBFFI >+_gobject_la_LIBADD += -lffi >+else >+if HAVE_CINVOKE >+_gobject_la_LIBADD += -lcinvoke >+endif >+endif Needs corresponding .pc.in file changes.
I committed the ffi version of the marshaller. A ffi snapshot is not included in pygobject, we have an external dependency on it instead. Ubuntu feisty includes a snapshot of the ffi marshaller which this patch was developed against. Enviando ChangeLog Enviando README Enviando configure.ac Enviando gobject/Makefile.am Adicionando gobject/ffi-marshaller.c Adicionando gobject/ffi-marshaller.h Enviando gobject/gobjectmodule.c Enviando pygobject-2.0.pc.in Enviando tests/test_signal.py Enviando tests/testhelpermodule.c Transmitindo dados do arquivo .......... Commit da revisão 651.