use objc2::{extern_class, extern_conformance, extern_methods, msg_send, rc::Retained, runtime::NSObject};
use objc2_foundation::{NSObjectProtocol, NSString};
use crate::MTLDataType;
macro_rules! impl_attribute {
($attribute:ident) => {
extern_conformance!(
unsafe impl NSObjectProtocol for $attribute {}
);
impl $attribute {
extern_methods!(
#[unsafe(method(attributeIndex))]
#[unsafe(method_family = none)]
pub fn attribute_index(&self) -> usize;
#[unsafe(method(attributeType))]
#[unsafe(method_family = none)]
pub fn attribute_type(&self) -> MTLDataType;
#[unsafe(method(isActive))]
#[unsafe(method_family = none)]
pub fn is_active(&self) -> bool;
#[unsafe(method(isPatchData))]
#[unsafe(method_family = none)]
pub fn is_patch_data(&self) -> bool;
#[unsafe(method(isPatchControlPointData))]
#[unsafe(method_family = none)]
pub fn is_patch_control_point_data(&self) -> bool;
);
pub fn name(&self) -> String {
let name: Retained<NSString> = unsafe { msg_send![self, name] };
name.to_string()
}
}
};
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLVertexAttribute;
);
impl_attribute!(MTLVertexAttribute);
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLAttribute;
);
impl_attribute!(MTLAttribute);