chiark / gitweb /
Changed to do some more stuff at compile time
[clg] / glib / gboxed.lisp
CommitLineData
94f15c3c 1;; Common Lisp bindings for GTK+ v2.0
2;; Copyright (C) 2001 Espen S. Johnsen <esj@stud.cs.uit.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
d4b21b08 18;; $Id: gboxed.lisp,v 1.3 2001-05-11 16:04:33 espen Exp $
94f15c3c 19
20(in-package "GLIB")
21
22
23(eval-when (:compile-toplevel :load-toplevel :execute)
7479d92c 24 (defclass boxed (proxy)
94f15c3c 25 ()
d4b21b08 26 (:metaclass proxy-class)
27 (:copy %boxed-copy)
28 (:free %boxed-free)))
29
30(defbinding %boxed-copy (type location) pointer
31 ((find-type-number type) type-number)
94f15c3c 32 (location pointer))
33
d4b21b08 34(defbinding %boxed-free (type location) nil
35 ((find-type-number type) type-number)
94f15c3c 36 (location pointer))
37
38
39;;;; Metaclass for boxed classes
40
41(eval-when (:compile-toplevel :load-toplevel :execute)
42 (defclass boxed-class (proxy-class)))
43
44
45(defmethod shared-initialize ((class boxed-class) names
d4b21b08 46 &rest initargs &key name alien-name)
94f15c3c 47 (declare (ignore initargs names))
48 (call-next-method)
49
50 (let* ((class-name (or name (class-name class)))
51 (type-number
d4b21b08 52 (find-type-number
53 (or (first alien-name) (default-alien-type-name class-name)))))
54 (register-type class-name type-number)))
94f15c3c 55
56
57(defmethod validate-superclass
58 ((class boxed-class) (super pcl::standard-class))
59 (subtypep (class-name super) 'boxed))
60
61
d4b21b08 62;;;;
63
64(defun expand-boxed-type (type-number &optional slots)
65 `(defclass ,(type-from-number type-number) (boxed)
66 ,slots
67 (:metaclass boxed-class)
68 (:alien-name ,(find-type-name type-number))))
94f15c3c 69
d4b21b08 70(register-derivable-type 'boxed "GBoxed" :expand 'expand-boxed-type)