Skip to content

[SE-0046] Implemented consistent function labels #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Build/Buildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protocol Buildable {

extension CModule {
///Returns the build directory path of a CModule
func buildDirectory(prefix: String) -> String {
func buildDirectory(_ prefix: String) -> String {
return Path.join(prefix, "\(c99name).build")
}
}
Expand All @@ -28,7 +28,7 @@ extension Module: Buildable {
return self is TestModule
}

func XccFlags(prefix: String) -> [String] {
func XccFlags(_ prefix: String) -> [String] {
return recursiveDependencies.flatMap { module -> [String] in
if let module = module as? ClangModule {
///For ClangModule we check if there is a user provided module map
Expand Down
6 changes: 3 additions & 3 deletions Sources/Build/Command.compile(ClangModule).swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private extension ClangModule {
return args
}

func includeFlagsWithExternalModules(externalModules: Set<Module>) -> [String] {
func includeFlagsWithExternalModules(_ externalModules: Set<Module>) -> [String] {
var args: [String] = []
for case let dep as ClangModule in dependencies {
let includeFlag: String
Expand All @@ -45,7 +45,7 @@ private extension ClangModule {
return args
}

func optimizationFlags(conf: Configuration) -> [String] {
func optimizationFlags(_ conf: Configuration) -> [String] {
switch conf {
case .Debug:
return ["-g", "-O0"]
Expand All @@ -56,7 +56,7 @@ private extension ClangModule {
}

private extension Sources {
func compilePathsForBuildDir(wd: String) -> [(filename: String, source: String, object: String, deps: String)] {
func compilePathsForBuildDir(_ wd: String) -> [(filename: String, source: String, object: String, deps: String)] {
return relativePaths.map { source in
let path = Path.join(root, source)
let object = Path.join(wd, "\(source).o")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/Command.compile(SwiftModule).swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension Command {

let otherArgs = otherArgs + module.XccFlags(prefix)

func cmd(tool: ToolProtocol) -> Command {
func cmd(_ tool: ToolProtocol) -> Command {
return Command(node: module.targetName, tool: tool)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/Command.link().swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Utility


extension Command {
static func link(product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {
static func link(_ product: Product, configuration conf: Configuration, prefix: String, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {

let objects: [String]
switch conf {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Command {
let node: String
let tool: ToolProtocol

static func createDirectory(path: String) -> Command {
static func createDirectory(_ path: String) -> Command {
return Command(node: path, tool: MkdirTool(path: path))
}
}
2 changes: 1 addition & 1 deletion Sources/Build/YAML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension Bool: YAMLRepresentable {

extension Array where Element: YAMLRepresentable {
var YAML: String {
func quote(input: String) -> String {
func quote(_ input: String) -> String {
for c in input.characters {
if c == "@" || c == " " || c == "-" || c == "&" {
return "\"\(input)\""
Expand Down
6 changes: 3 additions & 3 deletions Sources/Build/describe().swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Utility
/**
- Returns: path to generated YAML for consumption by the llbuild based swift-build-tool
*/
public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set<Module>, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String {
public func describe(_ prefix: String, _ conf: Configuration, _ modules: [Module], _ externalModules: Set<Module>, _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String], toolchain: Toolchain) throws -> String {

guard modules.count > 0 else {
throw Error.NoModules
Expand Down Expand Up @@ -78,7 +78,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
}
}

private func write(path path: String, write: ((String) -> Void) -> Void) throws -> String {
private func write(path: String, write: ((String) -> Void) -> Void) throws -> String {
var storedError: ErrorProtocol?

try fopen(path, mode: .Write) { fp in
Expand All @@ -105,7 +105,7 @@ private struct Targets {
var test = Target(node: "test", cmds: [])
var main = Target(node: "default", cmds: [])

mutating func append(command: Command, for buildable: Buildable) {
mutating func append(_ command: Command, for buildable: Buildable) {
if buildable.isTest {
test.cmds.append(command)
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extension ClangModule {
}

///warn user if in case module name and c99name are different and there a `name.h` umbrella header
private func diagnoseInvalidUmbrellaHeader(path: String) {
private func diagnoseInvalidUmbrellaHeader(_ path: String) {
let umbrellaHeader = Path.join(path, "\(c99name).h")
let invalidUmbrellaHeader = Path.join(path, "\(name).h")
if c99name != name && invalidUmbrellaHeader.isFile {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/Fetchable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ protocol Fetchable {
//FIXME protocols cannot impose new property constraints,
// so Package has a version { get } already, we cannot add
// a set, so instead we have to have this protocol func
func setVersion(newValue: Version) throws
func setVersion(_ newValue: Version) throws
}
14 changes: 7 additions & 7 deletions Sources/Get/Fetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import struct PackageDescription.Version
protocol Fetcher {
associatedtype T: Fetchable

func find(url url: String) throws -> Fetchable?
func fetch(url url: String) throws -> Fetchable
func finalize(fetchable: Fetchable) throws -> T
func find(url: String) throws -> Fetchable?
func fetch(url: String) throws -> Fetchable
func finalize(_ fetchable: Fetchable) throws -> T

func recursivelyFetch(urls: [(String, Range<Version>)]) throws -> [T]
func recursivelyFetch(_ urls: [(String, Range<Version>)]) throws -> [T]
}

extension Fetcher {
Expand All @@ -30,15 +30,15 @@ extension Fetcher {

This is our standard implementation that we override when testing.
*/
func recursivelyFetch(urls: [(String, Range<Version>)]) throws -> [T] {
func recursivelyFetch(_ urls: [(String, Range<Version>)]) throws -> [T] {

var graph = [String: (Fetchable, Range<Version>)]()

func recurse(urls: [(String, Range<Version>)]) throws -> [String] {
func recurse(_ urls: [(String, Range<Version>)]) throws -> [String] {

return try urls.flatMap { url, specifiedVersionRange -> [String] in

func adjust(pkg: Fetchable, _ versionRange: Range<Version>) throws {
func adjust(_ pkg: Fetchable, _ versionRange: Range<Version>) throws {
guard let v = pkg.constrain(to: versionRange) else {
throw Error.InvalidDependencyGraphMissingTag(package: url, requestedTag: "\(versionRange)", existingTags: "\(pkg.availableVersions)")
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import enum POSIX.Error
import Utility

extension Git {
class func clone(url: String, to dstdir: String) throws -> Repo {
class func clone(_ url: String, to dstdir: String) throws -> Repo {
// canonicalize URL
var url = url
if URL.scheme(url) == nil {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Get/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Utility
extension Package {
// FIXME we *always* have a manifest, don't reparse it

static func make(repo repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? {
static func make(repo: Git.Repo, manifestParser: (path: String, url: String) throws -> Manifest) throws -> Package? {
guard let origin = repo.origin else { throw Error.NoOrigin(repo.path) }
let manifest = try manifestParser(path: repo.path, url: origin)
let pkg = Package(manifest: manifest, url: origin)
Expand Down Expand Up @@ -45,7 +45,7 @@ extension Package: Fetchable {
return [version]
}

func setVersion(newValue: Version) throws {
func setVersion(_ newValue: Version) throws {
throw Get.Error.InvalidDependencyGraph(url)
}
}
6 changes: 3 additions & 3 deletions Sources/Get/PackagesDirectory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PackagesDirectory {
extension PackagesDirectory: Fetcher {
typealias T = Package

func find(url url: String) throws -> Fetchable? {
func find(url: String) throws -> Fetchable? {
for prefix in walk(self.prefix, recursively: false) {
guard let repo = Git.Repo(path: prefix) else { continue } //TODO warn user
guard repo.origin == url else { continue }
Expand All @@ -39,7 +39,7 @@ extension PackagesDirectory: Fetcher {
return nil
}

func fetch(url url: String) throws -> Fetchable {
func fetch(url: String) throws -> Fetchable {
let dstdir = Path.join(prefix, Package.nameForURL(url))
if let repo = Git.Repo(path: dstdir) where repo.origin == url {
//TODO need to canonicalize the URL need URL struct
Expand All @@ -52,7 +52,7 @@ extension PackagesDirectory: Fetcher {
return try RawClone(path: dstdir, manifestParser: manifestParser)
}

func finalize(fetchable: Fetchable) throws -> Package {
func finalize(_ fetchable: Fetchable) throws -> Package {
switch fetchable {
case let clone as RawClone:
let prefix = Path.join(self.prefix, clone.finalName)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/RawClone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RawClone: Fetchable {
}

/// contract, you cannot call this before you have attempted to `constrain` this clone
func setVersion(ver: Version) throws {
func setVersion(_ ver: Version) throws {
let packageVersionsArePrefixed = repo.versionsArePrefixed
let v = (packageVersionsArePrefixed ? "v" : "") + ver.description
try Git.runPopen([Git.tool, "-C", path, "reset", "--hard", v])
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension Version {
return self.min..<self.max
}

static func vprefix(string: String.CharacterView) -> Version? {
static func vprefix(_ string: String.CharacterView) -> Version? {
if string.first == "v" {
return Version(string.dropFirst())
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Get/get().swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Utility
- Throws: Error.InvalidDependencyGraph
- Returns: The modules that this manifest requires building
*/
public func get(manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) {
public func get(_ manifest: Manifest, manifestParser: (path: String, url: String) throws -> Manifest) throws -> (rootPackage: Package, externalPackages:[Package]) {
let dir = Path.join(manifest.path.parentDirectory, "Packages")
let box = PackagesDirectory(prefix: dir, manifestParser: manifestParser)

Expand Down
18 changes: 9 additions & 9 deletions Sources/ManifestParser/TOML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private struct Parser {
}

/// Find the new table to insert into given the top-level table and a list of specifiers.
private mutating func findInsertPoint(topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable {
private mutating func findInsertPoint(_ topLevelTable: TOMLItemTable, _ specifiers: [String], isAppend: Bool, startToken: Lexer.Token) -> TOMLItemTable {
// FIXME: Handle TOML requirements (sole definition).
var into = topLevelTable
for (i,specifier) in specifiers.enumerated() {
Expand Down Expand Up @@ -517,7 +517,7 @@ private struct Parser {
/// item), including the terminating brackets.
///
/// - Parameter isAppend: Whether the specifier should end with double brackets.
private mutating func parseTableSpecifier(isAppend: Bool) -> [String]? {
private mutating func parseTableSpecifier(_ isAppend: Bool) -> [String]? {
let startToken = lookahead

// Parse all of the specifiers.
Expand Down Expand Up @@ -573,7 +573,7 @@ private struct Parser {
// MARK: Parser Implementation

/// Report an error at the given token.
private mutating func error(message: String, at: Lexer.Token) {
private mutating func error(_ message: String, at: Lexer.Token) {
errors.append(message)
}

Expand All @@ -588,7 +588,7 @@ private struct Parser {
}

/// Consume a token if it matches a particular block.
private mutating func consumeIf(match: (Lexer.Token) -> Bool) -> Bool {
private mutating func consumeIf(_ match: (Lexer.Token) -> Bool) -> Bool {
if match(lookahead) {
eat()
return true
Expand All @@ -610,7 +610,7 @@ private struct Parser {
}

/// Parse the contents of a table, stopping at the next table marker.
private mutating func parseTableContents(table: TOMLItemTable) {
private mutating func parseTableContents(_ table: TOMLItemTable) {
// Parse assignments until we reach the EOF or a new table record.
while lookahead != .EOF && lookahead != .LSquare {
// If we have a bare newline, ignore it.
Expand All @@ -624,7 +624,7 @@ private struct Parser {
}

/// Parse an individual table assignment.
private mutating func parseAssignment(table: TOMLItemTable) {
private mutating func parseAssignment(_ table: TOMLItemTable) {
// Parse the LHS.
let key: String
switch eat() {
Expand Down Expand Up @@ -727,7 +727,7 @@ private struct Parser {
return .Array(contents: array)
}

private func parseNumberItem(spelling: String) -> TOMLItem? {
private func parseNumberItem(_ spelling: String) -> TOMLItem? {

let normalized = String(spelling.characters.filter { $0 != "_" })

Expand All @@ -749,7 +749,7 @@ public struct TOMLParsingError : ErrorProtocol {

/// Public interface to parsing TOML.
public extension TOMLItem {
static func parse(data: Swift.String) throws -> TOMLItem {
static func parse(_ data: Swift.String) throws -> TOMLItem {
// Parse the string.
var parser = Parser(data)
let result = parser.parse()
Expand All @@ -768,7 +768,7 @@ public extension TOMLItem {
/// Internal function for testing the lexer.
///
/// returns: A list of the lexed tokens' string representations.
internal func lexTOML(data: String) -> [String] {
internal func lexTOML(_ data: String) -> [String] {
let lexer = Lexer(data)
return lexer.map { String($0) }
}
10 changes: 5 additions & 5 deletions Sources/ManifestParser/fromTOML().swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Utility
import PackageDescription

extension PackageDescription.Package {
public static func fromTOML(item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package {
public static func fromTOML(_ item: TOMLItem, baseURL: String? = nil) -> PackageDescription.Package {
// This is a private API, currently, so we do not currently try and
// validate the input.
guard case .Table(let topLevelTable) = item else { fatalError("unexpected item") }
Expand Down Expand Up @@ -61,7 +61,7 @@ extension PackageDescription.Package {
}

extension PackageDescription.Package.Dependency {
public static func fromTOML(item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency {
public static func fromTOML(_ item: TOMLItem, baseURL: String?) -> PackageDescription.Package.Dependency {
guard case .Array(let array) = item where array.items.count == 3 else {
fatalError("Unexpected TOMLItem")
}
Expand All @@ -86,7 +86,7 @@ extension PackageDescription.Package.Dependency {
}

extension PackageDescription.Target {
private static func fromTOML(item: TOMLItem) -> PackageDescription.Target {
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target {
// This is a private API, currently, so we do not currently try and
// validate the input.
guard case .Table(let table) = item else { fatalError("unexpected item") }
Expand All @@ -106,7 +106,7 @@ extension PackageDescription.Target {
}

extension PackageDescription.Target.Dependency {
private static func fromTOML(item: TOMLItem) -> PackageDescription.Target.Dependency {
private static func fromTOML(_ item: TOMLItem) -> PackageDescription.Target.Dependency {
guard case .String(let name) = item else { fatalError("unexpected item") }
return .Target(name: name)
}
Expand Down Expand Up @@ -142,7 +142,7 @@ extension PackageDescription.Product {
self.init(name: name, type: type, modules: modules)
}

public static func fromTOML(item: TOMLItem) -> [PackageDescription.Product] {
public static func fromTOML(_ item: TOMLItem) -> [PackageDescription.Product] {
guard case .Table(let root) = item else { fatalError("unexpected item") }
guard let productsItem = root.items["products"] else { return [] }
guard case .Array(let array) = productsItem else { fatalError("products wrong type") }
Expand Down
6 changes: 3 additions & 3 deletions Sources/Multitool/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension Error: CustomStringConvertible {
}
}

@noreturn public func handleError(msg: Any, usage: ((String) -> Void) -> Void) {
@noreturn public func handleError(_ msg: Any, usage: ((String) -> Void) -> Void) {
switch msg {
case CommandLineError.InvalidUsage(let hint, let mode):
print(error: "invalid usage: \(hint)")
Expand All @@ -77,14 +77,14 @@ extension Error: CustomStringConvertible {
exit(1)
}

private func red(input: Any) -> String {
private func red(_ input: Any) -> String {
let input = "\(input)"
let ESC = "\u{001B}"
let CSI = "\(ESC)["
return CSI + "31m" + input + CSI + "0m"
}

private func print(error error: Any) {
private func print(error: Any) {
if !isatty(fileno(libc.stderr)) {
let cmd = Process.arguments.first?.basename ?? "SwiftPM"
print("\(cmd): error:", error, to: &stderr)
Expand Down
Loading