[pypy-commit] pypy reflex-support: allow bind_object to take a string (the class name) instead of the class itself
wlav
noreply at buildbot.pypy.org
Thu Mar 21 02:32:23 CET 2013
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r62600:f81426f91525
Date: 2013-03-20 17:17 -0700
http://bitbucket.org/pypy/pypy/changeset/f81426f91525/
Log: allow bind_object to take a string (the class name) instead of the
class itself
diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -1109,5 +1109,7 @@
"""Takes an address and a bound C++ class proxy, returns a bound instance."""
rawobject = rffi.cast(capi.C_OBJECT, address)
w_cppclass = space.findattr(w_pycppclass, space.wrap("_cpp_proxy"))
+ if not w_cppclass:
+ w_cppclass = scope_byname(space, space.str_w(w_pycppclass))
cppclass = space.interp_w(W_CPPClass, w_cppclass, can_be_None=False)
return wrap_cppobject(space, rawobject, cppclass, do_cast=False, python_owns=owns)
diff --git a/pypy/module/cppyy/test/test_advancedcpp.py b/pypy/module/cppyy/test/test_advancedcpp.py
--- a/pypy/module/cppyy/test/test_advancedcpp.py
+++ b/pypy/module/cppyy/test/test_advancedcpp.py
@@ -402,6 +402,9 @@
o = some_concrete_class()
+ # TODO: figure out the PyPy equivalent of CObject (may have to do this
+ # through the C-API from C++)
+
#cobj = cppyy.as_cobject(o)
addr = cppyy.addressof(o)
@@ -413,7 +416,8 @@
assert o == cppyy.bind_object(addr, some_concrete_class)
assert o == cppyy.bind_object(addr, type(o))
assert o == cppyy.bind_object(addr, o.__class__)
- #assert o == cppyy.bind_object(addr, "some_concrete_class")
+ assert o == cppyy.bind_object(addr, "some_concrete_class")
+ raises(TypeError, cppyy.bind_object, addr, 1)
def test10_object_identity(self):
"""Test object identity"""
More information about the pypy-commit
mailing list