/usr/share/perl5/Object/InsideOut/Autoload.pm is in libobject-insideout-perl 4.02-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | package Object::InsideOut; {
use strict;
use warnings;
no warnings 'redefine';
# Handles :Automethods and foreign inheritance
sub AUTOLOAD
{
my ($GBL, @args) = @_;
push(@{$$GBL{'export'}}, 'AUTOLOAD');
$$GBL{'init'} = 1;
*Object::InsideOut::AUTOLOAD = sub
{
my $thing = $_[0];
# Extract the class and method names from the fully-qualified name
my ($class, $method) = our $AUTOLOAD =~ /(.*)::(.*)/;
# Handle superclass calls
my $super;
if ($class =~ /::SUPER$/) {
$class =~ s/::SUPER//;
$super = 1;
}
my $heritage = $$GBL{'heritage'};
my $automethods = $$GBL{'sub'}{'auto'};
# Find a something to handle the method call
my ($code_type, $code_dir, %code_refs);
foreach my $pkg (@{$$GBL{'tree'}{'bu'}{$class}}) {
# Skip self's class if SUPER
if ($super && $class eq $pkg) {
next;
}
# Check with heritage objects/classes
if (exists($$heritage{$pkg})) {
my $objects = $$heritage{$pkg}{'obj'};
my $classes = $$heritage{$pkg}{'cl'};
if (Scalar::Util::blessed($thing)) {
if (exists($$objects{$$thing})) {
# Check objects
foreach my $obj (@{$$objects{$$thing}}) {
if (my $code = $obj->can($method)) {
shift;
unshift(@_, $obj);
goto $code;
}
}
} else {
# Check classes
foreach my $pkg (keys(%{$classes})) {
if (my $code = $pkg->can($method)) {
@_ = @_; # Perl 5.8.5 bug workaround
goto $code;
}
}
}
} else {
# Check classes
foreach my $pkg (keys(%{$classes})) {
if (my $code = $pkg->can($method)) {
shift;
unshift(@_, $pkg);
goto $code;
}
}
}
}
# Check with Automethod
if (my $automethod = $$automethods{$pkg}) {
# Call the Automethod to get a code ref
local $CALLER::_ = $_;
local $_ = $method;
local $SIG{'__DIE__'} = 'OIO::trap';
if (my ($code, $ctype) = $automethod->(@_)) {
if (ref($code) ne 'CODE') {
# Delete defective automethod
delete($$automethods{$pkg});
# Not a code ref
OIO::Code->die(
'message' => ':Automethod did not return a code ref',
'Info' => "NOTICE: The defective :Automethod in package '$pkg' has been DELETED!",
'Code' => ":Automethod in package '$pkg' invoked for method '$method'");
}
if (defined($ctype)) {
my ($type, $dir) = $ctype =~ /(\w+)(?:[(]\s*(.*)\s*[)])?/;
if ($type && $type =~ /CUM/i) {
if ($code_type) {
$type = ':Cumulative';
$dir = ($dir && $dir =~ /BOT/i) ? 'bottom up' : 'top down';
if ($code_type ne $type || $code_dir ne $dir) {
# Mixed types
my ($pkg2) = keys(%code_refs);
OIO::Code->die(
'message' => 'Inconsistent code types returned by :Automethods',
'Info' => "Class '$pkg' returned type $type($dir), and class '$pkg2' returned type $code_type($code_dir)");
}
} else {
$code_type = ':Cumulative';
$code_dir = ($dir && $dir =~ /BOT/i) ? 'bottom up' : 'top down';
}
$code_refs{$pkg} = $code;
next;
}
if ($type && $type =~ /CHA/i) {
if ($code_type) {
$type = ':Chained';
$dir = ($dir && $dir =~ /BOT/i) ? 'bottom up' : 'top down';
if ($code_type ne $type || $code_dir ne $dir) {
# Mixed types
my ($pkg2) = keys(%code_refs);
OIO::Code->die(
'message' => 'Inconsistent code types returned by :Automethods',
'Info' => "Class '$pkg' returned type $type($dir), and class '$pkg2' returned type $code_type($code_dir)");
}
} else {
$code_type = ':Chained';
$code_dir = ($dir && $dir =~ /BOT/i) ? 'bottom up' : 'top down';
}
$code_refs{$pkg} = $code;
next;
}
# Unknown automethod code type
OIO::Code->die(
'message' => "Unknown :Automethod code type: $ctype",
'Info' => ":Automethod in package '$pkg' invoked for method '$method'");
}
if ($code_type) {
# Mixed types
my ($pkg2) = keys(%code_refs);
OIO::Code->die(
'message' => 'Inconsistent code types returned by :Automethods',
'Info' => "Class '$pkg' returned an 'execute immediately' type, and class '$pkg2' returned type $code_type($code_dir)");
}
# Just a one-shot - execute it
@_ = @_; # Perl 5.8.5 bug workaround
goto $code;
}
}
}
if ($code_type) {
my $tree = ($code_dir eq 'bottom up') ? $$GBL{'tree'}{'bu'} : $$GBL{'tree'}{'td'};
my $code = ($code_type eq ':Cumulative')
? create_CUMULATIVE($method, $tree, \%code_refs)
: create_CHAINED($method, $tree, \%code_refs);
@_ = @_; # Perl 5.8.5 bug workaround
goto $code;
}
# Failed to AUTOLOAD
my $type = ref($thing) ? 'object' : 'class';
OIO::Method->die('message' => qq/Can't locate $type method "$method" via package "$class"/);
};
# Do the original call
@_ = @args;
goto &Object::InsideOut::AUTOLOAD;
}
} # End of package's lexical scope
# Ensure correct versioning
($Object::InsideOut::VERSION eq '4.02')
or die("Version mismatch\n");
# EOF
|