24af32f5 |
1 | ;; Common Lisp bindings for GTK+ v2.0 |
2 | ;; Copyright (C) 2001 Espen S. Johnsen <espen@users.sourceforge.net> |
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 | |
935a783c |
18 | ;; $Id: ginterface.lisp,v 1.2 2004/10/27 14:58:59 espen Exp $ |
24af32f5 |
19 | |
20 | (in-package "GLIB") |
21 | |
22 | (use-prefix "g") |
23 | |
24 | ;;;; |
25 | |
935a783c |
26 | (defclass ginterface () |
27 | ()) |
24af32f5 |
28 | |
29 | (deftype-method translate-type-spec ginterface (type-spec) |
30 | (declare (ignore type-spec)) |
31 | (translate-type-spec 'gobject)) |
32 | |
33 | (deftype-method size-of ginterface (type-spec) |
34 | (declare (ignore type-spec)) |
35 | (size-of 'gobject)) |
36 | |
37 | (deftype-method translate-from-alien |
38 | ginterface (type-spec location &optional weak-ref) |
39 | (declare (ignore type-spec)) |
40 | (translate-from-alien 'gobject location weak-ref)) |
41 | |
42 | (deftype-method translate-to-alien |
43 | ginterface (type-spec instance &optional weak-ref) |
44 | (declare (ignore type-spec)) |
45 | (translate-to-alien 'gobject instance weak-ref)) |
46 | |
47 | |
48 | |
49 | ;;;; Metaclass for interfaces |
50 | |
51 | (eval-when (:compile-toplevel :load-toplevel :execute) |
935a783c |
52 | (defclass ginterface-class (virtual-slot-class) |
53 | ())) |
24af32f5 |
54 | |
55 | |
56 | (defmethod shared-initialize ((class ginterface-class) names |
57 | &rest initargs &key name alien-name) |
58 | (declare (ignore initargs names)) |
59 | (let* ((class-name (or name (class-name class))) |
60 | (type-number |
61 | (find-type-number |
62 | (or (first alien-name) (default-alien-type-name class-name)) t))) |
63 | (register-type class-name type-number)) |
64 | (call-next-method)) |
65 | |
66 | |
67 | (defmethod validate-superclass |
68 | ((class ginterface-class) (super pcl::standard-class)) |
69 | (subtypep (class-name super) 'ginterface)) |
70 | |
71 | |
72 | ;;;; |
73 | |
935a783c |
74 | (defun expand-ginterface-type (type-number options &rest args) |
24af32f5 |
75 | (declare (ignore args)) |
76 | `(defclass ,(type-from-number type-number) (ginterface) |
935a783c |
77 | ,(getf options :slots) |
24af32f5 |
78 | (:metaclass ginterface-class) |
79 | (:alien-name ,(find-type-name type-number)))) |
80 | |
81 | |
82 | (register-derivable-type 'ginterface "GInterface" 'expand-ginterface-type) |