-
Notifications
You must be signed in to change notification settings - Fork 891
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
Fix some invalid msg_send!
usage
#2138
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.
Thank you for making these improvements.
There is one thing that bugs me. The fact that we have to write
my_objc_bool != NO
I know that it's necessary to compare against NO, but then we have a double negation for every single truthy check.
Here's an alternative:
trait BoolYeah {
/// This is true when `self` is not `NO`
///
/// Note that this different from
/// `self == YES`
/// because YES is the value 1 but
/// a BOOL may be any signed 8bit value
fn yeah(self) -> bool;
fn no(self) -> bool;
}
impl BoolYeah for objc::runtime::BOOL {
#[inline]
fn yeah(self) -> bool {
self != 0
}
#[inline]
fn no(self) -> bool {
self == 0
}
}
So that we can write
if window_has_focus.yeah() {
It would be more clear to have |
Just to throw another option into the mix, what about |
Maybe just a conversion, e.g. |
In my fork of I intend to use that fork in |
Alright, I'm looking forward to moving to your fork of objc then. |
Thanks! Though intending to move to something else in the unknown future shouldn't be a blocker for adding |
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.
Awesome!
Change a few types for more correct behaviour (e.g. using
bool
may be undefined behaviour, one should useBOOL
).The only critical thing here is the stuff in
unmark_text
(introduced in #2119), that part is certainly undefined behaviour, and will probably cause problems somewhere down the line.CHANGELOG.md
if knowledge of this change could be valuable to users