line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Sugar::Args; |
2
|
|
|
|
|
|
|
# $Id: Args.pm,v 1.1 2003/09/30 22:06:19 cwest Exp $ |
3
|
1
|
|
|
1
|
|
32787
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1138
|
use POE::Session; |
|
1
|
|
|
|
|
7594
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
1157
|
use Devel::Caller::Perl qw[called_args]; |
|
1
|
|
|
|
|
7566
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
1037
|
use Exporter::Lite; |
|
1
|
|
|
|
|
752
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
54
|
use vars qw[$VERSION @EXPORT]; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
366
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.3'; |
11
|
|
|
|
|
|
|
@EXPORT = qw[sweet_args]; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
POE::Sugar::Args - Get "pretty", OO representation of args. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use POE::Sugar::Args; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _start { |
22
|
|
|
|
|
|
|
my $poe = sweet_args; |
23
|
|
|
|
|
|
|
$poe->kernel->yield( '_stop' ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# or, the long, boring way |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _stop { |
29
|
|
|
|
|
|
|
my $poe = POE::Sugar::Args->new( @_ ); |
30
|
|
|
|
|
|
|
delete $poe->heap->{client}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 ABSTRACT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module give an OO representation to arguments POE passes to event |
36
|
|
|
|
|
|
|
states. I will not lie to you. This adds heavy, bulky code underneath. |
37
|
|
|
|
|
|
|
On the other hand, it makes arguments for POE events much more |
38
|
|
|
|
|
|
|
palatable. Of course, this is a Sugar module, meaning, it will rot |
39
|
|
|
|
|
|
|
your program in odd (you'll be hooked) and unexpected ways (performace), |
40
|
|
|
|
|
|
|
but you took the candy so you can suffer the consequences. Good luck. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 Exports |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head3 sweet_args |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This function will get C<@_> from the calling state by doing deep, |
49
|
|
|
|
|
|
|
dark voodoo. It will construct the C object for |
50
|
|
|
|
|
|
|
you. Very handy. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 Methods |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head3 new |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Constructs an object. Expects all of C<@_> that's passed to an event |
57
|
|
|
|
|
|
|
state. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head3 object |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
If this state was initialized as an C in the session, |
62
|
|
|
|
|
|
|
the object will be here. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 session |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L object. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head3 kernel |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L object. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head3 heap |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Your heap. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head3 state |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Event name that invoked the state. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 sender |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Reference to the session that send the event. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 caller_file |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The calling file. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head3 caller_line |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The calling line. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head3 args |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
All arguments this event was called with. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
3
|
1
|
607
|
sub sweet_args { __PACKAGE__->new( called_args ) } |
99
|
4
|
|
|
4
|
1
|
709
|
sub new { bless [ @_[1..$#_] ], $_[0] } |
100
|
0
|
|
|
0
|
1
|
0
|
sub object { $_[0]->[OBJECT] } |
101
|
2
|
|
|
2
|
1
|
674
|
sub session { $_[0]->[SESSION] } |
102
|
4
|
|
|
4
|
1
|
24
|
sub kernel { $_[0]->[KERNEL] } |
103
|
0
|
|
|
0
|
1
|
0
|
sub heap { $_[0]->[HEAP] } |
104
|
0
|
|
|
0
|
1
|
0
|
sub state { $_[0]->[STATE] } |
105
|
0
|
|
|
0
|
1
|
0
|
sub sender { $_[0]->[SENDER] } |
106
|
0
|
|
|
0
|
1
|
0
|
sub caller_file { $_[0]->[CALLER_FILE] } |
107
|
0
|
|
|
0
|
1
|
0
|
sub caller_line { $_[0]->[CALLER_LINE] } |
108
|
|
|
|
|
|
|
sub args { wantarray ? |
109
|
0
|
|
|
|
|
0
|
@{$_[0]}[ARG0 .. $#{$_[0]}] : |
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
7
|
|
110
|
2
|
50
|
|
2
|
1
|
13
|
[ @{$_[0]}[ARG0 .. $#{$_[0]}] ] } |
|
2
|
|
|
|
|
4
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |