Commits

wlav committed 16ca2f0

prevent infinite recursion on unnamed enums

Comments (0)

Files changed (5)

pypy/module/cppyy/src/cintcwrapper.cxx

     if (strcmp(cppitem_name, "") == 0)
         return cppstring_to_cstring(cppitem_name);
     G__TypeInfo ti(cppitem_name);
-    if (ti.IsValid())
+    if (ti.IsValid()) {
+        if (ti.Property() & G__BIT_ISENUM)
+            return cppstring_to_cstring("unsigned int");
         return cppstring_to_cstring(ti.TrueName());
+    }
     return cppstring_to_cstring(cppitem_name);
 }
 

pypy/module/cppyy/test/fragile.cxx

 #include "fragile.h"
+
+fragile::H::HH* fragile::H::HH::copy() {
+    return (HH*)0;
+}

pypy/module/cppyy/test/fragile.h

     int m_int;
 };
 
+class G {
+public:
+    enum { unnamed1=24, unnamed2=96 };
+
+    class GG {};
+};
+
+class H {
+public:
+    class HH {
+    public:
+       HH* copy();
+    };
+    HH* m_h;
+};
+
 } // namespace fragile

pypy/module/cppyy/test/fragile_LinkDef.h

 #pragma link C++ class fragile::D;
 #pragma link C++ class fragile::E;
 #pragma link C++ class fragile::F;
+#pragma link C++ class fragile::G;
+#pragma link C++ class fragile::H;
 
 #endif

pypy/module/cppyy/test/test_fragile.py

 
         assert isinstance(a.gime_null(), fragile.A)
         raises(ReferenceError, fragile.A.check, a.gime_null())
+
+    def test07_unnamed_enum(self):
+        """Test that an unnamed enum does not cause infinite recursion"""
+
+        import cppyy
+
+        assert cppyy.gbl.fragile is cppyy.gbl.fragile
+        fragile = cppyy.gbl.fragile
+        assert cppyy.gbl.fragile is fragile
+
+        g = fragile.G()
+
+    def test08_unhandled_scoped_data_member(self):
+        """Test that an unhandled scoped data member does not cause infinite recursion"""
+
+        import cppyy
+
+        assert cppyy.gbl.fragile is cppyy.gbl.fragile
+        fragile = cppyy.gbl.fragile
+        assert cppyy.gbl.fragile is fragile
+
+        h = fragile.H()