1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; a c t i v e - s l o t . s t k l o s -- Active slots metaclass
|
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Copyright <20> 1996-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Permission to use, copy, modify, distribute,and license this
|
|
|
|
|
;;;; software and its documentation for any purpose is hereby granted,
|
|
|
|
|
;;;; provided that existing copyright notices are retained in all
|
|
|
|
|
;;;; copies and that this notice is included verbatim in any
|
|
|
|
|
;;;; distributions. No written agreement, license, or royalty fee is
|
|
|
|
|
;;;; required for any of the authorized uses.
|
|
|
|
|
;;;; This software is provided ``AS IS'' without express or implied
|
|
|
|
|
;;;; warranty.
|
1998-04-10 06:59:06 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; Author: Erick Gallesio [eg@unice.fr]
|
|
|
|
|
;;;; Creation date: 17-Oct-1996 18:16
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Last file update: 3-Sep-1999 20:05 (eg)
|
1998-04-10 06:59:06 -04:00
|
|
|
|
|
|
|
|
|
(select-module STklos)
|
|
|
|
|
|
|
|
|
|
(define-class <Active-metaclass> (<class>)
|
|
|
|
|
())
|
|
|
|
|
|
|
|
|
|
(define-method compute-get-n-set ((class <Active-metaclass>) slot)
|
|
|
|
|
(if (eq? (get-slot-allocation slot) :active)
|
|
|
|
|
(let* ((index (slot-ref class 'nfields))
|
|
|
|
|
(name (car slot))
|
|
|
|
|
(s (cdr slot))
|
|
|
|
|
(env (class-environment class))
|
|
|
|
|
(before-ref (make-closure (get-keyword :before-slot-ref s #f) env))
|
|
|
|
|
(after-ref (make-closure (get-keyword :after-slot-ref s #f) env))
|
|
|
|
|
(before-set! (make-closure (get-keyword :before-slot-set! s #f) env))
|
|
|
|
|
(after-set! (make-closure (get-keyword :after-slot-set! s #f) env))
|
|
|
|
|
(unbound (make-unbound)))
|
|
|
|
|
(slot-set! class 'nfields (+ index 1))
|
|
|
|
|
(list (lambda (o)
|
|
|
|
|
(if before-ref
|
|
|
|
|
(if (before-ref o)
|
|
|
|
|
(let ((res (%fast-slot-ref o index)))
|
|
|
|
|
(and after-ref (not (eqv? res unbound)) (after-ref o))
|
|
|
|
|
res)
|
|
|
|
|
(make-unbound))
|
|
|
|
|
(let ((res (%fast-slot-ref o index)))
|
|
|
|
|
(and after-ref (not (eqv? res unbound)) (after-ref o))
|
|
|
|
|
res)))
|
|
|
|
|
|
|
|
|
|
(lambda (o v)
|
|
|
|
|
(if before-set!
|
|
|
|
|
(when (before-set! o v)
|
|
|
|
|
(%fast-slot-set! o index v)
|
|
|
|
|
(and after-set! (after-set! o v)))
|
|
|
|
|
(begin
|
|
|
|
|
(%fast-slot-set! o index v)
|
|
|
|
|
(and after-set! (after-set! o v)))))))
|
|
|
|
|
(next-method)))
|