This file is indexed.

/usr/share/perl5/MooseX/Declare/Syntax/KeywordHandling.pm is in libmoosex-declare-perl 0.43-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
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
package MooseX::Declare::Syntax::KeywordHandling;
# ABSTRACT: Basic keyword functionality

our $VERSION = '0.43';

use Moose::Role;
use Moose::Util::TypeConstraints qw(subtype as where);
use Devel::Declare ();
use Sub::Install qw( install_sub );
use Moose::Meta::Class ();
use Module::Runtime 'use_module';

use aliased 'MooseX::Declare::Context';

use namespace::autoclean -also => ['_uniq'];

#pod =head1 DESCRIPTION
#pod
#pod This role provides the functionality common for all keyword handlers
#pod in L<MooseX::Declare>.
#pod
#pod =head1 REQUIRED METHODS
#pod
#pod =head2 parse
#pod
#pod   Object->parse (Object $context)
#pod
#pod This method must implement the actual parsing of the keyword syntax.
#pod
#pod =cut

requires qw(
    parse
);

#pod =attr identifier
#pod
#pod This is the name of the actual keyword. It is a required string that is in
#pod the same format as a usual Perl identifier.
#pod
#pod =cut

has identifier => (
    is          => 'ro',
    isa         => subtype(as 'Str', where { /^ [_a-z] [_a-z0-9]* $/ix }),
    required    => 1,
);

#pod =method get_identifier
#pod
#pod   Str Object->get_identifier ()
#pod
#pod Returns the name the handler will be setup under.
#pod
#pod =cut

sub get_identifier { shift->identifier }

sub context_class { Context }

sub context_traits { }

#pod =method setup_for
#pod
#pod   Object->setup_for (ClassName $class, %args)
#pod
#pod This will setup the handler in the specified C<$class>. The handler will
#pod dispatch to the L</parse_declaration> method when the keyword is used.
#pod
#pod A normal code reference will also be exported into the calling namespace.
#pod It will either be empty or, if a C<generate_export> method is provided,
#pod the return value of that method.
#pod
#pod =cut

sub setup_for {
    my ($self, $setup_class, %args) = @_;

    # make sure the stack is valid
    my $stack = $args{stack} || [];
    my $ident = $self->get_identifier;

    # setup the D:D handler for our keyword
    Devel::Declare->setup_for($setup_class, {
        $ident => {
            const => sub { $self->parse_declaration((caller(1))[1], \%args, @_) },
        },
    });

    # search or generate a real export
    my $export = $self->can('generate_export') ? $self->generate_export($setup_class) : sub { };

    # export subroutine
    install_sub({
        code    => $export,
        into    => $setup_class,
        as      => $ident,
    }) unless $setup_class->can($ident);

    return 1;
}

#pod =method parse_declaration
#pod
#pod   Object->parse_declaration (Str $filename, HashRef $setup_args, @call_args)
#pod
#pod This simply creates a new L<context|MooseX::Declare::Context> and passes it
#pod to the L</parse> method.
#pod
#pod =cut

sub parse_declaration {
    my ($self, $caller_file, $args, @ctx_args) = @_;

    # find and load context object class
    my $ctx_class = $self->context_class;
    use_module $ctx_class;

    # do we have traits?
    if (my @ctx_traits = _uniq($self->context_traits)) {

        use_module $_
            for @ctx_traits;

        $ctx_class = Moose::Meta::Class->create_anon_class(
            superclasses => [$ctx_class],
            roles        => [@ctx_traits],
            cache        => 1,
        )->name;
    }

    # create a context object and initialize it
    my $ctx = $ctx_class->new(
        %{ $args },
        caller_file => $caller_file,
    );
    $ctx->init(@ctx_args);

    # parse with current context
    return $self->parse($ctx);
}

sub _uniq { keys %{ +{ map { $_ => undef } @_ } } }

#pod =head1 SEE ALSO
#pod
#pod =for :list
#pod * L<MooseX::Declare>
#pod * L<MooseX::Declare::Context>
#pod
#pod =cut

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

MooseX::Declare::Syntax::KeywordHandling - Basic keyword functionality

=head1 VERSION

version 0.43

=head1 DESCRIPTION

This role provides the functionality common for all keyword handlers
in L<MooseX::Declare>.

=head1 ATTRIBUTES

=head2 identifier

This is the name of the actual keyword. It is a required string that is in
the same format as a usual Perl identifier.

=head1 METHODS

=head2 get_identifier

  Str Object->get_identifier ()

Returns the name the handler will be setup under.

=head2 setup_for

  Object->setup_for (ClassName $class, %args)

This will setup the handler in the specified C<$class>. The handler will
dispatch to the L</parse_declaration> method when the keyword is used.

A normal code reference will also be exported into the calling namespace.
It will either be empty or, if a C<generate_export> method is provided,
the return value of that method.

=head2 parse_declaration

  Object->parse_declaration (Str $filename, HashRef $setup_args, @call_args)

This simply creates a new L<context|MooseX::Declare::Context> and passes it
to the L</parse> method.

=head1 REQUIRED METHODS

=head2 parse

  Object->parse (Object $context)

This method must implement the actual parsing of the keyword syntax.

=head1 SEE ALSO

=over 4

=item *

L<MooseX::Declare>

=item *

L<MooseX::Declare::Context>

=back

=head1 AUTHOR

Florian Ragwitz <rafl@debian.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2008 by Florian Ragwitz.

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

=cut