line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::DataType::UnsignedInteger; |
3
|
7
|
|
|
7
|
|
46
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
181
|
|
4
|
7
|
|
|
7
|
|
31
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
159
|
|
5
|
7
|
|
|
7
|
|
30
|
use RPerl::AfterSubclass; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1035
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.007_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
7
|
|
|
7
|
|
44
|
use parent qw(RPerl::DataType::Scalar); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
38
|
|
10
|
7
|
|
|
7
|
|
442
|
use RPerl::DataType::Scalar; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
205
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# [[[ CRITICS ]]] |
13
|
|
|
|
|
|
|
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator |
14
|
|
|
|
|
|
|
## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils |
15
|
|
|
|
|
|
|
## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# [[[ SUB-TYPES ]]] |
18
|
|
|
|
|
|
|
# an unsigned_integer is a whole number greater or equal to zero, it has no floating-pointer (fractional/decimal) component or negative value |
19
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
20
|
|
|
|
|
|
|
unsigned_integer; |
21
|
7
|
|
|
7
|
|
29
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
124
|
|
22
|
7
|
|
|
7
|
|
27
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
175
|
|
23
|
7
|
|
|
7
|
|
29
|
use parent qw(RPerl::DataType::UnsignedInteger); |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
24
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
26
|
|
|
|
|
|
|
constant_unsigned_integer; |
27
|
7
|
|
|
7
|
|
381
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
101
|
|
28
|
7
|
|
|
7
|
|
26
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
147
|
|
29
|
7
|
|
|
7
|
|
79
|
use parent qw(RPerl::DataType::UnsignedInteger); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
27
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# [[[ PRE-DECLARED TYPES ]]] |
32
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
33
|
|
|
|
|
|
|
boolean; |
34
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
35
|
|
|
|
|
|
|
integer; |
36
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
37
|
|
|
|
|
|
|
number; |
38
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
39
|
|
|
|
|
|
|
character; |
40
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
41
|
|
|
|
|
|
|
string; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# [[[ SWITCH CONTEXT BACK TO PRIMARY PACKAGE ]]] |
44
|
|
|
|
|
|
|
package RPerl::DataType::UnsignedInteger; |
45
|
7
|
|
|
7
|
|
465
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
147
|
|
46
|
7
|
|
|
7
|
|
32
|
use warnings; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
177
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# [[[ EXPORTS ]]] |
49
|
7
|
|
|
7
|
|
35
|
use RPerl::Exporter 'import'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
34
|
|
50
|
|
|
|
|
|
|
our @EXPORT = qw(unsigned_integer_CHECK unsigned_integer_CHECKTRACE unsigned_integer_to_boolean unsigned_integer_to_integer unsigned_integer_to_number unsigned_integer_to_character unsigned_integer_to_string); |
51
|
|
|
|
|
|
|
our @EXPORT_OK = qw(unsigned_integer__typetest0 unsigned_integer__typetest1); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# [[[ TYPE-CHECKING ]]] |
54
|
|
|
|
|
|
|
sub unsigned_integer_CHECK { |
55
|
0
|
|
|
0
|
|
|
{ my void $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
( my $possible_unsigned_integer ) = @ARG; |
57
|
0
|
0
|
|
|
|
|
if ( not( defined $possible_unsigned_integer ) ) { |
58
|
|
|
|
|
|
|
# croak("\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\ncroaking"); |
59
|
0
|
|
|
|
|
|
die("\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\ndying\n"); |
60
|
|
|
|
|
|
|
} |
61
|
0
|
0
|
|
|
|
|
if ( not( main::RPerl_SvUIOKp($possible_unsigned_integer) ) ) { |
62
|
|
|
|
|
|
|
# croak("\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\ncroaking"); |
63
|
0
|
|
|
|
|
|
dying("\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\ndying\n"); |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
sub unsigned_integer_CHECKTRACE { |
68
|
0
|
|
|
0
|
|
|
{ my void $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
( my $possible_unsigned_integer, my $variable_name, my $subroutine_name ) = @ARG; |
70
|
0
|
0
|
|
|
|
|
if ( not( defined $possible_unsigned_integer ) ) { |
71
|
|
|
|
|
|
|
# croak( "\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking" ); |
72
|
0
|
|
|
|
|
|
dying( "\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ndying\n" ); |
73
|
|
|
|
|
|
|
} |
74
|
0
|
0
|
|
|
|
|
if ( not( main::RPerl_SvUIOKp($possible_unsigned_integer) ) ) { |
75
|
|
|
|
|
|
|
# croak( "\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking" ); |
76
|
0
|
|
|
|
|
|
dying( "\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\nin variable $variable_name from subroutine $subroutine_name,\ndying\n" ); |
77
|
|
|
|
|
|
|
} |
78
|
0
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# [[[ BOOLEANIFY ]]] |
82
|
|
|
|
|
|
|
sub unsigned_integer_to_boolean { |
83
|
0
|
|
|
0
|
|
|
{ my boolean $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
( my unsigned_integer $input_unsigned_integer ) = @ARG; |
85
|
|
|
|
|
|
|
# unsigned_integer_CHECK($input_unsigned_integer); |
86
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_boolean()' ); |
87
|
0
|
0
|
|
|
|
|
if ( $input_unsigned_integer == 0 ) { return 0; } |
|
0
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
else { return 1; } |
89
|
0
|
|
|
|
|
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# [[[ INTEGERIFY ]]] |
93
|
|
|
|
|
|
|
sub unsigned_integer_to_integer { |
94
|
0
|
|
|
0
|
|
|
{ my integer $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
( my unsigned_integer $input_unsigned_integer ) = @ARG; |
96
|
|
|
|
|
|
|
# unsigned_integer_CHECK($input_unsigned_integer); |
97
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_integer()' ); |
98
|
0
|
|
|
|
|
|
return $input_unsigned_integer; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# [[[ NUMBERIFY ]]] |
102
|
|
|
|
|
|
|
sub unsigned_integer_to_number { |
103
|
0
|
|
|
0
|
|
|
{ my number $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
( my unsigned_integer $input_unsigned_integer ) = @ARG; |
105
|
|
|
|
|
|
|
# unsigned_integer_CHECK($input_unsigned_integer); |
106
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_number()' ); |
107
|
0
|
|
|
|
|
|
return $input_unsigned_integer * 1.0; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# [[[ CHARACTERIFY ]]] |
111
|
|
|
|
|
|
|
sub unsigned_integer_to_character { |
112
|
0
|
|
|
0
|
|
|
{ my character $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
( my unsigned_integer $input_unsigned_integer ) = @ARG; |
114
|
|
|
|
|
|
|
# unsigned_integer_CHECK($input_unsigned_integer); |
115
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_character()' ); |
116
|
0
|
|
|
|
|
|
my string $tmp_string = unsigned_integer_to_string($input_unsigned_integer); |
117
|
0
|
0
|
|
|
|
|
if ( $tmp_string eq q{} ) { return q{}; } |
|
0
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
else { return substr $tmp_string, 0, 1; } |
119
|
0
|
|
|
|
|
|
return; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# [[[ STRINGIFY ]]] |
123
|
|
|
|
|
|
|
sub unsigned_integer_to_string { |
124
|
0
|
|
|
0
|
|
|
{ my string $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
( my unsigned_integer $input_unsigned_integer ) = @ARG; |
126
|
|
|
|
|
|
|
# unsigned_integer_CHECK($input_unsigned_integer); |
127
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_string()' ); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer_to_string(), received \$input_unsigned_integer = $input_unsigned_integer\n"); |
130
|
|
|
|
|
|
|
# RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer_to_string()...\n"); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# DEV NOTE: disable old stringify w/out underscores |
133
|
|
|
|
|
|
|
# return "$input_unsigned_integer"; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my string $retval = reverse "$input_unsigned_integer"; |
136
|
0
|
|
|
|
|
|
$retval =~ s/(\d{3})/$1_/gxms; |
137
|
0
|
0
|
|
|
|
|
if ( ( substr $retval, -1, 1 ) eq '_' ) { chop $retval; } |
|
0
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$retval = reverse $retval; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# RPerl::diag('in PERLOPS_PERLTYPES unsigned_integer_to_string(), have $retval = ' . q{'} . $retval . q{'} . "\n"); |
141
|
0
|
|
|
|
|
|
return $retval; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# [[[ TYPE TESTING ]]] |
145
|
|
|
|
|
|
|
sub unsigned_integer__typetest0 { |
146
|
0
|
|
|
0
|
|
|
{ my unsigned_integer $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my unsigned_integer $retval = ( 21 / 7 ) + main::RPerl__DataType__UnsignedInteger__MODE_ID(); # return unsigned_integer (not number) value, don't do (22 / 7) etc. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer__typetest0(), have \$retval = $retval\n"); |
150
|
0
|
|
|
|
|
|
return ($retval); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub unsigned_integer__typetest1 { |
154
|
0
|
|
|
0
|
|
|
{ my unsigned_integer $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
( my unsigned_integer $lucky_unsigned_integer ) = @ARG; |
156
|
|
|
|
|
|
|
# unsigned_integer_CHECK($lucky_unsigned_integer); |
157
|
0
|
|
|
|
|
|
unsigned_integer_CHECKTRACE( $lucky_unsigned_integer, '$lucky_unsigned_integer', 'unsigned_integer__typetest1()' ); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# RPerl::diag('in PERLOPS_PERLTYPES unsigned_integer__typetest1(), received $lucky_unsigned_integer = ' . unsigned_integer_to_string($lucky_unsigned_integer) . "\n"); |
160
|
0
|
|
|
|
|
|
return ( ( $lucky_unsigned_integer * 2 ) + main::RPerl__DataType__UnsignedInteger__MODE_ID() ); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; # end of class |