| 1 | package Class::Easy; | ||
| 2 | |||
| 3 | use Class::Easy::Import; | ||
| 4 | |||
| 5 | sub __get_linear_isa_dfs { | ||
| 6 | my $classname = shift; | ||
| 7 | |||
| 8 | my @lin = ($classname); | ||
| 9 | my %stored; | ||
| 10 | foreach my $parent (@{"$classname\::ISA"}) { | ||
| 11 | my $plin = __get_linear_isa_dfs($parent); | ||
| 12 | foreach (@$plin) { | ||
| 13 | next if exists $stored{$_}; | ||
| 14 | push(@lin, $_); | ||
| 15 | $stored{$_} = 1; | ||
| 16 | } | ||
| 17 | } | ||
| 18 | return \@lin; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub __get_linear_isa { | ||
| 22 | my ($classname, $type) = @_; | ||
| 23 | die "mro::get_mro requires a classname" | ||
| 24 | if !defined $classname; | ||
| 25 | |||
| 26 | $type ||= exists $Class::C3::MRO{$classname} ? 'c3' : 'dfs'; | ||
| 27 | if($type eq 'dfs') { | ||
| 28 | return __get_linear_isa_dfs($classname); | ||
| 29 | } elsif($type eq 'c3') { | ||
| 30 | return [Class::C3::calculateMRO($classname)]; | ||
| 31 | } | ||
| 32 | die "type argument must be 'dfs' or 'c3'"; | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; |