X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/e552920f34e91ff099e85c55e4bc160957f1716a..6c55b6c45a4096e7ecc359184d345206c9462639:/glib/callback.c diff --git a/glib/callback.c b/glib/callback.c index f818c4b..23d1a19 100644 --- a/glib/callback.c +++ b/glib/callback.c @@ -1,5 +1,5 @@ /* Common Lisp bindings for GTK+ v2.0 - * Copyright (C) 1999-2000 Espen S. Johnsen + * Copyright (C) 1999-2002 Espen S. Johnsen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,9 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: callback.c,v 1.2 2001-02-11 21:53:03 espen Exp $ */ +/* $Id: callback.c,v 1.8 2002-03-24 12:49:18 espen Exp $ */ -#include +#include #ifdef CMUCL #include "lisp.h" @@ -29,32 +29,21 @@ lispobj callback_trampoline; lispobj destroy_user_data; #endif -void destroy_notify (gpointer data); - -void lisp_callback_marshal (GClosure *closure, - GValue *return_value, - guint n_params, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) +void callback_marshal (guint callback_id, GValue *return_value, + guint n_params, const GValue *param_values) { #ifdef CMUCL - funcall3 (callback_trampoline, alloc_number ((unsigned int)closure->data), + funcall3 (callback_trampoline, alloc_number ((unsigned int)callback_id), alloc_cons (alloc_number (n_params), alloc_sap (param_values)), alloc_sap (return_value)); #elif defined(CLISP) - callback_trampoline ((unsigned long)closure->data, + callback_trampoline ((unsigned long)callback_id, n_params, (unsigned int)param_values, (unsigned int)return_value); #endif } -void closure_destroy_notify (gpointer callback_id, GClosure *closure) -{ - destroy_notify (callback_id); -} - void destroy_notify (gpointer data) { #ifdef CMUCL @@ -64,22 +53,68 @@ void destroy_notify (gpointer data) #endif } +/* #ifndef CMUCL */ +/* void* */ +/* destroy_notify_address () */ +/* { */ +/* return (void*)destroy_notify; */ +/* } */ +/* #endif */ + + + +void closure_callback_marshal (GClosure *closure, + GValue *return_value, + guint n_params, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + callback_marshal ((guint)closure->data, return_value, n_params, param_values); +} + +void closure_destroy_notify (gpointer data, GClosure *closure) +{ + destroy_notify (data); +} + GClosure* g_lisp_callback_closure_new (guint callback_id) { GClosure *closure; closure = g_closure_new_simple (sizeof (GClosure), (gpointer)callback_id); - g_closure_set_marshal (closure, lisp_callback_marshal); - g_closure_add_fnotify (closure, (gpointer)callback_id, closure_destroy_notify); + g_closure_set_marshal (closure, closure_callback_marshal); + g_closure_add_finalize_notifier (closure, (gpointer)callback_id, closure_destroy_notify); return closure; } -#ifndef CMUCL -void* -destroy_notify_address () + +gboolean source_callback_marshal (gpointer data) { - return (void*)destroy_notify; + GValue return_value; + + memset (&return_value, 0, sizeof (GValue)); + g_value_init (&return_value, G_TYPE_BOOLEAN); + callback_marshal ((guint)data, &return_value, 0, NULL); + + return g_value_get_boolean (&return_value); } -#endif + + + +GEnumValue* +g_enum_class_values (GEnumClass *class, guint *n_values) +{ + *n_values = class->n_values; + return class->values; +} + +GFlagsValue* +g_flags_class_values (GFlagsClass *class, guint *n_values) +{ + *n_values = class->n_values; + return class->values; +} +