diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 64b765696..5528486a4 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2003-04-15 Mikael Djurfeldt + + * goops.c (scm_sys_fast_slot_ref): Use SCM_SLOT instead of + scm_at_assert_bound_ref. (We don't want the unbound check. See + oop/goops/active-slot.scm.) + 2003-04-14 Rob Browning * tags.h: scm_t_intptr should have been intptr_t. diff --git a/libguile/goops.c b/libguile/goops.c index cf3bbccaa..02c18baac 100644 --- a/libguile/goops.c +++ b/libguile/goops.c @@ -1074,7 +1074,7 @@ SCM_DEFINE (scm_sys_fast_slot_ref, "%fast-slot-ref", 2, 0, 0, i = SCM_INUM (index); SCM_ASSERT_RANGE (2, index, i < SCM_NUMBER_OF_SLOTS (obj)); - return scm_at_assert_bound_ref (obj, index); + return SCM_SLOT (obj, i); } #undef FUNC_NAME diff --git a/oop/ChangeLog b/oop/ChangeLog index 010d722c8..d37db7226 100644 --- a/oop/ChangeLog +++ b/oop/ChangeLog @@ -1,3 +1,11 @@ +2003-04-15 Mikael Djurfeldt + + * goops.scm (compute-getter-method): For custom getter: Check + boundness even if there is an init-thunk. (The getter can return + # even if the slot has been set before.) + (remove-class-accessors!): Also remove accessor-method from its + accessor. + 2003-04-13 Mikael Djurfeldt * goops.scm (compute-getters-n-setters/verify-accessors): Better diff --git a/oop/goops.scm b/oop/goops.scm index 4eb8a0cd3..360712122 100644 --- a/oop/goops.scm +++ b/oop/goops.scm @@ -1059,7 +1059,13 @@ (define-method (remove-class-accessors! (c )) (for-each (lambda (m) (if (is-a? m ) - (remove-method-in-classes! m))) + (let ((gf (slot-ref m 'generic-function))) + ;; remove the method from its GF + (slot-set! gf 'methods + (delq1! m (slot-ref gf 'methods))) + (%invalidate-method-cache! gf) + ;; remove the method from its specializers + (remove-method-in-classes! m)))) (class-direct-methods c))) ;;; @@ -1125,10 +1131,7 @@ (make #:specializers (list class) #:procedure (cond ((pair? g-n-s) - (if init-thunk - (car g-n-s) - (make-generic-bound-check-getter (car g-n-s)) - )) + (make-generic-bound-check-getter (car g-n-s))) (init-thunk (standard-get g-n-s)) (else diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 967e8b51b..1c8a68dde 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2003-04-15 Mikael Djurfeldt + + * tests/goops.test: Added tests for class redefinition, object + update and active slots. + 2003-04-14 Rob Browning * standalone/test-asmobs-lib.c (libtest_asmobs_init): include diff --git a/test-suite/tests/goops.test b/test-suite/tests/goops.test index 08f1f58ac..722a074fa 100644 --- a/test-suite/tests/goops.test +++ b/test-suite/tests/goops.test @@ -1,6 +1,6 @@ ;;;; goops.test --- test suite for GOOPS -*- scheme -*- ;;;; -;;;; Copyright (C) 2001 Free Software Foundation, Inc. +;;;; Copyright (C) 2001, 2003 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -167,3 +167,55 @@ (eval '(and (is-a? foo ) (null? (generic-function-methods foo))) (current-module))))) + +(with-test-prefix "object update" + (pass-if "defining class" + (eval '(define-class () + (x #:accessor x #:init-value 123) + (z #:accessor z #:init-value 789)) + (current-module)) + (eval '(is-a? ) (current-module))) + (pass-if "making instance" + (eval '(define foo (make )) (current-module)) + (eval '(and (is-a? foo ) (= (x foo) 123)) (current-module))) + (pass-if "redefining class" + (eval '(define-class () + (x #:accessor x #:init-value 123) + (y #:accessor y #:init-value 456) + (z #:accessor z #:init-value 789)) + (current-module)) + (eval '(and (= (y foo) 456) (= (z foo) 789)) (current-module)))) + +(use-modules (oop goops active-slot)) + +(with-test-prefix "active-slot" + (pass-if "defining class with active slot" + (eval '(begin + (define z '()) + (define-class () + (x #:accessor x + #:init-value 1 + #:allocation #:active + #:before-slot-ref + (lambda (o) + (set! z (cons 'before-ref z)) + #t) + #:after-slot-ref + (lambda (o) + (set! z (cons 'after-ref z))) + #:before-slot-set! + (lambda (o v) + (set! z (cons* v 'before-set! z))) + #:after-slot-set! + (lambda (o v) + (set! z (cons* v (x o) 'after-set! z)))) + #:metaclass ) + (define bar (make )) + (x bar) + (set! (x bar) 2) + (equal? (reverse z) + '(before-ref before-set! 1 before-ref after-ref + after-set! 1 1 before-ref after-ref + before-set! 2 before-ref after-ref after-set! 2 2))) + (current-module)))) +