| 1 | package Class::Root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use 5.006000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Class::Root - framework for writing perl OO modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | Version 0.02 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | our $VERSION = '0.02'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | my $ROOT_CLASS = __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | package declare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | goto &Class::Root::LOCAL::declare; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 12 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | my $self = { @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $INC{"declare.pm"} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | package Class::Root::LOCAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 12 | ▶ | use English; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $Carp::Verbose = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | ▶ | use Filter::Util::Call; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | my @flags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | *::CT_CHECKS = sub(){1} unless defined(&::CT_CHECKS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 12 | ▶ | *::RT_CHECKS = sub(){1} unless defined(&::RT_CHECKS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | ▶ | *::LOCAL_SUBS = sub(){1} unless defined(&::LOCAL_SUBS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | @flags = qw( AF MF CF PRIV PROT RO OVER VIRT SETOPTS ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | foreach (@flags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 108 | my $n = $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 108 | ▶ | *$_ = sub(){ 1<<$n }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub flags2hr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flags2hr: not called CC=3 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $flags = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $hr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | foreach (@flags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $hr->{$_} = $flags & &$_ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return $hr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # here we save class attributes for all classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | my $class_data = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # hash of all subs ( methods and attributes ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | my $subs = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # class schema hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | my $schema = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | ▶ | sub init_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_schema: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | $schema->{$class} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | NUMBER_OF_PARENTS => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | HAVE_CLASS_ATTR_VALUES => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | HAVE_INSTANCE_ATTR_VALUES => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | INSTANCE_ATTR_VALUES => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | CLASS_ATTR_VALUES => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | PROT_EXPORT => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | LOCAL_SUBS => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | SUBS => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | CT_OPTS => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | VERBOSE_SOURCE_CODE_CHANGES => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | DEFINE_LOCAL_SUBS => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | VERBOSE => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | init_schema($ROOT_CLASS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | my @export_local = qw( declare attribute class_attribute attributes method class_method overwrite override private protected virtual readonly setopts setoptions setval setvalue ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 24 | ▶ | sub prefix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 24 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 24 | $str =~ s/:/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 24 | return $str."__"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | my $ROOT_CLASS_PREFIX = prefix($ROOT_CLASS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | my %s2f = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | '_' => PRIV, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ':' => CF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | '?' => RO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | '*' => PROT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | '!' => OVER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | '~' => VIRT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub method_name_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method_name_ok: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | /^[_:?*!~]*[a-zA-Z]\w*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | ▶ | sub sflags2flags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sflags2flags: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 12 | my $sflags = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 12 | my $flags = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 12 | foreach ( unpack('A1' x length($sflags), $sflags) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $flags |= $s2f{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 12 | return $flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub c2cl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
c2cl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $class."::LOCAL"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 12 | ▶ | sub cl2c { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cl2c: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 12 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 12 | $str =~ s/::LOCAL$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 12 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub vmesg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vmesg: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $mesg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $verbose = $schema->{$class}->{CT_OPTS}->{VERBOSE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | print STDERR $mesg if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | ▶ | sub declare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declare: called CC=26 SCAR=49.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 | my $caller_local = caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 12 | my $caller = cl2c($caller_local); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 12 | my @args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | #print Dumper( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 12 | foreach ( @_ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 24 | ▶ | if ( /^([+-])(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | my $v = ( $1 eq '+' ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $k = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $old_v = $schema->{$caller}->{CT_OPTS}->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $schema->{$caller}->{CT_OPTS}->{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( $k eq 'DEFINE_LOCAL_SUBS' and $v and !$old_v ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$k eq "DEFINE_LOCAL_SUBS" and $v and not $old_v
$k eq "DEFINE_LOCAL_SUBS" and $v
MC/DC0%0/3
$k eq "DEFINE_LOCAL_SUBS" and $v and not $old_v
$k eq "DEFINE_LOCAL_SUBS"
$v
not $old_v
Truth table0%0/4
A and B and not(C)
A= $k eq "DEFINE_LOCAL_SUBS"B= $vC= not $old_v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | define_local_subs($caller_local, $caller, $caller); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 24 | push @args, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 12 | @_ = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 12 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 12 | ▶ | while ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 12 | my $name_str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 12 | my $hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 12 | ▶ | unless ( defined $hr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $hr = "declare"->new( FLAGS => AF, OPTS => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 12 | ▶ | unless ( ref($hr) eq "declare" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $hr = "declare"->new( FLAGS => AF, OPTS => { value => $hr } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 12 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 12 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | ▶ | croak "declare: syntax error - wrong argument in position $i\n" unless ref($hr) eq "declare"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 12 | ▶ | unless ( $name_str =~ /([:_?*!~]*)([a-zA-Z]\w*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | croak "Wrong format for method name -->$name_str<--\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | my $flags = sflags2flags($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 12 | my $pub_name = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 12 | $flags |= $hr->{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | #attribute flag is set by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 12 | ▶ | $flags |= AF unless $flags & MF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 12 | my $priv_name = prefix($caller) . $pub_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | my $opts = $hr->{OPTS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 12 | my $name = $pub_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 12 | my $key = $pub_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 12 | my $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | my $tied_sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 12 | ▶ | if ( $flags & AF ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $oro = $opts->{readonly}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ( defined $oro ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $flags |= RO if $oro; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | $flags = $flags | RO ^ RO unless $oro; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # remove PRIV flag for RO attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | my $ro_flags = $flags | PRIV ^ PRIV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # remove PROT flag for RO attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 12 | $ro_flags = $ro_flags | PROT ^ PROT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # force PRIV flag fo priv part of RO and PROT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 12 | ▶ | $flags |= PRIV if $flags & (RO|PROT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 12 | ▶ | if ( $flags & PRIV ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $name = $priv_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $key = $priv_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # set options for existing method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | ▶ | if ( $flags & SETOPTS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | setopts_only( CLASS => $caller, NAME => $name, OPTS => $opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 12 | ▶ | if ( exists $opts->{value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $key = $flags & CF ? "CLASS" : "INSTANCE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $schema->{$caller}->{$key."_ATTR_VALUES"}->{$name} = $opts->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $schema->{$caller}->{"HAVE_".$key."_ATTR_VALUES"} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 12 | ▶ | $sub = $hr->{SUB} if $flags & MF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | ▶ | if ( $flags & AF ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ( $sub, $tied_sub ) = create_accessor( NAME => $name, KEY => $key, FLAGS => $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 12 | make_method( CLASS => $caller, NAME => $name, FLAGS => $flags, SUB => $sub, TIED_SUB => $tied_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | if ( ::RT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ( exists $opts->{check_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $schema->{$caller}->{SUBS}->{$name}->{TIED} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $schema->{$caller}->{SUBS}->{$name}->{CHECK_VALUE} = $opts->{check_value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( $flags & RO ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ( my $ro_sub ) = create_accessor( NAME => $pub_name, KEY => $priv_name, FLAGS => $ro_flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | make_method( CLASS => $caller, NAME => $pub_name, FLAGS => $ro_flags, SUB => $ro_sub, TIED_SUB => $tied_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub setopts_only { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setopts_only: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my %args = ( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $class = $args{CLASS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $name = $args{NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $opts = $args{OPTS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $mhr = $schema->{$class}->{SUBS}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | croak "Can't set options for undefined attribute $name" unless defined $mhr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | croak "Can't set options for readonly attribute $name" if $mhr->{FLAGS} & RO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | croak "Can't set options for method" if $mhr->{FLAGS} & MF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $value = $opts->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my $key = $mhr->{FLAGS} & CF ? "CLASS" : "INSTANCE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $schema->{$class}->{$key."_ATTR_VALUES"}->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $schema->{$class}->{"HAVE_".$key."_ATTR_VALUES"} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | if ( ::RT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if ( defined $opts->{check_value} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $schema->{$class}->{SUBS}->{$name}->{TIED} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $schema->{$class}->{SUBS}->{$name}->{CHECK_VALUE} = $opts->{check_value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 144 | ▶ | sub gen_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_sub: called CC=2 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 144 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 144 | my $flag = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 144 | ▶ | my $setopts = ( $name =~ /^setopt(ion)?s$/ or $name =~ /^setval(ue)?$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$name =~ /^setopt(ion)?s$/ || $name =~ /^setval(ue)?$/
MC/DC100%2/2
$name =~ /^setopt(ion)?s$/ || $name =~ /^setval(ue)?$/
$name =~ /^setopt(ion)?s$/
$name =~ /^setval(ue)?$/
Truth table100%3/3
A || B
A= $name =~ /^setopt(ion)?s$/B= $name =~ /^setval(ue)?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | #print "$name: ", Dumper(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $hr = "declare"->new( FLAGS => 0, OPTS => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $arg0 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ( $setopts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $val = $arg0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $val_pos = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( method_name_ok($arg0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | push @ret, $arg0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $hr->{FLAGS} = SETOPTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $val_pos = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | #croak "function \"$name\": couldn't have more then 2 arguments" if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ( $name =~ /^setopt(ion)?s$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | croak "function \"$name\": argument at position $val_pos is not an options hr" unless ref($val) eq "HASH"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my %known_options = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | value => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | check_value => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | foreach my $key ( keys %$val ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | croak "function \"$name\": unknown option $key" unless exists $known_options{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $hr->{OPTS} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $hr->{OPTS} = { value => $val }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if ( ref($arg0) eq "declare" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $hr = $arg0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } elsif ( ref($arg0) eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | croak "function \"$name\": arg0 could be a method name or other declare subfunction\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | croak "function \"$name\": wrong format of method name arg0\n" unless method_name_ok($arg0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | push @ret, $arg0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $arg1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | #croak "function \"$name\": couldn't have more then 2 arguments" if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( ref($arg1) eq "declare" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $hr = $arg1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $hr->{OPTS} = { value => $arg1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | unless ( $setopts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $flags = $hr->{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $flags |= $flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $flags = $flags | SETOPTS ^ SETOPTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $hr->{FLAGS} = $flags;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | push @ret, $hr, @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 144 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 144 | *$name = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | my %declare_subs = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | attribute => AF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | class_attribute => CF|AF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | protected => PROT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | private => PRIV, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | virtual => VIRT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | overwrite => OVER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | override => OVER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | readonly => RO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | setopts => SETOPTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | setoptions => SETOPTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | setval => SETOPTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | setvalue => SETOPTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | while ( my ($k, $v ) = each %declare_subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | gen_sub($k, $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub method(;&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | #print "method: ", Dumper(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | return "declare"->new( FLAGS => MF, SUB => $sub, OPTS => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 12 | ▶ | sub class_method(;&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_method: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | #print "class_method: ", Dumper(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 12 | my $sub = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 12 | return "declare"->new( FLAGS => CF|MF, SUB => $sub, OPTS => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | foreach ( @_ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | foreach my $line ( split /\n/, $_ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $line =~ s/(^|\s)#.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | foreach my $str ( split /\s+/, $line ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | next unless $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless ( $str =~ /^([_:?*]*)([a-zA-Z]\w*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | croak "Wrong attribute format for -->$str<--\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $flags_str = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $name = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $flags = AF | sflags2flags($flags_str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | push @ret, $name, "declare"->new( FLAGS => $flags, OPTS => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | *update_schema = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $o = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $n = !$o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my $hr = { @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $name = delete $hr->{NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my $class = delete $hr->{CLASS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $cschema = $schema->{$class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $csubs = $cschema->{SUBS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | unless ( exists $csubs->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $csubs->{$name} = $hr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $hr2 = $csubs->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | my $ohr = $o ? $hr : $hr2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | my $nhr = $o ? $hr2 : $hr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $oflags = $ohr->{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $oparent = $ohr->{PARENT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $osub = $ohr->{SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $nflags = $nhr->{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $nparent = $nhr->{PARENT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $nsub = $nhr->{SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my $ocf = $oflags & CF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my $ncf = $nflags & CF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my $overstr = $class eq $nparent ? " (defined in class \"$class\")" : " (defined in base class \"$nparent\")"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | if ( $ncf != $ocf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | my $type_str1 = $ncf ? "instance method" : "class method"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my $type_str2 = $ocf ? "instance method" : "class method"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | return "$type_str1 \"$name\"$overstr also defined as $type_str2 \"$name\" in base class \"$oparent\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # same method in 2 base classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ( ($class ne $nparent) and ($oparent ne $nparent) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class ne $nparent and $oparent ne $nparent
MC/DC0%0/2
$class ne $nparent and $oparent ne $nparent
$class ne $nparent
$oparent ne $nparent
Truth table0%0/3
A and B
A= $class ne $nparentB= $oparent ne $nparent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | unless ( $name =~ /^(init|class_init|DESTROY)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return "Method \"$name\"$overstr also defined in base class \"$oparent\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # overwriting of nonvirtual method from base class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if ( ($class eq $nparent) and !($nflags & OVER) and !($oflags & VIRT) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$class eq $nparent and not $nflags & &OVER() and not $oflags & &VIRT()
$class eq $nparent and not $nflags & &OVER()
MC/DC0%0/3
$class eq $nparent and not $nflags & &OVER() and not $oflags & &VIRT()
$class eq $nparent
not $nflags & &OVER()
not $oflags & &VIRT()
Truth table0%0/4
A and not(B) and not(C)
A= $class eq $nparentB= not $nflags & &OVER()C= not $oflags & &VIRT()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return "Method \"$name\"$overstr also defined in base class \"$oparent\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if ( $nflags & AF and $nflags & OVER ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nflags & &AF() and $nflags & &OVER()
MC/DC0%0/2
$nflags & &AF() and $nflags & &OVER()
$nflags & &AF()
$nflags & &OVER()
Truth table0%0/3
A and B
A= $nflags & &AF()B= $nflags & &OVER()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | return "attributes couldn't be overwritten"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | return "" if ( $osub eq $nsub ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | $csubs->{$name} = $nhr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # files for which we already have a filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | my %filter_line = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # already seen classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | my %import_done = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | my $base_init_done_key = "_BASE_INIT_DONE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | my $base_destroy_done_key = "_BASE_DESTROY_DONE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | my $attr_init_done_key = "_ATTR_INIT_DONE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | declare import => class_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | my $parent = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | my $isa_arg = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | if ( @_ and $_[0] eq "isa" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | $isa_arg = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | my ( $caller, $caller_file, $caller_line ) = caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | my $caller_local = c2cl($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | unless ( exists $schema->{$caller} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | init_schema($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | my $cschema = $schema->{$caller}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | my $copts = $cschema->{CT_OPTS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | my @args = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | foreach ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | if ( /^([+-])(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | my $v = ( $1 eq '+' ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | $copts->{$2} = $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | push @args, $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | unless ( $isa_arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | if ( $copts->{DEFINE_LOCAL_SUBS} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | define_local_subs($caller, $parent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | if ( my $local_import = $caller_local->can("import") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | local @_ = ( $parent, @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | goto $local_import; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | my $filter_prefix = prefix($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | $filter_line{$caller_file} = $caller_line+1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | filter_add( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | my $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | if ( ( $status = filter_read() ) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | my $line = $filter_line{$caller_file}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | if ( /^\s*package\s+([\w:]+)\s*;/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | filter_del() unless ( $1 eq $caller_local ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # $class_foo->_PrivMethod will be translated in $class_foo->Class__Foo__PrivMethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | my $sav_line = "$_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | my $changed = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | if ( $filter_prefix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | s/((-\>\s*)_(?=[A-Za-z]))/$2$filter_prefix/g and $changed=1 ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # $obj->__Some_Method will be translated in $obj->_Some_Method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | s/(-\>\s*_)_/$1/g and $changed=1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | my $verbose_sf = $copts->{VERBOSE_SOURCE_CODE_FILTER}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | my $verbose = $copts->{VERBOSE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | if ( $changed and ($verbose or $verbose_sf) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | print STDERR "Changing source file \"$caller_file\", line $line:\nfrom..> ${sav_line}to....> $_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # @ISA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | my $caller_isa = $caller."::ISA"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | vmesg($caller,"push $parent to \@$caller_isa\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | push @$caller_isa, $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | $cschema->{NUMBER_OF_PARENTS}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # this should be done only once for each class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | unless ( $import_done{$caller} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | $import_done{$caller} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | $class_data->{$caller} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | $base_init_done_key => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | $attr_init_done_key => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ( my $inc_key = $caller ) =~ s{::}{/}g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | $inc_key .= '.pm'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | $INC{$inc_key} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # export declare and subfunctions in caller's "LOCAL" package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | foreach my $f ( @export_local ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | my $caller_f = $caller_local."::".$f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | vmesg($caller,"Defining sub $caller_f\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | *$caller_f = *$f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | my $class_initialize = $caller_local."::class_initialize"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | vmesg($caller,"Defining sub \"$class_initialize\"\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | my $generic_class_init_method = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | $class->base_class_init( "CALLER=$caller", @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | my $caller_class_init = $caller."::class_init"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | *$class_initialize = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | unless ( defined(&$caller_class_init) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | if ( @_ or $cschema->{NUMBER_OF_PARENTS} > 1 or $cschema->{HAVE_CLASS_ATTR_VALUES} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | vmesg($caller,"Defining sub \"$caller_class_init\" with generic code\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | *$caller_class_init = $generic_class_init_method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | $caller->class_init( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | my $class_verify = $caller_local."::class_verify"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | vmesg($caller,"Defining sub \"$class_verify\"\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | my $generic_init_method = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | $self->base_init( "CALLER=$caller", @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | my $caller_init = $caller."::init"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | my $generic_destroy_method = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | $self->base_destroy( "CALLER=$caller" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | my $caller_destroy = $caller."::DESTROY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | *$class_verify = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | unless ( defined(&$caller_init) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | if ( $cschema->{NUMBER_OF_PARENTS} > 1 or $cschema->{HAVE_INSTANCE_ATTR_VALUES} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | vmesg($caller,"Defining sub \"$caller_init\" with generic code\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | *$caller_init = $generic_init_method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | unless ( defined(&$caller_destroy) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | if ( $cschema->{NUMBER_OF_PARENTS} > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | vmesg($caller,"Defining sub \"$caller_destroy\" with generic code\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | *$caller_destroy = $generic_destroy_method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | $caller->class_schema_check( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | my $caller_prot_export = $cschema->{PROT_EXPORT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | my $caller_prefix = prefix($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | my $pschema = $schema->{$parent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | my $parent_prot_export = $pschema->{PROT_EXPORT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | my $parent_prefix = prefix($parent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | foreach my $prot_m ( @$parent_prot_export ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | push @$caller_prot_export, $prot_m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | my $caller_prot_m = $caller_prefix.$prot_m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | my $parent_prot_m = $parent_prefix.$prot_m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | my $caller_mname = $caller."::$caller_prot_m"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | my $parent_mname = $parent."::$parent_prot_m"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | vmesg($caller,"Defining sub $caller_mname as alias to $parent_mname\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | my $pmhr = $pschema->{SUBS}->{$parent_prot_m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | my $err = update_schema( 1, CLASS => $caller, NAME => $caller_prot_m, SUB => $pmhr->{SUB}, PARENT => $parent, FLAGS => $pmhr->{FLAGS} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | croak "Schema error for class \"$caller\": $err\n" if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | if ( ::LOCAL_SUBS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | my $pmhr = $pschema->{LOCAL_SUBS}->{$parent_prot_m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $cschema->{LOCAL_SUBS}->{$caller_prot_m}->{SUB} = $pmhr->{SUB}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | $cschema->{LOCAL_SUBS}->{$caller_prot_m}->{FLAGS} = $pmhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | *$caller_mname = *$parent_mname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | while ( my($m, $mhr) = each %{ $pschema->{SUBS} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | my $sub = $mhr->{SUB}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | my $parent = $mhr->{PARENT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | my $flags = $mhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | my $err = update_schema( 1, CLASS => $caller, NAME => $m, SUB => $sub, PARENT => $parent, FLAGS => $flags ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | croak "Schema error: $err\n" if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | if ( ::LOCAL_SUBS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | while ( my($m, $mhr) = each %{ $pschema->{LOCAL_SUBS} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | my $flags = $mhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | next if ( $flags & PRIV or exists $cschema->{LOCAL_SUBS}->{$m} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | $cschema->{LOCAL_SUBS}->{$m}->{SUB} = $mhr->{SUB}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | $cschema->{LOCAL_SUBS}->{$m}->{FLAGS} = $flags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | sub define_local_subs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
define_local_subs: not called CC=14 SCAR=52.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $caller = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $default_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | croak "Can't define local subs with disabled LOCAL_SUBS\n" unless ::LOCAL_SUBS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $clsubs = $schema->{$class}->{LOCAL_SUBS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | while ( my($f, $mhr) = each %$clsubs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my $flags = $mhr->{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $priv = $flags & PRIV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | next if ( $caller ne $class and $priv ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$caller ne $class and $priv
MC/DC0%0/2
$caller ne $class and $priv
$caller ne $class
$priv
Truth table0%0/3
A and B
A= $caller ne $classB= $priv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $sub = $mhr->{SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $prototype = prototype( $sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | if ( defined $prototype and $prototype eq "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $prototype and $prototype eq ""
MC/DC0%0/2
defined $prototype and $prototype eq ""
defined $prototype
$prototype eq ""
Truth table0%0/3
A and B
A= defined $prototypeB= $prototype eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | $f = "_$f" if $priv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | if ( $priv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my $prefix = prefix($caller); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | $f =~ s/^$prefix/_/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | my $caller_f = $caller."::".$f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $lfsub = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $def = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | if ( defined $default_class and $flags & CF ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $default_class and $flags & &CF()
MC/DC0%0/2
defined $default_class and $flags & &CF()
defined $default_class
$flags & &CF()
Truth table0%0/3
A and B
A= defined $default_classB= $flags & &CF()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $ro = $flags & RO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | ▶ | if ($flags & RO and !$priv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$flags & &RO() and not $priv
MC/DC0%0/2
$flags & &RO() and not $priv
$flags & &RO()
not $priv
Truth table0%0/3
A and not(B)
A= $flags & &RO()B= not $priv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | $lfsub = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | local $_ = shift || $default_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $default_class
MC/DC0%0/2
shift() || $default_class
shift()
$default_class
Truth table0%0/3
A || B
A= shift()B= $default_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | &$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | $lfsub = sub():lvalue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | local $_ = shift || $default_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $default_class
MC/DC0%0/2
shift() || $default_class
shift()
$default_class
Truth table0%0/3
A || B
A= shift()B= $default_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | &$sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $def = "D:$default_class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | if ( defined &$caller_f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | croak "Function \"$f\" already defined in package \"$caller\"\n" unless \&$caller_f eq $lfsub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | if (::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | vmesg($caller,"Defining local sub $caller_f $def\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | *$caller_f = $lfsub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 12 | ▶ | sub make_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_method: called CC=27 SCAR=57.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 12 | my %args = ( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 12 | my $class = $args{CLASS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 12 | my $name = $args{NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 12 | my $flags = $args{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 12 | my $sub = $args{SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 12 | my $tied_sub = $args{TIED_SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 12 | my $virt = $flags & VIRT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 12 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 12 | ▶ | unless ( $name =~ /^[a-zA-Z]\w*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | croak "Wrong method name: -->$name<--. Supported method names should match ".'/^[a-zA-Z]\w*$/'."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 12 | ▶ | if ( !$virt and !defined( $sub ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$virt or defined $sub
MC/DC0%0/2
$virt or defined $sub
$virt
defined $sub
Truth table33%1/3
A or B
A= $virtB= defined $sub
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | croak "class $class: implementation subroutine should be defined for non-virtual method \"$name\"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 12 | ▶ | if ( $virt and defined( $sub ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$virt and defined $sub
MC/DC0%0/2
$virt and defined $sub
$virt
defined $sub
Truth table33%1/3
A and B
A= $virtB= defined $sub
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | croak "class $class: no implementation subroutine should be defined for virtual method \"$name\"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 12 | my $over = $flags & OVER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 12 | my $cschema = $schema->{$class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 12 | my $csubs = $cschema->{SUBS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 12 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 12 | ▶ | if ( !$over and $code = $class->can($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $over and $code = $class->can($name)
MC/DC0%0/2
not $over and $code = $class->can($name)
not $over
$code = $class->can($name)
Truth table33%1/3
not(A) and B
A= not $overB= $code = $class->can($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 12 | ▶ | unless( $csubs->{$name}->{FLAGS} & VIRT ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 12 | ▶ | my $bc = defined $csubs->{$name} ? $csubs->{$name}->{PARENT} : "???"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 12 | my $mname = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 12 | ▶ | if ( $csubs->{$name}->{FLAGS} & PRIV ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | my $prefix = prefix($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | $mname =~ s/^$prefix/_/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 12 | croak "class \"$class\": method \"$mname\" already defined in base class \"$bc\"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | if ( $over and !$class->can($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$over and not $class->can($name)
MC/DC0%0/2
$over and not $class->can($name)
$over
not $class->can($name)
Truth table0%0/3
A and not(B)
A= $overB= not $class->can($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | croak "class \"$class\": method $name not defined, can not overwrite\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | if ( $virt ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | $sub = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | my ($package, $filename, $line ) = caller(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | croak "call of virtual method \"$name\" defined in class \"$class\" from package \"$package\", file \"$filename\", line \"$line\"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | if ( $flags & PROT ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | my $prefix = prefix($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $name =~ /^$prefix(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | push @{ $schema->{$class}->{PROT_EXPORT} }, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my $method_name = $class."::".$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | ▶ | unless ( exists $subs->{$sub} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $subs->{$sub} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | NAME => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | SUB => $sub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | TIED_SUB => $tied_sub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | my $err = update_schema( 0, CLASS => $class, PARENT => $class, NAME => $name, SUB => $sub, FLAGS => $flags ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | croak "Schema error in class \"$class\": $err\n" if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | if ( ::LOCAL_SUBS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my $cschema = $schema->{$class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | $cschema->{LOCAL_SUBS}->{$name}->{SUB} = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | $cschema->{LOCAL_SUBS}->{$name}->{FLAGS} = $flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | vmesg($class,"Defining sub $method_name\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | if ( $name eq "class_init" or $name eq "init" or $name eq "DESTROY" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$name eq "class_init" or $name eq "init" or $name eq "DESTROY"
$name eq "class_init" or $name eq "init"
MC/DC0%0/3
$name eq "class_init" or $name eq "init" or $name eq "DESTROY"
$name eq "class_init"
$name eq "init"
$name eq "DESTROY"
Truth table0%0/4
A or B or C
A= $name eq "class_init"B= $name eq "init"C= $name eq "DESTROY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 12 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | *$method_name = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | *$method_name = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | if ( ::LOCAL_SUBS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | if ( $schema->{$class}->{CT_OPTS}->{DEFINE_LOCAL_SUBS} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $local_func_name = $class."::LOCAL::".$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | my $cf = $flags & CF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | my $ro = $flags & RO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $priv = $flags & PRIV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | if ( $priv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $prefix = prefix($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | $name =~ /^$prefix(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | $local_func_name = $class."::LOCAL::_$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $prototype = prototype( $sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | if ( defined $prototype and $prototype eq "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $prototype and $prototype eq ""
MC/DC0%0/2
defined $prototype and $prototype eq ""
defined $prototype
$prototype eq ""
Truth table0%0/3
A and B
A= defined $prototypeB= $prototype eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my $lfsub = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | my $def = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | if ( $cf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | $lfsub = ($ro and !$priv) ? sub{local $_=shift||$class; &$sub} : sub():lvalue{local $_=shift||$class; &$sub }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
Condition0%0/9
$ro and not $priv
shift() || $class
shift() || $class
MC/DC0%0/2
$ro and not $priv
$ro
not $priv
MC/DC0%0/2
shift() || $class
shift()
$class
MC/DC0%0/2
shift() || $class
shift()
$class
Truth table0%0/3
A and not(B)
A= $roB= not $priv
Truth table0%0/3
A || B
A= shift()B= $class
Truth table0%0/3
A || B
A= shift()B= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | $def = "D:$class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | if ( ::CT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | vmesg($class,"Defining local sub $local_func_name\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | *$local_func_name = $lfsub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | my $ties = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | if ( ::RT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | *Class::Root::tiescalar::TIESCALAR = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | my $scalar = undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | return (bless \$scalar, $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | *Class::Root::tiescalar::FETCH = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | my $hr = $ties->{$self}->{hr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | my $key = $ties->{$self}->{key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | return $hr->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | *Class::Root::tiescalar::STORE = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | my $val = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | my $hr = $ties->{$self}->{hr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | my $key = $ties->{$self}->{key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | my $class = $ties->{$self}->{class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | my $name = $ties->{$self}->{subname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | my $chk_sub = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | my $sub = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | local $_ = $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | my $err = &$sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | croak "check_value error for attr ", $name, " : $err" if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | my $rec_check; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | $rec_check = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | my $sub = $schema->{$class}->{SUBS}->{$name}->{CHECK_VALUE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | &$chk_sub($sub) if defined $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | my @class_isa; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | @class_isa = @{$class."::ISA"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | foreach my $parent ( @class_isa ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | $rec_check->($parent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | $rec_check->($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | $hr->{$key} = $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | my $accessors = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | sub create_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_accessor: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | my $name = $args{NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | my $key = $args{KEY}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | my $flags = $args{FLAGS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $cf = $flags & CF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | my $ro = $flags & RO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | my $priv = $flags & PRIV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | my $akey = "$name/$key/$cf/$ro"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | my $sub = $accessors->{$akey}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | my $tied_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | if ( $ro and !$priv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ro and not $priv
MC/DC0%0/2
$ro and not $priv
$ro
not $priv
Truth table0%0/3
A and not(B)
A= $roB= not $priv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | $sub or $sub = sub () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | my $self = shift || $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $_
MC/DC0%0/2
shift() || $_
shift()
$_
Truth table0%0/3
A || B
A= shift()B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | ▶ | my $err = $cf ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | "class \"$class\": couldn't set read only class attribute \"$name\"\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | "instance of \"$class\": couldn't set read only attribute \"$name\"\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | croak $err if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | my $data = $cf ? $class_data->{$class} : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | return $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | ▶ | $sub or $sub = sub () : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | my $self = shift || $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $_
MC/DC0%0/2
shift() || $_
shift()
$_
Truth table0%0/3
A || B
A= shift()B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | if ( ::RT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | if ( $schema->{$class}->{SUBS}->{$name}->{TIED} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | unshift @_, $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | goto $subs->{$sub}->{TIED_SUB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | ▶ | my $data = $cf ? $class_data->{$class} : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | $data->{$key} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | if ( ::RT_CHECKS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | my $tref = tie my $tie, "Class::Root::tiescalar"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $ties->{$tref} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | subname => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | ▶ | $tied_sub = sub () : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | my $self = shift || $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $_
MC/DC0%0/2
shift() || $_
shift()
$_
Truth table0%0/3
A || B
A= shift()B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | $ties->{$tref}->{class} = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | $ties->{$tref}->{hr} = $cf ? $class_data->{$class} : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | $tie = shift | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | $tie; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | $accessors->{$akey} = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | return( $sub, $tied_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | declare new => class_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | my $proto = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | my $self = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | $self->{$attr_init_done_key} = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | $self->{$base_init_done_key} = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | bless($self, $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | if ( ::RT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | my $key = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | foreach ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | $key ^= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | if ( $key and /^_/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | croak "constructor new: couldn't set private attribute \"$_\"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | $self->init( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | my $root_init = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | my $class = ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | my %args = ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | while ( my($k,$v) = each %args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | my $method = $k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | unless ( $self->{$attr_init_done_key}->{$method} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | $self->{$attr_init_done_key}->{$method} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | if ( ::RT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | eval { $self->$method($v) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | croak "Error calling method \"$method\" for instance of class \"$class\": $EVAL_ERROR\n" if $EVAL_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | $self->$method($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | declare init => method { goto $root_init }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | declare base_init => method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | my $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | if ( @_ and $_[0] =~ /^CALLER=(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | $caller = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | unless ( defined $caller ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | $caller = caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | $caller =~ s/::LOCAL$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | $self->{$base_init_done_key}->{$caller} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | my %attr_values = %{ $schema->{$caller}->{INSTANCE_ATTR_VALUES} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | my @args = ( %attr_values ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | my $key = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | my $prefix = prefix($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | foreach ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | my $attr = $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | $key ^= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | $attr =~ s/^_/$prefix/ if $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | push @args, $attr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | my @caller_isa; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | @caller_isa = @{ $caller."::ISA" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | my $not_seen_parents = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | for my $parent ( @caller_isa ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | next if $self->{$base_init_done_key}->{$parent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | if ( my $code = $parent->can("init") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | $not_seen_parents++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | $self->$code( @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | unless ( $not_seen_parents ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | $self->$root_init(@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | declare base_destroy => method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | my $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | if ( @_ and $_[0] =~ /^CALLER=(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | $caller = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | unless ( defined $caller ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | $caller = caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | $caller =~ s/::LOCAL$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | $self->{$base_destroy_done_key}->{$caller} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | my @caller_isa; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | @caller_isa = @{ $caller."::ISA" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | for my $parent ( @caller_isa ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | next if $self->{$base_destroy_done_key}->{$parent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | if ( my $code = $parent->can("DESTROY") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | $self->$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | my $root_class_init = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | my $cdata = $class_data->{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | my %args = ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | while ( my($k,$v) = each %args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | my $method = $k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | unless ( $cdata->{$attr_init_done_key}->{$method} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | $cdata->{$attr_init_done_key}->{$method} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | if ( ::RT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | eval { $class->$method($v) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | croak "Error calling method \"$method\" for \"$class\": $EVAL_ERROR\n" if $EVAL_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | $class->$method($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | declare class_init => class_method { goto $root_class_init }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | declare base_class_init => class_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | my $cdata = $class_data->{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | my $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | if ( @_ and $_[0] =~ /^CALLER=(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | $caller = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | unless ( defined $caller ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | $caller = caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | $caller =~ s/::LOCAL$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | $cdata->{$base_init_done_key}->{$caller} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | my %attr_values = %{ $schema->{$caller}->{CLASS_ATTR_VALUES} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | my @args = ( %attr_values ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | my $key = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | my $prefix = prefix($caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | foreach ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | my $attr = $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | $key ^= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | $attr =~ s/^_/$prefix/ if $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | push @args, $attr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | my @caller_isa; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 12 | ▶ | { no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | @caller_isa = @{ $caller."::ISA" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | my $not_seen_parents = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | for my $parent ( @caller_isa ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | next if $cdata->{$base_init_done_key}->{$parent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | if ( my $code = $parent->can("class_init") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | $not_seen_parents++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | $class->$code( @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | unless ( $not_seen_parents ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | $class->$root_class_init(@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | declare class_schema_check => class_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | return 1 unless ::CT_CHECKS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | my $err = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | while( my($name, $mhr) = each %{ $schema->{$class}->{SUBS} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | #print $name, Dumper($mhr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | my $flags = $mhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | my $parent = $mhr->{PARENT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | if ( $flags & VIRT and $parent ne $class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | $err .= "Virtual method \"$name\" defined in class \"$parent\" not implemented in derived class \"$class\"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | if ( $err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | croak $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | if ( ::CT_CHECKS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | declare class_schema => class_method sub(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | my $proto = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | my $local_caller = caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | my $caller = cl2c($local_caller); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | $class = $caller unless defined $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | my $cschema = $schema->{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | my $str = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | $str .= "class \"$class\" schema:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | my $csubs = $cschema->{SUBS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | my $class_attributes = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | my $attributes = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | my $class_methods = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | my $methods = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | foreach my $m ( sort keys %$csubs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | my $mhr = $csubs->{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | my $flags = $mhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | my $parent = $mhr->{PARENT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | my $priv = $flags & PRIV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | my $prot = $flags & PROT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | next if ( $priv and !$prot and $parent ne $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | my $mflags = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | if ( $priv and !$prot ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | $mflags = "priv"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | my $prefix = prefix($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | $m =~ s/^$prefix/_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | if ( $prot ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | $mflags = "prot"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | my $prefix = prefix($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | next unless ( $m =~ /^$prefix/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | $m =~ s/^$prefix/_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | if ( $flags & VIRT ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | $mflags = "virt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | if ( $flags & RO and !$priv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | $mflags = "ro"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | my $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | $r = \$attributes if $flags & AF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | $r = \$class_attributes if ( $flags & CF and $flags & AF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | $r = \$methods if $flags & MF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | $r = \$class_methods if ( $flags & CF and $flags & MF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | $$r .= sprintf "%4s%-20s%-10s%s\n", "", $m, $mflags, $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | $str .= " class attributes:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | $str .= $class_attributes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | $str .= " attributes:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | $str .= $attributes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | $str .= " class methods:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | $str .= $class_methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | $str .= " methods:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | $str .= $methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | return $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | my $dump = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | my $proto = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | my $o_dump = ref($proto) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | my $str = $o_dump ? "instance \"$proto\"" : "class \"$class\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | $str .= " dump:\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | my $self = $o_dump ? $proto : $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | my $hr = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | my $cschema = $schema->{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | my $csubs = $cschema->{SUBS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | foreach my $m ( keys %$csubs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | my $mhr = $csubs->{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | my $flags = $mhr->{FLAGS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | my $parent = $mhr->{PARENT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | my $priv = $flags & PRIV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | my $prot = $flags & PROT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | next unless ( $flags & AF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | next if ( $o_dump and $flags & CF ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | next if ( !$o_dump and !($flags & CF) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | next if ( $priv|$prot and $parent ne $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | my $nm = $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | if ( $priv|$prot ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | my $prefix = prefix($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | $nm =~ s/^$prefix/_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 12 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | $hr->{$nm} = $self->$m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | local $Data::Dumper::Indent = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | local $Data::Dumper::Sortkeys = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | my $dumper = Dumper( $hr ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | my @lines = split "\n", $dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | my @less_lines = @lines[1..$#lines-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | $str .= join "\n", @less_lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | $str .= "\n" if scalar(@less_lines); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | return $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | declare instance_dump => method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | my $class = ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | return $dump->($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | declare class_dump => class_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | my $proto = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | return $dump->($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 1; # End of Class::Root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||