use objc2::{
extern_class, extern_conformance, extern_methods, msg_send,
rc::{Allocated, Retained},
runtime::{NSObject, ProtocolObject},
};
use objc2_foundation::{CopyingHelper, NSCopying, NSObjectProtocol, NSString};
use super::MTLCounterSet;
use crate::resource::MTLStorageMode;
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLCounterSampleBufferDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTLCounterSampleBufferDescriptor {}
);
unsafe impl CopyingHelper for MTLCounterSampleBufferDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTLCounterSampleBufferDescriptor {}
);
impl MTLCounterSampleBufferDescriptor {
extern_methods!(
#[unsafe(method(counterSet))]
#[unsafe(method_family = none)]
pub fn counter_set(&self) -> Option<Retained<ProtocolObject<dyn MTLCounterSet>>>;
#[unsafe(method(setCounterSet:))]
#[unsafe(method_family = none)]
pub fn set_counter_set(
&self,
counter_set: Option<&ProtocolObject<dyn MTLCounterSet>>,
);
#[unsafe(method(storageMode))]
#[unsafe(method_family = none)]
pub fn storage_mode(&self) -> MTLStorageMode;
#[unsafe(method(setStorageMode:))]
#[unsafe(method_family = none)]
pub fn set_storage_mode(
&self,
mode: MTLStorageMode,
);
#[unsafe(method(sampleCount))]
#[unsafe(method_family = none)]
pub fn sample_count(&self) -> usize;
#[unsafe(method(setSampleCount:))]
#[unsafe(method_family = none)]
pub fn set_sample_count(
&self,
sample_count: usize,
);
);
pub fn label(&self) -> String {
let label: Retained<NSString> = unsafe { msg_send![self, label] };
label.to_string()
}
pub fn set_label(
&self,
label: &str,
) {
unsafe {
let _: () = msg_send![self, setLabel: &*NSString::from_str(label)];
}
}
}
impl MTLCounterSampleBufferDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}