Skip to content

Commit fe93266

Browse files
authored
Merge pull request #3598 from parkera/se86_rename_process
Rename Process to CommandLine
2 parents 3cb4a76 + 80c85e6 commit fe93266

26 files changed

+78
-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!) {
@@ -1126,7 +1126,7 @@ public func runAllTests() {
11261126
#endif
11271127

11281128
let _isChildProcess: Bool =
1129-
Process.arguments.contains("--stdlib-unittest-run-child")
1129+
CommandLine.arguments.contains("--stdlib-unittest-run-child")
11301130

11311131
if _isChildProcess {
11321132
_childProcess()
@@ -1136,15 +1136,15 @@ public func runAllTests() {
11361136
var args = [String]()
11371137
var i = 0
11381138
i += 1 // Skip the name of the executable.
1139-
while i < Process.arguments.count {
1140-
let arg = Process.arguments[i]
1139+
while i < CommandLine.arguments.count {
1140+
let arg = CommandLine.arguments[i]
11411141
if arg == "--stdlib-unittest-in-process" {
11421142
runTestsInProcess = true
11431143
i += 1
11441144
continue
11451145
}
11461146
if arg == "--stdlib-unittest-filter" {
1147-
filter = Process.arguments[i + 1]
1147+
filter = CommandLine.arguments[i + 1]
11481148
i += 2
11491149
continue
11501150
}
@@ -1162,7 +1162,7 @@ public func runAllTests() {
11621162
}
11631163

11641164
// Pass through unparsed arguments to the child process.
1165-
args.append(Process.arguments[i])
1165+
args.append(CommandLine.arguments[i])
11661166

11671167
i += 1
11681168
}

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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212

1313
import SwiftShims
1414

15+
/// Temporary typealias to aid in migration
16+
public typealias Process = CommandLine
17+
1518
/// Command-line arguments for the current process.
16-
public enum Process {
19+
public enum CommandLine {
1720
/// The backing static variable for argument count may come either from the
1821
/// entry point or it may need to be computed e.g. if we're in the REPL.
1922
@_versioned
@@ -31,7 +34,7 @@ public enum Process {
3134

3235
/// Access to the raw argc value from C.
3336
public static var argc: Int32 {
34-
_ = Process.unsafeArgv // Force evaluation of argv.
37+
_ = CommandLine.unsafeArgv // Force evaluation of argv.
3538
return _argc
3639
}
3740

@@ -54,10 +57,10 @@ public // COMPILER_INTRINSIC
5457
func _stdlib_didEnterMain(
5558
argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
5659
) {
57-
// Initialize the Process.argc and Process.unsafeArgv variables with the
60+
// Initialize the CommandLine.argc and CommandLine.unsafeArgv variables with the
5861
// values that were passed in to main.
59-
Process._argc = Int32(argc)
60-
Process._unsafeArgv = argv
62+
CommandLine._argc = Int32(argc)
63+
CommandLine._unsafeArgv = argv
6164
}
6265

6366
// 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)