line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## -*- Mode: CPerl -*- |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## File: DiaColloDB::Compat.pm |
4
|
|
|
|
|
|
|
## Author: Bryan Jurish <moocow@cpan.org> |
5
|
|
|
|
|
|
|
## Description: DiaColloDB utilities: compatibility modules: top-level wrappers |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package DiaColloDB::Compat; |
8
|
|
|
|
|
|
|
#use DiaColloDB::Compat::v0_08; |
9
|
|
|
|
|
|
|
#use DiaColloDB::Compat::v0_09; |
10
|
2
|
|
|
2
|
|
726
|
use DiaColloDB::Logger; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
68
|
|
11
|
2
|
|
|
2
|
|
16
|
use Carp; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
106
|
|
12
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
610
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
##============================================================================== |
15
|
|
|
|
|
|
|
## Globals |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @ISA = qw(DiaColloDB::Logger); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
##============================================================================== |
20
|
|
|
|
|
|
|
## Utilities |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
## $bool = $that->usecompat($pkg) |
23
|
|
|
|
|
|
|
## + attempts to "use DiaColloDB::Compat::$pkg", throwing an error on failure |
24
|
|
|
|
|
|
|
sub usecompat { |
25
|
0
|
0
|
|
0
|
1
|
0
|
my $that = UNIVERSAL::isa($_[0],__PACKAGE__) ? shift : __PACKAGE__; |
26
|
0
|
|
|
|
|
0
|
my $pkg = shift; |
27
|
0
|
|
|
|
|
0
|
(my $file = $pkg) =~ s{::}{/}g; |
28
|
0
|
0
|
|
|
|
0
|
$file .= ".pm" if ($file !~ /\.pm$/); |
29
|
0
|
0
|
|
|
|
0
|
$file = "DiaColloDB/Compat/$file" if ($file !~ m{^DiaColloDB/Compat/}); |
30
|
0
|
|
|
|
|
0
|
my ($rc); |
31
|
0
|
|
|
|
|
0
|
eval { $rc = require $file }; |
|
0
|
|
|
|
|
0
|
|
32
|
0
|
0
|
0
|
|
|
0
|
$that->logconfess("failed to load compatibility package $pkg".($@ ? ": $@" : '')) if ($@ || !$rc); |
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
return $rc; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
## \&dummyMethodCode = $that->nocompat($methodName) |
37
|
|
|
|
|
|
|
## + wrapper for subclasses which do not implement some API methods |
38
|
|
|
|
|
|
|
sub nocompat { |
39
|
12
|
50
|
|
12
|
1
|
56
|
my $that = UNIVERSAL::isa($_[0],__PACKAGE__) ? shift : undef; |
40
|
12
|
|
|
|
|
21
|
my $method = shift; |
41
|
|
|
|
|
|
|
return sub { |
42
|
0
|
|
|
0
|
|
|
$_[0]->logconfess("method $method() not supported by compatibility wrapper"); |
43
|
12
|
|
|
|
|
6652
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
##============================================================================== |
47
|
|
|
|
|
|
|
## Footer |
48
|
|
|
|
|
|
|
1; ##-- be happy |