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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
//! 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::*;
use objc2_foundation::*;
use crate::*;
mod private_NSObjectWebScripting {
pub trait Sealed {}
}
/// Category "WebScripting" on [`NSObject`].
#[doc(alias = "WebScripting")]
pub unsafe trait NSObjectWebScripting:
ClassType + Sized + private_NSObjectWebScripting::Sealed
{
extern_methods!(
/// Parameter `selector`: The selector that will be exposed to the script environment.
///
/// Use the returned string as the exported name for the selector
/// in the script environment. It is the responsibility of the class to ensure
/// uniqueness of the returned name. If nil is returned or this
/// method is not implemented the default name for the selector will
/// be used. The default name concatenates the components of the
/// Objective-C selector name and replaces ':' with '_'. '_' characters
/// are escaped with an additional '$', i.e. '_' becomes "$_". '$' are
/// also escaped, i.e.
/// Objective-C name Default script name
/// moveTo:: move__
/// moveTo_ moveTo$_
/// moveTo$_ moveTo$$$_
///
/// Returns: Returns the name to be used to represent the specified selector in the
/// scripting environment.
#[unsafe(method(webScriptNameForSelector:))]
#[unsafe(method_family = none)]
unsafe fn webScriptNameForSelector(selector: Option<Sel>) -> Option<Retained<NSString>>;
/// Parameter `selector`: The selector the will be exposed to the script environment.
///
/// Return NO to export the selector to the script environment.
/// Return YES to prevent the selector from being exported to the script environment.
/// If this method is not implemented on the class no selectors will be exported.
///
/// Returns: Returns YES to hide the selector, NO to export the selector.
#[unsafe(method(isSelectorExcludedFromWebScript:))]
#[unsafe(method_family = none)]
unsafe fn isSelectorExcludedFromWebScript(selector: Option<Sel>) -> bool;
/// Parameter `name`: The name of the instance variable that will be exposed to the
/// script environment. Only instance variables that meet the export criteria will
/// be exposed.
///
/// Provide an alternate name for a property.
///
/// Returns: Returns the name to be used to represent the specified property in the
/// scripting environment.
#[unsafe(method(webScriptNameForKey:))]
#[unsafe(method_family = none)]
unsafe fn webScriptNameForKey(name: *const c_char) -> Option<Retained<NSString>>;
/// Parameter `name`: The name of the instance variable that will be exposed to the
/// script environment.
///
/// Return NO to export the property to the script environment.
/// Return YES to prevent the property from being exported to the script environment.
///
/// Returns: Returns YES to hide the property, NO to export the property.
#[unsafe(method(isKeyExcludedFromWebScript:))]
#[unsafe(method_family = none)]
unsafe fn isKeyExcludedFromWebScript(name: *const c_char) -> bool;
/// Parameter `name`: The name of the method to invoke.
///
/// Parameter `arguments`: The arguments to pass the method.
///
/// If a script attempts to invoke a method that is not exported,
/// invokeUndefinedMethodFromWebScript:withArguments: will be called.
///
/// Returns: The return value of the invocation. The value will be converted as appropriate
/// for the script environment.
#[unsafe(method(invokeUndefinedMethodFromWebScript:withArguments:))]
#[unsafe(method_family = none)]
unsafe fn invokeUndefinedMethodFromWebScript_withArguments(
&self,
name: Option<&NSString>,
arguments: Option<&NSArray>,
) -> Option<Retained<AnyObject>>;
/// Parameter `arguments`: The arguments to pass the method.
///
/// If a script attempts to call an exposed object as a function,
/// this method will be called.
///
/// Returns: The return value of the call. The value will be converted as appropriate
/// for the script environment.
#[unsafe(method(invokeDefaultMethodWithArguments:))]
#[unsafe(method_family = none)]
unsafe fn invokeDefaultMethodWithArguments(
&self,
arguments: Option<&NSArray>,
) -> Option<Retained<AnyObject>>;
/// finalizeForScript is called on objects exposed to the script
/// environment just before the script environment garbage collects the object.
/// Subsequently, any references to WebScriptObjects made by the exposed object will
/// be invalid and have undefined consequences.
#[unsafe(method(finalizeForWebScript))]
#[unsafe(method_family = none)]
unsafe fn finalizeForWebScript(&self);
);
}
impl private_NSObjectWebScripting::Sealed for NSObject {}
unsafe impl NSObjectWebScripting for NSObject {}
extern_class!(
/// WebScriptObjects are used to wrap script objects passed from
/// script environments to Objective-C. WebScriptObjects cannot be created
/// directly. In normal uses of WebKit, you gain access to the script
/// environment using the "windowScriptObject" method on WebView.
///
/// The following KVC methods are commonly used to access properties of the
/// WebScriptObject:
///
/// - (void)setValue:(id)value forKey:(NSString *)key
/// - (id)valueForKey:(NSString *)key
///
/// As it possible to remove attributes from web script objects, the following
/// additional method augments the basic KVC methods:
///
/// - (void)removeWebScriptKey:(NSString *)name;
///
/// Also, since the sparse array access allowed in script objects doesn't map well
/// to NSArray, the following methods can be used to access index based properties:
///
/// - (id)webScriptValueAtIndex:(unsigned)index;
/// - (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value;
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/webscriptobject?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated]
pub struct WebScriptObject;
);
unsafe impl NSObjectProtocol for WebScriptObject {}
impl WebScriptObject {
extern_methods!(
/// Throws an exception in the current script execution context.
///
/// Returns: Either NO if an exception could not be raised, YES otherwise.
#[deprecated]
#[unsafe(method(throwException:))]
#[unsafe(method_family = none)]
pub unsafe fn throwException(exception_message: Option<&NSString>) -> bool;
/// Parameter `name`: The name of the method to call in the script environment.
///
/// Parameter `arguments`: The arguments to pass to the script environment.
///
/// Calls the specified method in the script environment using the
/// specified arguments.
///
/// Returns: Returns the result of calling the script method.
/// Returns WebUndefined when an exception is thrown in the script environment.
#[deprecated]
#[unsafe(method(callWebScriptMethod:withArguments:))]
#[unsafe(method_family = none)]
pub unsafe fn callWebScriptMethod_withArguments(
&self,
name: Option<&NSString>,
arguments: Option<&NSArray>,
) -> Option<Retained<AnyObject>>;
/// Parameter `script`: The script to execute in the target script environment.
///
/// The script will be executed in the target script environment. The format
/// of the script is dependent of the target script environment.
///
/// Returns: Returns the result of evaluating the script in the script environment.
/// Returns WebUndefined when an exception is thrown in the script environment.
#[deprecated]
#[unsafe(method(evaluateWebScript:))]
#[unsafe(method_family = none)]
pub unsafe fn evaluateWebScript(
&self,
script: Option<&NSString>,
) -> Option<Retained<AnyObject>>;
/// Parameter `name`: The name of the property to remove.
///
/// Removes the property from the object in the script environment.
#[deprecated]
#[unsafe(method(removeWebScriptKey:))]
#[unsafe(method_family = none)]
pub unsafe fn removeWebScriptKey(&self, name: Option<&NSString>);
/// Converts the target object to a string representation. The coercion
/// of non string objects type is dependent on the script environment.
///
/// Returns: Returns the string representation of the object.
#[deprecated]
#[unsafe(method(stringRepresentation))]
#[unsafe(method_family = none)]
pub unsafe fn stringRepresentation(&self) -> Option<Retained<NSString>>;
/// Parameter `index`: The index of the property to return.
///
/// Gets the value of the property at the specified index.
///
/// Returns: The value of the property. Returns WebUndefined when an exception is
/// thrown in the script environment.
#[deprecated]
#[unsafe(method(webScriptValueAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn webScriptValueAtIndex(&self, index: c_uint) -> Option<Retained<AnyObject>>;
/// Parameter `index`: The index of the property to set.
///
/// Parameter `value`: The value of the property to set.
///
/// Sets the property value at the specified index.
#[deprecated]
#[unsafe(method(setWebScriptValueAtIndex:value:))]
#[unsafe(method_family = none)]
pub unsafe fn setWebScriptValueAtIndex_value(
&self,
index: c_uint,
value: Option<&AnyObject>,
);
/// Parameter `description`: The description of the exception.
///
/// Raises an exception in the script environment in the context of the
/// current object.
#[deprecated]
#[unsafe(method(setException:))]
#[unsafe(method_family = none)]
pub unsafe fn setException(&self, description: Option<&NSString>);
);
}
/// Methods declared on superclass `NSObject`.
impl WebScriptObject {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/webkit/webundefined?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated]
pub struct WebUndefined;
);
unsafe impl NSCoding for WebUndefined {}
unsafe impl NSCopying for WebUndefined {}
unsafe impl CopyingHelper for WebUndefined {
type Result = Self;
}
unsafe impl NSObjectProtocol for WebUndefined {}
impl WebUndefined {
extern_methods!(
/// Returns: The WebUndefined shared instance.
#[deprecated]
#[unsafe(method(undefined))]
#[unsafe(method_family = none)]
pub unsafe fn undefined() -> Option<Retained<WebUndefined>>;
);
}
/// Methods declared on superclass `NSObject`.
impl WebUndefined {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}