This file is indexed.

/usr/share/perl5/Class/Trait/Reflection.pm is in libclass-trait-perl 0.31-1ubuntu1.

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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
package Class::Trait::Reflection;

use strict;
use warnings;

our $VERSION = '0.31';

use Class::Trait ();

# constructor

sub new {
    my ( $_class, $_package_or_trait ) = @_;
    my $class = ref($_class) || $_class;
    no strict 'refs';

    # accept a package or an object
    my ( $_trait, $package );
    if ( ref($_package_or_trait)
        && $_package_or_trait->isa("Class::Trait::Config") )
    {
        $_trait  = $_package_or_trait;
        $package = $_trait->name();
    }
    else {
        $package = ref($_package_or_trait) || $_package_or_trait;
        $_trait = ${"${package}::TRAITS"}->clone();
    }

    # we are gonna do that symbol table thang
    my $trait = {
        package_name => $package,

        # we want to clone the trait so that
        # we can mess with it if we want
        trait => $_trait
    };
    bless $trait, $class;
    return $trait;
}

# methods

# accessors

sub getName {
    my ($self) = @_;
    return $self->{trait}->name();
}

sub getSubTraitList {
    my ($self) = @_;
    return wantarray
      ? @{ $self->{trait}->sub_traits() }
      : $self->{trait}->sub_traits();
}

sub getRequirements {
    my ($self) = @_;
    return wantarray
      ? keys %{ $self->{trait}->requirements() }
      : [ keys %{ $self->{trait}->requirements() } ];
}

sub getMethods {
    my ($self) = @_;
    return $self->{trait}->methods();
}

sub getMethodLabels {
    my ($self) = @_;
    return wantarray
      ? keys %{ $self->{trait}->methods }
      : [ keys %{ $self->{trait}->methods } ];
}

sub getConflicts {
    my ($self) = @_;
    return wantarray
      ? keys %{ $self->{trait}->conflicts() }
      : [ keys %{ $self->{trait}->conflicts() } ];
}

sub getOverloads {
    my ($self) = @_;
    return $self->{trait}->overloads();
}

sub getOperators {
    my ($self) = @_;
    return wantarray
      ? keys %{ $self->{trait}->overloads }
      : [ keys %{ $self->{trait}->overloads } ];
}

# other methods

sub loadSubTraitByName {
    my ( $self, $trait_name ) = @_;
    return $self->new( Class::Trait::load_trait($trait_name) );
}

sub getTraitDump {
    my ($self) = @_;
    require Data::Dumper;
    return Data::Dumper::Dumper( { %{ $self->{trait} } } );
}

sub traverse {
    my ( $trait, $function, $depth ) = @_;
    $depth ||= 0;
    $function->( $trait, $depth );
    foreach my $sub_trait_name ( $trait->getSubTraitList() ) {
        my $sub_trait = $trait->loadSubTraitByName($sub_trait_name);
        $sub_trait->traverse( $function, $depth + 1 );
    }
}

1;

__END__

=head1 NAME

Class::Trait::Reflection - Reflection class used to find information about
classes which use Traits.

=head1 SYNOPSIS

The Class::Trait::Reflection class used to find information about classes
which use Traits.

=head1 DESCRIPTION

This class is to be used by other applications as a foundation from which to
build various trait compostion tools. It attempts to decouple others from the
internal representation of traits (currently the Class::Trait::Config object)
and provide a more abstract view of them.

=head1 METHODS

=head2 constructor

=over 4

=item B<new>

If given either a I<Class::Trait::Config object>, I<a blessed perl object
which uses traits> or I<a valid perl package name which uses traits>. This
constructor will return a valid Class::Trait::Reflection object which can be
used to examine the specific properties of the traits utilized.

=back

=head2 accessors

=over 4

=item B<getName>

Returns the name string for the trait.

=item B<getSubTraitList>

Returns an array or an array ref in scalar context) of string names of all the
sub-traits the trait includes.

=item B<getRequirements>

Returns an array (or an array ref in scalar context) of method labels and
operators which represent the requirements for the given trait.

=item B<getMethods>

Returns an hash ref of method label strings to method subroutine references.

=item B<getMethodLabels>

Returns an array (or an array ref in scalar context) of method label strings.

=item B<getConflicts>

Returns an array (or an array ref in scalar context) of method labels and
operators which are in conflict for a given trait. This is only applicable for
COMPOSITE traits.

=item B<getOverloads>

Returns an hash ref of operators to method label strings.

=item B<getOperators>

Returns an array (or an array ref in scalar context) of all the operators for
a given trait.

=back

=head2 Utility methods

=over 4

=item B<loadSubTraitByName>

Given a trait name, this method attempts to load the trait using the
Class::Trait module, and then uses that trait to construct a new
Class::Trait::Reflection object to examine the trait with. This can function
both as a class method and an instance method. 

=item B<getTraitDump>

Returns a Data::Dumper string of the internals of a Class::Trait::Config
object. 

=item B<traverse>

Given a subroutine reference, this method can be used to traverse a trait
heirarchy. The subroutine reference needs to take two parameters, the first is
the current trait being examined, the second is the number representing the
depth within the trait heirarchy. 

Here is an example of printing out the trait heirarchy as tabbed in names:

    my $reflected_trait = Class::Trait::Reflection->new($object_or_package);
    
    $reflected_trait->traverse(sub {
        my ($trait, $depth) = @_;
        print(("   " x $depth), $trait->getName(), "\n");
    });

This should produce output similar to this:

    COMPOSITE
        TCircle
            TMagnitude
                TEquality
            TGeometry
        TColor
            TEquality

Note: COMPOSITE is the placeholder name for an unnamed composite trait such as
the one found in a class.

=back

=head1 SEE ALSO

B<Class::Trait>, B<Class::Trait::Config>

=head1 AUTHOR

Stevan Little E<lt>stevan@iinteractive.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2004, 2005 by Infinity Interactive, Inc.

L<http://www.iinteractive.com> 

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. 

=cut