diff --git a/pitfall/fontkit/directory.rkt b/pitfall/fontkit/directory.rkt index d59563de..a86ddcaf 100644 --- a/pitfall/fontkit/directory.rkt +++ b/pitfall/fontkit/directory.rkt @@ -21,11 +21,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js (define (unescape-tag tag) (symbol-replace tag "_" " ")) (define-subclass Struct (RDirectory) - (define/override (process this-res stream) + (define/augride (process this-res stream ctx) (define new-tables-val (mhash)) - (for ([table (in-list (dict-ref this-res 'tables))]) - (hash-set! new-tables-val (escape-tag (dict-ref table 'tag)) table)) - (dict-set! this-res 'tables new-tables-val)) + (for ([table (in-list (· this-res tables))]) + (hash-set! new-tables-val (escape-tag (· table tag)) table)) + (dict-set! this-res 'tables new-tables-val) + this-res) (define/override (preEncode this-val stream) (define preamble-length 12) diff --git a/pitfall/fontkit/loca.rkt b/pitfall/fontkit/loca.rkt index 5a58aaf1..51b44c7f 100644 --- a/pitfall/fontkit/loca.rkt +++ b/pitfall/fontkit/loca.rkt @@ -12,13 +12,14 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/loca.js |# (define-subclass VersionedStruct (Rloca) - (define/override (process res stream) + (define/augride (process res stream ctx) ;; in `restructure` `process` method, `res` is aliased as `this` ;; (when (= 16bit-style (· res version)) ;; in a 16bits-style loca table, actual 32bit offset values are divided by 2 (to fit into 16 bits) ;; so we re-inflate them. - (dict-update! res 'offsets (λ (offsets) (map (curry * 2) offsets))))) + (dict-update! res 'offsets (λ (offsets) (map (curry * 2) offsets)))) + res) (define/override (preEncode this-val stream) ;; this = val to be encoded diff --git a/pitfall/restructure/stream.rkt b/pitfall/restructure/stream.rkt index 182d7435..8a261b59 100644 --- a/pitfall/restructure/stream.rkt +++ b/pitfall/restructure/stream.rkt @@ -51,7 +51,7 @@ https://github.com/mbutterick/restructure/blob/master/src/EncodeStream.coffee (error 'swap-bytes-unimplemented))] [else (error 'unsupported-string-encoding)]))) -#;(test-module +(test-module (define es (+EncodeStream)) (check-true (EncodeStream? es)) (send es write #"AB") diff --git a/pitfall/restructure/versioned-struct-test.rkt b/pitfall/restructure/versioned-struct-test.rkt index 9644768c..eadf0d6b 100644 --- a/pitfall/restructure/versioned-struct-test.rkt +++ b/pitfall/restructure/versioned-struct-test.rkt @@ -256,7 +256,7 @@ https://github.com/mbutterick/restructure/blob/master/test/VersionedStruct.coffe 1 (dictify 'name (+StringT uint8 'utf8) 'age uint8 'gender uint8)))]) - (set-field! process struct (λ (o stream) (ref-set! o 'processed "true"))) + (set-field! process struct (λ (o stream ctx) (ref-set! o 'processed "true") o)) (let ([stream (+DecodeStream (+Buffer "\x00\x05devon\x15"))]) (check-equal? (send (send struct decode stream) kv) (mhasheq 'name "devon" 'processed "true" diff --git a/pitfall/restructure/versioned-struct.rkt b/pitfall/restructure/versioned-struct.rkt index b896234e..05ca5244 100644 --- a/pitfall/restructure/versioned-struct.rkt +++ b/pitfall/restructure/versioned-struct.rkt @@ -15,7 +15,7 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee (unless (and (dict? versions) (andmap (λ (val) (or (dict? val) (Struct? val))) (map cdr versions))) (raise-argument-error 'VersionedStruct "dict of dicts or Structs" versions)) - (inherit _setup _parseFields process) + (inherit _setup _parse-fields process) (inherit-field fields) (field [forced-version #f] [versionGetter void] @@ -42,7 +42,7 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee [else (send type decode stream)])) (when (ref versions 'header) - (_parseFields stream res (ref versions 'header))) + (_parse-fields stream res (ref versions 'header))) (define fields (or (ref versions (ref res 'version)) (raise-argument-error 'VersionedStruct:decode "valid version key" (cons version (· this versions))))) @@ -50,7 +50,7 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee (cond [(VersionedStruct? fields) (send fields decode stream parent)] [else - (_parseFields stream res fields) + (_parse-fields stream res fields) (process res stream) res]))