| 1 | package CGI::Session::Serialize::default; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # $Id: default.pm 224 2005-09-09 07:44:04Z markstos $ | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 12 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 12 | ▶ | use Safe; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 12 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 12 | ▶ | use CGI::Session::ErrorHandler; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 12 | ▶ | use Scalar::Util qw(blessed reftype refaddr); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 12 | ▶ | use Carp "croak"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 12 | @CGI::Session::Serialize::default::ISA = ( "CGI::Session::ErrorHandler" ); | |||||||||||||||||||
| 13 | 12 | $CGI::Session::Serialize::default::VERSION = '1.5'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub freeze { | ||||||||||||||||||||
| 17 | 0 | ▶ | my ($class, $data) = @_; | ||||||||||||||||||
|
Subroutine
freeze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | my $d = new Data::Dumper([$data], ["D"]); | |||||||||||||||||||
| 20 | 0 | $d->Indent( 0 ); | |||||||||||||||||||
| 21 | 0 | $d->Purity( 0 ); | |||||||||||||||||||
| 22 | 0 | $d->Useqq( 0 ); | |||||||||||||||||||
| 23 | 0 | $d->Deepcopy( 1 ); | |||||||||||||||||||
| 24 | 0 | $d->Quotekeys( 0 ); | |||||||||||||||||||
| 25 | 0 | $d->Terse( 0 ); | |||||||||||||||||||
| 26 | 0 | return $d->Dump(); | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | sub thaw { | ||||||||||||||||||||
| 30 | 0 | ▶ | my ($class, $string) = @_; | ||||||||||||||||||
|
Subroutine
thaw: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # To make -T happy | ||||||||||||||||||||
| 33 | 0 | my ($safe_string) = $string =~ m/^(.*)$/s; | |||||||||||||||||||
| 34 | 0 | my $rv = Safe->new->reval( $safe_string ); | |||||||||||||||||||
| 35 | 0 | ▶ | if ( my $errmsg = $@ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 0 | return $class->set_error("thaw(): couldn't thaw. $@"); | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | 0 | __walk($rv); | |||||||||||||||||||
| 39 | 0 | return $rv; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | sub __walk { | ||||||||||||||||||||
| 43 | 0 | ▶ | my %seen; | ||||||||||||||||||
|
Subroutine
__walk: not called CC=9 SCAR=45.0
| |||||||||||||||||||||
| 44 | 0 | my @filter = shift; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | while (defined(my $x = shift @filter)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 0 | ▶ | $seen{refaddr $x || ''}++ and next; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::refaddr($x) || ''
MC/DC0%0/1
builtin::refaddr($x) || ''
builtin::refaddr($x)
Truth table0%0/2
A
A= builtin::refaddr($x)
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | ▶ | my $r = reftype $x or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | ▶ | if ($r eq "HASH") { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 51 | 0 | push @filter, __scan(@{$x}{keys %$x}); | |||||||||||||||||||
| 52 | } elsif ($r eq "ARRAY") { | ||||||||||||||||||||
| 53 | 0 | push @filter, __scan(@$x); | |||||||||||||||||||
| 54 | ▶ | } elsif ($r eq "SCALAR" || $r eq "REF") { | |||||||||||||||||||
|
Condition0%0/3
$r eq "SCALAR" or $r eq "REF"
MC/DC0%0/2
$r eq "SCALAR" or $r eq "REF"
$r eq "SCALAR"
$r eq "REF"
Truth table0%0/3
A or B
A= $r eq "SCALAR"B= $r eq "REF"
| |||||||||||||||||||||
| 55 | 0 | push @filter, __scan($$x); | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub __scan { | ||||||||||||||||||||
| 61 | 0 | ▶ | for (@_) { | ||||||||||||||||||
|
Subroutine
__scan: not called CC=8 SCAR=42.8
| |||||||||||||||||||||
| 62 | 0 | ▶ | if (blessed $_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | ▶ | if (overload::Overloaded($_)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 0 | my $r = reftype $_; | |||||||||||||||||||
| 65 | 0 | ▶ | if ($r eq "HASH") { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 66 | 0 | $_ = bless { %$_ }, ref $_; | |||||||||||||||||||
| 67 | } elsif ($r eq "ARRAY") { | ||||||||||||||||||||
| 68 | 0 | $_ = bless [ @$_ ], ref $_; | |||||||||||||||||||
| 69 | ▶ | } elsif ($r eq "SCALAR" || $r eq "REF") { | |||||||||||||||||||
|
Condition0%0/3
$r eq "SCALAR" or $r eq "REF"
MC/DC0%0/2
$r eq "SCALAR" or $r eq "REF"
$r eq "SCALAR"
$r eq "REF"
Truth table0%0/3
A or B
A= $r eq "SCALAR"B= $r eq "REF"
| |||||||||||||||||||||
| 70 | 0 | $_ = bless \do{my $o = $$_},ref $_; | |||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||
| 72 | 0 | croak "Do not know how to reconstitute blessed object of base type $r"; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||
| 75 | 0 | bless $_, ref $_; | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 0 | return @_; | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 12 | 1; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | __END__; | ||||||||||||||||||||