forked from swiftlang/swift-corelibs-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSCFCharacterSet.swift
138 lines (103 loc) · 5.18 KB
/
NSCFCharacterSet.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
// NSCFCharacterSet.swift
// Foundation
//
// Created by Philippe Hausler on 6/3/16.
// Copyright © 2016 Apple. All rights reserved.
//
import CoreFoundation
internal class _NSCFCharacterSet : NSMutableCharacterSet {
required init(coder aDecoder: NSCoder) {
fatalError("Coding is not supported for bridge classes")
}
override func characterIsMember(_ aCharacter: unichar) -> Bool {
return CFCharacterSetIsCharacterMember(_cfObject, UniChar(aCharacter))
}
override var bitmapRepresentation: Data {
return CFCharacterSetCreateBitmapRepresentation(kCFAllocatorSystemDefault, _cfObject)._swiftObject
}
override var inverted: CharacterSet {
return CFCharacterSetCreateInvertedSet(kCFAllocatorSystemDefault, _cfObject)._swiftObject
}
override func longCharacterIsMember(_ theLongChar: UInt32) -> Bool {
return CFCharacterSetIsLongCharacterMember(_cfObject, theLongChar)
}
override func isSuperset(of theOtherSet: CharacterSet) -> Bool {
return CFCharacterSetIsSupersetOfSet(_cfObject, theOtherSet._cfObject)
}
override func hasMemberInPlane(_ thePlane: UInt8) -> Bool {
return CFCharacterSetHasMemberInPlane(_cfObject, CFIndex(thePlane))
}
override func copy() -> Any {
return copy(with: nil)
}
override func copy(with zone: NSZone? = nil) -> Any {
return CFCharacterSetCreateCopy(kCFAllocatorSystemDefault, self._cfObject)
}
override func mutableCopy(with zone: NSZone? = nil) -> Any {
return CFCharacterSetCreateMutableCopy(kCFAllocatorSystemDefault, _cfObject)._nsObject
}
override func addCharacters(in aRange: NSRange) {
CFCharacterSetAddCharactersInRange(_cfMutableObject , CFRangeMake(aRange.location, aRange.length))
}
override func removeCharacters(in aRange: NSRange) {
CFCharacterSetRemoveCharactersInRange(_cfMutableObject , CFRangeMake(aRange.location, aRange.length))
}
override func addCharacters(in aString: String) {
CFCharacterSetAddCharactersInString(_cfMutableObject, aString._cfObject)
}
override func removeCharacters(in aString: String) {
CFCharacterSetRemoveCharactersInString(_cfMutableObject, aString._cfObject)
}
override func formUnion(with otherSet: CharacterSet) {
CFCharacterSetUnion(_cfMutableObject, otherSet._cfObject)
}
override func formIntersection(with otherSet: CharacterSet) {
CFCharacterSetIntersect(_cfMutableObject, otherSet._cfObject)
}
override func invert() {
CFCharacterSetInvert(_cfMutableObject)
}
}
internal func _CFSwiftCharacterSetExpandedCFCharacterSet(_ cset: CFTypeRef) -> Unmanaged<CFCharacterSet>? {
return nil
}
internal func _CFSwiftCharacterSetRetainedBitmapRepresentation(_ cset: CFTypeRef) -> Unmanaged<CFData> {
NSUnimplemented()
}
internal func _CFSwiftCharacterSetCharacterIsMember(_ cset: CFTypeRef, _ ch: UniChar) -> Bool {
return (cset as! NSCharacterSet).characterIsMember(ch)
}
internal func _CFSwiftCharacterSetMutableCopy(_ cset: CFTypeRef) -> Unmanaged<CFMutableCharacterSet> {
return Unmanaged.passRetained((cset as! NSCharacterSet).mutableCopy() as! CFMutableCharacterSet)
}
internal func _CFSwiftCharacterSetLongCharacterIsMember(_ cset: CFTypeRef, _ ch:UInt32) -> Bool {
return (cset as! NSCharacterSet).longCharacterIsMember(ch)
}
internal func _CFSwiftCharacterSetHasMemberInPlane(_ cset: CFTypeRef, _ plane: UInt8) -> Bool {
return (cset as! NSCharacterSet).hasMemberInPlane(plane)
}
internal func _CFSwiftCharacterSetInverted(_ cset: CFTypeRef) -> Unmanaged<CFCharacterSet> {
return Unmanaged.passRetained((cset as! NSCharacterSet).inverted._cfObject)
}
internal func _CFSwiftMutableSetAddCharactersInRange(_ characterSet: CFTypeRef, _ range: CFRange) -> Void {
(characterSet as! NSMutableCharacterSet).addCharacters(in: NSRange(location: range.location, length: range.length))
}
internal func _CFSwiftMutableSetRemoveCharactersInRange(_ characterSet: CFTypeRef, _ range: CFRange) -> Void {
(characterSet as! NSMutableCharacterSet).removeCharacters(in: NSRange(location: range.location, length: range.length))
}
internal func _CFSwiftMutableSetAddCharactersInString(_ characterSet: CFTypeRef, _ string: CFString) -> Void {
(characterSet as! NSMutableCharacterSet).addCharacters(in: string._swiftObject)
}
internal func _CFSwiftMutableSetRemoveCharactersInString(_ characterSet: CFTypeRef, _ string: CFString) -> Void {
(characterSet as! NSMutableCharacterSet).removeCharacters(in: string._swiftObject)
}
internal func _CFSwiftMutableSetFormUnionWithCharacterSet(_ characterSet: CFTypeRef, _ other: CFTypeRef) -> Void {
(characterSet as! NSMutableCharacterSet).formUnion(with: (other as! NSCharacterSet)._swiftObject)
}
internal func _CFSwiftMutableSetFormIntersectionWithCharacterSet(_ characterSet: CFTypeRef, _ other: CFTypeRef) -> Void {
(characterSet as! NSMutableCharacterSet).formIntersection(with: (other as! NSCharacterSet)._swiftObject)
}
internal func _CFSwiftMutableSetInvert(_ characterSet: CFTypeRef) -> Void {
(characterSet as! NSMutableCharacterSet).invert()
}