| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||||||||||||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||||||||||||
| 3 | # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||||||||||||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||||||||||||||||||||||||
| 5 | # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||||||||||||
| 6 | # the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||
| 13 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||
| 14 | # limitations under the License. | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 54 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 54 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | package Clownfish; | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 54 | ▶ | use 5.008003; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 24 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 25 | our $MAJOR_VERSION = 0.008000; | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 54 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | 27 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 29 | 54 | our @EXPORT_OK = qw( to_clownfish ); | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | # On most UNIX variants, this flag makes DynaLoader pass RTLD_GLOBAL to | ||||||||||||||||||||||||||||||||
| 33 | # dl_open, so extensions can resolve the needed symbols without explicitly | ||||||||||||||||||||||||||||||||
| 34 | # linking against the DSO. | ||||||||||||||||||||||||||||||||
| 35 | 27 | ▶ | sub dl_load_flags { 1 } | ||||||||||||||||||||||||||||||
|
Subroutine
dl_load_flags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 27 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 38 | 54 | require DynaLoader; | |||||||||||||||||||||||||||||||
| 39 | 54 | our @ISA = qw( DynaLoader ); | |||||||||||||||||||||||||||||||
| 40 | # This loads a large number of disparate subs. | ||||||||||||||||||||||||||||||||
| 41 | 54 | bootstrap Clownfish '0.8.0'; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub error {$Clownfish::Err::error} | ||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||
| 47 | package Clownfish::Obj; | ||||||||||||||||||||||||||||||||
| 48 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 49 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 50 | 54 | ▶ | use Carp qw( confess ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 51 | # Clownfish objects are not thread-safe. | ||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub CLONE_SKIP { 1; } | ||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 53 | sub STORABLE_freeze { | ||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | my $class_name = ref(shift); | ||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 55 | 1 | confess("Storable serialization not implemented for $class_name"); | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | sub STORABLE_thaw { | ||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $class_name = ref(shift); | ||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 59 | 1 | confess("Storable serialization not implemented for $class_name"); | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||
| 64 | package Clownfish::Class; | ||||||||||||||||||||||||||||||||
| 65 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 66 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | sub _find_parent_class { | ||||||||||||||||||||||||||||||||
| 69 | 10 | ▶ | my $package = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_find_parent_class: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||
| 70 | 54 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 71 | 10 | for my $parent ( @{"$package\::ISA"} ) { | |||||||||||||||||||||||||||||||
| 72 | 10 | ▶ | return $parent if $parent->isa('Clownfish::Obj'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | sub _fresh_host_methods { | ||||||||||||||||||||||||||||||||
| 78 | 12 | ▶ | my $package = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_fresh_host_methods: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 79 | 54 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 80 | 12 | my $stash = \%{"$package\::"}; | |||||||||||||||||||||||||||||||
| 81 | 12 | my $methods | |||||||||||||||||||||||||||||||
| 82 | = Clownfish::Vector->new( capacity => scalar keys %$stash ); | ||||||||||||||||||||||||||||||||
| 83 | 12 | ▶ | while ( my ( $symbol, $entry ) = each %$stash ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | # A subroutine is stored in the CODE slot of a typeglob. Since | ||||||||||||||||||||||||||||||||
| 85 | # Perl 5.28 it may also be stored as a coderef. | ||||||||||||||||||||||||||||||||
| 86 | next unless ref($entry) eq 'CODE' | ||||||||||||||||||||||||||||||||
| 87 | 74 | ▶ | || ( ref(\$entry) eq 'GLOB' && *$entry{CODE} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
ref $entry eq "CODE" or ref \$entry eq "GLOB" and *$entry{"CODE"}
ref \$entry eq "GLOB" and *$entry{"CODE"}
MC/DC0%0/2
ref $entry eq "CODE" or ref \$entry eq "GLOB" and *$entry{"CODE"}
ref $entry eq "CODE"
ref \$entry eq "GLOB"
Truth table33%1/3
A or B
A= ref $entry eq "CODE"B= ref \$entry eq "GLOB"
| |||||||||||||||||||||||||||||||||
| 88 | 29 | $methods->push( Clownfish::String->new($symbol) ); | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | 12 | return $methods; | |||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | sub _register { | ||||||||||||||||||||||||||||||||
| 94 | 11 | ▶ | my ( $singleton, $parent ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_register: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 95 | 11 | my $singleton_class = $singleton->get_name; | |||||||||||||||||||||||||||||||
| 96 | 11 | my $parent_class = $parent->get_name; | |||||||||||||||||||||||||||||||
| 97 | 11 | ▶ | if ( !$singleton_class->isa($parent_class) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | 27 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 99 | 2 | push @{"$singleton_class\::ISA"}, $parent_class; | |||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 27 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub CLONE_SKIP { 0; } | ||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub DESTROY { } # leak all | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||
| 109 | package Clownfish::Method; | ||||||||||||||||||||||||||||||||
| 110 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 111 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 112 | 27 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub CLONE_SKIP { 0; } | ||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub DESTROY { } # leak all | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||
| 118 | package Clownfish::Err; | ||||||||||||||||||||||||||||||||
| 119 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 120 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 121 | 66 | ▶ | sub do_to_string { shift->to_string } | ||||||||||||||||||||||||||||||
|
Subroutine
do_to_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 122 | 27 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 123 | 27 | ▶ | use Carp qw( confess longmess ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 124 | use overload | ||||||||||||||||||||||||||||||||
| 125 | 27 | ▶ | '""' => \&do_to_string, | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 126 | 27 | fallback => 1; | |||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | sub new { | ||||||||||||||||||||||||||||||||
| 129 | 7 | ▶ | my ( $either, $message ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 130 | 7 | my ( undef, $file, $line ) = caller; | |||||||||||||||||||||||||||||||
| 131 | 7 | $message .= ", $file line $line\n"; | |||||||||||||||||||||||||||||||
| 132 | 7 | return $either->_new( mess => Clownfish::String->new($message) ); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | sub do_throw { | ||||||||||||||||||||||||||||||||
| 136 | 59 | ▶ | my $err = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
do_throw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 137 | 59 | my $longmess = longmess(); | |||||||||||||||||||||||||||||||
| 138 | 59 | $longmess =~ s/^\s*/\t/; | |||||||||||||||||||||||||||||||
| 139 | 59 | $err->cat_mess($longmess); | |||||||||||||||||||||||||||||||
| 140 | 59 | die $err; | |||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | our $error; | ||||||||||||||||||||||||||||||||
| 144 | sub set_error { | ||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $val = $_[1]; | ||||||||||||||||||||||||||||||
|
Subroutine
set_error: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( defined $val ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | confess("Not a Clownfish::Err") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($val) and $val->isa("Clownfish::Err")
MC/DC0%0/2
builtin::blessed($val) and $val->isa("Clownfish::Err")
builtin::blessed($val)
$val->isa("Clownfish::Err")
Truth table0%0/3
A and B
A= builtin::blessed($val)B= $val->isa("Clownfish::Err")
| |||||||||||||||||||||||||||||||||
| 148 | unless ( blessed($val) | ||||||||||||||||||||||||||||||||
| 149 | && $val->isa("Clownfish::Err") ); | ||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | 0 | $error = $val; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub get_error {$error} | ||||||||||||||||||||||||||||||
|
Subroutine
get_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||
| 157 | package Clownfish::Boolean; | ||||||||||||||||||||||||||||||||
| 158 | our $VERSION = '0.008000'; | ||||||||||||||||||||||||||||||||
| 159 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||
| 160 | 27 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 161 | our @EXPORT_OK = qw( $true_singleton $false_singleton ); | ||||||||||||||||||||||||||||||||
| 162 | our $true_singleton = Clownfish::Boolean->singleton(1); | ||||||||||||||||||||||||||||||||
| 163 | our $false_singleton = Clownfish::Boolean->singleton(0); | ||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub DESTROY { } # leak all | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 1; | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||