use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[cfg(feature = "AEDataModel")]
pub const keyDirectObject: AEKeyword = 0x2d2d2d2d;
#[cfg(feature = "AEDataModel")]
pub const keyErrorNumber: AEKeyword = 0x6572726e;
#[cfg(feature = "AEDataModel")]
pub const keyErrorString: AEKeyword = 0x65727273;
#[cfg(feature = "AEDataModel")]
pub const keyProcessSerialNumber: AEKeyword = 0x70736e20;
#[cfg(feature = "AEDataModel")]
pub const keyPreDispatch: AEKeyword = 0x70686163;
#[cfg(feature = "AEDataModel")]
pub const keySelectProc: AEKeyword = 0x73656c68;
#[cfg(feature = "AEDataModel")]
pub const keyAERecorderCount: AEKeyword = 0x72656372;
#[cfg(feature = "AEDataModel")]
pub const keyAEVersion: AEKeyword = 0x76657273;
#[cfg(feature = "AEDataModel")]
pub const kAEApplicationActivationExpected: AEKeyword = 0x61617064;
#[cfg(feature = "AEDataModel")]
pub const kCoreEventClass: DescType = 0x61657674;
#[cfg(feature = "AEDataModel")]
pub const kAEOpenApplication: AEEventID = 0x6f617070;
#[cfg(feature = "AEDataModel")]
pub const kAEOpenDocuments: AEEventID = 0x6f646f63;
#[cfg(feature = "AEDataModel")]
pub const kAEPrintDocuments: AEEventID = 0x70646f63;
#[cfg(feature = "AEDataModel")]
pub const kAEOpenContents: AEEventID = 0x6f636f6e;
#[cfg(feature = "AEDataModel")]
pub const kAEQuitApplication: AEEventID = 0x71756974;
#[cfg(feature = "AEDataModel")]
pub const kAEAnswer: AEEventID = 0x616e7372;
#[cfg(feature = "AEDataModel")]
pub const kAEApplicationDied: AEEventID = 0x6f626974;
#[cfg(feature = "AEDataModel")]
pub const kAEShowPreferences: AEEventID = 0x70726566;
#[cfg(feature = "AEDataModel")]
pub const keyAERestoreAppState: DescType = 0x7273746f;
#[cfg(feature = "AEDataModel")]
pub const kAEStartRecording: AEEventID = 0x72656361;
#[cfg(feature = "AEDataModel")]
pub const kAEStopRecording: AEEventID = 0x72656363;
#[cfg(feature = "AEDataModel")]
pub const kAENotifyStartRecording: AEEventID = 0x72656331;
#[cfg(feature = "AEDataModel")]
pub const kAENotifyStopRecording: AEEventID = 0x72656330;
#[cfg(feature = "AEDataModel")]
pub const kAENotifyRecording: AEEventID = 0x72656372;
pub type AEEventSource = i8;
pub const kAEUnknownSource: c_uint = 0;
pub const kAEDirectCall: c_uint = 1;
pub const kAESameProcess: c_uint = 2;
pub const kAELocalProcess: c_uint = 3;
pub const kAERemoteProcess: c_uint = 4;
pub const errAETargetAddressNotPermitted: c_int = -1742;
pub const errAEEventNotPermitted: c_int = -1743;
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AEInstallEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: AEEventHandlerUPP,
handler_refcon: SRefCon,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AEInstallEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: AEEventHandlerUPP,
handler_refcon: SRefCon,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe {
AEInstallEventHandler(
the_ae_event_class,
the_ae_event_id,
handler,
handler_refcon,
is_sys_handler as _,
)
}
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AERemoveEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: AEEventHandlerUPP,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AERemoveEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: AEEventHandlerUPP,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe {
AERemoveEventHandler(
the_ae_event_class,
the_ae_event_id,
handler,
is_sys_handler as _,
)
}
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AEGetEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: *mut AEEventHandlerUPP,
handler_refcon: *mut SRefCon,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AEGetEventHandler(
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
handler: *mut AEEventHandlerUPP,
handler_refcon: *mut SRefCon,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe {
AEGetEventHandler(
the_ae_event_class,
the_ae_event_id,
handler,
handler_refcon,
is_sys_handler as _,
)
}
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AEInstallSpecialHandler(
function_class: AEKeyword,
handler: AEEventHandlerUPP,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AEInstallSpecialHandler(
function_class: AEKeyword,
handler: AEEventHandlerUPP,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe { AEInstallSpecialHandler(function_class, handler, is_sys_handler as _) }
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AERemoveSpecialHandler(
function_class: AEKeyword,
handler: AEEventHandlerUPP,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AERemoveSpecialHandler(
function_class: AEKeyword,
handler: AEEventHandlerUPP,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe { AERemoveSpecialHandler(function_class, handler, is_sys_handler as _) }
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AEGetSpecialHandler(
function_class: AEKeyword,
handler: *mut AEEventHandlerUPP,
is_sys_handler: bool,
) -> OSErr {
extern "C-unwind" {
fn AEGetSpecialHandler(
function_class: AEKeyword,
handler: *mut AEEventHandlerUPP,
is_sys_handler: Boolean,
) -> OSErr;
}
unsafe { AEGetSpecialHandler(function_class, handler, is_sys_handler as _) }
}
extern "C-unwind" {
#[cfg(feature = "AEDataModel")]
pub fn AEManagerInfo(key_word: AEKeyword, result: *mut c_long) -> OSErr;
}
extern "C" {
pub static kAERemoteProcessURLKey: Option<&'static CFString>;
}
extern "C" {
pub static kAERemoteProcessNameKey: Option<&'static CFString>;
}
extern "C" {
pub static kAERemoteProcessUserIDKey: Option<&'static CFString>;
}
extern "C" {
pub static kAERemoteProcessProcessIDKey: Option<&'static CFString>;
}
#[repr(C, packed(2))]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct AERemoteProcessResolverContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: CFAllocatorRetainCallBack,
pub release: CFAllocatorReleaseCallBack,
pub copyDescription: CFAllocatorCopyDescriptionCallBack,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for AERemoteProcessResolverContext {
const ENCODING: Encoding = Encoding::Struct(
"AERemoteProcessResolverContext",
&[
<CFIndex>::ENCODING,
<*mut c_void>::ENCODING,
<CFAllocatorRetainCallBack>::ENCODING,
<CFAllocatorReleaseCallBack>::ENCODING,
<CFAllocatorCopyDescriptionCallBack>::ENCODING,
],
);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for AERemoteProcessResolverContext {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(C)]
#[derive(Debug)]
pub struct AERemoteProcessResolver {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for AERemoteProcessResolver {
const ENCODING_REF: Encoding =
Encoding::Pointer(&Encoding::Struct("AERemoteProcessResolver", &[]));
}
pub type AERemoteProcessResolverRef = *mut AERemoteProcessResolver;
extern "C-unwind" {
pub fn AECreateRemoteProcessResolver(
allocator: Option<&CFAllocator>,
url: Option<&CFURL>,
) -> AERemoteProcessResolverRef;
}
extern "C-unwind" {
pub fn AEDisposeRemoteProcessResolver(r#ref: AERemoteProcessResolverRef);
}
impl AERemoteProcessResolver {
#[doc(alias = "AERemoteProcessResolverGetProcesses")]
#[inline]
pub unsafe fn processes(
r#ref: AERemoteProcessResolverRef,
out_error: *mut CFStreamError,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn AERemoteProcessResolverGetProcesses(
r#ref: AERemoteProcessResolverRef,
out_error: *mut CFStreamError,
) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { AERemoteProcessResolverGetProcesses(r#ref, out_error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
}
pub type AERemoteProcessResolverCallback =
Option<unsafe extern "C-unwind" fn(AERemoteProcessResolverRef, *mut c_void)>;
impl AERemoteProcessResolver {
#[doc(alias = "AERemoteProcessResolverScheduleWithRunLoop")]
#[inline]
pub unsafe fn schedule_with_run_loop(
r#ref: AERemoteProcessResolverRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
callback: AERemoteProcessResolverCallback,
ctx: *const AERemoteProcessResolverContext,
) {
extern "C-unwind" {
fn AERemoteProcessResolverScheduleWithRunLoop(
r#ref: AERemoteProcessResolverRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
callback: AERemoteProcessResolverCallback,
ctx: *const AERemoteProcessResolverContext,
);
}
unsafe {
AERemoteProcessResolverScheduleWithRunLoop(
r#ref,
run_loop,
run_loop_mode,
callback,
ctx,
)
}
}
}
#[cfg(feature = "AEDataModel")]
#[inline]
pub unsafe extern "C-unwind" fn AEDeterminePermissionToAutomateTarget(
target: *const AEAddressDesc,
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
ask_user_if_needed: bool,
) -> OSStatus {
extern "C-unwind" {
fn AEDeterminePermissionToAutomateTarget(
target: *const AEAddressDesc,
the_ae_event_class: AEEventClass,
the_ae_event_id: AEEventID,
ask_user_if_needed: Boolean,
) -> OSStatus;
}
unsafe {
AEDeterminePermissionToAutomateTarget(
target,
the_ae_event_class,
the_ae_event_id,
ask_user_if_needed as _,
)
}
}
pub const errAEEventWouldRequireUserConsent: c_int = -1744;
pub const kAEDoNotPromptForUserConsent: c_uint = 0x00020000;
#[deprecated = "renamed to `AERemoteProcessResolver::processes`"]
#[inline]
pub unsafe extern "C-unwind" fn AERemoteProcessResolverGetProcesses(
r#ref: AERemoteProcessResolverRef,
out_error: *mut CFStreamError,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn AERemoteProcessResolverGetProcesses(
r#ref: AERemoteProcessResolverRef,
out_error: *mut CFStreamError,
) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { AERemoteProcessResolverGetProcesses(r#ref, out_error) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
extern "C-unwind" {
#[deprecated = "renamed to `AERemoteProcessResolver::schedule_with_run_loop`"]
pub fn AERemoteProcessResolverScheduleWithRunLoop(
r#ref: AERemoteProcessResolverRef,
run_loop: Option<&CFRunLoop>,
run_loop_mode: Option<&CFString>,
callback: AERemoteProcessResolverCallback,
ctx: *const AERemoteProcessResolverContext,
);
}