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 8774400f1f
commit 504f35722a
4 changed files with 26 additions and 4 deletions

View File

@@ -304,7 +304,8 @@
(else (equal? pattern type))))
;;; Map function to each field/value of a structure/union/enum
;;; For enums, field-type is the type of the enum (since C 23)
;;; For enums, field-type is the type of the enum (since C 23), and
;;; field-name the enumerator's name, (wire-varint 0) or not
;;; (map-fields type-name
;;; (lambda (field-name field-type) ...))
;;;
@@ -320,7 +321,8 @@
;; declared, since `enum some-typedef' is not a C type.
((enum)
(let ((type (list 'enum (cadr info))))
(map (lambda (value) (fn value type))
(map (lambda (value)
(fn (if (pair? value) (car value) value) type))
(caddr info))))
(else #f)))))