Add type db, some nice macro features and a brand new SDL3 example #27

Merged
pkulev merged 14 commits from sdl-example into main 2026-09-18 00:11:05 +02:00
Showing only changes of commit 85bf1c163c - Show all commits

View File

@@ -123,20 +123,21 @@
(out-file (if (eq? output 'default) (out-file (if (eq? output 'default)
"a.out" "a.out"
output))) output)))
;; `process' hands back one record. Its port accessors are named ;; The generated C goes to a temporary .c file rather than the
;; from the *child's* point of view, so `process-input-port' is the ;; compiler's stdin
;; port we write to: the C compiler's stdin. (let ((c-file (create-temporary-file "c")))
(let* ((proc (process compiler (append (list "-o" out-file "-x" "c") (with-output-to-file c-file
(if (get-arg args 'compile-object #f)
(list "-c")
(list))
(list "-") ; read stdin
cc-args)))
(cc-stdin (process-input-port proc)))
(with-output-to-port cc-stdin
(lambda () (emit-c sex-forms))) (lambda () (emit-c sex-forms)))
(close-output-port cc-stdin) (let ((proc (process compiler (append (list "-o" out-file)
(process-wait proc)))) (if (get-arg args 'compile-object #f)
(list "-c")
(list))
(list c-file)
cc-args))))
(call-with-values (lambda () (process-wait proc))

These wait values never become the process exit code: main ignores what compile-to-file returns, so sexc file.sex -- -bogus-flag prints the cc error and exits 0. sextest then treats that as a successful compile. Also delete-file* only runs after wait; if emit-c throws, the temp .c stays in /tmp.

These wait values never become the process exit code: `main` ignores what `compile-to-file` returns, so `sexc file.sex -- -bogus-flag` prints the cc error and exits 0. `sextest` then treats that as a successful compile. Also `delete-file*` only runs after wait; if `emit-c` throws, the temp `.c` stays in `/tmp`.
(lambda status
(delete-file* c-file)
(apply values status)))))))
(define (semantic-process-forms raw-forms input-source) (define (semantic-process-forms raw-forms input-source)
(if (eq? input-source 'stdin) (if (eq? input-source 'stdin)