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 = "CMMemoryPoolRef")]
#[repr(C)]
pub struct CMMemoryPool {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CMMemoryPool {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueCMMemoryPool"> for CMMemoryPool {}
);
unsafe impl Send for CMMemoryPool {}
unsafe impl Sync for CMMemoryPool {}
pub const kCMMemoryPoolError_AllocationFailed: OSStatus = -15490;
pub const kCMMemoryPoolError_InvalidParameter: OSStatus = -15491;
unsafe impl ConcreteType for CMMemoryPool {
#[doc(alias = "CMMemoryPoolGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CMMemoryPoolGetTypeID() -> CFTypeID;
}
unsafe { CMMemoryPoolGetTypeID() }
}
}
extern "C" {
pub static kCMMemoryPoolOption_AgeOutPeriod: &'static CFString;
}
impl CMMemoryPool {
#[doc(alias = "CMMemoryPoolCreate")]
#[inline]
pub unsafe fn new(options: Option<&CFDictionary>) -> CFRetained<CMMemoryPool> {
extern "C-unwind" {
fn CMMemoryPoolCreate(options: Option<&CFDictionary>) -> Option<NonNull<CMMemoryPool>>;
}
let ret = unsafe { CMMemoryPoolCreate(options) };
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[doc(alias = "CMMemoryPoolGetAllocator")]
#[inline]
pub unsafe fn allocator(&self) -> CFRetained<CFAllocator> {
extern "C-unwind" {
fn CMMemoryPoolGetAllocator(pool: &CMMemoryPool) -> Option<NonNull<CFAllocator>>;
}
let ret = unsafe { CMMemoryPoolGetAllocator(self) };
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::retain(ret) }
}
#[doc(alias = "CMMemoryPoolFlush")]
#[inline]
pub unsafe fn flush(&self) {
extern "C-unwind" {
fn CMMemoryPoolFlush(pool: &CMMemoryPool);
}
unsafe { CMMemoryPoolFlush(self) }
}
#[doc(alias = "CMMemoryPoolInvalidate")]
#[inline]
pub unsafe fn invalidate(&self) {
extern "C-unwind" {
fn CMMemoryPoolInvalidate(pool: &CMMemoryPool);
}
unsafe { CMMemoryPoolInvalidate(self) }
}
}
#[deprecated = "renamed to `CMMemoryPool::new`"]
#[inline]
pub unsafe extern "C-unwind" fn CMMemoryPoolCreate(
options: Option<&CFDictionary>,
) -> CFRetained<CMMemoryPool> {
extern "C-unwind" {
fn CMMemoryPoolCreate(options: Option<&CFDictionary>) -> Option<NonNull<CMMemoryPool>>;
}
let ret = unsafe { CMMemoryPoolCreate(options) };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[deprecated = "renamed to `CMMemoryPool::allocator`"]
#[inline]
pub unsafe extern "C-unwind" fn CMMemoryPoolGetAllocator(
pool: &CMMemoryPool,
) -> CFRetained<CFAllocator> {
extern "C-unwind" {
fn CMMemoryPoolGetAllocator(pool: &CMMemoryPool) -> Option<NonNull<CFAllocator>>;
}
let ret = unsafe { CMMemoryPoolGetAllocator(pool) };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::retain(ret) }
}
extern "C-unwind" {
#[deprecated = "renamed to `CMMemoryPool::flush`"]
pub fn CMMemoryPoolFlush(pool: &CMMemoryPool);
}
extern "C-unwind" {
#[deprecated = "renamed to `CMMemoryPool::invalidate`"]
pub fn CMMemoryPoolInvalidate(pool: &CMMemoryPool);
}