… | |
… | |
22 | =cut |
22 | =cut |
23 | |
23 | |
24 | package AnyEvent::Strict; |
24 | package AnyEvent::Strict; |
25 | |
25 | |
26 | no warnings; # *sigh* |
26 | no warnings; # *sigh* |
|
|
27 | use strict qw(vars subs); |
27 | |
28 | |
28 | use Carp qw(croak); |
29 | use Carp qw(croak); |
|
|
30 | use Fcntl (); |
29 | |
31 | |
30 | use AnyEvent (); |
32 | use AnyEvent (); |
|
|
33 | |
|
|
34 | our @ISA; |
31 | |
35 | |
32 | AnyEvent::post_detect { |
36 | AnyEvent::post_detect { |
33 | # assume the first ISA member is the implementation |
37 | # assume the first ISA member is the implementation |
34 | # # and link us in before it in the chain. |
38 | # # and link us in before it in the chain. |
35 | my $MODEL = shift @AnyEvent::ISA; |
39 | my $MODEL = shift @AnyEvent::ISA; |
… | |
… | |
43 | |
47 | |
44 | ref $arg{cb} |
48 | ref $arg{cb} |
45 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
49 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
46 | delete $arg{cb}; |
50 | delete $arg{cb}; |
47 | |
51 | |
|
|
52 | $arg{poll} =~ /^[rw]$/ |
|
|
53 | or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; |
|
|
54 | |
|
|
55 | if (defined fileno $arg{fh} or ref $arg{fh} or $arg{fh} !~ /^\s*\d+\s*$/) { |
48 | defined fileno $arg{fh} |
56 | defined fileno $arg{fh} |
49 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
57 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
|
|
58 | } else { |
|
|
59 | $arg{fh} = AnyEvent::_dupfh $arg{poll}, $arg{fh}; |
|
|
60 | } |
|
|
61 | |
50 | -f $arg{fh} |
62 | -f $arg{fh} |
51 | and croak "AnyEvent->io called with fh argument pointing to a file"; |
63 | and croak "AnyEvent->io called with fh argument pointing to a file"; |
|
|
64 | |
|
|
65 | delete $arg{poll}; |
52 | delete $arg{fh}; |
66 | 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 | |
67 | |
58 | croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg |
68 | croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg |
59 | if keys %arg; |
69 | if keys %arg; |
60 | |
70 | |
61 | $class->SUPER::io (@_) |
71 | $class->SUPER::io (@_) |