comparison Lib/IMPL/lang.pm @ 181:47dac58691ee

New templating system, small fixes
author sourcer
date Thu, 26 Jan 2012 01:15:57 +0400
parents 658a80d19d33
children 4d0e1962161c
comparison
equal deleted inserted replaced
180:d1676be8afcc 181:47dac58691ee
36 &private 36 &private
37 &virtual 37 &virtual
38 &property 38 &property
39 &static 39 &static
40 &property 40 &property
41 &ctor
42 ) 41 )
43 ], 42 ],
44 compare => [ 43 compare => [
45 qw( 44 qw(
46 &equals 45 &equals
53 &hashApply 52 &hashApply
54 &hashMerge 53 &hashMerge
55 &hashDiff 54 &hashDiff
56 &hashCompare 55 &hashCompare
57 &hashParse 56 &hashParse
57 &hashSave
58 ) 58 )
59 ] 59 ]
60 ); 60 );
61 61
62 our @EXPORT_OK = keys %{ { map (($_,1) , map (@{$_}, values %EXPORT_TAGS) ) } }; 62 our @EXPORT_OK = keys %{ { map (($_,1) , map (@{$_}, values %EXPORT_TAGS) ) } };
116 my ( $name, $value ) = @_; 116 my ( $name, $value ) = @_;
117 my $class = caller; 117 my $class = caller;
118 $class->static_accessor( $name, $value ); 118 $class->static_accessor( $name, $value );
119 } 119 }
120 120
121 sub ctor(&;$) {
122 my ( $code, %base ) = @_;
123 no strict 'refs';
124 my $class = caller;
125
126 if ($code) {
127 *{"${class}::CTOR"} = $code;
128 }
129
130 if (%base) {
131 %{"${class}::CTOR"} = %base;
132 }
133 }
134
135 sub equals { 121 sub equals {
136 if (defined $_[0]) { 122 if (defined $_[0]) {
137 return 0 if (not defined $_[1]); 123 return 0 if (not defined $_[1]);
138 124
139 return $_[0] == $_[1]; 125 return $_[0] == $_[1];
221 map split($d,$_,2), split($p,$s) 207 map split($d,$_,2), split($p,$s)
222 }; 208 };
223 } 209 }
224 210
225 sub hashSave { 211 sub hashSave {
226 212 my ($hash,$p,$d) = @_;
213
214 return "" unless ref $hash eq 'HASH';
215
216 $p ||= "\n";
217 $d ||= " = ";
218
219 return
220 join(
221 $p,
222 map(
223 join(
224 $d,
225 $_,
226 $hash->{$_}
227 ),
228 keys %$hash
229 )
230 );
227 } 231 }
228 232
229 1; 233 1;