diff --git a/collects/racket/private/serialize.rkt b/collects/racket/private/serialize.rkt index 1bf15d697d..e6a68d1ed1 100644 --- a/collects/racket/private/serialize.rkt +++ b/collects/racket/private/serialize.rkt @@ -2,6 +2,8 @@ (require syntax/modcollapse unstable/struct racket/list + racket/flonum + racket/fixnum "serialize-structs.rkt") ;; This module implements the core serializer. The syntactic @@ -43,6 +45,8 @@ (path-for-some-system? v) (bytes? v) (vector? v) + (flvector? v) + (fxvector? v) (pair? v) (mpair? v) (hash? v) @@ -137,6 +141,8 @@ (hash? o)) (not (immutable? o))) (serializable-struct? o) + (flvector? o) + (fxvector? o) (let ([k (prefab-struct-key o)]) (and k ;; Check whether all fields are mutable: @@ -226,6 +232,8 @@ (void)] [(vector? v) (for-each loop (vector->list v))] + [(flvector? v) (void)] + [(fxvector? v) (void)] [(pair? v) (loop (car v)) (loop (cdr v))] @@ -313,6 +321,10 @@ (andmap quotable? elems)) (cons 'q v) (cons (if (immutable? v) 'v 'v!) elems))] + [(flvector? v) + (cons 'vl (for/list ([i (in-flvector v)]) i))] + [(fxvector? v) + (cons 'vx (for/list ([i (in-fxvector v)]) i))] [(pair? v) (let ([loop (serial #t)]) (let ([a (loop (car v))] @@ -493,6 +505,8 @@ [(m) (mcons (loop (cadr v)) (loop (cddr v)))] [(v) (apply vector-immutable (map loop (cdr v)))] [(v!) (list->vector (map loop (cdr v)))] + [(vl) (apply flvector (map loop (cdr v)))] + [(vx) (apply fxvector (map loop (cdr v)))] [(b) (box-immutable (loop (cdr v)))] [(b!) (box (loop (cdr v)))] [(h) (let ([al (map (lambda (p) diff --git a/collects/scribblings/reference/serialization.scrbl b/collects/scribblings/reference/serialization.scrbl index 19eb014a33..ba8e4c006f 100644 --- a/collects/scribblings/reference/serialization.scrbl +++ b/collects/scribblings/reference/serialization.scrbl @@ -45,7 +45,8 @@ The following kinds of values are serializable: @tech{unreadable symbols}, @tech{strings}, @tech{byte strings}, @tech{paths} (for a specific convention), @|void-const|, and the empty list;} - @item{@tech{pairs}, @tech{mutable pairs}, @tech{vectors}, @tech{box}es, @tech{hash tables}, and @tech{sets};} + @item{@tech{pairs}, @tech{mutable pairs}, @tech{vectors}, @tech{flvectors}, @tech{fxvectors}, + @tech{box}es, @tech{hash tables}, and @tech{sets};} @item{@racket[date], @racket[date*], and @racket[arity-at-least] structures; and} @@ -264,6 +265,14 @@ elements: @racket[cdr] is a list of serials; it represents a mutable vector.} + @item{a pair whose @racket[car] is @racket['vl] and whose + @racket[cdr] is a list of serials; it represents a + @tech{flvector}.} + + @item{a pair whose @racket[car] is @racket['vx] and whose + @racket[cdr] is a list of serials; it represents a + @tech{fxvector}.} + @item{a pair whose @racket[car] is @racket['b] and whose @racket[cdr] is a serial; it represents an immutable box.} diff --git a/collects/tests/racket/serialize.rktl b/collects/tests/racket/serialize.rktl index 3d86de6097..a25f322a2e 100644 --- a/collects/tests/racket/serialize.rktl +++ b/collects/tests/racket/serialize.rktl @@ -4,7 +4,9 @@ (Section 'serialization) (require racket/serialize - racket/file) + racket/file + racket/flonum + racket/fixnum) ;; ---------------------------------------- @@ -136,6 +138,8 @@ (test-ser (mk-ht make-weak-hash)) (test-ser #s(a 0 1 2)) (test-ser #s((a q 2) 0 1 2)) +(test-ser (fxvector 1 2 30)) +(test-ser (flvector 0.1 2.0 30e3)) (test-ser (set 'set 0 1 2)) (test-ser (seteqv 'seteqv 0 1 2)) diff --git a/doc/release-notes/racket/HISTORY.txt b/doc/release-notes/racket/HISTORY.txt index 0aa42294a2..57fa1e1b46 100644 --- a/doc/release-notes/racket/HISTORY.txt +++ b/doc/release-notes/racket/HISTORY.txt @@ -3,6 +3,7 @@ Changed case to use equal? instead of eqv? r5rs, r6rs: fixed case and cond to disallow internal definitions in clauses Add #fx() and #fl() reader forms for flvectors and fxvectors +racket/serialize: fxvectors and flvectors are serializable Version 5.3.1.8 file/untar: added