;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: equal.lisp,v 1.1 2002/10/12 06:10:17 kevin Exp $
+;;;; $Id: equal.lisp,v 1.10 2003/03/25 05:27:55 kevin Exp $
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(return-from test nil)))
(return-from test t)))
-#+(or allegro lispworks)
-(defun class-slot-names (class-name)
+#+sbcl
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (if (find-package 'sb-mop)
+ (pushnew :sb-mop cl:*features*)
+ (pushnew :sb-acl cl:*features*)))
+
+(defun class-slot-names (c-name)
"Given a CLASS-NAME, returns a list of the slots in the class."
+ #+(or allegro lispworks scl)
(mapcar #'clos:slot-definition-name
- (clos:class-slots (find-class class-name))))
+ (clos:class-slots (find-class c-name)))
+ #+sbcl-mop (mapcar #'sb-mop::slot-definition-name
+ (sb-mop:class-slots (find-class c-name)))
+ #+sbcl-pcl (mapcar #'sb-pcl::slot-definition-name
+ (sb-pcl:class-slots (sb-pcl::find-class c-name)))
+ #+cmu (mapcar #'pcl::slot-definition-name
+ (pcl:class-slots (pcl:find-class c-name)))
+ #+mcl
+ (let* ((class (find-class c-name nil)))
+ (when (typep class 'standard-class)
+ (nconc (mapcar #'car (ccl:class-instance-slots class))
+ (mapcar #'car (ccl:class-class-slots class)))))
+ #-(or allegro lispworks cmu mcl sbcl scl)
+ (error "class-slot-names is not defined on this platform")
+ )
+
+(defun structure-slot-names (s-name)
+ "Given a STRUCTURE-NAME, returns a list of the slots in the structure."
+ #+allegro (class-slot-names s-name)
+ #+lispworks (structure:structure-class-slot-names
+ (find-class s-name))
+ #+sbcl-mop (mapcar #'sb-mop::slot-definition-name
+ (sb-mop:class-slots (find-class s-name)))
+ #+sbcl-pcl (mapcar #'sb-pcl::slot-definition-name
+ (sb-pcl:class-slots (sb-pcl::find-class s-name)))
+ #+cmu (mapcar #'pcl::slot-definition-name
+ (pcl:class-slots (pcl:find-class s-name)))
+ #+scl (mapcar #'kernel:dsd-name
+ (kernel:dd-slots
+ (kernel:layout-info
+ (kernel:class-layout (find-class s-name)))))
+ #+mcl (let* ((sd (gethash s-name ccl::%defstructs%))
+ (slots (if sd (ccl::sd-slots sd))))
+ (mapcar #'car (if (symbolp (caar slots)) slots (cdr slots))))
+ #-(or allegro lispworks cmu sbcl scl mcl)
+ (error "structure-slot-names is not defined on this platform")
+ )
-#-(or allegro lispworks)
-(defun class-slot-names (class-name)
- (warn "class-slot-names not supported on this platform"))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (if (find-package 'sb-mop)
+ (setq cl:*features* (delete :sb-mop cl:*features*))
+ (setq cl:*features* (delete :sb-acl cl:*features*))))
(defun function-to-string (obj)
"Returns the lambda code for a function. Relies on