use objc2::{Message, extern_protocol, msg_send, rc::Retained, runtime::ProtocolObject};
use objc2_foundation::{NSArray, NSObjectProtocol, NSString};
use super::MTLCounter;
extern_protocol!(
pub unsafe trait MTLCounterSet: NSObjectProtocol + Send + Sync {}
);
#[allow(unused)]
pub trait MTLCounterSetExt: MTLCounterSet + Message {
fn name(&self) -> String;
fn counters(&self) -> Box<[Retained<ProtocolObject<dyn MTLCounter>>]>;
}
impl MTLCounterSetExt for ProtocolObject<dyn MTLCounterSet> {
fn name(&self) -> String {
let ns: Retained<NSString> = unsafe { msg_send![self, name] };
ns.to_string()
}
fn counters(&self) -> Box<[Retained<ProtocolObject<dyn MTLCounter>>]> {
let arr: Retained<NSArray<ProtocolObject<dyn MTLCounter>>> = unsafe { msg_send![self, counters] };
arr.to_vec().into_boxed_slice()
}
}