-(defmethod compute-foreign-size ((class struct-class))
- (let ((size (loop
- for slotd in (class-slots class)
- when (eq (slot-definition-allocation slotd) :alien)
- maximize (+
- (slot-definition-offset slotd)
- (size-of (slot-definition-type slotd))))))
- (+ size (mod size +struct-alignmen+))))
+(defmethod compute-slots :around ((class struct-class))
+ (let ((slots (call-next-method)))
+ (when (and
+ #-sbcl>=0.9.8(class-finalized-p class) #+sbc098 t
+ (not (slot-boundp class 'size)))
+ (let ((size (loop
+ for slotd in slots
+ when (eq (slot-definition-allocation slotd) :alien)
+ maximize (+
+ (slot-definition-offset slotd)
+ (size-of (slot-definition-type slotd))))))
+ (setf (slot-value class 'size) (+ size (mod size +struct-alignmen+)))))
+ slots))
+
+(defmethod reader-function ((class struct-class) &rest args)
+ (declare (ignore args))
+ #'(lambda (location &optional (offset 0) weak-p)
+ (let ((instance (sap-ref-sap location offset)))
+ (unless (null-pointer-p instance)
+ (if weak-p
+ (ensure-proxy-instance class instance :weak t)
+ (ensure-proxy-instance class (reference-foreign class instance)))))))