Skip to content

Try splitting modules #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b44eee
WebIDLToSwift: Generate into a single file to make the output filenam…
kateinoigakukun May 2, 2022
114aa33
Split DOM related support code and generic support snippet
kateinoigakukun May 2, 2022
f95a3e0
Stop cleaning up generated directory
kateinoigakukun May 2, 2022
2216041
Format only Generated.swift
kateinoigakukun May 2, 2022
780073d
Move Sources/DOMKit/WebIDL/*.swift to Sources/DOMKit/
kateinoigakukun May 2, 2022
c2bee0a
Move hardcoded output path to main.swift
kateinoigakukun May 2, 2022
51ec9fe
Convert webidl to json one-by-one
kateinoigakukun May 2, 2022
b31b7c4
Allow to control behavior by cli arguments
kateinoigakukun May 2, 2022
d8e226c
WIP
kateinoigakukun May 2, 2022
4523a38
NFC: Record 'partial' interface while merging
kateinoigakukun May 2, 2022
923e9a3
Don't declare protocol when it's partial interface mixin
kateinoigakukun May 2, 2022
8827cf8
WIP
kateinoigakukun May 2, 2022
89ecce4
Allow to generate sources into separate files within a module per idl…
kateinoigakukun May 2, 2022
1853417
Record string literal, closure type, union use for each outputs
kateinoigakukun May 2, 2022
87b4e74
WIP
kateinoigakukun May 2, 2022
5b8be21
WIP
kateinoigakukun May 2, 2022
5bfeaef
Give up typing unions
kateinoigakukun May 3, 2022
cb52a3c
WIP
kateinoigakukun May 3, 2022
7e06338
WIP
kateinoigakukun May 3, 2022
c624622
WIP
kateinoigakukun May 3, 2022
63914f8
WIP
kateinoigakukun May 3, 2022
76a6e25
Repair build
kateinoigakukun May 3, 2022
4335637
WIP
kateinoigakukun May 3, 2022
b4673fb
Setup tests
kateinoigakukun May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Setup tests
  • Loading branch information
kateinoigakukun committed May 3, 2022
commit b4673fb24abf39337ee5e90ac8b5adfc0a82b576
7 changes: 6 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
name: "DOMKit",
targets: ["DOMKit"]),
.library(name: "WebIDL", targets: ["WebIDL"]),
.executable(name: "WebIDLToSwift", targets: ["WebIDLToSwift"]),
.executable(name: "idl2swift", targets: ["idl2swift"]),
],
dependencies: [
.package(
Expand All @@ -37,8 +37,13 @@ let package = Package(
.target(
name: "WebIDLToSwift",
dependencies: ["WebIDL"]),
.target(
name: "idl2swift",
dependencies: ["WebIDLToSwift"]),
.testTarget(
name: "DOMKitTests",
dependencies: ["DOMKit"]),
.testTarget(
name: "WebIDLToSwiftTests", dependencies: ["WebIDLToSwift"]),
]
)
4 changes: 4 additions & 0 deletions Sources/WebIDL/GenericCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ public struct GenericCollection<Element>: Collection, Decodable {
public subscript(index: Array.Index) -> Element { array[index] as! Element }
public func index(after index: Array.Index) -> Array.Index { array.index(after: index) }

init(_ array: [IDLNode]) {
self.array = array
}

public init(from decoder: Decoder) throws {
let wrappers = try decoder.singleValueContainer().decode([IDLNodeDecoder].self)
array = wrappers.map(\.node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ func parseOptions() -> [(name: String, path: URL)] {
}
}

main()

func main() {
public func main() {
do {
let idlInputs = parseOptions()
Record.reset()
Expand Down
25 changes: 6 additions & 19 deletions Sources/WebIDLToSwift/IDLParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,12 @@ enum IDLParser {
return try JSONDecoder().decode(GenericCollection<IDLNode>.self, from: data)
}

static func defaultIDLs() -> [(name: String, path: URL)] {
let enabledIDLs = [
"fetch",
"geometry",
"hr-time",
"referrer-policy",
"uievents",
"wai-aria",
"web-animations",
"xhr",
"service-workers",
"streams",
"dom",
"html",
"webidl",
"url",
"console",
"FileAPI"
]
static let defaultEnabledIDLs = [
"fetch", "geometry", "hr-time", "referrer-policy", "uievents", "wai-aria",
"web-animations", "xhr", "service-workers", "streams", "dom", "html",
"webidl", "url", "console", "FileAPI"
]
static func defaultIDLs(enabledIDLs: [String] = defaultEnabledIDLs) -> [(name: String, path: URL)] {
return enabledIDLs.map { idl in
let path = packageDir
.appendingPathComponent("node_modules")
Expand Down
3 changes: 3 additions & 0 deletions Sources/idl2swift/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import WebIDLToSwift

WebIDLToSwift.main()
14 changes: 14 additions & 0 deletions Tests/WebIDLToSwiftTests/WebIDLToSwiftTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@testable import WebIDLToSwift
@testable import WebIDL
import XCTest

final class WebIDLToSwiftTests: XCTestCase {
func testDeclGraph() throws {
let idlPaths = IDLParser.defaultIDLs(enabledIDLs: ["url"])
let idls = try idlPaths.map {
($0.name, try IDLParser.parseIDL(path: $0.path))
}
let graph = DeclGraph.build(from: idls.map { ($0, $1.array) })

}
}