C/NameVisitor.pm

filter: Statementstmt 4.0% 8 / 199 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 4.5% 2 / 44 Podpod 0.0% 0 / 40 totaltotal 3.1% 10 / 319 CC 30 SCAR 18.7
CC
30
Cov
3%
visitSpecification
20.0
visitBaseInterface
12.0
visitStructType
12.0
CRAP 6.5
« C/SkeletonVisitor.pm ↑ Summary C/IncSkelVisitor.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::NameVisitor;
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.60';
14
15 # builds $node->{c_name}
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->{key} = 'c_name';
24 0 $self->{symbtab} = $parser->YYData->{symbtab};
25 0 return $self;
26 }
27
28 0 ▶sub _get_defn {
Subroutine _get_defn: not called CC=2 SCAR=17.9
29 0 my $self = shift;
30 0 my ($defn) = @_;
31 0 ▶ if (ref $defn) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $defn) { } 0 0 0
32 0 return $defn;
33 }
34 else {
35 0 return $self->{symbtab}->Lookup($defn);
36 }
37 }
38
39 #
40 # See 1.2 Scoped Names
41 #
42 0 ▶sub _get_name {
Subroutine _get_name: not called CC=1 SCAR=6.9
43 0 my $self = shift;
44 0 my ($node) = @_;
45 0 my $name = $node->{full};
46 0 $name =~ s/^:://;
47 0 $name =~ s/::/_/g;
48 0 return $name;
49 }
50
51 #
52 # 3.5 OMG IDL Specification
53 #
54
55 0 ▶sub visitSpecification {
Subroutine visitSpecification: not called CC=4 SCAR=30.0
Pod undocumented
56 0 my $self = shift;
57 0 my ($node) = @_;
58 0 ▶ if (exists $node->{list_import}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{"list_import"}) 0 0 0
59 0 foreach (@{$node->{list_import}}) {
60 0 $_->visit($self);
61 }
62 }
63 0 foreach (@{$node->{list_export}}) {
64 0 $self->{symbtab}->Lookup($_)->visit($self);
65 }
66 }
67
68 #
69 # 3.6 Import Declaration
70 #
71
72 0 ▶sub visitImport {
Subroutine visitImport: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my $self = shift;
74 0 my ($node) = @_;
75 0 foreach (@{$node->{list_decl}}) {
76 0 $self->{symbtab}->Lookup($_)->visit($self);
77 }
78 }
79
80 #
81 # 3.7 Module Declaration
82 #
83
84 0 ▶sub visitModules {
Subroutine visitModules: not called CC=2 SCAR=17.9
Pod undocumented
85 0 my $self = shift;
86 0 my ($node) = @_;
87 0 $node->{$self->{key}} = $self->_get_name($node);
88 0 foreach (@{$node->{list_export}}) {
89 0 $self->{symbtab}->Lookup($_)->visit($self);
90 }
91 }
92
93 #
94 # 3.8 Interface Declaration
95 #
96
97 0 ▶sub visitBaseInterface {
Subroutine visitBaseInterface: not called CC=3 SCAR=24.8
Pod undocumented
98 0 my $self = shift;
99 0 my ($node) = @_;
100 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
101 0 $node->{$self->{key}} = $self->_get_name($node);
102 0 foreach (@{$node->{list_export}}) {
103 0 $self->{symbtab}->Lookup($_)->visit($self);
104 }
105 }
106
107 0 ▶sub visitForwardBaseInterface {
Subroutine visitForwardBaseInterface: not called CC=2 SCAR=17.9
Pod undocumented
108 0 my $self = shift;
109 0 my ($node) = @_;
110 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
111 0 $node->{$self->{key}} = $self->_get_name($node);
112 }
113
114 #
115 # 3.9 Value Declaration
116 #
117
118 0 ▶sub visitStateMember {
Subroutine visitStateMember: not called CC=1 SCAR=6.9
Pod undocumented
119 # C mapping is aligned with CORBA 2.1
120 0 my $self = shift;
121 0 my ($node) = @_;
122 0 $node->{$self->{key}} = $self->_get_name($node);
123 0 $self->_get_defn($node->{type})->visit($self);
124 }
125
126 0 ▶sub visitInitializer {
Subroutine visitInitializer: not called CC=2 SCAR=17.9
Pod undocumented
127 # C mapping is aligned with CORBA 2.1
128 0 my $self = shift;
129 0 my ($node) = @_;
130 0 $node->{$self->{key}} = $node->{idf};
131 0 foreach (@{$node->{list_param}}) {
132 0 $_->visit($self); # parameter
133 }
134 }
135
136 #
137 # 3.10 Constant Declaration
138 #
139
140 0 ▶sub visitConstant {
Subroutine visitConstant: not called CC=1 SCAR=6.9
Pod undocumented
141 0 my $self = shift;
142 0 my ($node) = @_;
143 0 $node->{$self->{key}} = $self->_get_name($node);
144 }
145
146 0 ▶sub visitExpression {
Subroutine visitExpression: not called CC=1 SCAR=0.0
Pod undocumented
147 # empty
148 }
149
150 #
151 # 3.11 Type Declaration
152 #
153
154 0 ▶sub visitTypeDeclarator {
Subroutine visitTypeDeclarator: not called CC=1 SCAR=6.9
Pod undocumented
155 0 my $self = shift;
156 0 my ($node) = @_;
157 0 $node->{$self->{key}} = $self->_get_name($node);
158 0 $self->_get_defn($node->{type})->visit($self);
159 }
160
161 0 ▶sub visitNativeType {
Subroutine visitNativeType: not called CC=1 SCAR=6.9
Pod undocumented
162 0 my $self = shift;
163 0 my ($node) = @_;
164 0 $node->{$self->{key}} = $node->{idf};
165 }
166
167 #
168 # 3.11.1 Basic Types
169 #
170 # See 1.7 Mapping for Basic Data Types
171 #
172
173 0 ▶sub visitBasicType {
Subroutine visitBasicType: not called CC=1 SCAR=6.9
Pod undocumented
174 0 my $self = shift;
175 0 my ($node) = @_;
176 0 my $name = $node->{value};
177 0 $name =~ s/ /_/g;
178 0 $node->{$self->{key}} = 'CORBA_' . $name;
179 }
180
181 #
182 # 3.11.2 Constructed Types
183 #
184 # 3.11.2.1 Structures
185 #
186
187 0 ▶sub visitStructType {
Subroutine visitStructType: not called CC=3 SCAR=24.8
Pod undocumented
188 0 my $self = shift;
189 0 my ($node) = @_;
190 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
191 0 $node->{$self->{key}} = $self->_get_name($node);
192 0 foreach (@{$node->{list_member}}) {
193 0 $self->_get_defn($_)->visit($self); # member
194 }
195 }
196
197 0 ▶sub visitMember {
Subroutine visitMember: not called CC=1 SCAR=6.9
Pod undocumented
198 0 my $self = shift;
199 0 my ($node) = @_;
200 0 $node->{$self->{key}} = $node->{idf};
201 0 $self->_get_defn($node->{type})->visit($self);
202 }
203
204 # 3.11.2.2 Discriminated Unions
205 #
206
207 0 ▶sub visitUnionType {
Subroutine visitUnionType: not called CC=3 SCAR=24.8
Pod undocumented
208 0 my $self = shift;
209 0 my ($node) = @_;
210 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
211 0 $node->{$self->{key}} = $self->_get_name($node);
212 0 $self->_get_defn($node->{type})->visit($self);
213 0 foreach (@{$node->{list_expr}}) {
214 0 $_->visit($self); # case
215 }
216 }
217
218 0 ▶sub visitCase {
Subroutine visitCase: not called CC=2 SCAR=17.9
Pod undocumented
219 0 my $self = shift;
220 0 my ($node) = @_;
221 0 foreach (@{$node->{list_label}}) {
222 0 $_->visit($self); # default or expression
223 }
224 0 $node->{element}->visit($self);
225 }
226
227 0 ▶sub visitDefault {
Subroutine visitDefault: not called CC=1 SCAR=0.0
Pod undocumented
228 # empty
229 }
230
231 0 ▶sub visitElement {
Subroutine visitElement: not called CC=1 SCAR=6.9
Pod undocumented
232 0 my $self = shift;
233 0 my ($node) = @_;
234 0 $self->_get_defn($node->{value})->visit($self); # member
235 }
236
237 # 3.11.2.4 Enumerations
238 #
239
240 0 ▶sub visitEnumType {
Subroutine visitEnumType: not called CC=2 SCAR=17.9
Pod undocumented
241 0 my $self = shift;
242 0 my ($node) = @_;
243 0 $node->{$self->{key}} = $self->_get_name($node);
244 0 foreach (@{$node->{list_expr}}) {
245 0 $_->visit($self); # enum
246 }
247 }
248
249 0 ▶sub visitEnum {
Subroutine visitEnum: not called CC=1 SCAR=6.9
Pod undocumented
250 0 my $self = shift;
251 0 my ($node) = @_;
252 0 $node->{$self->{key}} = $self->_get_name($node);
253 }
254
255 #
256 # 3.11.3 Template Types
257 #
258 # See 1.11 Mapping for Sequence Types
259 #
260
261 0 ▶sub visitSequenceType {
Subroutine visitSequenceType: not called CC=3 SCAR=24.8
Pod undocumented
262 0 my $self = shift;
263 0 my ($node) = @_;
264 0 my $type = $self->_get_defn($node->{type});
265 0 ▶ while ( $type->isa('TypeDeclarator')
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("TypeDeclarator") and not exists $type->{"array_size"}) 0 0 0
Condition0%0/3
$type->isa("TypeDeclarator") and not exists $type->{"array_size"}
!ll&&!rl&&r
000
MC/DC0%0/2
$type->isa("TypeDeclarator") and not exists $type->{"array_size"}
$type->isa("TypeDeclarator") not exists $type->{"array_size"}
Truth table0%0/3
A and not(B)
A= $type->isa("TypeDeclarator")B= not exists $type->{"array_size"}
ABresult
0X0
100
111
266 and ! exists $type->{array_size} ) {
267 0 $type = $self->_get_defn($type->{type});
268 }
269 0 $type->visit($self);
270 0 my $name = $type->{$self->{key}};
271 0 $name =~ s/^CORBA_//;
272 0 $node->{$self->{key}} = 'CORBA_sequence_' . $name;
273 }
274
275 #
276 # See 1.12 Mapping for Strings
277 #
278
279 0 ▶sub visitStringType {
Subroutine visitStringType: not called CC=1 SCAR=6.9
Pod undocumented
280 0 my $self = shift;
281 0 my ($node) = @_;
282 0 $node->{$self->{key}} = 'CORBA_string';
283 }
284
285 #
286 # See 1.13 Mapping for Wide Strings
287 #
288
289 0 ▶sub visitWideStringType {
Subroutine visitWideStringType: not called CC=1 SCAR=6.9
Pod undocumented
290 0 my $self = shift;
291 0 my ($node) = @_;
292 0 $node->{$self->{key}} = 'CORBA_wstring';
293 }
294
295 #
296 # See 1.14 Mapping for Fixed
297 #
298
299 0 ▶sub visitFixedPtType {
Subroutine visitFixedPtType: not called CC=1 SCAR=6.9
Pod undocumented
300 0 my $self = shift;
301 0 my ($node) = @_;
302 0 my $name = 'CORBA_fixed_' . $node->{d}->{value} . '_' . $node->{s}->{value};
303 0 $node->{$self->{key}} = $name;
304 }
305
306 0 ▶sub visitFixedPtConstType {
Subroutine visitFixedPtConstType: not called CC=1 SCAR=6.9
Pod undocumented
307 0 my $self = shift;
308 0 my ($node) = @_;
309 0 my $name = 'CORBA_fixed';
310 0 $node->{$self->{key}} = $name;
311 }
312
313 #
314 # 3.12 Exception Declaration
315 #
316
317 0 ▶sub visitException {
Subroutine visitException: not called CC=2 SCAR=17.9
Pod undocumented
318 0 my $self = shift;
319 0 my ($node) = @_;
320 0 $node->{$self->{key}} = $self->_get_name($node);
321 0 foreach (@{$node->{list_member}}) {
322 0 $self->_get_defn($_)->visit($self); # member
323 }
324 }
325
326 #
327 # 3.13 Operation Declaration
328 #
329 # See 1.4 Inheritance and Operation Names
330 #
331
332 0 ▶sub visitOperation {
Subroutine visitOperation: not called CC=2 SCAR=17.9
Pod undocumented
333 0 my $self = shift;
334 0 my ($node) = @_;
335 0 $node->{$self->{key}} = $node->{idf};
336 0 $self->_get_defn($node->{type})->visit($self);
337 0 foreach (@{$node->{list_param}}) {
338 0 $_->visit($self); # parameter
339 }
340 }
341
342 0 ▶sub visitParameter {
Subroutine visitParameter: not called CC=1 SCAR=6.9
Pod undocumented
343 0 my $self = shift;
344 0 my ($node) = @_;
345 0 $node->{$self->{key}} = $node->{idf};
346 0 $self->_get_defn($node->{type})->visit($self);
347 }
348
349 0 ▶sub visitVoidType {
Subroutine visitVoidType: not called CC=1 SCAR=6.9
Pod undocumented
350 0 my $self = shift;
351 0 my ($node) = @_;
352 0 $node->{$self->{key}} = 'void';
353 }
354
355 #
356 # 3.14 Attribute Declaration
357 #
358
359 0 ▶sub visitAttribute {
Subroutine visitAttribute: not called CC=2 SCAR=17.9
Pod undocumented
360 0 my $self = shift;
361 0 my ($node) = @_;
362 0 $node->{_get}->visit($self);
363 0 ▶ $node->{_set}->visit($self) if (exists $node->{_set});
Branch: 1 branch
BranchTrueFalseTotal
if exists $node->{"_set"} 0 0 0
364 }
365
366 #
367 # 3.15 Repository Identity Related Declarations
368 #
369
370 0 ▶sub visitTypeId {
Subroutine visitTypeId: not called CC=1 SCAR=0.0
Pod undocumented
371 # empty
372 }
373
374 0 ▶sub visitTypePrefix {
Subroutine visitTypePrefix: not called CC=1 SCAR=0.0
Pod undocumented
375 # empty
376 }
377
378 #
379 # 3.17 Component Declaration
380 #
381
382 0 ▶sub visitProvides {
Subroutine visitProvides: not called CC=2 SCAR=17.9
Pod undocumented
383 # C mapping is aligned with CORBA 2.1
384 0 my $self = shift;
385 0 my ($node) = @_;
386 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
387 0 $node->{$self->{key}} = $self->_get_name($node);
388 }
389
390 0 ▶sub visitUses {
Subroutine visitUses: not called CC=2 SCAR=17.9
Pod undocumented
391 # C mapping is aligned with CORBA 2.1
392 0 my $self = shift;
393 0 my ($node) = @_;
394 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
395 0 $node->{$self->{key}} = $self->_get_name($node);
396 }
397
398 0 ▶sub visitPublishes {
Subroutine visitPublishes: not called CC=2 SCAR=17.9
Pod undocumented
399 # C mapping is aligned with CORBA 2.1
400 0 my $self = shift;
401 0 my ($node) = @_;
402 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
403 0 $node->{$self->{key}} = $self->_get_name($node);
404 }
405
406 0 ▶sub visitEmits {
Subroutine visitEmits: not called CC=2 SCAR=17.9
Pod undocumented
407 # C mapping is aligned with CORBA 2.1
408 0 my $self = shift;
409 0 my ($node) = @_;
410 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
411 0 $node->{$self->{key}} = $self->_get_name($node);
412 }
413
414 0 ▶sub visitConsumes {
Subroutine visitConsumes: not called CC=2 SCAR=17.9
Pod undocumented
415 # C mapping is aligned with CORBA 2.1
416 0 my $self = shift;
417 0 my ($node) = @_;
418 0 ▶ return if (exists $node->{$self->{key}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $$node{$self->{"key"}} 0 0 0
419 0 $node->{$self->{key}} = $self->_get_name($node);
420 }
421
422 #
423 # 3.18 Home Declaration
424 #
425
426 0 ▶sub visitFactory {
Subroutine visitFactory: not called CC=2 SCAR=17.9
Pod undocumented
427 # C mapping is aligned with CORBA 2.1
428 0 my $self = shift;
429 0 my ($node) = @_;
430 0 $node->{$self->{key}} = $node->{idf};
431 0 foreach (@{$node->{list_param}}) {
432 0 $_->visit($self); # parameter
433 }
434 }
435
436 0 ▶sub visitFinder {
Subroutine visitFinder: not called CC=2 SCAR=17.9
Pod undocumented
437 # C mapping is aligned with CORBA 2.1
438 0 my $self = shift;
439 0 my ($node) = @_;
440 0 $node->{$self->{key}} = $node->{idf};
441 0 foreach (@{$node->{list_param}}) {
442 0 $_->visit($self); # parameter
443 }
444 }
445
446 1 1;
447
« C/SkeletonVisitor.pm ↑ Summary C/IncSkelVisitor.pm »