[pypy-commit] pypy default: more "x._cdata -> with x as ptr" conversions

mattip noreply at buildbot.pypy.org
Wed Mar 4 20:14:20 CET 2015


Author: mattip <matti.picus at gmail.com>
Branch: 
Changeset: r76245:e5ad346030ac
Date: 2015-03-04 21:13 +0200
http://bitbucket.org/pypy/pypy/changeset/e5ad346030ac/

Log:	more "x._cdata -> with x as ptr" conversions

diff --git a/pypy/module/cppyy/capi/loadable_capi.py b/pypy/module/cppyy/capi/loadable_capi.py
--- a/pypy/module/cppyy/capi/loadable_capi.py
+++ b/pypy/module/cppyy/capi/loadable_capi.py
@@ -259,7 +259,8 @@
         if not objectmodel.we_are_translated():
             leakfinder.remember_free(c_call.ctype.cif_descr._obj0)
         state.capi_calls[name] = c_call
-    return c_call.ctype.rcall(c_call._cdata, args)
+    with c_call as ptr:
+        return c_call.ctype.rcall(ptr, args)
 
 def _cdata_to_cobject(space, w_cdata):
     return rffi.cast(C_OBJECT, space.uint_w(w_cdata))
@@ -271,8 +272,8 @@
     return rffi.cast(rffi.LONG, space.int_w(w_cdata))
 
 def _cdata_to_ptr(space, w_cdata): # TODO: this is both a hack and dreadfully slow
-    return rffi.cast(rffi.VOIDP,
-        space.interp_w(cdataobj.W_CData, w_cdata, can_be_None=False)._cdata)
+    with space.interp_w(cdataobj.W_CData, w_cdata, can_be_None=False) as ptr:
+        return rffi.cast(rffi.VOIDP, ptr)
 
 def c_load_dictionary(name):
     return libffi.CDLL(name)


More information about the pypy-commit mailing list