(defmethod ensure-class-using-class ((class null) name &rest args &key)
(multiple-value-bind (meta initargs)
- (ensure-class-values class args)
- #+nil
- (set-class-type-translation (class-prototype meta) name)
+ (frob-ensure-class-args args)
(setf class (apply #'make-instance meta :name name initargs))
(without-package-locks
(setf (find-class name) class))
(defmethod ensure-class-using-class ((class pcl-class) name &rest args &key)
(multiple-value-bind (meta initargs)
- (ensure-class-values class args)
+ (frob-ensure-class-args args)
(unless (eq (class-of class) meta)
(apply #'change-class class meta initargs))
(apply #'reinitialize-instance class initargs)
(set-class-type-translation class name)
class))
-(defun fix-super (s)
- (cond ((classp s) s)
- ((not (legal-class-name-p s))
- (error "~S is not a class or a legal class name." s))
- (t
- (or (find-class s nil)
- (ensure-class s :metaclass 'forward-referenced-class)))))
-
-(defun ensure-class-values (class initargs)
+(defun frob-ensure-class-args (args)
(let (metaclass metaclassp reversed-plist)
- (doplist (key val) initargs
- (cond ((eq key :metaclass)
- (setf metaclass val
- metaclassp key))
- (t
- (when (eq key :direct-superclasses)
- (setf val (mapcar #'fix-super val)))
- (setf reversed-plist (list* val key reversed-plist)))))
- (values (cond (metaclassp
- (if (classp metaclass)
- metaclass
- (find-class metaclass)))
- ((or (null class) (forward-referenced-class-p class))
- *the-class-standard-class*)
- (t
- (class-of class)))
- (nreverse reversed-plist))))
-
+ (flet ((frob-superclass (s)
+ (cond
+ ((classp s) s)
+ ((legal-class-name-p s)
+ (or (find-class s nil)
+ (ensure-class s :metaclass 'forward-referenced-class)))
+ (t (error "Not a class or a legal class name: ~S." s)))))
+ (doplist (key val) args
+ (cond ((eq key :metaclass)
+ (unless metaclassp
+ (setf metaclass val metaclassp key)))
+ (t
+ (when (eq key :direct-superclasses)
+ (setf val (mapcar #'frob-superclass val)))
+ (setf reversed-plist (list* val key reversed-plist)))))
+ (values (cond (metaclassp
+ (if (classp metaclass)
+ metaclass
+ (find-class metaclass)))
+ (t *the-class-standard-class*))
+ (nreverse reversed-plist)))))
\f
(defmethod shared-initialize :after
((class std-class) slot-names &key
(push old collect)))))
(nreverse collect)))
(add-direct-subclasses class direct-superclasses)
- (update-class class nil)
- (do* ((slots (slot-value class 'slots) (cdr slots))
- (dupes nil))
- ((null slots) (when dupes
- (style-warn
- ;; FIXME: the indentation request ("~4I")
- ;; below appears not to do anything. Finding
- ;; out why would be nice. -- CSR, 2003-04-24
- "~@<slot names with the same SYMBOL-NAME but ~
- different SYMBOL-PACKAGE (possible package problem) ~
- for class ~S:~@:_~4I~<~@{~S~^~:@_~}~:>~@:>"
- class
- dupes)))
- (let* ((slot (car slots))
- (oslots (remove (slot-definition-name slot) (cdr slots)
- :test #'string/= :key #'slot-definition-name)))
- (when oslots
- (pushnew (cons (slot-definition-name slot)
- (mapcar #'slot-definition-name oslots))
- dupes
- :test #'string= :key #'car))))
+ (if (class-finalized-p class)
+ ;; required by AMOP, "Reinitialization of Class Metaobjects"
+ (finalize-inheritance class)
+ (update-class class nil))
(add-slot-accessors class direct-slots)
(make-preliminary-layout class))
(order-layout-inherits
(map 'simple-vector #'class-wrapper
(reverse (rest cpl))))))
- (register-layout layout :invalidate t))))
+ (register-layout layout :invalidate t)
+ (set-class-type-translation class (layout-classoid layout)))))
(mapc #'make-preliminary-layout (class-direct-subclasses class)))))
(defun fix-slot-accessors (class dslotds add/remove)
(flet ((fix (gfspec name r/w)
(let ((gf (cond ((eq add/remove 'add)
- (if (fboundp gfspec)
- (without-package-locks
- (ensure-generic-function gfspec))
+ (or (find-generic-function gfspec nil)
(ensure-generic-function
gfspec :lambda-list (case r/w
(r '(object))
(w '(new-value object))))))
- ((generic-function-p (and (fboundp gfspec)
- (fdefinition gfspec)))
- (without-package-locks
- (ensure-generic-function gfspec))))))
+ (t
+ (find-generic-function gfspec nil)))))
(when gf
(case r/w
(r (if (eq add/remove 'add)
;;; or reinitialized. The class may or may not be finalized.
(defun update-class (class finalizep)
(without-package-locks
- (when (or finalizep (class-finalized-p class))
- (update-cpl class (compute-class-precedence-list class))
- ;; This invocation of UPDATE-SLOTS, in practice, finalizes the
- ;; class.
- (update-slots class (compute-slots class))
- (update-gfs-of-class class)
- (update-initargs class (compute-default-initargs class))
- (update-ctors 'finalize-inheritance :class class))
- (dolist (sub (class-direct-subclasses class))
- (update-class sub nil))))
+ (when (or finalizep (class-finalized-p class))
+ (update-cpl class (compute-class-precedence-list class))
+ ;; This invocation of UPDATE-SLOTS, in practice, finalizes the
+ ;; class.
+ (update-slots class (compute-slots class))
+ (update-gfs-of-class class)
+ (update-initargs class (compute-default-initargs class))
+ (update-ctors 'finalize-inheritance :class class))
+ (dolist (sub (class-direct-subclasses class))
+ (update-class sub nil))))
(define-condition cpl-protocol-violation (reference-condition error)
((class :initarg :class :reader cpl-protocol-violation-class)
(wrapper-instance-slots-layout nwrapper) nlayout
(wrapper-class-slots nwrapper) nwrapper-class-slots
(wrapper-no-of-instance-slots nwrapper) nslots
- wrapper nwrapper))
+ wrapper nwrapper)
+ (do* ((slots (slot-value class 'slots) (cdr slots))
+ (dupes nil))
+ ((null slots)
+ (when dupes
+ (style-warn
+ "~@<slot names with the same SYMBOL-NAME but ~
+ different SYMBOL-PACKAGE (possible package problem) ~
+ for class ~S:~4I~@:_~<~@{~S~^~:@_~}~:>~@:>"
+ class dupes)))
+ (let* ((slot (car slots))
+ (oslots (remove (slot-definition-name slot) (cdr slots)
+ :test #'string/=
+ :key #'slot-definition-name)))
+ (when oslots
+ (pushnew (cons (slot-definition-name slot)
+ (mapcar #'slot-definition-name oslots))
+ dupes
+ :test #'string= :key #'car)))))
(setf (slot-value class 'finalized-p) t)
(unless (eq owrapper nwrapper)
(update-pv-table-cache-info class)
(list class)
(make-reader-method-function class slot-name)
"automatically generated reader method"
- slot-name)))
+ :slot-name slot-name
+ :object-class class
+ :method-class-function #'reader-method-class)))
(defmethod writer-method-class ((class slot-class) direct-slot &rest initargs)
(declare (ignore direct-slot initargs))
(list *the-class-t* class)
(make-writer-method-function class slot-name)
"automatically generated writer method"
- slot-name)))
+ :slot-name slot-name
+ :object-class class
+ :method-class-function #'writer-method-class)))
(defmethod add-boundp-method ((class slot-class) generic-function slot-name)
(add-method generic-function
- (make-a-method 'standard-boundp-method
+ (make-a-method (constantly (find-class 'standard-boundp-method))
+ class
()
(list (or (class-name class) 'object))
(list class)