Skip to content

Commit

Permalink
splitted idls + simple merging
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Jan 9, 2018
1 parent e108143 commit a1360ac
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 43 deletions.
15 changes: 13 additions & 2 deletions TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,19 @@ module InputIdlJson =
type InputIdlJsonType = JsonProvider<"inputfiles/sample.webidl.json">

let inputIdl =
File.ReadAllText(GlobalVars.inputFolder + @"/browser.webidl.json") |> InputIdlJsonType.Parse

let jsons =
DirectoryInfo(GlobalVars.inputFolder + @"/idls").GetFiles()
|> Array.map (fun file -> file.FullName |> File.ReadAllText |> InputIdlJsonType.Parse)

let inline extractJsonArray f =
jsons |> Array.collect f |> Array.map (fun item -> (^a: (member JsonValue: JsonValue) item)) |> JsonValue.Array;

let list = [| ("callbackFunctions", extractJsonArray (fun json -> json.CallbackFunctions));
("interfaces", extractJsonArray (fun json -> json.Interfaces));
("dictionaries", extractJsonArray (fun json -> json.Dictionaries));
("typedefs", extractJsonArray (fun json -> json.Typedefs)) |]
InputIdlJsonType.Root(JsonValue.Record list)

let allCallbackFunctionsMap =
inputIdl.CallbackFunctions |> toNameMap

Expand Down
44 changes: 44 additions & 0 deletions inputfiles/idls/Encoding.webidl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"callbackFunctions": [], "callbackInterfaces": [], "enums": [], "typedefs": [], "namespaces": [],
"dictionaries": [{
"name": "TextDecodeOptions",
"members": [{ "name": "stream", "type": "boolean", "default": "false" }]
}, {
"name": "TextDecoderOptions",
"members": [
{ "name": "fatal", "type": "boolean", "default": "false" },
{ "name": "ignoreBOM", "type": "boolean", "default": "false" }
]
}],
"interfaces": [{
"name": "TextDecoder",
"constructors": [{
"arguments": [
{ "name": "label", "type": "DOMString", "optional": true, "default": "\"utf-8\"" },
{ "name": "options", "type": "TextDecoderOptions", "optional": true }
]
}],
"exposed": ["Window", "Worker"],
"operations": [{
"name": "decode", "type": "USVString",
"arguments": [
{ "name": "input", "type": "BufferSource", "optional": true },
{ "name": "options", "type": "TextDecodeOptions", "optional": true }
]
}],
"attributes": [
{ "name": "encoding", "type": "DOMString", "readonly": true },
{ "name": "fatal", "type": "boolean", "readonly": true },
{ "name": "ignoreBOM", "type": "boolean", "readonly": true }
]
}, {
"name": "TextEncoder",
"constructors": [{ "arguments": [] }],
"exposed": ["Window", "Worker"],
"operations": [{
"name": "encode", "type": "Uint8Array",
"arguments": [{ "name": "input", "type": "USVString", "optional": true, "default": "\"\"" }]
}],
"attributes": [{ "name": "encoding", "type": "DOMString", "readonly": true }]
}]
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{
"callbackInterfaces": [], "enums": [], "namespaces": [],
"callbackInterfaces": [], "dictionaries": [], "enums": [], "namespaces": [],
"callbackFunctions": [
{
"name": "Function", "type": "any",
"arguments": [{ "name": "arguments", "type": "any", "variadic": true }]
},
{ "name": "VoidFunction", "type": "void", "arguments": [] }
],
"dictionaries": [{
"name": "TextDecodeOptions",
"members": [{ "name": "stream", "type": "boolean", "default": "false" }]
}, {
"name": "TextDecoderOptions",
"members": [
{ "name": "fatal", "type": "boolean", "default": "false" },
{ "name": "ignoreBOM", "type": "boolean", "default": "false" }
]
}],
"interfaces": [{
"name": "DOMException",
"exposed": ["Window", "Worker"],
Expand Down Expand Up @@ -58,36 +48,6 @@
{ "name": "message", "type": "DOMString", "readonly": true },
{ "name": "name", "type": "DOMString", "readonly": true }
]
}, {
"name": "TextDecoder",
"constructors": [{
"arguments": [
{ "name": "label", "type": "DOMString", "optional": true, "default": "\"utf-8\"" },
{ "name": "options", "type": "TextDecoderOptions", "optional": true }
]
}],
"exposed": ["Window", "Worker"],
"operations": [{
"name": "decode", "type": "USVString",
"arguments": [
{ "name": "input", "type": "BufferSource", "optional": true },
{ "name": "options", "type": "TextDecodeOptions", "optional": true }
]
}],
"attributes": [
{ "name": "encoding", "type": "DOMString", "readonly": true },
{ "name": "fatal", "type": "boolean", "readonly": true },
{ "name": "ignoreBOM", "type": "boolean", "readonly": true }
]
}, {
"name": "TextEncoder",
"constructors": [{ "arguments": [] }],
"exposed": ["Window", "Worker"],
"operations": [{
"name": "encode", "type": "Uint8Array",
"arguments": [{ "name": "input", "type": "USVString", "optional": true, "default": "\"\"" }]
}],
"attributes": [{ "name": "encoding", "type": "DOMString", "readonly": true }]
}],
"typedefs": [
{ "name": "ArrayBufferView", "type": "(Int8Array or Int16Array or Int32Array or Uint8Array or Uint16Array or Uint32Array or Uint8ClampedArray or Float32Array or Float64Array or DataView)" },
Expand Down

0 comments on commit a1360ac

Please sign in to comment.