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