;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: attrib-class.lisp,v 1.5 2003/04/28 21:12:27 kevin Exp $
+;;;; $Id: attrib-class.lisp,v 1.6 2003/04/28 23:51:59 kevin Exp $
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(in-package :kmrcl)
-(defclass attributes-dsd (standard-direct-slot-definition)
- ((attributes :initarg :attributes :initform nil
- :accessor attributes)))
+(defclass attributes-dsd (kmr-mop:standard-direct-slot-definition)
+ ((attributes :initarg :attributes :initform nil
+ :accessor dsd-attributes)))
-(defclass attributes-esd (standard-effective-slot-definition)
+(defclass attributes-esd (kmr-mop:standard-effective-slot-definition)
((attributes :initarg :attributes :initform nil
- :accessor slot-definition-attributes)))
+ :accessor esd-attributes)))
-(defclass attributes-class (standard-class)
+(defclass attributes-class (kmr-mop:standard-class)
()
- )
+ (:documentation "metaclass that implements attributes on slots. Based
+on example from AMOP"))
+
#+(or cmu scl sbcl)
-(defmethod validate-superclass ((class attributes-class)
- (superclass standard-class))
+(defmethod kmr-mop:validate-superclass ((class attributes-class)
+ (superclass kmr-mop:standard-class))
t)
-(defmethod direct-slot-definition-class ((cl attributes-class)
- &rest iargs &key attributes)
- (declare (ignorable attributes))
-;; (format t "attributes:~s iargs:~s~%" attributes iargs)
- (find-class 'attributes-dsd))
+(defmethod kmr-mop:direct-slot-definition-class ((cl attributes-class)
+ &rest iargs &key attributes)
+ (declare (ignore attributes))
+ ;; (format t "attributes:~s iargs:~s~%" attributes iargs)
+ (kmr-mop:find-class 'attributes-dsd))
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (when (>= (length (generic-function-lambda-list
- (ensure-generic-function
- 'compute-effective-slot-definition)))
- 3)
- (push :ho-named-cesd-fun cl:*features*)))
-
-(defmethod compute-effective-slot-definition :around
- ((cl attributes-class) #+ho-named-cesd-fun name dsds)
- #+ho-named-cesd-fun (declare (ignore name))
+(defmethod kmr-mop:compute-effective-slot-definition :around
+ ((cl attributes-class) #+kmr-named-cesd name dsds)
+ #+kmr-named-cesd (declare (ignore name))
(apply
#'make-instance 'attributes-esd
- :attributes (remove-duplicates (mapappend #'attributes dsds))
- (compute-effective-slot-definition-initargs cl dsds))
+ :attributes (remove-duplicates (mapappend #'dsd-attributes dsds))
+ (kmr-mop:compute-effective-slot-definition-initargs cl dsds))
)
-
#+ignore
-(defmethod compute-effective-slot-definition :around
- ((cl attributes-class) #+ho-named-cesd-fun name dsds)
- #+ho-named-cesd-fun (declare (ignore name))
+(defmethod kmr-mop:compute-effective-slot-definition :around
+ ((cl attributes-class) #+kmr-named-cesd name dsds)
+ #+kmr-named-cesd (declare (ignore name))
(let ((normal-slot (call-next-method)))
- (setf (slot-definition-attributes normal-slot)
+ (setf (esd-attributes normal-slot)
(remove-duplicates
- (mapappend #'slot-definition-attributes dsds)))
+ (mapappend #'esd-attributes dsds)))
normal-slot))
-(defmethod compute-slots ((class attributes-class))
+(defmethod kmr-mop:compute-slots ((class attributes-class))
(let* ((normal-slots (call-next-method))
(alist
(mapcar
#'(lambda (slot)
(let ((attr-list (mapcar #'(lambda (attr) (cons attr nil))
- (slot-definition-attributes slot))))
+ (esd-attributes slot))))
(when attr-list
- (cons (mop::slot-definition-name slot) attr-list))))
+ (cons (kmr-mop:slot-definition-name slot) attr-list))))
normal-slots)))
(setq alist (delete nil alist))
- (cons (mop::make-instance 'mop::standard-effective-slot-definition
+ (cons (make-instance 'kmr-mop:standard-effective-slot-definition
:name 'all-attributes
:initform `',alist
:initfunction #'(lambda () alist))
slot-name instance attribute))
attr-bucket)))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (export '(attributes-class slot-attributes)))