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.7 by root, Tue Jan 13 22:37:18 2009 UTC vs.
Revision 1.12 by root, Thu Apr 23 22:44:30 2009 UTC

3AnyEvent::Strict - force strict mode on for the whole process 3AnyEvent::Strict - force strict mode on for the whole process
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use AnyEvent::Strict; 7 use AnyEvent::Strict;
8 # struct mode now switched on 8 # strict mode now switched on
9 9
10=head1 DESCRIPTION 10=head1 DESCRIPTION
11 11
12This module implements AnyEvent's strict mode. 12This module implements AnyEvent's strict mode.
13 13
20L<AnyEvent>). However, this module can be loaded at any time. 20L<AnyEvent>). However, this module can be loaded at any time.
21 21
22=cut 22=cut
23 23
24package AnyEvent::Strict; 24package AnyEvent::Strict;
25
26no warnings; # *sigh*
25 27
26use Carp qw(croak); 28use Carp qw(croak);
27 29
28use AnyEvent (); 30use AnyEvent ();
29 31
43 or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; 45 or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'";
44 delete $arg{cb}; 46 delete $arg{cb};
45 47
46 defined fileno $arg{fh} 48 defined fileno $arg{fh}
47 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; 49 or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'";
50 -f $arg{fh}
51 and croak "AnyEvent->io called with fh argument pointing to a file";
48 delete $arg{fh}; 52 delete $arg{fh};
49 53
50 $arg{poll} =~ /^[rw]$/ 54 $arg{poll} =~ /^[rw]$/
51 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; 55 or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'";
52 delete $arg{poll}; 56 delete $arg{poll};
100sub child { 104sub child {
101 my $class = shift; 105 my $class = shift;
102 my %arg = @_; 106 my %arg = @_;
103 107
104 ref $arg{cb} 108 ref $arg{cb}
105 or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; 109 or croak "AnyEvent->child called with illegal cb argument '$arg{cb}'";
106 delete $arg{cb}; 110 delete $arg{cb};
107 111
108 $arg{pid} =~ /^-?\d+$/ 112 $arg{pid} =~ /^-?\d+$/
109 or croak "AnyEvent->signal called with illegal pid value '$arg{pid}'"; 113 or croak "AnyEvent->child called with malformed pid value '$arg{pid}'";
110 delete $arg{pid}; 114 delete $arg{pid};
111 115
112 croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg 116 croak "AnyEvent->child called with unsupported parameter(s) " . join ", ", keys %arg
113 if keys %arg; 117 if keys %arg;
114 118
115 $class->SUPER::child (@_) 119 $class->SUPER::child (@_)
120}
121
122sub idle {
123 my $class = shift;
124 my %arg = @_;
125
126 ref $arg{cb}
127 or croak "AnyEvent->idle called with illegal cb argument '$arg{cb}'";
128 delete $arg{cb};
129
130 croak "AnyEvent->idle called with unsupported parameter(s) " . join ", ", keys %arg
131 if keys %arg;
132
133 $class->SUPER::idle (@_)
116} 134}
117 135
118sub condvar { 136sub condvar {
119 my $class = shift; 137 my $class = shift;
120 my %arg = @_; 138 my %arg = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines