From 4cb22853031c89db0da148d16c60d917102a57ed Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Mon, 28 Apr 2003 11:00:22 +0000 Subject: [PATCH] 0.pre8.115: Fix for SLOT-VALUE inside (SETF SLOT-VALUE-USING-CLASS), from Gerd Moellmann (test case a simplified version of KMR's hyperobject) ... don't pass a NIL wrapper to the relevant PCL functions ... one or two code cleanups and comments --- src/pcl/methods.lisp | 56 ++++++++++++++++++++++++++++++------------------ src/pcl/std-class.lisp | 29 ++++++++++++++----------- version.lisp-expr | 2 +- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/pcl/methods.lisp b/src/pcl/methods.lisp index 06e0260..8d0f176 100644 --- a/src/pcl/methods.lisp +++ b/src/pcl/methods.lisp @@ -758,6 +758,22 @@ *standard-method-combination*)) type))))) + +;;; CMUCL (Gerd's PCL, 2002-04-25) comment: +;;; +;;; Return two values. First value is a function to be stored in +;;; effective slot definition SLOTD for reading it with +;;; SLOT-VALUE-USING-CLASS, setting it with (SETF +;;; SLOT-VALUE-USING-CLASS) or testing it with +;;; SLOT-BOUNDP-USING-CLASS. GF is one of these generic functions, +;;; TYPE is one of the symbols READER, WRITER, BOUNDP. CLASS is +;;; SLOTD's class. +;;; +;;; Second value is true if the function returned is one of the +;;; optimized standard functions for the purpose, which are used +;;; when only standard methods are applicable. +;;; +;;; FIXME: Change all these wacky function names to something sane. (defun get-accessor-method-function (gf type class slotd) (let* ((std-method (standard-svuc-method type)) (str-method (structure-svuc-method type)) @@ -768,27 +784,25 @@ (values (if std-p (get-optimized-std-accessor-method-function class slotd type) - (get-accessor-from-svuc-method-function - class slotd - (get-secondary-dispatch-function - gf methods types - `((,(car (or (member std-method methods) - (member str-method methods) - (error "error in get-accessor-method-function"))) - ,(get-optimized-std-slot-value-using-class-method-function - class slotd type))) - (unless (and (eq type 'writer) - (dolist (method methods t) - (unless (eq (car (method-specializers method)) - *the-class-t*) - (return nil)))) - (let ((wrappers (list (wrapper-of class) - (class-wrapper class) - (wrapper-of slotd)))) - (if (eq type 'writer) - (cons (class-wrapper *the-class-t*) wrappers) - wrappers)))) - type)) + (let* ((optimized-std-fun + (get-optimized-std-slot-value-using-class-method-function + class slotd type)) + (method-alist + `((,(car (or (member std-method methods) + (member str-method methods) + (bug "error in ~S" + 'get-accessor-method-function))) + ,optimized-std-fun))) + (wrappers + (let ((wrappers (list (wrapper-of class) + (class-wrapper class) + (wrapper-of slotd)))) + (if (eq type 'writer) + (cons (class-wrapper *the-class-t*) wrappers) + wrappers))) + (sdfun (get-secondary-dispatch-function + gf methods types method-alist wrappers))) + (get-accessor-from-svuc-method-function class slotd sdfun type))) std-p))) ;;; used by OPTIMIZE-SLOT-VALUE-BY-CLASS-P (vector.lisp) diff --git a/src/pcl/std-class.lisp b/src/pcl/std-class.lisp index 76b3343..2f88079 100644 --- a/src/pcl/std-class.lisp +++ b/src/pcl/std-class.lisp @@ -86,6 +86,20 @@ (compute-slot-accessor-info slotd type gf))) (initialize-internal-slot-gfs name))) +;;; CMUCL (Gerd PCL 2003-04-25) comment: +;;; +;;; Compute an effective method for SLOT-VALUE-USING-CLASS, (SETF +;;; SLOT-VALUE-USING-CLASS) or SLOT-BOUNDP-USING-CLASS for reading/ +;;; writing/testing effective slot SLOTD. +;;; +;;; TYPE is one of the symbols READER, WRITER or BOUNDP, depending on +;;; GF. Store the effective method in the effective slot definition +;;; object itself; these GFs have special dispatch functions calling +;;; effective methods directly retrieved from effective slot +;;; definition objects, as an optimization. +;;; +;;; FIXME: Change the function name to COMPUTE-SVUC-SLOTD-FUNCTION, +;;; or some such. (defmethod compute-slot-accessor-info ((slotd effective-slot-definition) type gf) (let* ((name (slot-value slotd 'name)) @@ -916,18 +930,9 @@ (setf (plist-value class 'default-initargs) inits)) (defmethod compute-default-initargs ((class slot-class)) - (let ((cpl (class-precedence-list class)) - (direct (class-direct-default-initargs class))) - (labels ((walk (tail) - (if (null tail) - nil - (let ((c (pop tail))) - (append (if (eq c class) - direct - (class-direct-default-initargs c)) - (walk tail)))))) - (let ((initargs (walk cpl))) - (delete-duplicates initargs :test #'eq :key #'car :from-end t))))) + (let ((initargs (loop for c in (class-precedence-list class) + append (class-direct-default-initargs c)))) + (delete-duplicates initargs :test #'eq :key #'car :from-end t))) ;;;; protocols for constructing direct and effective slot definitions diff --git a/version.lisp-expr b/version.lisp-expr index 6653b46..52a08f4 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.pre8.114" +"0.pre8.115" -- 1.7.10.4