annotate Lib/IMPL/Class/Property.pm @ 280:c6d0f889ef87

+IMPL::declare now supports meta attributes *bugfixes related to the typeof() operator
author cin
date Wed, 06 Feb 2013 02:15:48 +0400
parents 4ddb27ff4a0b
children
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);
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
12 require IMPL::Class::Member;
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
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
29 my $class = caller;
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
30
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
31 return hashMerge (
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
32 $class->ClassPropertyImplementor->NormalizeSpecification($attributes),
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
33 {
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
39 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
40
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
41 sub CreateProperty {
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
42 my ($class,$propName,@attributes) = @_;
276
8a5da17d7ef9 *IMPL::Class refactoring property definition mechanism (incomplete).
sergey
parents: 275
diff changeset
43
278
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
44 $class
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
45 ->ClassPropertyImplementor
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
46 ->Implement(
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
47 @attributes,
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
48 {
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
49 name => $propName,
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
50 class => $class,
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
51 }
4ddb27ff4a0b core refactoring
cin
parents: 276
diff changeset
52 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
53 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
55 1;