main
Matthew Butterick 6 years ago
parent 2a05b0c379
commit dd6da0fe5f

@ -90,6 +90,22 @@ https://github.com/mbutterick/restructure/blob/master/src/Pointer.coffee
(+ (hash-ref new-parent x:pointer-size-key) (send type size val new-parent)))))
(send @offset-type size))))
#|
The arguments here are renamed slightly compared to the original.
offsetType => offset-type
The type of the thing the pointer points to.
type => type
The type of the pointer value itself.
options.type => relative-to
The reference point of the pointer value (local, immediate, parent, global). It was confusing to have two things named `type`, however.
relativeTo => [not supported]
This allows the pointer to be calculated relative to a property on the parent. I saw no use for this, so I dropped it.
|#
(define (x:pointer [offset-arg #f] [type-arg #f]
#:offset-type [offset-kwarg #f]
#:type [type-kwarg #f]

@ -43,6 +43,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Pointer.coffee
(check-equal? (decode (x:pointer #:relative-to 'global) #:parent (mhash x:parent-key (mhash x:parent-key (mhash x:start-offset-key 2))))
53)))
;; skipping
;; 'should support offsets relative to a property on the parent'
(test-case
"pointer: decode should support returning pointer if there is no decode type"
(parameterize ([current-input-port (open-input-bytes (bytes 4))])

Loading…
Cancel
Save