File tree Expand file tree Collapse file tree 7 files changed +17
-668
lines changed Expand file tree Collapse file tree 7 files changed +17
-668
lines changed Original file line number Diff line number Diff line change @@ -57,14 +57,10 @@ let package = Package(
5757 dependencies: [
5858 " _RegexParser " , " _StringProcessing "
5959 ] ) ,
60- . target(
61- name: " _CUnicode " ,
62- dependencies: [ ] ) ,
6360 . target(
6461 name: " _StringProcessing " ,
6562 dependencies: [
66- " _RegexParser " ,
67- " _CUnicode " ,
63+ " _RegexParser "
6864 ] ,
6965 swiftSettings: publicStdlibSettings) ,
7066 . target(
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 99//
1010//===----------------------------------------------------------------------===//
1111
12+ @_spi ( _Unicode) import Swift
1213@_implementationOnly import _RegexParser
1314
1415extension DSLTree . Node {
@@ -371,10 +372,23 @@ extension DSLTree.CustomCharacterClass {
371372typealias ScalarPredicate = ( UnicodeScalar ) -> Bool
372373
373374private func scriptScalarPredicate( _ s: Unicode . Script ) -> ScalarPredicate {
374- { Unicode . Script ( $0) == s }
375+ {
376+ if #available( SwiftStdlib 5 . 7 , * ) {
377+ return unsafeBitCast ( $0. properties. _script, to: Unicode . Script. self) == s
378+ } else {
379+ return false
380+ }
381+ }
375382}
376383private func scriptExtensionScalarPredicate( _ s: Unicode . Script ) -> ScalarPredicate {
377- { Unicode . Script. extensions ( for: $0) . contains ( s) }
384+ {
385+ if #available( SwiftStdlib 5 . 7 , * ) {
386+ let extensions = $0. properties. _scriptExtensions
387+ return extensions. contains ( unsafeBitCast ( s, to: UInt8 . self) )
388+ } else {
389+ return false
390+ }
391+ }
378392}
379393private func categoryScalarPredicate( _ gc: Unicode . GeneralCategory ) -> ScalarPredicate {
380394 { gc == $0. properties. generalCategory }
Original file line number Diff line number Diff line change 99//
1010//===----------------------------------------------------------------------===//
1111
12- @_silgen_name ( " _swift_stdlib_getScript " )
13- func _swift_stdlib_getScript( _: UInt32 ) -> UInt8
14-
15- @_silgen_name ( " _swift_stdlib_getScriptExtensions " )
16- func _swift_stdlib_getScriptExtensions(
17- _: UInt32 ,
18- _: UnsafeMutablePointer < UInt8 >
19- ) -> UnsafePointer < UInt8 > ?
20-
21- extension Unicode. Script {
22- init ( _ scalar: Unicode . Scalar) {
23- let rawValue = _swift_stdlib_getScript ( scalar. value)
24-
25- _internalInvariant ( rawValue != . max, " Unknown script rawValue: \( rawValue) " )
26-
27- self = unsafeBitCast ( rawValue, to: Self . self)
28- }
29-
30- static func extensions( for scalar: Unicode . Scalar ) -> [ Unicode . Script ] {
31- var count : UInt8 = 0
32- let pointer = _swift_stdlib_getScriptExtensions ( scalar. value, & count)
33-
34- guard let pointer = pointer else {
35- return [ Unicode . Script ( scalar) ]
36- }
37-
38- var result : [ Unicode . Script ] = [ ]
39-
40- for i in 0 ..< count {
41- let script = pointer [ Int ( i) ]
42-
43- result. append ( unsafeBitCast ( script, to: Unicode . Script. self) )
44- }
45-
46- return result
47- }
48- }
49-
5012extension UnicodeScalar {
5113 var isHorizontalWhitespace : Bool {
5214 value == 0x09 || properties. generalCategory == . spaceSeparator
You can’t perform that action at this time.
0 commit comments