moo/kernel/Stdio.moo

74 lines
1.1 KiB
Smalltalk
Raw Normal View History

class Stdio(Object) from 'stdio'
{
var(#class) in, out, err.
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
method(#class) open: name for: mode
{
^(self new) open(name, mode)
}
2016-12-31 15:20:52 +00:00
/* ---------------------
method(#class) stdin
{
self.in isNil ifTrue: [ self.in := ^(super new) open: 0 for: 'r' ].
^self.in.
}
method(#class) stdout
{
self.out isNil ifTrue: [ self.out := ^(super new) open: 1 for: 'w' ].
^self.out.
}
method(#class) stderr
{
self.err isNil ifTrue: [ self.err := ^(super new) open: 2 for: 'w' ].
^self.err.
}
------------------------ */
/*
method format: fmt with: ...
{
}
*/
method(#variadic) format (fmt)
{
| a b c |
'THIS IS FORMAT' dump.
fmt dump.
2016-12-31 15:20:52 +00:00
thisContext temporaryCount dump.
0 priorTo: (thisContext vargCount) do: [:k |
2016-12-31 15:20:52 +00:00
(thisContext vargAt: k) dump.
].
}
}
extend Stdio
{
method xxxx
{
self basicSize dump.
}
}
class Stdio2(Stdio)
{
method(#class) new
2016-11-21 13:56:20 +00:00
{
//self prohibited
//raise exception. prohibited...
2016-11-21 13:56:20 +00:00
^(super new).
}
}