-(defun %direct-slot-definitions-slot-value (slotds slot &optional default)
- (let ((slotd
- (find-if
- #'(lambda (slotd)
- (and
- (slot-exists-p slotd slot)
- (slot-boundp slotd slot)))
- slotds)))
- (if slotd
- (slot-value slotd slot)
- default)))
-
-
-(defgeneric compute-virtual-slot-location (class slotd direct-slotds))
-
-(defmethod compute-virtual-slot-location
- ((class virtual-class)
- (slotd effective-virtual-slot-definition)
- direct-slotds)
- (let ((location
- (%direct-slot-definitions-slot-value direct-slotds 'location)))
- (if (and location (symbolp location))
- (list location `(setf ,location))
- location)))
-
-
-(defmethod compute-effective-slot-definition
- ((class virtual-class) direct-slotds)
- (let ((slotd (call-next-method)))
- (when (typep slotd 'effective-virtual-slot-definition)
- (setf
- (slot-value slotd 'pcl::location)
- (compute-virtual-slot-location class slotd direct-slotds)))
- slotd))
+(defmethod initialize-internal-slot-functions ((slotd effective-virtual-slot-definition))
+ (with-slots (getter setter boundp) slotd
+ (unless (slot-boundp slotd 'reader-function)
+ (setf
+ (slot-value slotd 'reader-function)
+ (etypecase getter
+ (function getter)
+ (null #'(lambda (object)
+ (declare (ignore object))
+ (error "Can't read slot: ~A" (slot-definition-name slotd))))
+ (symbol #'(lambda (object)
+ (funcall getter object)))
+ (string (let ((reader (mkbinding-late getter
+ (slot-definition-type slotd) 'pointer)))
+ (setf (slot-value slotd 'reader-function)
+ #'(lambda (object)
+ (funcall reader (proxy-location object)))))))))
+
+ (unless (slot-boundp slotd 'writer-function)
+ (setf
+ (slot-value slotd 'writer-function)
+ (etypecase setter
+ (function setter)
+ (null #'(lambda (object)
+ (declare (ignore object))
+ (error "Can't set slot: ~A" (slot-definition-name slotd))))
+ ((or symbol cons) #'(lambda (value object)
+ (funcall (fdefinition setter) value object)))
+ (string
+ (let ((writer (mkbinding-late setter 'nil 'pointer
+ (slot-definition-type slotd))))
+ (setf (slot-value slotd 'writer-function)
+ #'(lambda (value object)
+ (funcall writer (proxy-location object) value))))))))
+
+ (unless (slot-boundp slotd 'boundp-function)
+ (setf
+ (slot-value slotd 'boundp-function)
+ (etypecase boundp
+ (function boundp)
+ (null #'(lambda (object)
+ (declare (ignore object))
+ t))
+ (symbol #'(lambda (object)
+ (funcall boundp object)))))))
+ (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-slot-class) direct-slotds)
+ (if (eq (most-specific-slot-value direct-slotds 'allocation) :virtual)
+ (nconc
+ (list :getter (most-specific-slot-value direct-slotds 'getter)
+ :setter (most-specific-slot-value direct-slotds 'setter)
+ :boundp (most-specific-slot-value direct-slotds 'boundp))
+ (call-next-method))
+ (call-next-method)))