objc2-foundation 0.3.2

Bindings to the Foundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowsntoperatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSWindowsNTOperatingSystem: c_uint = 1;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindows95operatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSWindows95OperatingSystem: c_uint = 2;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssolarisoperatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSSolarisOperatingSystem: c_uint = 3;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshpuxoperatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSHPUXOperatingSystem: c_uint = 4;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmachoperatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSMACHOperatingSystem: c_uint = 5;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssunosoperatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSSunOSOperatingSystem: c_uint = 6;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsosf1operatingsystem?language=objc)
#[deprecated = "Not supported"]
pub const NSOSF1OperatingSystem: c_uint = 7;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsoperatingsystemversion?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NSOperatingSystemVersion {
    pub majorVersion: NSInteger,
    pub minorVersion: NSInteger,
    pub patchVersion: NSInteger,
}

unsafe impl Encode for NSOperatingSystemVersion {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <NSInteger>::ENCODING,
            <NSInteger>::ENCODING,
            <NSInteger>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for NSOperatingSystemVersion {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

unsafe impl Send for NSOperatingSystemVersion {}

unsafe impl Sync for NSOperatingSystemVersion {}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfo?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(PartialEq, Eq, Hash)]
    pub struct NSProcessInfo;
);

unsafe impl Send for NSProcessInfo {}

unsafe impl Sync for NSProcessInfo {}

extern_conformance!(
    unsafe impl NSObjectProtocol for NSProcessInfo {}
);

impl NSProcessInfo {
    extern_methods!(
        #[unsafe(method(processInfo))]
        #[unsafe(method_family = none)]
        pub fn processInfo() -> Retained<NSProcessInfo>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(environment))]
        #[unsafe(method_family = none)]
        pub fn environment(&self) -> Retained<NSDictionary<NSString, NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(arguments))]
        #[unsafe(method_family = none)]
        pub fn arguments(&self) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(hostName))]
        #[unsafe(method_family = none)]
        pub fn hostName(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(processName))]
        #[unsafe(method_family = none)]
        pub fn processName(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        /// Setter for [`processName`][Self::processName].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setProcessName:))]
        #[unsafe(method_family = none)]
        pub fn setProcessName(&self, process_name: &NSString);

        #[unsafe(method(processIdentifier))]
        #[unsafe(method_family = none)]
        pub fn processIdentifier(&self) -> c_int;

        #[cfg(feature = "NSString")]
        #[unsafe(method(globallyUniqueString))]
        #[unsafe(method_family = none)]
        pub fn globallyUniqueString(&self) -> Retained<NSString>;

        #[deprecated = "-operatingSystem always returns NSMACHOperatingSystem, use -operatingSystemVersion or -isOperatingSystemAtLeastVersion: instead"]
        #[unsafe(method(operatingSystem))]
        #[unsafe(method_family = none)]
        pub fn operatingSystem(&self) -> NSUInteger;

        #[cfg(feature = "NSString")]
        #[deprecated = "-operatingSystemName always returns NSMACHOperatingSystem, use -operatingSystemVersionString instead"]
        #[unsafe(method(operatingSystemName))]
        #[unsafe(method_family = none)]
        pub fn operatingSystemName(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(operatingSystemVersionString))]
        #[unsafe(method_family = none)]
        pub fn operatingSystemVersionString(&self) -> Retained<NSString>;

        #[unsafe(method(operatingSystemVersion))]
        #[unsafe(method_family = none)]
        pub fn operatingSystemVersion(&self) -> NSOperatingSystemVersion;

        #[unsafe(method(processorCount))]
        #[unsafe(method_family = none)]
        pub fn processorCount(&self) -> NSUInteger;

        #[unsafe(method(activeProcessorCount))]
        #[unsafe(method_family = none)]
        pub fn activeProcessorCount(&self) -> NSUInteger;

        #[unsafe(method(physicalMemory))]
        #[unsafe(method_family = none)]
        pub fn physicalMemory(&self) -> c_ulonglong;

        #[unsafe(method(isOperatingSystemAtLeastVersion:))]
        #[unsafe(method_family = none)]
        pub fn isOperatingSystemAtLeastVersion(&self, version: NSOperatingSystemVersion) -> bool;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(systemUptime))]
        #[unsafe(method_family = none)]
        pub fn systemUptime(&self) -> NSTimeInterval;

        #[unsafe(method(disableSuddenTermination))]
        #[unsafe(method_family = none)]
        pub fn disableSuddenTermination(&self);

        #[unsafe(method(enableSuddenTermination))]
        #[unsafe(method_family = none)]
        pub fn enableSuddenTermination(&self);

        #[cfg(feature = "NSString")]
        #[unsafe(method(disableAutomaticTermination:))]
        #[unsafe(method_family = none)]
        pub fn disableAutomaticTermination(&self, reason: &NSString);

        #[cfg(feature = "NSString")]
        #[unsafe(method(enableAutomaticTermination:))]
        #[unsafe(method_family = none)]
        pub fn enableAutomaticTermination(&self, reason: &NSString);

        #[unsafe(method(automaticTerminationSupportEnabled))]
        #[unsafe(method_family = none)]
        pub fn automaticTerminationSupportEnabled(&self) -> bool;

        /// Setter for [`automaticTerminationSupportEnabled`][Self::automaticTerminationSupportEnabled].
        #[unsafe(method(setAutomaticTerminationSupportEnabled:))]
        #[unsafe(method_family = none)]
        pub fn setAutomaticTerminationSupportEnabled(
            &self,
            automatic_termination_support_enabled: bool,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl NSProcessInfo {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSProcessInfo {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsactivityoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSActivityOptions(pub u64);
bitflags::bitflags! {
    impl NSActivityOptions: u64 {
        #[doc(alias = "NSActivityIdleDisplaySleepDisabled")]
        const IdleDisplaySleepDisabled = 1<<40;
        #[doc(alias = "NSActivityIdleSystemSleepDisabled")]
        const IdleSystemSleepDisabled = 1<<20;
        #[doc(alias = "NSActivitySuddenTerminationDisabled")]
        const SuddenTerminationDisabled = 1<<14;
        #[doc(alias = "NSActivityAutomaticTerminationDisabled")]
        const AutomaticTerminationDisabled = 1<<15;
        #[doc(alias = "NSActivityAnimationTrackingEnabled")]
        const AnimationTrackingEnabled = 1<<45;
        #[doc(alias = "NSActivityTrackingEnabled")]
        const TrackingEnabled = 1<<46;
        #[doc(alias = "NSActivityUserInitiated")]
        const UserInitiated = 0x00FFFFFF|NSActivityOptions::IdleSystemSleepDisabled.0;
        #[doc(alias = "NSActivityUserInitiatedAllowingIdleSystemSleep")]
        const UserInitiatedAllowingIdleSystemSleep = NSActivityOptions::UserInitiated.0&!NSActivityOptions::IdleSystemSleepDisabled.0;
        #[doc(alias = "NSActivityBackground")]
        const Background = 0x000000FF;
        #[doc(alias = "NSActivityLatencyCritical")]
        const LatencyCritical = 0xFF00000000;
        #[doc(alias = "NSActivityUserInteractive")]
        const UserInteractive = NSActivityOptions::UserInitiated.0|NSActivityOptions::LatencyCritical.0;
    }
}

unsafe impl Encode for NSActivityOptions {
    const ENCODING: Encoding = u64::ENCODING;
}

unsafe impl RefEncode for NSActivityOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// NSProcessInfoActivity.
impl NSProcessInfo {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(beginActivityWithOptions:reason:))]
        #[unsafe(method_family = none)]
        pub fn beginActivityWithOptions_reason(
            &self,
            options: NSActivityOptions,
            reason: &NSString,
        ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;

        /// # Safety
        ///
        /// `activity` should be of the correct type.
        #[unsafe(method(endActivity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn endActivity(&self, activity: &ProtocolObject<dyn NSObjectProtocol>);

        #[cfg(all(feature = "NSString", feature = "block2"))]
        #[unsafe(method(performActivityWithOptions:reason:usingBlock:))]
        #[unsafe(method_family = none)]
        pub fn performActivityWithOptions_reason_usingBlock(
            &self,
            options: NSActivityOptions,
            reason: &NSString,
            block: &block2::DynBlock<dyn Fn()>,
        );

        #[cfg(all(feature = "NSString", feature = "block2"))]
        /// # Safety
        ///
        /// `block` block must be sendable.
        #[unsafe(method(performExpiringActivityWithReason:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn performExpiringActivityWithReason_usingBlock(
            &self,
            reason: &NSString,
            block: &block2::DynBlock<dyn Fn(Bool)>,
        );
    );
}

/// NSUserInformation.
impl NSProcessInfo {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(userName))]
        #[unsafe(method_family = none)]
        pub fn userName(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(fullUserName))]
        #[unsafe(method_family = none)]
        pub fn fullUserName(&self) -> Retained<NSString>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfothermalstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSProcessInfoThermalState(pub NSInteger);
impl NSProcessInfoThermalState {
    #[doc(alias = "NSProcessInfoThermalStateNominal")]
    pub const Nominal: Self = Self(0);
    #[doc(alias = "NSProcessInfoThermalStateFair")]
    pub const Fair: Self = Self(1);
    #[doc(alias = "NSProcessInfoThermalStateSerious")]
    pub const Serious: Self = Self(2);
    #[doc(alias = "NSProcessInfoThermalStateCritical")]
    pub const Critical: Self = Self(3);
}

unsafe impl Encode for NSProcessInfoThermalState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSProcessInfoThermalState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// NSProcessInfoThermalState.
impl NSProcessInfo {
    extern_methods!(
        #[unsafe(method(thermalState))]
        #[unsafe(method_family = none)]
        pub fn thermalState(&self) -> NSProcessInfoThermalState;
    );
}

/// NSProcessInfoPowerState.
impl NSProcessInfo {
    extern_methods!(
        #[unsafe(method(isLowPowerModeEnabled))]
        #[unsafe(method_family = none)]
        pub fn isLowPowerModeEnabled(&self) -> bool;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfothermalstatedidchangenotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSProcessInfoThermalStateDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfopowerstatedidchangenotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSProcessInfoPowerStateDidChangeNotification: &'static NSNotificationName;
}

/// NSProcessInfoPlatform.
impl NSProcessInfo {
    extern_methods!(
        #[unsafe(method(isMacCatalystApp))]
        #[unsafe(method_family = none)]
        pub fn isMacCatalystApp(&self) -> bool;

        #[unsafe(method(isiOSAppOnMac))]
        #[unsafe(method_family = none)]
        pub fn isiOSAppOnMac(&self) -> bool;
    );
}