File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Darwin/Foundation-swiftoverlay Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -96,3 +96,28 @@ extension Substring : _ObjectiveCBridgeable {
96
96
}
97
97
98
98
extension String : CVarArg { }
99
+
100
+ /*
101
+ This is on NSObject so that the stdlib can call it in StringBridge.swift
102
+ without having to synthesize a receiver (e.g. lookup a class or allocate)
103
+
104
+ In the future (once the Foundation overlay can know about SmallString), we
105
+ should move the caller of this method up into the overlay and avoid this
106
+ indirection.
107
+ */
108
+ private extension NSObject {
109
+ // The ObjC selector has to start with "new" to get ARC to not autorelease
110
+ @_effects ( releasenone)
111
+ @objc ( newTaggedNSStringWithASCIIBytes_: length_: )
112
+ func createTaggedString( bytes: UnsafePointer < UInt8 > ,
113
+ count: Int ) -> AnyObject ? {
114
+ //TODO: update this to use _CFStringCreateTaggedPointerString once we can
115
+ return CFStringCreateWithBytes (
116
+ kCFAllocatorSystemDefault,
117
+ bytes,
118
+ count,
119
+ CFStringBuiltInEncodings . UTF8. rawValue,
120
+ false
121
+ ) as NSString as NSString ? //just "as AnyObject" inserts unwanted bridging
122
+ }
123
+ }
You can’t perform that action at this time.
0 commit comments