Author: Wim Lavrijsen <[email protected]> Branch: reflex-support Changeset: r65921:bfcf9013eef0 Date: 2013-08-03 02:54 -0700 http://bitbucket.org/pypy/pypy/changeset/bfcf9013eef0/
Log: fix for: https://bugs.pypy.org/issue1561 (enums accessible as type) diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py --- a/pypy/module/cppyy/pythonify.py +++ b/pypy/module/cppyy/pythonify.py @@ -426,6 +426,11 @@ # mostly for the benefit of the CINT backend, which treats std as special gbl.std = make_cppnamespace(None, "std", None, False) + # install a type for enums to refer to + # TODO: this is correct for C++98, not for C++11 and in general there will + # be the same issue for all typedef'd builtin types + setattr(gbl, 'unsigned int', int) + # install for user access cppyy.gbl = gbl diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py --- a/pypy/module/cppyy/test/test_datatypes.py +++ b/pypy/module/cppyy/test/test_datatypes.py @@ -428,12 +428,17 @@ c = cppyy_test_data() assert isinstance(c, cppyy_test_data) - # TODO: test that the enum is accessible as a type + # test that the enum is accessible as a type + assert cppyy_test_data.what assert cppyy_test_data.kNothing == 6 assert cppyy_test_data.kSomething == 111 assert cppyy_test_data.kLots == 42 + assert cppyy_test_data.what(cppyy_test_data.kNothing) == cppyy_test_data.kNothing + assert cppyy_test_data.what(6) == cppyy_test_data.kNothing + # TODO: only allow instantiations with correct values (C++11) + assert c.get_enum() == cppyy_test_data.kNothing assert c.m_enum == cppyy_test_data.kNothing @@ -455,6 +460,7 @@ assert cppyy_test_data.s_enum == cppyy_test_data.kSomething # global enums + assert gbl.fruit # test type accessible assert gbl.kApple == 78 assert gbl.kBanana == 29 assert gbl.kCitrus == 34 _______________________________________________ pypy-commit mailing list [email protected] http://mail.python.org/mailman/listinfo/pypy-commit
