objc2-metal 0.3.2

Bindings to the Metal framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Options for configuring the creation of binary functions.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4binaryfunctionoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTL4BinaryFunctionOptions(pub NSUInteger);
bitflags::bitflags! {
    impl MTL4BinaryFunctionOptions: NSUInteger {
/// Represents the default value: no options.
        #[doc(alias = "MTL4BinaryFunctionOptionNone")]
        const None = 0;
/// Compiles the function to have its function handles return a constant MTLResourceID across
/// all pipeline states. The function needs to be linked to the pipeline that will use this function.
        #[doc(alias = "MTL4BinaryFunctionOptionPipelineIndependent")]
        const PipelineIndependent = 1<<1;
    }
}

unsafe impl Encode for MTL4BinaryFunctionOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MTL4BinaryFunctionOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Base interface for other function-derived interfaces.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4binaryfunctiondescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTL4BinaryFunctionDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTL4BinaryFunctionDescriptor {}
);

unsafe impl CopyingHelper for MTL4BinaryFunctionDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTL4BinaryFunctionDescriptor {}
);

impl MTL4BinaryFunctionDescriptor {
    extern_methods!(
        /// Associates a string that uniquely identifies a binary function.
        ///
        /// You can use this property to look up a corresponding binary function by name in a ``MTL4Archive`` instance.
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub fn name(&self) -> Retained<NSString>;

        /// Setter for [`name`][Self::name].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setName:))]
        #[unsafe(method_family = none)]
        pub fn setName(&self, name: &NSString);

        #[cfg(feature = "MTL4FunctionDescriptor")]
        /// Provides the function descriptor corresponding to the function to compile into a binary function.
        #[unsafe(method(functionDescriptor))]
        #[unsafe(method_family = none)]
        pub fn functionDescriptor(&self) -> Retained<MTL4FunctionDescriptor>;

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

        /// Configure the options to use at binary function creation time.
        #[unsafe(method(options))]
        #[unsafe(method_family = none)]
        pub fn options(&self) -> MTL4BinaryFunctionOptions;

        /// Setter for [`options`][Self::options].
        #[unsafe(method(setOptions:))]
        #[unsafe(method_family = none)]
        pub fn setOptions(&self, options: MTL4BinaryFunctionOptions);
    );
}

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

impl DefaultRetained for MTL4BinaryFunctionDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}