parent parameter

main
Matthew Butterick 6 years ago
parent da3f055ee2
commit 06eb6f8cb6

@ -4,6 +4,8 @@
racket/port)
(provide (all-defined-out))
(define current-parent (make-parameter #f))
(define (->input-port arg)
(cond
[(bytes? arg) (open-input-bytes arg)]

@ -12,8 +12,9 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
(define (xversioned-struct-decode . args)
(dict->mutable-hash (apply xversioned-struct-xdecode args)))
(define/post-decode (xversioned-struct-xdecode xvs [port-arg (current-input-port)] #:parent [parent #f] [length 0])
(define/post-decode (xversioned-struct-xdecode xvs [port-arg (current-input-port)] #:parent [parent-arg #f] [length 0])
(define port (->input-port port-arg))
(define parent (or (current-parent) parent-arg))
(define res (xstruct-setup port parent length))
(dict-set! res 'version

Loading…
Cancel
Save