-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from tayloraswift/custom-conditions
implement a way to pass custom defines from SSGC.CompileCommand down to SSGC.Linker.Tables
- Loading branch information
Showing
33 changed files
with
664 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
Sources/LinkResolution/Codelinks/UCF.ConditionFilter (ext).swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import UCF | ||
|
||
extension UCF | ||
{ | ||
@frozen @usableFromInline | ||
enum ConditionError:Error | ||
{ | ||
case value(Condition, String) | ||
case valueExpected(Condition) | ||
} | ||
} | ||
extension UCF.ConditionError:CustomStringConvertible | ||
{ | ||
@usableFromInline | ||
var description:String | ||
{ | ||
switch self | ||
{ | ||
case .value(let condition, let value): | ||
"value '\(value)' is invalid for condition '\(condition)'" | ||
case .valueExpected(let condition): | ||
"value expected for condition '\(condition)'" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import UCF | ||
|
||
extension UCF.ConditionFilter | ||
{ | ||
@inlinable public | ||
func value<T>(as _:T.Type = T.self) throws -> T where T:LosslessStringConvertible | ||
{ | ||
guard | ||
let value:String = self.value | ||
else | ||
{ | ||
throw UCF.ConditionError.valueExpected(self.label) | ||
} | ||
|
||
guard | ||
let result:T = .init(value) | ||
else | ||
{ | ||
throw UCF.ConditionError.value(self.label, value) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func callAsFunction<T>(as _:T.Type = T.self, | ||
default:T) throws -> (UCF.Condition, T) where T:LosslessStringConvertible | ||
{ | ||
guard | ||
let value:String = self.value | ||
else | ||
{ | ||
return (self.label, `default`) | ||
} | ||
|
||
guard | ||
let result:T = .init(value) | ||
else | ||
{ | ||
throw UCF.ConditionError.value(self.label, value) | ||
} | ||
|
||
return (self.label, result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.