2024-09-23 11:43:05 +00:00
|
|
|
(import (scheme)
|
|
|
|
(chicken base)
|
2024-09-24 14:55:41 +00:00
|
|
|
(chicken syntax)
|
|
|
|
(srfi 152))
|
2024-09-23 11:43:05 +00:00
|
|
|
|
|
|
|
(define (snake-upcase in)
|
|
|
|
(string-map (lambda (c)
|
|
|
|
(if (char=? #\- c)
|
|
|
|
#\_
|
2024-09-24 14:55:41 +00:00
|
|
|
(char-upcase c)))
|
|
|
|
in))
|
2024-09-23 11:43:05 +00:00
|
|
|
|
|
|
|
(define-syntax define-sdl-flag
|
|
|
|
(er-macro-transformer
|
|
|
|
(lambda (exp rename compare)
|
|
|
|
(let ((flag (cadr exp)))
|
|
|
|
`(begin
|
|
|
|
(export ,flag)
|
|
|
|
(define ,flag
|
|
|
|
(foreign-value
|
|
|
|
,(string-append "SDL_" (snake-upcase (symbol->string flag)))
|
|
|
|
unsigned-int32)))))))
|
|
|
|
|
|
|
|
(define-syntax define-sdl-enum-values
|
|
|
|
(er-macro-transformer
|
|
|
|
(lambda (exp rename compare)
|
|
|
|
(let ((prefix (cadr exp))
|
|
|
|
(type (caddr exp))
|
|
|
|
(enum-labels (cdddr exp)))
|
|
|
|
`(begin
|
|
|
|
,@(map (lambda (enum-label)
|
|
|
|
(let ((full-str (string-append (symbol->string prefix)
|
|
|
|
"-" (symbol->string enum-label))))
|
|
|
|
`(begin
|
|
|
|
(export ,(string->symbol full-str))
|
|
|
|
(define ,(string->symbol full-str)
|
|
|
|
(foreign-value
|
|
|
|
,(string-append "SDL_" (snake-upcase full-str))
|
|
|
|
,type)))))
|
|
|
|
enum-labels))))))
|