Adding support for glib interfaces (GInterface)
[clg] / glib / proxy.lisp
index 6484cac..4176447 100644 (file)
@@ -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: proxy.lisp,v 1.3 2001-05-04 16:56:34 espen Exp $
+;; $Id: proxy.lisp,v 1.6 2001-10-21 16:55:39 espen Exp $
 
 (in-package "GLIB")
 
   (if weak-ref
       `(proxy-location ,instance)
     `(funcall
-      (proxy-class-copy (find-class ',type-spec))
+      ',(proxy-class-copy (find-class type-spec))
       ',type-spec (proxy-location ,instance))))
 
 (deftype-method unreference-alien proxy (type-spec location)
-  `(funcall (proxy-class-free (find-class ',type-spec)) ',type-spec ,location))
+  `(funcall ',(proxy-class-free (find-class type-spec)) ',type-spec ,location))
 
 (defun proxy-instance-size (proxy)
   (proxy-class-size (class-of proxy)))
 
   (defmethod finalize-inheritance ((class proxy-class))
     (call-next-method)
-    (let ((super (direct-proxy-superclass class)))
-      (unless (typep super 'proxy)
+    (let ((super (most-specific-proxy-superclass class)))
+      (unless (or (not super) (eq super (find-class 'proxy)))
        (unless (or (slot-boundp class 'copy) (not (slot-boundp super 'copy)))
          (setf (slot-value class 'copy) (proxy-class-copy super)))
        (unless (or (slot-boundp class 'free) (not (slot-boundp super 'free)))
        (with-slots (type) slotd
          (list
           (if (stringp getter)
-              (mkbinding getter type class-name)
+              (let ((getter (mkbinding-late getter type 'pointer)))
+                #'(lambda (object)
+                    (funcall getter (proxy-location object))))
             getter)
           (if (stringp setter)
-              (let ((setter (mkbinding setter 'nil class-name type)))
+              (let ((setter (mkbinding-late setter 'nil 'pointer type)))
                 #'(lambda (value object)
-                    (funcall setter object value)))
+                    (funcall setter (proxy-location object) value)))
             setter))))))
 
   (defmethod compute-slots ((class proxy-class))
   (defmethod validate-superclass ((class proxy-class)
                                  (super pcl::standard-class))
     (subtypep (class-name super) 'proxy))
-  
+
   (defmethod proxy-class-size (class)
     (declare (ignore class))
     0)
     (:copy %copy-struct)
     (:free %free-struct)))
 
-
 (defmethod initialize-instance ((structure struct)
                                &rest initargs)
   (declare (ignore initargs))
   (deallocate-memory location))
 
 
-(eval-when (:compile-toplevel :load-toplevel :execute)
+;(eval-when (:compile-toplevel :load-toplevel :execute)
   (defclass static (struct)
     ()
-    (:metaclass proxy-class)))
+    (:metaclass proxy-class)
+    (:copy %copy-static)
+    (:free %free-static));)
 
 (defun %copy-static (type location)
   (declare (ignore type))