annotate Lib/IMPL/Class/Property.pm @ 276:8a5da17d7ef9

*IMPL::Class refactoring property definition mechanism (incomplete).
author sergey
date Thu, 31 Jan 2013 17:37:44 +0400
parents 6253872024a4
children 4ddb27ff4a0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
1 package IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
2 use strict;
165
76515373dac0 Added Class::Template,
wizard
parents: 59
diff changeset
3 use parent qw(Exporter);
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
4
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
5 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
6 our @EXPORT = qw(property prop_get prop_set owner_set prop_none prop_all prop_list CreateProperty);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
7 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
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);
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
12 require IMPL::Class::Memeber;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
14 sub import {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
15 __PACKAGE__->export_to_level(1,@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
16 IMPL::Class::Member->export_to_level(1,@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
19 sub prop_get { 1 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
22 sub prop_none { 0 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
23 sub prop_all { 3 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
24 sub prop_list { 4 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
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
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
29 $attributes = {
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
30 get => $attributes & PROP_GET,
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
31 set => $attributes & PROP_SET,
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
32 isList => $attributes & PROP_LIST
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
33 } unless ref $attributes;
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
34
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
35 return hashMerge (
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
36 $attributes,
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 -implementor => 'ImplementProperty',
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
39 name => $propName,
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
40 class => scalar(caller),
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
41 }
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
42 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
43 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
45 sub CreateProperty {
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
46 my ($class,$propName,$attributes) = @_;
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
47
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
48 carp "Using create property is deprecated, use ImplementProperty instead";
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
49
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
50 $class->ImplementProperty($propName,$attributes);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
51 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
52
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
53 1;