Skip to content

Bring code generation into this repo, update to latest specs, support async functions natively #10

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

Merged
merged 124 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
05a8b9d
Swift interfaces for the WebIDL spec
j-f1 Mar 29, 2022
8fcd458
it parses!
j-f1 Mar 29, 2022
1a8b6e0
more fixes
j-f1 Mar 29, 2022
e169987
Start outputting Swift code
j-f1 Mar 29, 2022
7840dbc
Allow dynamic state
j-f1 Mar 29, 2022
2ab1dc6
more work
j-f1 Mar 29, 2022
7beaf87
whee it gets through the dom spec!
j-f1 Mar 29, 2022
75d117a
write out to the files, make public
j-f1 Mar 29, 2022
b1f0515
More fixes/polish
j-f1 Mar 29, 2022
affd27a
progress
j-f1 Mar 29, 2022
54367db
add HTML
j-f1 Mar 29, 2022
afc48a7
Fix broken enums
j-f1 Mar 29, 2022
2dc3245
Fix nullable IDLTypes
j-f1 Mar 29, 2022
f92b1cc
more fixes
j-f1 Mar 29, 2022
1569d9d
fetch all the IDL files
j-f1 Mar 29, 2022
aff3c64
remove IDLIncludes conformance for now since it is unused
j-f1 Mar 29, 2022
98c9315
fixes to optional arguments, merge declarations
j-f1 Mar 29, 2022
ae2568c
fix nullable optional params
j-f1 Mar 30, 2022
ee2f72d
use ReadWriteAttribute for dictionaries
j-f1 Mar 30, 2022
cc72638
remove broken getter support, fix IDLDictionary init
j-f1 Mar 30, 2022
5c2f314
Changes to JSKit
j-f1 Mar 30, 2022
d6fab9b
hammer more on errors
j-f1 Mar 30, 2022
cd34b3c
fix broken dictionaries
j-f1 Mar 30, 2022
139c412
try fix constructors
j-f1 Mar 30, 2022
e2f43ec
add uievents
j-f1 Mar 30, 2022
9b31877
oops
j-f1 Mar 30, 2022
b3a61b5
fancy number types
j-f1 Mar 30, 2022
3706967
correctly label class methods
j-f1 Mar 30, 2022
bcfa230
Work around type checking slowness
j-f1 Mar 30, 2022
82c358a
Add IDLNamed protocol
j-f1 Mar 30, 2022
fbda57c
Handle overridden declarations
j-f1 Mar 30, 2022
8a5586a
use Self more, comment out static overrides
j-f1 Mar 30, 2022
d0194a4
patches to Support.swift
j-f1 Mar 30, 2022
e265f6c
upstream Uint8ClampedArray, update JSClosure usage
j-f1 Mar 30, 2022
8b141f5
manually remove problematic entities
j-f1 Mar 30, 2022
ab42420
print mixins
j-f1 Mar 30, 2022
6a8f02a
add includes to the appropriate inheritances
j-f1 Mar 30, 2022
6667dcb
make ReadWriteAttribute, ReadonlyAttribute inlinable
j-f1 Mar 30, 2022
a1bc774
Update OptionalClosureHandler based on new closure lifetimes
j-f1 Mar 30, 2022
0b03441
fix inlinable, expand static subscripts
j-f1 Mar 30, 2022
843c5e1
fix wrapped properties on extensions
j-f1 Mar 30, 2022
41a5c24
more SwiftSource API
j-f1 Mar 30, 2022
77f2072
fix readonly properties
j-f1 Mar 30, 2022
8d5bd84
separate mixin and class inheritance
j-f1 Mar 30, 2022
5c74264
)
j-f1 Mar 30, 2022
dd9cf5b
oops
j-f1 Mar 30, 2022
41b2fba
fix some errors
j-f1 Mar 30, 2022
7480bb0
more work
j-f1 Mar 30, 2022
b0a7b2f
fix typo
j-f1 Mar 30, 2022
b2e1755
BUILD PASSES
j-f1 Mar 30, 2022
66bb949
add comment that the code was generated
j-f1 Mar 30, 2022
b8c1bb2
add iterable support
j-f1 Mar 30, 2022
e77a9eb
consistent syntax for removed code
j-f1 Mar 30, 2022
5bd89f6
Add getter support
j-f1 Mar 30, 2022
20fd412
merge namespaces too
j-f1 Mar 30, 2022
8a2073e
pretend to support async iterators
j-f1 Mar 30, 2022
d4384f9
generate async functions
j-f1 Mar 30, 2022
9d72d1b
add more specs
j-f1 Mar 30, 2022
b4dec82
Update Package.swift
j-f1 Mar 30, 2022
ce19248
drop custom ReadableStream
j-f1 Mar 30, 2022
e87bc3d
fix async functions
j-f1 Mar 30, 2022
2ea2764
\(quoted: ...)
j-f1 Mar 30, 2022
4fe726e
Generate closure wrapper types automatically
j-f1 Mar 30, 2022
5fdcd99
remove unsupported function
j-f1 Mar 30, 2022
4c37eb8
fix 0-arg closures
j-f1 Mar 30, 2022
ef7637b
“fix” readonly closure properties (why are these not methods?)
j-f1 Mar 30, 2022
9daa6e8
fix variadic callbacks
j-f1 Mar 30, 2022
18a9483
fixes for the Function type
j-f1 Mar 30, 2022
b65c5b2
Fix closure keys in dictionaries
j-f1 Mar 30, 2022
3d7c312
check in my changes to the iterator support (not working)
j-f1 Mar 30, 2022
4e24216
refactor main.swift
j-f1 Mar 30, 2022
5d1baef
Clean output folder before building
j-f1 Mar 30, 2022
fdee5ba
more refactoring
j-f1 Mar 30, 2022
ad6fe93
Parse the IDL files at runtime
j-f1 Mar 30, 2022
2d99509
check in updated IDL files
j-f1 Mar 30, 2022
67f10c8
reformat iterators
j-f1 Mar 30, 2022
934a47e
Don’t forget to format!
j-f1 Mar 30, 2022
5421c98
Update .gitignore
j-f1 Mar 30, 2022
ff24efd
clean up Support.swift, “fix” build error
j-f1 Mar 30, 2022
810a4f7
Don’t subclass JSObject anymore
j-f1 Apr 1, 2022
aacbe79
Just quote all the names and let SwiftFormat sort it out
j-f1 Apr 1, 2022
443952c
Use JSString more, intern all object keys
j-f1 Apr 1, 2022
f5d0edc
bump JSKit
j-f1 Apr 1, 2022
a7b625b
sdfasg
j-f1 Apr 1, 2022
4c75f8d
remove some swiftRepresentation
j-f1 Apr 1, 2022
7f8681e
Revert "Just quote all the names and let SwiftFormat sort it out"
j-f1 Apr 2, 2022
3d778bf
Fix most errors
j-f1 Apr 2, 2022
3a0e627
Merge all the strings into one enum
j-f1 Apr 2, 2022
432eba6
Also look up global names using Strings
j-f1 Apr 2, 2022
6dc015f
Add the rest of the APIs!
j-f1 Apr 2, 2022
43ff31e
Refactor ECMAScript folder into more files
j-f1 Apr 2, 2022
819b467
Fix typos, ignore a bunch of types
j-f1 Apr 2, 2022
cbd9bf1
update generated files
j-f1 Apr 2, 2022
fc48330
Pick a fixed order of loading in the specs
j-f1 Apr 2, 2022
c818907
Refactor ClosureAttribute code
j-f1 Apr 2, 2022
0544fde
Add support for void-returning closures
j-f1 Apr 2, 2022
cfd9f79
Correctly handle variadic method parameters
j-f1 Apr 2, 2022
72463cf
Also handle variadic constructors
j-f1 Apr 2, 2022
47d99df
Fix constants on protocol extensions
j-f1 Apr 2, 2022
8a367b3
Make things inlinable
j-f1 Apr 2, 2022
05351af
disable broken TrustedTypePolicyOptions
j-f1 Apr 2, 2022
3662d5b
nonmutating
j-f1 Apr 2, 2022
9d204ce
paper over compile error
j-f1 Apr 2, 2022
2d59fd9
Implement ValueIterableIterator, ValueIterableAsyncIterator
j-f1 Apr 2, 2022
8542c19
remove non-Window-exposed APIs
j-f1 Apr 2, 2022
b79a328
Initial union support
j-f1 Apr 2, 2022
24bf907
Replace X_or_Void unions with Optional<X>
j-f1 Apr 2, 2022
3f7febf
Remove redundant union
j-f1 Apr 2, 2022
2ddcf8e
special-case CustomElementConstructor
j-f1 Apr 2, 2022
cd16a42
fix ArrayBufferView
j-f1 Apr 2, 2022
582a77d
fix RotationMatrixType
j-f1 Apr 2, 2022
4600290
(wip) Automatically pick up friendly names for unions
j-f1 Apr 3, 2022
157f5ca
switch back to main branch of JSKit
j-f1 Apr 5, 2022
1d8188b
update to the new JSKit APIs
j-f1 Apr 5, 2022
b9c4648
polish naming of union cases that start with an acronym
j-f1 Apr 23, 2022
c435299
limit parsed specs
j-f1 Apr 22, 2022
2edf07e
fix UnionType crash
j-f1 Apr 23, 2022
a0d5667
add typed accessors to unions
j-f1 Apr 23, 2022
9bc4426
hand-implement RenderingContext, OffscreenRenderingContext
j-f1 Apr 23, 2022
6254975
cut some more
j-f1 Apr 23, 2022
8392de9
cut more
j-f1 Apr 23, 2022
3884036
Use macOS Monterey and Xcode 13.3.1
MaxDesiatov Apr 30, 2022
4e9716d
Use `macos-12` image name
MaxDesiatov Apr 30, 2022
96688c3
Add BodyInit typealias
j-f1 Apr 30, 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
Next Next commit
Fix closure keys in dictionaries
  • Loading branch information
j-f1 committed Mar 30, 2022
commit b65c5b245842d05b98fa419cad888df8f801cfcc
1 change: 0 additions & 1 deletion Sources/DOMKit/ECMAScript/ArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public typealias Int32Array = JSTypedArray<Int32>
public typealias Uint8Array = JSTypedArray<UInt8>
public typealias Uint16Array = JSTypedArray<UInt16>
public typealias Uint32Array = JSTypedArray<UInt32>
//public typealias Uint8ClampedArray = JSTypedArray<Uint8Clamped>
public typealias Float32Array = JSTypedArray<Float32>
public typealias Float64Array = JSTypedArray<Float64>

Expand Down
30 changes: 26 additions & 4 deletions Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ extension MergedDictionary: SwiftRepresentable {

private var swiftInit: SwiftSource {
"""
public init(\(sequence: members.map { "\($0.name): \($0.idlType)" })) {
public init(\(sequence: members.map { "\($0.name): \($0.idlType.isFunction ? "@escaping " : "")\($0.idlType)" })) {
let object = JSObject.global.Object.function!.new()
\(lines: members.map {
"""
object[\(quoted: $0.name)] = \($0.name).jsValue()
"""
if $0.idlType.isFunction {
return """
\($0.idlType.propertyWrapper(readonly: false))[\(quoted: $0.name), in: object] = \($0.name)
"""
} else {
return """
object[\(quoted: $0.name)] = \($0.name).jsValue()
"""
}
})
\(lines: members.map {
"""
Expand Down Expand Up @@ -487,6 +493,22 @@ extension IDLType: SwiftRepresentable {
}
}

var isFunction: Bool {
if case let .single(name) = value {
if Context.types[name] is IDLCallback {
return true
}
if let ref = Context.types[name] as? IDLTypedef,
case let .single(name) = ref.idlType.value,
Context.types[name] is IDLCallback
{
assert(ref.idlType.nullable)
return true
}
}
return false
}

func propertyWrapper(readonly: Bool) -> SwiftSource {
// TODO: handle readonly closure properties
// (should they be a JSFunction? or a closure? or something else?))
Expand Down