swiftwasm / WebAPIKit

Access the DOM and other Web APIs from Swift! (Very much a WIP)
MIT License
61 stars 8 forks source link

Finish support for subscripts #28

Closed j-f1 closed 1 year ago

j-f1 commented 2 years ago

Subscript getters/setters are represented as separate nodes in WebIDL, so we’ll need to do a step to merge them before attempting to print them (since Swift requires that the getter and setter for a subscript be colocated)

https://github.com/swiftwasm/DOMKit/blob/45ed26d277a73ff09fc79fd39d6f59fce39fdffd/Sources/WebIDLToSwift/WebIDL%2BSwiftRepresentation.swift#L370-L381

For a related example, see AsyncOperation, which wraps a single IDLOperation to emit both a JSPromise-returning and an async version of the method.

Also, support for deleters should be added. Swift doesn’t have a concept of a deleter, so I guess the best approach would be to define a removeValue(forKey:) method, just like Dictionary?

j-f1 commented 1 year ago

Setter merging implemented in 7dc16029001f738dd1c477e222febb56e0e7f1ed. (made extra fun by spec authors not putting the getter/setter methods adjacent to each other!)

Deleters implemented in 144bf2fe4870576b54d7638e2f94ee65d66b0071.