line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Wrapper; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#use 5.008; |
4
|
1
|
|
|
1
|
|
60175
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
795
|
|
7
|
|
|
|
|
|
|
#use Switch; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.22; |
12
|
|
|
|
|
|
|
our $AUTOLOAD; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
2
|
|
|
2
|
1
|
1283
|
my ($class,$component) = @_; |
16
|
2
|
100
|
50
|
|
|
241
|
croak __PACKAGE__." constructor argument was not an object reference: ".($component || "UNDEF") |
17
|
|
|
|
|
|
|
unless ref($component); |
18
|
1
|
|
33
|
|
|
12
|
my $self = bless { |
19
|
|
|
|
|
|
|
_component => $component |
20
|
|
|
|
|
|
|
}, ref($class) || $class; |
21
|
1
|
|
|
|
|
8
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub AUTOLOAD { |
25
|
3
|
|
|
3
|
|
521
|
my ($self,@args) = @_; |
26
|
3
|
50
|
|
|
|
12
|
return if $AUTOLOAD =~ /.*DESTROY$/; |
27
|
3
|
|
|
|
|
20
|
my ($method) = $self->_get_method_name(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Switch replaced by older foreach construct for compatibility |
30
|
|
|
|
|
|
|
# with Perl older than 5.8 |
31
|
|
|
|
|
|
|
#switch ($method) { |
32
|
|
|
|
|
|
|
# case /^get_(.+)/ {$self->_add_getter();} |
33
|
|
|
|
|
|
|
# case /^set_(.+)/ {$self->_add_setter();} |
34
|
|
|
|
|
|
|
# else {$self->_add_method();} |
35
|
|
|
|
|
|
|
#}; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
7
|
foreach ($method) { |
38
|
3
|
100
|
|
|
|
12
|
/^get_(.+)/ && do {$self->_add_getter();last;}; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
39
|
2
|
100
|
|
|
|
9
|
/^set_(.+)/ && do {$self->_add_setter();last;}; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
2
|
|
40
|
1
|
|
|
|
|
2
|
do {$self->_add_method();}; |
|
1
|
|
|
|
|
8
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
121
|
|
44
|
3
|
|
|
|
|
11
|
return $self->$method(@args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _add_getter { |
48
|
1
|
|
|
1
|
|
53
|
my ($self) = @_; |
49
|
1
|
|
|
|
|
3
|
my $method = $self->_get_method_name(); |
50
|
1
|
|
|
|
|
3
|
my $objComponent = $self->_get_component(); |
51
|
1
|
|
|
|
|
5
|
my ($property) = $method =~ /^get_(.+)/; |
52
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
717
|
|
53
|
1
|
|
|
|
|
5
|
*{$AUTOLOAD} = sub { |
54
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
55
|
1
|
|
|
|
|
1
|
my $result; |
56
|
1
|
|
|
|
|
2
|
eval {$result = $objComponent->{$property};}; |
|
1
|
|
|
|
|
4
|
|
57
|
1
|
50
|
|
|
|
4
|
croak($@) if $@; |
58
|
1
|
|
|
|
|
38
|
return $result; |
59
|
1
|
|
|
|
|
12
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _add_setter { |
63
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
64
|
1
|
|
|
|
|
3
|
my $method = $self->_get_method_name(); |
65
|
1
|
|
|
|
|
3
|
my $objComponent = $self->_get_component(); |
66
|
1
|
|
|
|
|
4
|
my ($property) = $method =~ /^set_(.+)/; |
67
|
1
|
|
|
1
|
|
13
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
152
|
|
68
|
1
|
|
|
|
|
5
|
*{$AUTOLOAD} = sub { |
69
|
1
|
|
|
1
|
|
2
|
my ($self,$arg) = @_; |
70
|
1
|
|
|
|
|
3
|
eval{$objComponent->{$property} = $arg}; |
|
1
|
|
|
|
|
3
|
|
71
|
1
|
50
|
|
|
|
21
|
croak($@) if $@; |
72
|
1
|
|
|
|
|
6
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _add_method { |
76
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
77
|
1
|
|
|
|
|
4
|
my $method = $self->_get_method_name(); |
78
|
1
|
|
|
|
|
6
|
my $objComponent = $self->_get_component(); |
79
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
796
|
|
80
|
1
|
|
|
|
|
8
|
*{$AUTOLOAD} = sub { |
81
|
1
|
|
|
1
|
|
2
|
my ($self,@args) = @_; |
82
|
1
|
|
|
|
|
2
|
my @retval; |
83
|
|
|
|
|
|
|
my $retval; |
84
|
1
|
50
|
|
|
|
4
|
if (wantarray) { |
85
|
0
|
|
|
|
|
0
|
eval{@retval = $objComponent->$method(@args);}; |
|
0
|
|
|
|
|
0
|
|
86
|
0
|
0
|
|
|
|
0
|
croak($@) if $@; |
87
|
0
|
|
|
|
|
0
|
return @retval; |
88
|
|
|
|
|
|
|
} else { |
89
|
1
|
|
|
|
|
2
|
eval{$retval = $objComponent->$method(@args);}; |
|
1
|
|
|
|
|
5
|
|
90
|
1
|
50
|
|
|
|
10
|
croak($@) if $@; |
91
|
1
|
|
|
|
|
6
|
return $retval; |
92
|
|
|
|
|
|
|
} |
93
|
1
|
|
|
|
|
6
|
}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _get_method_name { |
97
|
6
|
|
|
6
|
|
38
|
my ($method) = $AUTOLOAD =~ /^.*::(.*)$/; |
98
|
6
|
|
|
|
|
14
|
return $method; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
4
|
|
|
4
|
|
27
|
sub _get_component {$_[0]->{_component}} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |