mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-19 20:03:16 +00:00
Merge branch 'master' of https://github.com/antocuni/msgpack-python into newspec
Conflicts: msgpack/fallback.py msgpack/unpack.h msgpack/unpack_define.h msgpack/unpack_template.h
This commit is contained in:
commit
27f0cba8a5
11 changed files with 261 additions and 41 deletions
|
@ -24,6 +24,7 @@ typedef struct unpack_user {
|
|||
PyObject *object_hook;
|
||||
bool has_pairs_hook;
|
||||
PyObject *list_hook;
|
||||
PyObject *ext_type_hook;
|
||||
const char *encoding;
|
||||
const char *unicode_errors;
|
||||
} unpack_user;
|
||||
|
@ -235,4 +236,21 @@ static inline int unpack_callback_bin(unpack_user* u, const char* b, const char*
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int unpack_callback_ext(unpack_user* u, const char* base, const char* pos,
|
||||
unsigned int lenght, msgpack_unpack_object* o)
|
||||
{
|
||||
PyObject *py;
|
||||
int8_t typecode = (int8_t)*pos++;
|
||||
if (!u->ext_type_hook) {
|
||||
PyErr_SetString(PyExc_AssertionError, "u->ext_type_hook cannot be NULL");
|
||||
return -1;
|
||||
}
|
||||
// lenght also includes the typecode, so the actual data is lenght-1
|
||||
py = PyEval_CallFunction(u->ext_type_hook, "(is#)", typecode, pos, lenght-1);
|
||||
if (!py)
|
||||
return -1;
|
||||
*o = py;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "unpack_template.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue