Browse Source

Fix a bug substituting some enums
(Still a bug: some enums in templated classes don't get instanced properly)

rdb 11 years ago
parent
commit
ecf627b315

+ 21 - 0
dtool/src/cppparser/cppDeclaration.cxx

@@ -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;
+}

+ 3 - 0
dtool/src/cppparser/cppDeclaration.h

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

+ 8 - 2
dtool/src/cppparser/cppEnumType.cxx

@@ -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;
     }
   }

+ 2 - 0
dtool/src/cppparser/cppIdentifier.cxx

@@ -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.

+ 1 - 1
dtool/src/interrogate/interrogateBuilder.cxx

@@ -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;
   }
 

+ 1 - 1
makepanda/makepanda.py

@@ -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.