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:#ExternalWriteStream |
|
8 |
instanceVariableNames:'contentsSpecies' |
|
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 |
ExternalWriteStream comment:'Used to write to BlockableIOAccessors (e.g sockets or pipes). This is a binary stream (consumes bytes/ByteArrays). |
|
15 |
||
16 |
{{{ |
|
17 |
[ :in :out | |
|
18 |
[ out writing write: ''Hello''; close. |
|
19 |
in reading read: 5 |
|
20 |
] ensure: [ in close. out close ] |
|
21 |
] valueWithArguments: SocketAccessor openPair |
|
22 |
}}} |
|
23 |
{{{ |
|
24 |
[ :in :out | |
|
25 |
[ out writing write: ''Hello''; close. |
|
26 |
in reading read: 5 |
|
27 |
] ensure: [ in close. out close ] |
|
28 |
] valueWithArguments: OSSystemSupport concreteClass pipeAccessorClass openPair |
|
29 |
}}} |
|
30 |
||
31 |
Instance Variables |
|
32 |
contentsSpecies <Class> species for collections of elements of this stream |
|
33 |
||
34 |
' |
|
35 |
! |
|
36 |
||
37 |
||
38 |
!ExternalWriteStream methodsFor:'accessing'! |
|
39 |
||
40 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
39 | 41 |
| count wrote | |
42 |
anInteger isZero ifTrue: [^0]. |
|
43 |
count := 0. |
|
44 |
[count < anInteger] whileTrue: |
|
45 |
[wrote := destination nextPutBytes: anInteger - count from: aSequenceableCollection startingAt: startIndex + count. |
|
46 |
wrote isZero ifTrue: [(Incomplete on: aSequenceableCollection count: count at: startIndex) raise]. |
|
47 |
count := count + wrote]. |
|
48 |
^anInteger |
|
9 | 49 |
! ! |
50 |
||
51 |
!ExternalWriteStream methodsFor:'initialize-release'! |
|
52 |
||
53 |
close |
|
54 |
destination isActive ifFalse: [^self]. |
|
55 |
destination close |
|
56 |
! |
|
57 |
||
58 |
contentsSpecies |
|
59 |
^contentsSpecies |
|
60 |
! |
|
61 |
||
62 |
contentsSpecies: aClass |
|
63 |
contentsSpecies := aClass |
|
64 |
! |
|
65 |
||
66 |
on: anAccessor |
|
67 |
super on: anAccessor. |
|
68 |
contentsSpecies := ByteArray |
|
69 |
! ! |
|
70 |
||
71 |
!ExternalWriteStream class methodsFor:'documentation'! |
|
72 |
||
73 |
version_SVN |
|
74 |
^ '$Id$' |
|
75 |
! ! |