Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Property.pm @ 122:a7efb3117295
Fixed bug in IMPL::DOM::Navigator::selectNodes
Fixed bug in IMPL::DOM::Node::selectNodes
renamed operator 'type' to 'typeof' in IMPL::Object::Abstract
A proper implementation of the IMPL::DOM::Node::nodeProperty and a related changes in the IMPL::DOM::Property module, now the last is very simple.
author | wizard |
---|---|
date | Tue, 08 Jun 2010 20:12:45 +0400 |
parents | 16ada169ca75 |
children | 76515373dac0 |
comparison
equal
deleted
inserted
replaced
121:92c850d0bdb9 | 122:a7efb3117295 |
---|---|
1 package IMPL::DOM::Property; | 1 package IMPL::DOM::Property; |
2 use strict; | 2 use strict; |
3 use warnings; | 3 use warnings; |
4 | 4 |
5 use IMPL::Class::Property; | |
6 require IMPL::Exception; | 5 require IMPL::Exception; |
7 | 6 |
8 use base qw(Exporter); | 7 use base qw(Exporter); |
9 our @EXPORT_OK = qw(_dom); | 8 our @EXPORT_OK = qw(_dom); |
10 | 9 |
11 sub _dom($) { | 10 sub _dom($) { |
12 my ($prop_info) = @_; | 11 my ($prop_info) = @_; |
13 $prop_info->Implementor( 'IMPL::DOM::Property' ); | 12 $prop_info->Attributes->{domProperty} = 1; |
14 return $prop_info; | 13 return $prop_info; |
15 } | |
16 | |
17 sub Make { | |
18 my ($self,$propInfo) = @_; | |
19 | |
20 my ($class,$name,$virt,$access,$mutators) = $propInfo->get qw(Class Name Virtual Access Mutators); | |
21 | |
22 die new IMPL::InvalidOperationException("DOM properties can be declared only for the DOM objects") unless $class->isa('IMPL::DOM::Node'); | |
23 | |
24 no strict 'refs'; | |
25 die new IMPL::InvalidOperationException("Custom mutators are not allowed","${class}::$name") if ref $mutators; | |
26 if (($mutators & prop_all) == prop_all) { | |
27 *{"${class}::$name"} = sub { | |
28 $_[0]->nodeProperty($name,@_[1..$#_]); | |
29 }; | |
30 $propInfo->canGet(1); | |
31 $propInfo->canSet(1); | |
32 } elsif( $mutators & prop_get ) { | |
33 *{"${class}::$name"} = sub { | |
34 die new IMPL::InvalidOperationException("This is a readonly property", "${class}::$name") if @_>1; | |
35 $_[0]->nodeProperty($name); | |
36 }; | |
37 $propInfo->canGet(1); | |
38 $propInfo->canSet(0); | |
39 } elsif( $mutators & prop_set ) { | |
40 *{"${class}::$name"} = sub { | |
41 die new IMPL::InvalidOperationException("This is a writeonly property", "${class}::$name") if @_<2; | |
42 $_[0]->nodeProperty($name,@_[1..$#_]); | |
43 }; | |
44 $propInfo->canGet(0); | |
45 $propInfo->canSet(1); | |
46 } else { | |
47 die new IMPL::InvalidOperationException("Invalid value for the property mutators","${class}::$name",$mutators); | |
48 } | |
49 } | 14 } |
50 | 15 |
51 1; | 16 1; |
52 __END__ | 17 __END__ |
53 =pod | 18 =pod |
65 public property ServiceData => prop_all; | 30 public property ServiceData => prop_all; |
66 } | 31 } |
67 | 32 |
68 =head1 DESCRIPTION | 33 =head1 DESCRIPTION |
69 | 34 |
70 Позволяет объявлять свойства, которые будут храниться в списке динамических | 35 Позволяет объявлять свойства, которые будут видны в списке свойств. |
71 свойств. | |
72 | 36 |
73 =cut | 37 =cut |