chiark / gitweb /
Renamed dialog class slot vbox to main-area
[clg] / glib / callback.c
CommitLineData
c8c48a4c 1/* Common Lisp bindings for GTK+ v2.0
e911838b 2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
c8c48a4c 3 *
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.
8 *
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.
13 *
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
17 */
18
e911838b 19/* $Id: callback.c,v 1.8 2002-03-24 12:49:18 espen Exp $ */
c8c48a4c 20
f784870f 21#include <glib-object.h>
c8c48a4c 22
23#ifdef CMUCL
24#include "lisp.h"
25#include "alloc.h"
26#include "arch.h"
27
28lispobj callback_trampoline;
29lispobj destroy_user_data;
30#endif
31
c8c48a4c 32
ca8ae1cc 33void callback_marshal (guint callback_id, GValue *return_value,
34 guint n_params, const GValue *param_values)
c8c48a4c 35{
36#ifdef CMUCL
ca8ae1cc 37 funcall3 (callback_trampoline, alloc_number ((unsigned int)callback_id),
c8c48a4c 38 alloc_cons (alloc_number (n_params), alloc_sap (param_values)),
39 alloc_sap (return_value));
40#elif defined(CLISP)
ca8ae1cc 41 callback_trampoline ((unsigned long)callback_id,
c8c48a4c 42 n_params, (unsigned int)param_values,
43 (unsigned int)return_value);
44#endif
45}
46
c8c48a4c 47void destroy_notify (gpointer data)
48{
49#ifdef CMUCL
50 funcall1 (destroy_user_data, alloc_number ((unsigned long)data));
51#elif defined(CLISP)
52 destroy_user_data ((unsigned long)data);
53#endif
54}
55
ca8ae1cc 56/* #ifndef CMUCL */
57/* void* */
58/* destroy_notify_address () */
59/* { */
60/* return (void*)destroy_notify; */
61/* } */
62/* #endif */
63
64
65
66void closure_callback_marshal (GClosure *closure,
67 GValue *return_value,
68 guint n_params,
69 const GValue *param_values,
70 gpointer invocation_hint,
71 gpointer marshal_data)
72{
73 callback_marshal ((guint)closure->data, return_value, n_params, param_values);
74}
75
76void closure_destroy_notify (gpointer data, GClosure *closure)
77{
78 destroy_notify (data);
79}
80
c8c48a4c 81GClosure*
e552920f 82g_lisp_callback_closure_new (guint callback_id)
c8c48a4c 83{
84 GClosure *closure;
85
86 closure = g_closure_new_simple (sizeof (GClosure), (gpointer)callback_id);
ca8ae1cc 87 g_closure_set_marshal (closure, closure_callback_marshal);
f942a38c 88 g_closure_add_finalize_notifier (closure, (gpointer)callback_id, closure_destroy_notify);
c8c48a4c 89
90 return closure;
91}
92
ca8ae1cc 93
94gboolean source_callback_marshal (gpointer data)
c8c48a4c 95{
ca8ae1cc 96 GValue return_value;
97
e911838b 98 memset (&return_value, 0, sizeof (GValue));
99 g_value_init (&return_value, G_TYPE_BOOLEAN);
ca8ae1cc 100 callback_marshal ((guint)data, &return_value, 0, NULL);
101
102 return g_value_get_boolean (&return_value);
c8c48a4c 103}
ca8ae1cc 104
f942a38c 105
106
1931a598 107GEnumValue*
108g_enum_class_values (GEnumClass *class, guint *n_values)
f942a38c 109{
1931a598 110 *n_values = class->n_values;
111 return class->values;
f942a38c 112}
113
1931a598 114GFlagsValue*
115g_flags_class_values (GFlagsClass *class, guint *n_values)
f942a38c 116{
1931a598 117 *n_values = class->n_values;
118 return class->values;
f942a38c 119}
120