line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- mode: perl; coding: utf-8 -*- |
2
|
|
|
|
|
|
|
package YATT::Util::Enum; |
3
|
8
|
|
|
8
|
|
39
|
use strict; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
240
|
|
4
|
8
|
|
|
8
|
|
39
|
use warnings qw(FATAL all NONFATAL misc); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
303
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
39
|
use YATT::Util::Symbol qw/define_const/; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
2559
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub import { |
9
|
26
|
|
|
26
|
|
63
|
my ($pack) = shift; |
10
|
26
|
|
|
|
|
55
|
my $callpack = caller; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#---------------------------------------- |
13
|
26
|
|
|
|
|
46
|
my %opts; |
14
|
26
|
|
66
|
|
|
268
|
for (; @_ and $_[0] =~ /^-(\w+)/; splice @_, 0, 2) { |
15
|
19
|
|
|
|
|
167
|
$opts{$1} = $_[1]; |
16
|
|
|
|
|
|
|
} |
17
|
26
|
|
50
|
|
|
129
|
my $offset = delete $opts{offset} || 0; |
18
|
26
|
|
100
|
|
|
107
|
my $prefix = delete $opts{prefix} || ""; |
19
|
|
|
|
|
|
|
my $export = delete $opts{export} |
20
|
26
|
50
|
|
|
|
80
|
? $callpack . "::EXPORT" : ""; |
21
|
|
|
|
|
|
|
my $export_ok = $export || delete $opts{export_ok} |
22
|
26
|
50
|
33
|
|
|
114
|
? $callpack . "::EXPORT_OK" : ""; |
23
|
26
|
50
|
|
|
|
83
|
die "Unknown options for " . __PACKAGE__ . "\n". |
24
|
|
|
|
|
|
|
join ", ", keys %opts if keys %opts; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#---------------------------------------- |
27
|
26
|
|
|
|
|
67
|
foreach my $item (@_) { |
28
|
155
|
|
|
|
|
321
|
my $full_name = $callpack . "::" . $prefix . $item; |
29
|
|
|
|
|
|
|
{ |
30
|
155
|
|
|
|
|
182
|
define_const($full_name, $offset); |
|
155
|
|
|
|
|
429
|
|
31
|
155
|
50
|
|
|
|
379
|
push @{$export}, $full_name if $export; |
|
0
|
|
|
|
|
0
|
|
32
|
155
|
50
|
|
|
|
378
|
push @{$export_ok}, $full_name if $export_ok; |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} continue { |
35
|
155
|
|
|
|
|
26880
|
$offset++; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |