[pypy-commit] pypy reflex-support: (arigo, cfbolz): fix pythonify and test_zjit to use the new interface
cfbolz
noreply at buildbot.pypy.org
Thu Jul 14 18:48:30 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: reflex-support
Changeset: r45602:35ece280f108
Date: 2011-07-14 18:46 +0200
http://bitbucket.org/pypy/pypy/changeset/35ece280f108/
Log: (arigo, cfbolz): fix pythonify and test_zjit to use the new
interface
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
@@ -44,8 +44,13 @@
__metaclass__ = CppyyClass
def __init__(self, *args):
- self._cppinstance = self._cpp_proxy.construct(*args)
-
+ try:
+ cppol = self._cpp_proxy.get_overload(self._cpp_proxy.type_name)
+ except AttributeError:
+ raise TypeError("cannot instantiate abstract class '%s'" %
+ self._cpp_proxy.type_name)
+ self._cppinstance = cppol.call(None, cppyy.CPPInstance, *args)
+
def destruct(self):
self._cppinstance.destruct()
@@ -61,11 +66,11 @@
rettype = cppol.get_returntype()
if not rettype: # return builtin type
def function(*args):
- return cpptype.invoke(cppol, *args)
+ return cppol.call(None, cppyy.CPPInstance, *args)
else: # return instance
cppclass = get_cppclass(rettype)
def function(*args):
- return bind_object(cpptype.invoke(cppol, *args), cppclass)
+ return bind_object(cppol.call(None, cppyy.CPPInstance, *args), cppclass)
function.__name__ = func_name
return staticmethod(function)
@@ -73,11 +78,11 @@
rettype = cppol.get_returntype()
if not rettype: # return builtin type
def method(self, *args):
- return self._cppinstance.invoke(cppol, *args)
+ return cppol.call(self._cppinstance, cppyy.CPPInstance, *args)
else: # return instance
cppclass = get_cppclass(rettype)
def method(self, *args):
- return bind_object(self._cppinstance.invoke(cppol, *args), cppclass)
+ return bind_object(cppol.call(self._cppinstance, cppyy.CPPInstance, *args), cppclass)
method.__name__ = meth_name
return method
diff --git a/pypy/module/cppyy/test/test_zjit.py b/pypy/module/cppyy/test/test_zjit.py
--- a/pypy/module/cppyy/test/test_zjit.py
+++ b/pypy/module/cppyy/test/test_zjit.py
@@ -1,5 +1,5 @@
from pypy.jit.metainterp.test.support import LLJitMixin
-from pypy.rlib.objectmodel import specialize
+from pypy.rlib.objectmodel import specialize, instantiate
from pypy.rlib import rarithmetic, jit
from pypy.rpython.lltypesystem import rffi
from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
@@ -105,6 +105,10 @@
def findattr(self, w_obj, w_name):
return None
+ def allocate_instance(self, cls, w_type):
+ assert w_type == "stuff"
+ return instantiate(cls)
+
def _freeze_(self):
return True
@@ -115,13 +119,13 @@
def f():
lib = interp_cppyy.load_lib(space, "./example01Dict.so")
cls = interp_cppyy.type_byname(space, "example01")
- inst = cls.construct([FakeInt(0)])
+ inst = cls.get_overload("example01").call(None, "stuff", [FakeInt(0)])
addDataToInt = cls.get_overload("addDataToInt")
assert isinstance(inst, interp_cppyy.W_CPPInstance)
i = 10
while i > 0:
drv.jit_merge_point(inst=inst, addDataToInt=addDataToInt, i=i)
- inst.invoke(addDataToInt, [FakeInt(i)])
+ addDataToInt.call(inst, None, [FakeInt(i)])
i -= 1
return 7
f()
More information about the pypy-commit
mailing list