line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# BW::Jumptable.pm |
2
|
|
|
|
|
|
|
# Jump table support for BW::* |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# by Bill Weinman - http://bw.org/ |
5
|
|
|
|
|
|
|
# Copyright (c) 1995-2010 The BearHeart Group, LLC |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# See POD for History |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package BW::Jumptable; |
10
|
1
|
|
|
1
|
|
1306
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use base qw( BW::Base ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
14
|
1
|
|
|
1
|
|
6
|
use BW::Constants; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
303
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = "1.3.1"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _init |
19
|
|
|
|
|
|
|
{ |
20
|
0
|
|
|
0
|
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
$self->SUPER::_init(@_); |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
return FAILURE unless $self->{jumptable}; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return SUCCESS; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# _setter_getter entry points |
29
|
0
|
|
|
0
|
1
|
|
sub jumptable { BW::Base::_setter_getter(@_); } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub jump |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
1
|
|
my $sn = 'jump'; |
34
|
0
|
|
|
|
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
my $action = shift; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
return $self->_error("$sn: no action") unless $action; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
foreach my $j ( keys %{ $self->{jumptable} } ) { |
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( $j eq $action ) { |
41
|
0
|
|
|
|
|
|
&{ $self->{jumptable}{$j} }(); |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return SUCCESS; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->_error("$sn: action not found ($action)"); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |