[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g-io-add-watch, GIOFunc?
From: |
Jan Nieuwenhuizen |
Subject: |
Re: g-io-add-watch, GIOFunc? |
Date: |
Fri, 22 Oct 2004 01:55:30 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
Jan Nieuwenhuizen writes:
> Duh. I keep falling for this same kind of error. I'll add a wrapper.
This is harder than I thought. I made a patch that works reasonably,
but it crashes here
+ scm_c_gtype_instance_to_scm ((GTypeInstance*) source),
where it turns out that source is garbage... Note that this source
should be a channel, which is created and called using
(define (bindings-callback source condition)
(display "FIFO\n"))
(let ((channel (g-io-channel-new-file BINDINGS-FIFO)))
(g-io-add-watch channel 'in bindings-callback)))
Could this be related to not using (make <g-io-channel>) ? And if so,
it seems I really need channel-new-file.
There is something I do not understand, why are some GIOChannel
related C functions wrapped as GIOChannel methods, and others as
functions?
Jan.
* looking for address@hidden/glib--janneke--0--patch-1 to compare with
* comparing to address@hidden/glib--janneke--0--patch-1
M ChangeLog
M gnome/gw/glib-support.h
M gnome/overrides/glib.defs
M gnome/gw/Makefile.am
M gnome/gw/glib-support.c
* modified files
--- orig/ChangeLog
+++ mod/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-21 Jan Nieuwenhuizen <address@hidden>
+
+ * gnome/gw/glib-support.c (_wrap_g_io_add_watch):
+ * gnome/overrides/glib.defs: New function.
+
2004-10-12 Andreas Rottmann <address@hidden>
* shlib-dirs.ac: New file, to be used by dev-environ.
--- orig/gnome/gw/Makefile.am
+++ mod/gnome/gw/Makefile.am
@@ -29,9 +29,10 @@
nodist_libgw_guile_gnome_gobject_la_SOURCES = guile-gnome-gw-gobject.c
libgw_guile_gnome_gobject_la_CFLAGS = -I$(srcdir)/../gobject -I../gobject \
- $(AM_CFLAGS) $(GOBJECT_CFLAGS) $(GUILE_CFLAGS) $(G_WRAP_CFLAGS)
+ $(AM_CFLAGS) $(GOBJECT_CFLAGS) $(GUILE_CFLAGS) $(G_WRAP_CFLAGS) \
+ $(GUILE_GLIB_CFLAGS)
libgw_guile_gnome_gobject_la_LIBADD = $(G_WRAP_LIBS) $(GOBJECT_LIBS) \
- $(GUILE_LIBS) \
+ $(GUILE_LIBS) $(GUILE_GLIB_LIBS) \
../gobject/libguile-gnome-gobject.la
libgw_guile_gnome_gobject_la_LDFLAGS = -module
@@ -42,9 +43,10 @@
nodist_libgw_guile_gnome_glib_la_SOURCES = guile-gnome-gw-glib.c
libgw_guile_gnome_glib_la_SOURCES = glib-support.c
libgw_guile_gnome_glib_la_CFLAGS = \
- $(AM_CFLAGS) $(GLIB_CFLAGS) $(GUILE_CFLAGS) $(G_WRAP_CFLAGS)
+ $(AM_CFLAGS) $(GLIB_CFLAGS) $(GUILE_CFLAGS) $(G_WRAP_CFLAGS) \
+ $(GUILE_GLIB_CFLAGS)
libgw_guile_gnome_glib_la_LIBADD = $(GLIB_LIBS) $(GUILE_LIBS) \
- $(G_WRAP_LIBS)
+ $(G_WRAP_LIBS) $(GUILE_GLIB_LIBS)
libgw_guile_gnome_glib_la_LDFLAGS = -module
BUILT_SOURCES = \
--- orig/gnome/gw/glib-support.c
+++ mod/gnome/gw/glib-support.c
@@ -99,3 +99,37 @@
{
return scm_mem2string (str->str, str->len);
}
+
+static gboolean
+g_io_func (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data)
+{
+ SCM proc;
+ SCM result;
+
+ proc = SCM_PACK (GPOINTER_TO_INT (data));
+#if 0
+ result = scm_call_2 (proc,
+ scm_c_gtype_instance_to_scm ((GTypeInstance*) source),
+ scm_long2num (condition));
+#else
+ result = scm_call_2 (proc, SCM_BOOL_F, scm_long2num (condition));
+#endif
+
+ return scm_num2int (result, 0, "g_io_func");
+}
+
+guint
+_wrap_g_io_add_watch (GIOChannel *channel,
+ GIOCondition condition,
+ SCM func)
+#define FUNC_NAME "g-io-add-watch"
+{
+ SCM_VALIDATE_PROC (3, func);
+ return g_io_add_watch (channel,
+ condition,
+ ((GIOFunc) (g_io_func)),
+ GINT_TO_POINTER (SCM_UNPACK (func)));
+}
+#undef FUNC_NAME
--- orig/gnome/gw/glib-support.h
+++ mod/gnome/gw/glib-support.h
@@ -26,12 +26,14 @@
#include <glib.h>
#include <libguile.h>
+#include "guile-gnome-gobject.h"
G_BEGIN_DECLS
void scm_init_glib (void);
void _wrap_g_main_loop_run (GMainLoop *loop);
SCM _wrap_g_string_get_str (GString *str);
+guint _wrap_g_io_add_watch (GIOChannel *channel, GIOCondition condition, SCM
func);
G_END_DECLS
--- orig/gnome/overrides/glib.defs
+++ mod/gnome/overrides/glib.defs
@@ -37,6 +37,15 @@
(c-name "_wrap_g_string_get_str")
(return-type "SCM"))
+(define-function g_io_add_watch
+ (c-name "_wrap_g_io_add_watch")
+ (overrides "g_io_add_watch")
+ (return-type "gboolean")
+ (parameters
+ '("GIOChannel*" "channel")
+ '("GIOCondition" "condition")
+ '("SCM" "func")))
+
(ignore-glob "_*"
"*_copy"
"*_newv"
@@ -49,6 +58,7 @@
"g_timeout_remove*"
"g_idle_add*"
"g_idle_remove*"
+ "g_io_add_watch"
"g_error_*"
"g_child_watch_add*"
"g_parse_debug_string"
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org