Skip to content

Commit fd9bfad

Browse files
committed
Switch from copying out “customized” code to using patches
1 parent 9ef9583 commit fd9bfad

17 files changed

+262
-136
lines changed

Patches/CSSOM.patch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/Sources/CSSOM/Generated.swift b/Sources/CSSOM/Generated.swift
2+
index e9f9df4..331ec01 100644
3+
--- a/Sources/CSSOM/Generated.swift
4+
+++ b/Sources/CSSOM/Generated.swift
5+
@@ -361,8 +361,14 @@ public class CSSColor: CSSColorValue {
6+
self.init(unsafelyWrapping: Self.constructor!.new(arguments: [_toJSValue(colorSpace), _toJSValue(channels), _toJSValue(alpha)]))
7+
}
8+
9+
+ @available(*, unavailable)
10+
+ override public var colorSpace: CSSKeywordValue {
11+
+ get { colorSpaceOrString.cssKeywordValue! }
12+
+ set { colorSpaceOrString = .cssKeywordValue(newValue) }
13+
+ }
14+
+
15+
@usableFromInline let _colorSpace: ReadWriteAttribute<CSSKeywordish>
16+
- @inlinable override public var colorSpace: CSSKeywordish {
17+
+ @inlinable public var colorSpaceOrString: CSSKeywordish {
18+
get { _colorSpace.wrappedValue }
19+
set { _colorSpace.wrappedValue = newValue }
20+
}

Patches/DOM.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/Sources/DOM/Generated.swift b/Sources/DOM/Generated.swift
2+
index 0d66a02..708adef 100644
3+
--- a/Sources/DOM/Generated.swift
4+
+++ b/Sources/DOM/Generated.swift
5+
@@ -957,8 +957,15 @@ public class BeforeUnloadEvent: Event {
6+
super.init(unsafelyWrapping: jsObject)
7+
}
8+
9+
+ @available(*, unavailable)
10+
+ override public var returnValue: Bool {
11+
+ get { !_returnValue.wrappedValue.isEmpty }
12+
+ set {}
13+
+ }
14+
+
15+
@usableFromInline let _returnValue: ReadWriteAttribute<String>
16+
- @inlinable override public var returnValue: String {
17+
+ // renamed because `String` is not compatible with `Bool`
18+
+ @inlinable public var returnValueAsString: String {
19+
get { _returnValue.wrappedValue }
20+
set { _returnValue.wrappedValue = newValue }
21+
}
22+
@@ -6978,7 +6985,8 @@ public class HTMLFormControlsCollection: HTMLCollection {
23+
jsObject[key].fromJSValue()
24+
}
25+
26+
- @inlinable override public func namedItem(name: String) -> Element_or_RadioNodeList? {
27+
+ // `override` removed since the superclass returns a more constrained type `Element`
28+
+ @inlinable func namedItem(name: String) -> Element_or_RadioNodeList? {
29+
let this = jsObject
30+
return this[Strings.namedItem].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()!
31+
}

Patches/SVG.patch

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/Sources/SVG/Generated.swift b/Sources/SVG/Generated.swift
2+
index 287fe12..5c83d7e 100644
3+
--- a/Sources/SVG/Generated.swift
4+
+++ b/Sources/SVG/Generated.swift
5+
@@ -544,14 +544,16 @@ public class SVGElement: Element, GlobalEventHandlers, DocumentAndElementEventHa
6+
@inlinable override public class var constructor: JSFunction? { JSObject.global[Strings.SVGElement].function }
7+
8+
public required init(unsafelyWrapping jsObject: JSObject) {
9+
- _className = ReadonlyAttribute(jsObject: jsObject, name: Strings.className)
10+
+ _svgClassName = ReadonlyAttribute(jsObject: jsObject, name: Strings.className)
11+
_ownerSVGElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.ownerSVGElement)
12+
_viewportElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.viewportElement)
13+
super.init(unsafelyWrapping: jsObject)
14+
}
15+
16+
+ // Renamed because superclass has a `className` property of type `String`
17+
+ // NOTE! Accessing `className` on an SVGElement will crash your app
18+
@ReadonlyAttribute
19+
- public var className: SVGAnimatedString
20+
+ public var svgClassName: SVGAnimatedString
21+
22+
@ReadonlyAttribute
23+
public var ownerSVGElement: SVGSVGElement?

Patches/WebAudio.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/Sources/WebAudio/Generated.swift b/Sources/WebAudio/Generated.swift
2+
index 35bbf34..770a8e8 100644
3+
--- a/Sources/WebAudio/Generated.swift
4+
+++ b/Sources/WebAudio/Generated.swift
5+
@@ -194,7 +194,8 @@ public class AudioBufferSourceNode: AudioScheduledSourceNode {
6+
@ReadWriteAttribute
7+
public var loopEnd: Double
8+
9+
- @inlinable override public func start(when: Double? = nil, offset: Double? = nil, duration: Double? = nil) {
10+
+ // `override` removed since the superclass function has fewer parameters
11+
+ @inlinable func start(when: Double? = nil, offset: Double? = nil, duration: Double? = nil) {
12+
let this = jsObject
13+
_ = this[Strings.start].function!(this: this, arguments: [_toJSValue(when), _toJSValue(offset), _toJSValue(duration)])
14+
}

Sources/CSSOM/Customized.swift

Lines changed: 0 additions & 41 deletions
This file was deleted.

Sources/CSSOM/Generated.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,39 @@ public enum CSSBoxType: JSString, JSValueCompatible {
347347
@inlinable public var jsValue: JSValue { rawValue.jsValue }
348348
}
349349

350+
public class CSSColor: CSSColorValue {
351+
@inlinable override public class var constructor: JSFunction? { JSObject.global[Strings.CSSColor].function }
352+
353+
public required init(unsafelyWrapping jsObject: JSObject) {
354+
_colorSpace = ReadWriteAttribute(jsObject: jsObject, name: Strings.colorSpace)
355+
_channels = ReadWriteAttribute(jsObject: jsObject, name: Strings.channels)
356+
_alpha = ReadWriteAttribute(jsObject: jsObject, name: Strings.alpha)
357+
super.init(unsafelyWrapping: jsObject)
358+
}
359+
360+
@inlinable public convenience init(colorSpace: CSSKeywordish, channels: [CSSColorPercent], alpha: CSSNumberish? = nil) {
361+
self.init(unsafelyWrapping: Self.constructor!.new(arguments: [_toJSValue(colorSpace), _toJSValue(channels), _toJSValue(alpha)]))
362+
}
363+
364+
@available(*, unavailable)
365+
override public var colorSpace: CSSKeywordValue {
366+
get { colorSpaceOrString.cssKeywordValue! }
367+
set { colorSpaceOrString = .cssKeywordValue(newValue) }
368+
}
369+
370+
@usableFromInline let _colorSpace: ReadWriteAttribute<CSSKeywordish>
371+
@inlinable public var colorSpaceOrString: CSSKeywordish {
372+
get { _colorSpace.wrappedValue }
373+
set { _colorSpace.wrappedValue = newValue }
374+
}
375+
376+
@ReadWriteAttribute
377+
public var channels: [CSSColorPercent]
378+
379+
@ReadWriteAttribute
380+
public var alpha: CSSNumberish
381+
}
382+
350383
public class CSSColorValue: CSSStyleValue {
351384
@inlinable override public class var constructor: JSFunction? { JSObject.global[Strings.CSSColorValue].function }
352385

@@ -2017,6 +2050,7 @@ public typealias CSSColorAngle = CSSColorRGBComp
20172050
@usableFromInline enum Strings {
20182051
static let _self: JSString = "self"
20192052
@usableFromInline static let CSS: JSString = "CSS"
2053+
@usableFromInline static let CSSColor: JSString = "CSSColor"
20202054
@usableFromInline static let CSSColorValue: JSString = "CSSColorValue"
20212055
@usableFromInline static let CSSGroupingRule: JSString = "CSSGroupingRule"
20222056
@usableFromInline static let CSSHSL: JSString = "CSSHSL"
@@ -2093,6 +2127,7 @@ public typealias CSSColorAngle = CSSColorRGBComp
20932127
@usableFromInline static let box: JSString = "box"
20942128
@usableFromInline static let c: JSString = "c"
20952129
@usableFromInline static let ch: JSString = "ch"
2130+
@usableFromInline static let channels: JSString = "channels"
20962131
@usableFromInline static let clear: JSString = "clear"
20972132
@usableFromInline static let cm: JSString = "cm"
20982133
@usableFromInline static let colorDepth: JSString = "colorDepth"

Sources/DOM/Customized.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Sources/DOM/Generated.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,28 @@ public class BarProp: JSBridgedClass {
949949
public var visible: Bool
950950
}
951951

952+
public class BeforeUnloadEvent: Event {
953+
@inlinable override public class var constructor: JSFunction? { JSObject.global[Strings.BeforeUnloadEvent].function }
954+
955+
public required init(unsafelyWrapping jsObject: JSObject) {
956+
_returnValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.returnValue)
957+
super.init(unsafelyWrapping: jsObject)
958+
}
959+
960+
@available(*, unavailable)
961+
override public var returnValue: Bool {
962+
get { !_returnValue.wrappedValue.isEmpty }
963+
set {}
964+
}
965+
966+
@usableFromInline let _returnValue: ReadWriteAttribute<String>
967+
// renamed because `String` is not compatible with `Bool`
968+
@inlinable public var returnValueAsString: String {
969+
get { _returnValue.wrappedValue }
970+
set { _returnValue.wrappedValue = newValue }
971+
}
972+
}
973+
952974
public enum BitrateMode: JSString, JSValueCompatible {
953975
case constant = "constant"
954976
case variable = "variable"
@@ -6963,7 +6985,11 @@ public class HTMLFormControlsCollection: HTMLCollection {
69636985
jsObject[key].fromJSValue()
69646986
}
69656987

6966-
// XXX: member 'namedItem' is ignored
6988+
// `override` removed since the superclass returns a more constrained type `Element`
6989+
@inlinable func namedItem(name: String) -> Element_or_RadioNodeList? {
6990+
let this = jsObject
6991+
return this[Strings.namedItem].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()!
6992+
}
69676993
}
69686994

69696995
public class HTMLFormElement: HTMLElement {
@@ -17872,6 +17898,7 @@ public class XSLTProcessor: JSBridgedClass {
1787217898
@usableFromInline static let AudioTrack: JSString = "AudioTrack"
1787317899
@usableFromInline static let AudioTrackList: JSString = "AudioTrackList"
1787417900
@usableFromInline static let BarProp: JSString = "BarProp"
17901+
@usableFromInline static let BeforeUnloadEvent: JSString = "BeforeUnloadEvent"
1787517902
@usableFromInline static let Blob: JSString = "Blob"
1787617903
@usableFromInline static let BlobEvent: JSString = "BlobEvent"
1787717904
@usableFromInline static let BroadcastChannel: JSString = "BroadcastChannel"

Sources/SVG/Customized.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

Sources/SVG/Generated.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,28 @@ public class SVGDiscardElement: SVGAnimationElement {
540540
}
541541
}
542542

543+
public class SVGElement: Element, GlobalEventHandlers, DocumentAndElementEventHandlers, SVGElementInstance, HTMLOrSVGElement {
544+
@inlinable override public class var constructor: JSFunction? { JSObject.global[Strings.SVGElement].function }
545+
546+
public required init(unsafelyWrapping jsObject: JSObject) {
547+
_svgClassName = ReadonlyAttribute(jsObject: jsObject, name: Strings.className)
548+
_ownerSVGElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.ownerSVGElement)
549+
_viewportElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.viewportElement)
550+
super.init(unsafelyWrapping: jsObject)
551+
}
552+
553+
// Renamed because superclass has a `className` property of type `String`
554+
// NOTE! Accessing `className` on an SVGElement will crash your app
555+
@ReadonlyAttribute
556+
public var svgClassName: SVGAnimatedString
557+
558+
@ReadonlyAttribute
559+
public var ownerSVGElement: SVGSVGElement?
560+
561+
@ReadonlyAttribute
562+
public var viewportElement: SVGElement?
563+
}
564+
543565
public protocol SVGElementInstance: JSBridgedClass {}
544566
public extension SVGElementInstance {
545567
@inlinable var correspondingElement: SVGElement? { jsObject[Strings.correspondingElement].fromJSValue()! }

0 commit comments

Comments
 (0)