| 1 | package Encode::Encoding; | ||||||||||||
| 2 | |||||||||||||
| 3 | # Base class for classes which implement encodings | ||||||||||||
| 4 | 69 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 69 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 69 | our $VERSION = '2.09'; | |||||||||||
| 7 | |||||||||||||
| 8 | 69 | our @CARP_NOT = qw(Encode Encode::Encoder); | |||||||||||
| 9 | |||||||||||||
| 10 | 69 | ▶ | use Carp (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 69 | ▶ | use Encode (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 69 | ▶ | use Encode::MIME::Name; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 69 | ▶ | use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 28 | ▶ | sub Define { | ||||||||||
|
Subroutine
Define: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 17 | 28 | my $obj = shift; | |||||||||||
| 18 | 28 | my $canonical = shift; | |||||||||||
| 19 | 28 | ▶ | $obj = bless { Name => $canonical }, $obj unless ref $obj; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | |||||||||||||
| 21 | # warn "$canonical => $obj\n"; | ||||||||||||
| 22 | 28 | Encode::define_encoding( $obj, $canonical, @_ ); | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 598 | ▶ | sub name { return shift->{'Name'} } | ||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 26 | |||||||||||||
| 27 | 25 | ▶ | sub mime_name { | ||||||||||
|
Subroutine
mime_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 28 | 25 | return Encode::MIME::Name::get_mime_name(shift->name); | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 88 | ▶ | sub renew { | ||||||||||
|
Subroutine
renew: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 32 | 88 | my $self = shift; | |||||||||||
| 33 | 88 | my $clone = bless {%$self} => ref($self); | |||||||||||
| 34 | 88 | $clone->{renewed}++; # so the caller can see it | |||||||||||
| 35 | 88 | DEBUG and warn $clone->{renewed}; | |||||||||||
| 36 | 88 | return $clone; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 30891 | ▶ | sub renewed { return $_[0]->{renewed} || 0 } | ||||||||||
|
Subroutine
renewed: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$_[0]{'renewed'} || 0
MC/DC100%1/1
$_[0]{'renewed'} || 0
$_[0]{'renewed'}
Truth table100%2/2
A
A= $_[0]{'renewed'}
| |||||||||||||
| 40 | |||||||||||||
| 41 | 69 | *new_sequence = \&renew; | |||||||||||
| 42 | |||||||||||||
| 43 | 86 | ▶ | sub needs_lines { 0 } | ||||||||||
|
Subroutine
needs_lines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 44 | |||||||||||||
| 45 | 8 | ▶ | sub perlio_ok { | ||||||||||
|
Subroutine
perlio_ok: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||
| 46 | 8 | ▶ | return eval { require PerlIO::encoding } ? 1 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | # (Temporary|legacy) methods | ||||||||||||
| 50 | |||||||||||||
| 51 | 0 | ▶ | sub toUnicode { shift->decode(@_) } | ||||||||||
|
Subroutine
toUnicode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 52 | 0 | ▶ | sub fromUnicode { shift->encode(@_) } | ||||||||||
|
Subroutine
fromUnicode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 53 | |||||||||||||
| 54 | # | ||||||||||||
| 55 | # Needs to be overloaded or just croak | ||||||||||||
| 56 | # | ||||||||||||
| 57 | |||||||||||||
| 58 | 1 | ▶ | sub encode { | ||||||||||
|
Subroutine
encode: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 59 | 1 | my $obj = shift; | |||||||||||
| 60 | 1 | ▶ | my $class = ref($obj) ? ref($obj) : $obj; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | 1 | Carp::croak( $class . "->encode() not defined!" ); | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | sub decode { | ||||||||||
|
Subroutine
decode: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 65 | 0 | my $obj = shift; | |||||||||||
| 66 | 0 | ▶ | my $class = ref($obj) ? ref($obj) : $obj; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | 0 | Carp::croak( $class . "->encode() not defined!" ); | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | 0 | ▶ | sub DESTROY { } | ||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||
| 71 | |||||||||||||
| 72 | 69 | 1; | |||||||||||
| 73 | __END__ | ||||||||||||