Skip to content

Commit f65c139

Browse files
committed
Rename Process to CommandLine
Rename Process to CommandLine [SE-0086].
1 parent e25c751 commit f65c139

26 files changed

+75
-75
lines changed

benchmark/utils/ArgParse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct Arguments {
2424
}
2525
}
2626

27-
/// Using Process.arguments, returns an Arguments struct describing
27+
/// Using CommandLine.arguments, returns an Arguments struct describing
2828
/// the arguments to this program. If we fail to parse arguments, we
2929
/// return nil.
3030
///
@@ -37,13 +37,13 @@ public struct Arguments {
3737
/// other option passed in is assumed to be a positional argument.
3838
public func parseArgs(_ validOptions: [String]? = nil)
3939
-> Arguments? {
40-
let progName = Process.arguments[0]
40+
let progName = CommandLine.arguments[0]
4141
var positionalArgs = [String]()
4242
var optionalArgsMap = [String : String]()
4343

4444
// For each argument we are passed...
4545
var passThroughArgs = false
46-
for arg in Process.arguments[1..<Process.arguments.count] {
46+
for arg in CommandLine.arguments[1..<CommandLine.arguments.count] {
4747
// If the argument doesn't match the optional argument pattern. Add
4848
// it to the positional argument list and continue...
4949
if passThroughArgs || !arg.characters.starts(with: "-".characters) {

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func _stdlib_getline() -> String? {
584584

585585
func _printDebuggingAdvice(_ fullTestName: String) {
586586
print("To debug, run:")
587-
var invocation = [Process.arguments[0]]
587+
var invocation = [CommandLine.arguments[0]]
588588
let interpreter = getenv("SWIFT_INTERPRETER")
589589
if interpreter != nil {
590590
if let interpreterCmd = String(validatingUTF8: interpreter!) {
@@ -1122,7 +1122,7 @@ public func runAllTests() {
11221122
#endif
11231123

11241124
let _isChildProcess: Bool =
1125-
Process.arguments.contains("--stdlib-unittest-run-child")
1125+
CommandLine.arguments.contains("--stdlib-unittest-run-child")
11261126

11271127
if _isChildProcess {
11281128
_childProcess()
@@ -1132,15 +1132,15 @@ public func runAllTests() {
11321132
var args = [String]()
11331133
var i = 0
11341134
i += 1 // Skip the name of the executable.
1135-
while i < Process.arguments.count {
1136-
let arg = Process.arguments[i]
1135+
while i < CommandLine.arguments.count {
1136+
let arg = CommandLine.arguments[i]
11371137
if arg == "--stdlib-unittest-in-process" {
11381138
runTestsInProcess = true
11391139
i += 1
11401140
continue
11411141
}
11421142
if arg == "--stdlib-unittest-filter" {
1143-
filter = Process.arguments[i + 1]
1143+
filter = CommandLine.arguments[i + 1]
11441144
i += 2
11451145
continue
11461146
}
@@ -1158,7 +1158,7 @@ public func runAllTests() {
11581158
}
11591159

11601160
// Pass through unparsed arguments to the child process.
1161-
args.append(Process.arguments[i])
1161+
args.append(CommandLine.arguments[i])
11621162

11631163
i += 1
11641164
}

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public func spawnChild(_ args: [String])
110110
// Start the executable. If execve() does not encounter an error, the
111111
// code after this block will never be executed, and the parent write pipe
112112
// will be closed.
113-
withArrayOfCStrings([Process.arguments[0]] + args) {
114-
execve(Process.arguments[0], $0, _getEnviron())
113+
withArrayOfCStrings([CommandLine.arguments[0]] + args) {
114+
execve(CommandLine.arguments[0], $0, _getEnviron())
115115
}
116116

117117
// If execve() encountered an error, we write the errno encountered to the
@@ -182,7 +182,7 @@ public func spawnChild(_ args: [String])
182182

183183
var pid: pid_t = -1
184184
var childArgs = args
185-
childArgs.insert(Process.arguments[0], at: 0)
185+
childArgs.insert(CommandLine.arguments[0], at: 0)
186186
let interpreter = getenv("SWIFT_INTERPRETER")
187187
if interpreter != nil {
188188
if let invocation = String(validatingUTF8: interpreter!) {

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ set(SWIFTLIB_SOURCES
133133
CollectionOfOne.swift
134134
ExistentialCollection.swift.gyb
135135
Mirror.swift
136-
Process.swift
136+
CommandLine.swift
137137
SliceBuffer.swift
138138
Tuple.swift.gyb
139139
UnfoldSequence.swift

stdlib/public/core/Process.swift renamed to stdlib/public/core/CommandLine.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SwiftShims
1414

1515
/// Command-line arguments for the current process.
16-
public enum Process {
16+
public enum CommandLine {
1717
/// The backing static variable for argument count may come either from the
1818
/// entry point or it may need to be computed e.g. if we're in the REPL.
1919
@_versioned
@@ -31,7 +31,7 @@ public enum Process {
3131

3232
/// Access to the raw argc value from C.
3333
public static var argc: Int32 {
34-
_ = Process.unsafeArgv // Force evaluation of argv.
34+
_ = CommandLine.unsafeArgv // Force evaluation of argv.
3535
return _argc
3636
}
3737

@@ -54,10 +54,10 @@ public // COMPILER_INTRINSIC
5454
func _stdlib_didEnterMain(
5555
argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
5656
) {
57-
// Initialize the Process.argc and Process.unsafeArgv variables with the
57+
// Initialize the CommandLine.argc and CommandLine.unsafeArgv variables with the
5858
// values that were passed in to main.
59-
Process._argc = Int32(argc)
60-
Process._unsafeArgv = argv
59+
CommandLine._argc = Int32(argc)
60+
CommandLine._unsafeArgv = argv
6161
}
6262

6363
// FIXME: Move this to HashedCollections.swift.gyb

stdlib/public/core/GroupInfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"Shims.swift",
139139
"Unmanaged.swift",
140140
"Availability.swift",
141-
"Process.swift",
141+
"CommandLine.swift",
142142
"Tuple.swift",
143143
"NewtypeWrapper.swift",
144144
"UnsafeBitMap.swift",

stdlib/public/stubs/CommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "../SwiftShims/RuntimeStubs.h"
3030
#include "../SwiftShims/GlobalObjects.h"
3131

32-
// Backing storage for overrides of `Swift.Process.arguments`.
32+
// Backing storage for overrides of `Swift.CommandLine.arguments`.
3333
static char **_swift_stdlib_ProcessOverrideUnsafeArgv = nullptr;
3434
static int _swift_stdlib_ProcessOverrideUnsafeArgc = 0;
3535

test/1_stdlib/CommandLine.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
//
4+
//
5+
// RUN: %target-build-swift %S/Inputs/CommandLineStressTest/CommandLineStressTest.swift -parse-as-library -force-single-frontend-invocation -module-name CommandLineStressTestSwift -emit-object -o %t/CommandLineStressTestSwift.o
6+
// RUN: %clang -arch %target-cpu -c -o %t/CommandLineStressTest.o -x c %S/Inputs/CommandLineStressTest/CommandLineStressTest.c
7+
// RUN: %target-build-swift %t/CommandLineStressTest.o %t/CommandLineStressTestSwift.o -o %t/CommandLineStressTest
8+
// RUN: %target-run %t/CommandLineStressTest foo bar baz qux quux corge grault garply waldo fred plugh xyzzy and thud
9+
// REQUIRES: executable_test
10+
11+
// This file is an empty stub to call into the command line stress test which
12+
// houses `main`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "CommandLineStressTest.h"
2+
3+
int main(int argc, char **argv) {
4+
swift_commandline_test_getProcessArgs();
5+
return 0;
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Declared in CommandLineStressTest.swift.
2+
extern void swift_commandline_test_getProcessArgs(void);

0 commit comments

Comments
 (0)