[pypy-commit] pypy reflex-support: prevent infinite recursion on unnamed enums
wlav
noreply at buildbot.pypy.org
Thu Mar 8 16:36:30 CET 2012
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r53271:16ca2f015922
Date: 2012-03-07 23:52 -0800
http://bitbucket.org/pypy/pypy/changeset/16ca2f015922/
Log: prevent infinite recursion on unnamed enums
diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -161,8 +161,11 @@
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);
}
diff --git a/pypy/module/cppyy/test/fragile.cxx b/pypy/module/cppyy/test/fragile.cxx
--- a/pypy/module/cppyy/test/fragile.cxx
+++ b/pypy/module/cppyy/test/fragile.cxx
@@ -1,1 +1,5 @@
#include "fragile.h"
+
+fragile::H::HH* fragile::H::HH::copy() {
+ return (HH*)0;
+}
diff --git a/pypy/module/cppyy/test/fragile.h b/pypy/module/cppyy/test/fragile.h
--- a/pypy/module/cppyy/test/fragile.h
+++ b/pypy/module/cppyy/test/fragile.h
@@ -47,4 +47,20 @@
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
diff --git a/pypy/module/cppyy/test/fragile_LinkDef.h b/pypy/module/cppyy/test/fragile_LinkDef.h
--- a/pypy/module/cppyy/test/fragile_LinkDef.h
+++ b/pypy/module/cppyy/test/fragile_LinkDef.h
@@ -12,5 +12,7 @@
#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
diff --git a/pypy/module/cppyy/test/test_fragile.py b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -123,3 +123,25 @@
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()
More information about the pypy-commit
mailing list