|
14 | 14 |
|
15 | 15 | #include "templ_common.h"
|
16 | 16 | #include "npy_hashtable.h"
|
| 17 | +#include "hpy_utils.h" |
17 | 18 |
|
18 | 19 |
|
19 | 20 |
|
@@ -218,3 +219,28 @@ PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *const *key)
|
218 | 219 | {
|
219 | 220 | return find_item(tb, key)[0];
|
220 | 221 | }
|
| 222 | + |
| 223 | +NPY_NO_EXPORT int |
| 224 | +HPyArrayIdentityHash_SetItem(HPyContext *ctx, PyArrayIdentityHash *tb, |
| 225 | + HPy const *key, HPy value, int replace) |
| 226 | +{ |
| 227 | + CAPI_WARN("HPyArrayIdentityHash_SetItem"); |
| 228 | + PyObject **py_key = HPy_AsPyObjectArray(ctx, (HPy *)key, tb->key_len); |
| 229 | + PyObject *py_value = HPy_AsPyObject(ctx, value); |
| 230 | + int res = PyArrayIdentityHash_SetItem(tb, py_key, py_value, replace); |
| 231 | + Py_XDECREF(py_value); |
| 232 | + HPy_DecrefAndFreeArray(ctx, py_key, tb->key_len); |
| 233 | + return res; |
| 234 | +} |
| 235 | + |
| 236 | +NPY_NO_EXPORT HPy |
| 237 | +HPyArrayIdentityHash_GetItem(HPyContext *ctx, PyArrayIdentityHash const *tb, HPy const *key) |
| 238 | +{ |
| 239 | + CAPI_WARN("HPyArrayIdentityHash_GetItem"); |
| 240 | + PyObject **py_key = HPy_AsPyObjectArray(ctx, (HPy *)key, tb->key_len); |
| 241 | + PyObject *py_res = PyArrayIdentityHash_GetItem(tb, py_key); |
| 242 | + HPy res = HPy_FromPyObject(ctx, py_res); |
| 243 | + Py_XDECREF(py_res); |
| 244 | + HPy_DecrefAndFreeArray(ctx, py_key, tb->key_len); |
| 245 | + return res; |
| 246 | +} |
0 commit comments