main
Matthew Butterick 8 years ago
parent 7fa2496a66
commit 07ed46e23b

@ -186,8 +186,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
;; GPOSLookup.versions[9].extension.type = GPOSLookup;
(define gpos-common-dict (dictify 'scriptList (+Pointer uint16be ScriptList)
'featureList (+Pointer uint16be FeatureList)
'lookupList (+Pointer uint16be (LookupList GPOSLookup))
;'featureList (+Pointer uint16be FeatureList)
;'lookupList (+Pointer uint16be (LookupList GPOSLookup))
))
(define-subclass VersionedStruct (GPOS-MainVersionedStruct))

@ -8,6 +8,7 @@ https://github.com/mbutterick/restructure/blob/master/src/Array.coffee
|#
(define-subclass Streamcoder (Array type [length_ #f] [lengthType 'count])
(inherit-field res)
(define/augride (decode stream [parent #f])
(define pos (· stream pos))
@ -23,10 +24,10 @@ https://github.com/mbutterick/restructure/blob/master/src/Array.coffee
(floor (/ (send stream length) (send type size)))]))
(when (Number? length_)
(set-field! parent ctx parent)
(set-field! _startOffset ctx pos)
(set-field! _currentOffset ctx 0)
(set-field! _length ctx length_))
(hash-set! (· ctx res) 'parent parent)
(hash-set! (· ctx res) '_startOffset pos)
(hash-set! (· ctx res) '_currentOffset 0)
(hash-set! (· ctx res) '_length length_))
(define res (caseq lengthType
[(bytes) (error 'array-decode-bytes-no!)]

@ -4,15 +4,9 @@
(define RestructureBase
(class object%
(super-new)
(field [_startOffset #f]
[_currentOffset #f]
[_length #f]
[parent #f])
(define/public (decode stream . args)
(set! _startOffset (and (object? stream) (send stream pos)))
(set! parent (and (pair? args) (is-a? (car args) RestructureBase) (car args)))
#;(inner (void) decode stream . args))
(super-new)
(field [res (make-hash)])
(define/public (decode stream . args) (void))
(define/public (encode . xs) (void))
(define/public (size . xs) (void))
(define/public (process . args) (void))

@ -17,12 +17,12 @@ https://github.com/mbutterick/restructure/blob/master/src/Pointer.coffee
(define offset (send offsetType decode stream ctx))
(report scope 'pointer-scope)
(define relative (caseq scope
[(local) (when (and (· ctx res _startOffset) (· ctx _startOffset)
[(local) #;(when (and (· ctx res _startOffset) (· ctx _startOffset)
(not (= (· ctx res _startOffset) (· ctx _startOffset))))
(report* ctx (· ctx res _startOffset) (· ctx _startOffset))
(error 'bazongas))
(· ctx _startOffset)]
[(parent) (· ctx parent _startOffset)]
(· ctx res _startOffset)]
[(parent) (· ctx res parent res _startOffset)]
[(immediate) (- (· stream pos) (send offsetType size))]
[(global)
(let loop ([c ctx])
@ -32,9 +32,9 @@ https://github.com/mbutterick/restructure/blob/master/src/Pointer.coffee
[else 0]))]))
(report* this (· this _startOffset)
(and (· this res) (· this res _startOffset))
ctx (and ctx (· ctx _startOffset))
ctx
(and (· ctx res) (· ctx res _startOffset)))
(when (and ctx (· ctx _startOffset) (= (· ctx _startOffset) 1012)) (error 'stop))
#;(when (and ctx (· ctx res _startOffset) (= (· ctx res _startOffset) 1012)) (error 'stop))
(report* offset relative)
(define ptr (+ offset relative))
(report* ptr)

@ -8,7 +8,7 @@ https://github.com/mbutterick/restructure/blob/master/src/Struct.coffee
|#
(define-subclass Streamcoder (Struct [fields (dictify)])
(field [res #f])
(inherit-field res)
(unless ((disjoin assocs? VersionedStruct?) fields)
(raise-argument-error 'Struct "assocs or Versioned Struct" fields))

@ -54,16 +54,16 @@
#'(let loop ([x X])
(cond
[(and (object? x) (or (get-or-false x REF) (send-or-false x REF)))]
[(and (object? x) (get-or-false x res)) => loop]
[(and (object? x) (send-or-false x res)) => loop]
;[(and (object? x) (get-or-false x res)) => loop]
;[(and (object? x) (send-or-false x res)) => loop]
[(object? x) #f]
[(and (hash? x) (hash-ref x 'res #f)) => loop]
;[(and (hash? x) (hash-ref x 'res #f)) => loop]
[(and (hash? x) (hash-ref x 'REF #f))]
[(hash? x) #f]
[else (raise-argument-error '· (format "~a must be object or hash" 'X) x)]))]
[(_ X REF0 . REFS) #'(· (· X REF0) . REFS)])
(module+ test
#;(module+ test
(define c (class object%
(super-new)
(field [a 42])

Loading…
Cancel
Save