Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Update for SE-0055: Making pointer nullability explicit." #312

Merged
merged 1 commit into from
Apr 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CoreFoundation/Base.subproj/ForFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ enum {
// This is for NSNumberFormatter use only!
CF_EXPORT void *_CFNumberFormatterGetFormatter(CFNumberFormatterRef formatter);

CF_EXPORT void _CFDataInit(CFMutableDataRef memory, CFOptionFlags flags, CFIndex capacity, const uint8_t * _Nullable bytes, CFIndex length, Boolean noCopy);
CF_EXPORT void _CFDataInit(CFMutableDataRef memory, CFOptionFlags flags, CFIndex capacity, const uint8_t *bytes, CFIndex length, Boolean noCopy);
CF_EXPORT CFRange _CFDataFindBytes(CFDataRef data, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions);


Expand Down
22 changes: 11 additions & 11 deletions CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct _NSObjectBridge {
struct _NSArrayBridge {
CFIndex (*_Nonnull count)(CFTypeRef obj);
_Nonnull CFTypeRef (*_Nonnull objectAtIndex)(CFTypeRef obj, CFIndex index);
void (*_Nonnull getObjects)(CFTypeRef array, CFRange range, CFTypeRef _Nullable *_Nonnull values);
void (*_Nonnull getObjects)(CFTypeRef array, CFRange range, CFTypeRef _Nonnull * _Nonnull values);
};

struct _NSMutableArrayBridge {
Expand All @@ -73,11 +73,11 @@ struct _NSDictionaryBridge {
CFIndex (*countForKey)(CFTypeRef dictionary, CFTypeRef key);
bool (*containsKey)(CFTypeRef dictionary, CFTypeRef key);
_Nullable CFTypeRef (*_Nonnull objectForKey)(CFTypeRef dictionary, CFTypeRef key);
bool (*_getValueIfPresent)(CFTypeRef dictionary, CFTypeRef key, CFTypeRef _Nullable *_Nullable value);
bool (*_getValueIfPresent)(CFTypeRef dictionary, CFTypeRef key, CFTypeRef _Nonnull * _Nullable value);
CFIndex (*__getValue)(CFTypeRef dictionary, CFTypeRef value, CFTypeRef key);
bool (*containsObject)(CFTypeRef dictionary, CFTypeRef value);
CFIndex (*countForObject)(CFTypeRef dictionary, CFTypeRef value);
void (*getObjects)(CFTypeRef dictionary, CFTypeRef _Nullable *_Nullable valuebuf, CFTypeRef _Nullable *_Nullable keybuf);
void (*getObjects)(CFTypeRef dictionary, CFTypeRef _Nonnull * _Nonnull valuebuf, CFTypeRef _Nonnull * _Nonnull keybuf);
void (*__apply)(CFTypeRef dictionary, void (*applier)(CFTypeRef key, CFTypeRef value, void *context), void *context);
};

Expand All @@ -104,7 +104,7 @@ struct _NSStringBridge {
CFIndex (*length)(CFTypeRef str);
UniChar (*characterAtIndex)(CFTypeRef str, CFIndex idx);
void (*getCharacters)(CFTypeRef str, CFRange range, UniChar *buffer);
CFIndex (*__getBytes)(CFTypeRef str, CFStringEncoding encoding, CFRange range, uint8_t *_Nullable buffer, CFIndex maxBufLen, CFIndex *_Nullable usedBufLen);
CFIndex (*__getBytes)(CFTypeRef str, CFStringEncoding encoding, CFRange range, uint8_t *buffer, CFIndex maxBufLen, CFIndex *usedBufLen);
const char *_Nullable (*_Nonnull _fastCStringContents)(CFTypeRef str);
const UniChar *_Nullable (*_Nonnull _fastCharacterContents)(CFTypeRef str);
bool (*_getCString)(CFTypeRef str, char *buffer, size_t len, UInt32 encoding);
Expand All @@ -123,15 +123,15 @@ struct _NSMutableStringBridge {

struct _NSXMLParserBridge {
_CFXMLInterface _Nullable (*_Nonnull currentParser)();
_CFXMLInterfaceParserInput _Nullable (*_Nonnull _xmlExternalEntityWithURL)(_CFXMLInterface interface, const char *url, const char * identifier, _CFXMLInterfaceParserContext context, _CFXMLInterfaceExternalEntityLoader originalLoaderFunction);
_CFXMLInterfaceParserInput _Nonnull (*_Nonnull _xmlExternalEntityWithURL)(_CFXMLInterface interface, const char *url, const char * identifier, _CFXMLInterfaceParserContext context, _CFXMLInterfaceExternalEntityLoader originalLoaderFunction);

_CFXMLInterfaceParserContext _Nonnull (*_Nonnull getContext)(_CFXMLInterface ctx);

void (*internalSubset)(_CFXMLInterface ctx, const unsigned char *name, const unsigned char *ExternalID, const unsigned char *SystemID);
int (*isStandalone)(_CFXMLInterface ctx);
int (*hasInternalSubset)(_CFXMLInterface ctx);
int (*hasExternalSubset)(_CFXMLInterface ctx);
_CFXMLInterfaceEntity _Nullable (*_Nonnull getEntity)(_CFXMLInterface ctx, const unsigned char *name);
_CFXMLInterfaceEntity _Nonnull (*_Nonnull getEntity)(_CFXMLInterface ctx, const unsigned char *name);
void (*notationDecl)(_CFXMLInterface ctx,
const unsigned char *name,
const unsigned char *publicId,
Expand All @@ -156,16 +156,16 @@ struct _NSXMLParserBridge {
void (*endDocument)(_CFXMLInterface ctx);
void (*startElementNs)(_CFXMLInterface ctx,
const unsigned char *localname,
const unsigned char *_Nullable prefix,
const unsigned char *prefix,
const unsigned char *URI,
int nb_namespaces,
const unsigned char *_Nullable *_Nonnull namespaces,
const unsigned char *_Nonnull *_Nonnull namespaces,
int nb_attributes,
int nb_defaulted,
const unsigned char *_Nullable *_Nonnull attributes);
const unsigned char *_Nonnull *_Nonnull attributes);
void (*endElementNs)(_CFXMLInterface ctx,
const unsigned char *localname,
const unsigned char *_Nullable prefix,
const unsigned char *prefix,
const unsigned char *URI);
void (*characters)(_CFXMLInterface ctx,
const unsigned char *ch,
Expand Down Expand Up @@ -239,7 +239,7 @@ extern CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef al
extern _Nullable CFDateRef CFCalendarCopyGregorianStartDate(CFCalendarRef calendar);
extern void CFCalendarSetGregorianStartDate(CFCalendarRef calendar, CFDateRef date);

CF_PRIVATE CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);
CF_PRIVATE CF_EXPORT char *_Nonnull*_Nonnull _CFEnviron(void);

CF_EXPORT void CFLog1(CFLogLevel lev, CFStringRef message);

Expand Down
22 changes: 11 additions & 11 deletions CoreFoundation/Parsing.subproj/CFXMLInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ typedef void* _CFXMLEntityPtr;
typedef void* _CFXMLDTDPtr;
typedef void* _CFXMLDTDNodePtr;

_CFXMLNodePtr _CFXMLNewNode(_CFXMLNamespacePtr _Nullable namespace, const char* name);
_CFXMLNodePtr _CFXMLNewNode(_CFXMLNamespacePtr namespace, const char* name);
_CFXMLNodePtr _CFXMLCopyNode(_CFXMLNodePtr node, bool recursive);

_CFXMLDocPtr _CFXMLNewDoc(const unsigned char* version);
Expand All @@ -147,7 +147,7 @@ _CFXMLNodePtr _CFXMLNewProperty(_CFXMLNodePtr _Nullable node, const unsigned cha
_CFXMLNamespacePtr _CFXMLNewNamespace(_CFXMLNodePtr _Nullable node, const unsigned char* uri, const unsigned char* prefix);

CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLNodeURI(_CFXMLNodePtr node);
void _CFXMLNodeSetURI(_CFXMLNodePtr node, const unsigned char* _Nullable URI);
void _CFXMLNodeSetURI(_CFXMLNodePtr node, const unsigned char* URI);

void _CFXMLNodeSetPrivateData(_CFXMLNodePtr node, void* data);
void* _Nullable _CFXMLNodeGetPrivateData(_CFXMLNodePtr node);
Expand All @@ -156,7 +156,7 @@ CFIndex _CFXMLNodeGetType(_CFXMLNodePtr node);
const char* _CFXMLNodeGetName(_CFXMLNodePtr node);
void _CFXMLNodeSetName(_CFXMLNodePtr node, const char* name);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLNodeGetContent(_CFXMLNodePtr node);
void _CFXMLNodeSetContent(_CFXMLNodePtr node, const unsigned char* _Nullable content);
void _CFXMLNodeSetContent(_CFXMLNodePtr node, const unsigned char* _Nullable content);
void _CFXMLUnlinkNode(_CFXMLNodePtr node);

_CFXMLNodePtr _Nullable _CFXMLNodeGetFirstChild(_CFXMLNodePtr node);
Expand All @@ -179,13 +179,13 @@ void _CFXMLDocSetRootElement(_CFXMLDocPtr doc, _CFXMLNodePtr node);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDocCharacterEncoding(_CFXMLDocPtr doc);
void _CFXMLDocSetCharacterEncoding(_CFXMLDocPtr doc, const unsigned char* _Nullable encoding);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDocVersion(_CFXMLDocPtr doc);
void _CFXMLDocSetVersion(_CFXMLDocPtr doc, const unsigned char* _Nullable version);
void _CFXMLDocSetVersion(_CFXMLDocPtr doc, const unsigned char* version);
int _CFXMLDocProperties(_CFXMLDocPtr doc);
void _CFXMLDocSetProperties(_CFXMLDocPtr doc, int newProperties);
_CFXMLDTDPtr _Nullable _CFXMLDocDTD(_CFXMLDocPtr doc);
void _CFXMLDocSetDTD(_CFXMLDocPtr doc, _CFXMLDTDPtr _Nullable dtd);

CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLEncodeEntities(_CFXMLDocPtr _Nullable doc, const unsigned char* string);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLEncodeEntities(_CFXMLDocPtr doc, const unsigned char* string);
_CFXMLEntityPtr _Nullable _CFXMLGetDocEntity(_CFXMLDocPtr doc, const char* entity);
_CFXMLEntityPtr _Nullable _CFXMLGetDTDEntity(_CFXMLDocPtr doc, const char* entity);
_CFXMLEntityPtr _Nullable _CFXMLGetParameterEntity(_CFXMLDocPtr doc, const char* entity);
Expand All @@ -205,32 +205,32 @@ CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLNodePrefix(_CFXMLNodePtr node);

bool _CFXMLDocValidate(_CFXMLDocPtr doc, CFErrorRef _Nullable * error);

_CFXMLDTDPtr _CFXMLNewDTD(_CFXMLDocPtr _Nullable doc, const unsigned char* name, const unsigned char* publicID, const unsigned char* systemID);
_CFXMLDTDPtr _CFXMLNewDTD(_CFXMLDocPtr doc, const unsigned char* name, const unsigned char* publicID, const unsigned char* systemID);
_CFXMLDTDNodePtr _Nullable _CFXMLParseDTDNode(const unsigned char* xmlString);
_CFXMLDTDPtr _Nullable _CFXMLParseDTD(const unsigned char* URL);
_CFXMLDTDPtr _Nullable _CFXMLParseDTDFromData(CFDataRef data, CFErrorRef _Nullable * error);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDTDExternalID(_CFXMLDTDPtr dtd);
void _CFXMLDTDSetExternalID(_CFXMLDTDPtr dtd, const unsigned char* _Nullable externalID);
void _CFXMLDTDSetExternalID(_CFXMLDTDPtr dtd, const unsigned char* externalID);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDTDSystemID(_CFXMLDTDPtr dtd);
void _CFXMLDTDSetSystemID(_CFXMLDTDPtr dtd, const unsigned char* _Nullable systemID);
void _CFXMLDTDSetSystemID(_CFXMLDTDPtr dtd, const unsigned char* systemID);

_CFXMLDTDNodePtr _Nullable _CFXMLDTDGetElementDesc(_CFXMLDTDPtr dtd, const unsigned char* name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDGetAttributeDesc(_CFXMLDTDPtr dtd, const unsigned char* elementName, const unsigned char* name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDGetNotationDesc(_CFXMLDTDPtr dtd, const unsigned char* name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDGetEntityDesc(_CFXMLDTDPtr dtd, const unsigned char* name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDGetPredefinedEntity(const unsigned char* name);

_CFXMLDTDNodePtr _Nullable _CFXMLDTDNewElementDesc(_CFXMLDTDPtr _Nullable dtd, const unsigned char* _Nullable name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDNewElementDesc(_CFXMLDTDPtr dtd, const unsigned char* name);
_CFXMLDTDNodePtr _Nullable _CFXMLDTDNewAttributeDesc(_CFXMLDTDPtr dtd, const unsigned char* name);

CFIndex _CFXMLDTDElementNodeGetType(_CFXMLDTDNodePtr node);
CFIndex _CFXMLDTDEntityNodeGetType(_CFXMLDTDNodePtr node);
CFIndex _CFXMLDTDAttributeNodeGetType(_CFXMLDTDNodePtr node);

CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDTDNodeGetSystemID(_CFXMLDTDNodePtr node);
void _CFXMLDTDNodeSetSystemID(_CFXMLDTDNodePtr node, const unsigned char* _Nullable systemID);
void _CFXMLDTDNodeSetSystemID(_CFXMLDTDNodePtr node, const unsigned char* systemID);
CF_RETURNS_RETAINED CFStringRef _Nullable _CFXMLDTDNodeGetPublicID(_CFXMLDTDNodePtr node);
void _CFXMLDTDNodeSetPublicID(_CFXMLDTDNodePtr node, const unsigned char* _Nullable publicID);
void _CFXMLDTDNodeSetPublicID(_CFXMLDTDNodePtr node, const unsigned char* publicID);

void _CFXMLFreeNode(_CFXMLNodePtr node);
void _CFXMLFreeDocument(_CFXMLDocPtr doc);
Expand Down
10 changes: 5 additions & 5 deletions Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
}

public convenience override init() {
self.init(objects: [], count:0)
self.init(objects: nil, count:0)
}

public required init(objects: UnsafePointer<AnyObject?>, count cnt: Int) {
Expand Down Expand Up @@ -359,13 +359,13 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
return NSData(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer<Void>.self), length: count * sizeof(Int), freeWhenDone: true)
}

public func sortedArrayUsingFunction(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>?) -> Int, context: UnsafeMutablePointer<Void>?) -> [AnyObject] {
public func sortedArrayUsingFunction(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>) -> Int, context: UnsafeMutablePointer<Void>) -> [AnyObject] {
return sortedArrayWithOptions([]) { lhs, rhs in
return NSComparisonResult(rawValue: comparator(lhs, rhs, context))!
}
}

public func sortedArrayUsingFunction(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>?) -> Int, context: UnsafeMutablePointer<Void>?, hint: NSData?) -> [AnyObject] {
public func sortedArrayUsingFunction(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>) -> Int, context: UnsafeMutablePointer<Void>, hint: NSData?) -> [AnyObject] {
return sortedArrayWithOptions([]) { lhs, rhs in
return NSComparisonResult(rawValue: comparator(lhs, rhs, context))!
}
Expand Down Expand Up @@ -653,7 +653,7 @@ public class NSMutableArray : NSArray {
}

public init(capacity numItems: Int) {
super.init(objects: [], count: 0)
super.init(objects: nil, count: 0)

if self.dynamicType === NSMutableArray.self {
_storage.reserveCapacity(numItems)
Expand Down Expand Up @@ -807,7 +807,7 @@ public class NSMutableArray : NSArray {
}
}

public func sortUsingFunction(_ compare: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>?) -> Int, context: UnsafeMutablePointer<Void>?) {
public func sortUsingFunction(_ compare: @convention(c) (AnyObject, AnyObject, UnsafeMutablePointer<Void>) -> Int, context: UnsafeMutablePointer<Void>) {
self.setArray(self.sortedArrayUsingFunction(compare, context: context))
}

Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCFArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal func _CFSwiftArrayRemoveAllValues(_ array: AnyObject) {
(array as! NSMutableArray).removeAllObjects()
}

internal func _CFSwiftArrayReplaceValues(_ array: AnyObject, _ range: CFRange, _ newValues: UnsafeMutablePointer<Unmanaged<AnyObject>>, _ newCount: CFIndex) {
internal func _CFSwiftArrayReplaceValues(_ array: AnyObject, _ range: CFRange, _ newValues: UnsafeMutablePointer<Unmanaged<AnyObject>?>, _ newCount: CFIndex) {
NSUnimplemented()
// (array as! NSMutableArray).replaceObjectsInRange(NSMakeRange(range.location, range.length), withObjectsFromArray: newValues.array(newCount))
}
20 changes: 12 additions & 8 deletions Foundation/NSCFDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ internal final class _NSCFDictionary : NSMutableDictionary {
let cf = dict._cfObject
count = CFDictionaryGetCount(cf)

let keys = UnsafeMutablePointer<UnsafePointer<Void>?>(allocatingCapacity: count)
let keys = UnsafeMutablePointer<UnsafePointer<Void>>(allocatingCapacity: count)
CFDictionaryGetKeysAndValues(cf, keys, nil)

for idx in 0..<count {
let key = unsafeBitCast(keys.advanced(by: idx).pointee!, to: NSObject.self)
let key = unsafeBitCast(keys.advanced(by: idx).pointee, to: NSObject.self)
keyArray.append(key)
}
keys.deinitialize()
Expand Down Expand Up @@ -118,12 +118,12 @@ internal func _CFSwiftDictionaryGetValue(_ dictionary: AnyObject, key: AnyObject
}
}

internal func _CFSwiftDictionaryGetValueIfPresent(_ dictionary: AnyObject, key: AnyObject, value: UnsafeMutablePointer<Unmanaged<AnyObject>?>?) -> Bool {
internal func _CFSwiftDictionaryGetValueIfPresent(_ dictionary: AnyObject, key: AnyObject, value: UnsafeMutablePointer<Unmanaged<AnyObject>?>) -> Bool {
if let val = _CFSwiftDictionaryGetValue(dictionary, key: key) {
value?.pointee = val
value.pointee = val
return true
} else {
value?.pointee = nil
value.pointee = nil
return false
}
}
Expand All @@ -140,14 +140,18 @@ internal func _CFSwiftDictionaryContainsValue(_ dictionary: AnyObject, value: An
NSUnimplemented()
}

internal func _CFSwiftDictionaryGetValuesAndKeys(_ dictionary: AnyObject, valuebuf: UnsafeMutablePointer<Unmanaged<AnyObject>?>?, keybuf: UnsafeMutablePointer<Unmanaged<AnyObject>?>?) {
internal func _CFSwiftDictionaryGetValuesAndKeys(_ dictionary: AnyObject, valuebuf: UnsafeMutablePointer<Unmanaged<AnyObject>?>, keybuf: UnsafeMutablePointer<Unmanaged<AnyObject>?>) {
var idx = 0
if valuebuf == nil && keybuf == nil {
return
}
(dictionary as! NSDictionary).enumerateKeysAndObjectsUsingBlock { key, value, _ in
valuebuf?[idx] = Unmanaged<AnyObject>.passUnretained(value)
keybuf?[idx] = Unmanaged<AnyObject>.passUnretained(key)
if valuebuf != nil {
valuebuf[idx] = Unmanaged<AnyObject>.passUnretained(value)
}
if keybuf != nil {
keybuf[idx] = Unmanaged<AnyObject>.passUnretained(key)
}
idx += 1
}
}
Expand Down
20 changes: 12 additions & 8 deletions Foundation/NSCFString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,26 @@ internal func _CFSwiftStringGetCharacters(_ str: AnyObject, range: CFRange, buff
(str as! NSString).getCharacters(buffer, range: NSMakeRange(range.location, range.length))
}

internal func _CFSwiftStringGetBytes(_ str: AnyObject, encoding: CFStringEncoding, range: CFRange, buffer: UnsafeMutablePointer<UInt8>?, maxBufLen: CFIndex, usedBufLen: UnsafeMutablePointer<CFIndex>?) -> CFIndex {
internal func _CFSwiftStringGetBytes(_ str: AnyObject, encoding: CFStringEncoding, range: CFRange, buffer: UnsafeMutablePointer<UInt8>, maxBufLen: CFIndex, usedBufLen: UnsafeMutablePointer<CFIndex>) -> CFIndex {
switch encoding {
// TODO: Don't treat many encodings like they are UTF8
case CFStringEncoding(kCFStringEncodingUTF8), CFStringEncoding(kCFStringEncodingISOLatin1), CFStringEncoding(kCFStringEncodingMacRoman), CFStringEncoding(kCFStringEncodingASCII), CFStringEncoding(kCFStringEncodingNonLossyASCII):
let encodingView = (str as! NSString)._swiftObject.utf8
let start = encodingView.startIndex
if let buffer = buffer {
if buffer != nil {
for idx in 0..<range.length {
let character = encodingView[start.advanced(by: idx + range.location)]
buffer.advanced(by: idx).initialize(with: character)
}
}
usedBufLen?.pointee = range.length
if usedBufLen != nil {
usedBufLen.pointee = range.length
}

case CFStringEncoding(kCFStringEncodingUTF16):
let encodingView = (str as! NSString)._swiftObject.utf16
let start = encodingView.startIndex
if let buffer = buffer {
if buffer != nil {
for idx in 0..<range.length {
// Since character is 2 bytes but the buffer is in term of 1 byte values, we have to split it up
let character = encodingView[start.advanced(by: idx + range.location)]
Expand All @@ -152,8 +154,10 @@ internal func _CFSwiftStringGetBytes(_ str: AnyObject, encoding: CFStringEncodin
buffer.advanced(by: (idx * 2) + 1).initialize(with: byte1)
}
}
// Every character was 2 bytes
usedBufLen?.pointee = range.length * 2
if usedBufLen != nil {
// Every character was 2 bytes
usedBufLen.pointee = range.length * 2
}


default:
Expand All @@ -176,11 +180,11 @@ internal func _CFSwiftStringCreateMutableCopy(_ str: AnyObject) -> Unmanaged<Any
return Unmanaged<AnyObject>.passRetained((str as! NSString).mutableCopyWithZone(nil))
}

internal func _CFSwiftStringFastCStringContents(_ str: AnyObject) -> UnsafePointer<Int8>? {
internal func _CFSwiftStringFastCStringContents(_ str: AnyObject) -> UnsafePointer<Int8> {
return (str as! NSString)._fastCStringContents
}

internal func _CFSwiftStringFastContents(_ str: AnyObject) -> UnsafePointer<UniChar>? {
internal func _CFSwiftStringFastContents(_ str: AnyObject) -> UnsafePointer<UniChar> {
return (str as! NSString)._fastContents
}

Expand Down
Loading