| 1 | ############################################################################# | ||||||||||||||||||||||||||||
| 2 | ## Name: MultiType.pm | ||||||||||||||||||||||||||||
| 3 | ## Purpose: Object::MultiType | ||||||||||||||||||||||||||||
| 4 | ## Author: Graciliano M. P. | ||||||||||||||||||||||||||||
| 5 | ## Modified by: | ||||||||||||||||||||||||||||
| 6 | ## Created: 10/05/2003 | ||||||||||||||||||||||||||||
| 7 | ## RCS-ID: | ||||||||||||||||||||||||||||
| 8 | ## Copyright: (c) 2003 Graciliano M. P. | ||||||||||||||||||||||||||||
| 9 | ## Licence: This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 10 | ## modify it under the same terms as Perl itself | ||||||||||||||||||||||||||||
| 11 | ############################################################################# | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | package Object::MultiType; | ||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use 5.006 ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict qw(vars) ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | no warnings ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use overload ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | 'bool' => '_OVER_bool' , | |||||||||||||||||||||||||||
| 22 | '""' => '_OVER_string' , | ||||||||||||||||||||||||||||
| 23 | '=' => '_OVER_copy' , | ||||||||||||||||||||||||||||
| 24 | '+' => '_OVER_inc' , | ||||||||||||||||||||||||||||
| 25 | '-' => '_OVER_deinc' , | ||||||||||||||||||||||||||||
| 26 | '0+' => '_OVER_copy' , | ||||||||||||||||||||||||||||
| 27 | '@{}' => '_OVER_get_array' , | ||||||||||||||||||||||||||||
| 28 | '%{}' => '_OVER_get_hash' , | ||||||||||||||||||||||||||||
| 29 | '&{}' => '_OVER_get_code' , | ||||||||||||||||||||||||||||
| 30 | '*{}' => '_OVER_get_glob' , | ||||||||||||||||||||||||||||
| 31 | 'fallback' => 1 , | ||||||||||||||||||||||||||||
| 32 | 1 | ) ; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub is_saver { 0 ;} | ||||||||||||||||||||||||||
|
Subroutine
is_saver: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | ####### | ||||||||||||||||||||||||||||
| 37 | # NEW # | ||||||||||||||||||||||||||||
| 38 | ####### | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=20 SCAR=38.1
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 17 | my $class = shift ; | |||||||||||||||||||||||||||
| 42 | 17 | my (%args) = @_ ; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 17 | my $saver = Object::MultiType::Saver->new( $args{nodefault} ) ; | |||||||||||||||||||||||||||
| 45 | 17 | my $this = \$saver ; | |||||||||||||||||||||||||||
| 46 | 17 | bless($this,$class) ; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (!defined $args{boolsub} && defined $args{boolcode} ) { $args{boolsub} = $args{boolcode} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $args{"boolsub"} and defined $args{"boolcode"}
MC/DC0%0/2
not defined $args{"boolsub"} and defined $args{"boolcode"}
not defined $args{"boolsub"}
defined $args{"boolcode"}
Truth table66%2/3
not(A) and B
A= not defined $args{"boolsub"}B= defined $args{"boolcode"}
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 17 | ▶ | if ( exists $args{bool} ) { $saver->set_bool($args{bool}) ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 51 | elsif ( $args{boolsub} ) { | ||||||||||||||||||||||||||||
| 52 | 1 | my $sub = $args{boolsub} ; | |||||||||||||||||||||||||||
| 53 | 1 | $saver->set_bool(\$sub) ; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (!defined $args{scalarsub} && defined $args{scalarcode} ) { $args{scalarsub} = $args{scalarcode} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $args{"scalarsub"} and defined $args{"scalarcode"}
MC/DC0%0/2
not defined $args{"scalarsub"} and defined $args{"scalarcode"}
not defined $args{"scalarsub"}
defined $args{"scalarcode"}
Truth table66%2/3
not(A) and B
A= not defined $args{"scalarsub"}B= defined $args{"scalarcode"}
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 17 | ▶ | if ( defined $args{scalar} ) { $saver->set_scalar($args{scalar}) ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 59 | elsif ( $args{scalarsub} ) { | ||||||||||||||||||||||||||||
| 60 | 1 | my $sub = $args{scalarsub} ; | |||||||||||||||||||||||||||
| 61 | 1 | $saver->set_scalar(\$sub) ; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 17 | ▶ | if ( ref $args{array} eq 'ARRAY' ) { $saver->set_array($args{array}) ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 65 | elsif ( $args{tiearray} ) { | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $args{tieonuse} ) { $saver->{TIEONUSE}{a} = $args{tiearray} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||
| 68 | 0 | my @array ; tie(@array,$args{tiearray},$$this) ; | |||||||||||||||||||||||||||
| 69 | 0 | $saver->set_array(\@array) ; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 17 | ▶ | if ( ref $args{hash} eq 'HASH' ) { $saver->set_hash($args{hash}) ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 74 | elsif ( $args{tiehash} ) { | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( $args{tieonuse} ) { $saver->{TIEONUSE}{h} = $args{tiehash} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||
| 77 | 0 | my %hash = 1 ; tie(%hash,$args{tiehash},$$this) ; | |||||||||||||||||||||||||||
| 78 | 0 | $saver->set_hash(\%hash) ; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 17 | ▶ | if ( ref $args{code} eq 'CODE' ) { $saver->set_code( $args{code} ) ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 17 | ▶ | if ( $args{tiehandle} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if (!$args{glob}) { local(*NULL) ; $args{glob} = \*NULL ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( $args{tieonuse} ) { $saver->{TIEONUSE}{g} = $args{tiehandle} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | else { tie($args{glob} , $args{tiehandle} , $$this) ;} | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 17 | ▶ | if ( ref $args{glob} eq 'GLOB' ) { $saver->set_glob( $args{glob} ) ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 17 | return( $this ) ; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | ############## | ||||||||||||||||||||||||||||
| 97 | # _OVER_BOOL # | ||||||||||||||||||||||||||||
| 98 | ############## | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 7 | ▶ | sub _OVER_bool { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_bool: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 101 | 7 | my $this = shift ; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 7 | ▶ | if ( !exists $$this->{b} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 2 | return $this->_OVER_string ; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 5 | my $bool = $$this->bool ; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 5 | ▶ | if (ref($bool) && ref($$bool) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $bool and ref $$bool eq "CODE"
MC/DC100%2/2
ref $bool and ref $$bool eq "CODE"
ref $bool
ref $$bool eq "CODE"
Truth table100%3/3
A and B
A= ref $boolB= ref $$bool eq "CODE"
| |||||||||||||||||||||||||||||
| 110 | 2 | my $sub = $$bool ; | |||||||||||||||||||||||||||
| 111 | 2 | return &$sub($this) ; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 3 | ▶ | if (ref($bool) eq 'SCALAR') { return( $$bool ) ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 2 | return( $bool ) ; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | ########## | ||||||||||||||||||||||||||||
| 120 | # STRING # | ||||||||||||||||||||||||||||
| 121 | ########## | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 12 | ▶ | sub _OVER_string { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_string: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 124 | 12 | my $this = shift ; | |||||||||||||||||||||||||||
| 125 | 12 | my $scalar = $$this->scalar ; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 12 | ▶ | if (ref($$scalar) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 1 | my $sub = $$scalar ; | |||||||||||||||||||||||||||
| 129 | 1 | return &$sub($this) ; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 11 | else { return( $$scalar ) ;} | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | ############# | ||||||||||||||||||||||||||||
| 135 | # _OVER_INC # | ||||||||||||||||||||||||||||
| 136 | ############# | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 2 | ▶ | sub _OVER_inc { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_inc: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 139 | 2 | my $this = shift ; | |||||||||||||||||||||||||||
| 140 | 2 | my $scalar = $$this->scalar ; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 2 | my $n ; | |||||||||||||||||||||||||||
| 143 | 2 | ▶ | if (ref($$scalar) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | my $sub = $$scalar ; | |||||||||||||||||||||||||||
| 145 | 0 | $n = &$sub($this) ; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 2 | else { $n = substr($$scalar , 0 ) ;} | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 2 | $n += $_[0] ; | |||||||||||||||||||||||||||
| 150 | 2 | return $n ; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | ############### | ||||||||||||||||||||||||||||
| 154 | # _OVER_DEINC # | ||||||||||||||||||||||||||||
| 155 | ############### | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub _OVER_deinc { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_deinc: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 158 | 2 | my $this = shift ; | |||||||||||||||||||||||||||
| 159 | 2 | my $scalar = $$this->scalar ; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 2 | my $n ; | |||||||||||||||||||||||||||
| 162 | 2 | ▶ | if (ref($$scalar) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | my $sub = $$scalar ; | |||||||||||||||||||||||||||
| 164 | 0 | $n = &$sub($this) ; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | 2 | else { $n = substr($$scalar , 0 ) ;} | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 2 | $n -= $_[0] ; | |||||||||||||||||||||||||||
| 169 | 2 | return $n ; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | ############## | ||||||||||||||||||||||||||||
| 173 | # _OVER_COPY # | ||||||||||||||||||||||||||||
| 174 | ############## | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub _OVER_copy { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_copy: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 177 | 0 | my $this = shift ; | |||||||||||||||||||||||||||
| 178 | 0 | my $scalar = $$this->scalar ; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (ref($$scalar) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | my $sub = $$scalar ; | |||||||||||||||||||||||||||
| 182 | 0 | return &$sub($this) ; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | 0 | else { return( substr($$scalar , 0 ) ) ;} | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | ############# | ||||||||||||||||||||||||||||
| 188 | # GET_ARRAY # | ||||||||||||||||||||||||||||
| 189 | ############# | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 1 | ▶ | sub _OVER_get_array { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_get_array: called CC=2 SCAR=9.9
| |||||||||||||||||||||||||||||
| 192 | 1 | my $this = shift ; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 1 | ▶ | if ( $$this->{TIEONUSE}{a} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | my @array ; tie(@array, $$this->{TIEONUSE}{a} , $$this) ; | |||||||||||||||||||||||||||
| 196 | 0 | $$this->set_array(\@array) ; | |||||||||||||||||||||||||||
| 197 | 0 | $$this->{TIEONUSE}{a} = undef ; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 1 | return( $$this->array ) ; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | ############ | ||||||||||||||||||||||||||||
| 204 | # GET_HASH # | ||||||||||||||||||||||||||||
| 205 | ############ | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 1 | ▶ | sub _OVER_get_hash { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_get_hash: called CC=2 SCAR=9.9
| |||||||||||||||||||||||||||||
| 208 | 1 | my $this = shift ; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 1 | ▶ | if ( $$this->{TIEONUSE}{h} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | my %hash = 1 ; tie(%hash, $$this->{TIEONUSE}{h} ,$$this) ; | |||||||||||||||||||||||||||
| 212 | 0 | $$this->set_hash(\%hash) ; | |||||||||||||||||||||||||||
| 213 | 0 | $$this->{TIEONUSE}{h} = undef ; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 1 | return( $$this->hash ) ; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | ################## | ||||||||||||||||||||||||||||
| 220 | # _OVER_GET_CODE # | ||||||||||||||||||||||||||||
| 221 | ################## | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 1 | ▶ | sub _OVER_get_code { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_get_code: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 224 | 1 | my $this = shift ; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 1 | ▶ | if ( !$$this->{SUBCODE} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 1 | $$this->{SUBCODE}{self} = undef ; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 1 | my $sub = $$this->code ; | |||||||||||||||||||||||||||
| 230 | 1 | my $ref = $$this->{SUBCODE} ; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 1 | ▶ | $$this->{SUBCODE}{sub} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.5
| |||||||||||||||||||||||||||||
| 233 | 1 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | my @ret = &$sub( $$ref{self} , @_) ; | |||||||||||||||||||||||||||
| 235 | 0 | $$ref{self} = undef ; | |||||||||||||||||||||||||||
| 236 | 0 | return( @ret ) ; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | else { | ||||||||||||||||||||||||||||
| 239 | 1 | my $ret = &$sub( $$ref{self} , @_) ; | |||||||||||||||||||||||||||
| 240 | 1 | $$ref{self} = undef ; | |||||||||||||||||||||||||||
| 241 | 1 | return( $ret ) ; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | 1 | }; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 1 | $$this->{SUBCODE}{self} = $this ; | |||||||||||||||||||||||||||
| 248 | 1 | return( $$this->{SUBCODE}{sub} ) ; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | ################## | ||||||||||||||||||||||||||||
| 252 | # _OVER_GET_GLOB # | ||||||||||||||||||||||||||||
| 253 | ################## | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 1 | ▶ | sub _OVER_get_glob { | ||||||||||||||||||||||||||
|
Subroutine
_OVER_get_glob: called CC=2 SCAR=8.4
| |||||||||||||||||||||||||||||
| 256 | 1 | my $this = shift ; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 1 | ▶ | if ( $$this->{TIEONUSE}{g} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | tie($$this->glob , $$this->{TIEONUSE}{g} , $$this) ; | |||||||||||||||||||||||||||
| 260 | 0 | $$this->{TIEONUSE}{g} = undef ; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 1 | return( $$this->glob ) ; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | ########### | ||||||||||||||||||||||||||||
| 267 | # DESTROY # | ||||||||||||||||||||||||||||
| 268 | ########### | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 17 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 271 | 17 | my $this = shift ; | |||||||||||||||||||||||||||
| 272 | 17 | $$this->clean ; | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | ############################ | ||||||||||||||||||||||||||||
| 276 | # OBJECT::MULTITYPE::SAVER # | ||||||||||||||||||||||||||||
| 277 | ############################ | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | package Object::MultiType::Saver ; | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 1 | ▶ | use strict qw(vars) ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 1 | ▶ | sub is_saver { 1 ;} | ||||||||||||||||||||||||||
|
Subroutine
is_saver: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 286 | 17 | my $class = shift ; | |||||||||||||||||||||||||||
| 287 | 17 | my ( $nodefault ) = @_ ; | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 17 | my $this ; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ($nodefault) { $this = {} ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||
| 293 | 17 | local(*NULL); | |||||||||||||||||||||||||||
| 294 | $this = { | ||||||||||||||||||||||||||||
| 295 | s => \'' , | ||||||||||||||||||||||||||||
| 296 | a => [] , | ||||||||||||||||||||||||||||
| 297 | h => {} , | ||||||||||||||||||||||||||||
| 298 | 0 | ▶ | c => sub{} , | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 299 | 17 | g => \*NULL , | |||||||||||||||||||||||||||
| 300 | } ; | ||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 17 | bless($this,$class); | |||||||||||||||||||||||||||
| 304 | 17 | return( $this ) ; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 5 | ▶ | sub bool { return( $_[0]->{b} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
bool: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 308 | 16 | ▶ | sub scalar { return( $_[0]->{s} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
scalar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 309 | 1 | ▶ | sub array { return( $_[0]->{a} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 310 | 1 | ▶ | sub hash { return( $_[0]->{h} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 311 | 1 | ▶ | sub code { return( $_[0]->{c} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 312 | 1 | ▶ | sub glob { return( $_[0]->{g} ) ;} | ||||||||||||||||||||||||||
|
Subroutine
glob: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 38 | ▶ | sub set_bool { $_[0]->{b} = $_[1] ;} | ||||||||||||||||||||||||||
|
Subroutine
set_bool: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 45 | ▶ | sub set_scalar { | ||||||||||||||||||||||||||
|
Subroutine
set_scalar: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 317 | 45 | ▶ | if ($#_ == 0) { $_[0]->{s} = undef ;} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 318 | 3 | ▶ | elsif (ref($_[1]) ne 'SCALAR' && ref($_[1]) ne 'REF') { $_[0]->{s} = \$_[1] ;} | ||||||||||||||||||||||||||
|
Condition100%3/3
ref $_[1] ne "SCALAR" and ref $_[1] ne "REF"
MC/DC100%2/2
ref $_[1] ne "SCALAR" and ref $_[1] ne "REF"
ref $_[1] ne "SCALAR"
ref $_[1] ne "REF"
Truth table100%3/3
A and B
A= ref $_[1] ne "SCALAR"B= ref $_[1] ne "REF"
| |||||||||||||||||||||||||||||
| 319 | 8 | else { $_[0]->{s} = $_[1] ;} | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 35 | ▶ | sub set_array { $_[0]->{a} = $_[1] ;} | ||||||||||||||||||||||||||
|
Subroutine
set_array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 323 | 35 | ▶ | sub set_hash { $_[0]->{h} = $_[1] ;} | ||||||||||||||||||||||||||
|
Subroutine
set_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 324 | 35 | ▶ | sub set_code { $_[0]->{c} = $_[1] ;} | ||||||||||||||||||||||||||
|
Subroutine
set_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 325 | 35 | ▶ | sub set_glob { $_[0]->{g} = $_[1] ;} | ||||||||||||||||||||||||||
|
Subroutine
set_glob: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 34 | ▶ | sub clean { | ||||||||||||||||||||||||||
|
Subroutine
clean: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 328 | 34 | my $this = shift ; | |||||||||||||||||||||||||||
| 329 | 34 | $this->set_bool() ; | |||||||||||||||||||||||||||
| 330 | 34 | $this->set_scalar() ; | |||||||||||||||||||||||||||
| 331 | 34 | $this->set_array() ; | |||||||||||||||||||||||||||
| 332 | 34 | $this->set_hash() ; | |||||||||||||||||||||||||||
| 333 | 34 | $this->set_code() ; | |||||||||||||||||||||||||||
| 334 | 34 | $this->set_glob() ; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 17 | ▶ | sub DESTROY { &clean ;} | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | ####### | ||||||||||||||||||||||||||||
| 340 | # END # | ||||||||||||||||||||||||||||
| 341 | ####### | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 1 | 1; | |||||||||||||||||||||||||||
| 344 | __END__ | ||||||||||||||||||||||||||||