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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use crate::*;
#[cfg(feature = "objc2")]
extern_protocol!(
/// JSExport provides a declarative way to export Objective-C objects and
/// classes -- including properties, instance methods, class methods, and
/// initializers -- to JavaScript.
///
/// When an Objective-C object is exported to JavaScript, a JavaScript
/// wrapper object is created.
///
/// In JavaScript, inheritance works via a chain of prototype objects.
/// For each Objective-C class in each JSContext, an object appropriate for use
/// as a prototype will be provided. For the class NSObject the prototype
/// will be the Object prototype. For all other Objective-C
/// classes a prototype will be created. The prototype for a given
/// Objective-C class will have its internal [Prototype] property set to point to
/// the prototype created for the Objective-C class's superclass. As such the
/// prototype chain for a JavaScript wrapper object will reflect the wrapped
/// Objective-C type's inheritance hierarchy.
///
/// JavaScriptCore also produces a constructor for each Objective-C class. The
/// constructor has a property named 'prototype' that references the prototype,
/// and the prototype has a property named 'constructor' that references the
/// constructor.
///
/// By default JavaScriptCore does not export any methods or properties from an
/// Objective-C class to JavaScript; however methods and properties may be exported
/// explicitly using JSExport. For each protocol that a class conforms to, if the
/// protocol incorporates the protocol JSExport, JavaScriptCore exports the methods
/// and properties in that protocol to JavaScript
///
/// For each exported instance method JavaScriptCore will assign a corresponding
/// JavaScript function to the prototype. For each exported Objective-C property
/// JavaScriptCore will assign a corresponding JavaScript accessor to the prototype.
/// For each exported class method JavaScriptCore will assign a corresponding
/// JavaScript function to the constructor. For example:
///
/// <pre>
///
/// ```text
/// @protocol MyClassJavaScriptMethods <JSExport>
/// - (void)foo;
/// @end
///
/// @interface MyClass : NSObject <MyClassJavaScriptMethods>
/// - (void)foo;
/// - (void)bar;
/// @end
/// ```
///
/// </pre>
///
/// Data properties that are created on the prototype or constructor objects have
/// the attributes:
/// <code>
/// writable:true
/// </code>
/// ,
/// <code>
/// enumerable:false
/// </code>
/// ,
/// <code>
/// configurable:true
/// </code>
/// .
/// Accessor properties have the attributes:
/// <code>
/// enumerable:false
/// </code>
/// and
/// <code>
/// configurable:true
/// </code>
/// .
///
/// If an instance of
/// <code>
/// MyClass
/// </code>
/// is converted to a JavaScript value, the resulting
/// wrapper object will (via its prototype) export the method
/// <code>
/// foo
/// </code>
/// to JavaScript,
/// since the class conforms to the
/// <code>
/// MyClassJavaScriptMethods
/// </code>
/// protocol, and this
/// protocol incorporates
/// <code>
/// JSExport
/// </code>
/// .
/// <code>
/// bar
/// </code>
/// will not be exported.
///
/// JSExport supports properties, arguments, and return values of the following types:
///
/// Primitive numbers: signed values up to 32-bits convert using JSValue's
/// valueWithInt32/toInt32. Unsigned values up to 32-bits convert using JSValue's
/// valueWithUInt32/toUInt32. All other numeric values convert using JSValue's
/// valueWithDouble/toDouble.
///
/// BOOL: values convert using JSValue's valueWithBool/toBool.
///
/// id: values convert using JSValue's valueWithObject/toObject.
///
/// Objective-C instance pointers: Pointers convert using JSValue's
/// valueWithObjectOfClass/toObject.
///
/// C structs: C structs for CGPoint, NSRange, CGRect, and CGSize convert using
/// JSValue's appropriate methods. Other C structs are not supported.
///
/// Blocks: Blocks convert using JSValue's valueWithObject/toObject.
///
/// All objects that conform to JSExport convert to JavaScript wrapper objects,
/// even if they subclass classes that would otherwise behave differently. For
/// example, if a subclass of NSString conforms to JSExport, it converts to
/// JavaScript as a wrapper object rather than a JavaScript string.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsexport?language=objc)
#[cfg(feature = "objc2")]
pub unsafe trait JSExport {}
);