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.14 by root, Thu Jul 9 18:58:19 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
26use common::sense; 26use Carp qw(croak);
27 27
28use Carp qw(croak); 28use AnyEvent (); BEGIN { AnyEvent::common_sense }
29use Fcntl ();
30
31use AnyEvent ();
32 29
33our @ISA; 30our @ISA;
34 31
35AnyEvent::post_detect { 32AnyEvent::post_detect {
36 # assume the first ISA member is the implementation 33 # assume the first ISA member is the implementation
37 # # and link us in before it in the chain. 34 # # and link us in before it in the chain.
38 my $MODEL = shift @AnyEvent::ISA; 35 my $MODEL = shift @AnyEvent::ISA;
39 unshift @ISA, $MODEL; 36 unshift @ISA, $MODEL;
40 unshift @AnyEvent::ISA, AnyEvent::Strict:: 37 unshift @AnyEvent::ISA, AnyEvent::Strict::;
41}; 38};
42 39
43sub io { 40sub io {
44 my $class = shift; 41 my $class = shift;
45 my %arg = @_; 42 my %arg = @_;
49 delete $arg{cb}; 46 delete $arg{cb};
50 47
51 $arg{poll} =~ /^[rw]$/ 48 $arg{poll} =~ /^[rw]$/
52 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; 49 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'";
53 50
54 if (defined fileno $arg{fh} or ref $arg{fh} or $arg{fh} !~ /^\s*\d+\s*$/) { 51 if ($arg{fh} =~ /^\s*\d+\s*$/) {
52 $arg{fh} = AnyEvent::_dupfh $arg{poll}, $arg{fh};
53 } else {
55 defined fileno $arg{fh} 54 defined eval { fileno $arg{fh} }
56 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; 55 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'";
57 } else {
58 $arg{fh} = AnyEvent::_dupfh $arg{poll}, $arg{fh};
59 } 56 }
60 57
61 -f $arg{fh} 58 -f $arg{fh}
62 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";
63 60
98 95
99 ref $arg{cb} 96 ref $arg{cb}
100 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; 97 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'";
101 delete $arg{cb}; 98 delete $arg{cb};
102 99
103 eval "require POSIX; 0 < &POSIX::SIG$arg{signal}" 100 defined AnyEvent::Base::sig2num $arg{signal} and $arg{signal} == 0
104 or croak "AnyEvent->signal called with illegal signal name '$arg{signal}'"; 101 or croak "AnyEvent->signal called with illegal signal name '$arg{signal}'";
105 delete $arg{signal}; 102 delete $arg{signal};
106 103
107 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg 104 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg
108 if keys %arg; 105 if keys %arg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines