ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Strict.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Strict.pm (file contents):
Revision 1.10 by root, Wed Apr 1 14:02:27 2009 UTC vs.
Revision 1.22 by root, Sun Nov 14 02:24:52 2010 UTC

21 21
22=cut 22=cut
23 23
24package AnyEvent::Strict; 24package AnyEvent::Strict;
25 25
26no warnings; # *sigh*
27
28use Carp qw(croak); 26use Carp qw(croak);
29 27
30use AnyEvent (); 28use AnyEvent (); BEGIN { AnyEvent::common_sense }
29
30our @ISA;
31 31
32AnyEvent::post_detect { 32AnyEvent::post_detect {
33 # assume the first ISA member is the implementation 33 # assume the first ISA member is the implementation
34 # # and link us in before it in the chain. 34 # # and link us in before it in the chain.
35 my $MODEL = shift @AnyEvent::ISA; 35 my $MODEL = shift @AnyEvent::ISA;
36 unshift @ISA, $MODEL; 36 unshift @ISA, $MODEL;
37 unshift @AnyEvent::ISA, AnyEvent::Strict:: 37 unshift @AnyEvent::ISA, AnyEvent::Strict::;
38}; 38};
39 39
40sub io { 40sub io {
41 my $class = shift; 41 my $class = shift;
42 my %arg = @_; 42 my %arg = @_;
43 43
44 ref $arg{cb} 44 ref $arg{cb}
45 or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; 45 or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'";
46 delete $arg{cb}; 46 delete $arg{cb};
47 47
48 $arg{poll} =~ /^[rw]$/
49 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'";
50
51 if ($arg{fh} =~ /^\s*\d+\s*$/) {
52 $arg{fh} = AnyEvent::_dupfh $arg{poll}, $arg{fh};
53 } else {
48 defined fileno $arg{fh} 54 defined eval { fileno $arg{fh} }
49 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; 55 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'";
56 }
57
50 -f $arg{fh} 58 -f $arg{fh}
51 and croak "AnyEvent->io called with fh argument pointing to a file"; 59 and croak "AnyEvent->io called with fh argument pointing to a file";
60
61 delete $arg{poll};
52 delete $arg{fh}; 62 delete $arg{fh};
53
54 $arg{poll} =~ /^[rw]$/
55 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'";
56 delete $arg{poll};
57 63
58 croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg 64 croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg
59 if keys %arg; 65 if keys %arg;
60 66
61 $class->SUPER::io (@_) 67 $class->SUPER::io (@_)
89 95
90 ref $arg{cb} 96 ref $arg{cb}
91 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; 97 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'";
92 delete $arg{cb}; 98 delete $arg{cb};
93 99
94 eval "require POSIX; 0 < &POSIX::SIG$arg{signal}" 100 defined AnyEvent::Base::sig2num $arg{signal} and $arg{signal} == 0
95 or croak "AnyEvent->signal called with illegal signal name '$arg{signal}'"; 101 or croak "AnyEvent->signal called with illegal signal name '$arg{signal}'";
96 delete $arg{signal}; 102 delete $arg{signal};
97 103
98 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg 104 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg
99 if keys %arg; 105 if keys %arg;
104sub child { 110sub child {
105 my $class = shift; 111 my $class = shift;
106 my %arg = @_; 112 my %arg = @_;
107 113
108 ref $arg{cb} 114 ref $arg{cb}
109 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; 115 or croak "AnyEvent->child called with illegal cb argument '$arg{cb}'";
110 delete $arg{cb}; 116 delete $arg{cb};
111 117
112 $arg{pid} =~ /^-?\d+$/ 118 $arg{pid} =~ /^-?\d+$/
113 or croak "AnyEvent->signal called with illegal pid value '$arg{pid}'"; 119 or croak "AnyEvent->child called with malformed pid value '$arg{pid}'";
114 delete $arg{pid}; 120 delete $arg{pid};
115 121
116 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg 122 croak "AnyEvent->child called with unsupported parameter(s) " . join ", ", keys %arg
117 if keys %arg; 123 if keys %arg;
118 124
119 $class->SUPER::child (@_) 125 $class->SUPER::child (@_)
126}
127
128sub idle {
129 my $class = shift;
130 my %arg = @_;
131
132 ref $arg{cb}
133 or croak "AnyEvent->idle called with illegal cb argument '$arg{cb}'";
134 delete $arg{cb};
135
136 croak "AnyEvent->idle called with unsupported parameter(s) " . join ", ", keys %arg
137 if keys %arg;
138
139 $class->SUPER::idle (@_)
120} 140}
121 141
122sub condvar { 142sub condvar {
123 my $class = shift; 143 my $class = shift;
124 my %arg = @_; 144 my %arg = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines