XUL/Application.pm

filter: Statementstmt 60.0% 36 / 60 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 52.6% 10 / 19 Podpod 62.5% 5 / 8 totaltotal 51.0% 51 / 100 CC 6 SCAR 16.6
CC
6
Cov
51%
createHandler
20.0
spawn
6.0
__ANON__
6.0
CRAP 5.3
« XUL/Node.pm ↑ Summary XUL/Window.pm »
1 package POE::XUL::Application;
2 # $Id$
3 # Copyright Philip Gwyn 2007-2010. All rights reserved.
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.0601';
10  
11 1 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use POE::Component::XUL;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use POE::XUL::Logging;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use POE::XUL::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use constant DEBUG => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use vars qw( $window $server );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 require Exporter;
20 1 our @ISA = qw( Exporter );
21 1 our @EXPORT = qw( window server );
22  
23 ################################################################
24 0 ▶sub window () { return $window; }
Subroutine window: not called CC=1 SCAR=6.9
Pod documented
25 0 ▶sub server () { return $server; }
Subroutine server: not called CC=1 SCAR=6.9
Pod documented
26  
27 ################################################################
28 sub create_server
29 0 ▶{
Subroutine create_server: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my( $package, $name ) = @_;
31 0 POE::Component::XUL->spawn( {
32 apps => {
33 $name => $package
34 }
35 } );
36 0 $poe_kernel->run;
37 }
38  
39 ################################################################
40 sub spawn
41 0 ▶{
Subroutine spawn: not called CC=2 SCAR=17.9
Pod undocumented
42 0 my( $self, $event ) = @_;
43 0 ▶ $self = $self->new unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
44 0 $self->SID( $event->SID );
45  
46 0 POE::XUL::Session->create( $self );
47 }
48  
49 ################################################################
50 sub new
51 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my( $package ) = @_;
53 0 return bless {}, $package;
54 }
55  
56 ################################################################
57 sub connect
58 0 ▶{
Subroutine connect: not called CC=1 SCAR=6.9
Pod documented
59 0 my( $self, $event ) = @_;
60 0 die "You must overload ", ref( $self ), "->connect";
61 }
62  
63 ################################################################
64 sub __mk_accessor
65 2 ▶{
Subroutine __mk_accessor: called CC=1 SCAR=3.5
66 2 my( $name ) = @_;
67 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
68 0 my $self = shift;
69 0 my $rv = $self->{$name};
70 0 ▶ $self->{$name} = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
71 0 return $rv;
72 2 };
73 }
74  
75 1 *SID = __mk_accessor( 'SID' );
76 1 *name = __mk_accessor( 'name' );
77  
78 ################################################################
79 sub createHandler
80 0 ▶{
Subroutine createHandler: not called CC=4 SCAR=30.0
Pod documented
81 0 my( $self, $name, $what ) = @_;
82  
83 0 ▶ croak "Unable to createHandler outside of a POE::XUL::Application"
Branch: 1 branch
BranchTrueFalseTotal
unless $POE::XUL::Application::server 0 0 0
84 unless $server;
85  
86 # TODO: Make sure current_session is our session!
87 0 ▶ if( $what and ref $what ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($what and ref $what) { } 0 0 0
Condition0%0/3
$what and ref $what
!ll&&!rl&&r
000
MC/DC0%0/2
$what and ref $what
$what ref $what
Truth table0%0/3
A and B
A= $whatB= ref $what
ABresult
0X0
100
111
88 0 $poe_kernel->state( $name, $what );
89 }
90 else {
91 0 $poe_kernel->state( $name, $self, $what );
92 }
93 }
94  
95 ################################################################
96 sub removeHandler
97 0 ▶{
Subroutine removeHandler: not called CC=1 SCAR=6.9
Pod documented
98 0 my( $self, $name ) = @_;
99 # TODO: Make sure current_session is our session!
100 0 $poe_kernel->state( $name );
101 }
102  
103  
104 1 1;
105  
106 __END__
« XUL/Node.pm ↑ Summary XUL/Window.pm »