Author: Armin Rigo <[email protected]>
Branch: cpyext-gc-support-2
Changeset: r81963:af2938e59cd3
Date: 2016-01-27 00:29 +0100
http://bitbucket.org/pypy/pypy/changeset/af2938e59cd3/
Log: Rename: this new function should really be a superset of make_ref()
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
@@ -675,7 +675,7 @@
if callable.api_func.result_borrowed:
retval = as_pyobj(space, result)
else:
- retval = get_pyobj_and_incref(space, result)
+ retval = make_ref(space, result)
retval = rffi.cast(callable.api_func.restype, retval)
else:
retval = lltype.nullptr(PyObject.TO)
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
@@ -33,7 +33,7 @@
# similar to PyType_GenericAlloc?
# except that it's not related to any pypy object.
- pytype = get_pyobj_and_incref(space, w_type)
+ pytype = make_ref(space, w_type)
pytype = rffi.cast(PyTypeObjectPtr, pytype)
assert pytype
# Don't increase refcount for non-heaptypes
@@ -241,7 +241,7 @@
This doesn't give a new reference, but the returned 'PyObject *'
is valid at least as long as 'w_obj' is. **To be safe, you should
use keepalive_until_here(w_obj) some time later.** In case of
- doubt, use the safer get_pyobj_and_incref().
+ doubt, use the safer make_ref().
"""
if w_obj is not None:
assert not is_pyobj(w_obj)
@@ -293,7 +293,7 @@
return hop.inputconst(lltype.Bool, hop.s_result.const)
@specialize.ll()
-def get_pyobj_and_incref(space, obj):
+def make_ref(space, obj):
"""Increment the reference counter of the PyObject and return it.
Can be called with either a PyObject or a W_Root.
"""
@@ -309,7 +309,7 @@
return pyobj
else:
return lltype.nullptr(PyObject.TO)
-INTERPLEVEL_API['get_pyobj_and_incref'] = get_pyobj_and_incref
+INTERPLEVEL_API['make_ref'] = make_ref
@specialize.ll()
@@ -335,7 +335,7 @@
@specialize.ll()
def incref(space, obj):
- get_pyobj_and_incref(space, obj)
+ make_ref(space, obj)
INTERPLEVEL_API['incref'] = incref
@specialize.ll()
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,8 +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,
- get_pyobj_and_incref)
+ track_reference, RefcountState, borrow_from, Py_DecRef)
from pypy.module.cpyext.slotdefs import (
slotdefs_for_tp_slots, slotdefs_for_wrappers, get_slot_tp_function)
from pypy.module.cpyext.state import State
@@ -418,7 +417,7 @@
def type_alloc(space, w_metatype):
- metatype = get_pyobj_and_incref(space, w_metatype)
+ metatype = make_ref(space, w_metatype)
metatype = rffi.cast(PyTypeObjectPtr, metatype)
assert metatype
# Don't increase refcount for non-heaptypes
@@ -473,7 +472,7 @@
# XXX implement
# c_tp_compare and the following fields (see
http://docs.python.org/c-api/typeobj.html )
w_base = best_base(space, w_type.bases_w)
- py_base = get_pyobj_and_incref(space, w_base)
+ py_base = make_ref(space, w_base)
pto.c_tp_base = rffi.cast(PyTypeObjectPtr, py_base)
finish_type_1(space, pto)
@@ -493,7 +492,7 @@
if pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE:
w_typename = space.getattr(w_type, space.wrap('__name__'))
heaptype = rffi.cast(PyHeapTypeObject, pto)
- heaptype.c_ht_name = get_pyobj_and_incref(space, w_typename)
+ heaptype.c_ht_name = make_ref(space, w_typename)
from pypy.module.cpyext.stringobject import PyString_AsString
pto.c_tp_name = PyString_AsString(space, heaptype.c_ht_name)
else:
@@ -599,7 +598,7 @@
bases = space.newtuple([])
else:
bases = space.newtuple([from_ref(space, base_pyo)])
- pto.c_tp_bases = get_pyobj_and_incref(space, bases)
+ pto.c_tp_bases = make_ref(space, bases)
def finish_type_2(space, pto, w_obj):
"""
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit