diff options
Diffstat (limited to 'msgpack/unpack.h')
-rw-r--r-- | msgpack/unpack.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h index 9eb8ce7..e4c03bd 100644 --- a/msgpack/unpack.h +++ b/msgpack/unpack.h @@ -21,6 +21,7 @@ typedef struct unpack_user { int use_list; + PyObject *object_hook; } unpack_user; @@ -172,6 +173,19 @@ static inline int template_callback_map_item(unpack_user* u, msgpack_unpack_obje return -1; } +//static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_object* c) +int template_callback_map_end(unpack_user* u, msgpack_unpack_object* c) +{ + if (u->object_hook) { + PyObject *arglist = Py_BuildValue("(O)", *c); + Py_INCREF(*c); + *c = PyEval_CallObject(u->object_hook, arglist); + Py_DECREF(arglist); + return 0; + } + return -1; +} + static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o) { PyObject *py; |