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.13 by root, Wed Jul 8 02:01:12 2009 UTC

22=cut 22=cut
23 23
24package AnyEvent::Strict; 24package AnyEvent::Strict;
25 25
26no warnings; # *sigh* 26no warnings; # *sigh*
27use strict qw(vars subs);
27 28
28use Carp qw(croak); 29use Carp qw(croak);
30use Fcntl ();
29 31
30use AnyEvent (); 32use AnyEvent ();
33
34our @ISA;
31 35
32AnyEvent::post_detect { 36AnyEvent::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 (@_)
104sub child { 114sub child {
105 my $class = shift; 115 my $class = shift;
106 my %arg = @_; 116 my %arg = @_;
107 117
108 ref $arg{cb} 118 ref $arg{cb}
109 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; 119 or croak "AnyEvent->child called with illegal cb argument '$arg{cb}'";
110 delete $arg{cb}; 120 delete $arg{cb};
111 121
112 $arg{pid} =~ /^-?\d+$/ 122 $arg{pid} =~ /^-?\d+$/
113 or croak "AnyEvent->signal called with illegal pid value '$arg{pid}'"; 123 or croak "AnyEvent->child called with malformed pid value '$arg{pid}'";
114 delete $arg{pid}; 124 delete $arg{pid};
115 125
116 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg 126 croak "AnyEvent->child called with unsupported parameter(s) " . join ", ", keys %arg
117 if keys %arg; 127 if keys %arg;
118 128
119 $class->SUPER::child (@_) 129 $class->SUPER::child (@_)
130}
131
132sub 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 (@_)
120} 144}
121 145
122sub condvar { 146sub condvar {
123 my $class = shift; 147 my $class = shift;
124 my %arg = @_; 148 my %arg = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines