objc2_metal/generated/
MTL4BinaryFunctionDescriptor.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Options for configuring the creation of binary functions.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4binaryfunctionoptions?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MTL4BinaryFunctionOptions(pub NSUInteger);
17bitflags::bitflags! {
18    impl MTL4BinaryFunctionOptions: NSUInteger {
19/// Represents the default value: no options.
20        #[doc(alias = "MTL4BinaryFunctionOptionNone")]
21        const None = 0;
22/// Compiles the function to have its function handles return a constant MTLResourceID across
23/// all pipeline states. The function needs to be linked to the pipeline that will use this function.
24        #[doc(alias = "MTL4BinaryFunctionOptionPipelineIndependent")]
25        const PipelineIndependent = 1<<1;
26    }
27}
28
29unsafe impl Encode for MTL4BinaryFunctionOptions {
30    const ENCODING: Encoding = NSUInteger::ENCODING;
31}
32
33unsafe impl RefEncode for MTL4BinaryFunctionOptions {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// Base interface for other function-derived interfaces.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4binaryfunctiondescriptor?language=objc)
41    #[unsafe(super(NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    pub struct MTL4BinaryFunctionDescriptor;
44);
45
46extern_conformance!(
47    unsafe impl NSCopying for MTL4BinaryFunctionDescriptor {}
48);
49
50unsafe impl CopyingHelper for MTL4BinaryFunctionDescriptor {
51    type Result = Self;
52}
53
54extern_conformance!(
55    unsafe impl NSObjectProtocol for MTL4BinaryFunctionDescriptor {}
56);
57
58impl MTL4BinaryFunctionDescriptor {
59    extern_methods!(
60        /// Associates a string that uniquely identifies a binary function.
61        ///
62        /// You can use this property to look up a corresponding binary function by name in a ``MTL4Archive`` instance.
63        #[unsafe(method(name))]
64        #[unsafe(method_family = none)]
65        pub fn name(&self) -> Retained<NSString>;
66
67        /// Setter for [`name`][Self::name].
68        ///
69        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
70        #[unsafe(method(setName:))]
71        #[unsafe(method_family = none)]
72        pub fn setName(&self, name: &NSString);
73
74        #[cfg(feature = "MTL4FunctionDescriptor")]
75        /// Provides the function descriptor corresponding to the function to compile into a binary function.
76        #[unsafe(method(functionDescriptor))]
77        #[unsafe(method_family = none)]
78        pub fn functionDescriptor(&self) -> Retained<MTL4FunctionDescriptor>;
79
80        #[cfg(feature = "MTL4FunctionDescriptor")]
81        /// Setter for [`functionDescriptor`][Self::functionDescriptor].
82        ///
83        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
84        #[unsafe(method(setFunctionDescriptor:))]
85        #[unsafe(method_family = none)]
86        pub fn setFunctionDescriptor(&self, function_descriptor: &MTL4FunctionDescriptor);
87
88        /// Configure the options to use at binary function creation time.
89        #[unsafe(method(options))]
90        #[unsafe(method_family = none)]
91        pub fn options(&self) -> MTL4BinaryFunctionOptions;
92
93        /// Setter for [`options`][Self::options].
94        #[unsafe(method(setOptions:))]
95        #[unsafe(method_family = none)]
96        pub fn setOptions(&self, options: MTL4BinaryFunctionOptions);
97    );
98}
99
100/// Methods declared on superclass `NSObject`.
101impl MTL4BinaryFunctionDescriptor {
102    extern_methods!(
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        #[unsafe(method(new))]
108        #[unsafe(method_family = new)]
109        pub fn new() -> Retained<Self>;
110    );
111}
112
113impl DefaultRetained for MTL4BinaryFunctionDescriptor {
114    #[inline]
115    fn default_retained() -> Retained<Self> {
116        Self::new()
117    }
118}