blib/lib/Badger/Codec/Encode.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 27 CC 1 SCAR 6.9
CC
1
Cov
0%
encode
2.0
decode
2.0
encoder
2.0
CRAP 2.0
1 #========================================================================
2 #
3 # Badger::Codec::Encode
4 #
5 # DESCRIPTION
6 # A codec wrapper for Encode
7 #
8 # AUTHOR
9 # Andy Wardley <abw@wardley.org>
10 #
11 #========================================================================
12  
13 package Badger::Codec::Encode;
14  
15 use Badger::Class
16 version => 0.01,
17 base => 'Badger::Codec';
18  
19 use Encode qw();
20 use bytes;
21  
22 sub encode {
23 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 goto &Encode::encode;
28 }
29  
30 sub decode {
31 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 goto &Encode::decode;
39 }
40  
41 sub encoder {
42 \&Encode::encode;
43 }
44  
45 sub decoder {
46 \&Encode::decode;
47 }
48  
49 1;
50  
51  
52 __END__