anchor.diff:  (setf (alien-type-name 'unsigned-int) "guint")
   (setf (alien-type-name 'long) "glong")
   (setf (alien-type-name 'unsigned-long) "gulong")
  -(setf (alien-type-name 'enum) "GEnum")
  -(setf (alien-type-name 'flags) "GFlags")
   (setf (alien-type-name 'single-float) "gfloat")
   (setf (alien-type-name 'double-float) "gdouble")
  -(setf (alien-type-name 'string) "gstring")
  +(setf (alien-type-name 'string) "GString")
   (setf (find-type-number 'fixnum) (find-type-number 'int))
  
positive.code: ;; 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: gtype.lisp,v 1.7 2001-01-28 14:11:20 espen Exp $
  
  (in-package "GLIB")
  
  
negative.code: (defun type-number-of (object)
    (find-type-number (type-of object)))
  
  (defun alien-function (name return-type &rest arg-types)
    (let ((alien
  	 (alien::%heap-alien
  	  (alien::make-heap-alien-info
  	   :type (alien::parse-alien-type
  		  `(function ,@(cons return-type arg-types)))
  	   :sap-form (system:foreign-symbol-address name)))))
      #'(lambda (&rest args)
  	(apply #'alien:alien-funcall alien args))))
  
  
  (defun type-init (name &optional init-fname)
    (funcall
     (alien-function
      (or
       init-fname
       (default-alien-fname (format nil "~A_get_type" name)))
      '(unsigned 32))))
  
  
  ;;;; Superclass for wrapping types in the glib type system
  
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (defclass ginstance (proxy)
      ()
      (:metaclass proxy-class)
      (:size 4 #|(size-of 'pointer|#)))
  
  (defmethod initialize-proxy ((instance ginstance) &rest initargs &key location)
    (declare (ignore initargs))
    (setf 
     (slot-value instance 'location)
     (funcall (ginstance-class-ref (class-of instance)) location))
    (call-next-method))
  
  (defmethod instance-finalizer ((instance ginstance))
    (let ((location (proxy-location instance))
  	(unref (ginstance-class-unref (class-of instance))))
      (declare (type system-area-pointer location))
      #'(lambda ()
  	(funcall unref location)
  	(remove-cached-instance location))))
  
  (defun %type-of-ginstance (location)
    (let ((class (sap-ref-sap location 0)))
      (type-from-number (sap-ref-unsigned class 0))))
  
  (deftype-method translate-from-alien
      ginstance (type-spec location &optional weak-ref)
    (declare (ignore type-spec))
    `(let ((location ,location))
       (unless (null-pointer-p location)
         (ensure-proxy-instance
  	(%type-of-ginstance location) location ,weak-ref))))
  
  (deftype-method translate-to-alien
      ginstance (type-spec object &optional weak-ref)
    (declare (ignore type-spec))
    (if weak-ref
        `(proxy-location ,object)
      `(let ((object ,object))
         (funcall
  	(ginstance-class-ref (class-of object)) (proxy-location object)))))
  
  (deftype-method unreference-alien ginstance (type-spec location)
    (declare (ignore type-spec))
    `(let* ((location ,location)
  	  (class (find-class (%type-of-ginstance location))))
       (funcall (ginstance-class-unref class) location)))
  
  
  
  ;;;; Metaclass for subclasses of ginstance
  
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (defclass ginstance-class (proxy-class)
      ((ref :reader ginstance-class-ref)
       (unref :reader ginstance-class-unref))))
  
  
  (defmethod shared-initialize ((class ginstance-class) names
  			      &rest initargs
  			      &key name alien-name size
  			      ref unref type-init)
    (declare (ignore initargs names))
    (call-next-method)
  
    (let* ((class-name (or name (class-name class)))
  	 (type-number
  	  (cond
  	   ((and alien-name type-init)
  	    (error
  	     "Specify either :type-init or :alien-name for class ~A"
  	     class-name))
  	   (alien-name (type-number-from-alien-name (first alien-name)))
  	   (type-init (type-init class-name (first type-init)))
  	   (t
  	    (or
  	     (type-number-from-alien-name
  	      (default-alien-type-name class-name) nil)
  	     (type-init class-name))))))
      (setf (find-type-number class) type-number)
      (unless size
        (setf
         (slot-value class 'size)
         (type-instance-size (find-type-number class-name))))
      (when ref
        (setf
         (slot-value class 'ref)
         (alien-function (first ref) 'system-area-pointer 'system-area-pointer)))
      (when unref
        (setf
         (slot-value class 'unref)
         (alien-function (first unref) 'void 'system-area-pointer)))))
  
  (defmethod shared-initialize :after ((class ginstance-class) names
  				     &rest initargs)
    (declare (ignore names initargs))
    (unless (slot-boundp class 'ref)
      (setf
       (slot-value class 'ref)
       (ginstance-class-ref (most-specific-proxy-superclass class))))
    (unless (slot-boundp class 'unref)
      (setf
       (slot-value class 'unref)
       (ginstance-class-unref (most-specific-proxy-superclass class)))))
  
  
  (defmethod validate-superclass
      ((class ginstance-class) (super pcl::standard-class))
    (subtypep (class-name super) 'ginstance))
  
  
  ;;;; Initializing type numbers
  