Author: Matti Picus <[email protected]>
Branch: call-via-pyobj
Changeset: r85516:349eb5ca6183
Date: 2016-07-02 21:15 +0300
http://bitbucket.org/pypy/pypy/changeset/349eb5ca6183/
Log: fixes for translation, but not done yet
diff --git a/pypy/module/cpyext/methodobject.py
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -174,16 +174,25 @@
raise oefmt(space.w_TypeError,
"wrapper %s doesn't take any keyword arguments",
self.method_name)
+ func_to_call = self.func
if self.offset:
- ptr = pto = rffi.cast(PyTypeObjectPtr, as_pyobj(space,
self.w_objclass))
+ ptr = as_pyobj(space, self.w_objclass)
# make ptr the equivalent of this, using the offsets
- #func_to_call = rffi.cast(rffi.VOIDP,
pto.c_tp_as_number.c_nb_multiply)
- for o in self.offset:
- ptr_as_int = lltype.cast_ptr_to_int(ptr)
- ptr = rffi.cast(rffi.VOIDPP, ptr_as_int + o)[0]
- func_to_call = ptr
- else:
- func_to_call = self.func
+ #func_to_call = rffi.cast(rffi.VOIDP,
ptr.c_tp_as_number.c_nb_multiply)
+ if not ptr is rffi.VOIDP:
+ ptr = rffi.cast(rffi.VOIDP, ptr)
+ for o in self.offset:
+ if not ptr:
+ break
+ ptr_as_int = lltype.cast_ptr_to_int(ptr)
+ pptr = rffi.cast(rffi.VOIDPP, ptr_as_int + o)
+ if not pptr:
+ break
+ ptr = pptr[0]
+ ptr = rffi.cast(rffi.VOIDP, ptr)
+ if ptr:
+ func_to_call = ptr
+ assert func_to_call
return self.wrapper_func(space, w_self, w_args, func_to_call)
def descr_method_repr(self):
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
@@ -296,7 +296,7 @@
for method_name, slot_names, wrapper_func, wrapper_func_kwds, doc in
slotdefs_for_wrappers:
if method_name in dict_w:
continue
- offset = [rffi.offsetof(pto._T, slot_names[0])]
+ offset = [rffi.offsetof(lltype.typeOf(pto).TO, slot_names[0])]
if len(slot_names) == 1:
func = getattr(pto, slot_names[0])
else:
@@ -304,8 +304,7 @@
struct = getattr(pto, slot_names[0])
if not struct:
continue
- assert isinstance(struct, lltype._ptr)
- offset.append(rffi.offsetof(struct._T, slot_names[1]))
+ offset.append(rffi.offsetof(lltype.typeOf(struct).TO,
slot_names[1]))
func = getattr(struct, slot_names[1])
func_voidp = rffi.cast(rffi.VOIDP, func)
if not func:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit