| 1 | package MOP::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: For MOP External Use Only | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use MOP::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use MOP::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use MOP::Internal::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | our $VERSION = '0.14'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | sub get_meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_meta: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | my ($package) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | return $package->METACLASS->new( $package ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | if $package->can('METACLASS'); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | my $meta = MOP::Role->new( $package ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | my $isa = MOP::Internal::Util::GET_GLOB_SLOT( $meta->stash, 'ISA', 'ARRAY' ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # without inheritance, we assume it is a role ... | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | return $meta | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $isa or ref $isa eq "ARRAY" and scalar @$isa == 0
ref $isa eq "ARRAY" and scalar @$isa == 0
MC/DC33%1/3
defined $isa or ref $isa eq "ARRAY" and scalar @$isa == 0
defined $isa
ref $isa eq "ARRAY"
scalar @$isa == 0
Truth table50%2/4
A or B and C
A= defined $isaB= ref $isa eq "ARRAY"C= scalar @$isa == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | if not defined $isa | ||||||||||||||||||||||||||||||||||||||||||
| 26 | || (ref $isa eq 'ARRAY' && scalar @$isa == 0); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # with inheritance, we know it is a class .... | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | return MOP::Class->new( $package ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | sub compose_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compose_roles: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | my ($meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | my @roles = $meta->roles; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | MOP::Internal::Util::APPLY_ROLES( $meta, \@roles ) if @roles; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub inherit_slots { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inherit_slots: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # roles don't inherit, so do nothing ... | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return unless $meta->isa('MOP::Class'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # otherwise, inherit only the slots from | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # the direct superclasses, this assumes that | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # these superclasses have already done | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # INHERIT_SLOTS themselves. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | foreach my $super ( map { MOP::Role->new( name => $_ ) } $meta->superclasses ) { | |||||||||||||||||||||||||||||||||||||||||
| 51 | # remember to use all_slots so that it | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # will gives us *all* the slots, including | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # those that are themselves inherited ... | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | foreach my $slot ( $super->all_slots ) { | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $slot_name = $slot->name; | |||||||||||||||||||||||||||||||||||||||||
| 56 | # we always just alias this anyway ... | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $meta->alias_slot( $slot_name, $slot->initializer ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$meta->has_slot($slot_name) or $meta->has_slot_alias($slot_name)
MC/DC0%0/2
$meta->has_slot($slot_name) or $meta->has_slot_alias($slot_name)
$meta->has_slot($slot_name)
$meta->has_slot_alias($slot_name)
Truth table0%0/3
A or B
A= $meta->has_slot($slot_name)B= $meta->has_slot_alias($slot_name)
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | unless $meta->has_slot( $slot_name ) | ||||||||||||||||||||||||||||||||||||||||||
| 59 | || $meta->has_slot_alias( $slot_name ); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | # nothing to return ... | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | sub defer_until_UNITCHECK { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defer_until_UNITCHECK: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | my ($cb) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | MOP::Internal::Util::ADD_UNITCHECK_HOOK( $cb ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||||||||||||||||