Skip to content

Commit 7f2eda3

Browse files
committed
splitted idls + merging
1 parent e108143 commit 7f2eda3

File tree

3 files changed

+58
-43
lines changed

3 files changed

+58
-43
lines changed

TS.fsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,19 @@ module InputIdlJson =
144144
type InputIdlJsonType = JsonProvider<"inputfiles/sample.webidl.json">
145145

146146
let inputIdl =
147-
File.ReadAllText(GlobalVars.inputFolder + @"/browser.webidl.json") |> InputIdlJsonType.Parse
148-
147+
let jsons =
148+
DirectoryInfo(GlobalVars.inputFolder + @"/idls").GetFiles()
149+
|> Array.map (fun file -> file.FullName |> File.ReadAllText |> InputIdlJsonType.Parse)
150+
151+
let inline extractJsonArray f =
152+
jsons |> Array.collect f |> Array.map (fun item -> (^a: (member JsonValue: JsonValue) item)) |> JsonValue.Array;
153+
154+
let list = [| ("callbackFunctions", extractJsonArray (fun json -> json.CallbackFunctions));
155+
("interfaces", extractJsonArray (fun json -> json.Interfaces));
156+
("dictionaries", extractJsonArray (fun json -> json.Dictionaries));
157+
("typedefs", extractJsonArray (fun json -> json.Typedefs)) |]
158+
InputIdlJsonType.Root(JsonValue.Record list)
159+
149160
let allCallbackFunctionsMap =
150161
inputIdl.CallbackFunctions |> toNameMap
151162

inputfiles/idls/Encoding.webidl.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"callbackFunctions": [], "callbackInterfaces": [], "enums": [], "typedefs": [], "namespaces": [],
3+
"dictionaries": [{
4+
"name": "TextDecodeOptions",
5+
"members": [{ "name": "stream", "type": "boolean", "default": "false" }]
6+
}, {
7+
"name": "TextDecoderOptions",
8+
"members": [
9+
{ "name": "fatal", "type": "boolean", "default": "false" },
10+
{ "name": "ignoreBOM", "type": "boolean", "default": "false" }
11+
]
12+
}],
13+
"interfaces": [{
14+
"name": "TextDecoder",
15+
"constructors": [{
16+
"arguments": [
17+
{ "name": "label", "type": "DOMString", "optional": true, "default": "\"utf-8\"" },
18+
{ "name": "options", "type": "TextDecoderOptions", "optional": true }
19+
]
20+
}],
21+
"exposed": ["Window", "Worker"],
22+
"operations": [{
23+
"name": "decode", "type": "USVString",
24+
"arguments": [
25+
{ "name": "input", "type": "BufferSource", "optional": true },
26+
{ "name": "options", "type": "TextDecodeOptions", "optional": true }
27+
]
28+
}],
29+
"attributes": [
30+
{ "name": "encoding", "type": "DOMString", "readonly": true },
31+
{ "name": "fatal", "type": "boolean", "readonly": true },
32+
{ "name": "ignoreBOM", "type": "boolean", "readonly": true }
33+
]
34+
}, {
35+
"name": "TextEncoder",
36+
"constructors": [{ "arguments": [] }],
37+
"exposed": ["Window", "Worker"],
38+
"operations": [{
39+
"name": "encode", "type": "Uint8Array",
40+
"arguments": [{ "name": "input", "type": "USVString", "optional": true, "default": "\"\"" }]
41+
}],
42+
"attributes": [{ "name": "encoding", "type": "DOMString", "readonly": true }]
43+
}]
44+
}

inputfiles/browser.webidl.json renamed to inputfiles/idls/Web IDL.webidl.json

+1-41
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
{
2-
"callbackInterfaces": [], "enums": [], "namespaces": [],
2+
"callbackInterfaces": [], "dictionaries": [], "enums": [], "namespaces": [],
33
"callbackFunctions": [
44
{
55
"name": "Function", "type": "any",
66
"arguments": [{ "name": "arguments", "type": "any", "variadic": true }]
77
},
88
{ "name": "VoidFunction", "type": "void", "arguments": [] }
99
],
10-
"dictionaries": [{
11-
"name": "TextDecodeOptions",
12-
"members": [{ "name": "stream", "type": "boolean", "default": "false" }]
13-
}, {
14-
"name": "TextDecoderOptions",
15-
"members": [
16-
{ "name": "fatal", "type": "boolean", "default": "false" },
17-
{ "name": "ignoreBOM", "type": "boolean", "default": "false" }
18-
]
19-
}],
2010
"interfaces": [{
2111
"name": "DOMException",
2212
"exposed": ["Window", "Worker"],
@@ -58,36 +48,6 @@
5848
{ "name": "message", "type": "DOMString", "readonly": true },
5949
{ "name": "name", "type": "DOMString", "readonly": true }
6050
]
61-
}, {
62-
"name": "TextDecoder",
63-
"constructors": [{
64-
"arguments": [
65-
{ "name": "label", "type": "DOMString", "optional": true, "default": "\"utf-8\"" },
66-
{ "name": "options", "type": "TextDecoderOptions", "optional": true }
67-
]
68-
}],
69-
"exposed": ["Window", "Worker"],
70-
"operations": [{
71-
"name": "decode", "type": "USVString",
72-
"arguments": [
73-
{ "name": "input", "type": "BufferSource", "optional": true },
74-
{ "name": "options", "type": "TextDecodeOptions", "optional": true }
75-
]
76-
}],
77-
"attributes": [
78-
{ "name": "encoding", "type": "DOMString", "readonly": true },
79-
{ "name": "fatal", "type": "boolean", "readonly": true },
80-
{ "name": "ignoreBOM", "type": "boolean", "readonly": true }
81-
]
82-
}, {
83-
"name": "TextEncoder",
84-
"constructors": [{ "arguments": [] }],
85-
"exposed": ["Window", "Worker"],
86-
"operations": [{
87-
"name": "encode", "type": "Uint8Array",
88-
"arguments": [{ "name": "input", "type": "USVString", "optional": true, "default": "\"\"" }]
89-
}],
90-
"attributes": [{ "name": "encoding", "type": "DOMString", "readonly": true }]
9151
}],
9252
"typedefs": [
9353
{ "name": "ArrayBufferView", "type": "(Int8Array or Int16Array or Int32Array or Uint8Array or Uint16Array or Uint32Array or Uint8ClampedArray or Float32Array or Float64Array or DataView)" },

0 commit comments

Comments
 (0)