X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=mop.lisp;h=6a942da77ffbc35ad305c82f274d8a9aacdf4ac6;hb=4f4c2990af9e7fba7f1e2b25fab5327d6ae63040;hp=49dd87d50beadc3994b27f9921d4c97b64f0aa3e;hpb=ae806c523aa7162f356b95ba8826e393ab55e420;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index 49dd87d..6a942da 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.20 2003/03/29 04:20:19 kevin Exp $ +;;;; $Id: mop.lisp,v 1.41 2003/04/12 03:14:29 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -194,7 +194,7 @@ (defmethod compute-effective-slot-definition :around ((cl hyperobject-class) #+(or allegro lispworks) name dsds) - #+allergo (declare (ignore name)) + #+allegro (declare (ignore name)) (let* ((dsd (car dsds)) (value-type (canonicalize-value-type (slot-value dsd 'value-type)))) (multiple-value-bind (sql-type length) (value-type-to-sql-type value-type) @@ -281,15 +281,41 @@ (setf (slot-value ,the-instance ,the-slot-name) (,reader ,@keys))))) -#+(or sbcl scl cmu) -(defparameter *queued-definitions* nil) +#+lispworks +(defun intern-eql-specializer (slot) + `(eql ,slot)) -(defun process-queued-definitions () - #+(or sbcl scl cmu) - (progn - (dolist (def *queued-definitions*) - (eval def)) - (setq *queued-definitions* nil))) +#+(or sbcl scl cmu lispworks) +(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)) + #-lispworks + `(lambda (the-class the-instance the-slot-name) + (declare (ignore the-class)) + (setf (slot-value the-instance the-slot-name) (,reader ,@keys))) + #+lispworks + '(the-class the-instance the-slot-name) + #+lispworks + nil + #+lispworks + `(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" @@ -307,17 +333,21 @@ nil (cdr subobj-def))))) (unless (eq (lookup subobject) t) - #+(or sbcl scl cmu) - (push `(def-lazy-reader ,(name-class subobject) - ,(name-slot subobject) ,(lookup subobject) - ,@(lookup-keys subobject)) - *queued-definitions*) - #-(or sbcl scl cmu) - (eval `(def-lazy-reader ,(name-class subobject) - ,(name-slot subobject) ,(lookup subobject) - ,@(lookup-keys subobject)))) + #-(or sbcl cmu scl lispworks) + (eval + `(hyperobject::def-lazy-reader ,(name-class subobject) + ,(name-slot subobject) ,(lookup subobject) + ,@(lookup-keys subobject))) + #+(or sbcl cmu scl lispworks) + (apply #'ensure-lazy-reader + (name-class subobject) (name-slot subobject) (lookup subobject) (lookup-keys subobject)) + ) (push subobject subobjects)))) - subobjects))) + ;; allegro and lispworks reverse class-slots compared to the defclass form + ;; subobject is already reversed from the dolist/push loop, so re-reverse on non-allegro/lispworks + #+(or lispworks allegro) subobjects + #-(or lispworks allegro) (nreverse subobjects) + ))) (defun finalize-documentation (cl) "Calculate class documentation slot" @@ -355,6 +385,9 @@ :lookup it :link-parameters (slot-value esd 'hyperlink-parameters)) hyperlinks))) + ;; allegro and lispworks reverse class-slots compared to the defclass form + ;; hyperlinks is already reversed from the dolist/push loop, so re-reverse on non-allegro/lispworks + #-(or lispworks allegro) (setq hyperlinks (nreverse hyperlinks)) (setf (slot-value cl 'hyperlinks) hyperlinks))) (defun init-hyperobject-class (cl) @@ -387,5 +420,7 @@ (hyperlinks (class-of obj))) (defun hyperobject-class-fields (obj) - (class-slots (class-of obj))) + ;; allegro and lispworks reverse class-slots + #+(or allegro lispworks) (reverse (class-slots (class-of obj))) + #-(or allegro lispworks) (class-slots (class-of obj)))