… | |
… | |
21 | |
21 | |
22 | =cut |
22 | =cut |
23 | |
23 | |
24 | package AnyEvent::Strict; |
24 | package AnyEvent::Strict; |
25 | |
25 | |
26 | no warnings; # *sigh* |
26 | use common::sense; |
27 | |
27 | |
28 | use Carp qw(croak); |
28 | use Carp qw(croak); |
|
|
29 | use Fcntl (); |
29 | |
30 | |
30 | use AnyEvent (); |
31 | use AnyEvent (); |
|
|
32 | |
|
|
33 | our @ISA; |
31 | |
34 | |
32 | AnyEvent::post_detect { |
35 | AnyEvent::post_detect { |
33 | # assume the first ISA member is the implementation |
36 | # assume the first ISA member is the implementation |
34 | # # and link us in before it in the chain. |
37 | # # and link us in before it in the chain. |
35 | my $MODEL = shift @AnyEvent::ISA; |
38 | my $MODEL = shift @AnyEvent::ISA; |
… | |
… | |
43 | |
46 | |
44 | ref $arg{cb} |
47 | ref $arg{cb} |
45 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
48 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
46 | delete $arg{cb}; |
49 | delete $arg{cb}; |
47 | |
50 | |
|
|
51 | $arg{poll} =~ /^[rw]$/ |
|
|
52 | or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; |
|
|
53 | |
|
|
54 | if (defined fileno $arg{fh} or ref $arg{fh} or $arg{fh} !~ /^\s*\d+\s*$/) { |
48 | defined fileno $arg{fh} |
55 | defined fileno $arg{fh} |
49 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
56 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
|
|
57 | } else { |
|
|
58 | $arg{fh} = AnyEvent::_dupfh $arg{poll}, $arg{fh}; |
|
|
59 | } |
|
|
60 | |
50 | -f $arg{fh} |
61 | -f $arg{fh} |
51 | and croak "AnyEvent->io called with fh argument pointing to a file"; |
62 | and croak "AnyEvent->io called with fh argument pointing to a file"; |
|
|
63 | |
|
|
64 | delete $arg{poll}; |
52 | delete $arg{fh}; |
65 | 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 | |
66 | |
58 | croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg |
67 | croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg |
59 | if keys %arg; |
68 | if keys %arg; |
60 | |
69 | |
61 | $class->SUPER::io (@_) |
70 | $class->SUPER::io (@_) |
… | |
… | |
117 | if keys %arg; |
126 | if keys %arg; |
118 | |
127 | |
119 | $class->SUPER::child (@_) |
128 | $class->SUPER::child (@_) |
120 | } |
129 | } |
121 | |
130 | |
|
|
131 | sub idle { |
|
|
132 | my $class = shift; |
|
|
133 | my %arg = @_; |
|
|
134 | |
|
|
135 | ref $arg{cb} |
|
|
136 | or croak "AnyEvent->idle called with illegal cb argument '$arg{cb}'"; |
|
|
137 | delete $arg{cb}; |
|
|
138 | |
|
|
139 | croak "AnyEvent->idle called with unsupported parameter(s) " . join ", ", keys %arg |
|
|
140 | if keys %arg; |
|
|
141 | |
|
|
142 | $class->SUPER::idle (@_) |
|
|
143 | } |
|
|
144 | |
122 | sub condvar { |
145 | sub condvar { |
123 | my $class = shift; |
146 | my $class = shift; |
124 | my %arg = @_; |
147 | my %arg = @_; |
125 | |
148 | |
126 | !exists $arg{cb} or ref $arg{cb} |
149 | !exists $arg{cb} or ref $arg{cb} |