X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=mop.lisp;h=ca59a1c31eaf82f5a7f83ad5d20412a86595dde5;hb=61c28767dc6071b3f8edf0834aeab94eb40c3352;hp=54f685979f77a2681d69c6766caf1ee29daa3bb1;hpb=2ec170fb14c93a96313863aa47892bf1187503dc;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index 54f6859..ca59a1c 100644 --- a/mop.lisp +++ b/mop.lisp @@ -11,7 +11,7 @@ ;;;; in Text, HTML, and XML formats. This includes hyperlinking ;;;; capability and sub-objects. ;;;; -;;;; $Id: mop.lisp,v 1.17 2002/12/26 23:18:16 kevin Exp $ +;;;; $Id: mop.lisp,v 1.34 2003/03/29 20:58:09 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -281,6 +281,31 @@ (setf (slot-value ,the-instance ,the-slot-name) (,reader ,@keys))))) +#+(or sbcl scl cmu) +(defun ensure-lazy-reader (class-name slot-name reader &rest reader-keys) + (let ((keys nil) + (gf (ensure-generic-function 'slot-unbound))) + (dolist (key reader-keys) + (push (list 'slot-value 'the-instance (list 'quote key)) keys)) + (setq keys (nreverse keys)) + (multiple-value-bind (method-lambda init-args-values) + (make-method-lambda + gf + (class-prototype (generic-function-method-class gf)) + `(lambda (the-class the-instance the-slot-name) + (declare (ignore the-class)) + (setf (slot-value the-instance the-slot-name) (,reader ,@keys))) + nil) + (add-method gf + (apply + #'make-instance (generic-function-method-class gf) + ':specializers (list (class-of (find-class class-name)) + (find-class class-name) + (intern-eql-specializer slot-name)) + ':lambda-list '(the-class the-instance the-slot-name) + ':function (compile nil method-lambda) + init-args-values))))) + (defun finalize-subobjects (cl) "Process class subobjects slot" (setf (subobjects cl) @@ -297,9 +322,15 @@ nil (cdr subobj-def))))) (unless (eq (lookup subobject) t) - (eval `(def-lazy-reader ,(name-class subobject) - ,(name-slot subobject) ,(lookup subobject) - ,@(lookup-keys subobject)))) + #-(or sbcl cmu scl) + (eval + `(hyperobject::def-lazy-reader ,(name-class subobject) + ,(name-slot subobject) ,(lookup subobject) + ,@(lookup-keys subobject))) + #+(or sbcl cmu scl) + (apply #'ensure-lazy-reader + (name-class subobject) (name-slot subobject) (lookup subobject) (lookup-keys subobject)) + ) (push subobject subobjects)))) subobjects)))