comparison Lib/IMPL/Serialization.pm @ 115:5edc2ac5231c

minor fix to the serialization mechanism
author wizard
date Wed, 26 May 2010 02:32:22 +0400
parents b0c068da93ac
children fb896377389f
comparison
equal deleted inserted replaced
114:7084af955c57 115:5edc2ac5231c
176 private _direct property ObjectFactory => prop_all; 176 private _direct property ObjectFactory => prop_all;
177 177
178 # ������� �������������������� �������. 178 # ������� �������������������� �������.
179 # SurogateHelper($Type) 179 # SurogateHelper($Type)
180 # $Type ��� �����, ��� ������� ����� �������. 180 # $Type ��� �����, ��� ������� ����� �������.
181 private _direct property SurogateHelper => prop_all; 181 private _direct property SurrogateHelper => prop_all;
182 } 182 }
183 183
184 sub CTOR { 184 sub CTOR {
185 my ($this,%args) = @_; 185 my ($this,%args) = @_;
186 $this->{$CurrentObject} = undef; 186 $this->{$CurrentObject} = undef;
187 $this->{$Root} = undef; 187 $this->{$Root} = undef;
188 $this->{$ObjectFactory} = $args{ObjectFactory} if $args{ObjectFactory};
189 $this->{$SurrogateHelper} = $args{SurrogateHelper} if $args{SurrogateHelper};
188 } 190 }
189 191
190 sub OnObjectBegin { 192 sub OnObjectBegin {
191 my ($this,$name,$rhProps) = @_; 193 my ($this,$name,$rhProps) = @_;
192 194
221 refId => $rhProps->{'refid'} 223 refId => $rhProps->{'refid'}
222 }; 224 };
223 225
224 if (defined $rhProps->{'id'}) { 226 if (defined $rhProps->{'id'}) {
225 die new IMPL::Exception("Trying to create a simple object instead of a reference, type is missing.",$name,$rhProps->{id}) unless $rhProps->{'type'} ; 227 die new IMPL::Exception("Trying to create a simple object instead of a reference, type is missing.",$name,$rhProps->{id}) unless $rhProps->{'type'} ;
226 $this->{$Context}->{$rhProps->{'id'}} = $this->{$SurogateHelper} ? $this->{$SurogateHelper}->($rhProps->{'type'}) : DefaultSurogateHelper($rhProps->{'type'}); 228 $this->{$Context}->{$rhProps->{'id'}} = $this->{$SurrogateHelper} ? $this->{$SurrogateHelper}->($rhProps->{'type'}) : DefaultSurrogateHelper($rhProps->{'type'});
227 } 229 }
228 } 230 }
229 231
230 return 1; 232 return 1;
231 } 233 }
298 sub _is_class { 300 sub _is_class {
299 no strict 'refs'; 301 no strict 'refs';
300 scalar keys %{"$_[0]::"} ? 1 : 0; 302 scalar keys %{"$_[0]::"} ? 1 : 0;
301 } 303 }
302 304
303 sub DefaultSurogateHelper { 305 sub DefaultSurrogateHelper {
304 my ($Type) = @_; 306 my ($Type) = @_;
305 307
306 if ($Type eq 'SCALAR' or $Type eq 'REF') { 308 if ($Type eq 'SCALAR' or $Type eq 'REF') {
307 my $var; 309 my $var;
308 return \$var; 310 return \$var;