2017-01-10 10:50:26 +00:00
|
|
|
|
2017-02-14 08:29:30 +00:00
|
|
|
class Stdio(Object) from 'stdio'
|
2016-11-18 18:11:13 +00:00
|
|
|
{
|
2017-04-19 16:46:44 +00:00
|
|
|
var(#class) in, out, err.
|
2016-12-26 18:44:47 +00:00
|
|
|
|
2017-03-30 14:59:55 +00:00
|
|
|
method(#primitive) open(name, mode).
|
|
|
|
method(#primitive) close.
|
|
|
|
method(#primitive) gets.
|
|
|
|
method(#primitive,#variadic) puts().
|
|
|
|
method(#primitive,#variadic) putc().
|
2016-11-21 13:56:20 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) open: name for: mode
|
2016-11-18 18:11:13 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
^(self new) open(name, mode)
|
2016-11-18 18:11:13 +00:00
|
|
|
}
|
2016-12-31 15:20:52 +00:00
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/* ---------------------
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) stdin
|
2016-12-06 17:21:47 +00:00
|
|
|
{
|
2016-12-26 18:44:47 +00:00
|
|
|
self.in isNil ifTrue: [ self.in := ^(super new) open: 0 for: 'r' ].
|
|
|
|
^self.in.
|
2016-12-06 17:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) stdout
|
2016-12-06 17:21:47 +00:00
|
|
|
{
|
2016-12-26 18:44:47 +00:00
|
|
|
self.out isNil ifTrue: [ self.out := ^(super new) open: 1 for: 'w' ].
|
|
|
|
^self.out.
|
2016-12-06 17:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) stderr
|
2016-12-06 17:21:47 +00:00
|
|
|
{
|
2016-12-26 18:44:47 +00:00
|
|
|
self.err isNil ifTrue: [ self.err := ^(super new) open: 2 for: 'w' ].
|
|
|
|
^self.err.
|
2016-12-06 17:21:47 +00:00
|
|
|
}
|
2019-06-19 12:38:09 +00:00
|
|
|
------------------------ */
|
2016-12-06 17:21:47 +00:00
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/*
|
2017-01-06 09:53:40 +00:00
|
|
|
method format: fmt with: ...
|
2016-12-06 17:21:47 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-06-19 12:38:09 +00:00
|
|
|
*/
|
2016-12-06 17:21:47 +00:00
|
|
|
|
2017-03-23 16:14:22 +00:00
|
|
|
method(#variadic) format (fmt)
|
2016-12-06 17:21:47 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
| a b c |
|
2016-12-06 17:21:47 +00:00
|
|
|
'THIS IS FORMAT' dump.
|
|
|
|
fmt dump.
|
2016-12-31 15:20:52 +00:00
|
|
|
|
2016-12-13 15:18:19 +00:00
|
|
|
thisContext temporaryCount dump.
|
2017-01-06 09:53:40 +00:00
|
|
|
0 priorTo: (thisContext vargCount) do: [:k |
|
2016-12-31 15:20:52 +00:00
|
|
|
(thisContext vargAt: k) dump.
|
|
|
|
].
|
2016-12-06 17:21:47 +00:00
|
|
|
}
|
2016-11-27 15:37:14 +00:00
|
|
|
}
|
2016-11-18 18:11:13 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend Stdio
|
2016-11-27 15:37:14 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method xxxx
|
2016-11-18 18:11:13 +00:00
|
|
|
{
|
|
|
|
self basicSize dump.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 08:29:30 +00:00
|
|
|
class Stdio2(Stdio)
|
2016-11-18 18:11:13 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) new
|
2016-11-21 13:56:20 +00:00
|
|
|
{
|
2019-06-27 06:29:09 +00:00
|
|
|
//self prohibited
|
|
|
|
//raise exception. prohibited...
|
2016-11-21 13:56:20 +00:00
|
|
|
^(super new).
|
|
|
|
}
|
2016-11-18 18:11:13 +00:00
|
|
|
}
|