author | mkobetic |
Sun, 15 Jan 2012 02:18:17 +0000 | |
changeset 39 | 80fdc4602b14 |
parent 25 | 02e7c3b6f63c |
child 43 | b9a077d6ce14 |
permissions | -rw-r--r-- |
39 | 1 |
'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:27 PM' ! |
2 |
||
9 | 3 |
"{ Package: 'stx:goodies/xtreams/terminals' }" |
4 |
||
5 |
"{ NameSpace: Xtreams }" |
|
6 |
||
7 |
WriteStream subclass:#BlockClosureWriteStream |
|
8 |
instanceVariableNames:'contentsSpecies closeBlock' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
25
02e7c3b6f63c
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
11 |
category:'Xtreams-Terminals' |
9 | 12 |
! |
13 |
||
14 |
BlockClosureWriteStream comment:'Write stream on a single argument block, the block is evaluated for each element written with the element assigned as the argument of the evaluation. |
|
15 |
{{{ |
|
16 |
"Transcript as an xtream" |
|
17 |
[ :x | Transcript nextPut: x ] writing write: ''Hello World!!'' |
|
18 |
}}} |
|
19 |
{{{ |
|
20 |
"/dev/null" |
|
21 |
[ :x | ] writing write: ''Hello World!!'' |
|
22 |
}}} |
|
23 |
||
24 |
Instance Variables |
|
25 |
contentsSpecies <Class> species for collections of elements of this stream |
|
26 |
closeBlock <BlockClosure> invoked in response to the #close message, allows customizing the close behavior |
|
27 |
||
28 |
' |
|
29 |
! |
|
30 |
||
31 |
||
32 |
!BlockClosureWriteStream methodsFor:'accessing'! |
|
33 |
||
34 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
35 |
| count | |
|
36 |
count := 0. |
|
37 |
[[count < anInteger] whileTrue: |
|
38 |
[destination value: (aSequenceableCollection at: startIndex + count). |
|
39 |
count := count + 1]] |
|
40 |
on: Incomplete do: [(Incomplete on: aSequenceableCollection count: count at: startIndex) raise]. |
|
41 |
^anInteger |
|
42 |
! ! |
|
43 |
||
44 |
!BlockClosureWriteStream methodsFor:'initialize-release'! |
|
45 |
||
46 |
close |
|
47 |
closeBlock cull: self |
|
48 |
! |
|
49 |
||
50 |
closeBlock |
|
51 |
^closeBlock |
|
52 |
! |
|
53 |
||
54 |
closeBlock: aBlock |
|
55 |
closeBlock := aBlock |
|
56 |
! |
|
57 |
||
58 |
contentsSpecies |
|
59 |
^contentsSpecies |
|
60 |
! |
|
61 |
||
62 |
contentsSpecies: anObject |
|
63 |
contentsSpecies := anObject |
|
64 |
! |
|
65 |
||
66 |
flush |
|
67 |
! |
|
68 |
||
69 |
on: aBlockClosure |
|
70 |
super on: aBlockClosure. |
|
71 |
contentsSpecies := Array. |
|
72 |
closeBlock := [] |
|
73 |
! ! |
|
74 |
||
75 |
!BlockClosureWriteStream class methodsFor:'documentation'! |
|
76 |
||
77 |
version_SVN |
|
78 |
^ '$Id$' |
|
79 |
! ! |