X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Finspect.lisp;h=5625d641ad5817c90a01d0819de27dc2ced6a6b7;hb=b4831dc945c0754b3ba77881e67c8ea4d0a3d905;hp=2fe8ca224baf392285a37fcb8e80b65a9e0b72cd;hpb=1bfc464c657a8f4ad24ef612f76a38d8f6f1bbad;p=sbcl.git diff --git a/src/code/inspect.lisp b/src/code/inspect.lisp index 2fe8ca2..5625d64 100644 --- a/src/code/inspect.lisp +++ b/src/code/inspect.lisp @@ -17,15 +17,22 @@ ;;; indicates that that a slot is unbound. (defvar *inspect-unbound-object-marker* (gensym "INSPECT-UNBOUND-OBJECT-")) -(defun inspect (object) +(defun inspector (object input-stream output-stream) + (declare (ignore input-stream)) (catch 'quit-inspect - (%inspect object *standard-output*)) + (%inspect object output-stream)) (values)) +(defvar *inspect-fun* #'inspector + "a function of three arguments OBJECT, INPUT, and OUTPUT which starts an interactive inspector.") + (defvar *inspected*) (setf (documentation '*inspected* 'variable) "the value currently being inspected in CL:INSPECT") +(defun inspect (object) + (funcall *inspect-fun* object *standard-input* *standard-output*)) + (defvar *help-for-inspect* " help for INSPECT: @@ -41,17 +48,18 @@ evaluated expressions. ") (defun %inspect (*inspected* s) - (named-let redisplay () ; "lambda, the ultimate GOTO":-| + (named-let redisplay () ; "LAMBDA, the ultimate GOTO":-| (multiple-value-bind (description named-p elements) (inspected-parts *inspected*) (tty-display-inspected-parts description named-p elements s) (named-let reread () (format s "~&> ") (force-output) - (let (;; KMP idiom, using stream itself as EOF value - (command (read *standard-input* nil *standard-input*))) - (typecase command - (stream ; i.e. EOF + (let* (;; newly-consed object for hermetic protection against + ;; mischievous input like #.*EOF-OBJECT*: + (eof (cons *eof-object* nil)) + (command (read *standard-input* nil eof))) + (when (eq command eof) ;; currently-undocumented feature: EOF is handled as Q. ;; If there's ever consensus that this is *the* right ;; thing to do (as opposed to e.g. handling it as U), we @@ -59,6 +67,7 @@ evaluated expressions. ;; do this than to signal an error. (/show0 "THROWing QUIT-INSPECT for EOF") (throw 'quit-inspect nil)) + (typecase command (integer (let ((elements-length (length elements))) (cond ((< -1 command elements-length) @@ -163,7 +172,7 @@ evaluated expressions. (info (layout-info (sb-kernel:layout-of object)))) (when (sb-kernel::defstruct-description-p info) (dolist (dd-slot (dd-slots info) (nreverse parts-list)) - (push (cons (dsd-%name dd-slot) + (push (cons (dsd-name dd-slot) (funcall (dsd-accessor-name dd-slot) object)) parts-list)))))