This file is indexed.

/usr/share/perl5/Class/MakeMethods/Emulator.pm is in libclass-makemethods-perl 1.01-5.

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
package Class::MakeMethods::Emulator;

$VERSION = 1.009;

########################################################################
### IMPORT BEHAVIOR: import(), _handle_namespace()
########################################################################

@EXPORT_OK = qw( namespace_capture namespace_release );
sub import { 
  
  if ( scalar @_ == 2 and $_[1] eq '-isasubclass' ) {
    splice @_, 1, 1;
    my $target_class = ( caller )[0];
    no strict;
    push @{"$target_class\::ISA"}, $_[0];
  }
  
  if ( $_[0] eq __PACKAGE__ ) {
    require Exporter and goto &Exporter::import  # lazy Exporter
  }
}

sub _handle_namespace {
  my $class = shift;
  my $emulation_target = shift;
  my $firstarg = shift or return;
  my $take = shift || '-take_namespace';
  my $release = shift || '-release_namespace';
  
  if ( $firstarg eq $take) {
    Class::MakeMethods::Emulator::namespace_capture($class, $emulation_target);
    return 1;
  } elsif ( $firstarg eq $release) {
    Class::MakeMethods::Emulator::namespace_release($class, $emulation_target);
    return 1;
  }
}

########################################################################
### NAMESPACE MUNGING: _namespace_capture(), _namespace_release()
########################################################################

sub namespace_capture {
  my $source_package = shift;
  my $target_package = shift;

  # warn "Mapping $source_package over $target_package \n";

  my $source_file = "$source_package.pm";
  $source_file =~ s{::}{/}g;
  
  my $target_file = "$target_package.pm";
  $target_file =~ s{::}{/}g;
  
  my $temp_package = $source_package . '::Target::' . $target_package;
  my $temp_file = "$temp_package.pm";
  $temp_file =~ s{::}{/}g;
  
  no strict;
  unless ( ${$temp_package . "::TargetCaptured"} ++ ) {
    *{$temp_package . "::"} = *{$target_package . "::"};
    $::INC{$temp_file} = $::INC{$target_file};
  }
  *{$target_package . "::"} = *{$source_package . "::"};
  $::INC{$target_file} = $::INC{$source_file}
}

sub namespace_release {
  my $source_package = shift;
  my $target_package = shift;
  
  my $target_file = "$target_package.pm";
  $target_file =~ s{::}{/}g;
  
  my $temp_package = $source_package . '::Target::' . $target_package;
  my $temp_file = "$temp_package.pm";
  $temp_file =~ s{::}{/}g;
  
  no strict;
  unless ( ${"${temp_package}::TargetCaptured"} ) {
    Carp::croak("Can't _namespace_release: -take_namespace not called yet.");
  }
  *{$target_package . "::"} = *{$temp_package. "::"};
  $::INC{$target_file} = $::INC{$temp_file};
}

########################################################################

1;

__END__


=head1 NAME

Class::MakeMethods::Emulator - Demonstrate class-generator equivalency


=head1 SYNOPSIS

  # Equivalent to use Class::Singleton;
  use Class::MakeMethods::Emulator::Singleton; 
  
  # Equivalent to use Class::Struct;
  use Class::MakeMethods::Emulator::Struct; 
  struct ( ... );
  
  # Equivalent to use Class::MethodMaker( ... );
  use Class::MakeMethods::Emulator::MethodMaker( ... );
  
  # Equivalent to use base 'Class::Inheritable';
  use base 'Class::MakeMethods::Emulator::Inheritable';
  MyClass->mk_classdata( ... );
  
  # Equivalent to use base 'Class::AccessorFast';
  use base 'Class::MakeMethods::Emulator::AccessorFast';
  MyClass->mk_accessors(qw(this that whatever));
  
  # Equivalent to use accessors( ... );
  use Class::MakeMethods::Emulator::accessors( ... );
  
  # Equivalent to use mcoder( ... );
  use Class::MakeMethods::Emulator::mcoder( ... );


=head1 DESCRIPTION

In several cases, Class::MakeMethods provides functionality closely
equivalent to that of an existing module, and it is simple to map
the existing module's interface to that of Class::MakeMethods.

Class::MakeMethods::Emulator provides emulators for Class::MethodMaker,
Class::Accessor::Fast, Class::Data::Inheritable, Class::Singleton,
Class::Struct, accessors, and mcoder, each of which passes the
original module's test suite, usually requiring only the addition
of a a single line to each test, activating the emulation module.

Beyond demonstrating compatibility, these emulators also generally
indicate the changes needed to switch to direct use of Class::MakeMethods
functionality, illustrate commonalities between the various modules,
and serve as a source for new ideas that can be integrated into
Class::MakeMethods.


=head1 SEE ALSO

See L<Class::MakeMethods> for general information about this distribution. 

See L<Class::MakeMethods::Emulator::accessors>, and L<accessors> from CPAN.

See L<Class::MakeMethods::Emulator::Struct>, and L<Class::Struct> from CPAN.

See L<Class::MakeMethods::Emulator::AccessorFast>, and L<Class::Accessor::Fast> from CPAN.

See L<Class::MakeMethods::Emulator::Inheritable>, and L<Class::Data::Inheritable> from CPAN.

See L<Class::MakeMethods::Emulator::MethodMaker>, and L<Class::MethodMaker> from CPAN.

See L<Class::MakeMethods::Emulator::Singleton>, and L<Class::Singleton> from CPAN.

See L<Class::MakeMethods::Emulator::mcoder>, and L<mcoder> from CPAN.

=cut