Skip to content

Commit 81485d9

Browse files
authored
Use 'OpenPipe' for backwards compatibility. (#86)
1 parent e616e60 commit 81485d9

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/pipe.toit

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ get-standard-pipe_ fd/int -> Stream:
3838
if file.is-open-file_ fd:
3939
standard-pipes_[fd] = file.OpenFile_.internal_ fd
4040
else:
41-
standard-pipes_[fd] = OpenPipe_.from-std_ (fd-to-pipe_ pipe-resource-group_ fd)
41+
standard-pipes_[fd] = OpenPipe.from-std_ (fd-to-pipe_ pipe-resource-group_ fd)
4242
return standard-pipes_[fd]
4343

4444
/**
@@ -54,7 +54,7 @@ get-numbered-pipe fd/int -> Stream:
5454
if file.is-open-file_ fd:
5555
return file.OpenFile_.internal_ fd
5656
else:
57-
return OpenPipe_.from-std_ (fd-to-pipe_ pipe-resource-group_ fd)
57+
return OpenPipe.from-std_ (fd-to-pipe_ pipe-resource-group_ fd)
5858

5959
class OpenPipeReader_ extends io.CloseableReader:
6060
pipe_/OpenPipe_
@@ -93,6 +93,9 @@ class OpenPipe extends OpenPipe_:
9393
constructor input/bool --child-process-name="child process":
9494
super input --child-process-name=child-process-name
9595

96+
constructor.from-std_ resource:
97+
super.from-std_ resource
98+
9699
class OpenPipe_ implements Stream:
97100
resource_ := ?
98101
state_ := ?
@@ -375,15 +378,15 @@ fork_ use-path stdin stdout stderr command arguments -> List
375378
flat-environment[index++] = (value == null) ? null : value.stringify
376379
exception := catch:
377380
if stdin == PIPE-CREATED:
378-
pipe := OpenPipe_ true
381+
pipe := OpenPipe true
379382
result[0] = pipe
380383
stdin = pipe.fd_
381384
if stdout == PIPE-CREATED:
382-
pipe := OpenPipe_ false
385+
pipe := OpenPipe false
383386
result[1] = pipe
384387
stdout = pipe.fd_
385388
if stderr == PIPE-CREATED:
386-
pipe := OpenPipe_ false
389+
pipe := OpenPipe false
387390
result[2] = pipe
388391
stderr = pipe.fd_
389392
fd-3 := file-descriptor-3 ? file-descriptor-3.fd_ : -1
@@ -474,7 +477,7 @@ The $environment argument is used as in $fork.
474477
to --environment/Map?=null arguments -> Stream:
475478
if arguments is string:
476479
arguments = [arguments]
477-
pipe-ends := OpenPipe_ true --child-process-name=arguments[0]
480+
pipe-ends := OpenPipe true --child-process-name=arguments[0]
478481
stdin := pipe-ends.fd_
479482
pipes := fork_ --environment=environment true stdin PIPE-INHERITED PIPE-INHERITED arguments[0] arguments
480483
pipe-ends.pid = pipes[3]
@@ -512,7 +515,7 @@ The $environment argument is used as in $fork.
512515
from --environment/Map?=null arguments -> Stream:
513516
if arguments is string:
514517
arguments = [arguments]
515-
pipe-ends := OpenPipe_ false --child-process-name=arguments[0]
518+
pipe-ends := OpenPipe false --child-process-name=arguments[0]
516519
stdout := pipe-ends.fd_
517520
pipes := fork_ --environment=environment true PIPE-INHERITED stdout PIPE-INHERITED arguments[0] arguments
518521
pipe-ends.pid = pipes[3]
@@ -546,7 +549,7 @@ The $environment argument is used as in $fork.
546549
backticks --environment/Map?=null arguments -> string:
547550
if arguments is string:
548551
arguments = [arguments]
549-
pipe-ends := OpenPipe_ false
552+
pipe-ends := OpenPipe false
550553
stdout := pipe-ends.fd_
551554
pipes := fork_ --environment=environment true PIPE-INHERITED stdout PIPE-INHERITED arguments[0] arguments
552555
child-process := pipes[3]

src/stream.toit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import reader as old-reader
77

88
import .file as file-lib
99
import .file show RDONLY WRONLY RDWR APPEND CREAT TRUNC
10-
import .pipe show OpenPipe_
10+
import .pipe show OpenPipe
1111

1212
interface Stream implements old-reader.Reader:
1313
in -> io.CloseableReader
@@ -78,10 +78,10 @@ interface Stream implements old-reader.Reader:
7878
Constructs a pipe to send data to a child process.
7979
*/
8080
constructor --parent-to-child/True --child-process-name="child process":
81-
return OpenPipe_ true --child-process-name=child-process-name
81+
return OpenPipe true --child-process-name=child-process-name
8282

8383
/**
8484
Constructs a pipe to receive data from a child process.
8585
*/
8686
constructor --child-to-parent/True --child-process-name="child process":
87-
return OpenPipe_ false --child-process-name=child-process-name
87+
return OpenPipe false --child-process-name=child-process-name

0 commit comments

Comments
 (0)