You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#lang restructure/racket
|
|
|
|
|
(require "stream.rkt" "utils.rkt")
|
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
|
|
|
|
|
#|
|
|
|
|
|
approximates
|
|
|
|
|
https://github.com/mbutterick/restructure/blob/master/src/Reserved.coffee
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
|
|
(define-subclass Streamcoder (Reserved type [count 1])
|
|
|
|
|
|
|
|
|
|
(define/augment (decode stream parent)
|
|
|
|
|
(send stream pos (+ (· stream pos) (size #f parent)))
|
|
|
|
|
(void))
|
|
|
|
|
|
|
|
|
|
(define/override (size [val #f] [parent #f])
|
|
|
|
|
(* (send type size) (resolve-length count #f parent)))
|
|
|
|
|
|
|
|
|
|
(define/augment (encode stream val [parent #f])
|
|
|
|
|
(send stream fill 0 (size val parent))))
|
|
|
|
|
|