33 lines
1.1 KiB
Scheme
33 lines
1.1 KiB
Scheme
(import (scheme)
|
|
(chicken base)
|
|
(chicken bitwise)
|
|
(chicken syntax)
|
|
(srfi 152))
|
|
|
|
(define (snake-upcase in)
|
|
(string-map (lambda (c)
|
|
(if (char=? #\- c)
|
|
#\_
|
|
(char-upcase c)))
|
|
in))
|
|
|
|
(define-syntax define-sdl-const-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))))))
|
|
|
|
(define (foldl-uint-flags flags)
|
|
(foldl bitwise-ior (car flags) (cdr flags)))
|