XRandR/Receiver/Verbose.pm

filter: Statementstmt 26.9% 35 / 130 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 33.3% 9 / 27 Podpod 5.8% 1 / 17 totaltotal 20.4% 45 / 220 CC 20 SCAR 35.7
CC
20
Cov
21%
gotrule
132.0
remove_empty_arrays
12.0
got_property
12.0
CRAP 35.4
↑ Summary XRandR/CurCrtc.pm »
1 package X11::XRandR::Receiver::Verbose;
2  
3 # ABSTRACT: The Pegex Receiver for L<X11::XRandR::Grammar::Verbose>
4  
5 #pod =for Pod::Coverage *EVERYTHING*
6 #pod
7 #pod =cut
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '0.01';
13  
14 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Memoize;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use base 'Pegex::Tree';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 ▶use Module::Runtime qw[ require_module ];
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use String::CamelCase qw[ camelize ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 ▶use Data::Dump qw[ dd pp ];
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 ▶use X11::XRandR::CurMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 2 our %NameMap = ( dimension_mm => 'dimension', );
28  
29 0 ▶sub remove_empty_arrays {
Subroutine remove_empty_arrays: not called CC=3 SCAR=24.8
Pod undocumented
30 0 ▶ scalar [ map { 'ARRAY' eq ref $_ ? ( @{$_} ? $_ : () ) : $_ } @{ $_[0] } ];
Branch: 2 branches
BranchTrueFalseTotal
'ARRAY' eq ref $_ ? : 0 0 0
@{$_;} ? : 0 0 0
31 }
32  
33 0 ▶sub merge_hashes {
Subroutine merge_hashes: not called CC=1 SCAR=6.9
Pod undocumented
34 0 scalar { map { %{$_} } @{ $_[0] } };
35 }
36  
37 # cache module existence so that if the module doesn't exist, we don't
38 # keep looking for it.
39 2 memoize( '_require_module' );
40 0 ▶sub _require_module {
Subroutine _require_module: not called CC=2 SCAR=17.9
41 0 my $name = 'X11::XRandR::' . camelize( $_[0] );
42 0 ▶ return $name if eval { require_module( $name ); 1; };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { &require_module($name); 1 } } 0 0 0
43 0 return;
44 }
45  
46 0 ▶sub gotrule {
Subroutine gotrule: not called CC=11 SCAR=48.8
Pod documented
47 0 my $self = shift;
48 0 ▶ @_ || return ();
Branch: 1 branch
BranchTrueFalseTotal
@_ or return () 0 0 0
49  
50 0 my $res = $_[0];
51 return
52 0 ▶ if 'ARRAY' eq ref $res && !@$res || 'HASH' eq ref $res && !keys %$res;
Branch: 1 branch
BranchTrueFalseTotal
if "ARRAY" eq ref $res and not @$res or "HASH" eq ref $res and not keys %$res 0 0 0
Condition0%0/9
"ARRAY" eq ref $res and not @$res or "HASH" eq ref $res and not keys %$res
l!l&&r!l&&!r
000
"ARRAY" eq ref $res and not @$res
!ll&&!rl&&r
000
"HASH" eq ref $res and not keys %$res
!ll&&!rl&&r
000
MC/DC0%0/4
"ARRAY" eq ref $res and not @$res or "HASH" eq ref $res and not keys %$res
"ARRAY" eq ref $res not @$res "HASH" eq ref $res not keys %$res
Truth table0%0/7
A and not(B) or C and not(D)
A= "ARRAY" eq ref $resB= not @$resC= "HASH" eq ref $resD= not keys %$res
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
53  
54 0 my $name = $self->{parser}{rule};
55  
56 0 ▶ if ( defined $NameMap{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $NameMap{$name}) { } 0 0 0
57 0 $name = $NameMap{$name};
58 }
59 else {
60 0 $name
61 =~ s/^(EDID|frequency|screen|output_header|output|mode|cur_mode)_//;
62 }
63  
64 my ( $module_name )
65 0 ▶ = map { _require_module( $_ ) || () } $self->{parser}{rule},
Condition0%0/3
_require_module($_) || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
_require_module($_) || ()
_require_module($_) ()
Truth table0%0/3
A || B
A= _require_module($_)B= ()
ABresult
1X1
011
000
66 0 $name;
67  
68 0 ▶ if ( defined $module_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $module_name) 0 0 0
69 0 $res = eval { $module_name->new( $_[0] ) };
70 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
71 0 $res = $_[0];
72 $self->{parser}->throw_error(
73 0 "error instantiating $module_name from @{[ pp $_[0] ]}\n$@\n" );
74 }
75 }
76  
77 return $self->{parser}{parent}{-wrap}
78 0 ▶ ? { $name => $res }
Branch: 1 branch
BranchTrueFalseTotal
$self->{'parser'}{'parent'}{'-wrap'} ? : 0 0 0
79 : $res;
80 }
81  
82 0 ▶sub gotrule_boolean {
Subroutine gotrule_boolean: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my $self = shift;
84 0 $self->gotrule( !!@{ $_[0] } );
85 }
86  
87  
88 0 ▶sub gotrule_unwrap_array {
Subroutine gotrule_unwrap_array: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my $self = shift;
90 0 $self->gotrule( $_[0][0] );
91 }
92  
93  
94 0 ▶sub gotrule_merge_hashes {
Subroutine gotrule_merge_hashes: not called CC=2 SCAR=17.9
Pod undocumented
95 0 my $self = shift;
96  
97 0 my $hash = merge_hashes( remove_empty_arrays( shift ) );
98 0 ▶ return unless keys %$hash;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$hash 0 0 0
99 0 $self->gotrule( $hash );
100 }
101  
102 0 ▶sub dump_match {
Subroutine dump_match: not called CC=1 SCAR=6.9
Pod undocumented
103 0 my $self = shift;
104 0 dd \@_;
105 0 $self->gotrule( @_ );
106 }
107  
108 0 ▶sub got_screen_dims {
Subroutine got_screen_dims: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my $self = shift;
110  
111 0 my %dim = map { $_->[0] => $_->[1] } @{ $_[0] };
112 return $self->gotrule( {
113 max_dim => delete $dim{maximum}{dimension},
114 min_dim => delete $dim{minimum}{dimension},
115 cur_dim => delete $dim{current}{dimension},
116 0 } );
117 }
118  
119 2 *got_state = \&gotrule_merge_hashes;
120  
121 #<<< no perltidy
122 2 *got_Border =
123 *got_Brightness =
124 *got_CRTC =
125 *got_CRTCs =
126 *got_Clones =
127 *got_Gamma =
128 *got_Identifier =
129 *got_Panning =
130 *got_Subpixel =
131 *got_Timestamp =
132 *got_Tracking =
133 *got_filter =
134 *got_hSync =
135 *got_vSync =
136 *got_panning =
137 *got_property_EDID =
138 *got_ranges =
139 *got_supported =
140 \&gotrule_unwrap_array;
141 #>>> no perltidy
142  
143 #<<< no perltidy
144 2 *got_border_values =
145 *got_cur_crtc =
146 *got_cur_mode =
147 *got_dimension =
148 *got_frequency =
149 *got_geometry =
150 *got_output =
151 *got_output_header =
152 *got_screen =
153 *got_xrandr =
154 \&gotrule_merge_hashes;
155 #>>> no perltidy
156  
157 #<<< no perltidy
158 2 *got_mode_current =
159 *got_mode_preferred =
160 *got_output_primary =
161 \&gotrule_boolean;
162 #>>> no perltidy
163  
164 0 ▶sub got_float {
Subroutine got_float: not called CC=1 SCAR=6.9
Pod undocumented
165 0 my $self = shift;
166 0 $_[0] += 0;
167 0 $self->gotrule( @_ );
168 }
169  
170 0 ▶sub got_property {
Subroutine got_property: not called CC=3 SCAR=24.8
Pod undocumented
171 0 my $self = shift;
172  
173 0 my %property;
174 0 @property{ 'name', 'value' } = @{ $_[0][0] };
175  
176 0 ▶ if ( @{ $_[0] } > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$_[0];} > 1) 0 0 0
177 die( "expected exactly one key in property acceptable values:",
178 dd $_[0][1] )
179 0 ▶ if keys %{ $_[0][1] } != 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$_[0][1];} != 1 0 0 0
180 0 my ( $key, $values ) = each %{ $_[0][1] };
181 0 $property{$key} = $values;
182 }
183 0 $self->gotrule( \%property );
184 }
185  
186 0 ▶sub got_dimension_mm {
Subroutine got_dimension_mm: not called CC=1 SCAR=6.9
Pod undocumented
187 0 my $self = shift;
188 0 my $hash = merge_hashes( shift );
189 0 $hash->{unit} = 'mm';
190 0 $self->gotrule( $hash );
191 }
192  
193 0 ▶sub got_offset {
Subroutine got_offset: not called CC=3 SCAR=24.8
Pod undocumented
194 0 my $self = shift;
195  
196 0 my ( $xm, $x, $ym, $y ) = @{ $_[0] };
197  
198 0 ▶ $x *= -1 if $xm eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $xm eq "-" 0 0 0
199 0 ▶ $y *= -1 if $ym eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $ym eq "-" 0 0 0
200  
201 0 $self->gotrule( { x => $x, y => $y } );
202 }
203  
204 0 ▶sub got_Transform {
Subroutine got_Transform: not called CC=1 SCAR=6.9
Pod undocumented
205 0 my $self = shift;
206 0 my @values = @{ $_[0][0] };
207 return $self->gotrule( {
208 matrix =>
209 0 [ map { [ @values[@$_] ] }[ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ],
210 filter => $_[0][1] } );
211 }
212  
213 0 ▶sub got_hexint {
Subroutine got_hexint: not called CC=1 SCAR=6.9
Pod undocumented
214 0 my $self = shift;
215 0 $self->gotrule( hex $_[0] );
216 }
217  
218 0 ▶sub got_cur_mode_reflection {
Subroutine got_cur_mode_reflection: not called CC=1 SCAR=6.9
Pod undocumented
219 0 my $self = shift;
220 0 $self->gotrule( X11::XRandR::CurMode->map_reflection_in( $_[0] ) );
221 }
222  
223 0 ▶sub got_output_header_reflections {
Subroutine got_output_header_reflections: not called CC=2 SCAR=17.9
Pod undocumented
224 0 my $self = shift;
225  
226 0 s/\s*axis// for @{ $_[0] };
227  
228 0 $self->gotrule( @_ );
229 }
230  
231 0 ▶sub got_mode {
Subroutine got_mode: not called CC=1 SCAR=6.9
Pod undocumented
232  
233 0 my $self = shift;
234  
235 0 my $hash = merge_hashes( remove_empty_arrays( @_ ) );
236 0 my ( $hMode, $vMode ) = map { merge_hashes( delete $hash->{$_} ) } qw[ hMode vMode ];
237  
238 0 @{$hash}{keys %$hMode} = values %$hMode;
239 0 @{$hash}{keys %$vMode} = values %$vMode;
240  
241 0 $self->gotrule( $hash );
242 }
243  
244  
245 2 1;
246  
247 #
248 # This file is part of X11-XRandR
249 #
250 # This software is Copyright (c) 2018 by Diab Jerius.
251 #
252 # This is free software, licensed under:
253 #
254 # The GNU General Public License, Version 3, June 2007
255 #
256  
257 __END__
↑ Summary XRandR/CurCrtc.pm »