| 1 | # A sample external freezer for POE::Filter::Reference testing. | ||||||||||||||
| 2 | |||||||||||||||
| 3 | package MyOtherFreezer; | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 8 | 0 | my $type = shift; | |||||||||||||
| 9 | 0 | return bless [ ], $type; | |||||||||||||
| 10 | } | ||||||||||||||
| 11 | |||||||||||||||
| 12 | 26 | ▶ | sub freeze { | ||||||||||||
|
Subroutine
freeze: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||
| 13 | 26 | my $thing = shift; | |||||||||||||
| 14 | 26 | ▶ | $thing = shift if ref($thing) eq 'MyOtherFreezer'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 15 | |||||||||||||||
| 16 | 26 | ▶ | if (ref($thing) eq 'SCALAR') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 17 | 24 | return reverse(join "\0", ref($thing), $$thing); | |||||||||||||
| 18 | } | ||||||||||||||
| 19 | elsif (ref($thing) eq 'Package') { | ||||||||||||||
| 20 | 2 | return reverse(join "\0", ref($thing), @$thing); | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | 0 | die "can't freeze things of type ", ref($thing); | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | |||||||||||||||
| 25 | 26 | ▶ | sub thaw { | ||||||||||||
|
Subroutine
thaw: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||
| 26 | 26 | my $thing = shift; | |||||||||||||
| 27 | 26 | ▶ | $thing = shift if ref($thing) eq 'MyOtherFreezer'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 28 | |||||||||||||||
| 29 | 26 | my ($type, @stuff) = split /\0/, reverse($thing); | |||||||||||||
| 30 | 26 | ▶ | if ($type eq 'SCALAR') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 31 | 24 | my $scalar = $stuff[0]; | |||||||||||||
| 32 | 24 | return \$scalar; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | elsif ($type eq 'Package') { | ||||||||||||||
| 35 | 2 | return bless \@stuff, $type; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | 0 | die "can't thaw things of type $type"; | |||||||||||||
| 38 | } | ||||||||||||||
| 39 | |||||||||||||||
| 40 | 2 | 1; | |||||||||||||