Initial transition to objc2 (#2452)
* Use objc2 * Use objc2's NSInteger/NSUInteger/NSRange
This commit is contained in:
parent
e0018d0710
commit
112965b4ff
23 changed files with 394 additions and 480 deletions
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
use std::ffi::c_void;
|
||||
|
||||
use cocoa::{
|
||||
base::id,
|
||||
foundation::{NSInteger, NSUInteger},
|
||||
};
|
||||
use cocoa::base::id;
|
||||
use core_foundation::{
|
||||
array::CFArrayRef, dictionary::CFDictionaryRef, string::CFStringRef, uuid::CFUUIDRef,
|
||||
};
|
||||
|
|
@ -15,34 +12,10 @@ use core_graphics::{
|
|||
base::CGError,
|
||||
display::{CGDirectDisplayID, CGDisplayConfigRef},
|
||||
};
|
||||
use objc::foundation::{NSInteger, NSUInteger};
|
||||
|
||||
pub const NSNotFound: NSInteger = NSInteger::max_value();
|
||||
|
||||
#[repr(C)]
|
||||
pub struct NSRange {
|
||||
pub location: NSUInteger,
|
||||
pub length: NSUInteger,
|
||||
}
|
||||
|
||||
impl NSRange {
|
||||
#[inline]
|
||||
pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange {
|
||||
NSRange { location, length }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl objc::Encode for NSRange {
|
||||
fn encode() -> objc::Encoding {
|
||||
let encoding = format!(
|
||||
// TODO: Verify that this is correct
|
||||
"{{NSRange={}{}}}",
|
||||
NSUInteger::encode().as_str(),
|
||||
NSUInteger::encode().as_str(),
|
||||
);
|
||||
unsafe { objc::Encoding::from_str(&encoding) }
|
||||
}
|
||||
}
|
||||
|
||||
pub trait NSMutableAttributedString: Sized {
|
||||
unsafe fn alloc(_: Self) -> id {
|
||||
msg_send![class!(NSMutableAttributedString), alloc]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue