- options))
- (defstruct-p (and (eq *boot-state* 'complete)
- (let ((mclass (find-class metaclass nil)))
- (and mclass
- (*subtypep
- mclass
- *the-class-structure-class*))))))
- (let ((defclass-form
- (eval-when (:load-toplevel :execute)
- `(progn
- ,@(mapcar #'(lambda (x)
- `(declaim (ftype (function (t) t) ,x)))
- *readers*)
- ,@(mapcar #'(lambda (x)
- `(declaim (ftype (function (t t) t) ,x)))
- *writers*)
- (let ,(mapcar #'cdr *initfunctions*)
- (load-defclass ',name
- ',metaclass
- ',supers
- (list ,@canonical-slots)
- (list ,@(apply #'append
- (when defstruct-p
- '(:from-defclass-p t))
- other-initargs))))))))
- (if defstruct-p
- (progn
- (eval defclass-form) ; Define the class now, so that..
- `(progn ; ..the defstruct can be compiled.
- ,(class-defstruct-form (find-class name))
- ,defclass-form))
- (progn
- (when (eq *boot-state* 'complete)
- (inform-type-system-about-std-class name))
- defclass-form)))))))
+ options))
+ ;; DEFSTRUCT-P should be true if the class is defined
+ ;; with a metaclass STRUCTURE-CLASS, so that a DEFSTRUCT
+ ;; is compiled for the class.
+ (defstruct-p (and (eq *boot-state* 'complete)
+ (let ((mclass (find-class metaclass nil)))
+ (and mclass
+ (*subtypep
+ mclass
+ *the-class-structure-class*))))))
+ (let ((defclass-form
+ `(progn
+ ,@(mapcar (lambda (x)
+ `(declaim (ftype (function (t) t) ,x)))
+ *readers-for-this-defclass*)
+ ,@(mapcar (lambda (x)
+ `(declaim (ftype (function (t t) t) ,x)))
+ *writers-for-this-defclass*)
+ ,@(mapcar (lambda (x)
+ `(declaim (ftype (function (t) t)
+ ,(slot-reader-symbol x)
+ ,(slot-boundp-symbol x))
+ (ftype (function (t t) t)
+ ,(slot-writer-symbol x))))
+ *slot-names-for-this-defclass*)
+ (let ,(mapcar #'cdr *initfunctions-for-this-defclass*)
+ (load-defclass ',name
+ ',metaclass
+ ',supers
+ (list ,@canonical-slots)
+ (list ,@(apply #'append
+ (when defstruct-p
+ '(:from-defclass-p t))
+ other-initargs)))))))
+ (if defstruct-p
+ (progn
+ ;; FIXME: (YUK!) Why do we do this? Because in order
+ ;; to make the defstruct form, we need to know what
+ ;; the accessors for the slots are, so we need
+ ;; already to have hooked into the CLOS machinery.
+ ;;
+ ;; There may be a better way to do this: it would
+ ;; involve knowing enough about PCL to ask "what
+ ;; will my slot names and accessors be"; failing
+ ;; this, we currently just evaluate the whole
+ ;; kaboodle, and then use CLASS-DIRECT-SLOTS. --
+ ;; CSR, 2002-06-07
+ (eval defclass-form)
+ (let* ((include (or (and supers
+ (fix-super (car supers)))
+ (and (not (eq name 'structure-object))
+ *the-class-structure-object*)))
+ (defstruct-form (make-structure-class-defstruct-form
+ name (class-direct-slots (find-class name)) include)))
+ `(progn
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ ,defstruct-form) ; really compile the defstruct-form
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ ,defclass-form))))
+ `(progn
+ ;; By telling the type system at compile time about
+ ;; the existence of a class named NAME, we can avoid
+ ;; various bogus warnings about "type isn't defined yet"
+ ;; for code elsewhere in the same file which uses
+ ;; the name of the type.
+ ;;
+ ;; We only need to do this at compile time, because
+ ;; at load and execute time we write the actual
+ ;; full-blown class, so the "a class of this name is
+ ;; coming" note we write here would be irrelevant.
+ (eval-when (:compile-toplevel)
+ (preinform-compiler-about-class-type ',name))
+ ,defclass-form))))))))