line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# $Source$ |
3
|
|
|
|
|
|
|
# $Author$ |
4
|
|
|
|
|
|
|
# $HeadURL$ |
5
|
|
|
|
|
|
|
# $Revision$ |
6
|
|
|
|
|
|
|
# $Date$ |
7
|
|
|
|
|
|
|
package dot::meta; |
8
|
|
|
|
|
|
|
|
9
|
14
|
|
|
14
|
|
110
|
use strict; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
535
|
|
10
|
14
|
|
|
14
|
|
72
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
370
|
|
11
|
|
|
|
|
|
|
|
12
|
14
|
|
|
14
|
|
67
|
use Carp qw(confess); |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
942
|
|
13
|
14
|
|
|
14
|
|
78
|
use Scalar::Util qw(blessed reftype); |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
986
|
|
14
|
14
|
|
|
14
|
|
77
|
use Class::Dot::Registry; |
|
14
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
6290
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $REGISTRY = Class::Dot::Registry->new(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub for { |
19
|
4
|
|
|
4
|
0
|
1692
|
goto &with; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub with { |
23
|
4
|
|
|
4
|
0
|
9
|
my ($self, $the_other_class) = @_; |
24
|
|
|
|
|
|
|
|
25
|
4
|
100
|
|
|
|
40
|
confess 'dot::meta::for needs class instance or class name' |
26
|
|
|
|
|
|
|
if not defined $the_other_class; |
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
|
|
|
9
|
my $other_class = ref $the_other_class |
29
|
|
|
|
|
|
|
? ref $the_other_class |
30
|
|
|
|
|
|
|
: $the_other_class; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
15
|
return $REGISTRY->get_metaclass_for($other_class); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub incompatible { |
36
|
3
|
|
|
3
|
0
|
41
|
my ($class) = @_; |
37
|
|
|
|
|
|
|
|
38
|
3
|
100
|
|
|
|
31
|
confess 'Must be instance to check compatibility, not class name' |
39
|
|
|
|
|
|
|
if not blessed $class; |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
5
|
my $name = ref $class; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
6
|
my $type = reftype $class; |
44
|
|
|
|
|
|
|
|
45
|
2
|
100
|
|
|
|
15
|
return "Instance must be HASH-based, but $name is $type-based" |
46
|
|
|
|
|
|
|
if $type ne 'HASH'; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
6
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # |
52
|
|
|
|
|
|
|
# Attribute Related. |
53
|
|
|
|
|
|
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub has { |
56
|
0
|
|
|
0
|
0
|
|
my ($class, @args) = @_; |
57
|
0
|
|
|
|
|
|
with($class)->add_attribute(@args); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub hasattr { |
61
|
0
|
|
|
0
|
0
|
|
my ($class, @args) = @_; |
62
|
0
|
|
|
|
|
|
with($class)->has_attribute(@args); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub getattr { |
67
|
0
|
|
|
0
|
0
|
|
my ($class, @args) = @_; |
68
|
0
|
|
|
|
|
|
with($class)->get_attribute(@args); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub setattr { |
72
|
0
|
|
|
0
|
0
|
|
my ($class, @args) = @_; |
73
|
0
|
|
|
|
|
|
with($class)->set_attribute(@args); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
0
|
|
sub delattr { |
78
|
|
|
|
|
|
|
# NOT YET IMPLEMENTED |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |