| 1 | package CIAO::Lib::StackIO; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | require XSLoader; | |||||||||||||||||||||||||||
| 11 | 1 | XSLoader::load('CIAO::Lib::StackIO', $VERSION); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | our %Options = ( prepend => 1, expand => 1 ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub new | ||||||||||||||||||||||||||||
| 18 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 6 | my $class = shift; | |||||||||||||||||||||||||||
| 20 | 6 | my $list = shift; | |||||||||||||||||||||||||||
| 21 | 6 | ▶ | my $opts = shift || { prepend => 1, expand => 0 }; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {'prepend', 1, 'expand', 0}
MC/DC100%1/1
shift() || {'prepend', 1, 'expand', 0}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 6 | ▶ | croak( __PACKAGE__, ": options must be hash ref\n" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | unless 'HASH' eq ref $opts; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 6 | ▶ | croak( __PACKAGE__, ": extra arguments to constructor\n" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | if @_; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 6 | my @badopts = grep { ! exists $Options{lc $_ } } keys %$opts; | |||||||||||||||||||||||||||
| 30 | 6 | ▶ | croak( __PACKAGE__, ": unknown options: ", join(', ', @badopts ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | if @badopts; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 6 | my %opts = map { lc $_ => $opts->{$_} } keys %$opts; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 6 | my $stack; | |||||||||||||||||||||||||||
| 36 | 6 | ▶ | if ( exists $opts{expand} && $opts{expand} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $opts{"expand"} and $opts{"expand"}
MC/DC100%2/2
exists $opts{"expand"} and $opts{"expand"}
exists $opts{"expand"}
$opts{"expand"}
Truth table100%3/3
A and B
A= exists $opts{"expand"}B= $opts{"expand"}
| |||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||
| 38 | $stack = | ||||||||||||||||||||||||||||
| 39 | CIAO::Lib::StackIO::Private::stk_expand_n( $list, $opts{expand} ) | ||||||||||||||||||||||||||||
| 40 | 1 | ▶ | or croak( __PACKAGE__, ": error generating expanded stack\n" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else | ||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 5 | ▶ | $stack = ( exists $opts{prepend} && $opts{prepend} ) ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $opts{"prepend"} and $opts{"prepend"}
MC/DC50%1/2
exists $opts{"prepend"} and $opts{"prepend"}
exists $opts{"prepend"}
$opts{"prepend"}
Truth table66%2/3
A and B
A= exists $opts{"prepend"}B= $opts{"prepend"}
| |||||||||||||||||||||||||||||
| 45 | CIAO::Lib::StackIO::Private::stk_build( $list ) : | ||||||||||||||||||||||||||||
| 46 | CIAO::Lib::StackIO::Private::stk_build_gen( $list ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | ▶ | croak( __PACKAGE__, ": error building stack\n" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | unless $stack; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # force a stack rewind because of a bug in the stackio library when | ||||||||||||||||||||||||||||
| 53 | # creating empty stacks. | ||||||||||||||||||||||||||||
| 54 | 6 | $stack->rewind; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 6 | $stack; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | 1; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||