chiark / gitweb /
Cleanup in callback marshalers
authorespen <espen>
Tue, 19 Mar 2002 17:12:18 +0000 (17:12 +0000)
committerespen <espen>
Tue, 19 Mar 2002 17:12:18 +0000 (17:12 +0000)
glib/callback.c

index 1fa8cc1df254638ff18aa0d3407243cfc5ba4c10..c44dd954ea5c124829455f99939347a0cb52510f 100644 (file)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* $Id: callback.c,v 1.6 2001-12-12 20:24:41 espen Exp $ */
+/* $Id: callback.c,v 1.7 2002-03-19 17:12:18 espen Exp $ */
 
 #include <glib-object.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,25 +53,54 @@ 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_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;  
+  
+  return_value.g_type = G_TYPE_BOOLEAN;
+  callback_marshal ((guint)data, &return_value, 0, NULL);
+
+  return g_value_get_boolean (&return_value);
 }
-#endif
+
 
 
 GEnumValue*