|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#lang debug racket/base
|
|
|
|
|
(require "base.rkt"
|
|
|
|
|
"dict.rkt"
|
|
|
|
|
"util.rkt"
|
|
|
|
|
racket/dict
|
|
|
|
|
racket/match
|
|
|
|
|
racket/class
|
|
|
|
@ -14,8 +15,7 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
|
|
(define (version-type? x)
|
|
|
|
|
(for/or ([proc (list integer? procedure? xenomorphic? symbol?)])
|
|
|
|
|
(proc x)))
|
|
|
|
|
(and x (length-resolvable? x)))
|
|
|
|
|
|
|
|
|
|
(define x:versioned-dict%
|
|
|
|
|
(class x:dict%
|
|
|
|
@ -25,7 +25,7 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
|
|
|
|
|
[(@version-key version-key)])
|
|
|
|
|
|
|
|
|
|
(unless (version-type? @type)
|
|
|
|
|
(raise-argument-error 'x:versioned-dict "integer, procedure, symbol, or xenomorphic" @type))
|
|
|
|
|
(raise-argument-error 'x:versioned-dict "integer, procedure, or xenomorphic" @type))
|
|
|
|
|
|
|
|
|
|
(unless (and (dict? @versions) (andmap (λ (v) (or (dict? v) (x:dict? v))) (dict-values @versions)))
|
|
|
|
|
(raise-argument-error 'x:versioned-dict "dict of dicts or structish" @versions))
|
|
|
|
@ -43,7 +43,6 @@ https://github.com/mbutterick/restructure/blob/master/src/VersionedStruct.coffee
|
|
|
|
|
(define res (setup-private-fields port parent length))
|
|
|
|
|
(define which-version (match @type
|
|
|
|
|
[(? integer? int) int]
|
|
|
|
|
[(? symbol? key) #:when parent (dict-ref parent key)]
|
|
|
|
|
[(? procedure? proc) #:when parent (proc parent)]
|
|
|
|
|
[(or (? symbol?) (? procedure?))
|
|
|
|
|
(raise-argument-error 'decode "valid parent" parent)]
|
|
|
|
|