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:
@@ -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 . _)
|
||||
|
||||
Reference in New Issue
Block a user