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.18 by root, Wed Jul 29 12:39:21 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines