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