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::*;
pub const kCMSimpleQueueError_AllocationFailed: OSStatus = -12770;
pub const kCMSimpleQueueError_RequiredParameterMissing: OSStatus = -12771;
pub const kCMSimpleQueueError_ParameterOutOfRange: OSStatus = -12772;
pub const kCMSimpleQueueError_QueueIsFull: OSStatus = -12773;
#[doc(alias = "CMSimpleQueueRef")]
#[repr(C)]
pub struct CMSimpleQueue {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CMSimpleQueue {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"opaqueCMSimpleQueue"> for CMSimpleQueue {}
);
unsafe impl ConcreteType for CMSimpleQueue {
#[doc(alias = "CMSimpleQueueGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CMSimpleQueueGetTypeID() -> CFTypeID;
}
unsafe { CMSimpleQueueGetTypeID() }
}
}
impl CMSimpleQueue {
#[doc(alias = "CMSimpleQueueCreate")]
#[inline]
pub unsafe fn create(
allocator: Option<&CFAllocator>,
capacity: i32,
queue_out: NonNull<*mut CMSimpleQueue>,
) -> OSStatus {
extern "C-unwind" {
fn CMSimpleQueueCreate(
allocator: Option<&CFAllocator>,
capacity: i32,
queue_out: NonNull<*mut CMSimpleQueue>,
) -> OSStatus;
}
unsafe { CMSimpleQueueCreate(allocator, capacity, queue_out) }
}
#[doc(alias = "CMSimpleQueueEnqueue")]
#[inline]
pub unsafe fn enqueue(&self, element: NonNull<c_void>) -> OSStatus {
extern "C-unwind" {
fn CMSimpleQueueEnqueue(queue: &CMSimpleQueue, element: NonNull<c_void>) -> OSStatus;
}
unsafe { CMSimpleQueueEnqueue(self, element) }
}
#[doc(alias = "CMSimpleQueueDequeue")]
#[inline]
pub unsafe fn dequeue(&self) -> *const c_void {
extern "C-unwind" {
fn CMSimpleQueueDequeue(queue: &CMSimpleQueue) -> *const c_void;
}
unsafe { CMSimpleQueueDequeue(self) }
}
#[doc(alias = "CMSimpleQueueGetHead")]
#[inline]
pub unsafe fn head(&self) -> *const c_void {
extern "C-unwind" {
fn CMSimpleQueueGetHead(queue: &CMSimpleQueue) -> *const c_void;
}
unsafe { CMSimpleQueueGetHead(self) }
}
#[doc(alias = "CMSimpleQueueReset")]
#[inline]
pub unsafe fn reset(&self) -> OSStatus {
extern "C-unwind" {
fn CMSimpleQueueReset(queue: &CMSimpleQueue) -> OSStatus;
}
unsafe { CMSimpleQueueReset(self) }
}
#[doc(alias = "CMSimpleQueueGetCapacity")]
#[inline]
pub unsafe fn capacity(&self) -> i32 {
extern "C-unwind" {
fn CMSimpleQueueGetCapacity(queue: &CMSimpleQueue) -> i32;
}
unsafe { CMSimpleQueueGetCapacity(self) }
}
#[doc(alias = "CMSimpleQueueGetCount")]
#[inline]
pub unsafe fn count(&self) -> i32 {
extern "C-unwind" {
fn CMSimpleQueueGetCount(queue: &CMSimpleQueue) -> i32;
}
unsafe { CMSimpleQueueGetCount(self) }
}
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::create`"]
pub fn CMSimpleQueueCreate(
allocator: Option<&CFAllocator>,
capacity: i32,
queue_out: NonNull<*mut CMSimpleQueue>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::enqueue`"]
pub fn CMSimpleQueueEnqueue(queue: &CMSimpleQueue, element: NonNull<c_void>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::dequeue`"]
pub fn CMSimpleQueueDequeue(queue: &CMSimpleQueue) -> *const c_void;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::head`"]
pub fn CMSimpleQueueGetHead(queue: &CMSimpleQueue) -> *const c_void;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::reset`"]
pub fn CMSimpleQueueReset(queue: &CMSimpleQueue) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::capacity`"]
pub fn CMSimpleQueueGetCapacity(queue: &CMSimpleQueue) -> i32;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSimpleQueue::count`"]
pub fn CMSimpleQueueGetCount(queue: &CMSimpleQueue) -> i32;
}