X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=mop.lisp;h=0002d566f2f016374a6c3175232660bb9570e7b5;hb=224c382d0d7fa09a5c86bfb1a8479ac380a094c6;hp=c30c8c6169a592d6534d86bef488878a81e03fbe;hpb=1cfeecff23fb7fd5a3ae7c6e2f049e943bfbc3ba;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index c30c8c6..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.24 2003/03/29 07:32:50 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,28 +281,28 @@ (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* "~W~%" 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 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" @@ -320,10 +320,15 @@ nil (cdr subobj-def))))) (unless (eq (lookup subobject) t) - (add-definition + #-(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)))