/usr/share/perl5/Object/InsideOut/Dynamic.pm is in libobject-insideout-perl 3.97-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 179 180 181 182 183 184 185 | package Object::InsideOut; {
use strict;
use warnings;
no warnings 'redefine';
sub create_field
{
my ($GBL, $call, @args) = @_;
push(@{$$GBL{'export'}}, 'create_field');
if ($call eq 'create_field') {
$$GBL{'init'} = 1;
}
# Dynamically create a new object field
*Object::InsideOut::create_field = sub
{
# Handle being called as a method or subroutine
if ($_[0] eq 'Object::InsideOut') {
shift;
}
my ($class, $field, @attrs) = @_;
# Verify valid class
if (! $class->isa('Object::InsideOut')) {
OIO::Args->die(
'message' => 'Not an Object::InsideOut class',
'Arg' => $class);
}
# Check for valid field
if ($field !~ /^\s*[@%]\s*[a-zA-Z_]\w*\s*$/) {
OIO::Args->die(
'message' => 'Not an array or hash declaration',
'Arg' => $field);
}
# Convert attributes to single string
my $attr;
if (@attrs) {
s/^\s*(.*?)\s*$/$1/ foreach @attrs;
$attr = join(',', @attrs);
$attr =~ s/[\r\n]/ /sg;
$attr =~ s/,\s*,/,/g;
$attr =~ s/\s*,\s*:/ :/g;
if ($attr !~ /^\s*:/) {
$attr = ":Field($attr)";
}
} else {
$attr = ':Field';
}
# Create the declaration
my @errs;
local $SIG{'__WARN__'} = sub { push(@errs, @_); };
my $code = "package $class; my $field $attr;";
eval $code;
if (my $e = Exception::Class::Base->caught()) {
die($e);
}
if ($@ || @errs) {
my ($err) = split(/ at /, $@ || join(" | ", @errs));
OIO::Code->die(
'message' => 'Failure creating field',
'Error' => $err,
'Code' => $code);
}
# Invalidate object initialization activity cache
delete($$GBL{'cache'});
# Process the declaration
process_fields();
};
# Runtime hierarchy building
*Object::InsideOut::add_class = sub
{
my $class = shift;
if (ref($class)) {
OIO::Method->die('message' => q/'add_class' called as an object method/);
}
if ($class eq 'Object::InsideOut') {
OIO::Method->die('message' => q/'add_class' called on non-class 'Object::InsideOut'/);
}
if (! $class->isa('Object::InsideOut')) {
OIO::Method->die('message' => "'add_class' called on non-Object::InsideOut class '$class'");
}
my $pkg = shift;
if (! $pkg) {
OIO::Args->die(
'message' => 'Missing argument',
'Usage' => "$class\->add_class(\$class)");
}
# Already in the hierarchy - ignore
return if ($class->isa($pkg));
no strict 'refs';
# If no package symbols, then load it
if (! grep { $_ !~ /::$/ } keys(%{$pkg.'::'})) {
eval "require $pkg";
if ($@) {
OIO::Code->die(
'message' => "Failure loading package '$pkg'",
'Error' => $@);
}
# Empty packages make no sense
if (! grep { $_ !~ /::$/ } keys(%{$pkg.'::'})) {
OIO::Code->die('message' => "Package '$pkg' is empty");
}
}
# Import the package, if needed
if (@_) {
eval { $pkg->import(@_); };
if ($@) {
OIO::Code->die(
'message' => "Failure running 'import' on package '$pkg'",
'Error' => $@);
}
}
my $tree_bu = $$GBL{'tree'}{'bu'};
my $tree_td = $$GBL{'tree'}{'td'};
# Foreign class added
if (! exists($$tree_bu{$pkg})) {
# Get inheritance 'classes' hash
if (! exists($$GBL{'heritage'}{$class})) {
create_heritage($class);
}
# Add package to inherited classes
$$GBL{'heritage'}{$class}{'cl'}{$pkg} = undef;
return;
}
# Add to class trees
foreach my $cl (keys(%{$tree_bu})) {
next if (! grep { $_ eq $class } @{$$tree_bu{$cl}});
# Splice in the added class's tree
my @tree;
foreach (@{$$tree_bu{$cl}}) {
push(@tree, $_);
if ($_ eq $class) {
my %seen;
@seen{@{$$tree_bu{$cl}}} = undef;
foreach (@{$$tree_bu{$pkg}}) {
push(@tree, $_) if (! exists($seen{$_}));
}
}
}
# Add to @ISA array
push(@{$cl.'::ISA'}, $pkg);
# Save revised trees
$$tree_bu{$cl} = \@tree;
@{$$tree_td{$cl}} = reverse(@tree);
}
$$GBL{'asi'}{$pkg}{$class} = undef;
};
# Invalidate object initialization activity cache
delete($$GBL{'cache'});
# Do the original call
@_ = @args;
goto &$call;
}
} # End of package's lexical scope
# Ensure correct versioning
($Object::InsideOut::VERSION == 3.97)
or die("Version mismatch\n");
# EOF
|