chiark / gitweb /
Build instructions updated
[clg] / glib / glib.lisp
CommitLineData
560af5c5 1;; Common Lisp bindings for GTK+ v1.2.x
2;; Copyright (C) 1999 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
81a191e3 18;; $Id: glib.lisp,v 1.14 2004-10-31 11:37:11 espen Exp $
560af5c5 19
20
21(in-package "GLIB")
c4e9d221 22
560af5c5 23(use-prefix "g")
24
25
26;;;; Memory management
27
dba0c446 28(defbinding (allocate-memory "g_malloc0") () pointer
560af5c5 29 (size unsigned-long))
30
dba0c446 31(defbinding (reallocate-memory "g_realloc") () pointer
560af5c5 32 (address pointer)
33 (size unsigned-long))
34
3c657c71 35(defbinding (deallocate-memory "g_free") () nil
36 (address pointer))
37;(defun deallocate-memory (address)
38; (declare (ignore address)))
560af5c5 39
40(defun copy-memory (from length &optional (to (allocate-memory length)))
41 (kernel:system-area-copy from 0 to 0 (* 8 length))
42 to)
43
44
c4e9d221 45;;;; User data mechanism
46
47(internal *user-data* *user-data-count*)
48
49(declaim (fixnum *user-data-count*))
50
51(defvar *destroy-notify* (system:foreign-symbol-address "destroy_notify"))
52(defvar *user-data* (make-hash-table))
53(defvar *user-data-count* 0)
54
55(defun register-user-data (object &optional destroy-function)
56 (check-type destroy-function (or null symbol function))
57 (incf *user-data-count*)
58 (setf
59 (gethash *user-data-count* *user-data*)
60 (cons object destroy-function))
61 *user-data-count*)
62
63(defun find-user-data (id)
64 (check-type id fixnum)
65 (multiple-value-bind (user-data p) (gethash id *user-data*)
66 (values (car user-data) p)))
67
68(defun destroy-user-data (id)
69 (check-type id fixnum)
70 (let ((user-data (gethash id *user-data*)))
71 (when (cdr user-data)
72 (funcall (cdr user-data) (car user-data))))
73 (remhash id *user-data*))
74
75
560af5c5 76
0aef1da8 77;;;; Quarks
78
c4e9d221 79(internal *quark-counter* *quark-from-object* *quark-to-object*)
80
0aef1da8 81(deftype quark () 'unsigned)
82
5cae32e1 83;(defbinding %quark-get-reserved () quark)
415444ae 84
5cae32e1 85(defbinding %quark-from-string () quark
415444ae 86 (string string))
87
c4e9d221 88(defvar *quark-counter* 0)
415444ae 89
90(defun %quark-get-reserved ()
c4e9d221 91 ;; The string is just a dummy
92