| 1 | # [[[ HEADER ]]] | ||||||||||
| 2 | package Perl::Type::NonsignedInteger; | ||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use Perl::Config; # don't use Perl::Types inside itself, in order to avoid circular includes | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | our $VERSION = 0.008_000; | |||||||||
| 7 | |||||||||||
| 8 | # [[[ OO INHERITANCE ]]] | ||||||||||
| 9 | 5 | ▶ | use parent qw(Perl::Type::Scalar); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 5 | ▶ | use Perl::Type::Scalar; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | # DEV NOTE, CORRELATION #rp500 COMPILER REFACTOR: must use "nonsigned_integer" typedef because "unsigned_integer" or even "unsignedinteger" will trigger false error messages... | ||||||||||
| 18 | |||||||||||
| 19 | # [[[ SUB-TYPES ]]] | ||||||||||
| 20 | # an nonsigned_integer is a whole number greater or equal to zero, it has no floating-pointer (fractional/decimal) component or negative value | ||||||||||
| 21 | package nonsigned_integer; | ||||||||||
| 22 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 5 | ▶ | use parent qw(Perl::Type::NonsignedInteger); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | package constant_nonsigned_integer; | ||||||||||
| 27 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 5 | ▶ | use parent qw(Perl::Type::NonsignedInteger); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | # [[[ SWITCH CONTEXT BACK TO PRIMARY PACKAGE ]]] | ||||||||||
| 32 | package Perl::Type::NonsignedInteger; | ||||||||||
| 33 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | # [[[ EXPORTS ]]] | ||||||||||
| 37 | 5 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 5 | our @EXPORT = qw(nonsigned_integer_CHECK nonsigned_integer_CHECKTRACE nonsigned_integer_to_boolean nonsigned_integer_to_integer nonsigned_integer_to_number nonsigned_integer_to_character nonsigned_integer_to_string); | |||||||||
| 39 | 5 | our @EXPORT_OK = qw(nonsigned_integer_typetest0 nonsigned_integer_typetest1); | |||||||||
| 40 | |||||||||||
| 41 | # [[[ TYPE-CHECKING ]]] | ||||||||||
| 42 | 0 | ▶ | sub nonsigned_integer_CHECK { | ||||||||
|
Subroutine
nonsigned_integer_CHECK: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 43 | 0 | { my void $RETURN_TYPE }; | |||||||||
| 44 | 0 | ( my $possible_nonsigned_integer ) = @ARG; | |||||||||
| 45 | 0 | ▶ | if ( not( defined $possible_nonsigned_integer ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | # croak("\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but undefined/null value found,\ncroaking"); | ||||||||||
| 47 | 0 | die("\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but undefined/null value found,\ndying\n"); | |||||||||
| 48 | } | ||||||||||
| 49 | 0 | ▶ | if ( not( main::PerlTypes_SvUIOKp($possible_nonsigned_integer) ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | # croak("\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but non-nonsigned_integer value found,\ncroaking"); | ||||||||||
| 51 | 0 | dying("\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but non-nonsigned_integer value found,\ndying\n"); | |||||||||
| 52 | } | ||||||||||
| 53 | 0 | return; | |||||||||
| 54 | } | ||||||||||
| 55 | 0 | ▶ | sub nonsigned_integer_CHECKTRACE { | ||||||||
|
Subroutine
nonsigned_integer_CHECKTRACE: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 56 | 0 | { my void $RETURN_TYPE }; | |||||||||
| 57 | 0 | ( my $possible_nonsigned_integer, my $variable_name, my $subroutine_name ) = @ARG; | |||||||||
| 58 | 0 | ▶ | if ( not( defined $possible_nonsigned_integer ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | # croak( "\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking" ); | ||||||||||
| 60 | 0 | dying( "\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ndying\n" ); | |||||||||
| 61 | } | ||||||||||
| 62 | 0 | ▶ | if ( not( main::PerlTypes_SvUIOKp($possible_nonsigned_integer) ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | # croak( "\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but non-nonsigned_integer value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking" ); | ||||||||||
| 64 | 0 | dying( "\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nnonsigned_integer value expected but non-nonsigned_integer value found,\nin variable $variable_name from subroutine $subroutine_name,\ndying\n" ); | |||||||||
| 65 | } | ||||||||||
| 66 | 0 | return; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | # [[[ BOOLEANIFY ]]] | ||||||||||
| 70 | 0 | ▶ | sub nonsigned_integer_to_boolean { | ||||||||
|
Subroutine
nonsigned_integer_to_boolean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 71 | 0 | { my boolean $RETURN_TYPE }; | |||||||||
| 72 | 0 | ( my nonsigned_integer $input_nonsigned_integer ) = @ARG; | |||||||||
| 73 | # nonsigned_integer_CHECK($input_nonsigned_integer); | ||||||||||
| 74 | 0 | nonsigned_integer_CHECKTRACE( $input_nonsigned_integer, '$input_nonsigned_integer', 'nonsigned_integer_to_boolean()' ); | |||||||||
| 75 | 0 | ▶ | if ( $input_nonsigned_integer == 0 ) { return 0; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 0 | else { return 1; } | |||||||||
| 77 | 0 | return; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | # [[[ INTEGERIFY ]]] | ||||||||||
| 81 | 0 | ▶ | sub nonsigned_integer_to_integer { | ||||||||
|
Subroutine
nonsigned_integer_to_integer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 82 | 0 | { my integer $RETURN_TYPE }; | |||||||||
| 83 | 0 | ( my nonsigned_integer $input_nonsigned_integer ) = @ARG; | |||||||||
| 84 | # nonsigned_integer_CHECK($input_nonsigned_integer); | ||||||||||
| 85 | 0 | nonsigned_integer_CHECKTRACE( $input_nonsigned_integer, '$input_nonsigned_integer', 'nonsigned_integer_to_integer()' ); | |||||||||
| 86 | 0 | return $input_nonsigned_integer; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | # [[[ NUMBERIFY ]]] | ||||||||||
| 90 | 0 | ▶ | sub nonsigned_integer_to_number { | ||||||||
|
Subroutine
nonsigned_integer_to_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 91 | 0 | { my number $RETURN_TYPE }; | |||||||||
| 92 | 0 | ( my nonsigned_integer $input_nonsigned_integer ) = @ARG; | |||||||||
| 93 | # nonsigned_integer_CHECK($input_nonsigned_integer); | ||||||||||
| 94 | 0 | nonsigned_integer_CHECKTRACE( $input_nonsigned_integer, '$input_nonsigned_integer', 'nonsigned_integer_to_number()' ); | |||||||||
| 95 | 0 | return ($input_nonsigned_integer * 1.0); | |||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | # [[[ CHARACTERIFY ]]] | ||||||||||
| 99 | 0 | ▶ | sub nonsigned_integer_to_character { | ||||||||
|
Subroutine
nonsigned_integer_to_character: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 100 | 0 | { my character $RETURN_TYPE }; | |||||||||
| 101 | 0 | ( my nonsigned_integer $input_nonsigned_integer ) = @ARG; | |||||||||
| 102 | # nonsigned_integer_CHECK($input_nonsigned_integer); | ||||||||||
| 103 | 0 | nonsigned_integer_CHECKTRACE( $input_nonsigned_integer, '$input_nonsigned_integer', 'nonsigned_integer_to_character()' ); | |||||||||
| 104 | 0 | my string $tmp_string = nonsigned_integer_to_string($input_nonsigned_integer); | |||||||||
| 105 | 0 | ▶ | if ( $tmp_string eq q{} ) { return q{}; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 0 | else { return (substr $tmp_string, 0, 1); } | |||||||||
| 107 | 0 | return; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | # [[[ STRINGIFY ]]] | ||||||||||
| 111 | 0 | ▶ | sub nonsigned_integer_to_string { | ||||||||
|
Subroutine
nonsigned_integer_to_string: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 112 | 0 | { my string $RETURN_TYPE }; | |||||||||
| 113 | 0 | ( my nonsigned_integer $input_nonsigned_integer ) = @ARG; | |||||||||
| 114 | # nonsigned_integer_CHECK($input_nonsigned_integer); | ||||||||||
| 115 | 0 | nonsigned_integer_CHECKTRACE( $input_nonsigned_integer, '$input_nonsigned_integer', 'nonsigned_integer_to_string()' ); | |||||||||
| 116 | |||||||||||
| 117 | # Perl::diag("in PERLOPS_PERLTYPES nonsigned_integer_to_string(), received \$input_nonsigned_integer = $input_nonsigned_integer\n"); | ||||||||||
| 118 | # Perl::diag("in PERLOPS_PERLTYPES nonsigned_integer_to_string()...\n"); | ||||||||||
| 119 | |||||||||||
| 120 | # DEV NOTE: disable old stringify w/out underscores | ||||||||||
| 121 | # return "$input_nonsigned_integer"; | ||||||||||
| 122 | |||||||||||
| 123 | 0 | my string $retval = reverse "$input_nonsigned_integer"; | |||||||||
| 124 | 0 | $retval =~ s/(\d{3})/$1_/gxms; | |||||||||
| 125 | 0 | ▶ | if ( ( substr $retval, -1, 1 ) eq '_' ) { chop $retval; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | 0 | $retval = reverse $retval; | |||||||||
| 127 | |||||||||||
| 128 | # Perl::diag('in PERLOPS_PERLTYPES nonsigned_integer_to_string(), have $retval = ' . q{'} . $retval . q{'} . "\n"); | ||||||||||
| 129 | 0 | return $retval; | |||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | # [[[ TYPE TESTING ]]] | ||||||||||
| 133 | 0 | ▶ | sub nonsigned_integer_typetest0 { | ||||||||
|
Subroutine
nonsigned_integer_typetest0: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 134 | 0 | { my nonsigned_integer $RETURN_TYPE }; | |||||||||
| 135 | 0 | my nonsigned_integer $retval = ( 21 / 7 ) + main::Perl__Type__NonsignedInteger__MODE_ID(); # return nonsigned_integer (not number) value, don't do (22 / 7) etc. | |||||||||
| 136 | |||||||||||
| 137 | # Perl::diag("in PERLOPS_PERLTYPES nonsigned_integer_typetest0(), have \$retval = $retval\n"); | ||||||||||
| 138 | 0 | return $retval; | |||||||||
| 139 | } | ||||||||||
| 140 | |||||||||||
| 141 | 0 | ▶ | sub nonsigned_integer_typetest1 { | ||||||||
|
Subroutine
nonsigned_integer_typetest1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 142 | 0 | { my nonsigned_integer $RETURN_TYPE }; | |||||||||
| 143 | 0 | ( my nonsigned_integer $lucky_nonsigned_integer ) = @ARG; | |||||||||
| 144 | # nonsigned_integer_CHECK($lucky_nonsigned_integer); | ||||||||||
| 145 | 0 | nonsigned_integer_CHECKTRACE( $lucky_nonsigned_integer, '$lucky_nonsigned_integer', 'nonsigned_integer_typetest1()' ); | |||||||||
| 146 | |||||||||||
| 147 | # Perl::diag('in PERLOPS_PERLTYPES nonsigned_integer_typetest1(), received $lucky_nonsigned_integer = ' . nonsigned_integer_to_string($lucky_nonsigned_integer) . "\n"); | ||||||||||
| 148 | 0 | return ( ( $lucky_nonsigned_integer * 2 ) + main::Perl__Type__NonsignedInteger__MODE_ID() ); | |||||||||
| 149 | } | ||||||||||
| 150 | |||||||||||
| 151 | # DEV NOTE, CORRELATION #rp018: Perl::Type::*.pm files do not 'use RPerl;' and thus do not trigger the pseudo-source-filter contained in | ||||||||||
| 152 | # RPerl::CompileUnit::Module::Class::create_symtab_entries_and_accessors_mutators(), | ||||||||||
| 153 | # so *__MODE_ID() subroutines are hard-coded here instead of auto-generated there | ||||||||||
| 154 | package main; | ||||||||||
| 155 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 156 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 157 | 0 | ▶ | sub Perl__Type__NonsignedInteger__MODE_ID { return 0; } | ||||||||
|
Subroutine
Perl__Type__NonsignedInteger__MODE_ID: not called CC=1 SCAR=6.9
| |||||||||||
| 158 | |||||||||||
| 159 | 5 | 1; # end of class | |||||||||