line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## Class Objects - ~/lib/Class.pm |
3
|
|
|
|
|
|
|
## Version v1.1.6 |
4
|
|
|
|
|
|
|
## Copyright(c) 2022 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2022/02/27 |
7
|
|
|
|
|
|
|
## Modified 2022/03/06 |
8
|
|
|
|
|
|
|
## All rights reserved |
9
|
|
|
|
|
|
|
## |
10
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or modify it |
11
|
|
|
|
|
|
|
## under the same terms as Perl itself. |
12
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
13
|
|
|
|
|
|
|
BEGIN |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
use strict; |
16
|
2
|
|
|
2
|
|
172454
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
83
|
|
17
|
2
|
|
|
2
|
|
10
|
use parent -norequire, qw( Class ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
57
|
|
18
|
2
|
|
|
2
|
|
778
|
# Faster than 'use constant'. Load time critical. |
|
2
|
|
|
|
|
520
|
|
|
2
|
|
|
|
|
9
|
|
19
|
|
|
|
|
|
|
# Must eval to make $] constant. |
20
|
|
|
|
|
|
|
unless( defined( &PERL_VERSION ) ) |
21
|
2
|
50
|
|
2
|
|
168
|
{ |
22
|
|
|
|
|
|
|
*PERL_VERSION = eval qq{ sub () { $] } }; |
23
|
2
|
|
|
|
|
85
|
} |
24
|
|
|
|
|
|
|
our $VERSION = 'v1.1.6'; |
25
|
2
|
|
|
|
|
224
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my $self = shift( @_ ); |
29
|
|
|
|
|
|
|
my $pkg = caller; |
30
|
4
|
|
|
4
|
|
660
|
*{$pkg . '::CLASS'} = \$pkg; |
31
|
4
|
|
|
|
|
9
|
|
32
|
4
|
|
|
|
|
6
|
# This logic is compiled out. |
|
4
|
|
|
|
|
17
|
|
33
|
|
|
|
|
|
|
if( PERL_VERSION >= 5.008 ) |
34
|
|
|
|
|
|
|
{ |
35
|
4
|
|
|
|
|
7
|
# 5.8.x smart enough to make this a constant. |
36
|
|
|
|
|
|
|
# For legacy, we keep the upper case subroutine as well |
37
|
|
|
|
|
|
|
*{$pkg . '::CLASS'} = sub () { $pkg }; |
38
|
|
|
|
|
|
|
} |
39
|
4
|
|
|
9
|
|
16
|
else |
|
4
|
|
|
|
|
3743
|
|
|
9
|
|
|
|
|
115042
|
|
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
# Make CLASS a constant. |
42
|
|
|
|
|
|
|
*{$pkg . '::CLASS'} = eval qq{ sub () { q{$pkg} } }; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
BEGIN |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
use strict; |
49
|
|
|
|
|
|
|
use warnings; |
50
|
|
|
|
|
|
|
use parent qw( Module::Generic ); |
51
|
2
|
|
|
2
|
|
12
|
our @EXPORT = @Module::Generic::EXPORT; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
52
|
2
|
|
|
2
|
|
7
|
our @EXPORT_OK = @Module::Generic::EXPORT_OK; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
53
|
2
|
|
|
2
|
|
10
|
our %EXPORT_TAGS = %Module::Generic::EXPORT_TAGS; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
54
|
2
|
|
|
2
|
|
46289376
|
our $VERSION = 'v1.1.6'; |
55
|
2
|
|
|
|
|
8
|
}; |
56
|
2
|
|
|
|
|
5
|
|
57
|
2
|
|
|
|
|
418
|
{ |
58
|
|
|
|
|
|
|
my $self = shift( @_ ); |
59
|
|
|
|
|
|
|
my $pkg = caller; |
60
|
|
|
|
|
|
|
local $Exporter::ExportLevel = 1; |
61
|
|
|
|
|
|
|
Exporter::import( $self, @_ ); |
62
|
0
|
|
|
0
|
|
|
|
63
|
0
|
|
|
|
|
|
( my $dir = $pkg ) =~ s/::/\//g; |
64
|
0
|
|
|
|
|
|
my $path = $INC{ $dir . '.pm' }; |
65
|
0
|
|
|
|
|
|
if( defined( $path ) ) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
|
# Try absolute path name |
68
|
0
|
|
|
|
|
|
$path =~ s/^(.*)$dir\.pm$/$1auto\/$dir\/autosplit.ix/; |
69
|
0
|
0
|
|
|
|
|
eval |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
local $SIG{ '__DIE__' } = sub{ }; |
72
|
0
|
|
|
|
|
|
local $SIG{ '__WARN__' } = sub{ }; |
73
|
|
|
|
|
|
|
require $path; |
74
|
0
|
|
|
|
|
|
}; |
75
|
0
|
|
|
0
|
|
|
if( $@ ) |
76
|
0
|
|
|
0
|
|
|
{ |
77
|
0
|
|
|
|
|
|
$path = "auto/$dir/autosplit.ix"; |
78
|
|
|
|
|
|
|
eval |
79
|
0
|
0
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
local $SIG{ '__DIE__' } = sub{ }; |
81
|
0
|
|
|
|
|
|
local $SIG{ '__WARN__' } = sub{ }; |
82
|
|
|
|
|
|
|
require $path; |
83
|
0
|
|
|
|
|
|
}; |
84
|
0
|
|
|
0
|
|
|
} |
85
|
0
|
|
|
0
|
|
|
if( $@ ) |
86
|
0
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
CORE::warn( $@ ) unless( $SILENT_AUTOLOAD ); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
0
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
0
|
0
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding utf8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
CLASS - A Generic Object Class to Inherit From |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use parent qw( Class ); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub init |
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
my $self = shift( @_ ); |
108
|
|
|
|
|
|
|
return( $self->SUPER::init( @_ ) ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Support for legacy code: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
package Foo; |
114
|
|
|
|
|
|
|
use CLASS; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
print CLASS; # Foo |
117
|
|
|
|
|
|
|
print "My class is $CLASS\n"; # My class is Foo |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub bar { 23 } |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
print CLASS->bar; # 23 |
122
|
|
|
|
|
|
|
print $CLASS->bar; # 23 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
v1.1.6 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 DESCRIPTION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This package inherits all its features from L<Module::Generic> and provides a generic framework of methods to inherit from and speed up development. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
It also provides support for legacy code whereby C<CLASS> and C<$CLASS> are both synonyms for C<__PACKAGE__>. Easier to type. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
C<$CLASS> has the additional benefit of working in strings. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
C<Class> is a constant, not a subroutine call. C<$CLASS> is a plain variable, it is not tied. There is no performance loss for using C<Class> over C<__PACKAGE__> except the loading of the module. (Thanks Juerd) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SEE ALSO |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L<Class::Stack>, L<Class::String>, L<Class::Number>, L<Class::Boolean>, L<Class::Assoc>, L<Class::File>, L<Class::DateTime>, L<Class::Exception>, L<Class::Finfo>, L<Class::NullChain> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
From February 2022 onward: Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Michael G Schwern E<lt>F<schwern@pobox.com>E<gt> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Copyright (c) 2021 DEGUEST Pte. Ltd. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
153
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |