| 1 | package Class::MOP::Package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 459 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 459 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 459 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 459 | ▶ | use Scalar::Util 'blessed', 'weaken'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 459 | ▶ | use Devel::GlobalDestruction 'in_global_destruction'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 459 | ▶ | use Module::Runtime 'module_notional_filename'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 459 | ▶ | use Package::Stash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 459 | ▶ | use parent 'Class::MOP::Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # creation ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2488 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2488 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2488 | ▶ | unshift @args, "package" if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2488 | my %options = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2488 | my $package_name = delete $options{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # we hand-construct the class until we can bootstrap it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2488 | ▶ | if ( my $meta = Class::MOP::get_metaclass_by_name($package_name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 64 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2424 | ▶ | my $meta = ( ref $class || $class )->_new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table66%2/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'package' => $package_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | %options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2424 | Class::MOP::store_metaclass_by_name($package_name, $meta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2424 | ▶ | Class::MOP::weaken_metaclass($package_name) if $options{weaken}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2424 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 133 | ▶ | sub reinitialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reinitialize: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 133 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 133 | ▶ | unshift @args, "package" if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 133 | my %options = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 133 | my $package_name = delete $options{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 133 | ▶ | (defined $package_name && $package_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $package_name and $package_name and !builtin::blessed($package_name) || $package_name->isa("Class::MOP::Package")
defined $package_name and $package_name
not builtin::blessed($package_name) or $package_name->isa("Class::MOP::Package")
MC/DC100%4/4
defined $package_name and $package_name and !builtin::blessed($package_name) || $package_name->isa("Class::MOP::Package")
defined $package_name
$package_name
not builtin::blessed($package_name)
$package_name->isa("Class::MOP::Package")
Truth table100%5/5
A and B and not(C) or D
A= defined $package_nameB= $package_nameC= not builtin::blessed($package_name)D= $package_name->isa("Class::MOP::Package")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | && (!blessed $package_name || $package_name->isa('Class::MOP::Package'))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | || $class->_throw_exception( MustPassAPackageNameOrAnExistingClassMOPPackageInstance => params => \%options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | class => $class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 130 | ▶ | $package_name = $package_name->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | if blessed $package_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 130 | Class::MOP::remove_metaclass_by_name($package_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 130 | $class->initialize($package_name, %options); # call with first arg form for compat | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1535 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1535 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1535 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1535 | my $meta = $class->initialize(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1530 | my $filename = module_notional_filename($meta->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $INC{$filename} = '(set by Moose)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1530 | ▶ | unless exists $INC{$filename}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1530 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ## ANON packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # this should be sufficient, if you have a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # use case where it is not, write a test and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # I will change it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 459 | my $ANON_SERIAL = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 459 | my %ANON_PACKAGE_CACHE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # we need a sufficiently annoying prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # this should suffice for now, this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # used in a couple of places below, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # need to put it up here for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | sub _anon_package_prefix { 'Class::MOP::Package::__ANON__::SERIAL::' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_package_prefix: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 245 | ▶ | sub is_anon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_anon: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 245 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 459 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 245 | my $prefix = $self->_anon_package_prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 245 | $self->name =~ /^\Q$prefix/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2840 | ▶ | sub create_anon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_anon: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2840 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2840 | my $cache_ok = delete $options{cache}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2840 | ▶ | $options{weaken} = !$cache_ok unless exists $options{weaken}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2840 | my $cache_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2840 | ▶ | if ($cache_ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2721 | $cache_key = $class->_anon_cache_key(%options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2718 | ▶ | undef $cache_ok if !defined($cache_key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2837 | ▶ | if ($cache_ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2718 | ▶ | if (defined $ANON_PACKAGE_CACHE{$cache_key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2155 | return $ANON_PACKAGE_CACHE{$cache_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 682 | my $package_name = $class->_anon_package_prefix . ++$ANON_SERIAL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 682 | my $meta = $class->create($package_name, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 678 | ▶ | if ($cache_ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 563 | $ANON_PACKAGE_CACHE{$cache_key} = $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 563 | weaken($ANON_PACKAGE_CACHE{$cache_key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 678 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | sub _anon_cache_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_cache_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $class->_throw_exception( PackagesAndModulesAreNotCachable => class_name => $class, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | params => \%options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | is_module => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 295 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 295 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 295 | ▶ | return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 295 | ▶ | $self->_free_anon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | if $self->is_anon; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 104 | ▶ | sub _free_anon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_free_anon: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 104 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 104 | my $name = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # Moose does a weird thing where it replaces the metaclass for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # class when fixing metaclass incompatibility. In that case, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # we don't want to clean out the namespace now. We can detect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # that because Moose will explicitly update the singleton | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # cache in Class::MOP using store_metaclass_by_name, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # means that the new metaclass will already exist in the cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # by this point. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # The other options here are that $current_meta can be undef if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # remove_metaclass_by_name is called explicitly (since the hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # entry is removed first, and then this destructor is called), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # or that $current_meta can be the same as $self, which happens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # when the metaclass goes out of scope (since the weak reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # in the metaclass cache won't be freed until after this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # destructor runs). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 104 | my $current_meta = Class::MOP::get_metaclass_by_name($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 104 | ▶ | return if defined($current_meta) && $current_meta ne $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $current_meta and $current_meta ne $self
MC/DC100%2/2
defined $current_meta and $current_meta ne $self
defined $current_meta
$current_meta ne $self
Truth table100%3/3
A and B
A= defined $current_metaB= $current_meta ne $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 97 | my ($first_fragments, $last_fragment) = ($name =~ /^(.*)::(.*)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 459 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # clear @ISA first, to avoid a memory leak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # see https://rt.perl.org/rt3/Public/Bug/Display.html?id=92708 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 97 | @{$name . '::ISA'} = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 97 | %{$name . '::'} = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 97 | delete ${$first_fragments . '::'}{$last_fragment . '::'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 97 | Class::MOP::remove_metaclass_by_name($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 97 | delete $INC{module_notional_filename($name)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 459 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1110 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1110 | ▶ | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | if $class ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1109 | ▶ | my $params = @_ == 1 ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # Need to quote package to avoid a problem with PPI mis-parsing this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # as a package statement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 'package' => $params->{package}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # because of issues with the Perl API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # to the typeglob in some versions, we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # need to just always grab a new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # reference to the hash in the accessor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Ideally we could just store a ref and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # it would Just Work, but oh well :\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1109 | namespace => \undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } => $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # all these attribute readers will be bootstrapped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # away in the Class::MOP bootstrap section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 525550 | ▶ | sub _package_stash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_package_stash: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 525550 | ▶ | $_[0]->{_package_stash} ||= Package::Stash->new($_[0]->name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_[0]{"_package_stash"} ||= "Package::Stash"->new($_[0]->name)
MC/DC0%0/2
$_[0]{"_package_stash"} ||= "Package::Stash"->new($_[0]->name)
$_[0]{"_package_stash"}
"Package::Stash"->new($_[0]->name)
Truth table66%2/3
A ||= B
A= $_[0]{"_package_stash"}B= "Package::Stash"->new($_[0]->name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $_[0]->_package_stash->namespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Class attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # ... these functions have to touch the symbol table itself,.. yuk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 184686 | ▶ | sub add_package_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_package_symbol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 184686 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 184686 | $self->_package_stash->add_symbol(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub remove_package_glob { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_package_glob: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->_package_stash->remove_glob(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # ... these functions deal with stuff on the namespace level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 43250 | ▶ | sub has_package_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_package_symbol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 43250 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 43250 | $self->_package_stash->has_symbol(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 247829 | ▶ | sub get_package_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_package_symbol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 247829 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 247829 | $self->_package_stash->get_symbol(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 46220 | ▶ | sub get_or_add_package_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_or_add_package_symbol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 46220 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 46220 | $self->_package_stash->get_or_add_symbol(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 96 | ▶ | sub remove_package_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_package_symbol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 96 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 96 | $self->_package_stash->remove_symbol(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3470 | ▶ | sub list_all_package_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_all_package_symbols: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3470 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3470 | $self->_package_stash->list_all_symbols(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 6 | ▶ | sub get_all_package_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_package_symbols: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 6 | $self->_package_stash->get_all_symbols(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 459 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # ABSTRACT: Package Meta Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||