XUL/EventManager.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« XUL/Session.pm ↑ Summary XUL/SessionManager.pm »
1 package POE::XUL::EventManager;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 0 ▶use XUL::Node::Event;
Subroutine BEGIN: called CC=1 SCAR=2.6
8  
9 sub new {
10 my $class = shift;
11 bless { nodes => {} }, $class
12 }
13  
14 sub make_event {
15 my ($self, $request) = @_;
16 my $id = $request->{source};
17 croak "cannot make event with no source" unless $id;
18 $request->{source} = $self->get_node($id);
19 croak "node with id [$id] not found" unless $request->{source};
20 return XUL::Node::Event->make_event($request);
21 }
22  
23 sub fire_event {
24 my ($self, $event) = (shift,shift);
25 $event->source->fire_event($event,@_);
26 }
27  
28 sub register_node {
29 my ($self, $id, $node) = @_;
30 my $nodes = $self->{nodes};
31 $nodes->{$id} = $node;
32 weaken $nodes->{$id};
33 }
34  
35 # TODO: cleanup dangling weak ref now and then
36 sub get_node { shift->{nodes}->{pop()} }
37  
38 1;
39  
« XUL/Session.pm ↑ Summary XUL/SessionManager.pm »