| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Const::Common::Generator; |
|
2
|
2
|
|
|
2
|
|
26340
|
use 5.008001; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
78
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
85
|
|
|
4
|
2
|
|
|
2
|
|
24
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
99
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1764
|
use Text::MicroTemplate; |
|
|
2
|
|
|
|
|
14224
|
|
|
|
2
|
|
|
|
|
721
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub generate { |
|
11
|
1
|
|
|
1
|
1
|
21
|
my $class = shift; |
|
12
|
1
|
50
|
|
|
|
8
|
my %args = @_ == 1 ? %{$_[0]} : @_; |
|
|
0
|
|
|
|
|
0
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
2
|
my $package = $args{package}; |
|
15
|
1
|
|
|
|
|
2
|
my @constants = @{ $args{constants} }; |
|
|
1
|
|
|
|
|
4
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
3
|
my @consts; |
|
18
|
1
|
|
|
|
|
7
|
while (my ($name, $value) = splice @constants, 0, 2) { |
|
19
|
3
|
|
|
|
|
4
|
my $comment; |
|
20
|
3
|
100
|
|
|
|
7
|
if (ref $value) { |
|
21
|
1
|
|
|
|
|
3
|
$comment = $value->{comment}; |
|
22
|
1
|
|
|
|
|
2
|
$value = $value->{value}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
3
|
100
|
|
|
|
19
|
push @consts, { |
|
26
|
|
|
|
|
|
|
name => $name, |
|
27
|
|
|
|
|
|
|
value => $value, |
|
28
|
|
|
|
|
|
|
(defined($comment) ? (comment => $comment) : ()), |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
6
|
|
|
6
|
|
1005
|
my $gen = Text::MicroTemplate->new( |
|
33
|
|
|
|
|
|
|
template => $class->_template, |
|
34
|
|
|
|
|
|
|
escape_func => sub {shift}, |
|
35
|
1
|
|
|
|
|
6
|
)->build; |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
796
|
$gen->( |
|
38
|
|
|
|
|
|
|
package => $package, |
|
39
|
|
|
|
|
|
|
consts => \@consts |
|
40
|
|
|
|
|
|
|
)->as_string; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _template { |
|
44
|
1
|
|
|
1
|
|
15
|
<<'...'; |
|
45
|
|
|
|
|
|
|
? my %args = @_; |
|
46
|
|
|
|
|
|
|
? use Scalar::Util qw/looks_like_number/; |
|
47
|
|
|
|
|
|
|
package = $args{package} ?>; |
|
48
|
|
|
|
|
|
|
use strict; |
|
49
|
|
|
|
|
|
|
use warnings; |
|
50
|
|
|
|
|
|
|
use utf8; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use Const::Common ( |
|
53
|
|
|
|
|
|
|
? for my $const (@{ $args{consts} }) { |
|
54
|
|
|
|
|
|
|
? my $v = $const->{value}; |
|
55
|
|
|
|
|
|
|
= $const->{name} ?> => = looks_like_number($v) ? '' : "'" ?>= $v ?>= looks_like_number($v) ? '' : "'" ?>, if ($const->{comment}) { ?> # = $const->{comment} ?> } ?> |
|
56
|
|
|
|
|
|
|
? } |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
... |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
__END__ |