use objc2::{Message, extern_protocol, msg_send, rc::Retained, runtime::ProtocolObject};
use objc2_foundation::{NSObjectProtocol, NSString};
use crate::*;
extern_protocol!(
pub unsafe trait MTL4CommandAllocator: NSObjectProtocol {
#[unsafe(method(device))]
#[unsafe(method_family = none)]
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
#[unsafe(method(allocatedSize))]
#[unsafe(method_family = none)]
fn allocated_size(&self) -> u64;
#[unsafe(method(reset))]
#[unsafe(method_family = none)]
fn reset(&self);
}
);
pub trait MTL4CommandAllocatorExt: MTL4CommandAllocator + Message {
fn label(&self) -> Option<String> {
let s: Option<Retained<NSString>> = unsafe { msg_send![self, label] };
s.map(|s| s.to_string())
}
}
impl<T: MTL4CommandAllocator + Message> MTL4CommandAllocatorExt for T {}