X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=mop.lisp;h=b18672ca4ef97b38aa27e5fecbd9eb30d131d850;hb=e247c616f76b76e8171a6c62484ed849977cf981;hp=f40287473d92d2e75fa272f407b3774e3216ecac;hpb=509f5717bbb67f567741531ca7f2b34a9f8939f9;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index f402874..b18672c 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.21 2003/03/29 07:09:41 kevin Exp $ +;;;; $Id: mop.lisp,v 1.30 2003/03/29 20:31:45 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -281,28 +281,30 @@ (setf (slot-value ,the-instance ,the-slot-name) (,reader ,@keys))))) - -(defparameter *queued-definitions-pathname* - (make-pathname :directory '(:absolute "tmp") - :name (format nil "hyperobject-def-~d" (get-universal-time)) - :type "lisp")) -(defparameter *queued-definitions-stream* nil) - -(defun add-definition (def) - (unless *queued-definitions-stream* - (setq *queued-definitions-stream* (open *queued-definitions-pathname* - :direction :output - :if-exists :supersede))) - (format *queued-definitions-stream* "~A~%" def)) - -(defun process-queued-definitions () - (when *queued-definitions-stream* - (close *queued-definitions-stream*) - (compile-file *queued-definitions-pathname*) - (load (compile-file-pathname *queued-definitions-pathname*)) - (delete-file *queued-definitions-pathname*) - (delete-file (compile-file-pathname *queued-definitions-pathname*)) - (setq *queued-definitions-stream* nil))) +#+(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 (intern-eql-specializer class-name) + (find-class class-name) + (intern-eql-specializer slot-name)) + ':lambda-list '(the-class the-instance the-slot-name) + ':function method-lambda + init-args-values))))) (defun finalize-subobjects (cl) "Process class subobjects slot" @@ -320,10 +322,15 @@ nil (cdr subobj-def))))) (unless (eq (lookup subobject) t) - (add-definition - `(def-lazy-reader ,(name-class subobject) + #-(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)))