Skip to content

Commit

Permalink
Renamed StartVersion to VersionApplicability
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle committed Oct 17, 2023
1 parent c254570 commit 14f2a85
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Sources/WindowsMetadata/ActivatableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import DotNetMetadata

public struct ActivatableData {
public var type: InterfaceDefinition? = nil
public var startVersion: StartVersion
public var applicability: VersionApplicability

public init(type: InterfaceDefinition? = nil, startVersion: StartVersion) {
public init(type: InterfaceDefinition? = nil, applicability: VersionApplicability) {
self.type = type
self.startVersion = startVersion
self.applicability = applicability
}
}
12 changes: 6 additions & 6 deletions Sources/WindowsMetadata/FoundationAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public enum FoundationAttributes {

if case .type(let definition) = arguments[0] {
guard let type = definition as? InterfaceDefinition else { throw InvalidMetadataError.attributeArguments }
return ActivatableData(type: type, startVersion: try toStartVersion(arguments[1...]))
return ActivatableData(type: type, applicability: try toVersionApplicability(arguments[1...]))
}
else {
return ActivatableData(startVersion: try toStartVersion(arguments[...]))
return ActivatableData(applicability: try toVersionApplicability(arguments[...]))
}
}
}
Expand All @@ -57,14 +57,14 @@ public enum FoundationAttributes {
guard arguments.count >= 2 else { throw InvalidMetadataError.attributeArguments }
guard case .type(let definition) = arguments[0],
let type = definition as? InterfaceDefinition else { throw InvalidMetadataError.attributeArguments }
return StaticInterface(type: type, startVersion: try toStartVersion(arguments[1...]))
return StaticInterface(type: type, applicability: try toVersionApplicability(arguments[1...]))
}
}

private static func toStartVersion(_ arguments: ArraySlice<Attribute.Value>) throws -> StartVersion {
private static func toVersionApplicability(_ arguments: ArraySlice<Attribute.Value>) throws -> VersionApplicability {
guard arguments.count >= 1 else { throw InvalidMetadataError.attributeArguments }

var context: StartVersion.Context?
var context: VersionApplicability.Context?
if arguments.count == 2 {
guard case .constant(let contextConstant) = arguments.last! else { throw InvalidMetadataError.attributeArguments }
switch contextConstant {
Expand All @@ -80,7 +80,7 @@ public enum FoundationAttributes {
guard case .constant(let versionConstant) = arguments.first!,
case .uint32(let version) = versionConstant else { throw InvalidMetadataError.attributeArguments }

return StartVersion(version: .init(unpacking: version), context: context)
return VersionApplicability(version: .init(unpacking: version), context: context)
}

public static func isDefaultInterface(_ baseInterface: BaseInterface) throws -> Bool {
Expand Down
6 changes: 3 additions & 3 deletions Sources/WindowsMetadata/StaticInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import DotNetMetadata

public struct StaticInterface {
public var type: TypeDefinition
public var startVersion: StartVersion
public var applicability: VersionApplicability

public init(type: TypeDefinition, startVersion: StartVersion) {
public init(type: TypeDefinition, applicability: VersionApplicability) {
self.type = type
self.startVersion = startVersion
self.applicability = applicability
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public struct StartVersion {
public struct VersionApplicability {
public enum Context {
case contract(name: String)
case platform(Platform)
Expand Down

0 comments on commit 14f2a85

Please sign in to comment.