Author: mattip <matti.pi...@gmail.com> Branch: ufuncapi Changeset: r72855:2f354c411ced Date: 2014-08-17 23:42 +0300 http://bitbucket.org/pypy/pypy/changeset/2f354c411ced/
Log: fix api to accept {&func1, &func2}, probably could be cleaner. diff --git a/pypy/module/cpyext/ndarrayobject.py b/pypy/module/cpyext/ndarrayobject.py --- a/pypy/module/cpyext/ndarrayobject.py +++ b/pypy/module/cpyext/ndarrayobject.py @@ -295,9 +295,8 @@ GenericUfunc = lltype.FuncType([rffi.CArrayPtr(rffi.CCHARP), npy_intpp, npy_intpp, rffi.VOIDP], lltype.Void) gufunctype = lltype.Ptr(GenericUfunc) -# XXX the signature is wrong, it should be an array of gufunctype, but -# XXX rffi.CArrayPtr(gufunctype) does not seem to work ??? -@cpython_api([gufunctype, rffi.VOIDP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, +# XXX single rffi.CArrayPtr(gufunctype) does not work, this does, why??? +@cpython_api([rffi.CArrayPtr(rffi.CArrayPtr(gufunctype)), rffi.VOIDP, rffi.CCHARP, Py_ssize_t, Py_ssize_t, Py_ssize_t, Py_ssize_t, rffi.CCHARP, rffi.CCHARP, Py_ssize_t, rffi.CCHARP], PyObject) def _PyUFunc_FromFuncAndDataAndSignature(space, funcs, data, types, ntypes, @@ -305,8 +304,7 @@ funcs_w = [None] * ntypes dtypes_w = [None] * ntypes * (nin + nout) for i in range(ntypes): - # XXX this should be 'funcs[i]' not 'funcs' - funcs_w[i] = W_GenericUFuncCaller(funcs) + funcs_w[i] = W_GenericUFuncCaller(rffi.cast(gufunctype, funcs[i])) for i in range(ntypes*(nin+nout)): dtypes_w[i] = get_dtype_cache(space).dtypes_by_num[ord(types[i])] w_funcs = space.newlist(funcs_w) diff --git a/pypy/module/cpyext/test/test_ndarrayobject.py b/pypy/module/cpyext/test/test_ndarrayobject.py --- a/pypy/module/cpyext/test/test_ndarrayobject.py +++ b/pypy/module/cpyext/test/test_ndarrayobject.py @@ -324,10 +324,10 @@ PyObject * retval; /* XXX should be 'funcs', not 'funcs[1]' but how to define an array of function pointers in ndarrayobject.py? */ - retval = _PyUFunc_FromFuncAndDataAndSignature(funcs[1], + printf("calling w/funcs[0] = 0x%x, funcs[1] = 0x%x \\n", funcs[0], funcs[1]); + retval = _PyUFunc_FromFuncAndDataAndSignature(funcs, array_data, types, 2, 1, 1, PyUFunc_None, "times2", "times2_docstring", 0, "()->()"); - Py_INCREF(retval); return retval; """ ), _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit