mtl-rs 0.1.7

Rust bindings for Apple's Metal API
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
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!(
    /// Groups together properties to configure and create a specialized function by passing it to a factory method.
    ///
    /// You can pass an instance of this class to any methods that accept a ``MTL4FunctionDescriptor`` parameter to
    /// provide extra configuration, such as function constants or a name.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4specializedfunctiondescriptor?language=objc)
    #[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!(
        /// Provides a descriptor that corresponds to a base function that the specialization applies to.
        #[unsafe(method(functionDescriptor))]
        #[unsafe(method_family = none)]
        pub fn function_descriptor(&self) -> Option<Retained<MTL4FunctionDescriptor>>;

        /// Setter for [`functionDescriptor`][Self::functionDescriptor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setFunctionDescriptor:))]
        #[unsafe(method_family = none)]
        pub fn set_function_descriptor(
            &self,
            function_descriptor: Option<&MTL4FunctionDescriptor>,
        );

        /// Configures optional function constant values to associate with the function.
        #[unsafe(method(constantValues))]
        #[unsafe(method_family = none)]
        pub fn constant_values(&self) -> Option<Retained<MTLFunctionConstantValues>>;

        /// Setter for [`constantValues`][Self::constantValues].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[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()
            ];
        }
    }
}

/// Methods declared on superclass `NSObject`.
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>;
    );
}