main
Matthew Butterick 6 years ago
parent 19445f94bd
commit 539a53014c

@ -53,8 +53,8 @@
(define encode-result (inner (error 'xxencode-not-augmented) xxencode (pre-encode val) output-port parent))
(when (bytes? encode-result) (write-bytes encode-result output-port)))
(define/pubment (xxsize [val #f] [parent #f] . _)
(define size (inner 0 xxsize val parent))
(define/pubment (xxsize [val #f] [parent #f] . args)
(define size (inner 0 xxsize val parent . args))
(unless (and (integer? size) (not (negative? size)))
(raise-argument-error 'size "nonnegative integer" size))
size)

@ -75,7 +75,6 @@ https://github.com/mbutterick/restructure/blob/master/test/Struct.coffee
'nameLength uint8
'name (+xstring 'nameLength)
'age uint8))
;(set-pre-encode! struct (λ (val) (dict-set! val 'nameLength (string-length (dict-ref val 'name))) val))
(encode struct (mhasheq 'name "roxyb" 'age 21))
(check-equal? (get-output-bytes (current-output-port)) #"\x05roxyb\x15")))

Loading…
Cancel
Save