-;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: kmrcl-*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: attrib-class.lisp,v 1.5 2003/04/28 21:12:27 kevin Exp $
+;;;; $Id$
;;;;
-;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of KMRCL, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
;;;;
;;;; KMRCL users are granted the rights to distribute and use this software
;;;; as governed by the terms of the Lisp Lesser GNU Public License
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
+;; Disable attrib class until understand changes in sbcl/cmucl
+;; using COMPUTE-SLOT-ACCESSOR-INFO and defining method
+;; for slot access of ALL-ATTRIBUTES. Does this work on Allegro/LW?
+
;;;; Defines a metaclass that allows the use of attributes (or subslots)
;;;; on slots. Based on example in AMOP, but modified to use ACL's MOP.
-(in-package :kmrcl)
+(in-package #:kmrcl)
-(defclass attributes-dsd (standard-direct-slot-definition)
- ((attributes :initarg :attributes :initform nil
- :accessor attributes)))
+(defclass attributes-class (kmr-mop:standard-class)
+ ()
+ (:documentation "metaclass that implements attributes on slots. Based
+on example from AMOP"))
-(defclass attributes-esd (standard-effective-slot-definition)
- ((attributes :initarg :attributes :initform nil
- :accessor slot-definition-attributes)))
+(defclass attributes-dsd (kmr-mop:standard-direct-slot-definition)
+ ((attributes :initarg :attributes :initform nil
+ :accessor dsd-attributes)))
+(defclass attributes-esd (kmr-mop:standard-effective-slot-definition)
+ ((attributes :initarg :attributes :initform nil
+ :accessor esd-attributes)))
-(defclass attributes-class (standard-class)
- ()
- )
+;; encapsulating macro for Lispworks
+(kmr-mop:process-slot-option attributes-class :attributes)
-#+(or cmu scl sbcl)
-(defmethod validate-superclass ((class attributes-class)
- (superclass standard-class))
+#+(or cmu scl sbcl openmcl)
+(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))
-
-(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))
- (apply
- #'make-instance 'attributes-esd
- :attributes (remove-duplicates (mapappend #'attributes dsds))
- (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))
- (let ((normal-slot (call-next-method)))
- (setf (slot-definition-attributes normal-slot)
- (remove-duplicates
- (mapappend #'slot-definition-attributes dsds)))
- normal-slot))
-
-
-(defmethod compute-slots ((class attributes-class))
+(defmethod kmr-mop:direct-slot-definition-class ((cl attributes-class) #+kmr-normal-dsdc &rest initargs)
+ (declare (ignore initargs))
+ (kmr-mop:find-class 'attributes-dsd))
+
+(defmethod kmr-mop:effective-slot-definition-class ((cl attributes-class) #+kmr-normal-dsdc &rest initargs)
+ (declare (ignore initargs))
+ (kmr-mop:find-class 'attributes-esd))
+
+(defmethod kmr-mop:compute-effective-slot-definition
+ ((cl attributes-class) #+kmr-normal-cesd name dsds)
+ #+kmr-normal-cesd (declare (ignore name))
+ (let ((esd (call-next-method)))
+ (setf (esd-attributes esd) (remove-duplicates (mapappend #'dsd-attributes dsds)))
+ esd))
+
+;; This does not work in Lispworks prior to version 4.3
+
+(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))))
- (when attr-list
- (cons (mop::slot-definition-name slot) attr-list))))
- normal-slots)))
- (setq alist (delete nil alist))
- (cons (mop::make-instance 'mop::standard-effective-slot-definition
- :name 'all-attributes
- :initform `',alist
- :initfunction #'(lambda () alist))
+ (alist (mapcar
+ #'(lambda (slot)
+ (cons (kmr-mop:slot-definition-name slot)
+ (mapcar #'(lambda (attr) (list attr))
+ (esd-attributes slot))))
+ normal-slots)))
+
+ (cons (make-instance
+ 'attributes-esd
+ :name 'all-attributes
+ :initform `',alist
+ :initfunction #'(lambda () alist)
+ :allocation :instance
+ :documentation "Attribute bucket"
+ :type t
+ )
normal-slots)))
(defun slot-attribute (instance slot-name attribute)
attr-bucket)))
+