From 077b227f03709a97a31dcc3ec6b3d29bef6c90d1 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 28 Apr 2019 17:14:51 -0700 Subject: [PATCH] fly the flag --- xenomorph/xenomorph/scribblings/xenomorph.scrbl | 12 ++++++------ xenomorph/xenomorph/string.rkt | 6 +++--- xenomorph/xenomorph/symbol.rkt | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xenomorph/xenomorph/scribblings/xenomorph.scrbl b/xenomorph/xenomorph/scribblings/xenomorph.scrbl index b43e8760..753ae1f3 100644 --- a/xenomorph/xenomorph/scribblings/xenomorph.scrbl +++ b/xenomorph/xenomorph/scribblings/xenomorph.scrbl @@ -509,7 +509,7 @@ Base class for string formats. Use @racket[x:string] to conveniently instantiate @defconstructor[ ([len length-resolvable?] -[encoding supported-encoding?])]{ +[encoding (or/c procedure? supported-encoding?)])]{ Create class instance that represents a string format of length @racket[len]. If @racket[len] is an integer, the string is fixed at that length, otherwise it can be any length. } @@ -544,9 +544,9 @@ Whether @racket[x] is an object of type @racket[x:string%]. @defproc[ (x:string [len-arg (or/c length-resolvable? #false) #false] -[enc-arg (or/c supported-encoding? #false) #false] +[enc-arg (or/c procedure? supported-encoding? #false) #false] [#:length len-kw (or/c length-resolvable? #false) #false] -[#:encoding enc-kw (or/c supported-encoding? #false) #false] +[#:encoding enc-kw (or/c procedure? supported-encoding? #false) #false] [#:pre-encode pre-encode-proc (or/c (any/c . -> . any/c) #false) #false] [#:post-decode post-decode-proc (or/c (any/c . -> . any/c) #false) #false] [#:base-class base-class (λ (c) (subclass? c x:string%)) x:string%] @@ -574,7 +574,7 @@ Base class for symbol formats. Use @racket[x:symbol] to conveniently instantiate @defconstructor[ ([len length-resolvable?] -[encoding supported-encoding?])]{ +[encoding (or/c procedure? supported-encoding?)])]{ Create class instance that represents a symbol format of length @racket[len]. If @racket[len] is an integer, the symbol is fixed at that length, otherwise it can be any length. } @@ -609,9 +609,9 @@ Whether @racket[x] is an object of type @racket[x:symbol%]. @defproc[ (x:symbol [len-arg (or/c length-resolvable? #false) #false] -[enc-arg (or/c supported-encoding? #false) #false] +[enc-arg (or/c procedure? supported-encoding? #false) #false] [#:length len-kw (or/c length-resolvable? #false) #false] -[#:encoding enc-kw (or/c supported-encoding? #false) #false] +[#:encoding enc-kw (or/c procedure? supported-encoding? #false) #false] [#:pre-encode pre-encode-proc (or/c (any/c . -> . any/c) #false) #false] [#:post-decode post-decode-proc (or/c (any/c . -> . any/c) #false) #false] [#:base-class base-class (λ (c) (subclass? c x:symbol%)) x:symbol%] diff --git a/xenomorph/xenomorph/string.rkt b/xenomorph/xenomorph/string.rkt index 83849152..4966995e 100644 --- a/xenomorph/xenomorph/string.rkt +++ b/xenomorph/xenomorph/string.rkt @@ -101,9 +101,9 @@ https://github.com/mbutterick/restructure/blob/master/src/String.coffee #:base-class [base-class x:string%]) (() ((or/c length-resolvable? #false) - (or/c supported-encoding? #false) + (or/c procedure? supported-encoding? #false) #:length (or/c length-resolvable? #false) - #:encoding (or/c supported-encoding? #false) + #:encoding (or/c procedure? supported-encoding? #false) #:pre-encode (or/c (any/c . -> . any/c) #false) #:post-decode (or/c (any/c . -> . any/c) #false) #:base-class (λ (c) (subclass? c x:string%))) @@ -113,7 +113,7 @@ https://github.com/mbutterick/restructure/blob/master/src/String.coffee (unless (length-resolvable? len) (raise-argument-error 'x:string "resolvable length" len)) (define encoding (or enc-arg enc-kwarg 'ascii)) - (unless (supported-encoding? encoding) + (unless (or (supported-encoding? encoding) (procedure? encoding)) (raise-argument-error 'x:string "valid encoding value" encoding)) (new (generate-subclass base-class pre-proc post-proc) [len len] diff --git a/xenomorph/xenomorph/symbol.rkt b/xenomorph/xenomorph/symbol.rkt index 36505c52..a75e01d5 100644 --- a/xenomorph/xenomorph/symbol.rkt +++ b/xenomorph/xenomorph/symbol.rkt @@ -30,9 +30,9 @@ #:base-class [base-class x:symbol%]) (() ((or/c length-resolvable? #false) - (or/c supported-encoding? #false) + (or/c procedure? supported-encoding? #false) #:length (or/c length-resolvable? #false) - #:encoding (or/c supported-encoding? #false) + #:encoding (or/c procedure? supported-encoding? #false) #:pre-encode (or/c (any/c . -> . any/c) #false) #:post-decode (or/c (any/c . -> . any/c) #false) #:base-class (λ (c) (subclass? c x:symbol%))) @@ -42,7 +42,7 @@ (unless (length-resolvable? len) (raise-argument-error 'x:symbol "resolvable length" len)) (define encoding (or enc-arg enc-kwarg 'utf8)) - (unless (supported-encoding? encoding) + (unless (or (supported-encoding? encoding) (procedure? encoding)) (raise-argument-error 'x:symbol "valid encoding value" encoding)) (new (generate-subclass base-class pre-proc post-proc) [len len]