From 387fc7e0c9c83980ede2166232b135c8f7158506 Mon Sep 17 00:00:00 2001 From: Galvin Date: Wed, 8 May 2024 13:54:58 +0800 Subject: [PATCH] fix missing extension, if the class is defined, don't add new extension to it's `mixins` anymore. --- Sources/CSSOM/Generated.swift | 6 ++++++ Sources/WebIDLToSwift/MergeDeclarations.swift | 5 ++++- Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/CSSOM/Generated.swift b/Sources/CSSOM/Generated.swift index 10b24e1..ecc5dc7 100644 --- a/Sources/CSSOM/Generated.swift +++ b/Sources/CSSOM/Generated.swift @@ -1666,6 +1666,8 @@ public extension ElementCSSInlineStyle { @inlinable var attributeStyleMap: StylePropertyMap { jsObject[Strings.attributeStyleMap].fromJSValue()! } } +extension HTMLElement: ElementCSSInlineStyle {} + extension MathMLElement: ElementCSSInlineStyle {} extension SVGElement: ElementCSSInlineStyle {} @@ -1695,6 +1697,10 @@ public extension GeometryUtils { extension CSSPseudoElement: GeometryUtils {} +extension Document: GeometryUtils {} + +extension Element: GeometryUtils {} + extension Text: GeometryUtils {} public protocol LinkStyle: JSBridgedClass {} diff --git a/Sources/WebIDLToSwift/MergeDeclarations.swift b/Sources/WebIDLToSwift/MergeDeclarations.swift index dfd9d0e..88e707d 100644 --- a/Sources/WebIDLToSwift/MergeDeclarations.swift +++ b/Sources/WebIDLToSwift/MergeDeclarations.swift @@ -15,6 +15,7 @@ enum DeclarationMerger { static let validExposures: Set = ["Window"] static let ignoredParents: Set = ["LinkStyle"] + static var defindedClass: Set = [] private static func enhanceMembers(_ members: [IDLNode]) -> [IDLNode] { members.flatMap { member -> [IDLNode] in @@ -148,7 +149,9 @@ enum DeclarationMerger { partialResult.exposedToAll = partialResult.exposedToAll || interface.exposedToAll partialResult.global = partialResult.global || interface.global } - interface.mixins = includes.removeValue(forKey: interface.name) ?? [] + if !DeclarationMerger.defindedClass.contains(interface.name) { + interface.mixins = includes.removeValue(forKey: interface.name) ?? [] + } if let decl = interface.members.first(where: { $0 is IDLIterableDeclaration }) as? IDLIterableDeclaration { interface.mixins.append(decl.async ? "AsyncSequence" : "Sequence") } diff --git a/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift b/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift index afe8dcf..67bb0ab 100644 --- a/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift +++ b/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift @@ -243,6 +243,7 @@ extension MergedInterface: SwiftRepresentable { } else { let inheritance = (parentClasses.isEmpty ? ["JSBridgedClass"] : parentClasses) + mixins header = "\(access) class \(name): \(sequence: inheritance.map(SwiftSource.init(_:)))" + DeclarationMerger.defindedClass.insert(name) } return """