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