objc2_scripting_bridge/generated/
SBElementArray.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// `SBElementArray` is subclass of `NSMutableArray` that manages collections of
11    /// related
12    /// ``SBObject``
13    /// objects. For example, when you ask the Finder for a list of disks, or ask
14    /// iTunes for a list of playlists, you get the result back as an
15    /// `SBElementArray` containing Scripting Bridge objects representing those
16    /// items.
17    ///
18    /// `SBElementArray` defines methods beyond those of
19    /// <doc
20    /// ://com.apple.documentation/documentation/foundation/nsarray> for
21    /// obtaining individual objects. In addition to
22    /// <doc
23    /// ://com.apple.documentation/documentation/foundation/nsarray/1417555-objectatindex>,
24    /// `SBElementArray` also defines ``SBElementArray/objectWithName:``,
25    /// ``SBElementArray/objectWithID:``, and ``SBElementArray/objectAtLocation:``.
26    ///
27    /// ## Subclassing Notes
28    ///
29    /// The `SBElementArray` class is not designed for subclassing.
30    ///
31    /// See also [Apple's documentation](https://developer.apple.com/documentation/scriptingbridge/sbelementarray?language=objc)
32    #[unsafe(super(NSMutableArray<ObjectType>, NSArray<ObjectType>, NSObject))]
33    #[derive(PartialEq, Eq, Hash)]
34    pub struct SBElementArray<ObjectType: ?Sized = AnyObject>;
35);
36
37impl<ObjectType: ?Sized + Message> SBElementArray<ObjectType> {
38    /// Unchecked conversion of the generic parameter.
39    ///
40    /// # Safety
41    ///
42    /// The generic must be valid to reinterpret as the given type.
43    #[inline]
44    pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(
45        &self,
46    ) -> &SBElementArray<NewObjectType> {
47        unsafe { &*((self as *const Self).cast()) }
48    }
49}
50
51extern_conformance!(
52    unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for SBElementArray<ObjectType> {}
53);
54
55extern_conformance!(
56    unsafe impl<ObjectType: ?Sized> NSFastEnumeration for SBElementArray<ObjectType> {}
57);
58
59extern_conformance!(
60    unsafe impl<ObjectType: ?Sized> NSObjectProtocol for SBElementArray<ObjectType> {}
61);
62
63extern_conformance!(
64    unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for SBElementArray<ObjectType> {}
65);
66
67impl<ObjectType: Message> SBElementArray<ObjectType> {
68    extern_methods!(
69        /// Returns the object in the array with the given name.
70        ///
71        /// This method is provided as an alternative
72        /// to
73        /// <doc
74        /// ://com.apple.documentation/documentation/foundation/nsarray/1417555-objectatindex>
75        /// for applications where a name is available instead of (or in addition to) an
76        /// index. A name is generally more stable than an index. For example, it is
77        /// typically more useful to identify a mailbox in Mail by its name than by its
78        /// index in the list of mailboxes.
79        ///
80        /// - Parameters:
81        /// - name: The name of one of the receiver's objects.
82        ///
83        /// - Returns: A reference to the designated object or `nil` if the object
84        /// couldn’t be found.
85        #[unsafe(method(objectWithName:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn objectWithName(&self, name: &NSString) -> Retained<ObjectType>;
88
89        /// Returns the object in the array with the given identifier.
90        ///
91        /// This method is provided as an alternative to
92        /// <doc
93        /// ://com.apple.documentation/documentation/foundation/nsarray/1417555-objectatindex>
94        /// for applications where an identifier is available instead of (or in addition
95        /// to) an index. A unique ID is generally more stable than an index. For
96        /// example, it may be more useful to identify a contact in Address Book by its
97        /// identifier (which doesn't change over time) than by its index in the list of
98        /// contacts (which can change as contacts are added or removed).
99        ///
100        /// - Parameters:
101        /// - identifier: The identifier of one of the receiver's objects.
102        ///
103        /// - Returns: A reference to the identified object or `nil` if could not be
104        /// found.
105        ///
106        /// # Safety
107        ///
108        /// `identifier` should be of the correct type.
109        #[unsafe(method(objectWithID:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn objectWithID(&self, identifier: &AnyObject) -> Retained<ObjectType>;
112
113        /// Returns the object at the given location in the receiver.
114        ///
115        /// This method is a generalization of
116        /// <doc
117        /// ://com.apple.documentation/documentation/foundation/nsarray/1417555-objectatindex>
118        /// for applications where the "index" is not simply an integer. For example,
119        /// Finder can specify objects using a
120        /// <doc
121        /// ://com.apple.documentation/documentation/foundation/nsurl> object as a
122        /// location. In OSA this is known as "absolute position," a generalization of
123        /// the notion of “index” in Foundation—it could be an integer, but it doesn't
124        /// have to be. A single object may even have a number of different "absolute
125        /// position" values depending on the container.
126        ///
127        /// - Parameters:
128        /// - loc: An object that specifies the absolute position of the object within
129        /// the array. It can be an integer index, a list of coordinates, a URL, or
130        /// other determinant. See the discussion for clarification.
131        ///
132        /// - Returns: A reference to the ``SBObject`` object identified by `loc` or
133        /// `nil` if the object couldn’t be located.
134        ///
135        /// # Safety
136        ///
137        /// `location` should be of the correct type.
138        #[unsafe(method(objectAtLocation:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn objectAtLocation(&self, location: &AnyObject) -> Retained<ObjectType>;
141
142        /// Returns an array containing the results of sending the specified message to
143        /// each object in the receiver.
144        ///
145        /// The method identified by `selector` must not take any arguments and must
146        /// return an Objective-C object. It should not have the side effect of
147        /// modifying the receiving array. The order of the items in the result array
148        /// corresponds to the order of the items in the original array.
149        ///
150        /// - Parameters:
151        /// - selector: A selector identifying the message to be sent to each object in
152        /// the array.
153        ///
154        /// - Returns: A new array containing the results of sending the `selector`
155        /// message to each object in the receiver, starting with the first object and
156        /// continuing through the element array to the last object.
157        ///
158        /// # Safety
159        ///
160        /// `selector` must be a valid selector.
161        #[unsafe(method(arrayByApplyingSelector:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn arrayByApplyingSelector(&self, selector: Sel)
164            -> Retained<NSArray<AnyObject>>;
165
166        /// Returns an array containing the results of sending the specified message to
167        /// each object in the receiver.
168        ///
169        /// The method identified by `selector` must take a single argument—whose value
170        /// is provided in `argument`—and must return an object. It should not have the
171        /// side effect of modifying the receiving array. The order of the items in the
172        /// result array corresponds to the order of the items in the original array.
173        ///
174        /// - Parameters:
175        /// - selector: A selector identifying the message to be sent to each object in
176        /// the array.
177        ///
178        /// - argument: The value for the parameter of the message identified by
179        /// `selector`.
180        ///
181        /// - Returns: A new array containing the results of sending the `selector`
182        /// message to each object in the receiver, starting with the first object and
183        /// continuing through the element array to the last object.
184        ///
185        /// # Safety
186        ///
187        /// - `a_selector` must be a valid selector.
188        /// - `argument` should be of the correct type.
189        #[unsafe(method(arrayByApplyingSelector:withObject:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn arrayByApplyingSelector_withObject(
192            &self,
193            a_selector: Sel,
194            argument: &AnyObject,
195        ) -> Retained<NSArray<AnyObject>>;
196
197        /// Forces evaluation of the receiver, causing the real object to be returned
198        /// immediately.
199        ///
200        /// This method forces the evaluation of the current object reference (the
201        /// receiver), resulting in the return of the referenced object. By default,
202        /// Scripting Bridge deals with references to objects until you actually request
203        /// some concrete data from them or until you call the `get` method.
204        ///
205        /// - Returns: The object referenced by the receiver.
206        #[unsafe(method(get))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn get(&self) -> Option<Retained<NSArray<ObjectType>>>;
209    );
210}
211
212/// Methods declared on superclass `NSMutableArray`.
213impl<ObjectType: Message> SBElementArray<ObjectType> {
214    extern_methods!(
215        #[unsafe(method(init))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
218
219        #[unsafe(method(initWithCapacity:))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn initWithCapacity(
222            this: Allocated<Self>,
223            num_items: NSUInteger,
224        ) -> Retained<Self>;
225
226        /// # Safety
227        ///
228        /// `coder` possibly has further requirements.
229        #[unsafe(method(initWithCoder:))]
230        #[unsafe(method_family = init)]
231        pub unsafe fn initWithCoder(
232            this: Allocated<Self>,
233            coder: &NSCoder,
234        ) -> Option<Retained<Self>>;
235    );
236}
237
238/// Methods declared on superclass `NSArray`.
239impl<ObjectType: Message> SBElementArray<ObjectType> {
240    extern_methods!(
241        /// # Safety
242        ///
243        /// `objects` must be a valid pointer or null.
244        #[unsafe(method(initWithObjects:count:))]
245        #[unsafe(method_family = init)]
246        pub unsafe fn initWithObjects_count(
247            this: Allocated<Self>,
248            objects: *mut NonNull<ObjectType>,
249            cnt: NSUInteger,
250        ) -> Retained<Self>;
251    );
252}
253
254/// Methods declared on superclass `NSObject`.
255impl<ObjectType: Message> SBElementArray<ObjectType> {
256    extern_methods!(
257        #[unsafe(method(new))]
258        #[unsafe(method_family = new)]
259        pub unsafe fn new() -> Retained<Self>;
260    );
261}