Mercurial > pub > Impl
annotate Lib/IMPL/Class/Property.pm @ 290:7b0dad6117d5
*TTView: fixed memory leak
author | sergey |
---|---|
date | Wed, 20 Feb 2013 17:24:57 +0400 |
parents | 4ddb27ff4a0b |
children |
rev | line source |
---|---|
49 | 1 package IMPL::Class::Property; |
2 use strict; | |
165 | 3 use parent qw(Exporter); |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
4 |
49 | 5 BEGIN { |
6 our @EXPORT = qw(property prop_get prop_set owner_set prop_none prop_all prop_list CreateProperty); | |
7 } | |
8 | |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
9 use IMPL::lang qw(:hash); |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
10 use IMPL::Const qw(:prop); |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
11 use Carp qw(carp); |
278 | 12 require IMPL::Class::Member; |
49 | 13 |
14 sub import { | |
15 __PACKAGE__->export_to_level(1,@_); | |
16 IMPL::Class::Member->export_to_level(1,@_); | |
17 } | |
18 | |
19 sub prop_get { 1 }; | |
20 sub prop_set { 2 }; | |
59
0f3e369553bd
Rewritten property implementation (probably become slower but more flexible)
wizard
parents:
49
diff
changeset
|
21 sub owner_set { 10 }; |
49 | 22 sub prop_none { 0 }; |
23 sub prop_all { 3 }; | |
24 sub prop_list { 4 }; | |
25 | |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
26 sub property($$) { |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
27 my ($propName,$attributes) = @_; |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
28 |
278 | 29 my $class = caller; |
30 | |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
31 return hashMerge ( |
278 | 32 $class->ClassPropertyImplementor->NormalizeSpecification($attributes), |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
33 { |
278 | 34 implementor => $class->ClassPropertyImplementor, |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
35 name => $propName, |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
36 class => scalar(caller), |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
37 } |
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
38 ); |
49 | 39 } |
40 | |
41 sub CreateProperty { | |
278 | 42 my ($class,$propName,@attributes) = @_; |
276
8a5da17d7ef9
*IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents:
275
diff
changeset
|
43 |
278 | 44 $class |
45 ->ClassPropertyImplementor | |
46 ->Implement( | |
47 @attributes, | |
48 { | |
49 name => $propName, | |
50 class => $class, | |
51 } | |
52 ); | |
49 | 53 }; |
54 | |
55 1; |