racket/serialize: support keywords and regexp values
This commit is contained in:
parent
b243ce894a
commit
a134d0c0a3
|
@ -42,8 +42,8 @@ The following kinds of values are serializable:
|
||||||
or @racket[define-serializable-class*];}
|
or @racket[define-serializable-class*];}
|
||||||
|
|
||||||
@item{@tech{booleans}, @tech{numbers}, @tech{characters}, @tech{interned} symbols,
|
@item{@tech{booleans}, @tech{numbers}, @tech{characters}, @tech{interned} symbols,
|
||||||
@tech{unreadable symbols}, @tech{strings}, @tech{byte strings}, @tech{paths} (for a
|
@tech{unreadable symbols}, @tech{keywords}, @tech{strings}, @tech{byte strings}, @tech{paths} (for a
|
||||||
specific convention), @|void-const|, and the empty list;}
|
specific convention), @tech{regexp values}, @|void-const|, and the empty list;}
|
||||||
|
|
||||||
@item{@tech{pairs}, @tech{mutable pairs}, @tech{vectors}, @tech{flvectors}, @tech{fxvectors},
|
@item{@tech{pairs}, @tech{mutable pairs}, @tech{vectors}, @tech{flvectors}, @tech{fxvectors},
|
||||||
@tech{box}es, @tech{hash tables}, and @tech{sets};}
|
@tech{box}es, @tech{hash tables}, and @tech{sets};}
|
||||||
|
@ -70,7 +70,9 @@ currently do not handle certain cyclic values that @racket[read] and
|
||||||
@racket[write] can handle, such as @racket['@#,read[(open-input-string "#0=(#0#)")]].}
|
@racket[write] can handle, such as @racket['@#,read[(open-input-string "#0=(#0#)")]].}
|
||||||
|
|
||||||
See @racket[deserialize] for information on the format of serialized
|
See @racket[deserialize] for information on the format of serialized
|
||||||
data.}
|
data.
|
||||||
|
|
||||||
|
@history[#:changed "6.5.0.4" @elem{Added keywords and regexp values as serializable}]}
|
||||||
|
|
||||||
@; ----------------------------------------------------------------------
|
@; ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
(and (symbol? v)
|
(and (symbol? v)
|
||||||
(or (symbol-interned? v)
|
(or (symbol-interned? v)
|
||||||
(eq? v (string->unreadable-symbol (symbol->string v)))))
|
(eq? v (string->unreadable-symbol (symbol->string v)))))
|
||||||
|
(keyword? v)
|
||||||
|
(regexp? v)
|
||||||
|
(byte-regexp? v)
|
||||||
(string? v)
|
(string? v)
|
||||||
(path-for-some-system? v)
|
(path-for-some-system? v)
|
||||||
(bytes? v)
|
(bytes? v)
|
||||||
|
@ -201,6 +204,7 @@
|
||||||
(number? v)
|
(number? v)
|
||||||
(char? v)
|
(char? v)
|
||||||
(symbol? v)
|
(symbol? v)
|
||||||
|
(keyword? v)
|
||||||
(null? v)
|
(null? v)
|
||||||
(void? v)
|
(void? v)
|
||||||
(srcloc? v))
|
(srcloc? v))
|
||||||
|
@ -239,6 +243,8 @@
|
||||||
(for-each loop (struct->list v))]
|
(for-each loop (struct->list v))]
|
||||||
[(or (string? v)
|
[(or (string? v)
|
||||||
(bytes? v)
|
(bytes? v)
|
||||||
|
(regexp? v)
|
||||||
|
(byte-regexp? v)
|
||||||
(path-for-some-system? v))
|
(path-for-some-system? v))
|
||||||
;; No sub-structure
|
;; No sub-structure
|
||||||
(void)]
|
(void)]
|
||||||
|
@ -286,6 +292,9 @@
|
||||||
(null? v)
|
(null? v)
|
||||||
(string? v)
|
(string? v)
|
||||||
(symbol? v)
|
(symbol? v)
|
||||||
|
(keyword? v)
|
||||||
|
(regexp? v)
|
||||||
|
(byte-regexp? v)
|
||||||
(bytes? v))))
|
(bytes? v))))
|
||||||
|
|
||||||
(define (serialize-one v share check-share? mod-map mod-map-cache)
|
(define (serialize-one v share check-share? mod-map mod-map-cache)
|
||||||
|
@ -294,7 +303,8 @@
|
||||||
[(or (boolean? v)
|
[(or (boolean? v)
|
||||||
(number? v)
|
(number? v)
|
||||||
(char? v)
|
(char? v)
|
||||||
(null? v))
|
(null? v)
|
||||||
|
(keyword? v))
|
||||||
v]
|
v]
|
||||||
[(symbol? v)
|
[(symbol? v)
|
||||||
(if (symbol-interned? v)
|
(if (symbol-interned? v)
|
||||||
|
@ -309,6 +319,9 @@
|
||||||
(bytes? v))
|
(bytes? v))
|
||||||
(immutable? v))
|
(immutable? v))
|
||||||
v]
|
v]
|
||||||
|
[(or (regexp? v)
|
||||||
|
(byte-regexp? v))
|
||||||
|
v]
|
||||||
[(serializable-struct? v)
|
[(serializable-struct? v)
|
||||||
(let ([info (serializable-info v)])
|
(let ([info (serializable-info v)])
|
||||||
(cons (mod-to-id info mod-map mod-map-cache)
|
(cons (mod-to-id info mod-map mod-map-cache)
|
||||||
|
@ -492,6 +505,9 @@
|
||||||
(number? v)
|
(number? v)
|
||||||
(char? v)
|
(char? v)
|
||||||
(symbol? v)
|
(symbol? v)
|
||||||
|
(keyword? v)
|
||||||
|
(regexp? v)
|
||||||
|
(byte-regexp? v)
|
||||||
(null? v))
|
(null? v))
|
||||||
v]
|
v]
|
||||||
[(string? v)
|
[(string? v)
|
||||||
|
|
|
@ -176,12 +176,12 @@
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
#,@(if super-info
|
#,@(if super-info
|
||||||
(map (lambda (set get)
|
(map (lambda (set get)
|
||||||
#`(#,set s0 (#,get s)))
|
#`((or #,set void) s0 (#,get s)))
|
||||||
(list-ref super-info 4)
|
(list-ref super-info 4)
|
||||||
(list-ref super-info 3))
|
(list-ref super-info 3))
|
||||||
null)
|
null)
|
||||||
#,@(map (lambda (getter setter)
|
#,@(map (lambda (getter setter)
|
||||||
#`(#,setter s0 (#,getter s)))
|
#`((or #,setter void) s0 (#,getter s)))
|
||||||
getters
|
getters
|
||||||
setters)
|
setters)
|
||||||
(void))))))))
|
(void))))))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user