line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- mode: perl; coding: utf-8 -*- |
2
|
|
|
|
|
|
|
package YATT::Util::Enum; |
3
|
8
|
|
|
8
|
|
40
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
235
|
|
4
|
8
|
|
|
8
|
|
39
|
use warnings qw(FATAL all NONFATAL misc); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
315
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
42
|
use YATT::Util::Symbol qw/define_const/; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
2681
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub import { |
9
|
26
|
|
|
26
|
|
62
|
my ($pack) = shift; |
10
|
26
|
|
|
|
|
54
|
my $callpack = caller; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#---------------------------------------- |
13
|
26
|
|
|
|
|
41
|
my %opts; |
14
|
26
|
|
66
|
|
|
259
|
for (; @_ and $_[0] =~ /^-(\w+)/; splice @_, 0, 2) { |
15
|
19
|
|
|
|
|
177
|
$opts{$1} = $_[1]; |
16
|
|
|
|
|
|
|
} |
17
|
26
|
|
50
|
|
|
130
|
my $offset = delete $opts{offset} || 0; |
18
|
26
|
|
100
|
|
|
108
|
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
|
|
|
115
|
? $callpack . "::EXPORT_OK" : ""; |
23
|
26
|
50
|
|
|
|
79
|
die "Unknown options for " . __PACKAGE__ . "\n". |
24
|
|
|
|
|
|
|
join ", ", keys %opts if keys %opts; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#---------------------------------------- |
27
|
26
|
|
|
|
|
65
|
foreach my $item (@_) { |
28
|
155
|
|
|
|
|
323
|
my $full_name = $callpack . "::" . $prefix . $item; |
29
|
|
|
|
|
|
|
{ |
30
|
155
|
|
|
|
|
185
|
define_const($full_name, $offset); |
|
155
|
|
|
|
|
414
|
|
31
|
155
|
50
|
|
|
|
362
|
push @{$export}, $full_name if $export; |
|
0
|
|
|
|
|
0
|
|
32
|
155
|
50
|
|
|
|
418
|
push @{$export_ok}, $full_name if $export_ok; |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} continue { |
35
|
155
|
|
|
|
|
27683
|
$offset++; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |