Skip to content

Commit 0904581

Browse files
Disable toll-free bridging for CFRunLoopTimer
Foundation.Timer is not currently implemented with a compatible memory layout so attempt to bridge these classes will fail. Disabling bridging allows code using CFRunLoopTimer to work until Foundation.Timer is reimplemented. Fixes https://bugs.swift.org/browse/SR-10465
1 parent 37f6839 commit 0904581

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

CoreFoundation/RunLoop.subproj/CFRunLoop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4306,7 +4306,7 @@ CFIndex CFRunLoopTimerGetOrder(CFRunLoopTimerRef rlt) {
43064306

43074307
void CFRunLoopTimerInvalidate(CFRunLoopTimerRef rlt) { /* DOES CALLOUT */
43084308
CHECK_FOR_FORK();
4309-
CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, invalidate);
4309+
//CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, invalidate);
43104310
__CFGenericValidateType(rlt, CFRunLoopTimerGetTypeID());
43114311
__CFRunLoopTimerLock(rlt);
43124312
if (!__CFRunLoopTimerIsDeallocating(rlt)) {

CoreFoundation/RunLoop.subproj/CFRunLoop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFRunLoopSource * CFRunLoopSourceRe
2929

3030
typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFRunLoopObserver * CFRunLoopObserverRef;
3131

32-
typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef;
32+
typedef struct /*CF_BRIDGED_MUTABLE_TYPE(id)*/ __CFRunLoopTimer * CFRunLoopTimerRef;
3333

3434
/* Reasons for CFRunLoopRunInMode() to Return */
3535
typedef CF_ENUM(SInt32, CFRunLoopRunResult) {

Foundation/NSSwiftRuntime.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ internal func __CFInitializeSwift() {
173173
_CFRuntimeBridgeTypeToClass(CFAttributedStringGetTypeID(), unsafeBitCast(NSMutableAttributedString.self, to: UnsafeRawPointer.self))
174174
// _CFRuntimeBridgeTypeToClass(CFReadStreamGetTypeID(), unsafeBitCast(InputStream.self, UnsafeRawPointer.self))
175175
// _CFRuntimeBridgeTypeToClass(CFWriteStreamGetTypeID(), unsafeBitCast(OutputStream.self, UnsafeRawPointer.self))
176-
_CFRuntimeBridgeTypeToClass(CFRunLoopTimerGetTypeID(), unsafeBitCast(Timer.self, to: UnsafeRawPointer.self))
177-
176+
//_CFRuntimeBridgeTypeToClass(CFRunLoopTimerGetTypeID(), unsafeBitCast(Timer.self, to: UnsafeRawPointer.self))
177+
178178
__CFSwiftBridge.NSObject.isEqual = _CFSwiftIsEqual
179179
__CFSwiftBridge.NSObject.hash = _CFSwiftGetHash
180180
__CFSwiftBridge.NSObject._cfTypeID = _CFSwiftGetTypeID

Foundation/Timer.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ internal func __NSFireTimer(_ timer: CFRunLoopTimer?, info: UnsafeMutableRawPoin
1616
}
1717

1818
open class Timer : NSObject {
19-
typealias CFType = CFRunLoopTimer
20-
21-
internal var _cfObject: CFType {
19+
internal var _cfObject: CFRunLoopTimer {
2220
get {
2321
return _timer!
2422
}

0 commit comments

Comments
 (0)