annotate lib/IMPL/Class/Property.pm @ 416:cc2cf8c0edc2 ref20150831

sync
author cin
date Thu, 29 Oct 2015 03:50:25 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Class::Property;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3 use parent qw(Exporter);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 BEGIN {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 our @EXPORT = qw(property prop_get prop_set owner_set prop_none prop_all prop_list CreateProperty);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 use IMPL::lang qw(:hash);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 use Carp qw(carp);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 require IMPL::Class::Member;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 sub import {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 __PACKAGE__->export_to_level(1,@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 IMPL::Class::Member->export_to_level(1,@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 sub prop_get { 1 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 sub prop_set { 2 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 sub owner_set { 10 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 sub prop_none { 0 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 sub prop_all { 3 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 sub prop_list { 4 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 sub property($$) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 my ($propName,$attributes) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 my $class = caller;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 return hashMerge (
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 $class->ClassPropertyImplementor->NormalizeSpecification($attributes),
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 implementor => $class->ClassPropertyImplementor,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 name => $propName,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 class => scalar(caller),
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
39 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
40
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
41 sub CreateProperty {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
42 my ($class,$propName,@attributes) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
43
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
44 $class
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
45 ->ClassPropertyImplementor
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
46 ->Implement(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47 @attributes,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48 {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49 name => $propName,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50 class => $class,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
54
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55 1;