All Manuals > LispWorks® User Guide and Reference Manual > 38 The LISPWORKS Package

get-inspector-values Generic Function

Summary

Customizes the information display of attributes/values in the LispWorks IDE Inspector tool.

Package

lispworks

Signature

get-inspector-values object mode => names, values, getter, setter, type

Arguments
object
The object to be inspected.
mode
Name of a mode, or nil. nil defines the default inspection format for object.
Values
names, values
The two lists displayed in columns in the Inspector window.
getter
Ignored.
setter
A function used to update slot values.
type
Displayed in the Inspector window.
Description

The generic function get-inspector-values allows you to customize the LispWorks IDE Inspector tool by adding new ways to display attributes/values of class instances.

Defining a method on get-inspector-values allows you to add new formats (corresponding to different values of mode) in which object 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.

You can also define a method on sort-inspector-p to sort the list of displayed attributes/values.

Examples

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))))))
See also

sort-inspector-p


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:41