From b965473173d815196ac9f4d528d14a0fc524a128 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Mon, 4 Aug 2025 11:49:05 +0200 Subject: [PATCH 1/5] Special macro's for racket/gui --- gui-class.rkt | 97 +++++++++++++++++++++++++++++++++++++ scribblings/gui-class.scrbl | 21 ++++++++ 2 files changed, 118 insertions(+) create mode 100644 gui-class.rkt create mode 100644 scribblings/gui-class.scrbl diff --git a/gui-class.rkt b/gui-class.rkt new file mode 100644 index 0000000..2dcfc35 --- /dev/null +++ b/gui-class.rkt @@ -0,0 +1,97 @@ +#lang racket + +(require (rename-in racket/gui [send old-send] [new old-new])) +(require (for-syntax (rename-in roos [-> old->]))) +(require (rename-in roos [-> old->])) + +(provide (all-from-out roos) + (all-from-out racket/gui) + -> send new + ) + +(define-syntax send + (syntax-rules () + ((_ obj method) + (if (roos-object? obj) + (-> obj method) + (old-send obj method))) + ((_ obj method a ...) + (if (roos-object? obj) + (-> obj method a ...) + (old-send obj method a ...))) + )) + + + +(define-syntax -> + (syntax-rules () + ((_ obj method) + (if (roos-object? obj) + (old-> obj method) + (old-send obj method))) + ((_ obj method a ...) + (if (roos-object? obj) + (old-> obj method a ...) + (old-send obj method a ...))) + )) + +(define-syntax new* + (syntax-rules (v) + ((_ cl (x y) ...) + (old-new cl (x y) ...)) + ((_ cl x ...) + (old-new cl (v x) ...)) + )) + +(define-syntax new + (syntax-rules () + ((_ cl) + (if (roos-class? cl) + (roos-new cl) + (old-new cl))) + ((_ cl a ...) + (if (roos-class? cl) + (roos-new cl a ...) + (new* cl a ...))) + )) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Testing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(module+ test + (require rackunit) + + (define (t% x) + (class object% + (init-field (y* x)) + (define/public (y) y*) + (define/public (y! x) (set! y* x)) + (define/public (f a) (* (send this y) a)) + (super-new) + )) + + (def-roos (t x) this (supers) + (y x) + ((f a) (* (-> this y) a)) + ) + + (check-true + (let ((cl (t% 5))) + (let ((o (new cl))) + (= (send o f 2) 10)))) + + (check-true + (let ((cl (t% 6))) + (let ((o (new cl))) + (= (-> o f 3) 18)))) + + (check-true + (let ((o (new t 8))) + (= (-> o f 4) 32))) + + (check-true + (= (send (new t 4) f 2) 8)) +) + diff --git a/scribblings/gui-class.scrbl b/scribblings/gui-class.scrbl new file mode 100644 index 0000000..9332e59 --- /dev/null +++ b/scribblings/gui-class.scrbl @@ -0,0 +1,21 @@ +#lang scribble/manual + +@(require + scribble/example + @(for-label roos/gui-class)) + +@(define myeval + (make-base-eval '(require roos/class))) + + +@title[#:tag "top"]{Interoperability Macros for roos and racket/gui} + +@author[@author+email["Hans Dijkema" "hans@dijkewijk.nl"]] + +@defmodule[roos/gui-class] + +This module provides a compatibility layer between the @seclink["roos" #:doc '(lib "roos/scribblings/roos.scrbl") ]{@racketmodname[roos]} object system and the standard @racketmodname[racket/class] system. It exports the macros @racket[send], @racket[->], and @racket[new], which automatically dispatch to the appropriate implementation based on the type of the given object or class. + +This one is specifically for racket/gui. The provided macros are the same as for @seclink["roos/class" #:doc '(lib "roos/scribblings/class.scrbl")]. + +@; End of documentation From 754c90015e041521dd0f5d3a9a3cd2ab916ee0d2 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Mon, 4 Aug 2025 11:50:21 +0200 Subject: [PATCH 2/5] wrappers for racket/gui --- gui-class.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui-class.rkt b/gui-class.rkt index 2dcfc35..25a6586 100644 --- a/gui-class.rkt +++ b/gui-class.rkt @@ -1,6 +1,6 @@ #lang racket -(require (rename-in racket/gui [send old-send] [new old-new])) +(require (rename-in racket/gui [send old-send] [new old-new] [-> old-gui->])) (require (for-syntax (rename-in roos [-> old->]))) (require (rename-in roos [-> old->])) From 8548a002f1b6a10c9dfbe34c42e88e8756a5c273 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Mon, 4 Aug 2025 11:52:51 +0200 Subject: [PATCH 3/5] Updated version --- info.rkt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/info.rkt b/info.rkt index 0904bba..b0e07a3 100644 --- a/info.rkt +++ b/info.rkt @@ -10,6 +10,7 @@ '( ("scribblings/roos.scrbl" () (library) "roos") ("scribblings/class.scrbl" () (interop) "roos-class") + ("scribblings/gui-class.scrbl" () (interop) "roos-gui-class") ) ) @@ -20,3 +21,4 @@ '("racket-doc" "rackunit-lib" "scribble-lib")) + From 29d36e3e87bff28598527845e322817aac12a0b2 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Wed, 6 Aug 2025 10:11:28 +0200 Subject: [PATCH 4/5] no gui --- gui-class.rkt | 97 ------------------------------------- scribblings/gui-class.scrbl | 21 -------- 2 files changed, 118 deletions(-) delete mode 100644 gui-class.rkt delete mode 100644 scribblings/gui-class.scrbl diff --git a/gui-class.rkt b/gui-class.rkt deleted file mode 100644 index 25a6586..0000000 --- a/gui-class.rkt +++ /dev/null @@ -1,97 +0,0 @@ -#lang racket - -(require (rename-in racket/gui [send old-send] [new old-new] [-> old-gui->])) -(require (for-syntax (rename-in roos [-> old->]))) -(require (rename-in roos [-> old->])) - -(provide (all-from-out roos) - (all-from-out racket/gui) - -> send new - ) - -(define-syntax send - (syntax-rules () - ((_ obj method) - (if (roos-object? obj) - (-> obj method) - (old-send obj method))) - ((_ obj method a ...) - (if (roos-object? obj) - (-> obj method a ...) - (old-send obj method a ...))) - )) - - - -(define-syntax -> - (syntax-rules () - ((_ obj method) - (if (roos-object? obj) - (old-> obj method) - (old-send obj method))) - ((_ obj method a ...) - (if (roos-object? obj) - (old-> obj method a ...) - (old-send obj method a ...))) - )) - -(define-syntax new* - (syntax-rules (v) - ((_ cl (x y) ...) - (old-new cl (x y) ...)) - ((_ cl x ...) - (old-new cl (v x) ...)) - )) - -(define-syntax new - (syntax-rules () - ((_ cl) - (if (roos-class? cl) - (roos-new cl) - (old-new cl))) - ((_ cl a ...) - (if (roos-class? cl) - (roos-new cl a ...) - (new* cl a ...))) - )) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Testing -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(module+ test - (require rackunit) - - (define (t% x) - (class object% - (init-field (y* x)) - (define/public (y) y*) - (define/public (y! x) (set! y* x)) - (define/public (f a) (* (send this y) a)) - (super-new) - )) - - (def-roos (t x) this (supers) - (y x) - ((f a) (* (-> this y) a)) - ) - - (check-true - (let ((cl (t% 5))) - (let ((o (new cl))) - (= (send o f 2) 10)))) - - (check-true - (let ((cl (t% 6))) - (let ((o (new cl))) - (= (-> o f 3) 18)))) - - (check-true - (let ((o (new t 8))) - (= (-> o f 4) 32))) - - (check-true - (= (send (new t 4) f 2) 8)) -) - diff --git a/scribblings/gui-class.scrbl b/scribblings/gui-class.scrbl deleted file mode 100644 index 9332e59..0000000 --- a/scribblings/gui-class.scrbl +++ /dev/null @@ -1,21 +0,0 @@ -#lang scribble/manual - -@(require - scribble/example - @(for-label roos/gui-class)) - -@(define myeval - (make-base-eval '(require roos/class))) - - -@title[#:tag "top"]{Interoperability Macros for roos and racket/gui} - -@author[@author+email["Hans Dijkema" "hans@dijkewijk.nl"]] - -@defmodule[roos/gui-class] - -This module provides a compatibility layer between the @seclink["roos" #:doc '(lib "roos/scribblings/roos.scrbl") ]{@racketmodname[roos]} object system and the standard @racketmodname[racket/class] system. It exports the macros @racket[send], @racket[->], and @racket[new], which automatically dispatch to the appropriate implementation based on the type of the given object or class. - -This one is specifically for racket/gui. The provided macros are the same as for @seclink["roos/class" #:doc '(lib "roos/scribblings/class.scrbl")]. - -@; End of documentation From db9b245425f32ba43ee13aea53e0511576acc50b Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Wed, 6 Aug 2025 10:12:22 +0200 Subject: [PATCH 5/5] info --- info.rkt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/info.rkt b/info.rkt index b0e07a3..f4ee637 100644 --- a/info.rkt +++ b/info.rkt @@ -1,7 +1,7 @@ #lang info (define pkg-authors '(hnmdijkema)) -(define version "0.8.3") +(define version "0.8.5") (define license 'Apache-2.0) (define collection "roos") (define pkg-desc "A Simple (perl like) OO system for racket") @@ -10,7 +10,6 @@ '( ("scribblings/roos.scrbl" () (library) "roos") ("scribblings/class.scrbl" () (interop) "roos-class") - ("scribblings/gui-class.scrbl" () (interop) "roos-gui-class") ) )