From: Nikodemus S. <nik...@ra...> - 2011-09-20 12:22:37
|
On 14 September 2011 03:36, Zach Beane <xa...@xa...> wrote: > I'd like to pass FOO:BAZ to some function and get > #p"/path/to/bar-class.lisp". Is there any way to get that kind of > information from sb-introspect? This should do it: (defun map-classes (function &optional (class 'standard-object)) (let ((class (if (typep class 'class) class (find-class class t))) (function (if (functionp function) function (fdefinition function)))) (funcall function class) (dolist (subclass (sb-mop:class-direct-subclasses class)) (map-classes function subclass)))) (defun slot-name-classes (name &optional (class 'standard-object)) (let (classes) (map-classes (lambda (class) (let ((slotd (find name (sb-mop:class-direct-slots class) :key #'sb-mop:slot-definition-name))) (when slotd (push class classes)))) class) classes)) (defun slot-initarg-classes (name &optional (class 'standard-object)) (let (classes) (map-classes (lambda (class) (let ((slotd (find name (sb-mop:class-direct-slots class) :test #'member :key #'sb-mop:slot-definition-initargs))) (when slotd (push class classes)))) class) classes)) (defun slot-name-source-files (name) (mapcar (lambda (class) (sb-introspect:definition-source-pathname (sb-introspect:find-definition-source class))) (slot-name-classes name))) (defun slot-initarg-source-files (name) (mapcar (lambda (class) (sb-introspect:definition-source-pathname (sb-introspect:find-definition-source class))) (slot-initarg-classes name))) Cheers, -- Nikodemus |