chiark / gitweb /
Fixed bug in SET-PACKAGE-PREFIX
[clg] / glib / gobject.lisp
index 3c67fe03c848e6f05616314fe2a239a6d946cd37..a0631dc8bff8b0d6a2a5eebe21c4c7d97776de89 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: gobject.lisp,v 1.46 2006-02-09 22:29:01 espen Exp $
+;; $Id: gobject.lisp,v 1.50 2006-02-26 15:30:01 espen Exp $
 
 (in-package "GLIB")
 
@@ -64,7 +64,9 @@ (defbinding %object-unref () nil
 
 #+glib2.8
 (progn
-  (defcallback toggle-ref-callback (nil (data pointer) (location pointer) (last-ref-p boolean))
+  (define-callback toggle-ref-callback nil
+      ((data pointer) (location pointer) (last-ref-p boolean))
+    (declare (ignore data))
     #+debug-ref-counting
     (if last-ref-p
        (format t "Object at 0x~8,'0X has no foreign references~%" (sap-int location))
@@ -73,14 +75,14 @@   (defcallback toggle-ref-callback (nil (data pointer) (location pointer) (last-
        (cache-instance (find-cached-instance location) t)
       (cache-instance (find-cached-instance location) nil)))
 
-  (defbinding %object-add-toggle-ref () pointer
+  (defbinding %object-add-toggle-ref (location) pointer
     (location pointer)
-    ((callback toggle-ref-callback) pointer)
+    (toggle-ref-callback callback)
     (nil null))
 
-  (defbinding %object-remove-toggle-ref () pointer
+  (defbinding %object-remove-toggle-ref (location) pointer
     (location pointer)
-    ((callback toggle-ref-callback) pointer)
+    (toggle-ref-callback callback)
     (nil null)))
 
 (defmethod reference-foreign ((class gobject-class) location)
@@ -93,12 +95,12 @@ (defmethod unreference-foreign ((class gobject-class) location)
 
 #+debug-ref-counting
 (progn
-  (defcallback weak-ref-callback (nil (data pointer) (location pointer))
+  (define-callback weak-ref-callback nil ((data pointer) (location pointer))
     (format t "Object at 0x~8,'0X being finalized~%" (sap-int location)))
   
-  (defbinding %object-weak-ref () pointer
+  (defbinding %object-weak-ref (location) pointer
     (location pointer)
-    ((callback weak-ref-callback) pointer)
+    (weak-ref-callback callback)
     (nil null)))
 
 
@@ -128,7 +130,7 @@ (defmethod effective-slot-definition-class ((class gobject-class) &rest initargs
     (t (call-next-method))))
 
 (defmethod compute-effective-slot-definition-initargs ((class gobject-class) direct-slotds)
-  (if (typep (first direct-slotds) 'direct-property-slot-definition)
+  (if (eq (slot-definition-allocation (first direct-slotds)) :property)
       (nconc 
        (list :pname (signal-name-to-string 
                     (most-specific-slot-value direct-slotds 'pname
@@ -214,7 +216,6 @@ (defmethod shared-initialize :after ((class gobject-class) names &rest initargs)
     (setf (slot-value class 'instance-slots-p) t)))
 
 
-
 ;;;; Super class for all classes in the GObject type hierarchy
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
@@ -224,6 +225,9 @@   (defclass gobject (ginstance)
     (:metaclass gobject-class)
     (:gtype "GObject")))
 
+(define-type-method callback-from-alien-form ((type gobject) form)
+  (from-alien-form type form))
+
 #+debug-ref-counting
 (defmethod print-object ((instance gobject) stream)
   (print-unreadable-object (instance stream :type t :identity nil)
@@ -381,16 +385,14 @@ (defbinding %object-set-qdata-full () nil
   (object gobject)
   (id quark)
   (data unsigned-long)
-  (destroy-marshal pointer))
+  (destroy-marshal callback))
 
-(defcallback user-data-destroy-func (nil (id unsigned-int))
+(define-callback user-data-destroy-callback nil ((id unsigned-int))
   (destroy-user-data id))
 
-(export 'user-data-destroy-func)
-
 (defun (setf user-data) (data object key)
   (%object-set-qdata-full object (quark-intern key)
-   (register-user-data data) (callback user-data-destroy-func))
+   (register-user-data data) user-data-destroy-callback)
   data)
 
 ;; deprecated
@@ -555,16 +557,17 @@ (register-derivable-type 'gobject "GObject" 'expand-gobject-type 'gobject-depend
 ;;; Pseudo type for gobject instances which have their reference count
 ;;; increased by the returning function
 
-(defmethod alien-type ((type (eql 'referenced)) &rest args)
-  (declare (ignore type args))
-  (alien-type 'gobject))
+;; (deftype referenced (type) type)
 
-(defmethod from-alien-form (form (type (eql 'referenced)) &rest args)
+(define-type-method alien-type ((type referenced))
   (declare (ignore type))
-  (destructuring-bind (type) args
+  (alien-type 'gobject))
+
+(define-type-method from-alien-form ((type referenced) form)
+  (let ((type (second type)))
     (if (subtypep type 'gobject)
        (let ((instance (make-symbol "INSTANCE")))
-         `(let ((,instance ,(from-alien-form form type)))
+         `(let ((,instance ,(from-alien-form type form)))
             (when ,instance
               (%object-unref (foreign-location ,instance)))
             ,instance))