forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppNamespace.cxx
More file actions
110 lines (99 loc) · 1.87 KB
/
cppNamespace.cxx
File metadata and controls
110 lines (99 loc) · 1.87 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
/**
* 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 cppNamespace.cxx
* @author drose
* @date 1999-11-16
*/
#include "cppNamespace.h"
#include "cppIdentifier.h"
#include "cppScope.h"
#include "indent.h"
/**
*
*/
CPPNamespace::
CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) :
CPPDeclaration(file),
_ident(ident),
_scope(scope),
_is_inline(false)
{
}
/**
*
*/
std::string CPPNamespace::
get_simple_name() const {
if (_ident == nullptr) {
return "";
}
return _ident->get_simple_name();
}
/**
*
*/
std::string CPPNamespace::
get_local_name(CPPScope *scope) const {
if (_ident == nullptr) {
return "";
}
return _ident->get_local_name(scope);
}
/**
*
*/
std::string CPPNamespace::
get_fully_scoped_name() const {
if (_ident == nullptr) {
return "";
}
return _ident->get_fully_scoped_name();
}
/**
*
*/
CPPScope *CPPNamespace::
get_scope() const {
return _scope;
}
/**
*
*/
void CPPNamespace::
output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const {
if (_is_inline) {
out << "inline ";
}
if (!complete && _ident != nullptr) {
// If we have a name, use it.
out << "namespace " << _ident->get_local_name(scope);
} else {
if (_ident != nullptr) {
out << "namespace " << _ident->get_local_name(scope) << " {\n";
} else {
out << "namespace {\n";
}
_scope->write(out, indent_level + 2, _scope);
indent(out, indent_level) << "}";
}
}
/**
*
*/
CPPDeclaration::SubType CPPNamespace::
get_subtype() const {
return ST_namespace;
}
/**
*
*/
CPPNamespace *CPPNamespace::
as_namespace() {
return this;
}