CORBA/TypeCode.pm

filter: Statementstmt 17.0% 24 / 141 Branchbran 0.0% 0 / 58 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 16.6% 4 / 24 Podpod n/a totaltotal 11.3% 28 / 246 CC 35 SCAR 54.6
CC
35
Cov
11%
_unmarshal
552.0
_needs_ref
90.0
_create_struct_tc
6.0
CRAP 234.2
↑ Summary CORBA/Request.pm »
1 # $Id: TypeCode.pm,v 1.1.1.1 1997/05/17 11:47:05 schuller Exp $
2 # Copyright (c) 1997 Lunatech Research / Bart Schuller <schuller@lunatech.com>
3 # See the file "Artistic" in the distribution for licensing and
4 # (lack of) warranties.
5  
6 package COPE::CORBA::TypeCode;
7 6 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
8 6 shift;
9 6 my $callpkg = caller(0);
10 6 CORBA::TypeCode->export($callpkg, @_);
11 }
12  
13 # interface TypeCode // PIDL
14 package CORBA::TypeCode;
15 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 require Exporter;
17 3 @CORBA::TypeCode::ISA = qw(Exporter);
18 3 @CORBA::TypeCode::EXPORT = qw(
19 _create_struct_tc _create_union_tc _create_enum_tc
20 _create_alias_tc _create_exception_tc _create_interface_tc
21 _create_string_tc _create_sequence_tc
22 _create_recursive_sequence_tc _create_array_tc
23 );
24 3 ▶use COPE::CORBA::TCKind;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 @CORBA::_tc_basic = (
26 $CORBA::_tc_null = CORBA::TypeCode->_new_basic(tk_null),
27 $CORBA::_tc_void = CORBA::TypeCode->_new_basic(tk_void),
28 $CORBA::_tc_short = CORBA::TypeCode->_new_basic(tk_short),
29 $CORBA::_tc_long = CORBA::TypeCode->_new_basic(tk_long),
30 $CORBA::_tc_ushort = CORBA::TypeCode->_new_basic(tk_ushort),
31 $CORBA::_tc_ulong = CORBA::TypeCode->_new_basic(tk_ulong),
32 $CORBA::_tc_float = CORBA::TypeCode->_new_basic(tk_float),
33 $CORBA::_tc_double = CORBA::TypeCode->_new_basic(tk_double),
34 $CORBA::_tc_boolean = CORBA::TypeCode->_new_basic(tk_boolean),
35 $CORBA::_tc_char = CORBA::TypeCode->_new_basic(tk_char),
36 $CORBA::_tc_octet = CORBA::TypeCode->_new_basic(tk_octet),
37 $CORBA::_tc_any = CORBA::TypeCode->_new_basic(tk_any),
38 $CORBA::_tc_TypeCode = CORBA::TypeCode->_new_basic(tk_TypeCode),
39 $CORBA::_tc_Principal = CORBA::TypeCode->_new_basic(tk_Principal),
40 );
41  
42 3 my(%has_id_and_name) = map { $_ => 1 } (tk_objref, tk_struct, tk_union, tk_enum, tk_alias, tk_except);
43 3 my(%has_members) = map { $_ => 1 } (tk_struct, tk_union, tk_enum, tk_except);
44 3 my(%has_type) = map { $_ => 1 } (tk_sequence, tk_array, tk_alias);
45 3 my(%has_length) = map { $_ => 1 } (tk_sequence, tk_array);
46  
47 42 ▶sub _new_basic {
Subroutine _new_basic: called CC=1 SCAR=0.0
48 42 my($class, $tk) = @_;
49 42 return bless {_kind => $tk}, $class;
50 }
51  
52 0 ▶sub _unmarshal {
Subroutine _unmarshal: not called CC=23 SCAR=63.1
53 0 my $kind = CORBA::ORB::_unmarshal_ulong(@_);
54 0 my $self = {};
55 0 ▶ if ($kind <= 13) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind <= 13) { } 0 0 0
56 0 return $CORBA::_tc_basic[$kind];
57 } else {
58 0 $self->{_kind} = $kind;
59 }
60 0 ▶ if ($self->{_kind} == 0xffffffff) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_kind'} == 4294967295) { } 0 0 0
elsif ($self->{'_kind'} == 18) { } 0 0 0
61 0 die "CORBA::TypeCode::_unmarshal got an indirection: " . CORBA::ORB::_unmarshal_ulong(@_);
62 } elsif ($self->{_kind} == tk_string) {
63 0 $self->{_length} = CORBA::ORB::_unmarshal_ulong(@_);
64 } else {
65 #
66 # if we get here, we have parameters in "complex" encoding.
67 #
68 0 my($byte_order) = $_[2];
69 0 my($cdrin, $index) = ('', 0);
70 0 $cdrin = CORBA::ORB::_unmarshal_octet_sequence(@_);
71 0 @_ = (\$cdrin, \$index, $byte_order);
72 0 $byte_order = $_[2] = CORBA::ORB::_unmarshal_boolean(@_);
73 0 ▶ if ($has_id_and_name{$self->{_kind}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_id_and_name{$self->{"_kind"}}) 0 0 0
74 0 $self->{_id} = CORBA::ORB::_unmarshal_string(@_);
75 0 $self->{_name} = CORBA::ORB::_unmarshal_string(@_);
76 }
77 0 ▶ if ($self->{_kind} == tk_union) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_kind"} == 16) 0 0 0
78 0 $self->{_discriminator_type} = CORBA::TypeCode::_unmarshal(@_);
79 0 $self->{_default_index} = CORBA::ORB::_unmarshal_long(@_);
80 }
81 0 ▶ if ($has_members{$self->{_kind}}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_members{$self->{'_kind'}}) { } 0 0 0
elsif ($has_type{$self->{'_kind'}}) { } 0 0 0
82 0 my($count) = CORBA::ORB::_unmarshal_ulong(@_);
83 0 $self->{_members} = [];
84 0 ▶ if ($self->{_kind} == tk_enum) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'_kind'} == 17) { } 0 0 0
elsif ($self->{'_kind'} == 15 or $self->{'_kind'} == 22) { } 0 0 0
elsif ($self->{'_kind'} == 16) { } 0 0 0
85 0 ▶ while ($count--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count--) 0 0 0
86 0 push @{$self->{_members}}, {_name => CORBA::ORB::_unmarshal_string(@_)};
87 }
88 ▶ } elsif (($self->{_kind} == tk_struct) || ($self->{_kind} == tk_except)) {
Condition0%0/3
$self->{"_kind"} == 15 or $self->{"_kind"} == 22
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_kind"} == 15 or $self->{"_kind"} == 22
$self->{"_kind"} == 15 $self->{"_kind"} == 22
Truth table0%0/3
A or B
A= $self->{"_kind"} == 15B= $self->{"_kind"} == 22
ABresult
1X1
011
000
89 0 ▶ while ($count--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count--) 0 0 0
90 0 my $member = {};
91 0 $member->{_name} = CORBA::ORB::_unmarshal_string(@_);
92 0 $member->{_type} = CORBA::TypeCode::_unmarshal(@_);
93 0 push @{$self->{_members}}, $member;
94 }
95 } elsif ($self->{_kind} == tk_union) {
96 0 ▶ while ($count--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count--) 0 0 0
97 0 my $member = {};
98 0 ▶ if ($self->{_discriminator_type}->kind == tk_short) {
Branch: 7 branches
BranchTrueFalseTotal
if ($self->{'_discriminator_type'}->kind == 2) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 4) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 3) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 5) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 8) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 9) { } 0 0 0
elsif ($self->{'_discriminator_type'}->kind == 17) { } 0 0 0
99 0 $member->{_label} = CORBA::ORB::_unmarshal_short(@_);
100 } elsif ($self->{_discriminator_type}->kind == tk_ushort) {
101 0 $member->{_label} = CORBA::ORB::_unmarshal_ushort(@_);
102 } elsif ($self->{_discriminator_type}->kind == tk_long) {
103 0 $member->{_label} = CORBA::ORB::_unmarshal_long(@_);
104 } elsif ($self->{_discriminator_type}->kind == tk_ulong) {
105 0 $member->{_label} = CORBA::ORB::_unmarshal_ulong(@_);
106 } elsif ($self->{_discriminator_type}->kind == tk_boolean) {
107 0 $member->{_label} = CORBA::ORB::_unmarshal_boolean(@_);
108 } elsif ($self->{_discriminator_type}->kind == tk_char) {
109 0 $member->{_label} = CORBA::ORB::_unmarshal_char(@_);
110 } elsif ($self->{_discriminator_type}->kind == tk_enum) {
111 0 $member->{_label} = CORBA::ORB::_unmarshal_enum(@_);
112 }
113 0 $member->{_name} = CORBA::ORB::_unmarshal_string(@_);
114 0 $member->{_type} = CORBA::TypeCode::_unmarshal(@_);
115 0 push @{$self->{_members}}, $member;
116 }
117 }
118 } elsif ($has_type{$self->{_kind}}) {
119 0 $self->{_type} = CORBA::TypeCode::_unmarshal(@_);
120 }
121 0 ▶ if ($has_length{$self->{_kind}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_length{$self->{"_kind"}}) 0 0 0
122 0 $self->{_length} = CORBA::ORB::_unmarshal_ulong(@_);
123 }
124 }
125 0 return bless $self, 'CORBA::TypeCode';
126 }
127  
128 0 ▶sub kind {
Subroutine kind: not called CC=1 SCAR=6.9
129 0 my($self) = @_;
130 0 return $self->{_kind};
131 }
132  
133 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
134 0 my($self) = @_;
135 0 return $self->{_id};
136 }
137  
138 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
139 0 my($self) = @_;
140 0 return $self->{_name};
141 }
142  
143 0 ▶sub content_type {
Subroutine content_type: not called CC=1 SCAR=6.9
144 0 my($self) = @_;
145 0 return $self->{_type};
146 }
147  
148 0 ▶sub member_count {
Subroutine member_count: not called CC=1 SCAR=6.9
149 0 my($self) = @_;
150 0 return scalar @{$self->{_members}};
151 }
152  
153 0 ▶sub member_name {
Subroutine member_name: not called CC=1 SCAR=6.9
154 0 my($self, $index) = @_;
155 0 return $self->{_members}[$index]{_name};
156 }
157  
158 0 ▶sub member_type {
Subroutine member_type: not called CC=1 SCAR=6.9
159 0 my($self, $index) = @_;
160 0 return $self->{_members}[$index]{_type};
161 }
162  
163 0 ▶sub length {
Subroutine length: not called CC=1 SCAR=6.9
164 0 my($self) = @_;
165 0 return $self->{_length};
166 }
167  
168 0 ▶sub _create_alias_tc ($$$) {
Subroutine _create_alias_tc: not called CC=1 SCAR=6.9
169 0 my($id,$name,$original_type) = @_;
170 0 my $tc = { _kind => tk_alias,
171 _id => $id,
172 _name => $name,
173 _type => $original_type,
174 };
175 0 return bless $tc, 'CORBA::TypeCode';
176 }
177  
178 0 ▶sub _create_struct_tc ($$$) {
Subroutine _create_struct_tc: not called CC=2 SCAR=17.9
179 0 my($id,$name,$members) = @_;
180 0 my $tc = { _kind => tk_struct,
181 _id => $id,
182 _name => $name,
183 _members => [],
184 };
185 0 my @members = @$members;
186 0 ▶ while (my($n,$t) = splice(@members, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@members, 0, 2)) 0 0 0
187 0 push @{$tc->{_members}}, {_name => $n, _type => $t};
188 }
189 0 return bless $tc, 'CORBA::TypeCode';
190 }
191  
192 0 ▶sub _create_exception_tc ($$$) {
Subroutine _create_exception_tc: not called CC=2 SCAR=17.9
193 0 my($id,$name,$members) = @_;
194 0 my $tc = { _kind => tk_except,
195 _id => $id,
196 _name => $name,
197 _members => [],
198 };
199 0 my @members = @$members;
200 0 ▶ while (my($n,$t) = splice(@members, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@members, 0, 2)) 0 0 0
201 0 push @{$tc->{_members}}, {_name => $n, _type => $t};
202 }
203 0 return bless $tc, 'CORBA::TypeCode';
204 }
205  
206 0 ▶sub _create_enum_tc ($$$) {
Subroutine _create_enum_tc: not called CC=1 SCAR=6.9
207 0 my($id,$name,$members) = @_;
208 0 my $tc = { _kind => tk_enum,
209 _id => $id,
210 _name => $name,
211 _members => $members,
212 };
213 0 return bless $tc, 'CORBA::TypeCode';
214 }
215  
216 0 ▶sub _create_sequence_tc ($$) {
Subroutine _create_sequence_tc: not called CC=1 SCAR=6.9
217 0 my($bound,$element_type) = @_;
218 0 my $tc = { _kind => tk_sequence,
219 _length => $bound,
220 _type => $element_type,
221 };
222 0 return bless $tc, 'CORBA::TypeCode';
223 }
224  
225 0 ▶sub _create_array_tc ($$) {
Subroutine _create_array_tc: not called CC=1 SCAR=6.9
226 0 my($bound,$element_type) = @_;
227 0 my $tc = { _kind => tk_array,
228 _length => $bound,
229 _type => $element_type,
230 };
231 0 return bless $tc, 'CORBA::TypeCode';
232 }
233  
234 0 ▶sub _create_string_tc ($) {
Subroutine _create_string_tc: not called CC=1 SCAR=6.9
235 0 my($bound) = @_;
236 0 my $tc = { _kind => tk_string,
237 _length => $bound,
238 };
239 0 return bless $tc, 'CORBA::TypeCode';
240 }
241  
242 0 ▶sub _create_interface_tc ($$) {
Subroutine _create_interface_tc: not called CC=1 SCAR=6.9
243 0 my($id, $name) = @_;
244 0 my $tc = { _kind => tk_objref,
245 _id => $id,
246 _name => $name,
247 };
248 0 return bless $tc, 'CORBA::TypeCode';
249 }
250  
251 0 ▶sub _noalias_kind {
Subroutine _noalias_kind: not called CC=2 SCAR=17.9
252 0 my($self) = @_;
253 0 ▶ while ($self->kind() == tk_alias) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->kind == 21) 0 0 0
254 0 $self = $self->content_type();
255 }
256 0 return $self->kind();
257 }
258  
259 0 ▶sub _noalias_content_type {
Subroutine _noalias_content_type: not called CC=2 SCAR=17.9
260 0 my($self) = @_;
261 0 ▶ while ($self->kind() == tk_alias) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->kind == 21) 0 0 0
262 0 $self = $self->content_type();
263 }
264 0 return $self->content_type();
265 }
266  
267 0 ▶sub _needs_ref ($$) {
Subroutine _needs_ref: not called CC=9 SCAR=45.0
268 0 my($self, $mode) = @_;
269  
270 0 ▶ return 0 if $mode == 0; # in parameters never need pass by reference
Branch: 1 branch
BranchTrueFalseTotal
if $mode == 0 0 0 0
271 0 my $kind = $self->kind();
272 0 ▶ if (($kind <= tk_octet) || ($kind == tk_Principal) || ($kind == tk_enum) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($kind <= 10 or $kind == 13 or $kind == 17 or $kind == 18) 0 0 0
Condition0%0/9
$kind <= 10 or $kind == 13 or $kind == 17 or $kind == 18
l!l&&r!l&&!r
000
$kind <= 10 or $kind == 13 or $kind == 17
l!l&&r!l&&!r
000
$kind <= 10 or $kind == 13
l!l&&r!l&&!r
000
MC/DC0%0/4
$kind <= 10 or $kind == 13 or $kind == 17 or $kind == 18
$kind <= 10 $kind == 13 $kind == 17 $kind == 18
Truth table0%0/5
A or B or C or D
A= $kind <= 10B= $kind == 13C= $kind == 17D= $kind == 18
ABCDresult
1XXX1
01XX1
001X1
00011
00000
273 ($kind == tk_string)) {
274 0 return 1;
275 }
276 0 ▶ if ($kind == tk_alias) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 21) 0 0 0
277 0 return $self->content_type->_needs_ref($mode);
278 }
279 0 ▶ if (($kind == tk_sequence) && ($self->content_type()->kind() == tk_octet)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 19 and $self->content_type->kind == 10) 0 0 0
Condition0%0/3
$kind == 19 and $self->content_type->kind == 10
!ll&&!rl&&r
000
MC/DC0%0/2
$kind == 19 and $self->content_type->kind == 10
$kind == 19 $self->content_type->kind == 10
Truth table0%0/3
A and B
A= $kind == 19B= $self->content_type->kind == 10
ABresult
0X0
100
111
280 0 return 1; # octet-sequence implemented as a scalar
281 }
282 0 return 0;
283 }
284  
285 3 1;
286  
287 __END__
↑ Summary CORBA/Request.pm »