X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=equal.lisp;h=0da3c4865ccb307735fc27a2a9be5f708984be83;hp=b773db04316c8ed770fb8dc8dc8c62d874c58932;hb=a5e8d90b159f1a8dcef4e954a97cae6eb5396423;hpb=8646b9afb9979064c3b0b79990c064dce7cb12b7 diff --git a/equal.lisp b/equal.lisp index b773db0..0da3c48 100644 --- a/equal.lisp +++ b/equal.lisp @@ -7,7 +7,7 @@ ;;;; 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.14 2003/05/07 21:57:10 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -37,7 +37,7 @@ (complex (and (generalized-equal (realpart obj1) (realpart obj2)) (generalized-equal (imagpart obj1) (imagpart obj2)))) - (standard-xstructure + (structure-object (generalized-equal-fielded-object obj1 obj2)) (standard-object (generalized-equal-fielded-object obj1 obj2)) @@ -87,16 +87,37 @@ (return-from test nil))) (return-from test t))) -#+(or allegro lispworks) -(defun class-slot-names (class-name) +(defun class-slot-names (c-name) "Given a CLASS-NAME, returns a list of the slots in the class." - (mapcar #'clos:slot-definition-name - (clos:class-slots (find-class class-name)))) - -#-(or allegro lispworks) -(defun class-slot-names (class-name) - (warn "class-slot-names not supported on this platform")) + #+(or allegro cmu lispworks sbcl scl) + (mapcar #'kmr-mop:slot-definition-name + (kmr-mop:class-slots (kmr-mop: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)) + #+(or sbcl cmu) (mapcar #'kmr-mop:slot-definition-name + (kmr-mop:class-slots (kmr-mop: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") + ) (defun function-to-string (obj) "Returns the lambda code for a function. Relies on