Skip to content

Commit

Permalink
Use proper NSInteger/NSUInteger/NSRange
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 2, 2022
1 parent ebe1fcc commit f41d459
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/platform_impl/ios/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{
time::Instant,
};

use objc::foundation::{NSInteger, NSUInteger};
use objc::runtime::Object;
use once_cell::sync::Lazy;

Expand All @@ -21,8 +22,8 @@ use crate::{
ffi::{
id, kCFRunLoopCommonModes, CFAbsoluteTimeGetCurrent, CFRelease, CFRunLoopAddTimer,
CFRunLoopGetMain, CFRunLoopRef, CFRunLoopTimerCreate, CFRunLoopTimerInvalidate,
CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate, CGRect, CGSize, NSInteger,
NSOperatingSystemVersion, NSUInteger,
CFRunLoopTimerRef, CFRunLoopTimerSetNextFireDate, CGRect, CGSize,
NSOperatingSystemVersion,
},
},
window::WindowId as RootWindowId,
Expand Down
4 changes: 1 addition & 3 deletions src/platform_impl/ios/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{convert::TryInto, ffi::CString, ops::BitOr, os::raw::*};

use objc::foundation::{NSInteger, NSUInteger};
use objc::{runtime::Object, Encode, Encoding};

use crate::{
Expand All @@ -17,9 +18,6 @@ pub type CGFloat = f32;
#[cfg(target_pointer_width = "64")]
pub type CGFloat = f64;

pub type NSInteger = isize;
pub type NSUInteger = usize;

#[repr(C)]
#[derive(Clone, Debug)]
pub struct NSOperatingSystemVersion {
Expand Down
4 changes: 3 additions & 1 deletion src/platform_impl/ios/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ use std::{
ops::{Deref, DerefMut},
};

use objc::foundation::{NSInteger, NSUInteger};

use crate::{
dpi::{PhysicalPosition, PhysicalSize},
monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode},
platform_impl::platform::{
app_state,
ffi::{id, nil, CGFloat, CGRect, CGSize, NSInteger, NSUInteger},
ffi::{id, nil, CGFloat, CGRect, CGSize},
},
};

Expand Down
11 changes: 6 additions & 5 deletions src/platform_impl/macos/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ use std::{
use cocoa::{
appkit::{NSApp, NSEventModifierFlags, NSEventSubtype, NSEventType::NSApplicationDefined},
base::{id, nil},
foundation::{NSInteger, NSPoint, NSTimeInterval},
foundation::{NSPoint, NSTimeInterval},
};
use objc::{foundation::is_main_thread, rc::autoreleasepool};
use objc::foundation::is_main_thread;
use objc::rc::autoreleasepool;
use raw_window_handle::{AppKitDisplayHandle, RawDisplayHandle};

use crate::{
Expand Down Expand Up @@ -245,11 +246,11 @@ pub unsafe fn post_dummy_event(target: id) {
location: NSPoint::new(0.0, 0.0)
modifierFlags: NSEventModifierFlags::empty()
timestamp: 0 as NSTimeInterval
windowNumber: 0 as NSInteger
windowNumber: 0isize
context: nil
subtype: NSEventSubtype::NSWindowExposedEventType
data1: 0 as NSInteger
data2: 0 as NSInteger
data1: 0isize
data2: 0isize
];
let _: () = msg_send![target, postEvent: dummy_event, atStart: true];
}
Expand Down
6 changes: 2 additions & 4 deletions src/platform_impl/macos/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

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,
};
use core_graphics::{
base::CGError,
display::{CGDirectDisplayID, CGDisplayConfigRef},
};
use objc::foundation::{NSInteger, NSUInteger};

pub const NSNotFound: NSInteger = NSInteger::max_value();

Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/macos/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use crate::{
use cocoa::{
appkit::NSScreen,
base::{id, nil},
foundation::NSUInteger,
};
use core_foundation::{
array::{CFArrayGetCount, CFArrayGetValueAtIndex},
base::{CFRelease, TCFType},
string::CFString,
};
use core_graphics::display::{CGDirectDisplayID, CGDisplay, CGDisplayBounds};
use objc::foundation::NSUInteger;

#[derive(Clone)]
pub struct VideoMode {
Expand Down
3 changes: 2 additions & 1 deletion src/platform_impl/macos/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use std::os::raw::c_uchar;
use cocoa::{
appkit::{CGFloat, NSApp, NSWindowStyleMask},
base::{id, nil},
foundation::{NSPoint, NSRange, NSRect, NSString, NSUInteger},
foundation::{NSPoint, NSRect, NSString},
};
use core_graphics::display::CGDisplay;
use objc::foundation::{NSRange, NSUInteger};
use objc::runtime::{Class, Object};

use crate::dpi::LogicalPosition;
Expand Down
3 changes: 2 additions & 1 deletion src/platform_impl/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use std::{
use cocoa::{
appkit::{NSApp, NSEvent, NSEventModifierFlags, NSEventPhase, NSView, NSWindow},
base::{id, nil},
foundation::{NSInteger, NSPoint, NSRange, NSRect, NSSize, NSString, NSUInteger},
foundation::{NSPoint, NSRect, NSSize, NSString},
};
use objc::{
declare::ClassBuilder,
foundation::{NSInteger, NSRange, NSUInteger},
runtime::{Bool, Class, Object, Protocol, Sel},
};
use once_cell::sync::Lazy;
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ use cocoa::{
NSRequestUserAttentionType, NSScreen, NSView, NSWindow, NSWindowButton, NSWindowStyleMask,
},
base::{id, nil},
foundation::{NSDictionary, NSPoint, NSRect, NSSize, NSUInteger},
foundation::{NSDictionary, NSPoint, NSRect, NSSize},
};
use core_graphics::display::{CGDisplay, CGDisplayMode};
use objc::{
declare::ClassBuilder,
foundation::is_main_thread,
foundation::{is_main_thread, NSUInteger},
rc::autoreleasepool,
runtime::{Bool, Class, Object, Sel},
};
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/macos/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{
use cocoa::{
appkit::{self, NSApplicationPresentationOptions, NSView, NSWindow, NSWindowOcclusionState},
base::{id, nil},
foundation::NSUInteger,
};
use objc::{
declare::ClassBuilder,
foundation::NSUInteger,
rc::autoreleasepool,
runtime::{Bool, Class, Object, Sel},
};
Expand Down Expand Up @@ -477,7 +477,7 @@ extern "C" fn window_will_use_fullscreen_presentation_options(
options = (NSApplicationPresentationOptions::NSApplicationPresentationFullScreen
| NSApplicationPresentationOptions::NSApplicationPresentationHideDock
| NSApplicationPresentationOptions::NSApplicationPresentationHideMenuBar)
.bits();
.bits() as NSUInteger;
}
})
});
Expand Down

0 comments on commit f41d459

Please sign in to comment.