-
Notifications
You must be signed in to change notification settings - Fork 72
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 objc2
warnings
#34
base: trunk
Are you sure you want to change the base?
Conversation
/// Bool mapping types differ between ARM and x64. There's a number of places that we need to check | ||
/// against BOOL results throughout the framework, and this just simplifies some mismatches. | ||
#[inline(always)] | ||
pub fn to_bool(result: BOOL) -> bool { |
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.
This makes me stupidly happy to see deleted.
This one also looks fine to me, albeit needs a touch of rebase it seems. |
0942f27
to
d281529
Compare
I've incorporated a few fixes from a newer version of |
d281529
to
16d62e9
Compare
pub(crate) fn register_window_controller_class<T: WindowDelegate>() -> *const Class { | ||
static mut DELEGATE_CLASS: *const Class = 0 as *const Class; | ||
pub(crate) fn register_window_controller_class<T: WindowDelegate>() -> &'static Class { | ||
static mut DELEGATE_CLASS: Option<&'static Class> = None; |
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.
Does this need to be an Option<&'static Class>
because it was initialized as 0 as *const Class
before? I think the only part that feels odd to me is the unsafe { DELEGATE_CLASS.unwrap() }
.
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.
The static is created before the program begins, so it has to be initialized to some value, in this case None
. When the function is called the first time, the class is created and the static is set to the new value.
The unsafety in unsafe { DELEGATE_CLASS.unwrap() }
comes from the fact that DELEGATE_CLASS
is a mutable static, and hence can only be accessed behind unsafe
. Data races are prevented by Once
.
In essence, what we do here with DELEGATE_CLASS
and Once
is similar to once_cell::sync::Lazy
and the nightly std::cell::LazyCell
.
Where's this one sit with regards to #30? Should I just ignore it at this point? |
No, I'll pick it up again after #30 |
Kk sounds good! |
16d62e9
to
85649e5
Compare
Builds upon #30.
Fix warnings introduced by
objc2
deprecating certain functionality.