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 522c5a2c01 - Show all commits

View File

@@ -291,11 +291,26 @@ forms, and what remains."
(else
(type-convert-to-c form))))
(define (has-pointer-star? form)
(and (pair? form)
(or (memq '* form)
(any has-pointer-star? (filter pair? form)))))
;;; A `*' inside a sublist. Pointer chains are written flat -- (* * T),
;;; never (* (* T))
;;; Sublists that merely group, like (* (const struct suc)), contain
;;; no `*' and are fine.
(define (nested-pointer? type)
(and (pair? type)
(any has-pointer-star? (filter pair? type))))
(define (type-convert-to-c type)
;; Our pointers to C pointers
;; int -> int
;; * const char -> const char *
;; const * const char -> const char * const
(when (nested-pointer? type)
(sex-error type "pointer chains are written flat, as (* * T), not nested" type))
(if (atom? type) (atom-to-fmt-c type)
(flatten
(tree-map atom-to-fmt-c