annotate lib/IMPL/Serialization.pm @ 413:af8d359ee4cc ref20150831

working on di container
author cin
date Thu, 24 Sep 2015 12:19:30 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Serialization;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4 package IMPL::Serialization::Context;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 use IMPL::Exception();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 use Scalar::Util qw(refaddr);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 base => [ 'IMPL::Object' => undef ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 _objectWriter => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 _context => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 _nextId => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 serializer => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 _state => PROP_RW | PROP_DIRECT
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 sub STATE_CLOSED () { 0 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 sub STATE_OPENED () { 1 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 sub STATE_COMPLEX () { 2 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 sub STATE_DATA () { 3 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 sub CTOR {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 my ( $this, %args ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 $this->{$_objectWriter} = $args{'ObjectWriter'};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30 $this->{$_nextId} = 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 $this->{$serializer} =
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 ( $args{'Serializer'} ? $args{'Serializer'} : \&DefaultSerializer );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 $this->{$_state} = STATE_CLOSED;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 sub AddVar {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
39 my ( $this, $sName, $Var ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
40
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
41 die new Exception('Invalid operation') if $this->{$_state} == STATE_DATA;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
42
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
43 if ( not ref $Var ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
44 my $prevState = $this->{$_state};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
45
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
46 $this->{$_objectWriter}->BeginObject( name => $sName );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47 $this->{$_state} = STATE_OPENED;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49 $this->{$serializer}->( $this, \$Var );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51 $this->{$_objectWriter}->EndObject();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53 if ( $prevState == STATE_OPENED ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
54 $this->{$_state} = STATE_COMPLEX;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
56 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57 $this->{$_state} = $prevState;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59 return 0;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62 my $PrevState = $this->{$_state};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
63
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
64 my $ObjID = $this->{$_context}->{ refaddr $Var};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
65 if ($ObjID) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
66 $this->{$_objectWriter}->BeginObject( name => $sName, refid => $ObjID );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
67 $this->{$_objectWriter}->EndObject();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
68 return $ObjID;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
69 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
70
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
71 $ObjID = $this->{$_nextId};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
72 $this->{$_nextId} = $ObjID + 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
73
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
74 $this->{$_context}->{ refaddr $Var} = $ObjID;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
75
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
76 $this->{$_objectWriter}
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
77 ->BeginObject( name => $sName, type => ref($Var), id => $ObjID );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
78
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
79 $this->{$_state} = STATE_OPENED;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
80 $this->{$serializer}->( $this, $Var );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
81
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
82 $this->{$_objectWriter}->EndObject();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
83
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
84 if ( $PrevState == STATE_OPENED ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
85 $this->{$_state} = STATE_COMPLEX;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
86 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
87 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
88 $this->{$_state} = $PrevState;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
89 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
90
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
91 return $ObjID;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
92 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
93
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
94 sub SetData {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
95 my ( $this, $data, $type ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
96
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
97 die new Exception('The object should be a scalar value') if ref $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
98 die new Exception('Invalid operation') if $this->{$_state} != STATE_OPENED;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
99
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
100 $this->{$_objectWriter}->SetData( $data, $type );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
101
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
102 $this->{$_state} = STATE_DATA;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
103
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
104 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
105 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
106
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
107 sub DefaultSerializer {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
108 my ( $_context, $refObj ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
109
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
110 if ( ref($refObj) eq 'SCALAR' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
111 $_context->SetData( $$refObj, 'SCALAR' );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
112 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
113 elsif ( ref($refObj) eq 'ARRAY' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
114 $_context->AddVar( 'item', $_ ) foreach @$refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
115 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
116 elsif ( ref($refObj) eq 'HASH' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
117 while ( my ( $key, $value ) = each %$refObj ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
118 $_context->AddVar( $key, $value );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
119 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
120 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
121 elsif ( ref($refObj) eq 'REF' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
122 $_context->AddVar( 'ref', $$refObj );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
123 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
124 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
125 if ( ref $refObj and $refObj->UNIVARSAL::can('save') ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
126 $refObj->save($_context);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
127 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
128 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
129 die new Exception(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
130 'Cant serialize the object of the type: ' . ref($refObj) );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
131 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
132 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
133
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
134 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
135 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
136
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
137 package IMPL::Deserialization::Context;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
138
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
139 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
140 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
141 require => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
142 Exception => 'IMPL::Exception',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
143 Loader => 'IMPL::Code::Loader'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
144 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
145 base => [ 'IMPL::Object' => undef ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
146 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
147
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
148 # структура информации об объекте
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
149 # {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
150 # Type => 'typename',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
151 # Name => 'object_name',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
152 # Data => $data,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
153 # Id => 'object_id'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
154 # }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
155 _context => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
156 _currentObject => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
157 _objectsPath => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
158 root => PROP_RW | PROP_DIRECT
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
159 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
160 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
161
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
162 sub CTOR {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
163 my ( $this, %args ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
164 $this->{$_currentObject} = undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
165 $this->{$root} = undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
166 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
167
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
168 sub OnObjectBegin {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
169 my ( $this, $name, $rhProps ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
170
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
171 die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
172 "Invalid data from an ObjectReader",
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
173 "An object reader should pass a referense to a hash which contains attributes of an object"
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
174 ) if ( ref $rhProps ne 'HASH' );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
175
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
176 die Exception->new("Trying to create second root object")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
177 if not $this->{$_currentObject} and $this->{$root};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
178
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
179 if ( $rhProps->{'refid'} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
180
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
181 my $refObj = $this->{$_context}->{ $rhProps->{'refid'} };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
182
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
183 die Exception->new("A reference to a not existing object found")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
184 if not $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
185
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
186 my $rhCurrentObj = $this->{$_currentObject};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
187
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
188 die Exception->new("The root object can't be a reference")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
189 if not $rhCurrentObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
190
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
191 if ( $rhCurrentObj->{'Data'} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
192
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
193 die Exception->new( "Invalid serializaed data",
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
194 "Plain deserialization data for an object already exist" )
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
195 if not ref $rhCurrentObj->{'Data'};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
196
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
197 push @{ $rhCurrentObj->{'Data'} }, $name, $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
198 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
199 $rhCurrentObj->{'Data'} = [ $name, $refObj ];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
200 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
201
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
202 push @{ $this->{$_objectsPath} }, $rhCurrentObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
203 $this->{$_currentObject} = undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
204
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
205 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
206 push @{ $this->{$_objectsPath} }, $this->{$_currentObject}
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
207 if $this->{$_currentObject};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
208
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
209 $this->{$_currentObject} = {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
210 Name => $name,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
211 Type => $rhProps->{'type'} || 'SCALAR',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
212 Id => $rhProps->{'id'},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
213 refId => $rhProps->{'refid'}
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
214 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
215
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
216 if ( defined $rhProps->{'id'} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
217 die new IMPL::Exception(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
218 "Trying to create a simple object instead of a reference, type is missing.",
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
219 $name, $rhProps->{id}
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
220 ) unless $rhProps->{'type'};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
221
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
222 $this->{$_context}->{ $rhProps->{'id'} } = $this->CreateSurrogate( $rhProps->{'type'} );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
223 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
224 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
225
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
226 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
227 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
228
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
229 sub OnObjectData {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
230 my ( $this, $data ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
231
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
232 my $rhObject = $this->{$_currentObject};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
233
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
234 die Exception->new("Trying to set data for an object which not exists")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
235 if not $rhObject;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
236
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
237 #die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
238 # "Deserialization data already exists for a current object",
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
239 # "ObjectName= $rhObject->{'Name'}" )
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
240 # if $rhObject->{'Data'};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
241
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
242 $rhObject->{'Data'} .= $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
243
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
244 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
245 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
246 {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
247 my $autoId = 0;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
248
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
249 sub OnObjectEnd {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
250 my ( $this, $name ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
251
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
252 my $rhObject = $this->{$_currentObject};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
253 my $rhPrevObject = pop @{ $this->{$_objectsPath} };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
254
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
255 if ( ( not defined($rhObject) ) && $rhPrevObject ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
256 $this->{$_currentObject} = $rhPrevObject;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
257 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
258 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
259
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
260 my $refObj = $this->CreateObject(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
261 $rhObject->{'Type'},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
262 $rhObject->{'Data'},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
263 $rhObject->{'Id'}
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
264 ? $this->{$_context}->{ $rhObject->{'Id'} }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
265 : undef
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
266 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
267
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
268 die Exception->new("Trying to close a non existing oject")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
269 if not $rhObject;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
270
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
271 my $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
272
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
273 if ( $rhObject->{'Id'} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
274 $this->{$_context}->{ $rhObject->{'Id'} } = $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
275 $data = $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
276 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
277 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
278 if ( ref $refObj ne 'SCALAR' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
279 $rhObject->{Id} = "auto$autoId";
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
280 $autoId++;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
281 $this->{$_context}->{ $rhObject->{'Id'} } = $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
282 $data = $refObj;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
283 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
284 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
285 $data = ${$refObj};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
286 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
287 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
288
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
289 if ( not $rhPrevObject ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
290 $this->{$root} = $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
291 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
292 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
293 if ( $rhPrevObject->{'Data'} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
294 die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
295 "Trying append a reference to an object to the plain data")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
296 if not ref $rhPrevObject->{'Data'};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
297
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
298 push @{ $rhPrevObject->{'Data'} }, $rhObject->{'Name'}, $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
299 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
300 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
301 $rhPrevObject->{'Data'} = [ $rhObject->{'Name'}, $data ];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
302 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
303 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
304
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
305 $this->{$_currentObject} = $rhPrevObject;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
306
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
307 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
308 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
309 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
310
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
311 sub CreateSurrogate {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
312 my ($this,$type) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
313
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
314 if ( $type eq 'SCALAR' or $type eq 'REF' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
315 my $var;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
316 return \$var;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
317 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
318 elsif ( $type eq 'ARRAY' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
319 return [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
320 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
321 elsif ( $type eq 'HASH' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
322 return {};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
323 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
324 elsif ($type) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
325 Loader->safe->Require($type);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
326 if ( eval { $type->can('surrogate') } ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
327 return $type->surrogate();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
328 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
329 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
330 return bless {}, $type;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
331 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
332 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
333 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
334
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
335 # deserialization context:
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
336 # [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
337 # 'var_name',value,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
338 # ....
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
339 # ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
340
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
341 sub CreateObject {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
342 my ($this, $type, $data, $refSurogate ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
343
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
344 if ( $type eq 'SCALAR' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
345 die Exception->new("SCALAR needs a plain data for a deserialization")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
346 if ref $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
347 if ($refSurogate) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
348 $$refSurogate = $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
349 return $refSurogate;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
350 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
351 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
352 return \$data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
353 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
354 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
355 elsif ( $type eq 'ARRAY' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
356 $data ||= [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
357 die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
358 "Invalid a deserialization context when deserializing ARRAY")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
359 if not ref $data and defined $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
360 if ( not ref $refSurogate ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
361 my @Array;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
362 $refSurogate = \@Array;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
363 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
364 for ( my $i = 0 ; $i < scalar( @{$data} ) / 2 ; $i++ ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
365 push @$refSurogate, $data->[ $i * 2 + 1 ];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
366 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
367 return $refSurogate;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
368 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
369 elsif ( $type eq 'HASH' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
370 $data ||= [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
371 die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
372 "Invalid a deserialization context when deserializing HASH")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
373 if not ref $data and defined $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
374 if ( not ref $refSurogate ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
375 $refSurogate = {};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
376 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
377 for ( my $i = 0 ; $i < @$data ; $i += 2 ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
378 $refSurogate->{ $data->[$i] } = $data->[ $i + 1 ];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
379 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
380 return $refSurogate;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
381 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
382 elsif ( $type eq 'REF' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
383 $data ||= [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
384 die Exception->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
385 "Invalid a deserialization context when deserializing REF")
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
386 if not ref $data and defined $data;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
387 if ( not ref $refSurogate ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
388 my $ref = $data->[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
389 return \$ref;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
390 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
391 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
392 $$refSurogate = $data->[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
393 return $refSurogate;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
394 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
395 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
396 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
397 Loader->safe->Require($type);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
398 if ( eval { $type->can('restore') } ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
399 return $type->restore( $data, $refSurogate );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
400 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
401 else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
402 die Exception->new("Don't know how to deserialize $type");
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
403 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
404 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
405 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
406
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
407 package IMPL::Serializer;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
408
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
409 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
410 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
411 require => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
412 Exception => 'IMPL::Exception',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
413 SerializationContext => '-IMPL::Serialization::Context',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
414 DeserializationContext => '-IMPL::Deserialization::Context'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
415 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
416 base => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
417 'IMPL::Object' => undef
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
418 ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
419 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
420 _formatter => PROP_RW
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
421 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
422 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
423
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
424 sub CTOR {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
425 my ( $this, %args ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
426 $this->_formatter( $args{formatter} )
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
427 or die Exception->new("Omitted mandatory parameter 'formatter'");
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
428 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
429
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
430 sub Serialize {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
431 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
432 my ( $hStream, $Object ) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
433 my $ObjWriter = $this->_formatter->CreateWriter($hStream);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
434 my $context =
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
435 SerializationContext->new( objectWriter => $ObjWriter );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
436 $context->AddVar( 'root', $Object );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
437 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
438 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
439
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
440 sub Deserialize {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
441 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
442 my ($hStream) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
443 my $context = DeserializationContext->new();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
444 my $ObjReader = $this->_formatter->CreateReader( $hStream, $context );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
445 $ObjReader->Parse();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
446 return $context->root;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
447 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
448
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
449 1;