line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.41';
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
803
|
use CORBA::C::TypeVisitor;
|
|
1
|
|
|
|
|
1749
|
|
|
1
|
|
|
|
|
26
|
|
16
|
1
|
|
|
1
|
|
6
|
use base qw(CORBA::C::TypeVisitor);
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1498
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# builds $node->{cpp_arg}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new {
|
21
|
0
|
|
|
0
|
0
|
|
my $proto = shift;
|
22
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto;
|
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
|
|
|
|
|
|
|
sub _get_cpp_arg {
|
36
|
0
|
|
|
0
|
|
|
my $self = shift;
|
37
|
0
|
|
|
|
|
|
my ($type, $v_name, $attr) = @_;
|
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
0
|
|
|
|
if ( $type->isa('BasicType')
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
40
|
|
|
|
|
|
|
or $type->isa('EnumType') ) {
|
41
|
0
|
|
|
|
|
|
my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
|
42
|
0
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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')
|
56
|
|
|
|
|
|
|
or $type->isa('ForwardValue') ) {
|
57
|
0
|
|
|
|
|
|
my $t_name = $type->{cpp_name};
|
58
|
0
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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')
|
72
|
|
|
|
|
|
|
or $type->isa('ForwardBaseInterface') ) {
|
73
|
0
|
|
|
|
|
|
my $t_name = $type->{cpp_name};
|
74
|
0
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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')
|
88
|
|
|
|
|
|
|
or $type->isa('UnionType') ) {
|
89
|
0
|
|
|
|
|
|
my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
|
90
|
0
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if (defined $type->{length}) { # variable
|
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
|
0
|
|
|
|
|
if (defined $type->{length}) { # variable
|
106
|
0
|
|
|
|
|
|
return $t_name . ' *';
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
else {
|
109
|
0
|
|
|
|
|
|
return $t_name;
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
elsif ( $type->isa('StringType')
|
114
|
|
|
|
|
|
|
or $type->isa('WideStringType') ) {
|
115
|
0
|
|
|
|
|
|
my $t_name = $type->{cpp_ns} . '::' . $type->{cpp_name};
|
116
|
0
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if (exists $type->{array_size}) {
|
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
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if (defined $type->{length}) { # variable
|
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
|
0
|
|
|
|
|
unless (ref $type) {
|
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
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if ( $attr eq 'in' ) {
|
|
|
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
|
0
|
|
|
|
|
if ($attr eq 'return') {
|
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
|
|
|
|
|
|
|
sub visitInitializer {
|
247
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
248
|
0
|
|
|
|
|
|
my ($node) = @_;
|
249
|
0
|
|
|
|
|
|
foreach (@{$node->{list_param}}) { # parameter
|
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub visitOperation {
|
260
|
0
|
|
|
0
|
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
|
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub visitFactory {
|
275
|
|
|
|
|
|
|
# C++ mapping is aligned with CORBA 2.3
|
276
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
277
|
0
|
|
|
|
|
|
my ($node) = @_;
|
278
|
0
|
|
|
|
|
|
foreach (@{$node->{list_param}}) { # parameter
|
|
0
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
my $type = $self->_get_type($_->{type});
|
280
|
0
|
|
|
|
|
|
$_->{cpp_arg} = $self->_get_cpp_arg($type, $_->{cpp_name}, $_->{attr});
|
281
|
|
|
|
|
|
|
}
|
282
|
|
|
|
|
|
|
}
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub visitFinder {
|
285
|
|
|
|
|
|
|
# C++ mapping is aligned with CORBA 2.3
|
286
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
287
|
0
|
|
|
|
|
|
my ($node) = @_;
|
288
|
0
|
|
|
|
|
|
foreach (@{$node->{list_param}}) { # parameter
|
|
0
|
|
|
|
|
|
|
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;
|
295
|
|
|
|
|
|
|
|