line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#======================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Badger::Codec::Encode |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# A codec wrapper for Encode |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Andy Wardley |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
#======================================================================== |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Badger::Codec::Encode; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Badger::Class |
16
|
2
|
|
|
|
|
17
|
version => 0.01, |
17
|
2
|
|
|
2
|
|
2549
|
base => 'Badger::Codec'; |
|
2
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
1459
|
use Encode qw(); |
|
2
|
|
|
|
|
20408
|
|
|
2
|
|
|
|
|
53
|
|
20
|
2
|
|
|
2
|
|
27
|
use bytes; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub encode { |
23
|
5
|
|
|
5
|
1
|
21
|
my $self = shift; |
24
|
|
|
|
|
|
|
# No, really, it's OK. This isn't one of those kind of GOTOs. |
25
|
|
|
|
|
|
|
# This is an Offically OK version of GOTO which is really a special |
26
|
|
|
|
|
|
|
# kind of subroutine call. See: perldoc -f goto |
27
|
5
|
|
|
|
|
15
|
goto &Encode::encode; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub decode { |
31
|
5
|
|
|
5
|
1
|
121
|
my $self = shift; |
32
|
|
|
|
|
|
|
# we use goto rather than a call because a) it's quicker (the call |
33
|
|
|
|
|
|
|
# stack frame is re-used) and b) because the prototypes for encode() |
34
|
|
|
|
|
|
|
# and decode() would require us to shift all the arguments off the |
35
|
|
|
|
|
|
|
# stack in order to pass them to encode()/decode() in an orderly |
36
|
|
|
|
|
|
|
# fashion, e.g. my ($enc, $data) = @_; Encode::encode($enc, $data) |
37
|
|
|
|
|
|
|
# rather than: Encode::encode(@_); # not allowed - prototype mismatch |
38
|
5
|
|
|
|
|
20
|
goto &Encode::decode; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub encoder { |
42
|
1
|
|
|
1
|
1
|
2
|
\&Encode::encode; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub decoder { |
46
|
1
|
|
|
1
|
1
|
3
|
\&Encode::decode; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |