Skip to content

Commit

Permalink
Update to latest IDL specs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Jun 28, 2023
1 parent 0fc3378 commit 1535ceb
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 116 deletions.
23 changes: 20 additions & 3 deletions Sources/DOM/Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ public class AbortSignal: EventTarget {
return this[Strings.timeout].function!(this: this, arguments: [_toJSValue(milliseconds)]).fromJSValue()!
}

@inlinable public class func any(signals: [AbortSignal]) -> Self {
let this = constructor!
return this[Strings.any].function!(this: this, arguments: [_toJSValue(signals)]).fromJSValue()!
}

@ReadonlyAttribute
public var aborted: Bool

Expand Down Expand Up @@ -6943,9 +6948,9 @@ public class HTMLElement: Element, GlobalEventHandlers, ElementContentEditable,
_ = this[Strings.hidePopover].function!(this: this, arguments: [])
}

@inlinable public func togglePopover(force: Bool? = nil) {
@inlinable public func togglePopover(force: Bool? = nil) -> Bool {
let this = jsObject
_ = this[Strings.togglePopover].function!(this: this, arguments: [_toJSValue(force)])
return this[Strings.togglePopover].function!(this: this, arguments: [_toJSValue(force)]).fromJSValue()!
}

@ReadWriteAttribute
Expand Down Expand Up @@ -13493,6 +13498,11 @@ public class ReadableStream: JSBridgedClass, AsyncSequence {
self.init(unsafelyWrapping: Self.constructor!.new(arguments: [_toJSValue(underlyingSource), _toJSValue(strategy)]))
}

@inlinable public class func from(asyncIterable: JSValue) -> Self {
let this = constructor!
return this[Strings.from].function!(this: this, arguments: [_toJSValue(asyncIterable)]).fromJSValue()!
}

@ReadonlyAttribute
public var locked: Bool

Expand Down Expand Up @@ -16858,7 +16868,7 @@ public class VideoFrame: JSBridgedClass {
}

public class VideoFrameBufferInit: BridgedDictionary {
public convenience init(format: VideoPixelFormat, codedWidth: UInt32, codedHeight: UInt32, timestamp: Int64, duration: UInt64, layout: [PlaneLayout], visibleRect: DOMRectInit, displayWidth: UInt32, displayHeight: UInt32, colorSpace: VideoColorSpaceInit) {
public convenience init(format: VideoPixelFormat, codedWidth: UInt32, codedHeight: UInt32, timestamp: Int64, duration: UInt64, layout: [PlaneLayout], visibleRect: DOMRectInit, displayWidth: UInt32, displayHeight: UInt32, colorSpace: VideoColorSpaceInit, transfer: [ArrayBuffer]) {
let object = JSObject.global[Strings.Object].function!.new()
object[Strings.format] = _toJSValue(format)
object[Strings.codedWidth] = _toJSValue(codedWidth)
Expand All @@ -16870,6 +16880,7 @@ public class VideoFrameBufferInit: BridgedDictionary {
object[Strings.displayWidth] = _toJSValue(displayWidth)
object[Strings.displayHeight] = _toJSValue(displayHeight)
object[Strings.colorSpace] = _toJSValue(colorSpace)
object[Strings.transfer] = _toJSValue(transfer)
self.init(unsafelyWrapping: object)
}

Expand All @@ -16884,6 +16895,7 @@ public class VideoFrameBufferInit: BridgedDictionary {
_displayWidth = ReadWriteAttribute(jsObject: object, name: Strings.displayWidth)
_displayHeight = ReadWriteAttribute(jsObject: object, name: Strings.displayHeight)
_colorSpace = ReadWriteAttribute(jsObject: object, name: Strings.colorSpace)
_transfer = ReadWriteAttribute(jsObject: object, name: Strings.transfer)
super.init(unsafelyWrapping: object)
}

Expand Down Expand Up @@ -16916,6 +16928,9 @@ public class VideoFrameBufferInit: BridgedDictionary {

@ReadWriteAttribute
public var colorSpace: VideoColorSpaceInit

@ReadWriteAttribute
public var transfer: [ArrayBuffer]
}

public class VideoFrameCopyToOptions: BridgedDictionary {
Expand Down Expand Up @@ -18703,6 +18718,7 @@ public class XSLTProcessor: JSBridgedClass {
@usableFromInline static let ancestorOrigins: JSString = "ancestorOrigins"
@usableFromInline static let anchors: JSString = "anchors"
@usableFromInline static let animated: JSString = "animated"
@usableFromInline static let any: JSString = "any"
@usableFromInline static let appCodeName: JSString = "appCodeName"
@usableFromInline static let appName: JSString = "appName"
@usableFromInline static let appVersion: JSString = "appVersion"
Expand Down Expand Up @@ -19136,6 +19152,7 @@ public class XSLTProcessor: JSBridgedClass {
@usableFromInline static let frameRate: JSString = "frameRate"
@usableFromInline static let framerate: JSString = "framerate"
@usableFromInline static let frames: JSString = "frames"
@usableFromInline static let from: JSString = "from"
@usableFromInline static let fromBox: JSString = "fromBox"
@usableFromInline static let fromFloat32Array: JSString = "fromFloat32Array"
@usableFromInline static let fromFloat64Array: JSString = "fromFloat64Array"
Expand Down
79 changes: 75 additions & 4 deletions Sources/WebAPIBase/Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ public class URLSearchParams: JSBridgedClass, Sequence {
_ = this[Strings.append].function!(this: this, arguments: [_toJSValue(name), _toJSValue(value)])
}

@inlinable public func delete(name: String) {
@inlinable public func delete(name: String, value: String? = nil) {
let this = jsObject
_ = this[Strings.delete].function!(this: this, arguments: [_toJSValue(name)])
_ = this[Strings.delete].function!(this: this, arguments: [_toJSValue(name), _toJSValue(value)])
}

@inlinable public func get(name: String) -> String? {
Expand All @@ -190,9 +190,9 @@ public class URLSearchParams: JSBridgedClass, Sequence {
return this[Strings.getAll].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()!
}

@inlinable public func has(name: String) -> Bool {
@inlinable public func has(name: String, value: String? = nil) -> Bool {
let this = jsObject
return this[Strings.has].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()!
return this[Strings.has].function!(this: this, arguments: [_toJSValue(name), _toJSValue(value)]).fromJSValue()!
}

@inlinable public func set(name: String, value: String) {
Expand Down Expand Up @@ -369,6 +369,77 @@ public enum console {
@usableFromInline static let warn: JSString = "warn"
}

public protocol Any_AllowSharedBufferSource: ConvertibleToJSValue {}
extension ArrayBuffer: Any_AllowSharedBufferSource {}
extension ArrayBufferView: Any_AllowSharedBufferSource {}
extension SharedArrayBuffer: Any_AllowSharedBufferSource {}

public enum AllowSharedBufferSource: JSValueCompatible, Any_AllowSharedBufferSource {
case arrayBuffer(ArrayBuffer)
case arrayBufferView(ArrayBufferView)
case sharedArrayBuffer(SharedArrayBuffer)

init(_ arrayBuffer: ArrayBuffer) {
let val: AllowSharedBufferSource = .arrayBuffer(arrayBuffer)
self = val
}

init(_ arrayBufferView: ArrayBufferView) {
let val: AllowSharedBufferSource = .arrayBufferView(arrayBufferView)
self = val
}

init(_ sharedArrayBuffer: SharedArrayBuffer) {
let val: AllowSharedBufferSource = .sharedArrayBuffer(sharedArrayBuffer)
self = val
}

public var arrayBuffer: ArrayBuffer? {
switch self {
case let .arrayBuffer(arrayBuffer): return arrayBuffer
default: return nil
}
}

public var arrayBufferView: ArrayBufferView? {
switch self {
case let .arrayBufferView(arrayBufferView): return arrayBufferView
default: return nil
}
}

public var sharedArrayBuffer: SharedArrayBuffer? {
switch self {
case let .sharedArrayBuffer(sharedArrayBuffer): return sharedArrayBuffer
default: return nil
}
}

public static func construct(from value: JSValue) -> Self? {
if let arrayBuffer: ArrayBuffer = value.fromJSValue() {
return .arrayBuffer(arrayBuffer)
}
if let arrayBufferView: ArrayBufferView = value.fromJSValue() {
return .arrayBufferView(arrayBufferView)
}
if let sharedArrayBuffer: SharedArrayBuffer = value.fromJSValue() {
return .sharedArrayBuffer(sharedArrayBuffer)
}
return nil
}

public var jsValue: JSValue {
switch self {
case let .arrayBuffer(arrayBuffer):
return arrayBuffer.jsValue
case let .arrayBufferView(arrayBufferView):
return arrayBufferView.jsValue
case let .sharedArrayBuffer(sharedArrayBuffer):
return sharedArrayBuffer.jsValue
}
}
}

public protocol Any_BufferSource: ConvertibleToJSValue {}
extension ArrayBuffer: Any_BufferSource {}
extension ArrayBufferView: Any_BufferSource {}
Expand Down
Loading

0 comments on commit 1535ceb

Please sign in to comment.