use objc2::{
extern_class, extern_conformance, extern_methods, msg_send,
rc::{Allocated, Retained},
runtime::{NSObject, ProtocolObject},
};
use objc2_foundation::{CopyingHelper, NSArray, NSCopying, NSObjectProtocol};
use super::{MTLFunctionStitchingGraph, MTLStitchedLibraryOptions};
use crate::{MTLBinaryArchive, library::MTLFunction};
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLStitchedLibraryDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTLStitchedLibraryDescriptor {}
);
unsafe impl CopyingHelper for MTLStitchedLibraryDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTLStitchedLibraryDescriptor {}
);
impl MTLStitchedLibraryDescriptor {
extern_methods!(
#[unsafe(method(options))]
#[unsafe(method_family = none)]
pub fn options(&self) -> MTLStitchedLibraryOptions;
#[unsafe(method(setOptions:))]
#[unsafe(method_family = none)]
pub fn set_options(
&self,
options: MTLStitchedLibraryOptions,
);
);
pub fn function_graphs(&self) -> Box<[Retained<MTLFunctionStitchingGraph>]> {
let function_graphs: Retained<NSArray<MTLFunctionStitchingGraph>> = unsafe { msg_send![self, functionGraphs] };
function_graphs.to_vec().into_boxed_slice()
}
pub fn set_function_graphs(
&self,
function_graphs: &[&MTLFunctionStitchingGraph],
) {
let function_graphs = NSArray::from_slice(function_graphs);
unsafe {
let _: () = msg_send![self, setFunctionGraphs: &*function_graphs];
}
}
pub fn functions(&self) -> Box<[Retained<ProtocolObject<dyn MTLFunction>>]> {
let functions: Retained<NSArray<ProtocolObject<dyn MTLFunction>>> = unsafe { msg_send![self, functions] };
functions.to_vec().into_boxed_slice()
}
pub fn set_functions(
&self,
functions: &[&ProtocolObject<dyn MTLFunction>],
) {
let functions = NSArray::from_slice(functions);
unsafe {
let _: () = msg_send![self, setFunctions: &*functions];
}
}
pub fn binary_archives(&self) -> Box<[Retained<ProtocolObject<dyn MTLBinaryArchive>>]> {
let binary_archives: Retained<NSArray<ProtocolObject<dyn MTLBinaryArchive>>> =
unsafe { msg_send![self, binaryArchives] };
binary_archives.to_vec().into_boxed_slice()
}
pub fn set_binary_archives(
&self,
binary_archives: &[&ProtocolObject<dyn MTLBinaryArchive>],
) {
let binary_archives = NSArray::from_slice(binary_archives);
unsafe {
let _: () = msg_send![self, setBinaryArchives: &*binary_archives];
}
}
}
impl MTLStitchedLibraryDescriptor {
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>;
);
}