| 1 | #include <Python.h> |
| 2 | #include "hpy.h" |
| 3 | |
| 4 | #ifndef HPY_ABI_CPYTHON |
| 5 | // for _h2py and _py2h |
| 6 | # include "handles.h" |
| 7 | #endif |
| 8 | |
| 9 | |
| 10 | _HPy_HIDDEN HPy |
| 11 | ctx_Tuple_FromArray(HPyContext *ctx, const HPy items[], HPy_ssize_t n) |
| 12 | { |
| 13 | PyObject *res = PyTuple_New(n); |
| 14 | if (!res) |
| 15 | return HPy_NULL; |
| 16 | for(HPy_ssize_t i=0; i<n; i++) { |
| 17 | PyObject *item = _h2py(items[i]); |
| 18 | Py_INCREF(item); |
| 19 | PyTuple_SET_ITEM(res, i, item); |
| 20 | } |
| 21 | return _py2h(res); |
| 22 | } |