+ (slot-value slotd 'reader-function)
+ #'(lambda (object)
+ (declare (ignore object))
+ (error "Slot is not readable: ~A" (slot-definition-name slotd)))
+ (slot-value slotd 'boundp-function)
+ #'(lambda (object) (declare (ignore object)) nil))
+
+ (let ((getter-function
+ (let ((getter (slot-value slotd 'getter)))
+ (etypecase getter
+ (function getter)
+ (symbol
+ #'(lambda (object)
+ (funcall getter object)))
+ (string
+ (let ((reader nil))
+ (setf (slot-value slotd 'reader-function)
+ #'(lambda (object)
+ (unless reader
+ (setq reader
+ (mkbinding getter
+ (slot-definition-type slotd) 'pointer)))
+ (funcall reader (foreign-location object))))))))))
+
+ (setf
+ (slot-value slotd 'boundp-function)
+ (cond
+ ((slot-boundp slotd 'unbound)
+ (let ((unbound-value (slot-value slotd 'unbound)))
+ #'(lambda (object)
+ (not (eq (funcall getter-function object) unbound-value)))))
+ ((slot-boundp slotd 'boundp)
+ (let ((boundp (slot-value slotd 'boundp)))
+ (etypecase boundp
+ (function boundp)
+ (symbol #'(lambda (object)
+ (funcall boundp object)))
+ (string (let ((reader ()))
+ #'(lambda (object)
+ (unless reader
+ (setq reader
+ (mkbinding boundp
+ (slot-definition-type slotd) 'pointer)))
+ (funcall reader (foreign-location object))))))))
+ ((multiple-value-bind (unbound-p unbound-value)
+ (unbound-value (slot-definition-type slotd))
+ (when unbound-p
+ #'(lambda (object)
+ (not (eq (funcall getter-function object) unbound-value))))))
+ (#'(lambda (object) (declare (ignore object)) t))))
+
+ (setf
+ (slot-value slotd 'reader-function)
+ (cond
+ ((slot-boundp slotd 'unbound)
+ (let ((unbound (slot-value slotd 'unbound))
+ (slot-name (slot-definition-name slotd)))
+ #'(lambda (object)
+ (let ((value (funcall getter-function object)))
+ (if (eq value unbound)
+ (slot-unbound (class-of object) object slot-name)
+ value)))))
+ ((slot-boundp slotd 'boundp)
+ (let ((boundp-function (slot-value slotd 'boundp-function)))
+ #'(lambda (object)
+ (and
+ (funcall boundp-function object)
+ (funcall getter-function object)))))
+ ((multiple-value-bind (unbound-p unbound-value)
+ (unbound-value (slot-definition-type slotd))
+ (let ((slot-name (slot-definition-name slotd)))
+ (when unbound-p
+ #'(lambda (object)
+ (let ((value (funcall getter-function object)))
+ (if (eq value unbound-value)
+ (slot-unbound (class-of object) object slot-name)
+ value)))))))
+ (getter-function)))))
+
+ (setf
+ (slot-value slotd 'writer-function)
+ (if (not (slot-boundp slotd 'setter))
+ #'(lambda (value object)
+ (declare (ignore value object))
+ (error "Slot is not writable: ~A" (slot-definition-name slotd)))
+ (with-slots (setter) slotd
+ (etypecase setter
+ (function setter)
+ ((or symbol cons)
+ #'(lambda (value object)
+ (funcall (fdefinition setter) value object)))
+ (string
+ (let ((writer ()))
+ (setf
+ (slot-value slotd 'writer-function)
+ #'(lambda (value object)
+ (unless writer
+ (setq writer
+ (mkbinding setter 'nil 'pointer
+ (slot-definition-type slotd))))
+ (funcall writer (foreign-location object) value)))))))))
+
+ #-sbcl>=0.9.8(initialize-internal-slot-gfs (slot-definition-name slotd)))
+
+
+
+(defmethod compute-slot-accessor-info ((slotd effective-virtual-slot-definition) type gf)
+ nil)
+
+(defmethod compute-effective-slot-definition-initargs ((class virtual-slots-class) direct-slotds)
+ (if (typep (first direct-slotds) 'direct-virtual-slot-definition)
+ (let ((initargs ()))
+ (let ((getter (most-specific-slot-value direct-slotds 'getter)))
+ (unless (eq getter *unbound-marker*)
+ (setf (getf initargs :getter) getter)))
+ (let ((setter (most-specific-slot-value direct-slotds 'setter)))
+ (unless (eq setter *unbound-marker*)
+ (setf (getf initargs :setter) setter)))
+ (let ((unbound (most-specific-slot-value direct-slotds 'unbound)))
+ (unless (eq unbound *unbound-marker*)
+ (setf (getf initargs :unbound) unbound)))
+ (let ((boundp (most-specific-slot-value direct-slotds 'boundp)))
+ (unless (eq boundp *unbound-marker*)
+ (setf (getf initargs :boundp) boundp)))
+ (nconc initargs (call-next-method)))
+ (call-next-method)))
+