r9970: fix package name
[kmrcl.git] / attrib-class.lisp
index ee0228b7893e18d8415a4ea293c84dd9393d46bb..12572a290e458f671d0ee2553589abbf32687349 100644 (file)
@@ -1,4 +1,4 @@
-;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: kmrcl-*-
 ;;;; *************************************************************************
 ;;;; FILE IDENTIFICATION
 ;;;;
@@ -7,19 +7,23 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: attrib-class.lisp,v 1.12 2003/04/29 07:52:38 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-class (kmr-mop:standard-class)
   ()
@@ -37,7 +41,7 @@ on example from AMOP"))
 ;; encapsulating macro for Lispworks
 (kmr-mop:process-slot-option attributes-class :attributes)
 
-#+(or cmu scl sbcl)
+#+(or cmu scl sbcl openmcl)
 (defmethod kmr-mop:validate-superclass ((class attributes-class)
                                        (superclass kmr-mop:standard-class))
   t)
@@ -50,45 +54,34 @@ on example from AMOP"))
   (declare (ignore initargs))
   (kmr-mop:find-class 'attributes-esd))
 
-(defmethod kmr-mop:compute-effective-slot-definition :around
-    ((cl attributes-class) #+kmr-normal-cesd name dsds)
-  #+(and kmr-normal-cesd (not lispworks)) (declare (ignore name))
-  (apply
-   #'make-instance 'attributes-esd 
-   :attributes (remove-duplicates (mapappend #'dsd-attributes dsds))
-   (kmr-mop::compute-effective-slot-definition-initargs cl #+lispworks name dsds))
-  )
-
-#+ignore
-(defmethod kmr-mop:compute-effective-slot-definition :around
+(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)))
-    (setq esd (change-class esd 'attributes-esd))
-    (print esd)
-    (print (remove-duplicates (mapappend #'dsd-attributes dsds)))
     (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))
-                                       (esd-attributes slot))))
-                (when attr-list
-                  (cons (kmr-mop:slot-definition-name slot) attr-list))))
-          normal-slots)))
-    (format t "normal-slots: ~A~%" normal-slots)
-    (format t "alist: ~A~%" alist)
-    (let ((attrib-slot  (make-instance 'attributes-esd
-                        :name 'all-attributes
-                        :initform `',alist
-                        :initfunction #'(lambda () alist))))
-      (format t "attrib-slot: ~A~%" attrib-slot)
-      (cons attrib-slot normal-slots))))
+        (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)
   (cdr (slot-attribute-bucket instance slot-name attribute)))
@@ -109,6 +102,5 @@ on example from AMOP"))
               slot-name instance attribute))
       attr-bucket)))
 
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (export '(attributes-class slot-attributes)))
+