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