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; 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; return out;
} }
ostream &
operator << (ostream &out, const CPPDeclaration::SubstDecl &decl);
#endif #endif

View File

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

View File

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

View File

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

View File

@ -1249,7 +1249,7 @@ def CompileIgate(woutd,wsrc,opts):
cmd += ' -srcdir %s -I%s -Dvolatile -Dmutable' % (srcdir, srcdir) cmd += ' -srcdir %s -I%s -Dvolatile -Dmutable' % (srcdir, srcdir)
if (COMPILER=="MSVC"): 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': if GetTargetArch() == 'x64':
cmd += ' -DWIN64_VC -DWIN64 -D_WIN64' cmd += ' -DWIN64_VC -DWIN64 -D_WIN64'
# NOTE: this 1600 value is the version number for VC2010. # NOTE: this 1600 value is the version number for VC2010.