chiark / gitweb /
Fixed a few bugs
[clg] / glib / gobject.lisp
index f0d33b4119393ea8522e0303be73587a59df3c5a..9f560d2b97de17d85b78c8ae9f87f9b5fd1ed3d7 100644 (file)
@@ -1,5 +1,5 @@
 ;; Common Lisp bindings for GTK+ v2.0
-;; Copyright (C) 2000 Espen S. Johnsen <esj@stud.cs.uit.no>
+;; Copyright (C) 2000-2001 Espen S. Johnsen <esj@stud.cs.uit.no>
 ;;
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -15,7 +15,7 @@
 ;; License along with this library; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-;; $Id: gobject.lisp,v 1.4 2001-01-28 14:17:12 espen Exp $
+;; $Id: gobject.lisp,v 1.6 2001-04-29 20:34:18 espen Exp $
 
 (in-package "GLIB")
 
@@ -24,66 +24,45 @@ (eval-when (:compile-toplevel :load-toplevel :execute)
   (defclass gobject (ginstance)
     ()
     (:metaclass ginstance-class)
-    (:alien-name "GObject")))
+    (:alien-name "GObject")
+    (:ref "g_object_ref")
+    (:unref "g_object_unref")))
 
+(defmethod initialize-instance ((object gobject) &rest initargs)
+  (declare (ignore initargs))
+  (setf 
+   (slot-value object 'location)
+   (%gobject-new (type-number-of object)))
+  (call-next-method))
 
-;;;; Object construction
-
-(define-foreign ("g_object_new" %gobject-new) () gobject
+(defbinding ("g_object_new" %gobject-new) () gobject
   (type type-number)
   (nil null))
 
 
-;;;; Reference counting for gobject
-
-;; Specializing reference-instance and unreference-instance on gobject
-;; is not really necessary but done for efficiency
-
-(defmethod reference-instance ((object gobject))
-  (%object-ref object)
-  object)
-
-(defmethod unreference-instance ((object gobject))
-  (%object-unref object))
-
-(deftype-method alien-ref gobject (type-spec)
-  (declare (ignore type-spec))
-  '%object-ref)
-
-(deftype-method alien-unref gobject (type-spec)
-  (declare (ignore type-spec))
-  '%object-unref)
-
-(define-foreign %object-ref () pointer
-  (object (or gobject pointer)))
-
-(define-foreign %object-unref () nil
-  (object (or gobject pointer)))
-
-
 ;;;; Parameter stuff
 
-(define-foreign %object-set-property () nil
+(defbinding %object-set-property () nil
   (object gobject)
   (name string)
   (value gvalue))
 
-(define-foreign %object-get-property () nil
+(defbinding %object-get-property () nil
   (object gobject)
   (name string)
   (value gvalue))
 
-(define-foreign %object-notify () nil
+(defbinding %object-notify () nil
   (object gobject)
   (name string))
 
-(define-foreign object-freeze-notify () nil
+(defbinding object-freeze-notify () nil
   (object gobject))
 
-(define-foreign object-thaw-notify () nil
+(defbinding object-thaw-notify () nil
   (object gobject))
 
-(define-foreign %object-set-qdata-full () nil
+(defbinding %object-set-qdata-full () nil
   (object gobject)
   (id quark)
   (data unsigned-long)
@@ -98,7 +77,7 @@ (defun (setf object-data) (data object key &key (test #'eq))
    (register-user-data data) *destroy-notify*)
   data)
 
-(define-foreign %object-get-qdata () unsigned-long
+(defbinding %object-get-qdata () unsigned-long
   (object gobject)              
   (id quark))
 
@@ -118,32 +97,13 @@   (defclass direct-gobject-slot-definition (direct-virtual-slot-definition))
   (defclass effective-gobject-slot-definition
     (effective-virtual-slot-definition)))
 
-(defmethod allocate-alien-storage ((class gobject-class))
-  (alien-instance-location (%gobject-new (find-type-number class))))
-
-(defmethod shared-initialize ((class gobject-class) names &rest initargs
-                             &key type-init name)
-  (declare (ignore initargs names))
-  (let ((alien
-        (alien::%heap-alien
-         (alien::make-heap-alien-info
-          :type (alien::parse-alien-type '(function (unsigned 32)))
-          :sap-form (system:foreign-symbol-address
-                     (or
-                      (first type-init)
-                      (default-alien-func-name
-                        (format
-                         nil "~A_get_type" (or name (class-name class))))))))))
-    (alien:alien-funcall alien))
-  (call-next-method))
-
 
-; (define-foreign object-class-install-param () nil
+; (defbinding object-class-install-param () nil
 ;   (class pointer)
 ;   (id unsigned-int)
 ;   (parameter parameter))
 
-; (define-foreign object-class-find-param-spec () parameter
+; (defbinding object-class-find-param-spec () parameter
 ;   (class pointer)
 ;   (name string))
 
@@ -172,9 +132,9 @@ (defmethod compute-virtual-slot-location
   (with-slots (type) slotd
     (let ((param-name (slot-definition-location (first direct-slotds)))
          (type-number (find-type-number type))
-         (reader (get-reader-function type))
-         (writer (get-writer-function type))
-         (destroy (get-destroy-function type)))
+         (reader (intern-reader-function type))
+         (writer (intern-writer-function type))
+         (destroy (intern-destroy-function type)))
       (list
        #'(lambda (object)
           (with-gc-disabled
@@ -196,3 +156,4 @@ (defmethod compute-virtual-slot-location
 (defmethod validate-superclass ((class gobject-class)
                                (super pcl::standard-class))
   (subtypep (class-name super) 'gobject))
+    
\ No newline at end of file