objc2_metal/generated/
MTLEvent.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_protocol!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlevent?language=objc)
14    pub unsafe trait MTLEvent: NSObjectProtocol + Send + Sync {
15        #[cfg(feature = "MTLDevice")]
16        /// The device this event can be used with. Will be nil when the event is shared across devices (i.e. MTLSharedEvent).
17        #[unsafe(method(device))]
18        #[unsafe(method_family = none)]
19        fn device(&self) -> Option<Retained<ProtocolObject<dyn MTLDevice>>>;
20
21        /// A string to help identify this object.
22        #[unsafe(method(label))]
23        #[unsafe(method_family = none)]
24        fn label(&self) -> Option<Retained<NSString>>;
25
26        /// Setter for [`label`][Self::label].
27        ///
28        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
29        #[unsafe(method(setLabel:))]
30        #[unsafe(method_family = none)]
31        fn setLabel(&self, label: Option<&NSString>);
32    }
33);
34
35extern_class!(
36    /// This class provides a simple interface for handling the dispatching of MTLSharedEvent notifications from Metal.
37    ///
38    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsharedeventlistener?language=objc)
39    #[unsafe(super(NSObject))]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    pub struct MTLSharedEventListener;
42);
43
44unsafe impl Send for MTLSharedEventListener {}
45
46unsafe impl Sync for MTLSharedEventListener {}
47
48extern_conformance!(
49    unsafe impl NSObjectProtocol for MTLSharedEventListener {}
50);
51
52impl MTLSharedEventListener {
53    extern_methods!(
54        #[unsafe(method(init))]
55        #[unsafe(method_family = init)]
56        pub fn init(this: Allocated<Self>) -> Retained<Self>;
57
58        #[cfg(feature = "dispatch2")]
59        /// # Safety
60        ///
61        /// `dispatch_queue` possibly has additional threading requirements.
62        #[unsafe(method(initWithDispatchQueue:))]
63        #[unsafe(method_family = init)]
64        pub unsafe fn initWithDispatchQueue(
65            this: Allocated<Self>,
66            dispatch_queue: &DispatchQueue,
67        ) -> Retained<Self>;
68
69        #[cfg(feature = "dispatch2")]
70        #[unsafe(method(dispatchQueue))]
71        #[unsafe(method_family = none)]
72        pub fn dispatchQueue(&self) -> Retained<DispatchQueue>;
73
74        #[unsafe(method(sharedListener))]
75        #[unsafe(method_family = none)]
76        pub fn sharedListener() -> Retained<MTLSharedEventListener>;
77    );
78}
79
80/// Methods declared on superclass `NSObject`.
81impl MTLSharedEventListener {
82    extern_methods!(
83        #[unsafe(method(new))]
84        #[unsafe(method_family = new)]
85        pub fn new() -> Retained<Self>;
86    );
87}
88
89impl DefaultRetained for MTLSharedEventListener {
90    #[inline]
91    fn default_retained() -> Retained<Self> {
92        Self::new()
93    }
94}
95
96/// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsharedeventnotificationblock?language=objc)
97#[cfg(feature = "block2")]
98pub type MTLSharedEventNotificationBlock =
99    *mut block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn MTLSharedEvent>>, u64)>;
100
101extern_protocol!(
102    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsharedevent?language=objc)
103    pub unsafe trait MTLSharedEvent: MTLEvent {
104        #[cfg(feature = "block2")]
105        /// # Safety
106        ///
107        /// `block` must be a valid pointer.
108        #[unsafe(method(notifyListener:atValue:block:))]
109        #[unsafe(method_family = none)]
110        unsafe fn notifyListener_atValue_block(
111            &self,
112            listener: &MTLSharedEventListener,
113            value: u64,
114            block: MTLSharedEventNotificationBlock,
115        );
116
117        #[unsafe(method(newSharedEventHandle))]
118        #[unsafe(method_family = new)]
119        fn newSharedEventHandle(&self) -> Retained<MTLSharedEventHandle>;
120
121        #[unsafe(method(waitUntilSignaledValue:timeoutMS:))]
122        #[unsafe(method_family = none)]
123        fn waitUntilSignaledValue_timeoutMS(&self, value: u64, milliseconds: u64) -> bool;
124
125        #[unsafe(method(signaledValue))]
126        #[unsafe(method_family = none)]
127        fn signaledValue(&self) -> u64;
128
129        /// Setter for [`signaledValue`][Self::signaledValue].
130        #[unsafe(method(setSignaledValue:))]
131        #[unsafe(method_family = none)]
132        fn setSignaledValue(&self, signaled_value: u64);
133    }
134);
135
136extern_class!(
137    /// [Apple's documentation](https://developer.apple.com/documentation/metal/mtlsharedeventhandle?language=objc)
138    #[unsafe(super(NSObject))]
139    #[derive(Debug, PartialEq, Eq, Hash)]
140    pub struct MTLSharedEventHandle;
141);
142
143unsafe impl Send for MTLSharedEventHandle {}
144
145unsafe impl Sync for MTLSharedEventHandle {}
146
147extern_conformance!(
148    unsafe impl NSCoding for MTLSharedEventHandle {}
149);
150
151extern_conformance!(
152    unsafe impl NSObjectProtocol for MTLSharedEventHandle {}
153);
154
155extern_conformance!(
156    unsafe impl NSSecureCoding for MTLSharedEventHandle {}
157);
158
159impl MTLSharedEventHandle {
160    extern_methods!(
161        #[unsafe(method(label))]
162        #[unsafe(method_family = none)]
163        pub fn label(&self) -> Option<Retained<NSString>>;
164    );
165}
166
167/// Methods declared on superclass `NSObject`.
168impl MTLSharedEventHandle {
169    extern_methods!(
170        #[unsafe(method(init))]
171        #[unsafe(method_family = init)]
172        pub fn init(this: Allocated<Self>) -> Retained<Self>;
173
174        #[unsafe(method(new))]
175        #[unsafe(method_family = new)]
176        pub fn new() -> Retained<Self>;
177    );
178}
179
180impl DefaultRetained for MTLSharedEventHandle {
181    #[inline]
182    fn default_retained() -> Retained<Self> {
183        Self::new()
184    }
185}