Next Prev Up Top Contents Index

get-inspector-values

Generic Function
Summary

Customizes the information displayed in the Common LispWorks inspector tool.

Package

lispworks

Signature

get-inspector-values object mode

Arguments

object

The object to be inspected.

mode

Name of a mode, or nil . nil defines the default inspection format for object.

Values

Returns five values: names , values , getter , setter and type . names and values are the two lists displayed in columns in the inspector window. getter is ignored. setter is a function used to updated slot values. type is displayed at the foot of the inspector window.

Description

This generic function allows you to customize the Common LispWorks Inspector by adding new formats (corresponding to different values of mode) in which instances of a particular class can be inspected. Mode nil is the default mode, which is always present (it can be overwritten).

LispWorks includes methods for:

(get-inspector-values (object nil))
(get-inspector-values (standard-object nil))
(get-inspector-values (structured-object nil))
(get-inspector-values (sequence nil))
(get-inspector-values cons nil))

and so on.

Example

This example allows inspection of a CLOS object, displaying only direct slots form a chosen class in its class precedence list. This can be useful when an object inherits many slots from superclasses, and the inherited slots are of no interest.

(defmethod lispworks:get-inspector-values
         ((object standard-object)
          (mode (eql 'direct-as)))
         (declare (ignore mode))
         (loop with object-class =
                (class-of object)
               with precedence-list =
                (class-precedence-list object-class)
               with items =
                (loop for super in precedence-list
                      collecting (list*
                                  (format nil "~a"
                                   (class-name super))
                                   super))
               with class =
                (or (capi:prompt-with-list items
                        "Direct slots as ...")
                    object-class)
                            ;; default if no selection
               with slots =
                (class-direct-slots class)
               for slot in slots
               for name =
                    (clos::slot-definition-name slot)
               collect name into names
               collect (if (slot-boundp object name)
                           (slot-value object name)
                         :slot-unbound)
               into values
               finally
               (return
                (values
                 names
                 values
                 nil
                 #'(lambda
                    (x slot-name index new-value)
                    (declare (ignore index))
                    (setf (slot-value x slot-name)
                          new-value))
                 (format nil "~a - direct slots as ~a"
                         (class-name object-class)
                         (class-name class))))))

LispWorks Reference Manual (Windows version) - 14 Dec 2001

Next Prev Up Top Contents Index