Cplusplus/TypeVisitor.pm

filter: Statementstmt 10.6% 14 / 131 Branchbran 0.0% 0 / 114 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 5 totaltotal 6.2% 18 / 290 CC 68 SCAR 81.0
CC
68
Cov
5%
_get_cpp_arg
4032.0
new
6.0
visitInitializer
6.0
CRAP 3299.7
↑ Summary Cplusplus/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::Cplusplus::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 = '0.41';
14
15 1 ▶use CORBA::C::TypeVisitor;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use base qw(CORBA::C::TypeVisitor);
Subroutine BEGIN: called CC=1 SCAR=0.0
17
18 # builds $node->{cpp_arg}
19
20 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my $proto = shift;
22 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
23 0 my $self = {};
24 0 bless $self, $class;
25 0 my ($parser) = @_;
26 0 $self->{srcname} = $parser->YYData->{srcname};
27 0 $self->{symbtab} = $parser->YYData->{symbtab};
28 0 return $self;
29 }
30
31 #
32 # See 1.22 Argument Passing Considerations
33 #
34
35 0 ▶sub _get_cpp_arg {
Subroutine _get_cpp_arg: not called CC=63 SCAR=83.0
36 0 my $self = shift;
37 0 my ($type, $v_name, $attr) = @_;
38
39 0 ▶ if ( $type->isa('BasicType')
Branch: 11 branches
BranchTrueFalseTotal
if ($type->isa('BasicType') or $type->isa('EnumType')) { } 0 0 0
elsif ($type->isa('Value') or $type->isa('ForwardValue')) { } 0 0 0
elsif ($type->isa('BaseInterface') or $type->isa('ForwardBaseInterface')) { } 0 0 0
elsif ($type->isa('StructType') or $type->isa('UnionType')) { } 0 0 0
elsif ($type->isa('StringType') or $type->isa('WideStringType')) { } 0 0 0
elsif ($type->isa('SequenceType')) { } 0 0 0
elsif ($type->isa('TypeDeclarator')) { } 0 0 0
elsif ($type->isa('NativeType')) { } 0 0 0
elsif ($type->isa('AnyType')) { } 0 0 0
elsif ($type->isa('FixedPtType')) { } 0 0 0
elsif ($type->isa('VoidType')) { } 0 0 0
Condition0%0/3
$type->isa("BasicType") or $type->isa("EnumType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("BasicType") or $type->isa("EnumType")
$type->isa("BasicType") $type->isa("EnumType")
Truth table0%0/3
A or B
A= $type->isa("BasicType")B= $type->isa("EnumType")
ABresult
1X1
011
000
40 or $type->isa('EnumType') ) {
41 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
42 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
43 0 return $t_name . q{ } . $v_name;
44 }
45 elsif ( $attr eq 'inout' ) {
46 0 return $t_name . '_out ' . $v_name;
47 }
48 elsif ( $attr eq 'out' ) {
49 0 return $t_name . '_out ' . $v_name;
50 }
51 elsif ( $attr eq 'return' ) {
52 0 return $t_name;
53 }
54 }
55 ▶ elsif ( $type->isa('Value')
Condition0%0/3
$type->isa("Value") or $type->isa("ForwardValue")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("Value") or $type->isa("ForwardValue")
$type->isa("Value") $type->isa("ForwardValue")
Truth table0%0/3
A or B
A= $type->isa("Value")B= $type->isa("ForwardValue")
ABresult
1X1
011
000
56 or $type->isa('ForwardValue') ) {
57 0 my $t_name = $type->{cpp_name};
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 $t_name . '* ' . $v_name;
60 }
61 elsif ( $attr eq 'inout' ) {
62 0 return $t_name . '** ' . $v_name;
63 }
64 elsif ( $attr eq 'out' ) {
65 0 return $t_name . '** ' . $v_name;
66 }
67 elsif ( $attr eq 'return' ) {
68 0 return $t_name;
69 }
70 }
71 ▶ elsif ( $type->isa('BaseInterface')
Condition0%0/3
$type->isa("BaseInterface") or $type->isa("ForwardBaseInterface")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("BaseInterface") or $type->isa("ForwardBaseInterface")
$type->isa("BaseInterface") $type->isa("ForwardBaseInterface")
Truth table0%0/3
A or B
A= $type->isa("BaseInterface")B= $type->isa("ForwardBaseInterface")
ABresult
1X1
011
000
72 or $type->isa('ForwardBaseInterface') ) {
73 0 my $t_name = $type->{cpp_name};
74 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
75 0 return $t_name . '_ptr ' . $v_name;
76 }
77 elsif ( $attr eq 'inout' ) {
78 0 return $t_name . '_out ' . $v_name;
79 }
80 elsif ( $attr eq 'out' ) {
81 0 return $t_name . '_out ' . $v_name;
82 }
83 elsif ( $attr eq 'return' ) {
84 0 return $t_name . '_ptr';
85 }
86 }
87 ▶ elsif ( $type->isa('StructType')
Condition0%0/3
$type->isa("StructType") or $type->isa("UnionType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("StructType") or $type->isa("UnionType")
$type->isa("StructType") $type->isa("UnionType")
Truth table0%0/3
A or B
A= $type->isa("StructType")B= $type->isa("UnionType")
ABresult
1X1
011
000
88 or $type->isa('UnionType') ) {
89 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
90 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
91 0 return $t_name . ' * ' . $v_name;
92 }
93 elsif ( $attr eq 'inout' ) {
94 0 return $t_name . ' * ' . $v_name;
95 }
96 elsif ( $attr eq 'out' ) {
97 0 ▶ if (defined $type->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type->{'length'}) { } 0 0 0
98 0 return $t_name . ' ** ' . $v_name;
99 }
100 else {
101 0 return $t_name . ' * ' . $v_name;
102 }
103 }
104 elsif ( $attr eq 'return' ) {
105 0 ▶ if (defined $type->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type->{'length'}) { } 0 0 0
106 0 return $t_name . ' *';
107 }
108 else {
109 0 return $t_name;
110 }
111 }
112 }
113 ▶ elsif ( $type->isa('StringType')
Condition0%0/3
$type->isa("StringType") or $type->isa("WideStringType")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("StringType") or $type->isa("WideStringType")
$type->isa("StringType") $type->isa("WideStringType")
Truth table0%0/3
A or B
A= $type->isa("StringType")B= $type->isa("WideStringType")
ABresult
1X1
011
000
114 or $type->isa('WideStringType') ) {
115 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
116 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
117 0 return 'const ' . $t_name . q{ } . $v_name;
118 }
119 elsif ( $attr eq 'inout' ) {
120 0 return $t_name . '_out ' . $v_name;
121 }
122 elsif ( $attr eq 'out' ) {
123 0 return $t_name . '_out ' . $v_name;
124 }
125 elsif ( $attr eq 'return' ) {
126 0 return $t_name;
127 }
128 }
129 elsif ( $type->isa('SequenceType') ) { # TODO
130 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
131 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
132 0 return $t_name . ' * ' . $v_name;
133 }
134 elsif ( $attr eq 'inout' ) {
135 0 return $t_name . ' * ' . $v_name;
136 }
137 elsif ( $attr eq 'out' ) {
138 0 return $t_name . ' ** ' . $v_name;
139 }
140 elsif ( $attr eq 'return' ) {
141 0 return $t_name . ' *';
142 }
143 }
144 elsif ( $type->isa('TypeDeclarator') ) { # TODO
145 0 ▶ if (exists $type->{array_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $type->{'array_size'}) { } 0 0 0
146 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
147 # my $t_name = $type->{type}->{c_name};
148 # my $array = q{};
149 # foreach (@{$type->{array_size}}) {
150 # $array .= '[' . $_->{c_literal} . ']';
151 # }
152 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
153 # return $t_name . q{ } . $v_name . $array;
154 0 return $t_name . q{ } . $v_name;
155 }
156 elsif ( $attr eq 'inout' ) {
157 # return $t_name . q{ } . $v_name . $array;
158 0 return $t_name . q{ } . $v_name;
159 }
160 elsif ( $attr eq 'out' ) {
161 0 ▶ if (defined $type->{length}) { # variable
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type->{'length'}) { } 0 0 0
162 0 return $t_name . '_slice ** ' . $v_name;
163 }
164 else {
165 # return $t_name . q{ } . $v_name . $array;
166 0 return $t_name . q{ } . $v_name;
167 }
168 }
169 elsif ( $attr eq 'return' ) {
170 0 return $t_name . '_slice *';
171 }
172 }
173 else {
174 0 my $type = $type->{type};
175 0 ▶ unless (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $type) 0 0 0
176 0 $type = $self->{symbtab}->Lookup($type);
177 }
178 0 return $self->_get_cpp_arg($type, $v_name, $attr);
179 }
180 }
181 elsif ( $type->isa('NativeType') ) {
182 0 my $t_name = $type->{cpp_name};
183 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
184 0 return $t_name . q{ } . $v_name;
185 }
186 elsif ( $attr eq 'inout' ) {
187 0 return $t_name . ' * ' . $v_name;
188 }
189 elsif ( $attr eq 'out' ) {
190 0 return $t_name . ' * ' . $v_name;
191 }
192 elsif ( $attr eq 'return' ) {
193 0 return $t_name;
194 }
195 }
196 elsif ( $type->isa('AnyType') ) { # TODO
197 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
198 0 $type->{length} = 'variable';
199 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
200 0 return $t_name . ' * ' . $v_name;
201 }
202 elsif ( $attr eq 'inout' ) {
203 0 return $t_name . ' * ' . $v_name;
204 }
205 elsif ( $attr eq 'out' ) {
206 0 return $t_name . ' ** ' . $v_name;
207 }
208 elsif ( $attr eq 'return' ) {
209 0 return $t_name . ' *';
210 }
211 }
212 elsif ( $type->isa('FixedPtType') ) { # TODO
213 0 my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
214 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
215 0 return $t_name . ' * ' . $v_name;
216 }
217 elsif ( $attr eq 'inout' ) {
218 0 return $t_name . ' * ' . $v_name;
219 }
220 elsif ( $attr eq 'out' ) {
221 0 return $t_name . ' * ' . $v_name;
222 }
223 elsif ( $attr eq 'return' ) {
224 0 return $t_name;
225 }
226 }
227 elsif ( $type->isa('VoidType') ) {
228 0 my $t_name = $type->{cpp_name};
229 0 ▶ if ($attr eq 'return') {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr eq "return") 0 0 0
230 0 return $t_name;
231 }
232 }
233 else {
234 0 my $class = ref $type;
235 0 warn "Please implement '$class' in '_get_cpp_arg'.\n";
236 0 return;
237 }
238 0 my $class = ref $type;
239 0 warn "_get_cpp_arg : ERROR_INTERNAL $class $attr \n";
240 }
241
242 #
243 # 3.9 Value Declaration
244 #
245
246 0 ▶sub visitInitializer {
Subroutine visitInitializer: not called CC=2 SCAR=17.9
Pod undocumented
247 0 my $self = shift;
248 0 my ($node) = @_;
249 0 foreach (@{$node->{list_param}}) { # parameter
250 0 my $type = $self->_get_type($_->{type});
251 0 $_->{cpp_arg} = $self->_get_cpp_arg($type, $_->{cpp_name}, $_->{attr});
252 }
253 }
254
255 #
256 # 3.13 Operation Declaration
257 #
258
259 0 ▶sub visitOperation {
Subroutine visitOperation: not called CC=2 SCAR=17.9
Pod undocumented
260 0 my $self = shift;
261 0 my ($node) = @_;
262 0 my $type = $self->_get_type($node->{type});
263 0 $node->{cpp_arg} = $self->_get_cpp_arg($type, q{}, 'return');
264 0 foreach (@{$node->{list_param}}) { # parameter
265 0 $type = $self->_get_type($_->{type});
266 0 $_->{cpp_arg} = $self->_get_cpp_arg($type, $_->{cpp_name}, $_->{attr});
267 }
268 }
269
270 #
271 # 3.18 Home Declaration
272 #
273
274 0 ▶sub visitFactory {
Subroutine visitFactory: not called CC=2 SCAR=17.9
Pod undocumented
275 # C++ mapping is aligned with CORBA 2.3
276 0 my $self = shift;
277 0 my ($node) = @_;
278 0 foreach (@{$node->{list_param}}) { # parameter
279 0 my $type = $self->_get_type($_->{type});
280 0 $_->{cpp_arg} = $self->_get_cpp_arg($type, $_->{cpp_name}, $_->{attr});
281 }
282 }
283
284 0 ▶sub visitFinder {
Subroutine visitFinder: not called CC=2 SCAR=17.9
Pod undocumented
285 # C++ mapping is aligned with CORBA 2.3
286 0 my $self = shift;
287 0 my ($node) = @_;
288 0 foreach (@{$node->{list_param}}) { # parameter
289 0 my $type = $self->_get_type($_->{type});
290 0 $_->{cpp_arg} = $self->_get_cpp_arg($type, $_->{cpp_name}, $_->{attr});
291 }
292 }
293
294 1 1;
295
↑ Summary Cplusplus/IncludeVisitor.pm »