1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /* $Id: callback.c,v 1.8 2002-03-24 12:49:18 espen Exp $ */
21 #include <glib-object.h>
28 lispobj callback_trampoline
;
29 lispobj destroy_user_data
;
33 void callback_marshal (guint callback_id
, GValue
*return_value
,
34 guint n_params
, const GValue
*param_values
)
37 funcall3 (callback_trampoline
, alloc_number ((unsigned int)callback_id
),
38 alloc_cons (alloc_number (n_params
), alloc_sap (param_values
)),
39 alloc_sap (return_value
));
41 callback_trampoline ((unsigned long)callback_id
,
42 n_params
, (unsigned int)param_values
,
43 (unsigned int)return_value
);
47 void destroy_notify (gpointer data
)
50 funcall1 (destroy_user_data
, alloc_number ((unsigned long)data
));
52 destroy_user_data ((unsigned long)data
);
58 /* destroy_notify_address () */
60 /* return (void*)destroy_notify; */
66 void closure_callback_marshal (GClosure
*closure
,
69 const GValue
*param_values
,
70 gpointer invocation_hint
,
71 gpointer marshal_data
)
73 callback_marshal ((guint
)closure
->data
, return_value
, n_params
, param_values
);
76 void closure_destroy_notify (gpointer data
, GClosure
*closure
)
78 destroy_notify (data
);
82 g_lisp_callback_closure_new (guint callback_id
)
86 closure
= g_closure_new_simple (sizeof (GClosure
), (gpointer
)callback_id
);
87 g_closure_set_marshal (closure
, closure_callback_marshal
);
88 g_closure_add_finalize_notifier (closure
, (gpointer
)callback_id
, closure_destroy_notify
);
94 gboolean
source_callback_marshal (gpointer data
)
98 memset (&return_value
, 0, sizeof (GValue
));
99 g_value_init (&return_value
, G_TYPE_BOOLEAN
);
100 callback_marshal ((guint
)data
, &return_value
, 0, NULL
);
102 return g_value_get_boolean (&return_value
);
108 g_enum_class_values (GEnumClass
*class, guint
*n_values
)
110 *n_values
= class->n_values
;
111 return class->values
;
115 g_flags_class_values (GFlagsClass
*class, guint
*n_values
)
117 *n_values
= class->n_values
;
118 return class->values
;