line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Declare::Syntax::Keyword::Namespace; |
2
|
|
|
|
|
|
|
# ABSTRACT: Declare outer namespace |
3
|
|
|
|
|
|
|
$MooseX::Declare::Syntax::Keyword::Namespace::VERSION = '0.39'; |
4
|
24
|
|
|
24
|
|
21987
|
use Moose; |
|
24
|
|
|
|
|
60
|
|
|
24
|
|
|
|
|
198
|
|
5
|
24
|
|
|
24
|
|
181848
|
use Carp qw( confess ); |
|
24
|
|
|
|
|
71
|
|
|
24
|
|
|
|
|
1709
|
|
6
|
|
|
|
|
|
|
|
7
|
24
|
|
|
24
|
|
155
|
use MooseX::Declare::Util qw( outer_stack_push outer_stack_peek ); |
|
24
|
|
|
|
|
59
|
|
|
24
|
|
|
|
|
219
|
|
8
|
|
|
|
|
|
|
|
9
|
24
|
|
|
24
|
|
14387
|
use namespace::clean -except => 'meta'; |
|
24
|
|
|
|
|
163
|
|
|
24
|
|
|
|
|
281
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod use MooseX::Declare; |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod namespace Foo::Bar; |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod class ::Baz extends ::Qux with ::Fnording { |
18
|
|
|
|
|
|
|
#pod ... |
19
|
|
|
|
|
|
|
#pod } |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod The C<namespace> keyword allows you to declare an outer namespace under |
24
|
|
|
|
|
|
|
#pod which other namespaced constructs can be nested. The L</SYNOPSIS> is |
25
|
|
|
|
|
|
|
#pod effectively the same as |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod use MooseX::Declare; |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod class Foo::Bar::Baz extends Foo::Bar::Qux with Foo::Bar::Fnording { |
30
|
|
|
|
|
|
|
#pod ... |
31
|
|
|
|
|
|
|
#pod } |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod =head1 CONSUMES |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod =for :list |
36
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::KeywordHandling> |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
with qw( |
41
|
|
|
|
|
|
|
MooseX::Declare::Syntax::KeywordHandling |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#pod =method parse |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod Object->parse(Object $context) |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod Will skip the declarator, parse the namespace and push the namespace |
49
|
|
|
|
|
|
|
#pod in the file package stack. |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod =cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub parse { |
54
|
2
|
|
|
2
|
1
|
6
|
my ($self, $ctx) = @_; |
55
|
|
|
|
|
|
|
|
56
|
2
|
50
|
|
|
|
90
|
confess "Nested namespaces are not supported yet" |
57
|
|
|
|
|
|
|
if outer_stack_peek $ctx->caller_file; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
12
|
$ctx->skip_declarator; |
60
|
2
|
50
|
|
|
|
126
|
my $namespace = $ctx->strip_word |
61
|
|
|
|
|
|
|
or confess "Expected a namespace argument to use from here on"; |
62
|
|
|
|
|
|
|
|
63
|
2
|
50
|
|
|
|
114
|
confess "Relative namespaces are currently not supported" |
64
|
|
|
|
|
|
|
if $namespace =~ /^::/; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
8
|
$ctx->skipspace; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
45
|
my $next_char = $ctx->peek_next_char; |
69
|
2
|
50
|
|
|
|
40
|
confess "Expected end of statement after namespace argument" |
70
|
|
|
|
|
|
|
unless $next_char eq ';'; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
94
|
outer_stack_push $ctx->caller_file, $namespace; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod =for :list |
78
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
79
|
|
|
|
|
|
|
#pod |
80
|
|
|
|
|
|
|
#pod =cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding UTF-8 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
MooseX::Declare::Syntax::Keyword::Namespace - Declare outer namespace |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
version 0.39 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
use MooseX::Declare; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
namespace Foo::Bar; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
class ::Baz extends ::Qux with ::Fnording { |
105
|
|
|
|
|
|
|
... |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The C<namespace> keyword allows you to declare an outer namespace under |
111
|
|
|
|
|
|
|
which other namespaced constructs can be nested. The L</SYNOPSIS> is |
112
|
|
|
|
|
|
|
effectively the same as |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
use MooseX::Declare; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
class Foo::Bar::Baz extends Foo::Bar::Qux with Foo::Bar::Fnording { |
117
|
|
|
|
|
|
|
... |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 METHODS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 parse |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Object->parse(Object $context) |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Will skip the declarator, parse the namespace and push the namespace |
127
|
|
|
|
|
|
|
in the file package stack. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 CONSUMES |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::KeywordHandling> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over 4 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<MooseX::Declare> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
158
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |