C/TypeVisitor.pm

filter: Statementstmt 5.4% 8 / 146 Branchbran 0.0% 0 / 110 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 6.6% 2 / 30 Podpod 0.0% 0 / 25 totaltotal 2.9% 10 / 336 CC 70 SCAR 75.5
CC
70
Cov
3%
_get_name_attr
3306.0
visitSpecification
20.0
new
6.0
CRAP 1905.7
↑ Summary C/IncludeVisitor.pm »
1
2 #
3 # Interface Definition Language (OMG IDL CORBA v3.0)
4 #
5 # C Language Mapping Specification, New Edition June 1999
6 #
7
8 package CORBA::C::TypeVisitor;
9
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 1 our $VERSION = '2.61';
14
15 # builds $node->{c_arg}
16
17 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
18 0 my $proto = shift;
19 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
20 0 my $self = {};
21 0 bless $self, $class;
22 0 my ($parser) = @_;
23 0 $self->{srcname} = $parser->YYData->{srcname};
24 0 $self->{symbtab} = $parser->YYData->{symbtab};
25 0 return $self;
26 }
27
28 0 ▶sub _get_type {
Subroutine _get_type: not called CC=2 SCAR=17.9
29 0 my $self = shift;
30 0 my ($type) = @_;
31
32 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) { } 0 0 0
33 0 return $type;
34 }
35 else {
36 0 $self->{symbtab}->Lookup($type);
37 }
38 }
39
40 0 ▶sub _get_c_arg {
Subroutine _get_c_arg: not called CC=1 SCAR=6.9
41 0 my $self = shift;
42 0 my ($type, $v_name, $attr) = @_;
43
44 0 my $t_name = $type->{c_name};
45 0 return $t_name . $self->_get_name_attr($type, $attr) . $v_name;
46 }
47
48 #
49 # See 1.21 Summary of Argument/Result Passing
50 #
51
52 0 ▶sub _get_name_attr {
Subroutine _get_name_attr: not called CC=57 SCAR=81.0
53 0 my $self = shift;
54 0 my ($node, $attr) = @_;
55
56 0 ▶ if ( $node->isa('BasicType')
Branch: 10 branches
BranchTrueFalseTotal
if ($node->isa('BasicType') or $node->isa('EnumType')) { } 0 0 0
elsif ($node->isa('FixedPtType')) { } 0 0 0
elsif ($node->isa('BaseInterface') or $node->isa('ForwardBaseInterface')) { } 0 0 0
elsif ($node->isa('StructType') or $node->isa('UnionType')) { } 0 0 0
elsif ($node->isa('SequenceType')) { } 0 0 0
elsif ($node->isa('StringType') or $node->isa('WideStringType')) { } 0 0 0
elsif ($node->isa('TypeDeclarator')) { } 0 0 0
elsif ($node->isa('NativeType')) { } 0 0 0
elsif ($node->isa('AnyType')) { } 0 0 0
elsif ($node->isa('VoidType')) { } 0 0 0
Condition0%0/3
$node->isa("BasicType") or $node->isa("EnumType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->isa("BasicType") or $node->isa("EnumType")
$node->isa("BasicType") $node->isa("EnumType")
Truth table0%0/3
A or B
A= $node->isa("BasicType")B= $node->isa("EnumType")
ABresult
1X1
011
000
57 or $node->isa('EnumType') ) {
58 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
59 0 return q{ };
60 }
61 elsif ( $attr eq 'inout' ) {
62 0 return ' * ';
63 }
64 elsif ( $attr eq 'out' ) {
65 0 return ' * ';
66 }
67 elsif ( $attr eq 'return' ) {
68 0 return q{};
69 }
70 }
71 elsif ( $node->isa('FixedPtType') ) {
72 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
73 0 return ' * ';
74 }
75 elsif ( $attr eq 'inout' ) {
76 0 return ' * ';
77 }
78 elsif ( $attr eq 'out' ) {
79 0 return ' * ';
80 }
81 elsif ( $attr eq 'return' ) {
82 0 return q{};
83 }
84 }
85 ▶ elsif ( $node->isa('BaseInterface')
Condition0%0/3
$node->isa("BaseInterface") or $node->isa("ForwardBaseInterface")
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->isa("BaseInterface") or $node->isa("ForwardBaseInterface")
$node->isa("BaseInterface") $node->isa("ForwardBaseInterface")
Truth table0%0/3
A or B
A= $node->isa("BaseInterface")B= $node->isa("ForwardBaseInterface")
ABresult
1X1
011
000
86 or $node->isa('ForwardBaseInterface') ) {
87 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
88 0 return q{ };
89 }
90 elsif ( $attr eq 'inout' ) {
91 0 return ' * ';
92 }
93 elsif ( $attr eq 'out' ) {
94 0 return ' * ';
95 }
96 elsif ( $attr eq 'return' ) {
97 0 return q{};
98 }
99 }
100 ▶ elsif ( $node->isa('StructType')
Condition0%0/3
$node->isa("StructType") or $node->isa("UnionType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->isa("StructType") or $node->isa("UnionType")
$node->isa("StructType") $node->isa("UnionType")
Truth table0%0/3
A or B
A= $node->isa("StructType")B= $node->isa("UnionType")
ABresult
1X1
011
000
101 or $node->isa('UnionType') ) {
102 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
103 0 return ' * ';
104 }
105 elsif ( $attr eq 'inout' ) {
106 0 return ' * ';
107 }
108 elsif ( $attr eq 'out' ) {
109 0 ▶ if (defined $node->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->{'length'}) { } 0 0 0
110 0 return ' ** ';
111 }
112 else {
113 0 return ' * ';
114 }
115 }
116 elsif ( $attr eq 'return' ) {
117 0 ▶ if (defined $node->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->{'length'}) { } 0 0 0
118 0 return ' *';
119 }
120 else {
121 0 return q{};
122 }
123 }
124 }
125 elsif ( $node->isa('SequenceType') ) {
126 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
127 0 return ' * ';
128 }
129 elsif ( $attr eq 'inout' ) {
130 0 return ' * ';
131 }
132 elsif ( $attr eq 'out' ) {
133 0 return ' ** ';
134 }
135 elsif ( $attr eq 'return' ) {
136 0 return ' *';
137 }
138 }
139 ▶ elsif ( $node->isa('StringType')
Condition0%0/3
$node->isa("StringType") or $node->isa("WideStringType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->isa("StringType") or $node->isa("WideStringType")
$node->isa("StringType") $node->isa("WideStringType")
Truth table0%0/3
A or B
A= $node->isa("StringType")B= $node->isa("WideStringType")
ABresult
1X1
011
000
140 or $node->isa('WideStringType') ) {
141 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
142 0 return q{ };
143 }
144 elsif ( $attr eq 'inout' ) {
145 0 return ' * ';
146 }
147 elsif ( $attr eq 'out' ) {
148 0 return ' * ';
149 }
150 elsif ( $attr eq 'return' ) {
151 0 return q{};
152 }
153 }
154 elsif ( $node->isa('TypeDeclarator') ) {
155 0 ▶ if (exists $node->{array_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{'array_size'}) { } 0 0 0
156 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
157 0 return q{ };
158 }
159 elsif ( $attr eq 'inout' ) {
160 0 return q{ };
161 }
162 elsif ( $attr eq 'out' ) {
163 0 ▶ if (defined $node->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->{'length'}) { } 0 0 0
164 0 return '_slice ** ';
165 }
166 else {
167 0 return q{ };
168 }
169 }
170 elsif ( $attr eq 'return' ) {
171 0 return '_slice *';
172 }
173 }
174 else {
175 0 my $type = $node->{type};
176 0 ▶ unless (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $type) 0 0 0
177 0 $type = $self->{symbtab}->Lookup($type);
178 }
179 0 return $self->_get_name_attr($type, $attr);
180 }
181 }
182 elsif ( $node->isa('NativeType') ) {
183 # C mapping is aligned with CORBA 2.1
184 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
185 0 return q{ };
186 }
187 elsif ( $attr eq 'inout' ) {
188 0 return ' * ';
189 }
190 elsif ( $attr eq 'out' ) {
191 0 return ' * ';
192 }
193 elsif ( $attr eq 'return' ) {
194 0 return q{};
195 }
196 else {
197 0 warn caller()," NativeType : ERROR_INTERNAL $attr \n";
198 }
199 }
200 elsif ( $node->isa('AnyType') ) {
201 0 ▶ if ( $attr eq 'in' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($attr eq 'in') { } 0 0 0
elsif ($attr eq 'inout') { } 0 0 0
elsif ($attr eq 'out') { } 0 0 0
elsif ($attr eq 'return') { } 0 0 0
202 0 return ' * ';
203 }
204 elsif ( $attr eq 'inout' ) {
205 0 return ' * ';
206 }
207 elsif ( $attr eq 'out' ) {
208 0 return ' ** ';
209 }
210 elsif ( $attr eq 'return' ) {
211 0 return ' *';
212 }
213 }
214 elsif ( $node->isa('VoidType') ) {
215 0 ▶ if ($attr eq 'return') {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr eq "return") 0 0 0
216 0 return q{};
217 }
218 }
219 else {
220 0 my $class = ref $node;
221 0 warn "Please implement '$class' in '_get_name_attr'.\n";
222 0 return;
223 }
224 0 my $class = ref $node;
225 0 warn "_get_name_attr : ERROR_INTERNAL $class $attr \n";
226 }
227
228 #
229 # 3.5 OMG IDL Specification
230 #
231
232 0 ▶sub visitSpecification {
Subroutine visitSpecification: not called CC=4 SCAR=30.0
Pod undocumented
233 0 my $self = shift;
234 0 my ($node) = @_;
235 0 ▶ if (exists $node->{list_import}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{"list_import"}) 0 0 0
236 0 foreach (@{$node->{list_import}}) {
237 0 $_->visit($self);
238 }
239 }
240 0 foreach (@{$node->{list_export}}) {
241 0 $self->{symbtab}->Lookup($_)->visit($self);
242 }
243 }
244
245 #
246 # 3.6 Import Declaration
247 #
248
249 0 ▶sub visitImport {
Subroutine visitImport: not called CC=2 SCAR=17.9
Pod undocumented
250 0 my $self = shift;
251 0 my ($node) = @_;
252 0 foreach (@{$node->{list_decl}}) {
253 0 $self->{symbtab}->Lookup($_)->visit($self);
254 }
255 }
256
257 #
258 # 3.7 Module Declaration
259 #
260
261 0 ▶sub visitModules {
Subroutine visitModules: not called CC=2 SCAR=17.9
Pod undocumented
262 0 my $self = shift;
263 0 my ($node) = @_;
264 0 foreach (@{$node->{list_export}}) {
265 0 $self->{symbtab}->Lookup($_)->visit($self);
266 }
267 }
268
269 #
270 # 3.8 Interface Declaration
271 #
272
273 0 ▶sub visitBaseInterface {
Subroutine visitBaseInterface: not called CC=2 SCAR=17.9
Pod undocumented
274 0 my $self = shift;
275 0 my ($node) = @_;
276 0 foreach (@{$node->{list_export}}) {
277 0 $self->{symbtab}->Lookup($_)->visit($self);
278 }
279 }
280
281 #
282 # 3.9 Value Declaration
283 #
284
285 0 ▶sub visitStateMember {
Subroutine visitStateMember: not called CC=1 SCAR=0.0
Pod undocumented
286 # C mapping is aligned with CORBA 2.1
287 }
288
289 0 ▶sub visitInitializer {
Subroutine visitInitializer: not called CC=2 SCAR=17.9
Pod undocumented
290 # C mapping is aligned with CORBA 2.1
291 0 my $self = shift;
292 0 my ($node) = @_;
293 0 foreach (@{$node->{list_param}}) { # parameter
294 0 my $type = $self->_get_type($_->{type});
295 0 $_->{c_arg} = $self->_get_c_arg($type, $_->{c_name}, $_->{attr});
296 }
297 }
298
299 #
300 # 3.10 Constant Declaration
301 #
302
303 0 ▶sub visitConstant {
Subroutine visitConstant: not called CC=1 SCAR=0.0
Pod undocumented
304 # empty
305 }
306
307 #
308 # 3.11 Type Declaration
309 #
310
311 0 ▶sub visitTypeDeclarator {
Subroutine visitTypeDeclarator: not called CC=1 SCAR=0.0
Pod undocumented
312 # empty
313 }
314
315 0 ▶sub visitNativeType {
Subroutine visitNativeType: not called CC=1 SCAR=0.0
Pod undocumented
316 # C mapping is aligned with CORBA 2.1
317 }
318
319 #
320 # 3.11.2 Constructed Types
321 #
322
323 0 ▶sub visitStructType {
Subroutine visitStructType: not called CC=1 SCAR=0.0
Pod undocumented
324 # empty
325 }
326
327 0 ▶sub visitUnionType {
Subroutine visitUnionType: not called CC=1 SCAR=0.0
Pod undocumented
328 # empty
329 }
330
331 0 ▶sub visitEnumType {
Subroutine visitEnumType: not called CC=1 SCAR=0.0
Pod undocumented
332 # empty
333 }
334
335 #
336 # 3.12 Exception Declaration
337 #
338
339 0 ▶sub visitException {
Subroutine visitException: not called CC=1 SCAR=0.0
Pod undocumented
340 # empty
341 }
342
343 #
344 # 3.13 Operation Declaration
345 #
346
347 0 ▶sub visitOperation {
Subroutine visitOperation: not called CC=2 SCAR=17.9
Pod undocumented
348 0 my $self = shift;
349 0 my ($node) = @_;
350 0 my $type = $self->_get_type($node->{type});
351 0 $node->{c_arg} = $self->_get_c_arg($type, q{}, 'return');
352 0 foreach (@{$node->{list_param}}) { # parameter
353 0 $type = $self->_get_type($_->{type});
354 0 $_->{c_arg} = $self->_get_c_arg($type, $_->{c_name}, $_->{attr});
355 }
356 }
357
358 #
359 # 3.14 Attribute Declaration
360 #
361
362 0 ▶sub visitAttribute {
Subroutine visitAttribute: not called CC=2 SCAR=17.9
Pod undocumented
363 0 my $self = shift;
364 0 my ($node) = @_;
365 0 $node->{_get}->visit($self);
366 0 ▶ $node->{_set}->visit($self) if (exists $node->{_set});
Branch: 1 branch
BranchTrueFalseTotal
if exists $node->{"_set"} 0 0 0
367 }
368
369 #
370 # 3.15 Repository Identity Related Declarations
371 #
372
373 0 ▶sub visitTypeId {
Subroutine visitTypeId: not called CC=1 SCAR=0.0
Pod undocumented
374 # empty
375 }
376
377 0 ▶sub visitTypePrefix {
Subroutine visitTypePrefix: not called CC=1 SCAR=0.0
Pod undocumented
378 # empty
379 }
380
381 #
382 # 3.16 Event Declaration
383 #
384
385 #
386 # 3.17 Component Declaration
387 #
388
389 0 ▶sub visitProvides {
Subroutine visitProvides: not called CC=1 SCAR=0.0
Pod undocumented
390 # empty
391 }
392
393 0 ▶sub visitUses {
Subroutine visitUses: not called CC=1 SCAR=0.0
Pod undocumented
394 # empty
395 }
396
397 0 ▶sub visitPublishes {
Subroutine visitPublishes: not called CC=1 SCAR=0.0
Pod undocumented
398 # empty
399 }
400
401 0 ▶sub visitEmits {
Subroutine visitEmits: not called CC=1 SCAR=0.0
Pod undocumented
402 # empty
403 }
404
405 0 ▶sub visitConsumes {
Subroutine visitConsumes: not called CC=1 SCAR=0.0
Pod undocumented
406 # empty
407 }
408
409 #
410 # 3.18 Home Declaration
411 #
412
413 0 ▶sub visitFactory {
Subroutine visitFactory: not called CC=2 SCAR=17.9
Pod undocumented
414 # C mapping is aligned with CORBA 2.1
415 0 my $self = shift;
416 0 my ($node) = @_;
417 0 foreach (@{$node->{list_param}}) { # parameter
418 0 my $type = $self->_get_type($_->{type});
419 0 $_->{c_arg} = $self->_get_c_arg($type, $_->{c_name}, $_->{attr});
420 }
421 }
422
423 0 ▶sub visitFinder {
Subroutine visitFinder: not called CC=2 SCAR=17.9
Pod undocumented
424 # C mapping is aligned with CORBA 2.1
425 0 my $self = shift;
426 0 my ($node) = @_;
427 0 foreach (@{$node->{list_param}}) { # parameter
428 0 my $type = $self->_get_type($_->{type});
429 0 $_->{c_arg} = $self->_get_c_arg($type, $_->{c_name}, $_->{attr});
430 }
431 }
432
433 1 1;
434
↑ Summary C/IncludeVisitor.pm »