line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::TypeCheck::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require Exporter; |
4
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
445
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Devel::TypeCheck::Util - Exports utility functions to other TypeCheck modules. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Devel::TypeCheck::Util; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=over 4 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
@EXPORT = qw(getVerbose setVerbose verbose verbose_ TRUE FALSE abstract); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $verbose = 0; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item B |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Return whether or not verbose mode is enabled. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
# getVerbose(): return the verbosity status |
31
|
|
|
|
|
|
|
sub getVerbose () { |
32
|
0
|
|
|
0
|
1
|
0
|
return $verbose; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item B($status) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Turn verbose mode on or off, depending on the value of C<<$status>> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
# setVerbose($status): set the verbosity status |
41
|
|
|
|
|
|
|
sub setVerbose ($) { |
42
|
0
|
|
|
0
|
1
|
0
|
my $status = shift; |
43
|
0
|
0
|
|
|
|
0
|
if ($status) { |
44
|
0
|
|
|
|
|
0
|
$verbose = 1; |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
0
|
$verbose = 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B($msg1, $msg2, ...) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
If verbosity is on, print out the messages to STDOUT. Otherwise, do nothing. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
sub verbose { |
56
|
0
|
0
|
|
0
|
1
|
0
|
if ($verbose) { |
57
|
0
|
|
|
|
|
0
|
print STDOUT (@_, "\n"); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item B |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Like verbose(), but without a carriage return. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
sub verbose_ { |
67
|
0
|
0
|
|
0
|
1
|
0
|
if ($verbose) { |
68
|
0
|
|
|
|
|
0
|
print STDOUT (@_); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B |
73
|
|
|
|
|
|
|
=item B |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Helper functions to signify that we are using scalars to store boolean values. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
sub TRUE () { |
79
|
22
|
|
|
22
|
1
|
186
|
return 1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub FALSE () { |
83
|
0
|
|
|
0
|
1
|
|
return 0; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B($method, $class) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Called from abstract methods to indicate an error |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
sub abstract ($$) { |
92
|
0
|
|
|
0
|
1
|
|
my ($method, $class) = @_; |
93
|
0
|
|
|
|
|
|
confess("Method &$method is not implemented in class $class"); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
TRUE; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Gary Jackson, C<< >> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 BUGS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This version is specific to Perl 5.8.1. It may work with other |
107
|
|
|
|
|
|
|
versions that have the same opcode list and structure, but this is |
108
|
|
|
|
|
|
|
entirely untested. It definitely will not work if those parameters |
109
|
|
|
|
|
|
|
change. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
112
|
|
|
|
|
|
|
C, or through the web interface at |
113
|
|
|
|
|
|
|
L. |
114
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
115
|
|
|
|
|
|
|
your bug as I make changes. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright 2005 Gary Jackson, all rights reserved. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
122
|
|
|
|
|
|
|
under the same terms as Perl itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |