main
Matthew Butterick 6 years ago
parent 62923bd1f0
commit f8bb9db270

@ -66,7 +66,6 @@ https://github.com/mbutterick/restructure/blob/master/src/Struct.coffee
x:pointer-size-key 0))
(hash-set! parent x:pointer-offset-key (+ (pos port) (size field-data parent #f)))
(for ([(key type) (in-dict @fields)])
#R (list key 'in-struct)
(send type encode (dict-ref field-data key) port parent))
(for ([ptr (in-list (hash-ref parent x:pointers-key))])
(match ptr

@ -80,15 +80,12 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
(unless (andmap (λ (key) (member key (dict-keys field-data))) (dict-keys fields))
(raise-argument-error 'x:versioned-struct-encode (format "hash that contains superset of xversioned-struct keys: ~a" (dict-keys fields)) (dict-keys field-data)))
(for ([(key type) (in-dict fields)])
#R (list key 'in-verseioned-struct)
(send type encode (dict-ref field-data key) port parent))
#R (list 'broccoli (length (dict-ref parent x:pointers-key)))
(let loop ([i 0])
(when (< i (length (dict-ref parent x:pointers-key)))
(define ptr (list-ref (dict-ref parent x:pointers-key) i))
#R 'all-the-marbles
(match ptr
[(x:ptr type val parent) #R i (send type encode val port parent)])
[(x:ptr type val parent) i (send type encode val port parent)])
(loop (add1 i)))))
(define/override (size [val-arg #f] [parent-arg #f] [include-pointers #t])

Loading…
Cancel
Save