objc2_core_services/
lib.rs

1//! # Bindings to the `CoreServices` framework
2//!
3//! See [Apple's docs][apple-doc] and [the general docs on framework crates][framework-crates] for more information.
4//!
5//! [apple-doc]: https://developer.apple.com/documentation/coreservices/
6//! [framework-crates]: https://docs.rs/objc2/latest/objc2/topics/about_generated/index.html
7#![no_std]
8#![cfg_attr(feature = "unstable-darwin-objc", feature(darwin_objc))]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10// Update in Cargo.toml as well.
11#![doc(html_root_url = "https://docs.rs/objc2-core-services/0.2.2")]
12// We ignore everything that depends on CarbonCore for now.
13#![allow(unexpected_cfgs)]
14
15#[cfg(feature = "alloc")]
16extern crate alloc;
17
18#[cfg(feature = "std")]
19extern crate std;
20
21#[cfg(all(feature = "CarbonCore", feature = "Files"))]
22mod files;
23mod generated;
24
25#[cfg(all(feature = "CarbonCore", feature = "Files"))]
26pub use self::files::*;
27#[allow(unused_imports, unreachable_pub)]
28pub use self::generated::*;
29
30#[cfg(feature = "FSEvents")]
31pub type ConstFSEventStreamRef = *const __FSEventStream;
32
33#[allow(non_upper_case_globals)]
34#[cfg(feature = "FSEvents")]
35/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventidsincenow?language=objc)
36pub const kFSEventStreamEventIdSinceNow: FSEventStreamEventId = 0xFFFFFFFFFFFFFFFF;
37
38// MacTypes.h
39#[allow(dead_code)]
40mod mac_types {
41    #[cfg(feature = "objc2")]
42    use objc2::encode::{Encode, Encoding, RefEncode};
43
44    pub(crate) type Fract = i32;
45
46    #[repr(C)]
47    #[derive(Clone, Copy, Debug, PartialEq)]
48    pub(crate) struct Float80 {
49        exp: i16,
50        man: [i16; 4],
51    }
52
53    #[cfg(feature = "objc2")]
54    unsafe impl Encode for Float80 {
55        const ENCODING: Encoding =
56            Encoding::Struct("Float80", &[<i16>::ENCODING, <[i16; 4]>::ENCODING]);
57    }
58
59    #[cfg(feature = "objc2")]
60    unsafe impl RefEncode for Float80 {
61        const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62    }
63
64    pub(crate) type Ptr = *mut core::ffi::c_char;
65    pub(crate) type Handle = *mut Ptr;
66    pub(crate) type Size = core::ffi::c_long;
67
68    pub(crate) type OSErr = i16;
69    pub(crate) type OSStatus = i32;
70    pub(crate) type LogicalAddress = *mut core::ffi::c_void;
71    pub(crate) type ConstLogicalAddress = *const core::ffi::c_void;
72    pub(crate) type PhysicalAddress = *mut core::ffi::c_void;
73    pub(crate) type BytePtr = *mut u8;
74    pub(crate) type ByteCount = core::ffi::c_ulong;
75    pub(crate) type ByteOffset = core::ffi::c_ulong;
76    pub(crate) type Duration = i32;
77    pub(crate) type AbsoluteTime = i32;
78    pub(crate) type OptionBits = u32;
79    pub(crate) type ItemCount = core::ffi::c_ulong;
80    pub(crate) type PBVersion = u32;
81    pub(crate) type ScriptCode = i16;
82    pub(crate) type LangCode = i16;
83    pub(crate) type RegionCode = i16;
84    pub(crate) type FourCharCode = u32;
85    pub(crate) type OSType = FourCharCode;
86    pub(crate) type ResType = FourCharCode;
87    pub(crate) type OSTypePtr = *mut OSType;
88    pub(crate) type ResTypePtr = *mut ResType;
89
90    pub(crate) type Boolean = u8;
91
92    #[cfg(target_pointer_width = "64")]
93    pub(crate) type URefCon = *mut core::ffi::c_void;
94    #[cfg(target_pointer_width = "64")]
95    pub(crate) type SRefCon = *mut core::ffi::c_void;
96    #[cfg(target_pointer_width = "32")]
97    pub(crate) type URefCon = u32;
98    #[cfg(target_pointer_width = "32")]
99    pub(crate) type SRefCon = i32;
100
101    #[allow(non_camel_case_types)]
102    pub(crate) type extended80 = Float80;
103
104    pub(crate) type UniChar = u16;
105    pub(crate) type UniCharCount = core::ffi::c_ulong;
106    pub(crate) type ConstStr255Param = *const core::ffi::c_char;
107    pub(crate) type StringPtr = *mut core::ffi::c_char;
108    pub(crate) type ConstStringPtr = *const core::ffi::c_char;
109    pub(crate) type Str255 = [core::ffi::c_uchar; 255];
110    pub(crate) type Str63 = [core::ffi::c_uchar; 64];
111    pub(crate) type Str32 = [core::ffi::c_uchar; 33];
112    pub(crate) type Str31 = [core::ffi::c_uchar; 32];
113    pub(crate) type Str27 = [core::ffi::c_uchar; 28];
114    pub(crate) type Str15 = [core::ffi::c_uchar; 16];
115    pub(crate) type Str32Field = [core::ffi::c_uchar; 34];
116
117    pub(crate) type SignedByte = i8;
118}
119
120#[allow(unused_imports)]
121pub(crate) use self::mac_types::*;