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

+3-3
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

+6-6
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

+3-3
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

+1-1
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 stdlib/public/core/CommandLine.swift

+5-5
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

+1-1
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

+1-1
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

+12
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`.
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+
}
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);

test/1_stdlib/Inputs/ProcessStressTest/ProcessStressTest.swift test/1_stdlib/Inputs/CommandLineStressTest/CommandLineStressTest.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
// Do not change the SIL name for this without also changing ProcessStressTest.c
2-
@_silgen_name("swift_process_test_getProcessArgs")
1+
// Do not change the SIL name for this without also changing CommandLineStressTest.c
2+
@_silgen_name("swift_commandline_test_getProcessArgs")
33
public func runTest() {
4-
let ProcessRaceTestSuite = TestSuite("Process Race")
4+
let CommandLineRaceTestSuite = TestSuite("CommandLine Race")
55

6-
ProcessRaceTestSuite.test("passes") {
7-
runRaceTest(ProcessRace.self, trials: 1)
6+
CommandLineRaceTestSuite.test("passes") {
7+
runRaceTest(CommandLineRace.self, trials: 1)
88
}
99

1010
runAllTests()
1111
}
1212

1313
import StdlibUnittest
1414

15-
struct ProcessRace : RaceTestWithPerTrialData {
16-
class ProcessRaceData {
15+
struct CommandLineRace : RaceTestWithPerTrialData {
16+
class CommandLineRaceData {
1717
init() {}
1818
}
1919

2020
typealias ThreadLocalData = Void
2121
typealias Observation = Observation1UInt
2222

23-
func makeRaceData() -> ProcessRaceData {
24-
return ProcessRaceData()
23+
func makeRaceData() -> CommandLineRaceData {
24+
return CommandLineRaceData()
2525
}
2626

2727
func makeThreadLocalData() -> Void {
2828
return Void()
2929
}
3030

3131
func thread1(
32-
_ raceData: ProcessRaceData, _ threadLocalData: inout ThreadLocalData
32+
_ raceData: CommandLineRaceData, _ threadLocalData: inout ThreadLocalData
3333
) -> Observation {
34-
let argptr = Process.unsafeArgv
34+
let argptr = CommandLine.unsafeArgv
3535
return Observation(unsafeBitCast(argptr, to: UInt.self))
3636
}
3737

test/1_stdlib/Inputs/ProcessStressTest/ProcessStressTest.c

-6
This file was deleted.

test/1_stdlib/Inputs/ProcessStressTest/ProcessStressTest.h

-2
This file was deleted.

test/1_stdlib/PrintFloat.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import PrintTestTypes
1717
let PrintTests = TestSuite("PrintFloat")
1818

1919
PrintTests.setUp {
20-
if let localeArgIndex = Process.arguments.index(of: "--locale") {
21-
let locale = Process.arguments[localeArgIndex + 1]
20+
if let localeArgIndex = CommandLine.arguments.index(of: "--locale") {
21+
let locale = CommandLine.arguments[localeArgIndex + 1]
2222
expectEqual("ru_RU.UTF-8", locale)
2323
setlocale(LC_ALL, locale)
2424
} else {

test/1_stdlib/Process.swift

-12
This file was deleted.

test/1_stdlib/Reflection_objc.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ case _:
138138
// CHECK-NEXT: got the expected quick look color
139139
// CHECK-NEXT: got the expected quick look bezier path
140140

141-
let image = OSImage(contentsOfFile:Process.arguments[1])!
141+
let image = OSImage(contentsOfFile:CommandLine.arguments[1])!
142142
switch PlaygroundQuickLook(reflecting: image) {
143143
case .image(let image2 as OSImage) where image === image2:
144144
print("got the expected quick look image")

test/1_stdlib/UIViewControllerAdditions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class View6Controller : UIViewController { }
2828
// no nib
2929
class MissingViewController : UIViewController { }
3030

31-
let bundle = Bundle(path: Process.arguments[1])
31+
let bundle = Bundle(path: CommandLine.arguments[1])
3232

3333
let v1 = View1Controller(nibName:nil, bundle:bundle)
3434
print("tag 1 0=\(v1.view.tag) you're it")

test/Interpreter/SDK/NSApplicationMain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// REQUIRES: OS=macosx
44

55
import AppKit
6-
NSApplicationMain(Process.argc, Process.unsafeArgv)
6+
NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)

test/Interpreter/SDK/archiving_generic_swift_class.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ func driver() {
7171

7272
// Spawn the archiver process.
7373
let archiverArgv: [UnsafeMutablePointer<Int8>?] = [
74-
Process.unsafeArgv[0],
74+
CommandLine.unsafeArgv[0],
7575
UnsafeMutablePointer(("-archive" as StaticString).utf8Start),
7676
nil
7777
]
78-
guard posix_spawn(&archiver, Process.unsafeArgv[0],
78+
guard posix_spawn(&archiver, CommandLine.unsafeArgv[0],
7979
&archiverActions, nil,
8080
archiverArgv, envp) == 0 else {
8181
fatalError("posix_spawn failed")
@@ -101,11 +101,11 @@ func driver() {
101101
// Spawn the unarchiver process.
102102
var unarchiver: pid_t = 0
103103
let unarchiverArgv: [UnsafeMutablePointer<Int8>?] = [
104-
Process.unsafeArgv[0],
104+
CommandLine.unsafeArgv[0],
105105
UnsafeMutablePointer(("-unarchive" as StaticString).utf8Start),
106106
nil
107107
]
108-
guard posix_spawn(&unarchiver, Process.unsafeArgv[0],
108+
guard posix_spawn(&unarchiver, CommandLine.unsafeArgv[0],
109109
&unarchiverActions, nil,
110110
unarchiverArgv, envp) == 0 else {
111111
fatalError("posix_spawn failed")
@@ -201,11 +201,11 @@ func unarchive() {
201201
// Pick a mode based on the command-line arguments.
202202
// The test launches as a "driver" which then respawns itself into reader
203203
// and writer subprocesses.
204-
if Process.arguments.count < 2 {
204+
if CommandLine.arguments.count < 2 {
205205
driver()
206-
} else if Process.arguments[1] == "-archive" {
206+
} else if CommandLine.arguments[1] == "-archive" {
207207
archive()
208-
} else if Process.arguments[1] == "-unarchive" {
208+
} else if CommandLine.arguments[1] == "-unarchive" {
209209
unarchive()
210210
} else {
211211
fatalError("invalid commandline argument")

test/Interpreter/SDK/libc.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import Glibc
1414
#endif
1515

16-
let sourcePath = Process.arguments[1]
17-
let tempPath = Process.arguments[2] + "/libc.txt"
16+
let sourcePath = CommandLine.arguments[1]
17+
let tempPath = CommandLine.arguments[2] + "/libc.txt"
1818

1919
// CHECK: Hello world
2020
fputs("Hello world", stdout)

test/Interpreter/process_arguments.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// REQUIRES: swift_interpreter
77

88
print("Begin arguments")
9-
for arg in Process.arguments { print(arg) }
9+
for arg in CommandLine.arguments { print(arg) }
1010
print("End arguments")
1111

1212
// CHECK-NONE: Begin arguments
@@ -21,8 +21,8 @@ print("End arguments")
2121
// CHECK-THREE-NEXT: End arguments
2222

2323
print("Begin unsafeArgv")
24-
for i in 0...Int(Process.argc) {
25-
print(Process.unsafeArgv[i].map { String(cString: $0) } ?? "(null)")
24+
for i in 0...Int(CommandLine.argc) {
25+
print(CommandLine.unsafeArgv[i].map { String(cString: $0) } ?? "(null)")
2626
}
2727
print("End unsafeArgv")
2828

test/Interpreter/shebang-env.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// REQUIRES: swift_interpreter
1111

1212
print("Begin")
13-
for arg in Process.arguments {
13+
for arg in CommandLine.arguments {
1414
print(arg)
1515
}
1616
print("End")

test/PlaygroundTransform/placeholder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func f(crash crash: Bool) -> Int {
2121
}
2222
}
2323

24-
if Process.arguments.last == "--crash" {
24+
if CommandLine.arguments.last == "--crash" {
2525
print("the value is \(f(crash: true))")
2626
} else {
2727
print("the value is \(f(crash: false))")

test/SILGen/NSApplicationMain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ class MyDelegate: NSApplicationDelegate {}
2121
// Ensure that we coexist with normal references to the functions we
2222
// implicitly reference in the synthesized main.
2323
func bar() {
24-
NSApplicationMain(Process.argc, Process.unsafeArgv)
24+
NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
2525
}
2626
#endif

utils/swift-bench.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ def process_source(self, name):
151151
func main() {
152152
var N = 1
153153
var name = ""
154-
if Process.arguments.count > 1 {
155-
N = Process.arguments[1].toInt()!
154+
if CommandLine.arguments.count > 1 {
155+
N = CommandLine.arguments[1].toInt()!
156156
}
157157
"""
158158
main_body = """
159159
name = "%s"
160-
if Process.arguments.count <= 2 || Process.arguments[2] == name {
160+
if CommandLine.arguments.count <= 2 || CommandLine.arguments[2] == name {
161161
let start = __mach_absolute_time__()
162162
for _ in 1...N {
163163
bench_%s()

0 commit comments

Comments
 (0)