From b29393b840818e21c17476b87df52b443ce7cf30 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 1 Jun 2003 04:19:12 +0000 Subject: [PATCH] .. original commit: 99d4ae8b1373b106a897126bf9a342428531826c --- collects/mzlib/surrogate.ss | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/collects/mzlib/surrogate.ss b/collects/mzlib/surrogate.ss index ba6f22e..7bba197 100644 --- a/collects/mzlib/surrogate.ss +++ b/collects/mzlib/surrogate.ss @@ -83,7 +83,7 @@ (map make-empty-method (syntax->list (syntax (method-spec ...))))]) - (syntax + (syntax/loc stx (let ([surrogate<%> (interface () on-disable-surrogate @@ -91,21 +91,25 @@ ids ...)]) (values (lambda (super%) - (class* super% (delegating<%>) + (class* super% (host<%>) (field [surrogate #f]) (define/public (set-surrogate d) (when surrogate (send surrogate on-disable-surrogate this)) + + ;; error checking (when d (unless (object? d) (error 'set-surrogate "expected an object, got: ~e" d)) - (let ([methods-to-impl '(on-enable on-disable ids ...)] + (let ([methods-to-impl '(on-enable-surrogate on-disable-surrogate ids ...)] [i (object-interface d)]) (for-each (lambda (x) (unless (method-in-interface? x i) (error 'set-surrogate "expected object to implement an ~s method" x))) - methods-to-impl)) - (set! surrogate d) + methods-to-impl))) + + (set! surrogate d) + (when surrogate (send surrogate on-enable-surrogate this))) (define/public (get-surrogate) surrogate) @@ -114,8 +118,8 @@ (super-new))) (class* object% (surrogate<%>) - (define/public (on-enable-surrogate) (void)) - (define/public (on-disable-surrogate) (void)) + (define/public (on-enable-surrogate x) (void)) + (define/public (on-disable-surrogate x) (void)) empty-methods ... (super-new)) surrogate<%>))))])))