From e1cb4d5c5d2d3ef09bca926543000a229099f0ee Mon Sep 17 00:00:00 2001 From: Jan Moringen Date: Mon, 22 Feb 2016 10:17:10 +0100 Subject: [PATCH] Rearrange methods in src/pcl/documentation.lisp * Define generic behavior at the top of the file. * Group methods for TYPE-related objects by class. --- src/pcl/documentation.lisp | 73 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/pcl/documentation.lisp b/src/pcl/documentation.lisp index 9c7bbb25c..7f84be254 100644 --- a/src/pcl/documentation.lisp +++ b/src/pcl/documentation.lisp @@ -101,6 +101,23 @@ documentation))) documentation) +;;; Generic behavior + +;;; default if DOC-TYPE doesn't match one of the specified types +(defmethod documentation (object doc-type) + (warn "unsupported DOCUMENTATION: doc-type ~S for object of type ~S" + doc-type (type-of object)) + nil) + +;;; default if DOC-TYPE doesn't match one of the specified types +(defmethod (setf documentation) (new-value object doc-type) + ;; CMU CL made this an error, but since ANSI says that even for supported + ;; doc types an implementation is permitted to discard docs at any time + ;; for any reason, this feels to me more like a warning. -- WHN 19991214 + (warn "discarding unsupported DOCUMENTATION: doc-type ~S for object of type ~S" + doc-type (type-of object)) + new-value) + ;;; Deprecation note (defun maybe-add-deprecation-note (namespace name documentation) @@ -265,16 +282,27 @@ (setf (package-doc-string x) new-value)) ;;; types, classes, and structure names + (defmethod documentation ((x structure-class) (doc-type (eql 't))) (fdocumentation (class-name x) 'type)) (defmethod documentation ((x structure-class) (doc-type (eql 'type))) (fdocumentation (class-name x) 'type)) +(defmethod (setf documentation) (new-value + (x structure-class) + (doc-type (eql 't))) + (setf (fdocumentation (class-name x) 'type) new-value)) + +(defmethod (setf documentation) (new-value + (x structure-class) + (doc-type (eql 'type))) + (setf (fdocumentation (class-name x) 'type) new-value)) + (defmethod documentation ((x class) (doc-type (eql 't))) (slot-value x '%documentation)) -(defmethod documentation ((x class) (doc-type (eql 'type))) ; TODO setf +(defmethod documentation ((x class) (doc-type (eql 'type))) (slot-value x '%documentation)) (defmethod (setf documentation) (new-value @@ -297,24 +325,6 @@ (defmethod documentation ((x condition-class) (doc-type (eql 'type))) (fdocumentation (class-name x) 'type)) -(defmethod documentation ((x symbol) (doc-type (eql 'type))) - (or (fdocumentation x 'type) - (awhen (find-class x nil) - (slot-value it '%documentation)))) - -(defmethod documentation ((x symbol) (doc-type (eql 'structure))) - (fdocumentation x 'structure)) - -(defmethod (setf documentation) (new-value - (x structure-class) - (doc-type (eql 't))) - (setf (fdocumentation (class-name x) 'type) new-value)) - -(defmethod (setf documentation) (new-value - (x structure-class) - (doc-type (eql 'type))) - (setf (fdocumentation (class-name x) 'type) new-value)) - (defmethod (setf documentation) (new-value (x condition-class) (doc-type (eql 't))) @@ -325,6 +335,14 @@ (doc-type (eql 'type))) (setf (fdocumentation (class-name x) 'type) new-value)) +(defmethod documentation ((x symbol) (doc-type (eql 'type))) + (or (fdocumentation x 'type) + (awhen (find-class x nil) + (slot-value it '%documentation)))) + +(defmethod documentation ((x symbol) (doc-type (eql 'structure))) + (fdocumentation x 'structure)) + (defmethod (setf documentation) (new-value (x symbol) (doc-type (eql 'type))) (if (or (structure-type-p x) (condition-type-p x)) (setf (fdocumentation x 'type) new-value) @@ -354,23 +372,6 @@ (t (ignore-nil-doc 'variable) new-value))) - -;;; default if DOC-TYPE doesn't match one of the specified types -(defmethod documentation (object doc-type) - (warn "unsupported DOCUMENTATION: doc-type ~S for object of type ~S" - doc-type - (type-of object)) - nil) - -;;; default if DOC-TYPE doesn't match one of the specified types -(defmethod (setf documentation) (new-value object doc-type) - ;; CMU CL made this an error, but since ANSI says that even for supported - ;; doc types an implementation is permitted to discard docs at any time - ;; for any reason, this feels to me more like a warning. -- WHN 19991214 - (warn "discarding unsupported DOCUMENTATION: doc-type ~S for object of type ~S" - doc-type - (type-of object)) - new-value) ;;; extra-standard methods, for getting at slot documentation (defmethod documentation ((slotd standard-slot-definition) (doc-type (eql 't))) -- 2.11.4.GIT