use objc2::{
extern_class, extern_conformance, extern_methods, msg_send,
rc::{Allocated, Retained},
};
use objc2_foundation::{CopyingHelper, NSCopying, NSObject, NSObjectProtocol, NSString};
use crate::*;
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4CommitOptions;
);
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4CommitOptions {}
);
impl MTL4CommitOptions {
extern_methods!(
#[unsafe(method(addFeedbackHandler:))]
#[unsafe(method_family = none)]
pub fn add_feedback_handler(
&self,
block: MTL4CommitFeedbackHandler,
);
);
}
impl MTL4CommitOptions {
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>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4CommandQueueDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTL4CommandQueueDescriptor {}
);
unsafe impl CopyingHelper for MTL4CommandQueueDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4CommandQueueDescriptor {}
);
impl MTL4CommandQueueDescriptor {
extern_methods!(
#[unsafe(method(feedbackQueue))]
#[unsafe(method_family = none)]
pub fn feedback_queue(&self) -> Option<Retained<dispatch2::DispatchQueue>>;
#[unsafe(method(setFeedbackQueue:))]
#[unsafe(method_family = none)]
pub fn set_feedback_queue(
&self,
feedback_queue: Option<&dispatch2::DispatchQueue>,
);
);
}
impl MTL4CommandQueueDescriptor {
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>;
);
}
impl MTL4CommandQueueDescriptor {
pub fn label(&self) -> Option<String> {
let s: Option<Retained<NSString>> = unsafe { msg_send![self, label] };
s.map(|v| v.to_string())
}
pub fn set_label(
&self,
label: Option<&str>,
) {
unsafe {
let _: () = msg_send![self, setLabel: label.map(NSString::from_str).as_deref()];
}
}
}