use crate::MTLDevice;
use objc2::rc::Retained;
use objc2::runtime::ProtocolObject;
use objc2_foundation::NSArray;
#[inline]
#[allow(unexpected_cfgs)]
pub extern "C-unwind" fn MTLCopyAllDevices() -> Retained<NSArray<ProtocolObject<dyn MTLDevice>>> {
#[cfg(any(target_os = "macos", target_env = "macabi"))]
{
extern "C-unwind" {
fn MTLCopyAllDevices() -> *mut NSArray<ProtocolObject<dyn MTLDevice>>;
}
let ret = unsafe { MTLCopyAllDevices() };
unsafe { Retained::from_raw(ret) }
.expect("function was marked as returning non-null, but actually returned NULL")
}
#[cfg(not(any(target_os = "macos", target_env = "macabi")))]
{
let device = crate::MTLCreateSystemDefaultDevice();
let slice: &[_] = if let Some(device) = device.as_deref() {
&[device]
} else {
&[]
};
NSArray::from_slice(slice)
}
}