- (sb-kernel:layout-class object)))
- `(sb-kernel:class-layout (cl:find-class ',pname))))
-\f
-;;;; The following are hacks to deal with CMU CL having two different CLASS
-;;;; classes.
-
-(defun coerce-to-pcl-class (class)
- (if (typep class 'cl:class)
- (or (sb-kernel:class-pcl-class class)
- (find-structure-class (cl:class-name class)))
- class))
-
-(defmethod make-instance ((class cl:class) &rest stuff)
- (apply #'make-instance (coerce-to-pcl-class class) stuff))
-(defmethod change-class (instance (class cl:class))
- (apply #'change-class instance (coerce-to-pcl-class class)))
-
-(macrolet ((frob (&rest names)
- `(progn
- ,@(mapcar #'(lambda (name)
- `(defmethod ,name ((class cl:class))
- (funcall #',name
- (coerce-to-pcl-class class))))
- names))))
- (frob
- class-direct-slots
- class-prototype
- class-precedence-list
- class-direct-default-initargs
- class-direct-superclasses
- compute-class-precedence-list
- class-default-initargs class-finalized-p
- class-direct-subclasses class-slots
- make-instances-obsolete))
+ (layout-classoid object)))
+ `(classoid-layout (find-classoid ',pname))))
+
+(defmethod make-load-form ((object structure-object) &optional env)
+ (declare (ignore env))
+ (error "~@<don't know how to dump ~S (default ~S method called).~@>"
+ object 'make-load-form))
+
+(defmethod make-load-form ((object standard-object) &optional env)
+ (declare (ignore env))
+ (error "~@<don't know how to dump ~S (default ~S method called).~@>"
+ object 'make-load-form))
+
+(defmethod make-load-form ((object condition) &optional env)
+ (declare (ignore env))
+ (error "~@<don't know how to dump ~S (default ~S method called).~@>"
+ object 'make-load-form))
+
+(defun make-load-form-saving-slots (object &key slot-names environment)
+ (declare (ignore environment))
+ (let ((class (class-of object)))
+ (collect ((inits))
+ (dolist (slot (class-slots class))
+ (let ((slot-name (slot-definition-name slot)))
+ (when (or (memq slot-name slot-names)
+ (and (null slot-names)
+ (eq :instance (slot-definition-allocation slot))))
+ (if (slot-boundp-using-class class object slot)
+ (let ((value (slot-value-using-class class object slot)))
+ (if (typep object 'structure-object)
+ ;; low-level but less noisy initializer form
+ (let* ((dd (get-structure-dd (class-name class)))
+ (dsd (find slot-name (dd-slots dd)
+ :key #'dsd-name)))
+ (inits `(,(slot-setter-lambda-form dd dsd)
+ ',value ,object)))
+ (inits `(setf (slot-value ,object ',slot-name) ',value))))
+ (inits `(slot-makunbound ,object ',slot-name))))))
+ (values `(allocate-instance (find-class ',(class-name class)))
+ `(progn ,@(inits))))))