;;;; 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.38 2003/04/04 00:00:07 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
;;;;
(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)
(setf (slot-value ,the-instance ,the-slot-name)
(,reader ,@keys)))))
+#+lispworks
+(defun intern-eql-specializer (slot)
+ `(eql ,slot))
+
+#+(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
+ '(declare (ignore the-class))
+ #+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"
(setf (subobjects cl)
nil
(cdr subobj-def)))))
(unless (eq (lookup subobject) t)
+ #-(or sbcl cmu scl lispworks)
(eval
`(hyperobject::def-lazy-reader ,(name-class subobject)
,(name-slot subobject) ,(lookup subobject)
- ,@(lookup-keys 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)))