Fix a bug substituting some enums

(Still a bug: some enums in templated classes don't get instanced properly)
This commit is contained in:
rdb 2015-01-05 17:04:38 +01:00
parent e2cdade9d2
commit ecf627b315
6 changed files with 36 additions and 4 deletions

View File

@ -399,3 +399,24 @@ is_less(const CPPDeclaration *other) const {
return this < other;
}
ostream &
operator << (ostream &out, const CPPDeclaration::SubstDecl &subst) {
CPPDeclaration::SubstDecl::const_iterator it;
for (it = subst.begin(); it != subst.end(); ++it) {
out << " ";
if (it->first == NULL) {
out << "(null)";
} else {
out << *(it->first);
}
out << " -> ";
if (it->second == NULL) {
out << "(null)";
} else {
out << *(it->second);
}
out << "\n";
}
return out;
}

View File

@ -157,4 +157,7 @@ operator << (ostream &out, const CPPDeclaration &decl) {
return out;
}
ostream &
operator << (ostream &out, const CPPDeclaration::SubstDecl &decl);
#endif

View File

@ -34,6 +34,9 @@ CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope,
_element_type(NULL),
_last_value(NULL)
{
if (ident != NULL) {
ident->_native_scope = current_scope;
}
}
////////////////////////////////////////////////////////////////////
@ -49,6 +52,9 @@ CPPEnumType(CPPIdentifier *ident, CPPType *element_type,
_element_type(element_type),
_last_value(NULL)
{
if (ident != NULL) {
ident->_native_scope = current_scope;
}
}
////////////////////////////////////////////////////////////////////
@ -110,7 +116,6 @@ is_incomplete() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: CPPEnumType::is_fully_specified
// Access: Public, Virtual
@ -157,6 +162,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst,
}
CPPEnumType *rep = new CPPEnumType(*this);
if (_ident != NULL) {
rep->_ident =
_ident->substitute_decl(subst, current_scope, global_scope);
@ -176,7 +182,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst,
->as_instance();
if (elem_rep != _elements[i]) {
_elements[i] = elem_rep;
rep->_elements[i] = elem_rep;
any_changed = true;
}
}

View File

@ -146,8 +146,10 @@ get_local_name(CPPScope *scope) const {
if (scope == NULL || (_native_scope == NULL && _names.size() == 1)) {
result = _names.back().get_name_with_templ(scope);
} else if (_names.front().empty()) {
result = get_fully_scoped_name();
} else {
// Determine the scope of everything up until but not including the
// last name.

View File

@ -2312,7 +2312,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype,
TypeIndex type_index, bool forced) {
if (cpptype->get_simple_name().empty()) {
// If the type has no name, forget it. We don't export anonymous
// types.
// structs.
return;
}

View File

@ -1249,7 +1249,7 @@ def CompileIgate(woutd,wsrc,opts):
cmd += ' -srcdir %s -I%s -Dvolatile -Dmutable' % (srcdir, srcdir)
if (COMPILER=="MSVC"):
cmd += ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -longlong __int64 -D_X86_ -DWIN32_VC -DWIN32 -D_WIN32'
cmd += ' -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -D_X86_ -DWIN32_VC -DWIN32 -D_WIN32'
if GetTargetArch() == 'x64':
cmd += ' -DWIN64_VC -DWIN64 -D_WIN64'
# NOTE: this 1600 value is the version number for VC2010.