X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=mop.lisp;h=0002d566f2f016374a6c3175232660bb9570e7b5;hb=224c382d0d7fa09a5c86bfb1a8479ac380a094c6;hp=03cb099a3bc36fbe90dd8eacd8996b6e380dd1b1;hpb=3e5379739ac86e30f191961b15dd69f3516bf0f0;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index 03cb099..0002d56 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.26 2003/03/29 13:57:07 kevin Exp $ +;;;; $Id: mop.lisp,v 1.27 2003/03/29 20:11:09 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -281,6 +281,29 @@ (setf (slot-value ,the-instance ,the-slot-name) (,reader ,@keys))))) +#+(or sbcl scl cmu) +(defun ensure-lazy-reader (class 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)))) + (print init-args-values) + (add-method gf + (make-instance (generic-function-method-class gf) + ':specializers (list t class (intern-eql-specializer slot-name)) + ':lambda-list '(the-class the-instance the-slot-name) + ':function `(function ,method-lambda) + ;;init-args-values + ))))) + (defun finalize-subobjects (cl) "Process class subobjects slot" (setf (subobjects cl) @@ -297,10 +320,15 @@ nil (cdr subobj-def))))) (unless (eq (lookup subobject) t) + #-(or sbcl cmu scl) (eval `(hyperobject::def-lazy-reader ,(name-class subobject) ,(name-slot subobject) ,(lookup subobject) - ,@(lookup-keys 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)))