| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package KinoSearch1::Util::VerifyArgs; |
|
2
|
51
|
|
|
51
|
|
47858
|
use strict; |
|
|
51
|
|
|
|
|
92
|
|
|
|
51
|
|
|
|
|
1982
|
|
|
3
|
51
|
|
|
51
|
|
257
|
use warnings; |
|
|
51
|
|
|
|
|
97
|
|
|
|
51
|
|
|
|
|
1731
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
51
|
|
|
51
|
|
283
|
use Scalar::Util qw( blessed ); |
|
|
51
|
|
|
|
|
83
|
|
|
|
51
|
|
|
|
|
4549
|
|
|
6
|
51
|
|
|
51
|
|
278
|
use Carp; |
|
|
51
|
|
|
|
|
95
|
|
|
|
51
|
|
|
|
|
3685
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
51
|
|
|
51
|
|
396
|
use base qw( Exporter ); |
|
|
51
|
|
|
|
|
98
|
|
|
|
51
|
|
|
|
|
26358
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( verify_args kerror a_isa_b ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $kerror; |
|
13
|
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
0
|
1592
|
sub kerror {$kerror} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Verify that named parameters exist in a defaults hash. |
|
17
|
|
|
|
|
|
|
sub verify_args { |
|
18
|
9632
|
|
|
9632
|
0
|
14088
|
my $defaults = shift; # leave the rest of @_ intact |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# verify that args came in pairs |
|
21
|
9632
|
100
|
|
|
|
23598
|
if ( @_ % 2 ) { |
|
22
|
1
|
|
|
|
|
13
|
my ( $package, $filename, $line ) = caller(1); |
|
23
|
1
|
|
|
|
|
6
|
$kerror |
|
24
|
|
|
|
|
|
|
= "Parameter error: odd number of args at $filename line $line\n"; |
|
25
|
1
|
|
|
|
|
5
|
return 0; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# verify keys, ignore values |
|
29
|
9631
|
|
|
|
|
21544
|
while (@_) { |
|
30
|
21789
|
|
|
|
|
34003
|
my ( $var, undef ) = ( shift, shift ); |
|
31
|
21789
|
100
|
|
|
|
83927
|
next if exists $defaults->{$var}; |
|
32
|
2
|
|
|
|
|
15
|
my ( $package, $filename, $line ) = caller(1); |
|
33
|
2
|
|
|
|
|
13
|
$kerror = "Invalid parameter: '$var' at $filename line $line\n"; |
|
34
|
2
|
|
|
|
|
9
|
return 0; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
9629
|
|
|
|
|
43601
|
return 1; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=begin comment |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
a_isa_b serves the same purpose as the isa method from UNIVERSAL, only it is |
|
43
|
|
|
|
|
|
|
called as a function rather than a method. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# safer than $foo->isa($class), which crashes if $foo isn't blessed |
|
46
|
|
|
|
|
|
|
my $confirm = a_isa_b( $foo, $class ); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=end comment |
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub a_isa_b { |
|
52
|
1594
|
|
|
1594
|
0
|
3328
|
my ( $item, $class_name ) = @_; |
|
53
|
1594
|
100
|
|
|
|
6815
|
return 0 unless blessed($item); |
|
54
|
1546
|
|
|
|
|
14260
|
return $item->isa($class_name); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |