resume in loca / versioned struct
parent
b2a563f523
commit
4b063efda4
@ -1,6 +1,7 @@
|
|||||||
#lang fontkit/racket
|
#lang fontkit/racket
|
||||||
|
(require racket/serialize)
|
||||||
(provide cloneDeep)
|
(provide cloneDeep)
|
||||||
|
|
||||||
(define (cloneDeep val)
|
(define (cloneDeep val)
|
||||||
(parameterize ([print-graph #t])
|
(deserialize (serialize val)))
|
||||||
(read (open-input-string (~s val)))))
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
#lang fontkit/racket
|
||||||
|
(require restructure)
|
||||||
|
(provide (all-defined-out))
|
||||||
|
|
||||||
|
#|
|
||||||
|
approximates
|
||||||
|
https://github.com/mbutterick/fontkit/blob/master/src/tables/loca.js
|
||||||
|
|#
|
||||||
|
|
||||||
|
(define-subclass RVersionedStruct (Rloca))
|
||||||
|
|
||||||
|
(define loca (make-object Rloca
|
||||||
|
(λ (this) (hash-ref (send this _getTable 'head) 'indexToLocFormat))
|
||||||
|
(dictify
|
||||||
|
|
||||||
|
|
||||||
|
)))
|
||||||
|
|
||||||
|
(test-module
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
#lang restructure/racket
|
||||||
|
(require racket/dict "struct.rkt")
|
||||||
|
(provide (all-defined-out))
|
||||||
|
|
||||||
|
#|
|
||||||
|
approximates
|
||||||
|
https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
|
||||||
|
|#
|
||||||
|
|
||||||
|
(define-subclass RStruct (RVersionedStruct type [versions (dictify)])
|
||||||
|
|
||||||
|
(define/override (decode stream [parent #f] [length 0])
|
||||||
|
(define res (send this _setup stream parent length))
|
||||||
|
(define version (cond
|
||||||
|
[(procedure? type) (type parent)]
|
||||||
|
[(is-a? type RBase) (send type decode stream)]
|
||||||
|
[else (raise-argument-error 'decode "way of finding version" type)]))
|
||||||
|
(report version 'yay)
|
||||||
|
#;(_parseFields stream res fields)
|
||||||
|
#;(send this process res stream)
|
||||||
|
res))
|
Loading…
Reference in New Issue