objc2_application_services/
lib.rs

1//! # Bindings to the `ApplicationServices` 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/applicationservices/
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-application-services/0.3.2")]
12
13#[cfg(feature = "alloc")]
14extern crate alloc;
15
16#[cfg(feature = "std")]
17extern crate std;
18
19mod generated;
20#[allow(unused_imports, unreachable_pub)]
21pub use self::generated::*;
22
23// MacTypes.h
24#[allow(dead_code)]
25mod mac_types {
26    #[cfg(feature = "objc2")]
27    use objc2::encode::{Encode, Encoding, RefEncode};
28
29    pub(crate) type OSStatus = u32;
30    pub(crate) type Boolean = u8;
31    pub(crate) type FourCharCode = u32;
32    pub(crate) type OSType = FourCharCode;
33    pub(crate) type ResType = FourCharCode;
34    pub(crate) type OptionBits = u32;
35
36    pub(crate) type Ptr = *mut core::ffi::c_char;
37    pub(crate) type Handle = *mut Ptr;
38
39    pub(crate) type OSErr = i16;
40    pub(crate) type ItemCount = core::ffi::c_ulong;
41
42    pub(crate) type StringPtr = *mut core::ffi::c_char;
43    pub(crate) type ConstStr255Param = *const core::ffi::c_char;
44    pub(crate) type Str255 = [core::ffi::c_uchar; 255];
45    pub(crate) type Str63 = [core::ffi::c_uchar; 64];
46    pub(crate) type Str32 = [core::ffi::c_uchar; 33];
47    pub(crate) type Str31 = [core::ffi::c_uchar; 32];
48
49    pub(crate) type Style = core::ffi::c_uchar;
50
51    #[repr(C)]
52    #[derive(Clone, Copy, Debug, PartialEq)]
53    #[allow(unreachable_pub)] // Intentionally don't make this truly public
54    pub struct ProcessSerialNumber {
55        high_long_of_psn: u32,
56        low_long_of_psn: u32,
57    }
58
59    #[cfg(feature = "objc2")]
60    unsafe impl Encode for ProcessSerialNumber {
61        const ENCODING: Encoding =
62            Encoding::Struct("ProcessSerialNumber", &[<u32>::ENCODING, <u32>::ENCODING]);
63    }
64
65    #[cfg(feature = "objc2")]
66    unsafe impl RefEncode for ProcessSerialNumber {
67        const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68    }
69
70    #[repr(C)]
71    #[derive(Clone, Copy, Debug, PartialEq)]
72    #[allow(unreachable_pub)] // Intentionally don't make this truly public
73    pub struct Point {
74        v: core::ffi::c_short,
75        h: core::ffi::c_short,
76    }
77
78    #[cfg(feature = "objc2")]
79    unsafe impl Encode for Point {
80        const ENCODING: Encoding = Encoding::Struct(
81            "Point",
82            &[
83                <core::ffi::c_short>::ENCODING,
84                <core::ffi::c_short>::ENCODING,
85            ],
86        );
87    }
88
89    #[cfg(feature = "objc2")]
90    unsafe impl RefEncode for Point {
91        const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92    }
93}
94
95#[allow(unused_imports)]
96pub(crate) use self::mac_types::*;