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::*;
#[doc(alias = "PasteboardRef")]
#[repr(C)]
pub struct Pasteboard {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl Pasteboard {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaquePasteboardRef"> for Pasteboard {}
);
pub type PasteboardItemID = *mut c_void;
pub const badPasteboardSyncErr: c_int = -25130;
pub const badPasteboardIndexErr: c_int = -25131;
pub const badPasteboardItemErr: c_int = -25132;
pub const badPasteboardFlavorErr: c_int = -25133;
pub const duplicatePasteboardFlavorErr: c_int = -25134;
pub const notPasteboardOwnerErr: c_int = -25135;
pub const noPasteboardPromiseKeeperErr: c_int = -25136;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PasteboardSyncFlags(pub OptionBits);
bitflags::bitflags! {
impl PasteboardSyncFlags: OptionBits {
#[doc(alias = "kPasteboardModified")]
const Modified = 1<<0;
#[doc(alias = "kPasteboardClientIsOwner")]
const ClientIsOwner = 1<<1;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for PasteboardSyncFlags {
const ENCODING: Encoding = OptionBits::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for PasteboardSyncFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PasteboardFlavorFlags(pub OptionBits);
bitflags::bitflags! {
impl PasteboardFlavorFlags: OptionBits {
#[doc(alias = "kPasteboardFlavorNoFlags")]
const NoFlags = 0;
#[doc(alias = "kPasteboardFlavorSenderOnly")]
const SenderOnly = 1<<0;
#[doc(alias = "kPasteboardFlavorSenderTranslated")]
const SenderTranslated = 1<<1;
#[doc(alias = "kPasteboardFlavorNotSaved")]
const NotSaved = 1<<2;
#[doc(alias = "kPasteboardFlavorRequestOnly")]
const RequestOnly = 1<<3;
#[doc(alias = "kPasteboardFlavorSystemTranslated")]
const SystemTranslated = 1<<8;
#[doc(alias = "kPasteboardFlavorPromised")]
const Promised = 1<<9;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for PasteboardFlavorFlags {
const ENCODING: Encoding = OptionBits::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for PasteboardFlavorFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PasteboardStandardLocation(pub OSType);
impl PasteboardStandardLocation {
#[doc(alias = "kPasteboardStandardLocationTrash")]
pub const Trash: Self = Self(0x74727368);
#[doc(alias = "kPasteboardStandardLocationUnknown")]
pub const Unknown: Self = Self(0x756e6b6e);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for PasteboardStandardLocation {
const ENCODING: Encoding = OSType::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for PasteboardStandardLocation {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
unsafe impl ConcreteType for Pasteboard {
#[doc(alias = "PasteboardGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn PasteboardGetTypeID() -> CFTypeID;
}
unsafe { PasteboardGetTypeID() }
}
}
impl Pasteboard {
#[doc(alias = "PasteboardCreate")]
#[inline]
pub unsafe fn create(
in_name: Option<&CFString>,
out_pasteboard: NonNull<*mut Pasteboard>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardCreate(
in_name: Option<&CFString>,
out_pasteboard: NonNull<*mut Pasteboard>,
) -> OSStatus;
}
unsafe { PasteboardCreate(in_name, out_pasteboard) }
}
#[doc(alias = "PasteboardSynchronize")]
#[inline]
pub unsafe fn synchronize(&self) -> PasteboardSyncFlags {
extern "C-unwind" {
fn PasteboardSynchronize(in_pasteboard: &Pasteboard) -> PasteboardSyncFlags;
}
unsafe { PasteboardSynchronize(self) }
}
#[doc(alias = "PasteboardClear")]
#[inline]
pub unsafe fn clear(&self) -> OSStatus {
extern "C-unwind" {
fn PasteboardClear(in_pasteboard: &Pasteboard) -> OSStatus;
}
unsafe { PasteboardClear(self) }
}
#[doc(alias = "PasteboardCopyName")]
#[inline]
pub unsafe fn copy_name(&self, out_name: NonNull<*const CFString>) -> OSStatus {
extern "C-unwind" {
fn PasteboardCopyName(
in_pasteboard: &Pasteboard,
out_name: NonNull<*const CFString>,
) -> OSStatus;
}
unsafe { PasteboardCopyName(self, out_name) }
}
#[doc(alias = "PasteboardGetItemCount")]
#[inline]
pub unsafe fn item_count(&self, out_item_count: NonNull<ItemCount>) -> OSStatus {
extern "C-unwind" {
fn PasteboardGetItemCount(
in_pasteboard: &Pasteboard,
out_item_count: NonNull<ItemCount>,
) -> OSStatus;
}
unsafe { PasteboardGetItemCount(self, out_item_count) }
}
#[doc(alias = "PasteboardGetItemIdentifier")]
#[inline]
pub unsafe fn item_identifier(
&self,
in_index: CFIndex,
out_item: NonNull<PasteboardItemID>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardGetItemIdentifier(
in_pasteboard: &Pasteboard,
in_index: CFIndex,
out_item: NonNull<PasteboardItemID>,
) -> OSStatus;
}
unsafe { PasteboardGetItemIdentifier(self, in_index, out_item) }
}
#[doc(alias = "PasteboardCopyItemFlavors")]
#[inline]
pub unsafe fn copy_item_flavors(
&self,
in_item: PasteboardItemID,
out_flavor_types: NonNull<*const CFArray>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardCopyItemFlavors(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
out_flavor_types: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { PasteboardCopyItemFlavors(self, in_item, out_flavor_types) }
}
#[doc(alias = "PasteboardGetItemFlavorFlags")]
#[inline]
pub unsafe fn item_flavor_flags(
&self,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_flags: NonNull<PasteboardFlavorFlags>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardGetItemFlavorFlags(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_flags: NonNull<PasteboardFlavorFlags>,
) -> OSStatus;
}
unsafe { PasteboardGetItemFlavorFlags(self, in_item, in_flavor_type, out_flags) }
}
#[doc(alias = "PasteboardCopyItemFlavorData")]
#[inline]
pub unsafe fn copy_item_flavor_data(
&self,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_data: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardCopyItemFlavorData(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_data: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { PasteboardCopyItemFlavorData(self, in_item, in_flavor_type, out_data) }
}
#[doc(alias = "PasteboardPutItemFlavor")]
#[inline]
pub unsafe fn put_item_flavor(
&self,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
in_data: Option<&CFData>,
in_flags: PasteboardFlavorFlags,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardPutItemFlavor(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
in_data: Option<&CFData>,
in_flags: PasteboardFlavorFlags,
) -> OSStatus;
}
unsafe { PasteboardPutItemFlavor(self, in_item, in_flavor_type, in_data, in_flags) }
}
#[doc(alias = "PasteboardCopyPasteLocation")]
#[inline]
pub unsafe fn copy_paste_location(
&self,
out_paste_location: NonNull<*const CFURL>,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardCopyPasteLocation(
in_pasteboard: &Pasteboard,
out_paste_location: NonNull<*const CFURL>,
) -> OSStatus;
}
unsafe { PasteboardCopyPasteLocation(self, out_paste_location) }
}
#[doc(alias = "PasteboardSetPasteLocation")]
#[inline]
pub unsafe fn set_paste_location(&self, in_paste_location: &CFURL) -> OSStatus {
extern "C-unwind" {
fn PasteboardSetPasteLocation(
in_pasteboard: &Pasteboard,
in_paste_location: &CFURL,
) -> OSStatus;
}
unsafe { PasteboardSetPasteLocation(self, in_paste_location) }
}
}
pub type PasteboardPromiseKeeperProcPtr = Option<
unsafe extern "C-unwind" fn(
NonNull<Pasteboard>,
PasteboardItemID,
NonNull<CFString>,
*mut c_void,
) -> OSStatus,
>;
impl Pasteboard {
#[doc(alias = "PasteboardSetPromiseKeeper")]
#[inline]
pub unsafe fn set_promise_keeper(
&self,
in_promise_keeper: PasteboardPromiseKeeperProcPtr,
in_context: *mut c_void,
) -> OSStatus {
extern "C-unwind" {
fn PasteboardSetPromiseKeeper(
in_pasteboard: &Pasteboard,
in_promise_keeper: PasteboardPromiseKeeperProcPtr,
in_context: *mut c_void,
) -> OSStatus;
}
unsafe { PasteboardSetPromiseKeeper(self, in_promise_keeper, in_context) }
}
#[doc(alias = "PasteboardResolvePromises")]
#[inline]
pub unsafe fn resolve_promises(&self) -> OSStatus {
extern "C-unwind" {
fn PasteboardResolvePromises(in_pasteboard: &Pasteboard) -> OSStatus;
}
unsafe { PasteboardResolvePromises(self) }
}
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::create`"]
pub fn PasteboardCreate(
in_name: Option<&CFString>,
out_pasteboard: NonNull<*mut Pasteboard>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::synchronize`"]
pub fn PasteboardSynchronize(in_pasteboard: &Pasteboard) -> PasteboardSyncFlags;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::clear`"]
pub fn PasteboardClear(in_pasteboard: &Pasteboard) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::copy_name`"]
pub fn PasteboardCopyName(
in_pasteboard: &Pasteboard,
out_name: NonNull<*const CFString>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::item_count`"]
pub fn PasteboardGetItemCount(
in_pasteboard: &Pasteboard,
out_item_count: NonNull<ItemCount>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::item_identifier`"]
pub fn PasteboardGetItemIdentifier(
in_pasteboard: &Pasteboard,
in_index: CFIndex,
out_item: NonNull<PasteboardItemID>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::copy_item_flavors`"]
pub fn PasteboardCopyItemFlavors(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
out_flavor_types: NonNull<*const CFArray>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::item_flavor_flags`"]
pub fn PasteboardGetItemFlavorFlags(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_flags: NonNull<PasteboardFlavorFlags>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::copy_item_flavor_data`"]
pub fn PasteboardCopyItemFlavorData(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
out_data: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::put_item_flavor`"]
pub fn PasteboardPutItemFlavor(
in_pasteboard: &Pasteboard,
in_item: PasteboardItemID,
in_flavor_type: &CFString,
in_data: Option<&CFData>,
in_flags: PasteboardFlavorFlags,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::copy_paste_location`"]
pub fn PasteboardCopyPasteLocation(
in_pasteboard: &Pasteboard,
out_paste_location: NonNull<*const CFURL>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::set_paste_location`"]
pub fn PasteboardSetPasteLocation(
in_pasteboard: &Pasteboard,
in_paste_location: &CFURL,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::set_promise_keeper`"]
pub fn PasteboardSetPromiseKeeper(
in_pasteboard: &Pasteboard,
in_promise_keeper: PasteboardPromiseKeeperProcPtr,
in_context: *mut c_void,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `Pasteboard::resolve_promises`"]
pub fn PasteboardResolvePromises(in_pasteboard: &Pasteboard) -> OSStatus;
}