forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
320 lines (297 loc) · 16.6 KB
/
Copy pathindex.html
File metadata and controls
320 lines (297 loc) · 16.6 KB
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScriptKit - JSObject</title>
<link rel="stylesheet" type="text/css" href="/JavaScriptKit/all.css" media="all" />
</head>
<body>
<header>
<a href="/JavaScriptKit">
<strong>
JavaScriptKit
</strong>
<span>Documentation</span>
</a>
<sup>Beta</sup>
</header>
<!--
<form class="search">
<input type="search" placeholder="Search" />
</form>
-->
<nav>
<div class="wrapper">
<h2>On This Page</h2>
<ol><li><a href="#relationships">Relationships</a><ul><li><a href="#relationships">Subclasses</a></li><li><a href="#relationships">Conforms To</a></li></ul></li><li><a href="#properties">Properties</a><ul><li class="variable"><a href="#jsobject.`throwing`">`throwing`</a></li><li class="variable"><a href="#jsobject.global">global</a></li><li class="variable"><a href="#jsobject.description">description</a></li></ul></li><li><a href="#methods">Methods</a><ul><li class="function"><a href="#jsobject.isinstanceof(_:)">isInstanceOf(_:)</a></li><li class="function"><a href="#jsobject.==(lhs:rhs:)">==(lhs:rhs:)</a></li><li class="function"><a href="#jsobject.construct(from:)">construct(from:)</a></li><li class="function"><a href="#jsobject.jsvalue()">jsValue()</a></li></ul></li></ol>
</div>
</nav>
<main>
<article>
<h1>
<small>Class</small>
<code class="name">JSObject</code>
</h1>
<html><body><pre class="highlight"><code><span class="attribute">@</span><span class="attribute">dynamicMemberLookup</span> <span class="keyword">public</span> <span class="keyword">class</span> <span class="type">JSObject</span>: <span class="type">Equatable</span></code></pre></body></html>
<div class="summary" role="doc-abstract">
<p><code>JSObject</code> represents an object in JavaScript and supports dynamic member lookup.
Any member access like <code>object.foo</code> will dynamically request the JavaScript and Swift
runtime bridge library for a member with the specified name in this object.</p>
</div>
<div class="discussion">
<p>And this object supports to call a member method of the object.</p>
<p>e.g.</p>
<html><body><pre class="highlight"><code><span class="keyword">let</span> <span class="variable">document</span> = <span class="variable">JSObject</span>.<span class="type">global</span>.<span class="type">document</span>.<span class="type">object</span>!
<span class="keyword">let</span> <span class="variable">divElement</span> = <span class="variable">document</span>.<span class="type">createElement</span>!(<span class="string literal">"</span><span class="string literal">div</span><span class="string literal">"</span>)
</code></pre></body></html>
<p>The lifetime of this object is managed by the JavaScript and Swift runtime bridge library with
reference counting system.</p>
</div>
<section id="relationships">
<h2 hidden>Relationships</h2>
<figure>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %3 Pages: 1 -->
<svg width="1301pt" height="268pt"
viewBox="0.00 0.00 1300.77 268.35" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 264.3469)">
<title>%3</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-264.3469 1296.7682,-264.3469 1296.7682,4 -4,4"/>
<!-- JSObject -->
<g id="node1" class="node class current">
<title>JSObject</title>
<g id="a_node1"><a xlink:href="/JavaScriptKit/JSObject" xlink:title="JSObject">
<path fill="none" stroke="#000000" stroke-width="3" d="M751.2908,-138.5683C751.2908,-138.5683 559.2908,-138.5683 559.2908,-138.5683 553.2908,-138.5683 547.2908,-132.5683 547.2908,-126.5683 547.2908,-126.5683 547.2908,-114.5683 547.2908,-114.5683 547.2908,-108.5683 553.2908,-102.5683 559.2908,-102.5683 559.2908,-102.5683 751.2908,-102.5683 751.2908,-102.5683 757.2908,-102.5683 763.2908,-108.5683 763.2908,-114.5683 763.2908,-114.5683 763.2908,-126.5683 763.2908,-126.5683 763.2908,-132.5683 757.2908,-138.5683 751.2908,-138.5683"/>
<text text-anchor="middle" x="655.2908" y="-116.8683" font-family="Menlo" font-size="14.00" fill="#000000">JSObject</text>
</a>
</g>
</g>
<!-- Equatable -->
<g id="node3" class="node unknown">
<title>Equatable</title>
<path fill="none" stroke="#000000" d="M445.6007,-36C445.6007,-36 253.6007,-36 253.6007,-36 247.6007,-36 241.6007,-30 241.6007,-24 241.6007,-24 241.6007,-12 241.6007,-12 241.6007,-6 247.6007,0 253.6007,0 253.6007,0 445.6007,0 445.6007,0 451.6007,0 457.6007,-6 457.6007,-12 457.6007,-12 457.6007,-24 457.6007,-24 457.6007,-30 451.6007,-36 445.6007,-36"/>
<text text-anchor="middle" x="349.6007" y="-14.3" font-family="Menlo" font-size="14.00" fill="#000000">Equatable</text>
</g>
<!-- JSObject->Equatable -->
<g id="edge2" class="edge conformsTo">
<title>JSObject->Equatable</title>
<path fill="none" stroke="#000000" d="M601.3432,-102.4672C548.7121,-84.8079 468.6635,-57.9492 413.0141,-39.2771"/>
<polygon fill="#000000" stroke="#000000" points="413.8594,-35.869 403.2654,-36.0061 411.6326,-42.5054 413.8594,-35.869"/>
</g>
<!-- CustomStringConvertible -->
<g id="node6" class="node unknown">
<title>CustomStringConvertible</title>
<path fill="none" stroke="#000000" d="M724.5289,-260.3469C724.5289,-260.3469 532.5289,-260.3469 532.5289,-260.3469 526.5289,-260.3469 520.5289,-254.3469 520.5289,-248.3469 520.5289,-248.3469 520.5289,-236.3469 520.5289,-236.3469 520.5289,-230.3469 526.5289,-224.3469 532.5289,-224.3469 532.5289,-224.3469 724.5289,-224.3469 724.5289,-224.3469 730.5289,-224.3469 736.5289,-230.3469 736.5289,-236.3469 736.5289,-236.3469 736.5289,-248.3469 736.5289,-248.3469 736.5289,-254.3469 730.5289,-260.3469 724.5289,-260.3469"/>
<text text-anchor="middle" x="628.5289" y="-238.6469" font-family="Menlo" font-size="14.00" fill="#000000">CustomStringConvertible</text>
</g>
<!-- JSObject->CustomStringConvertible -->
<g id="edge3" class="edge conformsTo">
<title>JSObject->CustomStringConvertible</title>
<path fill="none" stroke="#000000" d="M651.2843,-138.7998C646.9092,-158.7085 639.8471,-190.8442 634.7498,-214.039"/>
<polygon fill="#000000" stroke="#000000" points="631.2908,-213.4726 632.5628,-223.9908 638.1277,-214.9751 631.2908,-213.4726"/>
</g>
<!-- JSClosure -->
<g id="node2" class="node class">
<title>JSClosure</title>
<g id="a_node2"><a xlink:href="/JavaScriptKit/JSClosure" xlink:title="JSClosure">
<path fill="none" stroke="#000000" d="M1113.609,-44.7481C1113.609,-44.7481 921.609,-44.7481 921.609,-44.7481 915.609,-44.7481 909.609,-38.7481 909.609,-32.7481 909.609,-32.7481 909.609,-20.7481 909.609,-20.7481 909.609,-14.7481 915.609,-8.7481 921.609,-8.7481 921.609,-8.7481 1113.609,-8.7481 1113.609,-8.7481 1119.609,-8.7481 1125.609,-14.7481 1125.609,-20.7481 1125.609,-20.7481 1125.609,-32.7481 1125.609,-32.7481 1125.609,-38.7481 1119.609,-44.7481 1113.609,-44.7481"/>
<text text-anchor="middle" x="1017.609" y="-23.0481" font-family="Menlo" font-size="14.00" fill="#000000">JSClosure</text>
</a>
</g>
</g>
<!-- JSClosure->JSObject -->
<g id="edge4" class="edge inheritsFrom">
<title>JSClosure->JSObject</title>
<path fill="none" stroke="#000000" d="M947.7504,-44.8376C886.8501,-60.6073 798.5514,-83.4718 734.9265,-99.9471"/>
<polygon fill="#000000" stroke="#000000" points="733.7383,-96.6393 724.9349,-102.5343 735.4931,-103.4158 733.7383,-96.6393"/>
</g>
<!-- JSOneshotClosure -->
<g id="node4" class="node class">
<title>JSOneshotClosure</title>
<g id="a_node4"><a xlink:href="/JavaScriptKit/JSOneshotClosure" xlink:title="JSOneshotClosure">
<path fill="none" stroke="#000000" d="M204,-170.5843C204,-170.5843 12,-170.5843 12,-170.5843 6,-170.5843 0,-164.5843 0,-158.5843 0,-158.5843 0,-146.5843 0,-146.5843 0,-140.5843 6,-134.5843 12,-134.5843 12,-134.5843 204,-134.5843 204,-134.5843 210,-134.5843 216,-140.5843 216,-146.5843 216,-146.5843 216,-158.5843 216,-158.5843 216,-164.5843 210,-170.5843 204,-170.5843"/>
<text text-anchor="middle" x="108" y="-148.8843" font-family="Menlo" font-size="14.00" fill="#000000">JSOneshotClosure</text>
</a>
</g>
</g>
<!-- JSOneshotClosure->JSObject -->
<g id="edge5" class="edge inheritsFrom">
<title>JSOneshotClosure->JSObject</title>
<path fill="none" stroke="#000000" d="M216.1271,-146.259C308.5512,-140.8522 441.3266,-133.085 536.6537,-127.5084"/>
<polygon fill="#000000" stroke="#000000" points="537.1426,-130.9859 546.9211,-126.9078 536.7337,-123.9979 537.1426,-130.9859"/>
</g>
<!-- JSFunction -->
<g id="node5" class="node class">
<title>JSFunction</title>
<g id="a_node5"><a xlink:href="/JavaScriptKit/JSFunction" xlink:title="JSFunction">
<path fill="none" stroke="#000000" d="M1280.7682,-182.7551C1280.7682,-182.7551 1088.7682,-182.7551 1088.7682,-182.7551 1082.7682,-182.7551 1076.7682,-176.7551 1076.7682,-170.7551 1076.7682,-170.7551 1076.7682,-158.7551 1076.7682,-158.7551 1076.7682,-152.7551 1082.7682,-146.7551 1088.7682,-146.7551 1088.7682,-146.7551 1280.7682,-146.7551 1280.7682,-146.7551 1286.7682,-146.7551 1292.7682,-152.7551 1292.7682,-158.7551 1292.7682,-158.7551 1292.7682,-170.7551 1292.7682,-170.7551 1292.7682,-176.7551 1286.7682,-182.7551 1280.7682,-182.7551"/>
<text text-anchor="middle" x="1184.7682" y="-161.0551" font-family="Menlo" font-size="14.00" fill="#000000">JSFunction</text>
</a>
</g>
</g>
<!-- JSFunction->JSObject -->
<g id="edge1" class="edge inheritsFrom">
<title>JSFunction->JSObject</title>
<path fill="none" stroke="#000000" d="M1076.6628,-155.7333C988.6208,-148.3859 864.489,-138.0266 773.7613,-130.4551"/>
<polygon fill="#000000" stroke="#000000" points="773.9589,-126.9595 763.7024,-129.6156 773.3766,-133.9352 773.9589,-126.9595"/>
</g>
</g>
</svg>
<figcaption hidden>Inheritance graph for JSObject.</figcaption>
</figure>
<h3>Subclasses</h3>
<dl>
<dt class="class"><code><a href="/JavaScriptKit/JSOneshotClosure">JSOneshotClosure</a></code></dt>
<dd><p><code>JSOneshotClosure</code> is a JavaScript function that can be called only once.</p>
</dd>
<dt class="class"><code><a href="/JavaScriptKit/JSClosure">JSClosure</a></code></dt>
<dd><p><code>JSClosure</code> represents a JavaScript function the body of which is written in Swift.
This type can be passed as a callback handler to JavaScript functions.
Note that the lifetime of <code>JSClosure</code> should be managed by users manually
due to GC boundary between Swift and JavaScript.
For further discussion, see also <a href="https://github.com/swiftwasm/JavaScriptKit/pull/33">swiftwasm/JavaScriptKit #33</a></p>
</dd>
<dt class="class"><code><a href="/JavaScriptKit/JSFunction">JSFunction</a></code></dt>
<dd><p><code>JSFunction</code> represents a function in JavaScript and supports new object instantiation.
This type can be callable as a function using <code>callAsFunction</code>.</p>
</dd>
</dl>
<h3>Conforms To</h3>
<dl>
<dt class="unknown"><code>CustomStringConvertible</code></dt>
<dt class="unknown"><code>Equatable</code></dt>
</dl>
</section>
<section id="properties">
<h2>Properties</h2>
<div role="article" class="variable" id="jsobject.`throwing`">
<h3>
<code>`throwing`</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">var</span> <span class="variable">`throwing`</span>: <a href="/JavaScriptKit/JSThrowingObject"><span class="type">JSThrowingObject</span></a></code></pre></body></html>
<div class="summary" role="doc-abstract">
<p>A modifier to call methods as throwing methods capturing <code>this</code></p>
</div>
<div class="discussion">
<html><body><pre><code class="language-javascript">const animal = {
validateAge: function() {
if (this.age < 0) {
throw new Error("Invalid age");
}
}
}
</code></pre>
</body></html>
<html><body><pre class="highlight"><code><span class="keyword">let</span> <span class="variable">animal</span> = <span class="variable">JSObject</span>.<span class="type">global</span>.<span class="type">animal</span>.<span class="type">object</span>!
<span class="keyword">try</span> <span class="variable">animal</span>.<span class="type">throwing</span>.<span class="type">validateAge</span>!()
</code></pre></body></html>
</div>
</div>
<div role="article" class="variable" id="jsobject.global">
<h3>
<code>global</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">let</span> <span class="variable">global</span></code></pre></body></html>
<div class="summary" role="doc-abstract">
<p>A <code>JSObject</code> of the global scope object.
This allows access to the global properties and global names by accessing the <code>JSObject</code> returned.</p>
</div>
</div>
<div role="article" class="variable" id="jsobject.description">
<h3>
<code>description</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">var</span> <span class="variable">description</span>: <span class="type">String</span></code></pre></body></html>
</div>
</section>
<section id="methods">
<h2>Methods</h2>
<div role="article" class="function" id="jsobject.isinstanceof(_:)">
<h3>
<code>isInstanceOf(_:)</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">isInstanceOf</span>(<span class="keyword">_</span> <span class="variable">constructor</span>: <a href="/JavaScriptKit/JSFunction"><span class="type">JSFunction</span></a>) -> <span class="type">Bool</span></code></pre></body></html>
<div class="summary" role="doc-abstract">
<p>Return <code>true</code> if this value is an instance of the passed <code>constructor</code> function.</p>
</div>
<h4>Parameters</h4>
<table class="parameters">
<thead hidden>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>constructor</th>
<td><code class="type">JSFunction</code></td>
<td><p>The constructor function to check.</p>
</td>
</tr>
</tbody>
</table>
<h4>Returns</h4>
<p>The result of <code>instanceof</code> in the JavaScript environment.</p>
</div>
<div role="article" class="function" id="jsobject.==(lhs:rhs:)">
<h3>
<code>==(lhs:rhs:)</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">func</span> ==(<span class="variable">lhs</span>: <a href="/JavaScriptKit/JSObject"><span class="type">JSObject</span></a>, <span class="variable">rhs</span>: <a href="/JavaScriptKit/JSObject"><span class="type">JSObject</span></a>) -> <span class="type">Bool</span></code></pre></body></html>
<div class="summary" role="doc-abstract">
<p>Returns a Boolean value indicating whether two values point to same objects.</p>
</div>
<h4>Parameters</h4>
<table class="parameters">
<thead hidden>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>lhs</th>
<td><code class="type">JSObject</code></td>
<td><p>A object to compare.</p>
</td>
</tr>
<tr>
<th>rhs</th>
<td><code class="type">JSObject</code></td>
<td><p>Another object to compare.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div role="article" class="function" id="jsobject.construct(from:)">
<h3>
<code>construct(from:)</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">public</span> <span class="keyword">class</span> <span class="keyword">func</span> <span class="function">construct</span>(<span class="variable">from</span> <span class="variable">value</span>: <a href="/JavaScriptKit/JSValue"><span class="type">JSValue</span></a>) -> <span class="keyword">Self</span>?</code></pre></body></html>
</div>
<div role="article" class="function" id="jsobject.jsvalue()">
<h3>
<code>jsValue()</code>
</h3>
<html><body><pre class="highlight"><code><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">jsValue</span>() -> <a href="/JavaScriptKit/JSValue"><span class="type">JSValue</span></a></code></pre></body></html>
</div>
</section>
</article>
</main>
<footer>
<p>
Generated on <time datetime="2021-01-21T17:19:15+0000">January 21, 2021</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a> <span class="version">1.0.0-beta.5</span>.
</p>
</footer>
</body>
</html>