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(MTL4FunctionDescriptor, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTL4SpecializedFunctionDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTL4SpecializedFunctionDescriptor {}
);
unsafe impl CopyingHelper for MTL4SpecializedFunctionDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTL4SpecializedFunctionDescriptor {}
);
impl MTL4SpecializedFunctionDescriptor {
extern_methods!(
#[unsafe(method(functionDescriptor))]
#[unsafe(method_family = none)]
pub fn function_descriptor(&self) -> Option<Retained<MTL4FunctionDescriptor>>;
#[unsafe(method(setFunctionDescriptor:))]
#[unsafe(method_family = none)]
pub fn set_function_descriptor(
&self,
function_descriptor: Option<&MTL4FunctionDescriptor>,
);
#[unsafe(method(constantValues))]
#[unsafe(method_family = none)]
pub fn constant_values(&self) -> Option<Retained<MTLFunctionConstantValues>>;
#[unsafe(method(setConstantValues:))]
#[unsafe(method_family = none)]
pub fn set_constant_values(
&self,
constant_values: Option<&MTLFunctionConstantValues>,
);
);
pub fn specialized_name(&self) -> Option<String> {
let name: Option<Retained<NSString>> = unsafe { msg_send![self, specializedName] };
name.map(|value| value.to_string())
}
pub fn set_specialized_name(
&self,
specialized_name: Option<&str>,
) {
unsafe {
let _: () = msg_send![
self,
setSpecializedName: specialized_name.map(NSString::from_str).as_deref()
];
}
}
}
impl MTL4SpecializedFunctionDescriptor {
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>;
);
}