[pypy-commit] pypy cpyext-gc-support-2: rename from_pyobj() back to from_ref() too
arigo
pypy.commits at gmail.com
Tue Jan 26 18:36:53 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support-2
Changeset: r81964:769d8cdc1853
Date: 2016-01-27 00:34 +0100
http://bitbucket.org/pypy/pypy/changeset/769d8cdc1853/
Log: rename from_pyobj() back to from_ref() too
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -308,7 +308,7 @@
elif is_PyObject(ARG) and is_wrapped:
# build a W_Root, possibly from a 'PyObject *'
if is_pyobj(input_arg):
- arg = from_pyobj(space, input_arg)
+ arg = from_ref(space, input_arg)
else:
arg = input_arg
@@ -634,7 +634,7 @@
arg = args[i]
if is_PyObject(typ) and is_wrapped:
assert is_pyobj(arg)
- arg_conv = from_pyobj(space, arg)
+ arg_conv = from_ref(space, arg)
else:
arg_conv = arg
boxed_args += (arg_conv, )
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -209,17 +209,12 @@
Finds the interpreter object corresponding to the given reference. If the
object is not yet realized (see stringobject.py), creates it.
"""
- GOES_AWAY
- assert lltype.typeOf(ref) == PyObject
+ assert is_pyobj(ref)
if not ref:
return None
- state = space.fromcache(RefcountState)
- ptr = rffi.cast(ADDR, ref)
-
- try:
- return state.py_objects_r2w[ptr]
- except KeyError:
- pass
+ w_obj = rawrefcount.to_obj(W_Root, pyobj)
+ if w_obj is not None:
+ return w_obj
# This reference is not yet a real interpreter object.
# Realize it.
@@ -259,20 +254,6 @@
return rawrefcount.to_obj(W_Root, pyobj) is not None
INTERPLEVEL_API['pyobj_has_w_obj'] = staticmethod(pyobj_has_w_obj)
- at specialize.ll()
-def from_pyobj(space, pyobj):
- assert is_pyobj(pyobj)
- if pyobj:
- pyobj = rffi.cast(PyObject, pyobj)
- w_obj = rawrefcount.to_obj(W_Root, pyobj)
- if w_obj is None:
- XXXXXXXXXXX
- return w_obj
- else:
- return None
-from_pyobj._always_inline_ = 'try'
-INTERPLEVEL_API['from_pyobj'] = from_pyobj
-
def is_pyobj(x):
if x is None or isinstance(x, W_Root):
@@ -321,7 +302,7 @@
"""
if is_pyobj(obj):
pyobj = rffi.cast(PyObject, obj)
- w_obj = from_pyobj(space, pyobj)
+ w_obj = from_ref(space, pyobj)
else:
w_obj = obj
pyobj = as_pyobj(space, w_obj)
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -21,7 +21,7 @@
from pypy.module.cpyext.modsupport import convert_method_defs
from pypy.module.cpyext.pyobject import (
PyObject, make_ref, create_ref, from_ref, get_typedescr, make_typedescr,
- track_reference, RefcountState, borrow_from, Py_DecRef)
+ track_reference, RefcountState, borrow_from, Py_DecRef, as_pyobj)
from pypy.module.cpyext.slotdefs import (
slotdefs_for_tp_slots, slotdefs_for_wrappers, get_slot_tp_function)
from pypy.module.cpyext.state import State
More information about the pypy-commit
mailing list