| 1 | package Getopt::Yath::HashBase; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '2.000008'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | ################################################################# | ||||||||||||||||||||||||||||
| 8 | # # | ||||||||||||||||||||||||||||
| 9 | # This is a generated file! Do not modify this file directly! # | ||||||||||||||||||||||||||||
| 10 | # Use hashbase_inc.pl script to regenerate this file. # | ||||||||||||||||||||||||||||
| 11 | # The script is part of the Object::HashBase distribution. # | ||||||||||||||||||||||||||||
| 12 | # Note: You can modify the version number above this comment # | ||||||||||||||||||||||||||||
| 13 | # if needed, that is fine. # | ||||||||||||||||||||||||||||
| 14 | # # | ||||||||||||||||||||||||||||
| 15 | ################################################################# | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | { | ||||||||||||||||||||||||||||
| 18 | 2 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | $Getopt::Yath::HashBase::HB_VERSION = '0.015'; | |||||||||||||||||||||||||||
| 20 | 2 | *Getopt::Yath::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS; | |||||||||||||||||||||||||||
| 21 | 2 | *Getopt::Yath::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST; | |||||||||||||||||||||||||||
| 22 | 2 | *Getopt::Yath::HashBase::VERSION = \%Object::HashBase::VERSION; | |||||||||||||||||||||||||||
| 23 | 2 | *Getopt::Yath::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | require Carp; | |||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 2 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 2 | $Carp::Internal{+__PACKAGE__} = 1; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | BEGIN { | ||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | # Make sure none of these get messed up. | ||||||||||||||||||||||||||||
| 36 | 2 | ▶ | local ($SIG{__DIE__}, $@, $?, $!, $^E); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=16.8
| |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | if (eval { require Class::XSAccessor; Class::XSAccessor->VERSION(1.19); 1 }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | *CLASS_XS_ACCESSOR = sub() { 1 } | ||||||||||||||||||||||||||||
| 39 | 2 | } | |||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||
| 41 | *CLASS_XS_ACCESSOR = sub() { 0 } | ||||||||||||||||||||||||||||
| 42 | 0 | } | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # these are not strictly equivalent, but for out use we don't care | ||||||||||||||||||||||||||||
| 46 | # about order | ||||||||||||||||||||||||||||
| 47 | *_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub { | ||||||||||||||||||||||||||||
| 48 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my @packages = ($_[0]); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 50 | 0 | my %seen; | |||||||||||||||||||||||||||
| 51 | 0 | for my $package (@packages) { | |||||||||||||||||||||||||||
| 52 | 0 | push @packages, grep !$seen{$_}++, @{"$package\::ISA"}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 0 | return \@packages; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 2 | ▶ | } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$] >= "5.01" and require mro
MC/DC0%0/2
$] >= "5.01" and require mro
$] >= "5.01"
require mro
Truth table33%1/3
A and B
A= $] >= "5.01"B= require mro
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | my %SPEC = ( | |||||||||||||||||||||||||||
| 59 | '^' => {reader => 1, writer => 0, dep_writer => 1, read_only => 0, strip => 1}, | ||||||||||||||||||||||||||||
| 60 | '-' => {reader => 1, writer => 0, dep_writer => 0, read_only => 1, strip => 1}, | ||||||||||||||||||||||||||||
| 61 | '>' => {reader => 0, writer => 1, dep_writer => 0, read_only => 0, strip => 1}, | ||||||||||||||||||||||||||||
| 62 | '<' => {reader => 1, writer => 0, dep_writer => 0, read_only => 0, strip => 1}, | ||||||||||||||||||||||||||||
| 63 | '+' => {reader => 0, writer => 0, dep_writer => 0, read_only => 0, strip => 1}, | ||||||||||||||||||||||||||||
| 64 | '~' => {reader => 1, writer => 1, dep_writer => 0, read_only => 0, strip => 1, no_xs => 1}, | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 73 | ▶ | sub spec { \%SPEC } | ||||||||||||||||||||||||||
|
Subroutine
spec: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub import { | ||||||||||||||||||||||||||||
| 70 | 21 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | 21 | my $into = caller; | |||||||||||||||||||||||||||
| 72 | 21 | $class->do_import($into, @_); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub do_import { | ||||||||||||||||||||||||||||
| 76 | 21 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
do_import: called CC=13 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 21 | my $into = shift; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # Make sure we list the OLDEST version used to create this class. | ||||||||||||||||||||||||||||
| 80 | 21 | ▶ | my $ver = $Getopt::Yath::HashBase::HB_VERSION || $Getopt::Yath::HashBase::VERSION; | ||||||||||||||||||||||||||
|
Condition33%1/3
$Getopt::Yath::HashBase::HB_VERSION || $Getopt::Yath::HashBase::VERSION
MC/DC0%0/2
$Getopt::Yath::HashBase::HB_VERSION || $Getopt::Yath::HashBase::VERSION
$Getopt::Yath::HashBase::HB_VERSION
$Getopt::Yath::HashBase::VERSION
Truth table33%1/3
A || B
A= $Getopt::Yath::HashBase::HB_VERSIONB= $Getopt::Yath::HashBase::VERSION
| |||||||||||||||||||||||||||||
| 81 | 21 | ▶ | $Getopt::Yath::HashBase::VERSION{$into} = $ver if !$Getopt::Yath::HashBase::VERSION{$into} || $Getopt::Yath::HashBase::VERSION{$into} > $ver; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $Getopt::Yath::HashBase::VERSION{$into} or $Getopt::Yath::HashBase::VERSION{$into} > $ver
MC/DC0%0/2
not $Getopt::Yath::HashBase::VERSION{$into} or $Getopt::Yath::HashBase::VERSION{$into} > $ver
not $Getopt::Yath::HashBase::VERSION{$into}
$Getopt::Yath::HashBase::VERSION{$into} > $ver
Truth table33%1/3
not(A) or B
A= not $Getopt::Yath::HashBase::VERSION{$into}B= $Getopt::Yath::HashBase::VERSION{$into} > $ver
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 21 | my $isa = _isa($into); | |||||||||||||||||||||||||||
| 84 | 21 | ▶ | my $attr_list = $Getopt::Yath::HashBase::ATTR_LIST{$into} ||= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Getopt::Yath::HashBase::ATTR_LIST{$into} ||= []
MC/DC0%0/1
$Getopt::Yath::HashBase::ATTR_LIST{$into} ||= []
$Getopt::Yath::HashBase::ATTR_LIST{$into}
Truth table50%1/2
A
A= $Getopt::Yath::HashBase::ATTR_LIST{$into}
| |||||||||||||||||||||||||||||
| 85 | 21 | ▶ | my $attr_subs = $Getopt::Yath::HashBase::ATTR_SUBS{$into} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Getopt::Yath::HashBase::ATTR_SUBS{$into} ||= {}
MC/DC0%0/1
$Getopt::Yath::HashBase::ATTR_SUBS{$into} ||= {}
$Getopt::Yath::HashBase::ATTR_SUBS{$into}
Truth table50%1/2
A
A= $Getopt::Yath::HashBase::ATTR_SUBS{$into}
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 21 | my @pre_init; | |||||||||||||||||||||||||||
| 88 | my @post_init; | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 21 | my $add_new = 1; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 21 | ▶ | if (my $have_new = $into->can('new')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 12 | ▶ | my $new_lookup = $Getopt::Yath::HashBase::NEW_LOOKUP //= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Getopt::Yath::HashBase::NEW_LOOKUP //= {}
MC/DC0%0/1
$Getopt::Yath::HashBase::NEW_LOOKUP //= {}
$Getopt::Yath::HashBase::NEW_LOOKUP
Truth table50%1/2
A
A= $Getopt::Yath::HashBase::NEW_LOOKUP
| |||||||||||||||||||||||||||||
| 94 | 12 | ▶ | $add_new = 0 unless $new_lookup->{$have_new}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | my %subs = ( | ||||||||||||||||||||||||||||
| 98 | ($add_new ? ($class->_build_new($into, \@pre_init, \@post_init)) : ()), | ||||||||||||||||||||||||||||
| 99 | 21 | ▶ | (map %{$Getopt::Yath::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]), | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 100 | ($class->args_to_subs($attr_list, $attr_subs, \@_, $into)), | ||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 104 | 21 | ▶ | while (my ($k, $v) = each %subs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 544 | ▶ | if (ref($v) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 458 | *{"$into\::$k"} = $v; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||
| 109 | 86 | my ($sub, @args) = @$v; | |||||||||||||||||||||||||||
| 110 | 86 | $sub->(@args); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub args_to_subs { | ||||||||||||||||||||||||||||
| 116 | 21 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
args_to_subs: called CC=16 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | 21 | my ($attr_list, $attr_subs, $args, $into) = @_; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 21 | my $use_gen = $class->can('gen_accessor') ; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 21 | my %out; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 21 | ▶ | while (@$args) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 73 | my $x = shift @$args; | |||||||||||||||||||||||||||
| 125 | 73 | my $p = substr($x, 0, 1); | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 73 | ▶ | my $spec = $class->spec->{$p} || {reader => 1, writer => 1}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$class->spec->{$p} || {'reader', 1, 'writer', 1}
MC/DC100%1/1
$class->spec->{$p} || {'reader', 1, 'writer', 1}
$class->spec->{$p}
Truth table100%2/2
A
A= $class->spec->{$p}
| |||||||||||||||||||||||||||||
| 128 | 73 | ▶ | substr($x, 0, 1) = '' if $spec->{strip}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 73 | push @$attr_list => $x; | |||||||||||||||||||||||||||
| 131 | 73 | my ($sub, $attr) = (uc $x, $x); | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 73 | ▶ | $attr_subs->{$sub} = sub() { $attr }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 134 | 73 | $out{$sub} = $attr_subs->{$sub}; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 73 | my $copy = "$attr"; | |||||||||||||||||||||||||||
| 137 | 73 | ▶ | if ($spec->{reader}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 63 | ▶ | if ($use_gen) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 139 | 0 | $out{$attr} = $class->gen_accessor(reader => $copy, $spec, $args); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | elsif (CLASS_XS_ACCESSOR && !$spec->{no_xs}) { | ||||||||||||||||||||||||||||
| 142 | 63 | $out{$attr} = [\&Class::XSAccessor::newxs_getter, "$into\::$attr", $copy]; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $out{$attr} = sub { $_[0]->{$attr} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 73 | ▶ | if ($spec->{writer}) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 150 | 23 | ▶ | if ($use_gen) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 151 | 0 | $out{"set_$attr"} = $class->gen_accessor(writer => $copy, $spec, $args); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | elsif(CLASS_XS_ACCESSOR && !$spec->{no_xs}) { | ||||||||||||||||||||||||||||
| 154 | 23 | $out{"set_$attr"} = [\&Class::XSAccessor::newxs_setter, "$into\::set_$attr", $copy, 0]; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $out{"set_$attr"} = sub { $_[0]->{$attr} = $_[1] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | elsif($spec->{read_only}) { | ||||||||||||||||||||||||||||
| 161 | 1 | ▶ | $out{"set_$attr"} = $use_gen ? $class->gen_accessor(read_only => $copy, $spec, $args) : sub { Carp::croak("'$attr' is read-only") }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | elsif($spec->{dep_writer}) { | ||||||||||||||||||||||||||||
| 164 | 1 | ▶ | $out{"set_$attr"} = $use_gen ? $class->gen_accessor(dep_writer => $copy, $spec, $args) : sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 73 | ▶ | if ($spec->{custom}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | my %add = $class->gen_accessor(custom => $copy, $spec, $args); | |||||||||||||||||||||||||||
| 169 | 0 | $out{$_} = $add{$_} for keys %add; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 21 | return %out; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub attr_list { | ||||||||||||||||||||||||||||
| 177 | 3 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
attr_list: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 3 | my $isa = _isa($class); | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 3 | my %seen; | |||||||||||||||||||||||||||
| 182 | 15 | my @list = grep { !$seen{$_}++ } map { | |||||||||||||||||||||||||||
| 183 | 3 | my @out; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 6 | ▶ | if (0.004 > ($Getopt::Yath::HashBase::VERSION{$_} || 0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$Getopt::Yath::HashBase::VERSION{$_} || 0
MC/DC0%0/1
$Getopt::Yath::HashBase::VERSION{$_} || 0
$Getopt::Yath::HashBase::VERSION{$_}
Truth table50%1/2
A
A= $Getopt::Yath::HashBase::VERSION{$_}
| |||||||||||||||||||||||||||||
| 186 | 0 | Carp::carp("$_ uses an inlined version of Getopt::Yath::HashBase too old to support attr_list()"); | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||
| 189 | 6 | my $list = $Getopt::Yath::HashBase::ATTR_LIST{$_}; | |||||||||||||||||||||||||||
| 190 | 6 | ▶ | @out = $list ? @$list : () | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 6 | @out; | |||||||||||||||||||||||||||
| 194 | } reverse @$isa; | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 3 | return @list; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | sub _build_new { | ||||||||||||||||||||||||||||
| 200 | 20 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_new: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 201 | 20 | my ($into, $pre_init, $post_init) = @_; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 20 | ▶ | my $add_pre_init = sub(&) { push @$pre_init => $_[-1] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 204 | 20 | ▶ | my $add_post_init = sub(&) { push @$post_init => $_[-1] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 20 | my $__pre_init = $into->can('_pre_init'); | |||||||||||||||||||||||||||
| 207 | 20 | ▶ | my $_pre_init = $__pre_init ? sub { ($__pre_init->(), @$pre_init) } : sub { @$pre_init }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 20 | my $__post_init = $into->can('_post_init'); | |||||||||||||||||||||||||||
| 210 | 20 | ▶ | my $_post_init = $__post_init ? sub { ($__post_init->(), @$post_init) } : sub { @$post_init }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | my $new = sub { | ||||||||||||||||||||||||||||
| 213 | 30 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 30 | my $self; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 30 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 3 | my $arg = shift; | |||||||||||||||||||||||||||
| 219 | 3 | my $type = ref($arg); | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 3 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 1 | $self = bless({%$arg}, $class); | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||
| 225 | 2 | ▶ | Carp::croak("Not sure what to do with '$type' in $class constructor") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | unless $type eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 2 | my %proto; | |||||||||||||||||||||||||||
| 229 | 2 | my @attributes = attr_list($class); | |||||||||||||||||||||||||||
| 230 | 2 | ▶ | while (@$arg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 9 | my $val = shift @$arg; | |||||||||||||||||||||||||||
| 232 | 9 | ▶ | my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 8 | $proto{$key} = $val; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 1 | $self = bless(\%proto, $class); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | else { | ||||||||||||||||||||||||||||
| 240 | 27 | $self = bless({@_}, $class); | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | $Getopt::Yath::HashBase::CAN_CACHE{$class} = $self->can('init') | ||||||||||||||||||||||||||||
| 244 | 29 | ▶ | unless exists $Getopt::Yath::HashBase::CAN_CACHE{$class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 29 | $self->$_() for $_pre_init->(); | |||||||||||||||||||||||||||
| 247 | 29 | ▶ | $self->init() if $Getopt::Yath::HashBase::CAN_CACHE{$class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 28 | $self->$_() for reverse $_post_init->(); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 28 | $self; | |||||||||||||||||||||||||||
| 251 | 20 | }; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 20 | ▶ | my $new_lookup = $Getopt::Yath::HashBase::NEW_LOOKUP //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$Getopt::Yath::HashBase::NEW_LOOKUP //= {}
MC/DC100%1/1
$Getopt::Yath::HashBase::NEW_LOOKUP //= {}
$Getopt::Yath::HashBase::NEW_LOOKUP
Truth table100%2/2
A
A= $Getopt::Yath::HashBase::NEW_LOOKUP
| |||||||||||||||||||||||||||||
| 254 | 20 | $new_lookup->{$new} = 1; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 20 | my %out; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||
| 259 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | 20 | ▶ | $out{new} = $new unless defined(&{"${into}\::new"}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | 20 | ▶ | $out{add_pre_init} = $add_pre_init unless defined(&{"${into}\::add_pre_init"}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 20 | ▶ | $out{add_post_init} = $add_post_init unless defined(&{"${into}\::add_post_init"}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 20 | ▶ | $out{_pre_init} = $_pre_init unless defined(&{"${into}\::_pre_init"}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 20 | ▶ | $out{_post_init} = $_post_init unless defined(&{"${into}\::_post_init"}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 20 | return %out; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 2 | 1; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | __END__ | ||||||||||||||||||||||||||||