@idlizer/core 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/build/lib/src/IndentedPrinter.d.ts +28 -0
  2. package/build/lib/src/IndentedPrinter.js +81 -0
  3. package/build/lib/src/Language.d.ts +15 -0
  4. package/build/lib/src/Language.js +42 -0
  5. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +318 -0
  6. package/build/lib/src/LanguageWriters/ArgConvertors.js +1015 -0
  7. package/build/lib/src/LanguageWriters/InteropConvertor.d.ts +36 -0
  8. package/build/lib/src/LanguageWriters/InteropConvertor.js +174 -0
  9. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +386 -0
  10. package/build/lib/src/LanguageWriters/LanguageWriter.js +746 -0
  11. package/build/lib/src/LanguageWriters/common.d.ts +17 -0
  12. package/build/lib/src/LanguageWriters/common.js +33 -0
  13. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +8 -0
  14. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +35 -0
  15. package/build/lib/src/LanguageWriters/index.d.ts +3 -0
  16. package/build/lib/src/LanguageWriters/index.js +3 -0
  17. package/build/lib/src/LanguageWriters/nameConvertor.d.ts +28 -0
  18. package/build/lib/src/LanguageWriters/nameConvertor.js +61 -0
  19. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +147 -0
  20. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +578 -0
  21. package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +46 -0
  22. package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.js +121 -0
  23. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +116 -0
  24. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +472 -0
  25. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +72 -0
  26. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +329 -0
  27. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +83 -0
  28. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +275 -0
  29. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +93 -0
  30. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +390 -0
  31. package/build/lib/src/LibraryInterface.d.ts +21 -0
  32. package/build/lib/src/LibraryInterface.js +2 -0
  33. package/build/lib/src/config.d.ts +8 -0
  34. package/build/lib/src/config.js +20 -0
  35. package/build/lib/src/from-idl/DtsPrinter.d.ts +35 -0
  36. package/build/lib/src/from-idl/DtsPrinter.js +375 -0
  37. package/build/lib/src/from-idl/common.d.ts +5 -0
  38. package/build/lib/src/from-idl/common.js +83 -0
  39. package/build/lib/src/from-idl/deserialize.d.ts +9 -0
  40. package/build/lib/src/from-idl/deserialize.js +384 -0
  41. package/build/lib/src/from-idl/toString.d.ts +2 -0
  42. package/build/lib/src/from-idl/toString.js +18 -0
  43. package/build/lib/src/from-idl/webidl2-utils.d.ts +20 -0
  44. package/build/lib/src/from-idl/webidl2-utils.js +84 -0
  45. package/build/lib/src/idl.d.ts +404 -0
  46. package/build/lib/src/idl.js +1015 -0
  47. package/build/lib/src/idlize.d.ts +4 -0
  48. package/build/lib/src/idlize.js +52 -0
  49. package/build/lib/src/index.d.ts +34 -0
  50. package/build/lib/src/index.js +48 -0
  51. package/build/lib/src/inheritance.d.ts +16 -0
  52. package/build/lib/src/inheritance.js +76 -0
  53. package/build/lib/src/languageSpecificKeywords.d.ts +5 -0
  54. package/build/lib/src/languageSpecificKeywords.js +51 -0
  55. package/build/lib/src/library.d.ts +67 -0
  56. package/build/lib/src/library.js +190 -0
  57. package/build/lib/src/options.d.ts +11 -0
  58. package/build/lib/src/options.js +16 -0
  59. package/build/lib/src/peer-generation/PrimitiveType.d.ts +24 -0
  60. package/build/lib/src/peer-generation/PrimitiveType.js +52 -0
  61. package/build/lib/src/peer-generation/ReferenceResolver.d.ts +9 -0
  62. package/build/lib/src/peer-generation/ReferenceResolver.js +37 -0
  63. package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +28 -0
  64. package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +82 -0
  65. package/build/lib/src/peer-generation/idl/common.d.ts +9 -0
  66. package/build/lib/src/peer-generation/idl/common.js +70 -0
  67. package/build/lib/src/peer-generation/unions.d.ts +29 -0
  68. package/build/lib/src/peer-generation/unions.js +111 -0
  69. package/build/lib/src/rand_utils.d.ts +6 -0
  70. package/build/lib/src/rand_utils.js +100 -0
  71. package/build/lib/src/util.d.ts +75 -0
  72. package/build/lib/src/util.js +622 -0
  73. package/package.json +49 -0
  74. package/webidl2.js/LICENSE +21 -0
  75. package/webidl2.js/README.md +827 -0
  76. package/webidl2.js/dist/package.json +3 -0
  77. package/webidl2.js/dist/webidl2.js +4547 -0
  78. package/webidl2.js/package.json +55 -0
@@ -0,0 +1,827 @@
1
+ # webidl2.js
2
+
3
+ [![NPM version](https://badge.fury.io/js/webidl2.svg)](http://badge.fury.io/js/webidl2) [![Known Vulnerabilities](https://snyk.io/test/github/w3c/webidl2.js/badge.svg)](https://snyk.io/test/github/w3c/webidl2.js/)
4
+ [![Financial Contributors on Open Collective](https://opencollective.com/webidl2js/all/badge.svg?label=financial+contributors)](https://opencollective.com/webidl2js)
5
+
6
+ ## Purpose
7
+
8
+ This is a parser for [Web IDL](https://heycam.github.io/webidl/), a language
9
+ [to specify web APIs in interoperable way](https://heycam.github.io/webidl/#introduction).
10
+ This library supports both Node.js and the browser environment.
11
+
12
+ Try the online checker [here](https://w3c.github.io/webidl2.js/checker/).
13
+
14
+ ## Installation
15
+
16
+ Just the usual. For Node:
17
+
18
+ ```Bash
19
+ npm install webidl2
20
+ ```
21
+
22
+ In the browser without module support:
23
+
24
+ ```HTML
25
+ <script src='./webidl2/dist/webidl2.js'></script>
26
+ ```
27
+
28
+ ## Documentation
29
+
30
+ WebIDL2 provides two functions: `parse` and `write`.
31
+
32
+ * `parse`: Converts a WebIDL string into a syntax tree.
33
+ * `write`: Converts a syntax tree into a WebIDL string. Useful for programmatic code
34
+ modification.
35
+
36
+ In Node, that happens with:
37
+
38
+ ```JS
39
+ const { parse, write, validate } = require("webidl2");
40
+ const tree = parse("string of WebIDL");
41
+ const text = write(tree);
42
+ const validation = validate(tree);
43
+ ```
44
+
45
+ In the browser:
46
+ ```HTML
47
+ <script>
48
+ const tree = WebIDL2.parse("string of WebIDL");
49
+ const text = WebIDL2.write(tree);
50
+ const validation = WebIDL2.validate(tree);
51
+ </script>
52
+
53
+ <!-- Or when module is supported -->
54
+ <script type="module">
55
+ import { parse, write, validate } from "./webidl2/index.js";
56
+ const tree = parse("string of WebIDL");
57
+ const text = write(tree);
58
+ const validation = validate(tree);
59
+ </script>
60
+ ```
61
+
62
+ `parse()` optionally takes an option bag with the following fields:
63
+
64
+ * `concrete`: Boolean indicating whether the result should include [EOF](#end-of-file)
65
+ node or not.
66
+ * `productions`: An array with custom production functions. See [Custom productions](docs/custom-productions.md) for more information.
67
+ * `sourceName`: The source name, typically a filename. [Errors](#errors) and validation
68
+ objects can indicate their origin if you pass a value.
69
+
70
+ `write()` optionally takes a "templates" object, whose properties are functions that process input in different ways (depending on what is needed for output). Every property is optional. Each property is documented below:
71
+
72
+ ```js
73
+ var result = WebIDL2.write(tree, {
74
+ templates: {
75
+ /**
76
+ * A function that receives syntax strings plus anything the templates returned.
77
+ * The items are guaranteed to be ordered.
78
+ * The returned value may be again passed to any template functions,
79
+ * or it may also be the final return value of `write()`.
80
+ * @param {any[]} items
81
+ */
82
+ wrap: items => items.join(""),
83
+ /**
84
+ * @param {string} t A trivia string, which includes whitespaces and comments.
85
+ */
86
+ trivia: t => t,
87
+ /**
88
+ * The identifier for a container type. For example, the `Foo` part of `interface Foo {};`.
89
+ * @param {string} escaped The escaped raw name of the definition.
90
+ * @param data The definition with the name
91
+ * @param parent The parent of the definition, undefined if absent
92
+ */
93
+ name: (escaped, { data, parent }) => escaped,
94
+ /**
95
+ * Called for each type referece, e.g. `Window`, `DOMString`, or `unsigned long`.
96
+ * @param escaped The referenced name. Typically string, but may also be the return
97
+ * value of `wrap()` if the name contains whitespace.
98
+ * @param unescaped Unescaped reference.
99
+ */
100
+ reference: (escaped, unescaped) => escaped,
101
+ /**
102
+ * Called for each generic-form syntax, e.g. `sequence`, `Promise`, or `maplike`.
103
+ * @param {string} name The keyword for syntax
104
+ */
105
+ generic: name => name,
106
+ /**
107
+ * Called for each nameless members, e.g. `stringifier` for `stringifier;` and `constructor` for `constructor();`
108
+ * @param {string} name The keyword for syntax
109
+ */
110
+ nameless: (keyword, { data, parent }) => keyword,
111
+ /**
112
+ * Called only once for each types, e.g. `Document`, `Promise<DOMString>`, or `sequence<long>`.
113
+ * @param type The `wrap()`ed result of references and syntatic bracket strings.
114
+ */
115
+ type: type => type,
116
+ /**
117
+ * Receives the return value of `reference()`. String if it's absent.
118
+ */
119
+ inheritance: inh => inh,
120
+ /**
121
+ * Called for each IDL type definition, e.g. an interface, an operation, or a typedef.
122
+ * @param content The wrapped value of everything the definition contains.
123
+ * @param data The original definition object
124
+ * @param parent The parent of the definition, undefined if absent
125
+ */
126
+ definition: (content, { data, parent }) => content,
127
+ /**
128
+ * Called for each extended attribute annotation.
129
+ * @param content The wrapped value of everything the annotation contains.
130
+ */
131
+ extendedAttribute: content => content,
132
+ /**
133
+ * The `Foo` part of `[Foo=Whatever]`.
134
+ * @param ref The name of the referenced extended attribute name.
135
+ */
136
+ extendedAttributeReference: ref => ref
137
+ }
138
+ });
139
+ ```
140
+
141
+ "Wrapped value" here will all be raw strings when the `wrap()` callback is absent.
142
+
143
+ `validate()` receives an AST or an array of AST, and returns semantic errors as an
144
+ array of objects. Their fields are same as [errors](#errors) have, with one addition:
145
+
146
+ * `level`: `"error"` or `"warning"`.
147
+
148
+ ```js
149
+ const validations = validate(tree);
150
+ for (const validation of validations) {
151
+ console.log(validation.message);
152
+ }
153
+ // Validation error on line X: ...
154
+ // Validation error on line Y: ...
155
+ ```
156
+
157
+ The validator function may provide an autofix function that modifies AST. You can
158
+ optionally call it to skip manual fixes, but make sure you review the result.
159
+
160
+ ```js
161
+ const validations = validate(tree);
162
+ for (const validation of validations) {
163
+ if (validation.autofix) {
164
+ validation.autofix();
165
+ }
166
+ }
167
+ write(tree); // magic!
168
+ ```
169
+
170
+ ### Errors
171
+
172
+ When there is a syntax error in the WebIDL, it throws an exception object with the following
173
+ properties:
174
+
175
+ * `message`: the error message with its context. Below is what it looks like.
176
+ ```
177
+ Syntax error at line 1 in callback-noparen.webidl, since `callback YourCall`:
178
+ callback YourCall = undefined;
179
+ ^ Callback lacks parentheses for arguments
180
+ ```
181
+ * `bareMessage`: the error message without any context description like below.
182
+ ```
183
+ Callback lacks parentheses for arguments
184
+ ```
185
+ * `line`: the line at which the error occurred.
186
+ * `sourceName`: the source name you passed to `parse()`.
187
+ * `level`: `"error"` by default, can be `"warning"` for some validations for e.g. potential future deprecations.
188
+ * `ruleName`: Only for validations. Currently the followings are supported:
189
+ * `attr-invalid-type`: Attributes cannot have sequences, records, nor dictionaries.
190
+ * `dict-arg-default`: Optional dictionary type arguments must have a default value of `{}`.
191
+ * `dict-arg-optional`: Dictionary type arguments must be optional if the type does not include a required field.
192
+ * `no-nullable-dict-arg`: Dictionary arguments cannot be nullable.
193
+ * `no-nullable-union-dict`: Nullable unions cannot include a dictionary type.
194
+ * `constructor-member`: Constructors must use newer `constructor()` syntax.
195
+ * `no-duplicate`: Types cannot have identical names.
196
+ * `require-exposed`: Interfaces must explicitly expose themselves to specific contexts by `[Exposed]`.
197
+ * `incomplete-op`: Regular or static operations must have both a return type and an identifier.
198
+ * `no-cross-overload`: Overloading must be done within a single interface or namespace.
199
+ * `no-constructible-global`: Interfaces with `[Global]` cannot have constructors.
200
+ * `renamed-legacy`: Legacy extended attributes must use their new names.
201
+ * `replace-void`: `void` type is replaced by `undefined` type.
202
+ * `migrate-allowshared`: `[AllowShared] BufferSource` is replaced by `AllowSharedBufferSource`.
203
+ * `input`: a short peek at the text at the point where the error happened
204
+ * `tokens`: the five tokens at the point of error, as understood by the tokeniser
205
+ (this is the same content as `input`, but seen from the tokeniser's point of view)
206
+
207
+ The exception also has a `toString()` method that hopefully should produce a decent
208
+ error message.
209
+
210
+ ### AST (Abstract Syntax Tree)
211
+
212
+ The `parse()` method returns a tree object representing the parse tree of the IDL.
213
+ Comment and white space are not represented in the AST.
214
+
215
+ The root of this object is always an array of definitions (where definitions are
216
+ any of interfaces, dictionaries, callbacks, etc. — anything that can occur at the root
217
+ of the IDL).
218
+
219
+ ### IDL Type
220
+
221
+ This structure is used in many other places (operation return types, argument types, etc.).
222
+ It captures a WebIDL type with a number of options. Types look like this and are typically
223
+ attached to a field called `idlType`:
224
+
225
+ ```JS
226
+ {
227
+ "type": "attribute-type",
228
+ "generic": "",
229
+ "idlType": "unsigned short",
230
+ "nullable": false,
231
+ "union": false,
232
+ "extAttrs": [...]
233
+ }
234
+ ```
235
+
236
+ Where the fields are as follows:
237
+
238
+ * `type`: String indicating where this type is used. Can be `null` if not applicable.
239
+ * `generic`: String indicating the generic type (e.g. "Promise", "sequence").
240
+ * `idlType`: String indicating the type name, or array of subtypes if the type is
241
+ generic or a union.
242
+ * `nullable`: `true` if the type is nullable.
243
+ * `union`: Boolean indicating whether this is a union type or not.
244
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
245
+
246
+ ### Interface
247
+
248
+ Interfaces look like this:
249
+
250
+ ```JS
251
+ {
252
+ "type": "interface",
253
+ "name": "Animal",
254
+ "partial": false,
255
+ "members": [...],
256
+ "inheritance": null,
257
+ "extAttrs": [...]
258
+ }, {
259
+ "type": "interface",
260
+ "name": "Human",
261
+ "partial": false,
262
+ "members": [...],
263
+ "inheritance": "Animal",
264
+ "extAttrs": [...]
265
+ }
266
+ ```
267
+
268
+ The fields are as follows:
269
+
270
+ * `type`: Always "interface".
271
+ * `name`: The name of the interface.
272
+ * `partial`: `true` if the type is a partial interface.
273
+ * `members`: An array of interface members (attributes, operations, etc.). Empty if there are none.
274
+ * `inheritance`: The name of an interface this one inherits from, `null` otherwise.
275
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
276
+
277
+ ### Interface mixins
278
+
279
+ Interfaces mixins look like this:
280
+
281
+ ```JS
282
+ {
283
+ "type": "interface mixin",
284
+ "name": "Animal",
285
+ "inheritance": null,
286
+ "partial": false,
287
+ "members": [...],
288
+ "extAttrs": [...]
289
+ }, {
290
+ "type": "interface mixin",
291
+ "name": "Human",
292
+ "inheritance": null,
293
+ "partial": false,
294
+ "members": [...],
295
+ "extAttrs": [...]
296
+ }
297
+ ```
298
+
299
+ The fields are as follows:
300
+
301
+ * `type`: Always "interface mixin".
302
+ * `name`: The name of the interface mixin.
303
+ * `inheritance`: Always `null`.
304
+ * `partial`: `true if the type is a partial interface mixin.
305
+ * `members`: An array of interface members (attributes, operations, etc.). Empty if there are none.
306
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
307
+
308
+ ### Namespace
309
+
310
+ Namespaces look like this:
311
+
312
+ ```JS
313
+ {
314
+ "type": "namespace",
315
+ "name": "console",
316
+ "inheritance": null,
317
+ "partial": false,
318
+ "members": [...],
319
+ "extAttrs": [...]
320
+ }
321
+ ```
322
+
323
+ The fields are as follows:
324
+
325
+ * `type`: Always "namespace".
326
+ * `name`: The name of the namespace.
327
+ * `inheritance`: Always `null`.
328
+ * `partial`: `true if the type is a partial namespace.
329
+ * `members`: An array of namespace members (attributes, constants, and operations). Empty if there are none.
330
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
331
+
332
+ ### Callback Interfaces
333
+
334
+ These are captured by the same structure as [Interfaces](#interface) except that
335
+ their `type` field is "callback interface".
336
+
337
+ ### Callback
338
+
339
+ A callback looks like this:
340
+
341
+ ```JS
342
+ {
343
+ "type": "callback",
344
+ "name": "AsyncOperationCallback",
345
+ "idlType": {
346
+ "type": "return-type",
347
+ "generic": "",
348
+ "nullable": false,
349
+ "union": false,
350
+ "idlType": "undefined",
351
+ "extAttrs": []
352
+ },
353
+ "arguments": [...],
354
+ "extAttrs": []
355
+ }
356
+ ```
357
+
358
+ The fields are as follows:
359
+
360
+ * `type`: Always "callback".
361
+ * `name`: The name of the callback.
362
+ * `idlType`: An [IDL Type](#idl-type) describing what the callback returns.
363
+ * `arguments`: A list of [arguments](#arguments), as in function paramters.
364
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
365
+
366
+ ### Dictionary
367
+
368
+ A dictionary looks like this:
369
+
370
+ ```JS
371
+ {
372
+ "type": "dictionary",
373
+ "name": "PaintOptions",
374
+ "partial": false,
375
+ "members": [{
376
+ "type": "field",
377
+ "name": "fillPattern",
378
+ "required": false,
379
+ "idlType": {
380
+ "type": "dictionary-type",
381
+ "generic": "",
382
+ "nullable": true
383
+ "union": false,
384
+ "idlType": "DOMString",
385
+ "extAttrs": []
386
+ },
387
+ "extAttrs": [],
388
+ "default": {
389
+ "type": "string",
390
+ "value": "black"
391
+ }
392
+ }],
393
+ "inheritance": null,
394
+ "extAttrs": []
395
+ }
396
+ ```
397
+
398
+ The fields are as follows:
399
+
400
+ * `type`: Always "dictionary".
401
+ * `name`: The dictionary name.
402
+ * `partial`: `true` if the type is a partial dictionary.
403
+ * `members`: An array of members (see below).
404
+ * `inheritance`: An object indicating which dictionary is being inherited from, `null` otherwise.
405
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
406
+
407
+ All the members are fields as follows:
408
+
409
+ * `type`: Always "field".
410
+ * `name`: The name of the field.
411
+ * `required`: `true` if the field is required.
412
+ * `idlType`: An [IDL Type](#idl-type) describing what field's type.
413
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
414
+ * `default`: A [default value](#default-and-const-values), or `null` if there is none.
415
+
416
+ ### Enum
417
+
418
+ An enum looks like this:
419
+
420
+ ```JS
421
+ {
422
+ "type": "enum",
423
+ "name": "MealType",
424
+ "values": [
425
+ {
426
+ "type": "enum-value",
427
+ "value": "rice"
428
+ },
429
+ {
430
+ "type": "enum-value",
431
+ "value": "noodles"
432
+ },
433
+ {
434
+ "type": "enum-value",
435
+ "value": "other"
436
+ }
437
+ ]
438
+ "extAttrs": []
439
+ }
440
+ ```
441
+
442
+ The fields are as follows:
443
+
444
+ * `type`: Always "enum".
445
+ * `name`: The enum's name.
446
+ * `values`: An array of values. The type of value is "enum-value".
447
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
448
+
449
+ ### Typedef
450
+
451
+ A typedef looks like this:
452
+
453
+ ```JS
454
+ {
455
+ "type": "typedef",
456
+ "idlType": {
457
+ "type": "typedef-type",
458
+ "generic": "sequence",
459
+ "nullable": false,
460
+ "union": false,
461
+ "idlType": [
462
+ {
463
+ "type": "typedef-type",
464
+ "generic": "",
465
+ "nullable": false,
466
+ "union": false,
467
+ "idlType": "Point",
468
+ "extAttrs": [...]
469
+ }
470
+ ],
471
+ "extAttrs": [...]
472
+ },
473
+ "name": "PointSequence",
474
+ "extAttrs": []
475
+ }
476
+ ```
477
+
478
+
479
+ The fields are as follows:
480
+
481
+ * `type`: Always "typedef".
482
+ * `name`: The typedef's name.
483
+ * `idlType`: An [IDL Type](#idl-type) describing what typedef's type.
484
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
485
+
486
+ ### Includes
487
+
488
+ An includes definition looks like this:
489
+
490
+ ```JS
491
+ {
492
+ "type": "includes",
493
+ "target": "Node",
494
+ "includes": "EventTarget",
495
+ "extAttrs": []
496
+ }
497
+ ```
498
+
499
+ The fields are as follows:
500
+
501
+ * `type`: Always "includes".
502
+ * `target`: The interface that includes an interface mixin.
503
+ * `includes`: The interface mixin that is being included by the target.
504
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
505
+
506
+ ### Operation Member
507
+
508
+ An operation looks like this:
509
+
510
+ ```JS
511
+ {
512
+ "type": "operation",
513
+ "special": "",
514
+ "idlType": {
515
+ "type": "return-type",
516
+ "generic": "",
517
+ "nullable": false,
518
+ "union": false,
519
+ "idlType": "undefined",
520
+ "extAttrs": []
521
+ },
522
+ "name": "intersection",
523
+ "arguments": [{
524
+ "default": null,
525
+ "optional": false,
526
+ "variadic": true,
527
+ "extAttrs": [],
528
+ "idlType": {
529
+ "type": "argument-type",
530
+ "generic": "",
531
+ "nullable": false,
532
+ "union": false,
533
+ "idlType": "long",
534
+ "extAttrs": [...]
535
+ },
536
+ "name": "ints"
537
+ }],
538
+ "extAttrs": [],
539
+ "parent": { ... }
540
+ }
541
+ ```
542
+
543
+ The fields are as follows:
544
+
545
+ * `type`: Always "operation".
546
+ * `special`: One of `"getter"`, `"setter"`, `"deleter"`, `"static"`, `"stringifier"`, or `""`.
547
+ * `idlType`: An [IDL Type](#idl-type) of what the operation returns, if exists.
548
+ * `name`: The name of the operation if exists.
549
+ * `arguments`: An array of [arguments](#arguments) for the operation.
550
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
551
+ * `parent`: The container of this type as an Object.
552
+
553
+ ### Constructor Operation Member
554
+
555
+ A constructor operation member looks like this:
556
+
557
+ ```JS
558
+ {
559
+ "type": "constructor",
560
+ "arguments": [{
561
+ "default": null,
562
+ "optional": false,
563
+ "variadic": true,
564
+ "extAttrs": [],
565
+ "idlType": {
566
+ "type": "argument-type",
567
+ "generic": "",
568
+ "nullable": false,
569
+ "union": false,
570
+ "idlType": "long",
571
+ "extAttrs": [...]
572
+ },
573
+ "name": "ints"
574
+ }],
575
+ "extAttrs": [],
576
+ "parent": { ... }
577
+ }
578
+ ```
579
+
580
+ The fields are as follows:
581
+
582
+ * `type`: Always "constructor".
583
+ * `arguments`: An array of [arguments](#arguments) for the constructor operation.
584
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
585
+ * `parent`: The container of this type as an Object.
586
+
587
+ ### Attribute Member
588
+
589
+ An attribute member looks like this:
590
+
591
+ ```JS
592
+ {
593
+ "type": "attribute",
594
+ "special": "",
595
+ "readonly": false,
596
+ "idlType": {
597
+ "type": "attribute-type",
598
+ "generic": "",
599
+ "nullable": false,
600
+ "union": false,
601
+ "idlType": "any",
602
+ "extAttrs": [...]
603
+ },
604
+ "name": "regexp",
605
+ "extAttrs": [],
606
+ "parent": { ... }
607
+ }
608
+ ```
609
+
610
+ The fields are as follows:
611
+
612
+ * `type`: Always "attribute".
613
+ * `name`: The attribute's name.
614
+ * `special`: One of `"static"`, `"stringifier"`, `"inherit"`, or `""`.
615
+ * `readonly`: `true` if the attribute is read-only.
616
+ * `idlType`: An [IDL Type](#idl-type) for the attribute.
617
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
618
+ * `parent`: The container of this type as an Object.
619
+
620
+ ### Constant Member
621
+
622
+ A constant member looks like this:
623
+
624
+ ```JS
625
+ {
626
+ "type": "const",
627
+ "idlType": {
628
+ "type": "const-type",
629
+ "generic": "",
630
+ "nullable": false,
631
+ "union": false,
632
+ "idlType": "boolean",
633
+ "extAttrs": []
634
+ },
635
+ "name": "DEBUG",
636
+ "value": {
637
+ "type": "boolean",
638
+ "value": false
639
+ },
640
+ "extAttrs": [],
641
+ "parent": { ... }
642
+ }
643
+ ```
644
+
645
+ The fields are as follows:
646
+
647
+ * `type`: Always "const".
648
+ * `idlType`: An [IDL Type](#idl-type) of the constant that represents a simple type, the type name.
649
+ * `name`: The name of the constant.
650
+ * `value`: The constant value as described by [Const Values](#default-and-const-values)
651
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
652
+ * `parent`: The container of this type as an Object.
653
+
654
+ ### Arguments
655
+
656
+ The arguments (e.g. for an operation) look like this:
657
+
658
+ ```JS
659
+ {
660
+ "arguments": [{
661
+ "type": "argument",
662
+ "default": null,
663
+ "optional": false,
664
+ "variadic": true
665
+ "extAttrs": []
666
+ "idlType": {
667
+ "type": "argument-type",
668
+ "generic": "",
669
+ "nullable": false,
670
+ "union": false,
671
+ "idlType": "float",
672
+ "extAttrs": [...]
673
+ },
674
+ "name": "ints",
675
+ "parent": { ... }
676
+ }]
677
+ }
678
+ ```
679
+
680
+ The fields are as follows:
681
+
682
+ * `default`: A [default value](#default-and-const-values), or `null` if there is none.
683
+ * `optional`: `true` if the argument is optional.
684
+ * `variadic`: `true` if the argument is variadic.
685
+ * `idlType`: An [IDL Type](#idl-type) describing the type of the argument.
686
+ * `name`: The argument's name.
687
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
688
+ * `parent`: The container of this type as an Object.
689
+
690
+ ### Extended Attributes
691
+
692
+ Extended attribute container look like this:
693
+
694
+ ```JS
695
+ {
696
+ "extAttrs": [{
697
+ "name": "PutForwards",
698
+ "arguments": [...],
699
+ "type": "extended-attribute",
700
+ "rhs": {
701
+ "type": "identifier",
702
+ "value": "foo"
703
+ },
704
+ "parent": { ... }
705
+ }]
706
+ }
707
+ ```
708
+
709
+ The fields are as follows:
710
+
711
+ * `items`: An array of extended attributes.
712
+
713
+ Extended attributes look like this:
714
+
715
+ * `name`: The extended attribute's name.
716
+ * `arguments`: An array of [arguments](#arguments), if the extended
717
+ attribute has a signature (e.g. `[Foo()]`) or if its right-hand side does (e.g.
718
+ `[LegacyFactoryFunction=Name(DOMString blah)]`).
719
+ * `type`: Always `"extended-attribute"`.
720
+ * `rhs`: If there is a right-hand side, this will capture its `type` and `value`. The
721
+ type can be one of the following:
722
+ * `"identifier"`
723
+ * `"identifier-list"`
724
+ * `"string"`
725
+ * `"string-list"`
726
+ * `"decimal"`
727
+ * `"decimal-list"`
728
+ * `"integer"`
729
+ * `"integer-list"`
730
+ * `"*"`
731
+ * `parent`: The container of this type as an Object.
732
+
733
+ ### Default and Const Values
734
+
735
+ Dictionary fields and operation arguments can take default values, and constants take
736
+ values, all of which have the following fields:
737
+
738
+ * `type`: One of `"string"`, `"number"`, `"boolean"`, `"null"`, `"Infinity"`, `"NaN"`, `"sequence"` or `"dictionary"`.
739
+
740
+ For `"boolean"`, `"string"`, `"number"`, and `"sequence"`:
741
+
742
+ * `value`: The value of the given type. For string and number types, the value is given as a string. For booleans, the possible values are `true` and `false`. For sequence, the only possible value is `[]`.
743
+
744
+ For `"Infinity"`:
745
+
746
+ * `negative`: Boolean indicating whether this is negative Infinity or not.
747
+
748
+ ### `iterable<>`, `async iterable<>`, `maplike<>`, and `setlike<>` declarations
749
+
750
+ These appear as members of interfaces that look like this:
751
+
752
+ ```JS
753
+ {
754
+ "type": "maplike", // or "iterable" / "setlike"
755
+ "idlType": /* One or two types */ ,
756
+ "readonly": false, // only for maplike and setlike
757
+ "async": false, // iterable can be async
758
+ "arguments": [], // only for async iterable
759
+ "extAttrs": [],
760
+ "parent": { ... }
761
+ }
762
+ ```
763
+
764
+ The fields are as follows:
765
+
766
+ * `type`: Always one of "iterable", "maplike" or "setlike".
767
+ * `idlType`: An array with one or more [IDL Types](#idl-type) representing the declared type arguments.
768
+ * `readonly`: `true` if the maplike or setlike is declared as read only.
769
+ * `async`: `true` if the type is async iterable.
770
+ * `arguments`: An array of arguments if exists, empty otherwise. Currently only `async iterable` supports the syntax.
771
+ * `extAttrs`: An array of [extended attributes](#extended-attributes).
772
+ * `parent`: The container of this type as an Object.
773
+
774
+ ### End of file
775
+
776
+ ```js
777
+ {
778
+ "type": "eof",
779
+ "value": ""
780
+ }
781
+ ```
782
+
783
+ This type only appears as the last item of parser results, only if options.concrete is `true`.
784
+ This is needed for the writer to keep any comments or whitespaces at the end of file.
785
+
786
+ The fields are as follows:
787
+
788
+ * `type`: Always "eof"
789
+ * `value`: Always an empty string.
790
+
791
+ ## Testing
792
+
793
+ ### Running
794
+
795
+ The test runs with mocha and expect.js. Normally, running `npm test` in the root directory
796
+ should be enough once you're set up.
797
+
798
+
799
+ ## Contributors
800
+
801
+ ### Code Contributors
802
+
803
+ This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
804
+ <a href="https://github.com/w3c/webidl2.js/graphs/contributors"><img src="https://opencollective.com/webidl2js/contributors.svg?width=890&button=false" /></a>
805
+
806
+ ### Financial Contributors
807
+
808
+ Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/webidl2js/contribute)]
809
+
810
+ #### Individuals
811
+
812
+ <a href="https://opencollective.com/webidl2js"><img src="https://opencollective.com/webidl2js/individuals.svg?width=890"></a>
813
+
814
+ #### Organizations
815
+
816
+ Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/webidl2js/contribute)]
817
+
818
+ <a href="https://opencollective.com/webidl2js/organization/0/website"><img src="https://opencollective.com/webidl2js/organization/0/avatar.svg"></a>
819
+ <a href="https://opencollective.com/webidl2js/organization/1/website"><img src="https://opencollective.com/webidl2js/organization/1/avatar.svg"></a>
820
+ <a href="https://opencollective.com/webidl2js/organization/2/website"><img src="https://opencollective.com/webidl2js/organization/2/avatar.svg"></a>
821
+ <a href="https://opencollective.com/webidl2js/organization/3/website"><img src="https://opencollective.com/webidl2js/organization/3/avatar.svg"></a>
822
+ <a href="https://opencollective.com/webidl2js/organization/4/website"><img src="https://opencollective.com/webidl2js/organization/4/avatar.svg"></a>
823
+ <a href="https://opencollective.com/webidl2js/organization/5/website"><img src="https://opencollective.com/webidl2js/organization/5/avatar.svg"></a>
824
+ <a href="https://opencollective.com/webidl2js/organization/6/website"><img src="https://opencollective.com/webidl2js/organization/6/avatar.svg"></a>
825
+ <a href="https://opencollective.com/webidl2js/organization/7/website"><img src="https://opencollective.com/webidl2js/organization/7/avatar.svg"></a>
826
+ <a href="https://opencollective.com/webidl2js/organization/8/website"><img src="https://opencollective.com/webidl2js/organization/8/avatar.svg"></a>
827
+ <a href="https://opencollective.com/webidl2js/organization/9/website"><img src="https://opencollective.com/webidl2js/organization/9/avatar.svg"></a>