Skip to content

Commit 842383a

Browse files
committed
Merge pull request #264 from hpux735/arm-fixes
Foundation fixes for 32-bit systems and more
2 parents f080a00 + 8955678 commit 842383a

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

CoreFoundation/NumberDate.subproj/CFNumber.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType type, const vo
12021202
}
12031203
}
12041204

1205-
CFIndex size = 8 + ((!__CFNumberTypeTable[type].floatBit && __CFNumberTypeTable[type].storageBit) ? 8 : 0);
1205+
CFIndex size = (sizeof(struct __CFNumber) - sizeof(CFRuntimeBase)) + ((!__CFNumberTypeTable[type].floatBit && __CFNumberTypeTable[type].storageBit) ? 8 : 0);
12061206
#if OLD_CRAP_TOO
12071207
size += 2 * sizeof(void *);
12081208
#endif

Foundation/NSDateFormatter.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class NSDateFormatter : NSFormatter {
2323
#endif
2424
let obj = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale._cfObject, dateStyle, timeStyle)
2525
// TODO: Set up attributes here
26+
if let dateFormat = _dateFormat {
27+
CFDateFormatterSetFormat(obj, dateFormat._cfObject)
28+
}
2629
__cfObject = obj
2730
return obj
2831
}
@@ -51,7 +54,7 @@ public class NSDateFormatter : NSFormatter {
5154
}
5255

5356
public func dateFromString(string: String) -> NSDate? {
54-
var range = CFRange()
57+
var range = CFRange(location: 0, length: string.length)
5558
let date = withUnsafeMutablePointer(&range) { (rangep: UnsafeMutablePointer<CFRange>) -> NSDate? in
5659
guard let res = CFDateFormatterCreateDateFromString(kCFAllocatorSystemDefault, _cfObject, string._cfObject, rangep) else {
5760
return nil
@@ -100,7 +103,16 @@ public class NSDateFormatter : NSFormatter {
100103

101104
public var timeStyle: NSDateFormatterStyle = .NoStyle { willSet { _reset() } }
102105

103-
/*@NSCopying*/ public var locale: NSLocale! { willSet { _reset() } }
106+
internal var _locale: NSLocale = NSLocale.currentLocale()
107+
/*@NSCopying*/ public var locale: NSLocale! {
108+
get {
109+
return _locale
110+
}
111+
set {
112+
_reset()
113+
_locale = newValue
114+
}
115+
}
104116

105117
public var generatesCalendarDates = false { willSet { _reset() } }
106118

Foundation/NSGeometry.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ public struct CGFloat {
3333
public var native: NativeType
3434

3535
private var hash: Int {
36+
#if arch(i386) || arch(arm)
37+
return Int(Float(self.native)._toBitPattern())
38+
#else
3639
return Int(self.native._toBitPattern())
40+
#endif
3741
}
3842
}
3943

Foundation/NSNumberFormatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class NSNumberFormatter : NSFormatter {
5959
}
6060

6161
public func numberFromString(string: String) -> NSNumber? {
62-
var range = CFRange()
62+
var range = CFRange(location: 0, length: string.length)
6363
let number = withUnsafeMutablePointer(&range) { (rangePointer: UnsafeMutablePointer<CFRange>) -> NSNumber? in
6464

6565
#if os(OSX) || os(iOS)

Foundation/NSPathUtilities.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public func NSTemporaryDirectory() -> String {
2424
}
2525
#endif
2626
if let tmpdir = NSProcessInfo.processInfo().environment["TMPDIR"] {
27-
return tmpdir
27+
if !tmpdir.hasSuffix("/") {
28+
return tmpdir + "/"
29+
} else {
30+
return tmpdir
31+
}
2832
}
2933
return "/tmp/"
3034
}
@@ -644,4 +648,4 @@ internal func _NSCleanupTemporaryFile(auxFilePath: String, _ filePath: String) t
644648
}
645649
throw _NSErrorWithErrno(errno, reading: false, path: filePath)
646650
}
647-
}
651+
}

Foundation/NSXMLElement.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public class NSXMLElement : NSXMLNode {
159159
*/
160160
public func attributeForName(name: String) -> NSXMLNode? {
161161
let attribute = _CFXMLNodeHasProp(_xmlNode, name)
162+
if attribute == nil { return nil }
162163
return NSXMLNode._objectNodeForNode(attribute)
163164
}
164165

0 commit comments

Comments
 (0)