convert enumerators written with a value

(wire-varint 0) is a pair, and both the writer and map-fields only
expected a name: the writer passed it out unconverted, and a macro
mapping over the enum was handed the pair.

Fixes #46.
This commit is contained in:
2026-10-09 15:59:16 +03:00
parent 816c1db9ed
commit c06845a80a
4 changed files with 26 additions and 4 deletions

View File

@@ -450,11 +450,17 @@ forms, and what remains."
(('enum (? symbol? name))
`(enum ,(atom-to-fmt-c name)))
(('enum (values ...))
`(enum ,(map atom-to-fmt-c values)))
`(enum ,(map walk-enumerator values)))
(('enum name (values ...))
`(enum ,(atom-to-fmt-c name) ,(map atom-to-fmt-c values)))
`(enum ,(atom-to-fmt-c name) ,(map walk-enumerator values)))
(else (sex-error form "malformed enum" form))))
;;; red -> red, (wire-varint 0) -> wire_varint = 0
(define (walk-enumerator value)
(match value
((name expr) (list (atom-to-fmt-c name) (walk-expr expr)))
(_ (atom-to-fmt-c value))))
(define (walk-extern form)
(match form
(('fn . _)