[pypy-commit] pypy cpyext-fast-typecheck: kill wrapper_func_kwds, since it was used only by wrap_init and wrap_call, which are now new-style; this simplify a bit of stuff around
antocuni
pypy.commits at gmail.com
Thu Mar 22 13:03:16 EDT 2018
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: cpyext-fast-typecheck
Changeset: r94089:0e2721692722
Date: 2018-03-22 17:54 +0100
http://bitbucket.org/pypy/pypy/changeset/0e2721692722/
Log: kill wrapper_func_kwds, since it was used only by wrap_init and
wrap_call, which are now new-style; this simplify a bit of stuff
around
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -857,14 +857,12 @@
PyWrapperFlag_KEYWORDS = 1
class TypeSlot:
- def __init__(self, method_name, slot_name, function, wrapper1, wrapper2, doc):
+ def __init__(self, method_name, slot_name, function, wrapper, doc):
self.method_name = method_name
self.slot_name = slot_name
self.slot_names = tuple(("c_" + slot_name).split("."))
self.slot_func = function
- self.wrapper_func = wrapper1
- assert wrapper2 is None
- self.wrapper_func_kwds = None # eventually kill this
+ self.wrapper_class = wrapper
self.doc = doc
# adapted from typeobject.c
@@ -885,7 +883,7 @@
function = getattr(userslot, FUNCTION or '!missing', None)
assert FLAGS == 0 or FLAGS == PyWrapperFlag_KEYWORDS
- return TypeSlot(NAME, SLOT, function, wrapper, None, DOC)
+ return TypeSlot(NAME, SLOT, function, wrapper, DOC)
def TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC):
return FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, 0)
@@ -1174,7 +1172,7 @@
x.slot_func.api_func if x.slot_func else None) for x in slotdefs])
slotdefs_for_wrappers = unrolling_iterable(
- [(x.method_name, x.slot_names, x.wrapper_func, x.wrapper_func_kwds, x.doc)
+ [(x.method_name, x.slot_names, x.wrapper_class, x.doc)
for x in slotdefs])
if __name__ == "__main__":
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
@@ -312,7 +312,7 @@
def add_operators(space, dict_w, pto):
from pypy.module.cpyext.object import PyObject_HashNotImplemented
hash_not_impl = llslot(space, PyObject_HashNotImplemented)
- for method_name, slot_names, wrapper_func, wrapper_func_kwds, doc in slotdefs_for_wrappers:
+ for method_name, slot_names, wrapper_class, doc in slotdefs_for_wrappers:
if method_name in dict_w:
continue
offset = [rffi.offsetof(lltype.typeOf(pto).TO, slot_names[0])]
@@ -337,21 +337,20 @@
func_voidp = rffi.cast(rffi.VOIDP, func)
if not func:
continue
- if wrapper_func is None and wrapper_func_kwds is None:
+ if wrapper_class is None:
continue
# XXX: this is just a quick hack to distinguish the old wrappers from
# the new ones: eventually, all of them will be subclasses of
# W_PyCWrapperObject
- if type(wrapper_func_kwds) is type:
- assert wrapper_func is None
- wrapper_func = wrapper_func_kwds
- if type(wrapper_func) is type and issubclass(wrapper_func, W_PyCWrapperObject):
+ if type(wrapper_class) is type and issubclass(wrapper_class, W_PyCWrapperObject):
# new style
- wrapper_class = wrapper_func
w_obj = wrapper_class(space, pto, method_name, doc, func_voidp,
offset=offset)
else:
+ # old style
+ wrapper_func = wrapper_class
+ wrapper_func_kwds = None
w_obj = W_PyCWrapperObjectGeneric(space, pto, method_name, wrapper_func,
wrapper_func_kwds, doc,
func_voidp, offset=offset)
More information about the pypy-commit
mailing list