X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fprint-object.lisp;h=7711dab7fd336028ec925f4e856645b5fa6c4f09;hb=HEAD;hp=ed8be04f81da26e234b97668dbf5d39b5777a79c;hpb=81ce38f2e03e4f569d7a95bb18efb25bb16fc269;p=sbcl.git diff --git a/src/pcl/print-object.lisp b/src/pcl/print-object.lisp index ed8be04..7711dab 100644 --- a/src/pcl/print-object.lisp +++ b/src/pcl/print-object.lisp @@ -46,7 +46,10 @@ (fmakunbound 'print-object) (defgeneric print-object (object stream)) (defmethod print-object ((x t) stream) - (print-unreadable-object (x stream :type t :identity t)))) + (if *print-pretty* + (pprint-logical-block (stream nil) + (print-unreadable-object (x stream :type t :identity t))) + (print-unreadable-object (x stream :type t :identity t))))) (/show0 "done replacing placeholder PRINT-OBJECT with DEFGENERIC") ;;;; a hook called by the printer to take care of dispatching to PRINT-OBJECT @@ -67,46 +70,46 @@ (defmethod print-object ((method standard-method) stream) (print-unreadable-object (method stream :type t :identity t) - (if (slot-boundp method 'generic-function) + (if (slot-boundp method '%generic-function) (let ((generic-function (method-generic-function method))) (format stream "~S ~{~S ~}~:S" (and generic-function (generic-function-name generic-function)) (method-qualifiers method) - (unparse-specializers method))) + (if generic-function + (unparse-specializers generic-function (method-specializers method)) + (method-specializers method)))) ;; FIXME: Why do we do CALL-NEXT-METHOD in this method (and ;; in the PRINT-OBJECT STANDARD-ACCESSOR-METHOD method too)? (call-next-method)))) (defmethod print-object ((method standard-accessor-method) stream) (print-unreadable-object (method stream :type t :identity t) - (if (slot-boundp method 'generic-function) + (if (slot-boundp method '%generic-function) (let ((generic-function (method-generic-function method))) (format stream "~S, slot:~S, ~:S" (and generic-function (generic-function-name generic-function)) (accessor-method-slot-name method) - (unparse-specializers method))) + (if generic-function + (unparse-specializers generic-function (method-specializers method)) + (method-specializers method)))) (call-next-method)))) (defmethod print-object ((mc standard-method-combination) stream) (print-unreadable-object (mc stream :type t :identity t) (format stream "~S ~S" - (slot-value-or-default mc 'type) + (slot-value-or-default mc 'type-name) (slot-value-or-default mc 'options)))) (defun named-object-print-function (instance stream &optional (extra nil extra-p)) - (print-unreadable-object (instance stream :type t) - (if extra-p - (format stream - "~S ~:S" - (slot-value-or-default instance 'name) - extra) - (format stream - "~S" - (slot-value-or-default instance 'name))))) + (let ((name (slot-value-or-default instance 'name))) + (print-unreadable-object (instance stream :type t :identity (not name)) + (if extra-p + (format stream "~S ~:S" name extra) + (format stream "~S" name))))) (defmethod print-object ((class class) stream) (named-object-print-function class stream)) @@ -124,11 +127,17 @@ (defmethod print-object ((cache cache) stream) (print-unreadable-object (cache stream :type t :identity t) - (format stream - "~W ~S ~W" - (cache-nkeys cache) - (cache-valuep cache) - (cache-nlines cache)))) + (multiple-value-bind (lines-used lines-total max-depth depth-limit) + (cache-statistics cache) + (format stream + "~D key~P, ~:[no value~;value~], ~D/~D lines, depth ~D/~D" + (cache-key-count cache) + (cache-key-count cache) + (cache-value cache) + lines-used + lines-total + max-depth + depth-limit)))) (defmethod print-object ((wrapper wrapper) stream) (print-unreadable-object (wrapper stream :type t :identity t) @@ -137,3 +146,8 @@ (defmethod print-object ((dfun-info dfun-info) stream) (declare (type stream stream)) (print-unreadable-object (dfun-info stream :type t :identity t))) + +(defmethod print-object ((ctor ctor) stream) + (print-unreadable-object (ctor stream :type t) + (format stream "~S ~:S" (ctor-class-or-name ctor) (ctor-initargs ctor))) + ctor)