Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ uuid = { version = "0.8", features = ["v4"], optional = true }

[target.'cfg(target_os="macos")'.dependencies]
objc2 = "0.6.4"
objc2-core-foundation = { version = "0.3.2", default-features = false, features = ["std", "CFString", "CFUUID"] }
objc2-foundation = { version = "0.3.2", default-features = false, features = ["std", "NSEnumerator"] }
objc2-core-foundation = { version = "0.3.2", default-features = false, features = ["std", "CFString", "CFUUID", "block2", "objc2"] }
block2 = "0.6.2"
objc2-foundation = { version = "0.3.2", default-features = false, features = ["std", "NSEnumerator", "block2", "NSOperation"] }
objc2-app-kit = { version = "0.3.2", default-features = false, features = [
"NSApplication",
"NSDragging",
Expand Down
35 changes: 0 additions & 35 deletions src/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,4 @@ mod keyboard;
mod view;
mod window;

use objc2::rc::Retained;
use objc2::Message;
use std::cell::RefCell;
pub use window::*;

pub struct RetainedCell<T> {
inner: RefCell<Option<Retained<T>>>,
}

impl<T> RetainedCell<T> {
pub const fn empty() -> Self {
RetainedCell { inner: RefCell::new(None) }
}

pub const fn new(value: Retained<T>) -> Self {
RetainedCell { inner: RefCell::new(Some(value)) }
}

pub const fn with(value: Option<Retained<T>>) -> Self {
RetainedCell { inner: RefCell::new(value) }
}

pub fn take(&self) -> Option<Retained<T>> {
self.inner.borrow_mut().take()
}
}

impl<T: Message> RetainedCell<T> {
pub fn get(&self) -> Option<Retained<T>> {
(*self.inner.borrow()).as_ref().map(|inner| inner.retain())
}

pub fn set(&self, value: Retained<T>) {
self.inner.replace(Some(value));
}
}
Loading
Loading