From d8524df5e4081036e92eaaa3d67e47cfbaa6c90e Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 30 May 2010 17:37:45 -0700 Subject: [PATCH] Move Unicode char predicates to "char.scm". --- src/runtime/char.scm | 36 ++++++++++++++++++++++++++++++++++++ src/runtime/runtime.pkg | 23 +++++++++++++---------- src/runtime/unicode.scm | 38 -------------------------------------- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/runtime/char.scm b/src/runtime/char.scm index 1c1354f0d..dd25c9913 100644 --- a/src/runtime/char.scm +++ b/src/runtime/char.scm @@ -87,6 +87,42 @@ USA. (%make-char (%char-code char) (fix:andc (%char-bits char) bits))) +(define (unicode-char? object) + (and (char? object) + (legal-code-32? (char->integer object)))) + +(define-guarantee unicode-char "a Unicode character") + +(define (unicode-scalar-value? object) + (and (index-fixnum? object) + (fix:< object char-code-limit) + (not (illegal? object)))) + +(define-guarantee unicode-scalar-value "a Unicode scalar value") + +(define-integrable (legal-code-32? pt) + (and (fix:< pt char-code-limit) + (not (illegal? pt)))) + +(define-integrable (legal-code-16? pt) + (not (illegal? pt))) + +(define-integrable (illegal? pt) + (or (and (fix:>= pt #xD800) (fix:< pt #xE000)) + (fix:= pt #xFFFE) + (fix:= pt #xFFFF))) + +#| + +Not used at the moment. + +(define-integrable (non-character? pt) + (or (and (fix:>= pt #xD800) (fix:< pt #xE000)) + (and (fix:>= pt #xFDD0) (fix:< pt #xFDF0)) + (fix:= #x00FFFE (fix:and #x00FFFE pt)))) + +|# + (define (8-bit-char? object) (and (char? object) (fix:< (char->integer object) 256))) diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 5307eea8a..d4d6fe6c9 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -1014,6 +1014,9 @@ USA. (files "char") (parent (runtime)) (export () + (error:not-wide-char error:not-unicode-char) + (guarantee-wide-char guarantee-unicode-char) + (wide-char? unicode-char?) 8-bit-char? ascii->char char->ascii @@ -1051,14 +1054,20 @@ USA. digit->char error:not-char error:not-radix + error:not-unicode-char + error:not-unicode-scalar-value guarantee-8-bit-char guarantee-char guarantee-radix + guarantee-unicode-char + guarantee-unicode-scalar-value integer->char make-char name->char radix? - set-char-bits) + set-char-bits + unicode-char? + unicode-scalar-value?) (export (runtime string) %charutf16-be-string string->utf16-be-string) (wide-string->utf16-le-string string->utf16-le-string) (wide-string->utf16-string string->utf16-string) @@ -5254,8 +5263,6 @@ USA. call-with-utf8-input-string call-with-utf8-output-string combine-utf16-surrogates - error:not-unicode-char - error:not-unicode-scalar-value error:not-utf16-be-string error:not-utf16-high-surrogate error:not-utf16-le-string @@ -5268,8 +5275,6 @@ USA. error:not-wide-string for-all-chars-in-string? for-any-char-in-string? - guarantee-unicode-char - guarantee-unicode-scalar-value guarantee-utf16-be-string guarantee-utf16-high-surrogate guarantee-utf16-le-string @@ -5307,8 +5312,6 @@ USA. string->utf8-string string->utf8-string string->wide-string - unicode-char? - unicode-scalar-value? utf16-be-string->wide-string utf16-be-string-length utf16-be-string-valid? diff --git a/src/runtime/unicode.scm b/src/runtime/unicode.scm index b29875f22..d0ae2ab46 100644 --- a/src/runtime/unicode.scm +++ b/src/runtime/unicode.scm @@ -160,44 +160,6 @@ USA. (procedure port) (get-output-string! port)))) -;;;; Unicode characters - -(define (unicode-char? object) - (and (char? object) - (legal-code-32? (char->integer object)))) - -(define-guarantee unicode-char "a Unicode character") - -(define (unicode-scalar-value? object) - (and (index-fixnum? object) - (fix:< object char-code-limit) - (not (illegal? object)))) - -(define-guarantee unicode-scalar-value "a Unicode scalar value") - -(define-integrable (legal-code-32? pt) - (and (fix:< pt char-code-limit) - (not (illegal? pt)))) - -(define-integrable (legal-code-16? pt) - (not (illegal? pt))) - -(define-integrable (illegal? pt) - (or (and (fix:>= pt #xD800) (fix:< pt #xE000)) - (fix:= pt #xFFFE) - (fix:= pt #xFFFF))) - -#| - -Not used at the moment. - -(define-integrable (non-character? pt) - (or (and (fix:>= pt #xD800) (fix:< pt #xE000)) - (and (fix:>= pt #xFDD0) (fix:< pt #xFDF0)) - (fix:= #x00FFFE (fix:and #x00FFFE pt)))) - -|# - ;;;; Unicode strings (define-structure (wide-string (type-descriptor ) -- 2.25.1