forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppTypeProxy.cxx
More file actions
319 lines (289 loc) · 6.25 KB
/
cppTypeProxy.cxx
File metadata and controls
319 lines (289 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file cppTypeProxy.cxx
* @author drose
* @date 1999-12-07
*/
#include "cppTypeProxy.h"
#include "cppFile.h"
using std::string;
/**
*
*/
CPPTypeProxy::
CPPTypeProxy() :
CPPType(CPPFile())
{
_actual_type = nullptr;
}
/**
* If this CPPType object is a forward reference or other nonspecified
* reference to a type that might now be known a real type, returns the real
* type. Otherwise returns the type itself.
*/
CPPType *CPPTypeProxy::
resolve_type(CPPScope *, CPPScope *) {
if (_actual_type == nullptr) {
return this;
}
return _actual_type;
}
/**
* Returns true if the type, or any nested type within the type, is a
* CPPTBDType and thus isn't fully determined right now. In this case,
* calling resolve_type() may or may not resolve the type.
*/
bool CPPTypeProxy::
is_tbd() const {
if (_actual_type == nullptr) {
return false;
}
return _actual_type->is_tbd();
}
/**
* Returns true if the type has even been typedef'ed and therefore has a
* simple name available to stand for it. Extension types are all implicitly
* typedef'ed on declaration.
*/
bool CPPTypeProxy::
has_typedef_name() const {
if (_actual_type == nullptr) {
return false;
}
return _actual_type->has_typedef_name();
}
/**
* Returns a string that can be used to name the type, if has_typedef_name()
* returned true. This will be the first typedef name applied to the type.
*/
string CPPTypeProxy::
get_typedef_name(CPPScope *) const {
if (_actual_type == nullptr) {
return string();
}
return _actual_type->get_typedef_name();
}
/**
* Returns a fundametal one-word name for the type. This name will not
* include any scoping operators or template parameters, so it may not be a
* compilable reference to the type.
*/
string CPPTypeProxy::
get_simple_name() const {
if (_actual_type == nullptr) {
return "unknown";
}
return _actual_type->get_simple_name();
}
/**
* Returns the compilable, correct name for this type within the indicated
* scope. If the scope is NULL, within the scope the type is declared in.
*/
string CPPTypeProxy::
get_local_name(CPPScope *scope) const {
if (_actual_type == nullptr) {
return "unknown";
}
return _actual_type->get_local_name(scope);
}
/**
* Returns the compilable, correct name for the type, with completely explicit
* scoping.
*/
string CPPTypeProxy::
get_fully_scoped_name() const {
if (_actual_type == nullptr) {
return "unknown";
}
return _actual_type->get_fully_scoped_name();
}
/**
* Returns the best name to use for the type from a programmer's point of
* view. This will typically be a typedef name if one is available, or the
* full C++ name if it is not. The typedef may or may not be visible within
* the current scope, so this type name may not be compilable.
*/
string CPPTypeProxy::
get_preferred_name() const {
if (_actual_type == nullptr) {
return "unknown";
}
return _actual_type->get_preferred_name();
}
/**
* Returns true if the type has not yet been fully specified, false if it has.
*/
bool CPPTypeProxy::
is_incomplete() const {
if (_actual_type == nullptr) {
return true;
}
return _actual_type->is_incomplete();
}
/**
* Formats a C++-looking line that defines an instance of the given type, with
* the indicated name. In most cases this will be "type name", but some types
* have special exceptions.
*/
void CPPTypeProxy::
output_instance(std::ostream &out, int indent_level, CPPScope *scope,
bool complete, const string &prename,
const string &name) const {
if (_actual_type == nullptr) {
out << "unknown " << prename << name;
return;
}
_actual_type->output_instance(out, indent_level, scope, complete,
prename, name);
}
/**
*
*/
void CPPTypeProxy::
output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const {
if (_actual_type == nullptr) {
out << "unknown";
return;
}
_actual_type->output(out, indent_level, scope, complete);
}
/**
*
*/
CPPDeclaration::SubType CPPTypeProxy::
get_subtype() const {
return ST_type_proxy;
}
/**
*
*/
CPPType *CPPTypeProxy::
as_type() {
if (_actual_type == nullptr) {
return this;
}
return _actual_type;
}
/**
*
*/
CPPSimpleType *CPPTypeProxy::
as_simple_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_simple_type();
}
/**
*
*/
CPPPointerType *CPPTypeProxy::
as_pointer_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_pointer_type();
}
/**
*
*/
CPPReferenceType *CPPTypeProxy::
as_reference_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_reference_type();
}
/**
*
*/
CPPArrayType *CPPTypeProxy::
as_array_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_array_type();
}
/**
*
*/
CPPConstType *CPPTypeProxy::
as_const_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_const_type();
}
/**
*
*/
CPPFunctionType *CPPTypeProxy::
as_function_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_function_type();
}
/**
*
*/
CPPExtensionType *CPPTypeProxy::
as_extension_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_extension_type();
}
/**
*
*/
CPPStructType *CPPTypeProxy::
as_struct_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_struct_type();
}
/**
*
*/
CPPEnumType *CPPTypeProxy::
as_enum_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_enum_type();
}
/**
*
*/
CPPTBDType *CPPTypeProxy::
as_tbd_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_tbd_type();
}
/**
*
*/
CPPTypedefType *CPPTypeProxy::
as_typedef_type() {
if (_actual_type == nullptr) {
return nullptr;
}
return _actual_type->as_typedef_type();
}
/**
*
*/
CPPTypeProxy *CPPTypeProxy::
as_type_proxy() {
return this;
}