-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Disable toll-free bridging for CFRunLoopTimer #2116
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
Disable toll-free bridging for CFRunLoopTimer #2116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two changes before it's okay.
@@ -4306,7 +4306,7 @@ CFIndex CFRunLoopTimerGetOrder(CFRunLoopTimerRef rlt) { | |||
|
|||
void CFRunLoopTimerInvalidate(CFRunLoopTimerRef rlt) { /* DOES CALLOUT */ | |||
CHECK_FOR_FORK(); | |||
CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, invalidate); | |||
//CF_OBJC_FUNCDISPATCHV(CFRunLoopTimerGetTypeID(), void, (NSTimer *)rlt, invalidate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not disable CF_OBJC_… functions. As the name implies, these are for ObjC (and are no-ops in Swift.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK great, I didn't realise that. Specifically that one however does appear to be casting CFRunLoopTimer
to NSTimer *
, is that ok to keep in?
@@ -29,7 +29,7 @@ typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFRunLoopSource * CFRunLoopSourceRe | |||
|
|||
typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFRunLoopObserver * CFRunLoopObserverRef; | |||
|
|||
typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef; | |||
typedef struct /*CF_BRIDGED_MUTABLE_TYPE(id)*/ __CFRunLoopTimer * CFRunLoopTimerRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not disable this. This does not bridge to NSTimer
; it bridges to id
, meaning that it allows CFRunLoopTimer
to be treated as an AnyObject
(and thus its API be imported without using Unmanaged<…>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK makes sense, I did note CFRunLoop
itself etc are also CF_BRIDGED_MUTABLE_TYPE
there. Should the type remain NSTimer
however or be id
like the rest?
In general, changing public API headers is not allowed. |
Noted, thanks. Thanks for the feedback! |
0904581
to
5a5d730
Compare
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
5a5d730
to
af01e68
Compare
This one should do it, works on my system without changing the API. Thanks again for the feedback! |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
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