resolve typedefs in get-fields and map-fields

Now these macro helpers take in account the possibility of typedefing
one type to another, and correctly find the one intended
This commit is contained in:
2026-09-16 01:18:20 +03:00
parent 847bb14340
commit 97ef62b7f4
5 changed files with 76 additions and 11 deletions

View File

@@ -14,7 +14,7 @@
SEXC ?= ../../sexc
EXPECTED = hello, world\nhello, sex\n2 greetings\ntext times \nmood 1
EXPECTED = hello, world\nhello, sex\n2 greetings\ntext times \ntext times \nmood 1
check:
@$(SEXC) greet.sex -c -o greet.o

View File

@@ -21,6 +21,9 @@
(printf "%d greetings\n" greet-count)
(describe-fields greeting)
(printf "\n")
;; ...and through the imported typedef for it
(describe-fields greeting-t)
(printf "\n")
(var m (enum mood) grumpy)
(printf "mood %d\n" m)
(return 0))

View File

@@ -13,6 +13,8 @@
(pub enum mood (cheerful grumpy))
(pub typedef greeting-t (struct greeting))
;;; Compile-time reflection across the module boundary: both the macro
;;; and the struct it asks about are exported, and the importing unit
;;; has to know the struct's fields to expand this.