Skip to content

Commit

Permalink
Remove usages of extern crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Apr 27, 2024
1 parent 199badc commit 1408a8e
Show file tree
Hide file tree
Showing 38 changed files with 37 additions and 101 deletions.
4 changes: 3 additions & 1 deletion cocoa-foundation/src/foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)]
Expand Down
9 changes: 0 additions & 9 deletions cocoa-foundation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 1 addition & 5 deletions cocoa-foundation/tests/foundation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#[macro_use]
extern crate objc;
extern crate block;
extern crate cocoa_foundation;

#[cfg(test)]
mod foundation {
mod nsstring {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions cocoa/examples/color.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate cocoa;

use cocoa::base::{id, nil, selector, NO};

use cocoa::appkit::{
Expand Down
7 changes: 1 addition & 6 deletions cocoa/examples/fullscreen.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions cocoa/examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate cocoa;

use cocoa::appkit::{
NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps,
NSApplicationActivationPolicyRegular, NSBackingStoreBuffered, NSMenu, NSMenuItem,
Expand Down
3 changes: 0 additions & 3 deletions cocoa/examples/nsvisualeffectview_blur.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate cocoa;
extern crate objc;

use cocoa::base::{nil, selector, NO};
use objc::*;

Expand Down
2 changes: 0 additions & 2 deletions cocoa/examples/tab_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate cocoa;

use cocoa::base::{id, nil, selector, NO};

use cocoa::appkit::{
Expand Down
2 changes: 2 additions & 0 deletions cocoa/src/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 0 additions & 11 deletions cocoa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions cocoa/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions cocoa/src/quartzcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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};

Expand Down
2 changes: 0 additions & 2 deletions core-foundation/src/filedescriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions core-foundation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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};
///
Expand Down
5 changes: 1 addition & 4 deletions core-foundation/src/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions core-foundation/tests/use_macro_outside_crate.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions core-graphics-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions core-graphics/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/color_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsafe extern "C" fn(*mut c_void, *mut c_void, size_t) -> size_t>;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions core-graphics/src/event.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/event_source.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 2 additions & 1 deletion core-graphics/src/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
13 changes: 0 additions & 13 deletions core-graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core-graphics/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions core-text/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions core-text/src/font_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions core-text/src/font_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 1408a8e

Please sign in to comment.