X11/Protocol/Ext/MIT_SHM.pm

filter: Statementstmt 31.0% 18 / 58 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 31.2% 5 / 16 Podpod 0.0% 0 / 1 totaltotal 27.3% 23 / 84 CC 5 SCAR 14.0
CC
5
Cov
28%
_interp_none
12.0
_ext_requests_install
6.0
_request_empty
6.0
CRAP 4.0
« X11/Protocol/Ext/DAMAGE.pm ↑ Summary X11/Protocol/Ext/X_Resource.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2017 Kevin Ryde
2  
3 # This file is part of X11-Protocol-Other.
4 #
5 # X11-Protocol-Other is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as published
7 # by the Free Software Foundation; either version 3, or (at your option) any
8 # later version.
9 #
10 # X11-Protocol-Other is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>.
17  
18 1 ▶BEGIN { require 5 }
Subroutine BEGIN: called CC=1 SCAR=0.0
19 package X11::Protocol::Ext::MIT_SHM;
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use X11::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use vars '$VERSION', '@CARP_NOT';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 $VERSION = 31;
26 1 @CARP_NOT = ('X11::Protocol');
27  
28 # uncomment this to run the ### lines
29 #use Smart::Comments;
30  
31 # /usr/share/doc/x11proto-xext-dev/shm.txt.gz
32 # /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
33 #
34 # /usr/include/X11/extensions/shm.h
35 # /usr/include/X11/extensions/shmproto.h
36 # /usr/include/X11/extensions/shmstr.h
37 #
38 # /usr/share/doc/libxext-dev/
39 # /usr/include/X11/extensions/Xshm.h
40 # Xlib
41 #
42  
43 ### MIT_SHM.pm loads
44  
45 #------------------------------------------------------------------------------
46 # events
47  
48 # "major_opcode", "minor_opcode" names as per GraphicsExposure and NoExpose
49 1 my $MitShmCompletion_event = [ 'xxxxLSCxLLx12',
50 'drawable',
51 'minor_opcode',
52 'major_opcode',
53 'shmseg',
54 'offset',
55 ];
56  
57 #------------------------------------------------------------------------------
58  
59 my $reqs =
60 [
61 [ 'MitShmQueryVersion', # 0
62 \&_request_empty,
63 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 0 my ($X, $data) = @_;
65 0 my ($shared_pixmaps, $major, $minor, $uid, $gid, $pixmap_format)
66 = unpack 'xCx6SSSSC', $data;
67 0 return ($major, $minor, $uid, $gid,
68 $shared_pixmaps,
69 $X->interp('ImageFormat', $pixmap_format));
70 }],
71  
72 [ 'MitShmAttach', # 1
73 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
74 0 my ($X, $shmseg, $shmid, $readonly) = @_;
75 0 return pack 'LLCxxx', $shmseg, $shmid, $readonly;
76 } ],
77  
78 [ 'MitShmDetach', # 2
79 \&_request_card32s ], # ($X, $shmseg)
80  
81 [ 'MitShmPutImage', # 3
82 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
83 0 my $self = shift;
84 0 my ($drawable, $gc, $depth,
85 $total_width, $total_height,
86 $src_x, $src_y,
87 $src_width, $src_height,
88 $dst_x, $dst_y,
89 $format,
90 $send_event,
91 $shmseg, $offset) = @_;
92 0 return pack("LLSSssSSssCCCxLL",
93 $drawable, $gc,
94 $total_width, $total_height,
95 $src_x, $src_y,
96 $src_width, $src_height,
97 $dst_x, $dst_y,
98 $depth,
99 $self->num('ImageFormat',$format),
100 $send_event,
101 $shmseg, $offset);
102 }],
103  
104 [ 'MitShmGetImage', # 4
105 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 0 my $self = shift;
107 0 my ($drawable, $x, $y, $width, $height,
108 $planemask, $format,
109 $shmseg, $offset) = @_;
110 0 $format = $self->num('ImageFormat', $format);
111 0 return pack ('LssSSLCxxxLL',
112 $drawable, $x, $y, $width, $height,
113 $planemask, $format,
114 $shmseg, $offset);
115 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
116 0 my ($X, $data) = @_;
117 ### $data
118 0 my ($depth, $visual, $size) = unpack 'xCx6LL', $data;
119 0 return ($depth, _interp_none($X,$visual), $size);
120 } ],
121  
122 [ 'MitShmCreatePixmap', # 5
123 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
124 0 my ($X, $pixmap, $drawable, $depth, $width, $height, $shmseg, $offset)
125 = @_;
126 0 return pack ('LLSSCxxxLL',
127 $pixmap, $drawable,
128 $width, $height, $depth,
129 $shmseg, $offset);
130 1 } ],
131  
132 ];
133  
134 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
135 0 my ($class, $X, $request_num, $event_num, $error_num) = @_;
136 ### MIT_SHM new() ...
137  
138 # Errors
139 0 $X->{'ext_const'}->{'Error'}->[$error_num] = 'ShmSeg';
140 0 $X->{'ext_const_num'}->{'Error'}->{'ShmSeg'} = $error_num;
141 0 $X->{'ext_error_type'}->[$error_num] = 1; # bad resource
142  
143 # Requests
144 0 _ext_requests_install ($X, $request_num, $reqs);
145  
146 # Events
147 0 $X->{'ext_const'}{'Events'}[$event_num] = 'MitShmCompletion';
148 0 $X->{'ext_events'}[$event_num] = $MitShmCompletion_event;
149  
150 0 return bless { }, $class;
151 }
152  
153 0 ▶sub _ext_requests_install {
Subroutine _ext_requests_install: not called CC=2 SCAR=17.9
154 0 my ($X, $request_num, $reqs) = @_;
155  
156 0 $X->{'ext_request'}->{$request_num} = $reqs;
157 0 my $href = $X->{'ext_request_num'};
158 0 my $i;
159 0 foreach $i (0 .. $#$reqs) {
160 0 $href->{$reqs->[$i]->[0]} = [$request_num, $i];
161 }
162 }
163  
164 0 ▶sub _request_empty {
Subroutine _request_empty: not called CC=2 SCAR=17.9
165 # ($X)
166 0 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
167 0 croak "No parameters in this request";
168 }
169 0 return '';
170 }
171  
172 0 ▶sub _request_card32s {
Subroutine _request_card32s: not called CC=1 SCAR=6.9
173 0 shift; # ($X, $card32...)
174 ### _request_card32s(): @_
175 0 return pack 'L*', @_;
176 }
177  
178 0 ▶sub _interp_none {
Subroutine _interp_none: not called CC=3 SCAR=24.8
179 0 my ($X, $id) = @_;
180 0 ▶ if ($X->{'do_interp'} && $id == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($X->{'do_interp'} and $id == 0) { } 0 0 0
Condition0%0/3
$X->{"do_interp"} and $id == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$X->{"do_interp"} and $id == 0
$X->{"do_interp"} $id == 0
Truth table0%0/3
A and B
A= $X->{"do_interp"}B= $id == 0
ABresult
0X0
100
111
181 0 return 'None';
182 } else {
183 0 return $id;
184 }
185 }
186  
187 1 1;
188 __END__
« X11/Protocol/Ext/DAMAGE.pm ↑ Summary X11/Protocol/Ext/X_Resource.pm »