Skip to content

Commit a2bbb65

Browse files
committed
Fix deprecations
1 parent e8f7a02 commit a2bbb65

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

Macros/ECSMacros/ECSComponentMacro.swift

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public enum ComponentMacroError: Error, CustomStringConvertible {
2323
}
2424
}
2525

26-
public struct ECSComponentMacro: MemberMacro, ExtensionMacro {
26+
public struct ECSComponentMacro: ExtensionMacro {
2727
public static func expansion(
28-
of node: SwiftSyntax.AttributeSyntax,
29-
attachedTo declaration: some SwiftSyntax.DeclGroupSyntax,
30-
providingExtensionsOf type: some SwiftSyntax.TypeSyntaxProtocol,
31-
conformingTo protocols: [SwiftSyntax.TypeSyntax],
32-
in context: some SwiftSyntaxMacros.MacroExpansionContext
28+
of node: AttributeSyntax,
29+
attachedTo declaration: some DeclGroupSyntax,
30+
providingExtensionsOf type: some TypeSyntaxProtocol,
31+
conformingTo protocols: [TypeSyntax],
32+
in context: some MacroExpansionContext
3333
) throws -> [SwiftSyntax.ExtensionDeclSyntax] {
3434
let isClass = declaration.as(ClassDeclSyntax.self) != nil
3535
guard let name = declaration.as(ClassDeclSyntax.self)?.name.trimmed ?? declaration.as(StructDeclSyntax.self)?.name.trimmed else {
@@ -56,38 +56,10 @@ public struct ECSComponentMacro: MemberMacro, ExtensionMacro {
5656
})?.trimmedDescription ?? ""
5757

5858
let extensionBody = "\(access) static let componentID: GateEngine.ComponentID = .init()"
59-
60-
// let find = try InitializerDeclSyntax("init()") {
61-
//
62-
// }
63-
64-
// if declaration.memberBlock.members.compactMap({InitializerDeclSyntax($0)}).isEmpty == true {
65-
// extensionBody = "\(access) init() { }" + "\n" + extensionBody
66-
// }
67-
6859
extensionDeclaration += "{\n" + extensionBody + "\n}"
6960

7061
return [
7162
try ExtensionDeclSyntax(SyntaxNodeString(stringLiteral: extensionDeclaration))
7263
]
7364
}
74-
75-
// public static func expansion(
76-
// of node: SwiftSyntax.AttributeSyntax,
77-
// providingPeersOf declaration: some SwiftSyntax.DeclSyntaxProtocol,
78-
// in context: some SwiftSyntaxMacros.MacroExpansionContext
79-
// ) throws -> [SwiftSyntax.DeclSyntax] {
80-
// guard let classDecl = declaration.as(ClassDeclSyntax.self) else {
81-
// throw SystemMacroError.notClass
82-
// }
83-
// let className = classDecl.name.trimmed
84-
// return [DeclSyntax(
85-
//"""
86-
//@_cdecl(\"eventHandler\")
87-
//fileprivate func _eventHandler(pointer: UnsafeMutableRawPointer!, event: System.Event, arg: CUnsignedInt) -> CInt {
88-
// return \(className)._eventHandler(pointer: pointer, event: event, arg: arg)
89-
//}
90-
//"""
91-
// )]
92-
// }
9365
}

Sources/GateEngine/Resources/Import & Export/Importers/ApplePlatformImageImporter.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ImageIO
1010
import CoreImage
1111
import CoreServices
1212
import GameMath
13+
import UniformTypeIdentifiers
1314

1415
public final class ApplePlatformImageImporter: TextureImporter {
1516
var data: Data! = nil
@@ -59,17 +60,13 @@ public final class ApplePlatformImageImporter: TextureImporter {
5960
public static func canProcessFile(_ path: String) -> Bool {
6061
let pathExtension = URL(fileURLWithPath: path).pathExtension
6162
guard pathExtension.isEmpty == false else {return false}
62-
guard let identifiers = (CGImageSourceCopyTypeIdentifiers() as? [CFString]) else {
63+
guard let uttype = UTType(tag: pathExtension, tagClass: .filenameExtension, conformingTo: .image) else {
6364
return false
6465
}
65-
guard
66-
let uttype = UTTypeCreatePreferredIdentifierForTag(
67-
kUTTagClassFilenameExtension,
68-
pathExtension as CFString,
69-
kUTTypeImage
70-
)?.takeRetainedValue()
71-
else { return false }
72-
return identifiers.contains(where: { $0 == uttype })
66+
guard let identifiers = CGImageSourceCopyTypeIdentifiers() as? [CFString] else {
67+
return false
68+
}
69+
return identifiers.contains(where: { UTType($0 as String) == uttype })
7370
}
7471
}
7572

0 commit comments

Comments
 (0)