Skip to content

Commit 8c72e51

Browse files
committed
MLC: Add syntax for obtaining stdout stream.
This adds a way of getting a stream that wraps the libc stdout stream. For example: write tData to the output stream
1 parent 2a934d5 commit 8c72e51

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

libscript/src/module-stream.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ MCStreamExecWriteToStream(MCDataRef p_data,
3636
return; /* Error should already have been set */
3737
}
3838
}
39+
40+
////////////////////////////////////////////////////////////////////////////////
41+
42+
extern "C" MC_DLLEXPORT void
43+
MCStreamExecGetStandardOutput (MCStreamRef & r_stream)
44+
{
45+
MCStreamGetStandardOutput (r_stream);
46+
}

libscript/src/stream.mlc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ public foreign type Stream binds to "kMCStreamTypeInfo"
99

1010
--
1111

12+
public foreign handler MCStreamExecGetStandardOutput(out Stdout as Stream) as undefined binds to "<builtin>"
13+
14+
/*
15+
Summary: Default output stream.
16+
Returns: The default output stream.
17+
18+
Description:
19+
The default output stream for output from the program.
20+
21+
In command-line programs, this is usually used to output the results
22+
of running the program. In CGI programs running on servers, this is
23+
usually used to output the data to be sent to the client.
24+
25+
Tags: IO
26+
*/
27+
syntax DefaultOutputStream is expression
28+
"the" "output" "stream"
29+
begin
30+
MCStreamExecGetStandardOutput(output)
31+
end syntax
32+
33+
--
34+
1235
public foreign handler MCStreamExecWriteToStream(in Buffer as data, in Destination as Stream) as undefined binds to "<builtin>"
1336

1437
/*

0 commit comments

Comments
 (0)