author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 01 Feb 2012 00:41:14 +0000 | |
changeset 99 | 677c81c943e4 |
parent 72 | d16c7d84d4a8 |
child 104 | e50c1293b723 |
permissions | -rw-r--r-- |
10 | 1 |
"{ Package: 'stx:goodies/xtreams/transforms' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
ReadStream subclass:#ObjectAnalyseStream |
|
6 |
instanceVariableNames:'marshaler nothing log depth objects int8 int16 int32 int64 uint16 |
|
7 |
uint32 uint64 float double' |
|
8 |
classVariableNames:'' |
|
9 |
poolDictionaries:'' |
|
27
2cc5a8a3ca14
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
10
diff
changeset
|
10 |
category:'Xtreams-Transforms' |
10 | 11 |
! |
12 |
||
13 |
||
14 |
!ObjectAnalyseStream class methodsFor:'instance creation'! |
|
15 |
||
16 |
on: aDestination |
|
17 |
^self on: aDestination marshaler: ObjectMarshaler new |
|
18 |
! |
|
19 |
||
20 |
on: aDestination marshaler: aMarshaler |
|
21 |
^self new on: aDestination marshaler: aMarshaler |
|
22 |
! ! |
|
23 |
||
24 |
!ObjectAnalyseStream methodsFor:'accessing'! |
|
25 |
||
26 |
get |
|
27 |
| details | |
|
28 |
marshaler analyse: self. |
|
29 |
details := log conclusion. |
|
30 |
log := String new writing. |
|
31 |
self complete. |
|
32 |
^details |
|
33 |
! |
|
34 |
||
35 |
read: anInteger into: aSequenceableCollection at: startIndex |
|
36 |
| count | |
|
37 |
count := 0. |
|
38 |
[anInteger timesRepeat: |
|
39 |
[marshaler analyse: self. |
|
40 |
aSequenceableCollection at: startIndex + count put: log conclusion. |
|
41 |
log := String new writing. |
|
42 |
self complete. |
|
43 |
count := count + 1]] |
|
44 |
on: Incomplete do: [:exception | |
|
45 |
aSequenceableCollection at: startIndex + count put: log conclusion. |
|
46 |
log := String new writing. |
|
47 |
self complete. |
|
48 |
(Incomplete on: aSequenceableCollection count: count at: startIndex) raise]. |
|
49 |
^anInteger |
|
50 |
! ! |
|
51 |
||
52 |
!ObjectAnalyseStream methodsFor:'initialize-release'! |
|
53 |
||
54 |
contentsSpecies |
|
55 |
^Array |
|
56 |
! |
|
57 |
||
58 |
on: aSource marshaler: aMarshaler |
|
59 |
super on: aSource. |
|
60 |
marshaler := aMarshaler. |
|
61 |
nothing := Object new. |
|
62 |
objects := OrderedCollection with: Transcript. |
|
63 |
depth := 0. |
|
64 |
||
65 |
log := String new writing. |
|
66 |
int8 := aSource interpreting: #signedChar. |
|
67 |
(self log: 'header' do: [marshaler configureAnalyse: aSource]) |
|
68 |
ifTrue: [ |
|
69 |
int16 := aSource interpreting: #signedShort_be. |
|
70 |
int32 := aSource interpreting: #signedLong_be. |
|
71 |
int64 := aSource interpreting: #signedLonglong_be. |
|
72 |
uint16 := aSource interpreting: #unsignedShort_be. |
|
73 |
uint32 := aSource interpreting: #unsignedLong_be. |
|
74 |
uint64 := aSource interpreting: #unsignedLonglong_be] |
|
75 |
ifFalse: [ |
|
76 |
int16 := aSource interpreting: #signedShort_le. |
|
77 |
int32 := aSource interpreting: #signedLong_le. |
|
78 |
int64 := aSource interpreting: #signedLonglong_le. |
|
79 |
uint16 := aSource interpreting: #unsignedShort_le. |
|
80 |
uint32 := aSource interpreting: #unsignedLong_le. |
|
81 |
uint64 := aSource interpreting: #unsignedLonglong_le]. |
|
82 |
float := aSource interpreting: #float. |
|
83 |
double := aSource interpreting: #double |
|
84 |
! ! |
|
85 |
||
86 |
!ObjectAnalyseStream methodsFor:'primitives'! |
|
87 |
||
88 |
double |
|
89 |
^double |
|
90 |
! |
|
91 |
||
92 |
float |
|
93 |
^float |
|
94 |
! |
|
95 |
||
96 |
int16 |
|
97 |
^int16 |
|
98 |
! |
|
99 |
||
100 |
int32 |
|
101 |
^int32 |
|
102 |
! |
|
103 |
||
104 |
int64 |
|
105 |
^int64 |
|
106 |
! |
|
107 |
||
108 |
int8 |
|
109 |
^int8 |
|
110 |
! |
|
111 |
||
112 |
uint16 |
|
113 |
^uint16 |
|
114 |
! |
|
115 |
||
116 |
uint32 |
|
117 |
^uint32 |
|
118 |
! |
|
119 |
||
120 |
uint64 |
|
121 |
^uint64 |
|
122 |
! |
|
123 |
||
124 |
uint8 |
|
125 |
^source |
|
126 |
! ! |
|
127 |
||
128 |
!ObjectAnalyseStream methodsFor:'private'! |
|
129 |
||
130 |
complete |
|
131 |
objects := OrderedCollection with: Transcript |
|
132 |
! |
|
133 |
||
134 |
log: type do: aBlock |
|
135 |
| superlog sublog position incomplete | |
|
136 |
position := source position. |
|
137 |
superlog := log. |
|
138 |
log := String new writing. |
|
139 |
||
140 |
depth := depth + 1. |
|
141 |
incomplete := false. |
|
142 |
^[aBlock on: Incomplete do: [:ex | incomplete := true. ex pass]] ensure: |
|
143 |
[depth := depth - 1. |
|
144 |
sublog := log conclusion. |
|
145 |
log := superlog. |
|
146 |
||
147 |
incomplete ifFalse: |
|
148 |
[log tab: depth; print: position; write: '+'; print: (source position - position); tab. |
|
149 |
type isCharacters |
|
150 |
ifTrue: [log write: type] |
|
151 |
ifFalse: [log write: type value]. |
|
152 |
log cr; write: sublog]] |
|
153 |
! |
|
154 |
||
155 |
nothing |
|
156 |
^nothing |
|
157 |
! |
|
158 |
||
159 |
objects |
|
160 |
^objects |
|
161 |
! ! |
|
162 |
||
163 |
!ObjectAnalyseStream class methodsFor:'documentation'! |
|
164 |
||
165 |
version_SVN |
|
166 |
^ '$Id$' |
|
167 |
! ! |