Skip to content

Commit

Permalink
Whitespace fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaputo committed May 31, 2011
1 parent e0d6b99 commit 4dcae46
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 219 deletions.
238 changes: 119 additions & 119 deletions eg/RunnerRole.pm
Expand Up @@ -17,56 +17,56 @@ callback_parameter cb_stdout_error => qw( on att_stdout error );
method_parameter method_put => qw( put att_stdin _ );

role {
my $p = shift;
my $p = shift;

with 'Reflex::Role::OutStreaming' => {
att_handle => $p->att_stdin(),
method_put => $p->method_put(),
};
with 'Reflex::Role::OutStreaming' => {
att_handle => $p->att_stdin(),
method_put => $p->method_put(),
};

my $m_stdout_stop = "stop_" . $p->att_stdout();
my $cb_stdout_closed = $p->cb_stdout_closed();
my $m_stdout_stop = "stop_" . $p->att_stdout();
my $cb_stdout_closed = $p->cb_stdout_closed();

requires(
requires(
map { $p->$_() } qw(
att_pid att_stderr att_stdin att_stdout
cb_exit
cb_stderr_closed cb_stderr_data cb_stderr_data
cb_stdout_closed cb_stdout_data cb_stdout_data
)
);

after $cb_stdout_closed => sub {
my ($self, $args) = @_;
$self->$m_stdout_stop();
};

with 'Reflex::Role::InStreaming' => {
att_handle => $p->att_stdout(),
cb_data => $p->cb_stdout_data(),
cb_error => $p->cb_stdout_error(),
cb_closed => $cb_stdout_closed,
};

my $m_stderr_stop = "stop_" . $p->att_stderr();
my $cb_stderr_closed = $p->cb_stderr_closed();

after $cb_stderr_closed => sub {
my ($self, $args) = @_;
$self->$m_stderr_stop();
};

with 'Reflex::Role::InStreaming' => {
att_handle => $p->att_stderr(),
cb_data => $p->cb_stderr_data(),
cb_error => $p->cb_stderr_error(),
cb_closed => $cb_stderr_closed,
};

with 'Reflex::Role::PidCatcher' => {
att_pid => $p->att_pid(),
cb_exit => $p->cb_exit(),
};
att_pid att_stderr att_stdin att_stdout
cb_exit
cb_stderr_closed cb_stderr_data cb_stderr_data
cb_stdout_closed cb_stdout_data cb_stdout_data
)
);

after $cb_stdout_closed => sub {
my ($self, $args) = @_;
$self->$m_stdout_stop();
};

with 'Reflex::Role::InStreaming' => {
att_handle => $p->att_stdout(),
cb_data => $p->cb_stdout_data(),
cb_error => $p->cb_stdout_error(),
cb_closed => $cb_stdout_closed,
};

my $m_stderr_stop = "stop_" . $p->att_stderr();
my $cb_stderr_closed = $p->cb_stderr_closed();

after $cb_stderr_closed => sub {
my ($self, $args) = @_;
$self->$m_stderr_stop();
};

with 'Reflex::Role::InStreaming' => {
att_handle => $p->att_stderr(),
cb_data => $p->cb_stderr_data(),
cb_error => $p->cb_stderr_error(),
cb_closed => $cb_stderr_closed,
};

with 'Reflex::Role::PidCatcher' => {
att_pid => $p->att_pid(),
cb_exit => $p->cb_exit(),
};
};

1;
Expand All @@ -88,135 +88,135 @@ __END__
watches process => ( isa => 'Maybe[Reflex::PID]', is => 'rw' );
has [qw(stdin stdout stderr)] => (
isa => 'Maybe[FileHandle]',
is => 'rw',
isa => 'Maybe[FileHandle]',
is => 'rw',
);
has ipc_run => ( isa => 'IPC::Run', is => 'rw' );
has cmd => (
isa => 'ArrayRef',
is => 'ro',
required => 1,
isa => 'ArrayRef',
is => 'ro',
required => 1,
);
### Reap the child process.
sub on_process_exit {
my ($self, $args) = @_;
$self->emit(event => 'exit', args => $args);
my ($self, $args) = @_;
$self->emit(event => 'exit', args => $args);
}
sub kill {
my ($self, $signal) = @_;
croak "no process to kill" unless $self->process();
$signal ||= 'TERM';
kill $signal, $self->process()->pid();
my ($self, $signal) = @_;
croak "no process to kill" unless $self->process();
$signal ||= 'TERM';
kill $signal, $self->process()->pid();
}
### Write to standard input.
sub on_stdin_error {
my ($self, $args) = @_;
$self->emit(event => 'stdin_error', args => $args);
my ($self, $args) = @_;
$self->emit(event => 'stdin_error', args => $args);
}
with 'Reflex::Role::Writing' => { att_handle => 'stdin' };
sub on_stdin_writable {
my ($self, $arg) = @_;
my $octets_left = $self->flush_stdin();
return if $octets_left;
$self->flush_stdin();
my ($self, $arg) = @_;
my $octets_left = $self->flush_stdin();
return if $octets_left;
$self->flush_stdin();
}
with 'Reflex::Role::Writable' => { att_handle => 'stdin' };
### Read from standard output.
sub on_stdout_readable {
my ($self, $arg) = @_;
my $octets_read = $self->read_stdout($arg);
warn $octets_read;
return if $octets_read;
if (defined $octets_read) {
warn 111;
$self->pause_stdout_readable();
return;
}
$self->stop_stdout_readable();
my ($self, $arg) = @_;
my $octets_read = $self->read_stdout($arg);
warn $octets_read;
return if $octets_read;
if (defined $octets_read) {
warn 111;
$self->pause_stdout_readable();
return;
}
$self->stop_stdout_readable();
}
sub on_stdout_error {
my ($self, $args) = @_;
$self->emit(event => 'stdout_error', args => $args);
$self->stop_stdout_readable();
my ($self, $args) = @_;
$self->emit(event => 'stdout_error', args => $args);
$self->stop_stdout_readable();
}
with 'Reflex::Role::Reading' => {
att_handle => 'stdout',
cb_data => make_emitter(on_stdout => "stdout"),
att_handle => 'stdout',
cb_data => make_emitter(on_stdout => "stdout"),
};
with 'Reflex::Role::Readable' => {
att_handle => 'stdout',
cb_ready => 'on_stdout_readable',
att_handle => 'stdout',
cb_ready => 'on_stdout_readable',
};
### Read from standard error.
sub on_stderr_error {
my ($self, $args) = @_;
$self->emit(event => 'stderr_error', args => $args);
$self->stop_stderr_readable();
my ($self, $args) = @_;
$self->emit(event => 'stderr_error', args => $args);
$self->stop_stderr_readable();
}
sub on_stderr_readable {
my ($self, $arg) = @_;
my $octets_read = $self->read_stderr($arg);
warn $octets_read;
return if $octets_read;
if (defined $octets_read) {
warn 111;
$self->pause_stderr_readable();
return;
}
$self->stop_stderr_readable();
my ($self, $arg) = @_;
my $octets_read = $self->read_stderr($arg);
warn $octets_read;
return if $octets_read;
if (defined $octets_read) {
warn 111;
$self->pause_stderr_readable();
return;
}
$self->stop_stderr_readable();
}
with 'Reflex::Role::Reading' => {
att_handle => 'stderr',
cb_data => make_emitter(on_stderr => "stderr"),
att_handle => 'stderr',
cb_data => make_emitter(on_stderr => "stderr"),
};
with 'Reflex::Role::Readable' => {
att_handle => 'stderr',
cb_ready => 'on_stderr_readable',
att_handle => 'stderr',
cb_ready => 'on_stderr_readable',
};
sub BUILD {
my $self = shift;
my ($fh_in, $fh_out, $fh_err) = (gensym(), gensym(), gensym());
$self->ipc_run(
start(
$self->cmd(),
'<pipe', $fh_in,
'>pipe', $fh_out,
'2>pipe', $fh_err,
)
) or die "IPC::Run start() failed: $? ($!)";
$self->process(
Reflex::PID->new(
pid => $self->ipc_run->{KIDS}[0]{PID}
)
);
$self->att_stdin($fh_in);
$self->att_stdout($fh_out);
$self->att_stderr($fh_err);
my $self = shift;
my ($fh_in, $fh_out, $fh_err) = (gensym(), gensym(), gensym());
$self->ipc_run(
start(
$self->cmd(),
'<pipe', $fh_in,
'>pipe', $fh_out,
'2>pipe', $fh_err,
)
) or die "IPC::Run start() failed: $? ($!)";
$self->process(
Reflex::PID->new(
pid => $self->ipc_run->{KIDS}[0]{PID}
)
);
$self->att_stdin($fh_in);
$self->att_stdout($fh_out);
$self->att_stderr($fh_err);
}
1;
14 changes: 7 additions & 7 deletions eg/eg-02-encoding.pl
Expand Up @@ -29,13 +29,13 @@
% perl -I../lib eg-02-encoding.pl
--- !!perl/hash:Reflex::Decoder::Line
messages:
- !!perl/hash:Reflex::Codec::Message::Stream
is_combinable: 1
octets: 'test line one<nl>test line two<nl>test line three<nl>test line four<nl>'
priority: 500
- !!perl/hash:Reflex::Codec::Message::Eof
is_combinable: 0
priority: 500
- !!perl/hash:Reflex::Codec::Message::Stream
is_combinable: 1
octets: 'test line one<nl>test line two<nl>test line three<nl>test line four<nl>'
priority: 500
- !!perl/hash:Reflex::Codec::Message::Eof
is_combinable: 0
priority: 500
newline: '<nl>'
--- !!perl/hash:Reflex::Codec::Message::Datagram
is_combinable: 0
Expand Down
6 changes: 3 additions & 3 deletions eg/eg-41-signal-twice.pl
Expand Up @@ -11,11 +11,11 @@
eg_say("Process $$ is waiting for SIGUSR1 twice.");

my $usr1_a = Reflex::Signal->new(
signal => "USR1",
on_signal => sub { eg_say("Got SIGUSR1 callback.") },
signal => "USR1",
on_signal => sub { eg_say("Got SIGUSR1 callback.") },
);

my $usr1_b = Reflex::Signal->new( signal => "USR1" );
while ($usr1_b->next()) {
eg_say("Got SIGUSR1 from promise.");
eg_say("Got SIGUSR1 from promise.");
}
8 changes: 4 additions & 4 deletions eg/eg-42-reflex-in-poe.pl
Expand Up @@ -140,20 +140,20 @@
17:18 kthakore : dngor: right ..
17:18 kthakore : but how do I plug it into Bot::BasicBot
17:19 dngor : When you get the trigger from Bot::BasicBot, open a
socket, send a request, and wait for a response.
socket, send a request, and wait for a response.
17:19 dngor : You could use IO::Socket::INET and
$poe_kernel->select_read(), or something higher level.
17:19 kthakore : http://github.com/PerlGameDev/SDL/blob/master/tools/SDLBot.pl
17:20 kthakore : but where do I get $poe_kernel from?
17:20 dngor : If the server is localhost, the connect() will tend to
pass or fail pretty quickly... unless your firewall is
interfering with localhost. So blocking is generally not
a problem.
a problem.
17:20 kthakore : I mean I know BasicBot uses Poe
17:20 dngor : Presumably Bot::BasicBot passes it to you, in the
standard POE way. If not, POE::Kernel exports it.
standard POE way. If not, POE::Kernel exports it.
17:21 dngor : Hm. There's an excellent exercise. Using Reflex INSIDE
POE components.
POE components.
17:21 dngor : Bot::BasicBot + Reflex::Client
17:22 kthakore : dngor: whut is reflex ... and how do I use it?
17:23 dngor : It's neither here nor there. I'm just brainstorming aloud.
Expand Down
10 changes: 5 additions & 5 deletions eg/ttl/Ttl/HexDecoder.pm
Expand Up @@ -19,13 +19,13 @@ sub on_my_change {
my $self = shift;

my $decimal = (
($self->ones() || 0) * 1 +
($self->twos() || 0) * 2 +
($self->fours() || 0) * 4 +
($self->eights() || 0) * 8
($self->ones() || 0) * 1 +
($self->twos() || 0) * 2 +
($self->fours() || 0) * 4 +
($self->eights() || 0) * 8
);

$self->out( ("0".."9","a".."f")[$decimal] );
$self->out( ("0".."9","a".."f")[$decimal] );
}

1;

0 comments on commit 4dcae46

Please sign in to comment.