diff --git a/cocoa-foundation/src/foundation.rs b/cocoa-foundation/src/foundation.rs index 6fcc2a939..760b6b0ff 100644 --- a/cocoa-foundation/src/foundation.rs +++ b/cocoa-foundation/src/foundation.rs @@ -10,8 +10,10 @@ #![allow(non_upper_case_globals)] use crate::base::{id, nil, BOOL, NO, SEL}; +use bitflags::bitflags; use block::Block; use libc; +use objc::{class, msg_send, sel, sel_impl}; use std::os::raw::c_void; use std::ptr; @@ -35,7 +37,7 @@ mod macos { use crate::base::id; use core_graphics_types::base::CGFloat; use core_graphics_types::geometry::CGRect; - use objc; + use objc::{self, class, msg_send, sel, sel_impl}; use std::mem; #[repr(C)] diff --git a/cocoa-foundation/src/lib.rs b/cocoa-foundation/src/lib.rs index 7cd0350f6..cf224b5a4 100644 --- a/cocoa-foundation/src/lib.rs +++ b/cocoa-foundation/src/lib.rs @@ -9,14 +9,5 @@ #![allow(non_snake_case)] -extern crate block; -#[macro_use] -extern crate bitflags; -extern crate core_foundation; -extern crate core_graphics_types; -extern crate libc; -#[macro_use] -extern crate objc; - pub mod base; pub mod foundation; diff --git a/cocoa-foundation/tests/foundation.rs b/cocoa-foundation/tests/foundation.rs index f139b072a..c726cc152 100644 --- a/cocoa-foundation/tests/foundation.rs +++ b/cocoa-foundation/tests/foundation.rs @@ -1,8 +1,3 @@ -#[macro_use] -extern crate objc; -extern crate block; -extern crate cocoa_foundation; - #[cfg(test)] mod foundation { mod nsstring { @@ -66,6 +61,7 @@ mod foundation { mod nsfastenumeration { use cocoa_foundation::base::{id, nil}; use cocoa_foundation::foundation::{NSFastEnumeration, NSString}; + use objc::{msg_send, sel, sel_impl}; use std::slice; use std::str; diff --git a/cocoa/examples/color.rs b/cocoa/examples/color.rs index d44042689..401bdeac7 100644 --- a/cocoa/examples/color.rs +++ b/cocoa/examples/color.rs @@ -1,5 +1,3 @@ -extern crate cocoa; - use cocoa::base::{id, nil, selector, NO}; use cocoa::appkit::{ diff --git a/cocoa/examples/fullscreen.rs b/cocoa/examples/fullscreen.rs index e3772e47b..7571e8d16 100644 --- a/cocoa/examples/fullscreen.rs +++ b/cocoa/examples/fullscreen.rs @@ -1,9 +1,3 @@ -extern crate cocoa; -extern crate core_graphics; - -#[macro_use] -extern crate objc; - use cocoa::appkit::{ NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps, NSApplicationActivationPolicyRegular, NSApplicationPresentationOptions, NSBackingStoreBuffered, @@ -19,6 +13,7 @@ use core_graphics::display::CGDisplay; use objc::declare::ClassDecl; use objc::runtime::{Object, Sel}; +use objc::{class, msg_send, sel, sel_impl}; fn main() { unsafe { diff --git a/cocoa/examples/hello_world.rs b/cocoa/examples/hello_world.rs index 2f1f0273b..2c64a9feb 100644 --- a/cocoa/examples/hello_world.rs +++ b/cocoa/examples/hello_world.rs @@ -1,5 +1,3 @@ -extern crate cocoa; - use cocoa::appkit::{ NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps, NSApplicationActivationPolicyRegular, NSBackingStoreBuffered, NSMenu, NSMenuItem, diff --git a/cocoa/examples/nsvisualeffectview_blur.rs b/cocoa/examples/nsvisualeffectview_blur.rs index b3fb07cdd..994b94f83 100644 --- a/cocoa/examples/nsvisualeffectview_blur.rs +++ b/cocoa/examples/nsvisualeffectview_blur.rs @@ -1,6 +1,3 @@ -extern crate cocoa; -extern crate objc; - use cocoa::base::{nil, selector, NO}; use objc::*; diff --git a/cocoa/examples/tab_view.rs b/cocoa/examples/tab_view.rs index 1b0a6feb5..7e98eb746 100644 --- a/cocoa/examples/tab_view.rs +++ b/cocoa/examples/tab_view.rs @@ -1,5 +1,3 @@ -extern crate cocoa; - use cocoa::base::{id, nil, selector, NO}; use cocoa::appkit::{ diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index 72d8da2d7..98359cb7b 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -13,8 +13,10 @@ use crate::base::{id, BOOL, SEL}; use crate::foundation::{ NSInteger, NSPoint, NSRange, NSRect, NSRectEdge, NSSize, NSTimeInterval, NSUInteger, }; +use bitflags::bitflags; use block::Block; use libc; +use objc::{class, msg_send, sel, sel_impl}; pub use core_graphics::base::CGFloat; pub use core_graphics::geometry::CGPoint; diff --git a/cocoa/src/lib.rs b/cocoa/src/lib.rs index 0d75b7622..1650ae111 100644 --- a/cocoa/src/lib.rs +++ b/cocoa/src/lib.rs @@ -11,17 +11,6 @@ #![crate_type = "rlib"] #![allow(non_snake_case)] -extern crate block; -#[macro_use] -extern crate bitflags; -extern crate cocoa_foundation; -extern crate core_foundation; -extern crate core_graphics; -extern crate foreign_types; -extern crate libc; -#[macro_use] -extern crate objc; - #[cfg(target_os = "macos")] pub mod appkit; pub mod base; diff --git a/cocoa/src/macros.rs b/cocoa/src/macros.rs index 264bead5e..7063da85e 100644 --- a/cocoa/src/macros.rs +++ b/cocoa/src/macros.rs @@ -12,13 +12,12 @@ /// /// # Example with `NSWindowDelegate` /// ``` no_run -/// #[macro_use] extern crate cocoa; -/// #[macro_use] extern crate objc; -/// /// use cocoa::appkit::NSWindow; /// use cocoa::base::{id, nil}; +/// use cocoa::delegate; /// /// use objc::runtime::{Object, Sel}; +/// use objc::{msg_send, sel, sel_impl}; /// /// # fn main() { /// unsafe { @@ -57,7 +56,7 @@ macro_rules! delegate { $( ($($sel:ident :)+) => $func:expr),* } ) => ({ - let mut decl = objc::declare::ClassDecl::new($name, class!(NSObject)).unwrap(); + let mut decl = objc::declare::ClassDecl::new($name, objc::class!(NSObject)).unwrap(); $( decl.add_ivar::<$var_type>(stringify!($var)); diff --git a/cocoa/src/quartzcore.rs b/cocoa/src/quartzcore.rs index 5d7bb9314..649384dc5 100644 --- a/cocoa/src/quartzcore.rs +++ b/cocoa/src/quartzcore.rs @@ -9,6 +9,7 @@ #![allow(non_upper_case_globals)] +use bitflags::bitflags; use core_foundation::array::{CFArray, CFArrayRef}; use core_foundation::base::{CFType, CFTypeRef, TCFType}; use core_foundation::date::CFTimeInterval; @@ -21,6 +22,7 @@ use core_graphics::context::CGContext; use core_graphics::geometry::{CGAffineTransform, CGPoint, CGRect, CGSize}; use core_graphics::path::{CGPath, SysCGPathRef}; use foreign_types::ForeignType; +use objc::{class, msg_send, sel, sel_impl}; use std::ops::Mul; use std::ptr; @@ -1358,6 +1360,7 @@ pub mod transaction { use block::{Block, ConcreteBlock, IntoConcreteBlock, RcBlock}; use core_foundation::date::CFTimeInterval; use core_foundation::string::CFString; + use objc::{class, msg_send, sel, sel_impl}; use crate::base::{id, BOOL, YES}; diff --git a/core-foundation/src/filedescriptor.rs b/core-foundation/src/filedescriptor.rs index 876d1cec0..e3fc61be9 100644 --- a/core-foundation/src/filedescriptor.rs +++ b/core-foundation/src/filedescriptor.rs @@ -97,8 +97,6 @@ impl AsRawFd for CFFileDescriptor { #[cfg(test)] mod test { - extern crate libc; - use super::*; use crate::runloop::CFRunLoop; use core_foundation_sys::base::CFOptionFlags; diff --git a/core-foundation/src/lib.rs b/core-foundation/src/lib.rs index 767d45aad..c58b1098e 100644 --- a/core-foundation/src/lib.rs +++ b/core-foundation/src/lib.rs @@ -15,12 +15,6 @@ //! It also provides a framework for other crates to use when wrapping //! other frameworks that use the CoreFoundation framework. -extern crate core_foundation_sys; -extern crate libc; - -#[cfg(feature = "with-chrono")] -extern crate chrono; - use crate::base::TCFType; pub unsafe trait ConcreteCFType: TCFType {} @@ -32,7 +26,7 @@ pub unsafe trait ConcreteCFType: TCFType {} /// provided using the [`impl_TCFType`] macro. /// /// ``` -/// #[macro_use] extern crate core_foundation; +/// use core_foundation::{declare_TCFType, impl_TCFType}; /// // Make sure that the `TCFType` trait is in scope. /// use core_foundation::base::{CFTypeID, TCFType}; /// diff --git a/core-foundation/src/uuid.rs b/core-foundation/src/uuid.rs index f5146c54e..3ac1cc111 100644 --- a/core-foundation/src/uuid.rs +++ b/core-foundation/src/uuid.rs @@ -9,16 +9,13 @@ //! Core Foundation UUID objects. -#[cfg(feature = "with-uuid")] -extern crate uuid; - use core_foundation_sys::base::kCFAllocatorDefault; pub use core_foundation_sys::uuid::*; use crate::base::TCFType; #[cfg(feature = "with-uuid")] -use self::uuid::Uuid; +use uuid::Uuid; declare_TCFType! { /// A UUID. diff --git a/core-foundation/tests/use_macro_outside_crate.rs b/core-foundation/tests/use_macro_outside_crate.rs index ff1c17d4c..b60b9d0ee 100644 --- a/core-foundation/tests/use_macro_outside_crate.rs +++ b/core-foundation/tests/use_macro_outside_crate.rs @@ -1,7 +1,5 @@ -#[macro_use] -extern crate core_foundation; - use core_foundation::base::{CFComparisonResult, TCFType}; +use core_foundation::{declare_TCFType, impl_CFComparison, impl_CFTypeDescription, impl_TCFType}; use std::os::raw::c_void; // sys equivalent stuff that must be declared diff --git a/core-graphics-types/src/lib.rs b/core-graphics-types/src/lib.rs index 94a4eb979..d9ca4ee22 100644 --- a/core-graphics-types/src/lib.rs +++ b/core-graphics-types/src/lib.rs @@ -7,8 +7,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate core_foundation; -extern crate libc; - pub mod base; pub mod geometry; diff --git a/core-graphics/src/color.rs b/core-graphics/src/color.rs index f19a345a9..dbace27a0 100644 --- a/core-graphics/src/color.rs +++ b/core-graphics/src/color.rs @@ -11,6 +11,7 @@ use super::sys::CGColorRef; use crate::base::CGFloat; use core_foundation::base::CFTypeID; use core_foundation::base::TCFType; +use core_foundation::{declare_TCFType, impl_TCFType}; pub use super::sys::CGColorRef as SysCGColorRef; diff --git a/core-graphics/src/color_space.rs b/core-graphics/src/color_space.rs index 49ac5dc81..47b1ec087 100644 --- a/core-graphics/src/color_space.rs +++ b/core-graphics/src/color_space.rs @@ -9,7 +9,7 @@ use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; use core_foundation::string::CFStringRef; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; foreign_type! { #[doc(hidden)] diff --git a/core-graphics/src/context.rs b/core-graphics/src/context.rs index 9149fec73..db36b5af0 100644 --- a/core-graphics/src/context.rs +++ b/core-graphics/src/context.rs @@ -20,7 +20,7 @@ use std::os::raw::c_void; use crate::geometry::{CGAffineTransform, CGRect}; use crate::image::CGImage; -use foreign_types::{ForeignType, ForeignTypeRef}; +use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; use std::cmp; use std::ptr; use std::slice; diff --git a/core-graphics/src/data_provider.rs b/core-graphics/src/data_provider.rs index 6002659c3..80f092823 100644 --- a/core-graphics/src/data_provider.rs +++ b/core-graphics/src/data_provider.rs @@ -16,7 +16,7 @@ use std::os::raw::c_void; use std::ptr; use std::sync::Arc; -use foreign_types::{ForeignType, ForeignTypeRef}; +use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; pub type CGDataProviderGetBytesCallback = Option size_t>; diff --git a/core-graphics/src/display.rs b/core-graphics/src/display.rs index d2f450f2d..9592dc497 100644 --- a/core-graphics/src/display.rs +++ b/core-graphics/src/display.rs @@ -19,7 +19,7 @@ pub use crate::geometry::{CGPoint, CGRect, CGSize}; use crate::image::CGImage; use core_foundation::base::{CFRetain, TCFType}; use core_foundation::string::{CFString, CFStringRef}; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; pub type CGDirectDisplayID = u32; pub type CGWindowID = u32; diff --git a/core-graphics/src/event.rs b/core-graphics/src/event.rs index 02024de39..c96961826 100644 --- a/core-graphics/src/event.rs +++ b/core-graphics/src/event.rs @@ -1,11 +1,13 @@ #![allow(non_upper_case_globals)] use crate::event_source::CGEventSource; use crate::geometry::CGPoint; + +use bitflags::bitflags; use core_foundation::{ base::{CFRelease, CFRetain, CFTypeID, TCFType}, mach_port::{CFMachPort, CFMachPortRef}, }; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; use libc::c_void; use std::mem::ManuallyDrop; @@ -441,7 +443,6 @@ unsafe extern "C" fn cg_event_tap_callback_internal( } /// ```no_run -///extern crate core_foundation; ///use core_foundation::runloop::{kCFRunLoopCommonModes, CFRunLoop}; ///use core_graphics::event::{CGEventTap, CGEventTapLocation, CGEventTapPlacement, CGEventTapOptions, CGEventType}; ///let current = CFRunLoop::get_current(); diff --git a/core-graphics/src/event_source.rs b/core-graphics/src/event_source.rs index 7ac2c5a23..ed3c65418 100644 --- a/core-graphics/src/event_source.rs +++ b/core-graphics/src/event_source.rs @@ -1,5 +1,5 @@ use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; /// Possible source states of an event source. #[repr(C)] diff --git a/core-graphics/src/font.rs b/core-graphics/src/font.rs index 7e0287740..7cd9b9cc3 100644 --- a/core-graphics/src/font.rs +++ b/core-graphics/src/font.rs @@ -17,7 +17,7 @@ use core_foundation::number::CFNumber; use core_foundation::string::{CFString, CFStringRef}; use std::ptr::NonNull; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; use libc::{c_int, size_t}; diff --git a/core-graphics/src/gradient.rs b/core-graphics/src/gradient.rs index a70fa194f..854bdb0ae 100644 --- a/core-graphics/src/gradient.rs +++ b/core-graphics/src/gradient.rs @@ -13,9 +13,10 @@ use crate::base::CGFloat; use crate::color::CGColor; use crate::color_space::CGColorSpace; +use bitflags::bitflags; use core_foundation::array::{CFArray, CFArrayRef}; use core_foundation::base::{CFRelease, CFRetain, TCFType}; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; use libc::size_t; diff --git a/core-graphics/src/image.rs b/core-graphics/src/image.rs index e684ffb2a..9aca0cbc0 100644 --- a/core-graphics/src/image.rs +++ b/core-graphics/src/image.rs @@ -6,7 +6,7 @@ use crate::data_provider::{CGDataProvider, CGDataProviderRef}; use crate::geometry::CGRect; use core_foundation::base::{CFRetain, CFTypeID}; use core_foundation::data::CFData; -use foreign_types::{ForeignType, ForeignTypeRef}; +use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; use libc::size_t; #[repr(C)] diff --git a/core-graphics/src/lib.rs b/core-graphics/src/lib.rs index 3c1b6443a..0d545d01b 100644 --- a/core-graphics/src/lib.rs +++ b/core-graphics/src/lib.rs @@ -7,19 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate libc; - -#[macro_use] -extern crate core_foundation; - -#[macro_use] -extern crate bitflags; - -#[macro_use] -extern crate foreign_types; - -extern crate core_graphics_types; - #[cfg(target_os = "macos")] pub mod access; pub mod base; diff --git a/core-graphics/src/path.rs b/core-graphics/src/path.rs index 78c2653ba..9a33284c3 100644 --- a/core-graphics/src/path.rs +++ b/core-graphics/src/path.rs @@ -11,7 +11,7 @@ pub use crate::sys::CGPathRef as SysCGPathRef; use crate::geometry::{CGAffineTransform, CGPoint, CGRect}; use core_foundation::base::{CFRelease, CFRetain, CFTypeID}; -use foreign_types::ForeignType; +use foreign_types::{foreign_type, ForeignType}; use libc::c_void; use std::fmt::{self, Debug, Formatter}; use std::marker::PhantomData; diff --git a/core-text/src/font.rs b/core-text/src/font.rs index efe9e321b..cf28ca548 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -23,6 +23,7 @@ use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; use core_foundation::number::CFNumber; use core_foundation::string::{CFString, CFStringRef, UniChar}; use core_foundation::url::{CFURLRef, CFURL}; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::base::CGFloat; use core_graphics::context::CGContext; use core_graphics::font::{CGFont, CGGlyph}; diff --git a/core-text/src/font_collection.rs b/core-text/src/font_collection.rs index 5745721c6..824e6665e 100644 --- a/core-text/src/font_collection.rs +++ b/core-text/src/font_collection.rs @@ -19,6 +19,7 @@ use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; use core_foundation::number::CFNumber; use core_foundation::set::CFSet; use core_foundation::string::{CFString, CFStringRef}; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use std::os::raw::c_void; diff --git a/core-text/src/font_descriptor.rs b/core-text/src/font_descriptor.rs index e5506d216..b0006a5fd 100644 --- a/core-text/src/font_descriptor.rs +++ b/core-text/src/font_descriptor.rs @@ -16,6 +16,7 @@ use core_foundation::number::{CFNumber, CFNumberRef}; use core_foundation::set::CFSetRef; use core_foundation::string::{CFString, CFStringRef}; use core_foundation::url::{CFURLRef, CFURL}; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::base::CGFloat; use std::os::raw::c_void; diff --git a/core-text/src/frame.rs b/core-text/src/frame.rs index eebaaa1d0..09687f639 100644 --- a/core-text/src/frame.rs +++ b/core-text/src/frame.rs @@ -10,6 +10,7 @@ use crate::line::CTLine; use core_foundation::array::{CFArray, CFArrayRef}; use core_foundation::base::{CFRange, CFTypeID, TCFType}; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::context::{CGContext, CGContextRef}; use core_graphics::geometry::CGPoint; use core_graphics::path::{CGPath, SysCGPathRef}; diff --git a/core-text/src/framesetter.rs b/core-text/src/framesetter.rs index abdd3eb37..ac83a319f 100644 --- a/core-text/src/framesetter.rs +++ b/core-text/src/framesetter.rs @@ -11,6 +11,7 @@ use super::frame::{CTFrame, CTFrameRef}; use core_foundation::attributed_string::CFAttributedStringRef; use core_foundation::base::{CFRange, CFTypeID, TCFType}; use core_foundation::dictionary::CFDictionaryRef; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::geometry::CGSize; use core_graphics::path::{CGPath, CGPathRef}; use foreign_types::{ForeignType, ForeignTypeRef}; diff --git a/core-text/src/lib.rs b/core-text/src/lib.rs index be394b020..8311c8b38 100644 --- a/core-text/src/lib.rs +++ b/core-text/src/lib.rs @@ -16,13 +16,6 @@ Many of these functions will add objects to the autorelease pool. If you don't have one this will cause leaks. */ -extern crate foreign_types; -extern crate libc; - -#[macro_use] -extern crate core_foundation; -extern crate core_graphics; - pub mod font; pub mod font_collection; pub mod font_descriptor; diff --git a/core-text/src/line.rs b/core-text/src/line.rs index 09d34fd35..c250924f5 100644 --- a/core-text/src/line.rs +++ b/core-text/src/line.rs @@ -11,6 +11,7 @@ use crate::run::CTRun; use core_foundation::array::{CFArray, CFArrayRef}; use core_foundation::attributed_string::CFAttributedStringRef; use core_foundation::base::{CFIndex, CFRange, CFTypeID, TCFType}; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::base::CGFloat; use core_graphics::context::CGContext; use core_graphics::geometry::{CGPoint, CGRect}; diff --git a/core-text/src/run.rs b/core-text/src/run.rs index e03065a1f..c20db2a1d 100644 --- a/core-text/src/run.rs +++ b/core-text/src/run.rs @@ -10,6 +10,7 @@ use core_foundation::base::{CFIndex, CFRange, CFType, CFTypeID, TCFType}; use core_foundation::dictionary::{CFDictionary, CFDictionaryRef}; use core_foundation::string::CFString; +use core_foundation::{declare_TCFType, impl_CFTypeDescription, impl_TCFType}; use core_graphics::font::CGGlyph; use core_graphics::geometry::CGPoint; use std::borrow::Cow; diff --git a/io-surface/src/lib.rs b/io-surface/src/lib.rs index 184655beb..7dad15981 100644 --- a/io-surface/src/lib.rs +++ b/io-surface/src/lib.rs @@ -10,12 +10,6 @@ #![crate_name = "io_surface"] #![crate_type = "rlib"] -extern crate cgl; -extern crate core_foundation; -extern crate core_foundation_sys; -extern crate leaky_cow; -extern crate libc; - // Rust bindings to the IOSurface framework on macOS. use cgl::{kCGLNoError, CGLErrorString, CGLGetCurrentContext, CGLTexImageIOSurface2D, GLenum};