[pypy-commit] pypy hpy: implement METH_O calls; test_identify_function passes
antocuni
pypy.commits at gmail.com
Sat Nov 16 19:16:25 EST 2019
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: hpy
Changeset: r98092:f51448bff9a4
Date: 2019-11-17 01:09 +0100
http://bitbucket.org/pypy/pypy/changeset/f51448bff9a4/
Log: implement METH_O calls; test_identify_function passes
diff --git a/pypy/module/hpy_universal/interp_extfunc.py b/pypy/module/hpy_universal/interp_extfunc.py
--- a/pypy/module/hpy_universal/interp_extfunc.py
+++ b/pypy/module/hpy_universal/interp_extfunc.py
@@ -38,7 +38,13 @@
return handles.consume(space, h_result)
def call_o(self, space, w_arg):
- raise NotImplementedError("later")
+ state = space.fromcache(State)
+ with handles.using(space, self.w_self) as h_self:
+ with handles.using(space, w_arg) as h_arg:
+ h_result = generic_cpy_call_dont_convert_result(space,
+ self.cfuncptr, state.ctx, h_self, h_arg)
+ # XXX check for exceptions
+ return handles.consume(space, h_result)
def call_varargs(self, space, arguments_w):
raise NotImplementedError("later")
diff --git a/pypy/module/hpy_universal/test/test_basic.py b/pypy/module/hpy_universal/test/test_basic.py
--- a/pypy/module/hpy_universal/test/test_basic.py
+++ b/pypy/module/hpy_universal/test/test_basic.py
@@ -52,3 +52,16 @@
@INIT
""")
assert mod.f() is mod
+
+ def test_identity_function(self):
+ mod = self.make_module("""
+ HPy_FUNCTION(f)
+ static HPy f_impl(HPyContext ctx, HPy self, HPy arg)
+ {
+ return HPy_Dup(ctx, arg);
+ }
+ @EXPORT f METH_O
+ @INIT
+ """)
+ x = object()
+ assert mod.f(x) is x
More information about the pypy-commit
mailing list