line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AutoCode::ModuleModel; |
2
|
5
|
|
|
5
|
|
23
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
166
|
|
3
|
5
|
|
|
5
|
|
26
|
use AutoCode::Root; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
26
|
|
4
|
|
|
|
|
|
|
our @ISA=qw(AutoCode::Root); |
5
|
|
|
|
|
|
|
use AutoCode::AccessorMaker ( |
6
|
5
|
|
|
|
|
49
|
'$' => [qw(schema type _value_attributes _directive_attributes)], |
7
|
|
|
|
|
|
|
'@' => ['scalar_attribute', 'array_attribute', 'scalar_slot', 'array_slot', |
8
|
|
|
|
|
|
|
[qw(scalar_child scalar_children)], [qw(array_child array_children)], |
9
|
|
|
|
|
|
|
'isa'] |
10
|
5
|
|
|
5
|
|
25
|
); |
|
5
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
1826
|
use AutoCode::AttributeType; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
47
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _initialize { |
15
|
14
|
|
|
14
|
|
53
|
my ($self, @args)=@_; |
16
|
14
|
|
|
|
|
88
|
my ($schema, $type)=$self->_rearrange([qw(SCHEMA TYPE)], @args); |
17
|
14
|
50
|
|
|
|
51
|
defined $schema or $self->throw("NO schema!"); |
18
|
14
|
|
|
|
|
243
|
$self->schema($schema); |
19
|
14
|
50
|
|
|
|
41
|
defined $type or $self->throw("NO type!"); |
20
|
14
|
|
|
|
|
61
|
$self->type($type); |
21
|
|
|
|
|
|
|
|
22
|
14
|
|
|
|
|
57
|
$self->__initialize_value_attributes; # value_attribute, directive_attribute |
23
|
14
|
|
|
|
|
41
|
$self->__initialize_directive_attributes; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub __initialize_value_attributes { |
28
|
14
|
|
|
14
|
|
21
|
my $self=shift; |
29
|
14
|
|
|
|
|
36
|
my ($schema, $type)=($self->schema, $self->type); |
30
|
14
|
|
|
|
|
24
|
my %module =%{$schema->_get_module_definition($type)}; |
|
14
|
|
|
|
|
62
|
|
31
|
|
|
|
|
|
|
|
32
|
14
|
|
|
|
|
30
|
my (%value_attrs, %directive_attrs); |
33
|
14
|
|
|
|
|
143
|
$value_attrs{$_}=$module{$_} foreach grep /^[a-zA-Z_]/, keys %module; |
34
|
14
|
|
|
|
|
89
|
$directive_attrs{$_}=$module{$_} foreach grep /^\W/, keys %module; |
35
|
14
|
|
|
|
|
56
|
$self->_value_attributes(\%value_attrs); |
36
|
14
|
|
|
|
|
42
|
$self->_directive_attributes(\%directive_attrs); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# initialize_value_attributes |
39
|
39
|
|
|
|
|
158
|
$self->add_scalar_attribute($_) |
40
|
14
|
|
|
|
|
107
|
foreach grep {$value_attrs{$_}=~/^\$/} keys %value_attrs; |
41
|
39
|
|
|
|
|
209
|
$self->add_array_attribute($_) |
42
|
14
|
|
|
|
|
38
|
foreach grep {$value_attrs{$_}=~/^\@/} keys %value_attrs; |
43
|
|
|
|
|
|
|
|
44
|
14
|
|
|
|
|
55
|
foreach my $attr ($self->get_scalar_attributes){ |
45
|
29
|
|
|
|
|
75
|
my $kind = ($self->_classify_value_attribute($attr))[1]; |
46
|
29
|
100
|
|
|
|
108
|
if($kind =~ /^[PE]$/){ $self->add_scalar_slot($attr); |
|
19
|
50
|
|
|
|
54
|
|
47
|
10
|
|
|
|
|
41
|
}elsif($kind eq 'M'){ $self->add_scalar_child($attr); |
48
|
0
|
|
|
|
|
0
|
}else{ $self->throw("$kind of Attr[$attr] is not valid kind"); } |
49
|
|
|
|
|
|
|
} |
50
|
14
|
|
|
|
|
53
|
foreach my $attr ($self->get_array_attributes){ |
51
|
10
|
|
|
|
|
27
|
my $kind = ($self->_classify_value_attribute($attr))[1]; |
52
|
10
|
100
|
|
|
|
1199
|
if($kind eq 'P'){ $self->add_array_slot($attr); } |
|
5
|
50
|
|
|
|
20
|
|
53
|
5
|
|
|
|
|
22
|
elsif($kind eq 'M'){ $self->add_array_child($attr); } |
54
|
0
|
|
|
|
|
0
|
else{ $self->throw("$kind of Attr[$attr] is not valid kind"); } |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub __initialize_directive_attributes { |
60
|
14
|
|
|
14
|
|
17
|
my $self=shift; |
61
|
14
|
|
|
|
|
16
|
my %d_attrs=%{$self->_directive_attributes}; |
|
14
|
|
|
|
|
35
|
|
62
|
14
|
100
|
|
|
|
65
|
if(exists $d_attrs{'@ISA'}){ |
63
|
8
|
|
|
|
|
15
|
my $isa=$d_attrs{'@ISA'}; |
64
|
8
|
50
|
|
|
|
51
|
$self->add_isa((ref($isa) eq'ARRAY')?@$isa:$isa); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_all_value_attributes { |
69
|
0
|
|
|
0
|
0
|
0
|
return keys %{shift->_value_attributes}; |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_value_attribute { |
73
|
39
|
|
|
39
|
0
|
57
|
my ($self, $attr)=@_; |
74
|
39
|
|
|
|
|
39
|
my %attrs=%{$self->_value_attributes}; |
|
39
|
|
|
|
|
253
|
|
75
|
39
|
|
|
|
|
149
|
return $attrs{$attr}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub get_all_directive_attributes { |
79
|
0
|
|
|
0
|
0
|
0
|
keys %{shift->_directive_attributes}; |
|
0
|
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub get_directive_attribute { |
83
|
0
|
|
|
0
|
0
|
0
|
my ($self, $attr)=@_; |
84
|
0
|
|
|
|
|
0
|
my %attrs=%{$self->_directive_attributes}; |
|
0
|
|
|
|
|
0
|
|
85
|
0
|
|
|
|
|
0
|
return $attrs{$attr}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _classify_value_attribute { |
89
|
39
|
|
|
39
|
|
53
|
my ($self, $attr)=@_; |
90
|
39
|
|
|
|
|
78
|
my $value = $self->get_value_attribute($attr); |
91
|
|
|
|
|
|
|
|
92
|
39
|
|
|
|
|
135
|
return AutoCode::AttributeType->classify($value); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |