Updates for recent versions of Rust.

* Added lots of dyns
* Removed unused whitespace.
* Removed rust-toolchain because stable rust compiles the project.
* Fixed Doc-tests with ignore keyword.
This commit is contained in:
Sebastian Imlay 2019-10-04 14:52:33 -07:00
parent f15cf258af
commit 5695ec9b94
23 changed files with 170 additions and 171 deletions

View file

@ -1,7 +1,7 @@
//! Implements a View Component struct. The most common
//! basic building block of any app. Wraps NSView on macOS.
use std::sync::{Once, ONCE_INIT};
use std::sync::{Once};
use objc_id::{Id, ShareId};
use objc::{msg_send, sel, sel_impl};
@ -20,7 +20,7 @@ use alchemy_lifecycle::traits::PlatformSpecificNodeType;
static ALCHEMY_DELEGATE: &str = "alchemyDelegate";
static BACKGROUND_COLOR: &str = "alchemyBackgroundColor";
/// A wrapper for `NSView`. This holds retained pointers for the Objective-C
/// A wrapper for `NSView`. This holds retained pointers for the Objective-C
/// runtime - namely, the view itself, and associated things such as background
/// colors and so forth.
#[derive(Debug)]
@ -76,8 +76,8 @@ impl View {
);
self.background_color = appearance.background_color.into_nscolor();
self.inner_mut.set_ivar(BACKGROUND_COLOR, &*self.background_color);
self.inner_mut.set_ivar(BACKGROUND_COLOR, &*self.background_color);
msg_send![&*self.inner_mut, setFrame:rect];
msg_send![&*self.inner_mut, setNeedsDisplay:YES];
}
@ -107,12 +107,12 @@ extern fn update_layer(this: &Object, _: Sel) {
/// to store.
fn register_class() -> *const Class {
static mut VIEW_CLASS: *const Class = 0 as *const Class;
static INIT: Once = ONCE_INIT;
static INIT: Once = Once::new();
INIT.call_once(|| unsafe {
let superclass = Class::get("NSView").unwrap();
let mut decl = ClassDecl::new("AlchemyView", superclass).unwrap();
// Force NSView to render from the top-left, not bottom-left
decl.add_method(sel!(isFlipped), enforce_normalcy as extern fn(&Object, _) -> BOOL);
@ -131,7 +131,7 @@ fn register_class() -> *const Class {
// for common terminology sake.
decl.add_ivar::<usize>(ALCHEMY_DELEGATE);
decl.add_ivar::<id>(BACKGROUND_COLOR);
VIEW_CLASS = decl.register();
});