chiark / gitweb /
Changed PROXY-CLASS to work with forward referneced superclasses.
[clg] / glib / callback.c
CommitLineData
c8c48a4c 1/* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
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
f942a38c 19/* $Id: callback.c,v 1.3 2001-04-29 20:11:21 espen Exp $ */
c8c48a4c 20
21#include <gobject/gobject.h>
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
32void destroy_notify (gpointer data);
33
34
35void lisp_callback_marshal (GClosure *closure,
36 GValue *return_value,
37 guint n_params,
38 const GValue *param_values,
39 gpointer invocation_hint,
40 gpointer marshal_data)
41{
42#ifdef CMUCL
43 funcall3 (callback_trampoline, alloc_number ((unsigned int)closure->data),
44 alloc_cons (alloc_number (n_params), alloc_sap (param_values)),
45 alloc_sap (return_value));
46#elif defined(CLISP)
47 callback_trampoline ((unsigned long)closure->data,
48 n_params, (unsigned int)param_values,
49 (unsigned int)return_value);
50#endif
51}
52
53void closure_destroy_notify (gpointer callback_id, GClosure *closure)
54{
55 destroy_notify (callback_id);
56}
57
58void destroy_notify (gpointer data)
59{
60#ifdef CMUCL
61 funcall1 (destroy_user_data, alloc_number ((unsigned long)data));
62#elif defined(CLISP)
63 destroy_user_data ((unsigned long)data);
64#endif
65}
66
67GClosure*
e552920f 68g_lisp_callback_closure_new (guint callback_id)
c8c48a4c 69{
70 GClosure *closure;
71
72 closure = g_closure_new_simple (sizeof (GClosure), (gpointer)callback_id);
73 g_closure_set_marshal (closure, lisp_callback_marshal);
f942a38c 74 g_closure_add_finalize_notifier (closure, (gpointer)callback_id, closure_destroy_notify);
c8c48a4c 75
76 return closure;
77}
78
79#ifndef CMUCL
80void*
81destroy_notify_address ()
82{
83 return (void*)destroy_notify;
84}
85#endif
f942a38c 86
87
88GList*
89g_object_class_properties (GObjectClass *class)
90{
91 GList *list = NULL;
92 int i;
93
94 for (i = 0; i < class->n_property_specs; i++)
95 list = g_list_append (list, class->property_specs[i]);
96
97 return list;
98}
99
100#include <gobject/genums.h>
101GList*
102g_enum_class_values (GEnumClass *class)
103{
104 GList *list = NULL;
105 int i;
106
107 for (i = 0; i < class->n_values; i++)
108 list = g_list_append (list, &class->values[i]);
109
110 return list;
111}
112
113GList*
114g_flags_class_values (GFlagsClass *class)
115{
116 GList *list = NULL;
117 int i;
118
119 for (i = 0; i < class->n_values; i++)
120 list = g_list_append (list, &class->values[i]);
121
122 return list;
123}
124