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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
//! 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::*;
#[cfg(feature = "objc2-core-services")]
use objc2_core_services::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// The `SBObject` class declares methods that can be invoked on any object in a
/// scriptable application. It defines methods for getting elements and
/// properties of an object, as well as setting a given object to a new value.
///
/// Each `SBObject` is built around an object specifier, which tells Scripting
/// Bridge how to locate the object. Therefore, you can think of an `SBObject`
/// as a reference to an object in an target application rather than an object
/// itself. To bypass this reference-based approach and force evaluation, use
/// the ``SBObject/get`` method.
///
/// Typically, rather than create `SBObject` instances explictly, you receive
/// `SBObject` objects by calling methods of an ``SBApplication`` subclass. For
/// example, if you wanted to get an `SBObject` representing the current iTunes
/// track, you would use code like this (where `iTunesTrack` is a subclass of
/// `SBObject`):
///
/// ```objc
/// iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:
/// "
/// com.apple.iTunes"];
/// iTunesTrack *track = [iTunes currentTrack];
/// ```
///
/// You can discover the names of dynamically generated classes such as
/// `iTunesApplication` and `iTunesTrack` by examining the header file created
/// by the `sdp` tool. Alternatively, you give these variables the dynamic
/// Objective-C type `id`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/scriptingbridge/sbobject?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct SBObject;
);
extern_conformance!(
unsafe impl NSCoding for SBObject {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for SBObject {}
);
impl SBObject {
extern_methods!(
/// Initializes and returns an instance of an `SBObject` subclass.
///
/// Scripting Bridge does not actually create an object in the target
/// application until you add the object returned from this method to an element
/// array (``SBElementArray``).
///
/// - Returns: An `SBObject` object or `nil` if the object could not be
/// initialized.
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Returns an instance of an `SBObject` subclass initialized with the specified
/// properties.
///
/// Scripting Bridge does not actually create an object in the target
/// application until you add the object returned from this method to an element
/// array (``SBElementArray``).
///
/// - Parameters:
/// - properties: A dictionary with keys specifying the names of properties
/// (that is, attributes or to-one relationships) and the values for those
/// properties.
///
/// - Returns: An `SBObject` object or `nil` if the object could not be
/// initialized.
///
/// # Safety
///
/// `properties` generic should be of the correct type.
#[unsafe(method(initWithProperties:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithProperties(
this: Allocated<Self>,
properties: &NSDictionary,
) -> Retained<Self>;
/// Returns an instance of an `SBObject` subclass initialized with the given
/// data.
///
/// Scripting Bridge does not actually create an object in the target
/// application until you add the object returned from this method to an element
/// array (``SBElementArray``).
///
/// - Parameters:
/// - data: An object containing data for the new `SBObject` object. The data
/// varies according to the type of scripting object to be created.
///
/// - Returns: An `SBObject` object or `nil` if the object could not be
/// initialized.
///
/// # Safety
///
/// `data` should be of the correct type.
#[unsafe(method(initWithData:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithData(this: Allocated<Self>, data: &AnyObject) -> Retained<Self>;
/// Forces evaluation of the receiver, causing the real object to be returned
/// immediately.
///
/// This method forces the current object reference (the receiver) to be
/// evaluated, 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: For most properties, the result is a Foundation object such as an `NSString`. For properties with no Foundation equivalent, the result is an `NSAppleEventDescriptor` or another ``SBObject`` for most elements.
#[unsafe(method(get))]
#[unsafe(method_family = none)]
pub unsafe fn get(&self) -> Option<Retained<AnyObject>>;
/// The error from the last event this object sent, or nil if it succeeded.
#[unsafe(method(lastError))]
#[unsafe(method_family = none)]
pub unsafe fn lastError(&self) -> Option<Retained<NSError>>;
);
}
/// Methods declared on superclass `NSObject`.
impl SBObject {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// SBGlueInterface.
impl SBObject {
extern_methods!(
#[cfg(feature = "objc2-core-services")]
/// Returns an instance of an `SBObject` subclass initialized with the specified
/// properties and data and added to the designated element array.
///
/// Unlike the other initializers of this class, this method not only
/// initializes the `SBObject` object but adds it to a specified element array.
/// This method is the designated initializer.
///
/// - Parameters:
/// - code: A four-character code used to identify an element in the target
/// application’s scripting interface. See
/// <doc
/// ://com.apple.documentation/documentation/applicationservices/apple_event_manager>
/// for details.
///
/// - properties: A dictionary with
/// <doc
/// ://com.apple.documentation/documentation/foundation/nsnumber> keys specifying the four-character codes of properties
/// (that is, attributes or to-one relationships) and the values for those
/// properties. Pass `nil` if you are initializing the object by `data` only.
///
/// - data: An object containing data for the new `SBObject` object. The data
/// varies according to the type of scripting object to be created. Pass `nil`
/// if you initializing the object by `properties` only.
///
/// - Returns: An `SBObject` object or `nil` if the object could not be
/// initialized.
///
/// # Safety
///
/// - `properties` generic should be of the correct type.
/// - `data` should be of the correct type.
#[unsafe(method(initWithElementCode:properties:data:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithElementCode_properties_data(
this: Allocated<Self>,
code: DescType,
properties: Option<&NSDictionary<NSString, AnyObject>>,
data: Option<&AnyObject>,
) -> Retained<Self>;
#[cfg(feature = "objc2-core-services")]
/// Returns an object representing the specified property of the receiver.
///
/// `SBObject` subclasses use this method to implement application-specific
/// property accessor methods. You should not need to call this method directly.
///
/// - Parameters:
/// - code: A four-character code that uniquely identifies a property of the
/// receiver.
///
/// - Returns: An object representing the receiver’s property as identified by
/// `code`.
#[unsafe(method(propertyWithCode:))]
#[unsafe(method_family = none)]
pub unsafe fn propertyWithCode(&self, code: AEKeyword) -> Retained<SBObject>;
#[cfg(feature = "objc2-core-services")]
/// Returns an object of the designated scripting class representing the
/// specified property of the receiver
///
/// `SBObject` subclasses use this method to implement application-specific
/// property accessor methods. You should not need to call this method directly.
///
/// > Note: This method doesn't retrieve the value of the property. To get the
/// value, call ``get``.
///
/// - Parameters:
/// - class: The `SBObject` subclass with which to instantiate the object.
///
/// - code: A four-character code that uniquely identifies a property of the
/// receiver.
///
/// - Returns: An instance of the designated `class` that represents the
/// receiver’s property identified by `code`.
///
/// # Safety
///
/// `cls` probably has further requirements.
#[unsafe(method(propertyWithClass:code:))]
#[unsafe(method_family = none)]
pub unsafe fn propertyWithClass_code(
&self,
cls: &AnyClass,
code: AEKeyword,
) -> Retained<SBObject>;
#[cfg(all(feature = "SBElementArray", feature = "objc2-core-services"))]
/// Returns an array containing every child of the receiver with the given
/// class-type code.
///
/// `SBObject` subclasses use this method to implement application-specific
/// property accessor methods. You should not need to call this method directly.
///
/// > Note: This method doesn't retrieve the value of the property. To get the
/// value, call ``get``.
///
/// - Parameters:
/// - code: A four-character code that identifies a scripting class.
///
/// - Returns: An ``SBElementArray`` object containing every child of the
/// receiver whose class matches `code`.
#[unsafe(method(elementArrayWithCode:))]
#[unsafe(method_family = none)]
pub unsafe fn elementArrayWithCode(&self, code: DescType) -> Retained<SBElementArray>;
/// Sets the receiver to a specified value.
///
/// You should not call this method directly.
///
/// - Parameters:
/// - value: The data the receiver should be set to. It can be an
/// <doc
/// ://com.apple.documentation/documentation/foundation/nsstring>,
/// <doc
/// ://com.apple.documentation/documentation/foundation/nsnumber>,
/// <doc
/// ://com.apple.documentation/documentation/foundation/nsarray>,
/// `SBObject`, or any other type of object supported by the Scripting Bridge
/// framework.
///
/// # Safety
///
/// `value` should be of the correct type.
#[unsafe(method(setTo:))]
#[unsafe(method_family = none)]
pub unsafe fn setTo(&self, value: Option<&AnyObject>);
);
}