From dd6da0fe5f0f08f61e3f3fb009538ffa56fd4fb4 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 7 Mar 2019 10:15:58 -0800 Subject: [PATCH] notes --- xenomorph/xenomorph/pointer.rkt | 16 ++++++++++++++++ xenomorph/xenomorph/test/pointer-test.rkt | 3 +++ 2 files changed, 19 insertions(+) diff --git a/xenomorph/xenomorph/pointer.rkt b/xenomorph/xenomorph/pointer.rkt index 3ffcb4e5..e0539b99 100644 --- a/xenomorph/xenomorph/pointer.rkt +++ b/xenomorph/xenomorph/pointer.rkt @@ -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] diff --git a/xenomorph/xenomorph/test/pointer-test.rkt b/xenomorph/xenomorph/test/pointer-test.rkt index 54f97b18..95fd45b2 100644 --- a/xenomorph/xenomorph/test/pointer-test.rkt +++ b/xenomorph/xenomorph/test/pointer-test.rkt @@ -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))])