mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-20 05:49:06 +02:00
Fix refcount leak and optimize list initialization.
This commit is contained in:
229
python/msgpack.c
229
python/msgpack.c
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.2 on Tue Jun 16 01:57:05 2009 */
|
||||
/* Generated by Cython 0.11.1 on Wed Jun 17 13:44:30 2009 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
@@ -103,9 +103,6 @@
|
||||
#ifndef __cdecl
|
||||
#define __cdecl
|
||||
#endif
|
||||
#ifndef __fastcall
|
||||
#define __fastcall
|
||||
#endif
|
||||
#else
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
@@ -136,7 +133,6 @@
|
||||
#include "string.h"
|
||||
#include "pack.h"
|
||||
#include "unpack.h"
|
||||
#define __PYX_USE_C99_COMPLEX defined(_Complex_I)
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -228,7 +224,6 @@ static const char * __pyx_cfilenm= __FILE__;
|
||||
static const char *__pyx_filename;
|
||||
static const char **__pyx_f;
|
||||
|
||||
|
||||
#ifdef CYTHON_REFNANNY
|
||||
typedef struct {
|
||||
void (*INCREF)(void*, PyObject*, int);
|
||||
@@ -325,7 +320,7 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":39
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":39
|
||||
* cdef int BUFF_SIZE=2*1024
|
||||
*
|
||||
* cdef class Packer: # <<<<<<<<<<<<<<
|
||||
@@ -343,7 +338,7 @@ struct __pyx_obj_7msgpack_Packer {
|
||||
PyObject *strm;
|
||||
};
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":200
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":200
|
||||
* return unpacks(packed)
|
||||
*
|
||||
* cdef class Unpacker: # <<<<<<<<<<<<<<
|
||||
@@ -356,7 +351,7 @@ struct __pyx_obj_7msgpack_Unpacker {
|
||||
};
|
||||
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":39
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":39
|
||||
* cdef int BUFF_SIZE=2*1024
|
||||
*
|
||||
* cdef class Packer: # <<<<<<<<<<<<<<
|
||||
@@ -375,12 +370,10 @@ static PyTypeObject *__pyx_ptype_7msgpack_Unpacker = 0;
|
||||
static int __pyx_v_7msgpack_BUFF_SIZE;
|
||||
static PyObject *__pyx_k_1 = 0;
|
||||
static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *, const char*, unsigned int); /*proto*/
|
||||
#define __Pyx_MODULE_NAME "msgpack"
|
||||
int __pyx_module_is_main_msgpack = 0;
|
||||
|
||||
const char *__pyx_modulename = "msgpack";
|
||||
|
||||
/* Implementation of msgpack */
|
||||
static char __pyx_k___main__[] = "__main__";
|
||||
static PyObject *__pyx_kp___main__;
|
||||
static char __pyx_k___init__[] = "__init__";
|
||||
static PyObject *__pyx_kp___init__;
|
||||
static char __pyx_k___del__[] = "__del__";
|
||||
@@ -438,7 +431,7 @@ static PyObject *__pyx_kp_4;
|
||||
static char __pyx_k_3[] = "utf-8";
|
||||
static char __pyx_k_4[] = "can't serialize %r";
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":51
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":51
|
||||
* cdef object strm
|
||||
*
|
||||
* def __init__(self, strm, int size=0): # <<<<<<<<<<<<<<
|
||||
@@ -500,7 +493,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
return -1;
|
||||
__pyx_L4_argument_unpacking_done:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":52
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":52
|
||||
*
|
||||
* def __init__(self, strm, int size=0):
|
||||
* if size <= 0: # <<<<<<<<<<<<<<
|
||||
@@ -510,7 +503,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
__pyx_t_1 = (__pyx_v_size <= 0);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":53
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":53
|
||||
* def __init__(self, strm, int size=0):
|
||||
* if size <= 0:
|
||||
* size = BUFF_SIZE # <<<<<<<<<<<<<<
|
||||
@@ -522,7 +515,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
}
|
||||
__pyx_L6:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":55
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":55
|
||||
* size = BUFF_SIZE
|
||||
*
|
||||
* self.strm = strm # <<<<<<<<<<<<<<
|
||||
@@ -535,7 +528,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
__Pyx_DECREF(((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->strm);
|
||||
((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->strm = __pyx_v_strm;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":56
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":56
|
||||
*
|
||||
* self.strm = strm
|
||||
* self.buff = <char*> malloc(size) # <<<<<<<<<<<<<<
|
||||
@@ -544,7 +537,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
*/
|
||||
((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->buff = ((char *)malloc(__pyx_v_size));
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":57
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":57
|
||||
* self.strm = strm
|
||||
* self.buff = <char*> malloc(size)
|
||||
* self.allocated = size # <<<<<<<<<<<<<<
|
||||
@@ -553,7 +546,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
*/
|
||||
((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->allocated = __pyx_v_size;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":58
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":58
|
||||
* self.buff = <char*> malloc(size)
|
||||
* self.allocated = size
|
||||
* self.length = 0 # <<<<<<<<<<<<<<
|
||||
@@ -562,7 +555,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
*/
|
||||
((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->length = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":60
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":60
|
||||
* self.length = 0
|
||||
*
|
||||
* msgpack_packer_init(&self.pk, <void*>self, <msgpack_packer_write>_packer_write) # <<<<<<<<<<<<<<
|
||||
@@ -576,7 +569,7 @@ static int __pyx_pf_7msgpack_6Packer___init__(PyObject *__pyx_v_self, PyObject *
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":62
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":62
|
||||
* msgpack_packer_init(&self.pk, <void*>self, <msgpack_packer_write>_packer_write)
|
||||
*
|
||||
* def __del__(self): # <<<<<<<<<<<<<<
|
||||
@@ -589,7 +582,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer___del__(PyObject *__pyx_v_self, PyObj
|
||||
PyObject *__pyx_r = NULL;
|
||||
__Pyx_SetupRefcountContext("__del__");
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":63
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":63
|
||||
*
|
||||
* def __del__(self):
|
||||
* free(self.buff); # <<<<<<<<<<<<<<
|
||||
@@ -604,7 +597,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer___del__(PyObject *__pyx_v_self, PyObj
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":65
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":65
|
||||
* free(self.buff);
|
||||
*
|
||||
* def flush(self): # <<<<<<<<<<<<<<
|
||||
@@ -622,7 +615,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
PyObject *__pyx_t_4 = NULL;
|
||||
__Pyx_SetupRefcountContext("flush");
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":67
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":67
|
||||
* def flush(self):
|
||||
* """Flash local buffer and output stream if it has 'flush()' method."""
|
||||
* if self.length > 0: # <<<<<<<<<<<<<<
|
||||
@@ -632,7 +625,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
__pyx_t_1 = (((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->length > 0);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":68
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":68
|
||||
* """Flash local buffer and output stream if it has 'flush()' method."""
|
||||
* if self.length > 0:
|
||||
* self.strm.write(PyString_FromStringAndSize(self.buff, self.length)) # <<<<<<<<<<<<<<
|
||||
@@ -654,7 +647,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":69
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":69
|
||||
* if self.length > 0:
|
||||
* self.strm.write(PyString_FromStringAndSize(self.buff, self.length))
|
||||
* self.length = 0 # <<<<<<<<<<<<<<
|
||||
@@ -666,7 +659,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
}
|
||||
__pyx_L5:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":70
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":70
|
||||
* self.strm.write(PyString_FromStringAndSize(self.buff, self.length))
|
||||
* self.length = 0
|
||||
* if hasattr(self.strm, 'flush'): # <<<<<<<<<<<<<<
|
||||
@@ -676,7 +669,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
__pyx_t_1 = PyObject_HasAttr(((struct __pyx_obj_7msgpack_Packer *)__pyx_v_self)->strm, __pyx_kp_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":71
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":71
|
||||
* self.length = 0
|
||||
* if hasattr(self.strm, 'flush'):
|
||||
* self.strm.flush() # <<<<<<<<<<<<<<
|
||||
@@ -707,7 +700,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_flush(PyObject *__pyx_v_self, PyObjec
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":73
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":73
|
||||
* self.strm.flush()
|
||||
*
|
||||
* def pack_list(self, len): # <<<<<<<<<<<<<<
|
||||
@@ -722,7 +715,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack_list(PyObject *__pyx_v_self, PyO
|
||||
size_t __pyx_t_1;
|
||||
__Pyx_SetupRefcountContext("pack_list");
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":86
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":86
|
||||
* packer.pack(['foo', 'bar'])
|
||||
* """
|
||||
* msgpack_pack_array(&self.pk, len) # <<<<<<<<<<<<<<
|
||||
@@ -743,7 +736,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack_list(PyObject *__pyx_v_self, PyO
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":88
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":88
|
||||
* msgpack_pack_array(&self.pk, len)
|
||||
*
|
||||
* def pack_dict(self, len): # <<<<<<<<<<<<<<
|
||||
@@ -758,7 +751,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack_dict(PyObject *__pyx_v_self, PyO
|
||||
size_t __pyx_t_1;
|
||||
__Pyx_SetupRefcountContext("pack_dict");
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":101
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":101
|
||||
* packer.pack({'foo', 'bar'})
|
||||
* """
|
||||
* msgpack_pack_map(&self.pk, len) # <<<<<<<<<<<<<<
|
||||
@@ -779,7 +772,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack_dict(PyObject *__pyx_v_self, PyO
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":103
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":103
|
||||
* msgpack_pack_map(&self.pk, len)
|
||||
*
|
||||
* cdef __pack(self, object o): # <<<<<<<<<<<<<<
|
||||
@@ -813,7 +806,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
|
||||
__pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":108
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":108
|
||||
* cdef char* rawval
|
||||
*
|
||||
* if o is None: # <<<<<<<<<<<<<<
|
||||
@@ -823,7 +816,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = (__pyx_v_o == Py_None);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":109
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":109
|
||||
*
|
||||
* if o is None:
|
||||
* msgpack_pack_nil(&self.pk) # <<<<<<<<<<<<<<
|
||||
@@ -834,7 +827,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":110
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":110
|
||||
* if o is None:
|
||||
* msgpack_pack_nil(&self.pk)
|
||||
* elif o is True: # <<<<<<<<<<<<<<
|
||||
@@ -847,7 +840,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":111
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":111
|
||||
* msgpack_pack_nil(&self.pk)
|
||||
* elif o is True:
|
||||
* msgpack_pack_true(&self.pk) # <<<<<<<<<<<<<<
|
||||
@@ -858,7 +851,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":112
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":112
|
||||
* elif o is True:
|
||||
* msgpack_pack_true(&self.pk)
|
||||
* elif o is False: # <<<<<<<<<<<<<<
|
||||
@@ -871,7 +864,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":113
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":113
|
||||
* msgpack_pack_true(&self.pk)
|
||||
* elif o is False:
|
||||
* msgpack_pack_false(&self.pk) # <<<<<<<<<<<<<<
|
||||
@@ -882,7 +875,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":114
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":114
|
||||
* elif o is False:
|
||||
* msgpack_pack_false(&self.pk)
|
||||
* elif isinstance(o, long): # <<<<<<<<<<<<<<
|
||||
@@ -892,7 +885,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyLong_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":115
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":115
|
||||
* msgpack_pack_false(&self.pk)
|
||||
* elif isinstance(o, long):
|
||||
* intval = o # <<<<<<<<<<<<<<
|
||||
@@ -902,7 +895,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_o); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_intval = __pyx_t_3;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":116
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":116
|
||||
* elif isinstance(o, long):
|
||||
* intval = o
|
||||
* msgpack_pack_long_long(&self.pk, intval) # <<<<<<<<<<<<<<
|
||||
@@ -913,7 +906,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":117
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":117
|
||||
* intval = o
|
||||
* msgpack_pack_long_long(&self.pk, intval)
|
||||
* elif isinstance(o, int): # <<<<<<<<<<<<<<
|
||||
@@ -923,7 +916,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyInt_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":118
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":118
|
||||
* msgpack_pack_long_long(&self.pk, intval)
|
||||
* elif isinstance(o, int):
|
||||
* intval = o # <<<<<<<<<<<<<<
|
||||
@@ -933,7 +926,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_o); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_intval = __pyx_t_3;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":119
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":119
|
||||
* elif isinstance(o, int):
|
||||
* intval = o
|
||||
* msgpack_pack_long_long(&self.pk, intval) # <<<<<<<<<<<<<<
|
||||
@@ -944,7 +937,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":120
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":120
|
||||
* intval = o
|
||||
* msgpack_pack_long_long(&self.pk, intval)
|
||||
* elif isinstance(o, float): # <<<<<<<<<<<<<<
|
||||
@@ -954,7 +947,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyFloat_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":121
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":121
|
||||
* msgpack_pack_long_long(&self.pk, intval)
|
||||
* elif isinstance(o, float):
|
||||
* fval = o # <<<<<<<<<<<<<<
|
||||
@@ -964,7 +957,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_o); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_fval = __pyx_t_4;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":122
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":122
|
||||
* elif isinstance(o, float):
|
||||
* fval = o
|
||||
* msgpack_pack_double(&self.pk, fval) # <<<<<<<<<<<<<<
|
||||
@@ -975,7 +968,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":123
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":123
|
||||
* fval = o
|
||||
* msgpack_pack_double(&self.pk, fval)
|
||||
* elif isinstance(o, str): # <<<<<<<<<<<<<<
|
||||
@@ -985,7 +978,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyString_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":124
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":124
|
||||
* msgpack_pack_double(&self.pk, fval)
|
||||
* elif isinstance(o, str):
|
||||
* rawval = o # <<<<<<<<<<<<<<
|
||||
@@ -995,7 +988,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_rawval = __pyx_t_5;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":125
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":125
|
||||
* elif isinstance(o, str):
|
||||
* rawval = o
|
||||
* msgpack_pack_raw(&self.pk, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1005,7 +998,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_6 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
msgpack_pack_raw((&__pyx_v_self->pk), __pyx_t_6);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":126
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":126
|
||||
* rawval = o
|
||||
* msgpack_pack_raw(&self.pk, len(o))
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1017,7 +1010,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":127
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":127
|
||||
* msgpack_pack_raw(&self.pk, len(o))
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o))
|
||||
* elif isinstance(o, unicode): # <<<<<<<<<<<<<<
|
||||
@@ -1027,7 +1020,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyUnicode_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":128
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":128
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o))
|
||||
* elif isinstance(o, unicode):
|
||||
* o = o.encode('utf-8') # <<<<<<<<<<<<<<
|
||||
@@ -1049,7 +1042,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_v_o = __pyx_t_8;
|
||||
__pyx_t_8 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":129
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":129
|
||||
* elif isinstance(o, unicode):
|
||||
* o = o.encode('utf-8')
|
||||
* rawval = o # <<<<<<<<<<<<<<
|
||||
@@ -1059,7 +1052,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_rawval = __pyx_t_5;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":130
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":130
|
||||
* o = o.encode('utf-8')
|
||||
* rawval = o
|
||||
* msgpack_pack_raw(&self.pk, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1069,7 +1062,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_6 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
msgpack_pack_raw((&__pyx_v_self->pk), __pyx_t_6);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":131
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":131
|
||||
* rawval = o
|
||||
* msgpack_pack_raw(&self.pk, len(o))
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1081,7 +1074,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":132
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":132
|
||||
* msgpack_pack_raw(&self.pk, len(o))
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o))
|
||||
* elif isinstance(o, dict): # <<<<<<<<<<<<<<
|
||||
@@ -1091,7 +1084,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)&PyDict_Type)));
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":133
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":133
|
||||
* msgpack_pack_raw_body(&self.pk, rawval, len(o))
|
||||
* elif isinstance(o, dict):
|
||||
* msgpack_pack_map(&self.pk, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1101,7 +1094,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_6 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
msgpack_pack_map((&__pyx_v_self->pk), __pyx_t_6);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":134
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":134
|
||||
* elif isinstance(o, dict):
|
||||
* msgpack_pack_map(&self.pk, len(o))
|
||||
* for k,v in o.iteritems(): # <<<<<<<<<<<<<<
|
||||
@@ -1164,7 +1157,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_3 = 0;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":135
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":135
|
||||
* msgpack_pack_map(&self.pk, len(o))
|
||||
* for k,v in o.iteritems():
|
||||
* self.pack(k) # <<<<<<<<<<<<<<
|
||||
@@ -1184,7 +1177,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
|
||||
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":136
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":136
|
||||
* for k,v in o.iteritems():
|
||||
* self.pack(k)
|
||||
* self.pack(v) # <<<<<<<<<<<<<<
|
||||
@@ -1208,7 +1201,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
goto __pyx_L3;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":137
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":137
|
||||
* self.pack(k)
|
||||
* self.pack(v)
|
||||
* elif isinstance(o, tuple) or isinstance(o, list): # <<<<<<<<<<<<<<
|
||||
@@ -1224,7 +1217,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
}
|
||||
if (__pyx_t_11) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":138
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":138
|
||||
* self.pack(v)
|
||||
* elif isinstance(o, tuple) or isinstance(o, list):
|
||||
* msgpack_pack_array(&self.pk, len(o)) # <<<<<<<<<<<<<<
|
||||
@@ -1234,7 +1227,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_t_6 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
msgpack_pack_array((&__pyx_v_self->pk), __pyx_t_6);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":139
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":139
|
||||
* elif isinstance(o, tuple) or isinstance(o, list):
|
||||
* msgpack_pack_array(&self.pk, len(o))
|
||||
* for v in o: # <<<<<<<<<<<<<<
|
||||
@@ -1266,7 +1259,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
__pyx_v_v = __pyx_t_7;
|
||||
__pyx_t_7 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":140
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":140
|
||||
* msgpack_pack_array(&self.pk, len(o))
|
||||
* for v in o:
|
||||
* self.pack(v) # <<<<<<<<<<<<<<
|
||||
@@ -1291,7 +1284,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
}
|
||||
/*else*/ {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":143
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":143
|
||||
* else:
|
||||
* # TODO: Serialize with defalt() like simplejson.
|
||||
* raise TypeError, "can't serialize %r" % (o,) # <<<<<<<<<<<<<<
|
||||
@@ -1333,7 +1326,7 @@ static PyObject *__pyx_f_7msgpack_6Packer___pack(struct __pyx_obj_7msgpack_Pack
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":145
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":145
|
||||
* raise TypeError, "can't serialize %r" % (o,)
|
||||
*
|
||||
* def pack(self, obj, flush=True): # <<<<<<<<<<<<<<
|
||||
@@ -1394,7 +1387,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack(PyObject *__pyx_v_self, PyObject
|
||||
return NULL;
|
||||
__pyx_L4_argument_unpacking_done:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":146
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":146
|
||||
*
|
||||
* def pack(self, obj, flush=True):
|
||||
* self.__pack(obj) # <<<<<<<<<<<<<<
|
||||
@@ -1405,7 +1398,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack(PyObject *__pyx_v_self, PyObject
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":147
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":147
|
||||
* def pack(self, obj, flush=True):
|
||||
* self.__pack(obj)
|
||||
* if flush: # <<<<<<<<<<<<<<
|
||||
@@ -1415,7 +1408,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack(PyObject *__pyx_v_self, PyObject
|
||||
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_flush); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_2) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":148
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":148
|
||||
* self.__pack(obj)
|
||||
* if flush:
|
||||
* self.flush() # <<<<<<<<<<<<<<
|
||||
@@ -1445,7 +1438,7 @@ static PyObject *__pyx_pf_7msgpack_6Packer_pack(PyObject *__pyx_v_self, PyObject
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":150
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":150
|
||||
* self.flush()
|
||||
*
|
||||
* cdef int _packer_write(Packer packer, const_char_ptr b, unsigned int l): # <<<<<<<<<<<<<<
|
||||
@@ -1461,7 +1454,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
PyObject *__pyx_t_4 = NULL;
|
||||
__Pyx_SetupRefcountContext("_packer_write");
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":151
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":151
|
||||
*
|
||||
* cdef int _packer_write(Packer packer, const_char_ptr b, unsigned int l):
|
||||
* if packer.length + l > packer.allocated: # <<<<<<<<<<<<<<
|
||||
@@ -1471,7 +1464,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
__pyx_t_1 = ((__pyx_v_packer->length + __pyx_v_l) > __pyx_v_packer->allocated);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":152
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":152
|
||||
* cdef int _packer_write(Packer packer, const_char_ptr b, unsigned int l):
|
||||
* if packer.length + l > packer.allocated:
|
||||
* if packer.length > 0: # <<<<<<<<<<<<<<
|
||||
@@ -1481,7 +1474,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
__pyx_t_1 = (__pyx_v_packer->length > 0);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":153
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":153
|
||||
* if packer.length + l > packer.allocated:
|
||||
* if packer.length > 0:
|
||||
* packer.strm.write(PyString_FromStringAndSize(packer.buff, packer.length)) # <<<<<<<<<<<<<<
|
||||
@@ -1506,7 +1499,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
}
|
||||
__pyx_L4:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":154
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":154
|
||||
* if packer.length > 0:
|
||||
* packer.strm.write(PyString_FromStringAndSize(packer.buff, packer.length))
|
||||
* if l > 64: # <<<<<<<<<<<<<<
|
||||
@@ -1516,7 +1509,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
__pyx_t_1 = (__pyx_v_l > 64);
|
||||
if (__pyx_t_1) {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":155
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":155
|
||||
* packer.strm.write(PyString_FromStringAndSize(packer.buff, packer.length))
|
||||
* if l > 64:
|
||||
* packer.strm.write(PyString_FromStringAndSize(b, l)) # <<<<<<<<<<<<<<
|
||||
@@ -1538,7 +1531,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":156
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":156
|
||||
* if l > 64:
|
||||
* packer.strm.write(PyString_FromStringAndSize(b, l))
|
||||
* packer.length = 0 # <<<<<<<<<<<<<<
|
||||
@@ -1550,7 +1543,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
}
|
||||
/*else*/ {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":158
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":158
|
||||
* packer.length = 0
|
||||
* else:
|
||||
* memcpy(packer.buff, b, l) # <<<<<<<<<<<<<<
|
||||
@@ -1559,7 +1552,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
*/
|
||||
memcpy(__pyx_v_packer->buff, __pyx_v_b, __pyx_v_l);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":159
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":159
|
||||
* else:
|
||||
* memcpy(packer.buff, b, l)
|
||||
* packer.length = l # <<<<<<<<<<<<<<
|
||||
@@ -1573,7 +1566,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
}
|
||||
/*else*/ {
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":161
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":161
|
||||
* packer.length = l
|
||||
* else:
|
||||
* memcpy(packer.buff + packer.length, b, l) # <<<<<<<<<<<<<<
|
||||
@@ -1582,7 +1575,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
*/
|
||||
memcpy((__pyx_v_packer->buff + __pyx_v_packer->length), __pyx_v_b, __pyx_v_l);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":162
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":162
|
||||
* else:
|
||||
* memcpy(packer.buff + packer.length, b, l)
|
||||
* packer.length += l # <<<<<<<<<<<<<<
|
||||
@@ -1593,7 +1586,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
}
|
||||
__pyx_L3:;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":163
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":163
|
||||
* memcpy(packer.buff + packer.length, b, l)
|
||||
* packer.length += l
|
||||
* return 0 # <<<<<<<<<<<<<<
|
||||
@@ -1616,7 +1609,7 @@ static int __pyx_f_7msgpack__packer_write(struct __pyx_obj_7msgpack_Packer *__p
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":165
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":165
|
||||
* return 0
|
||||
*
|
||||
* def pack(object o, object stream): # <<<<<<<<<<<<<<
|
||||
@@ -1677,7 +1670,7 @@ static PyObject *__pyx_pf_7msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_ar
|
||||
__pyx_L4_argument_unpacking_done:;
|
||||
__pyx_v_packer = Py_None; __Pyx_INCREF(Py_None);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":166
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":166
|
||||
*
|
||||
* def pack(object o, object stream):
|
||||
* packer = Packer(stream) # <<<<<<<<<<<<<<
|
||||
@@ -1696,7 +1689,7 @@ static PyObject *__pyx_pf_7msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_ar
|
||||
__pyx_v_packer = __pyx_t_2;
|
||||
__pyx_t_2 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":167
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":167
|
||||
* def pack(object o, object stream):
|
||||
* packer = Packer(stream)
|
||||
* packer.pack(o) # <<<<<<<<<<<<<<
|
||||
@@ -1716,7 +1709,7 @@ static PyObject *__pyx_pf_7msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_ar
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":168
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":168
|
||||
* packer = Packer(stream)
|
||||
* packer.pack(o)
|
||||
* packer.flush() # <<<<<<<<<<<<<<
|
||||
@@ -1745,7 +1738,7 @@ static PyObject *__pyx_pf_7msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_ar
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":170
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":170
|
||||
* packer.flush()
|
||||
*
|
||||
* def packs(object o): # <<<<<<<<<<<<<<
|
||||
@@ -1767,7 +1760,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
__pyx_v_buf = Py_None; __Pyx_INCREF(Py_None);
|
||||
__pyx_v_packer = Py_None; __Pyx_INCREF(Py_None);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":171
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":171
|
||||
*
|
||||
* def packs(object o):
|
||||
* buf = StringIO() # <<<<<<<<<<<<<<
|
||||
@@ -1783,7 +1776,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
__pyx_v_buf = __pyx_t_1;
|
||||
__pyx_t_1 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":172
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":172
|
||||
* def packs(object o):
|
||||
* buf = StringIO()
|
||||
* packer = Packer(buf) # <<<<<<<<<<<<<<
|
||||
@@ -1802,7 +1795,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
__pyx_v_packer = __pyx_t_2;
|
||||
__pyx_t_2 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":173
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":173
|
||||
* buf = StringIO()
|
||||
* packer = Packer(buf)
|
||||
* packer.pack(o) # <<<<<<<<<<<<<<
|
||||
@@ -1822,7 +1815,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":174
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":174
|
||||
* packer = Packer(buf)
|
||||
* packer.pack(o)
|
||||
* packer.flush() # <<<<<<<<<<<<<<
|
||||
@@ -1836,7 +1829,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":175
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":175
|
||||
* packer.pack(o)
|
||||
* packer.flush()
|
||||
* return buf.getvalue() # <<<<<<<<<<<<<<
|
||||
@@ -1870,7 +1863,7 @@ static PyObject *__pyx_pf_7msgpack_packs(PyObject *__pyx_self, PyObject *__pyx_v
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":186
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":186
|
||||
*
|
||||
*
|
||||
* def unpacks(object packed_bytes): # <<<<<<<<<<<<<<
|
||||
@@ -1891,7 +1884,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
__Pyx_SetupRefcountContext("unpacks");
|
||||
__pyx_self = __pyx_self;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":188
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":188
|
||||
* def unpacks(object packed_bytes):
|
||||
* """Unpack packed_bytes to object. Returns unpacked object."""
|
||||
* cdef const_char_ptr p = packed_bytes # <<<<<<<<<<<<<<
|
||||
@@ -1901,7 +1894,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
__pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_packed_bytes); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_p = __pyx_t_1;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":190
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":190
|
||||
* cdef const_char_ptr p = packed_bytes
|
||||
* cdef template_context ctx
|
||||
* cdef size_t off = 0 # <<<<<<<<<<<<<<
|
||||
@@ -1910,7 +1903,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
*/
|
||||
__pyx_v_off = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":191
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":191
|
||||
* cdef template_context ctx
|
||||
* cdef size_t off = 0
|
||||
* template_init(&ctx) # <<<<<<<<<<<<<<
|
||||
@@ -1919,7 +1912,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
*/
|
||||
template_init((&__pyx_v_ctx));
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":192
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":192
|
||||
* cdef size_t off = 0
|
||||
* template_init(&ctx)
|
||||
* template_execute(&ctx, p, len(packed_bytes), &off) # <<<<<<<<<<<<<<
|
||||
@@ -1929,7 +1922,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
__pyx_t_2 = PyObject_Length(__pyx_v_packed_bytes); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
template_execute((&__pyx_v_ctx), __pyx_v_p, __pyx_t_2, (&__pyx_v_off));
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":193
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":193
|
||||
* template_init(&ctx)
|
||||
* template_execute(&ctx, p, len(packed_bytes), &off)
|
||||
* return template_data(&ctx) # <<<<<<<<<<<<<<
|
||||
@@ -1955,7 +1948,7 @@ static PyObject *__pyx_pf_7msgpack_unpacks(PyObject *__pyx_self, PyObject *__pyx
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":195
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":195
|
||||
* return template_data(&ctx)
|
||||
*
|
||||
* def unpack(object stream): # <<<<<<<<<<<<<<
|
||||
@@ -1975,7 +1968,7 @@ static PyObject *__pyx_pf_7msgpack_unpack(PyObject *__pyx_self, PyObject *__pyx_
|
||||
__pyx_self = __pyx_self;
|
||||
__pyx_v_packed = Py_None; __Pyx_INCREF(Py_None);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":197
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":197
|
||||
* def unpack(object stream):
|
||||
* """unpack from stream."""
|
||||
* packed = stream.read() # <<<<<<<<<<<<<<
|
||||
@@ -1991,7 +1984,7 @@ static PyObject *__pyx_pf_7msgpack_unpack(PyObject *__pyx_self, PyObject *__pyx_
|
||||
__pyx_v_packed = __pyx_t_2;
|
||||
__pyx_t_2 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":198
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":198
|
||||
* """unpack from stream."""
|
||||
* packed = stream.read()
|
||||
* return unpacks(packed) # <<<<<<<<<<<<<<
|
||||
@@ -2097,11 +2090,7 @@ static PyNumberMethods __pyx_tp_as_number_Packer = {
|
||||
0, /*nb_coerce*/
|
||||
#endif
|
||||
0, /*nb_int*/
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
0, /*reserved*/
|
||||
#else
|
||||
0, /*nb_long*/
|
||||
#endif
|
||||
0, /*nb_float*/
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /*nb_oct*/
|
||||
@@ -2257,11 +2246,7 @@ static PyNumberMethods __pyx_tp_as_number_Unpacker = {
|
||||
0, /*nb_coerce*/
|
||||
#endif
|
||||
0, /*nb_int*/
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
0, /*reserved*/
|
||||
#else
|
||||
0, /*nb_long*/
|
||||
#endif
|
||||
0, /*nb_float*/
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /*nb_oct*/
|
||||
@@ -2404,7 +2389,6 @@ static struct PyModuleDef __pyx_moduledef = {
|
||||
#endif
|
||||
|
||||
static __Pyx_StringTabEntry __pyx_string_tab[] = {
|
||||
{&__pyx_kp___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1},
|
||||
{&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
|
||||
{&__pyx_kp___del__, __pyx_k___del__, sizeof(__pyx_k___del__), 1, 1, 1},
|
||||
{&__pyx_kp_flush, __pyx_k_flush, sizeof(__pyx_k_flush), 1, 1, 1},
|
||||
@@ -2496,9 +2480,6 @@ PyMODINIT_FUNC PyInit_msgpack(void)
|
||||
__pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
|
||||
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
if (__pyx_module_is_main_msgpack) {
|
||||
if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_kp___main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
}
|
||||
/*--- Builtin init code ---*/
|
||||
if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_skip_dispatch = 0;
|
||||
@@ -2522,7 +2503,7 @@ PyMODINIT_FUNC PyInit_msgpack(void)
|
||||
/*--- Function import code ---*/
|
||||
/*--- Execution code ---*/
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":3
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":3
|
||||
* # coding: utf-8
|
||||
*
|
||||
* from cStringIO import StringIO # <<<<<<<<<<<<<<
|
||||
@@ -2543,7 +2524,7 @@ PyMODINIT_FUNC PyInit_msgpack(void)
|
||||
__Pyx_DECREF(__pyx_2); __pyx_2 = 0;
|
||||
__Pyx_DECREF(__pyx_1); __pyx_1 = 0;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":37
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":37
|
||||
*
|
||||
*
|
||||
* cdef int BUFF_SIZE=2*1024 # <<<<<<<<<<<<<<
|
||||
@@ -2552,7 +2533,7 @@ PyMODINIT_FUNC PyInit_msgpack(void)
|
||||
*/
|
||||
__pyx_v_7msgpack_BUFF_SIZE = 2048;
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":145
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":145
|
||||
* raise TypeError, "can't serialize %r" % (o,)
|
||||
*
|
||||
* def pack(self, obj, flush=True): # <<<<<<<<<<<<<<
|
||||
@@ -2565,7 +2546,7 @@ PyMODINIT_FUNC PyInit_msgpack(void)
|
||||
__pyx_t_1 = 0;
|
||||
__Pyx_GIVEREF(__pyx_k_1);
|
||||
|
||||
/* "/home/inada-n/work/msgpack/python/msgpack.pyx":202
|
||||
/* "/home/inada-n/work/msgpack/msgpack-py/python/msgpack.pyx":202
|
||||
* cdef class Unpacker:
|
||||
* """Do nothing. This function is for symmetric to Packer"""
|
||||
* unpack = staticmethod(unpacks) # <<<<<<<<<<<<<<
|
||||
@@ -3368,14 +3349,14 @@ static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
|
||||
return Py_INCREF(x), x;
|
||||
m = Py_TYPE(x)->tp_as_number;
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
if (m && m->nb_int) {
|
||||
name = "int";
|
||||
res = PyNumber_Int(x);
|
||||
}
|
||||
else if (m && m->nb_long) {
|
||||
if (m && m->nb_long) {
|
||||
name = "long";
|
||||
res = PyNumber_Long(x);
|
||||
}
|
||||
else if (m && m->nb_int) {
|
||||
name = "int";
|
||||
res = PyNumber_Int(x);
|
||||
}
|
||||
#else
|
||||
if (m && m->nb_int) {
|
||||
name = "int";
|
||||
|
@@ -2,7 +2,7 @@ from distutils.core import setup, Extension
|
||||
|
||||
version = '0.0.1'
|
||||
|
||||
msgpack_mod = Extension('msgpack', sources=['msgpack.c'])
|
||||
msgpack_mod = Extension('msgpack', sources=['msgpack.c'], extra_compile_args=["-O3"])
|
||||
|
||||
desc = 'MessagePack serializer/desirializer.'
|
||||
long_desc = desc + """
|
||||
|
@@ -20,7 +20,8 @@
|
||||
#include "msgpack/unpack_define.h"
|
||||
|
||||
typedef struct {
|
||||
int reserved;
|
||||
struct {unsigned int size, last} array_stack[MSGPACK_MAX_STACK_SIZE];
|
||||
int array_current;
|
||||
} unpack_user;
|
||||
|
||||
|
||||
@@ -42,7 +43,10 @@ struct template_context;
|
||||
typedef struct template_context template_context;
|
||||
|
||||
static inline msgpack_unpack_object template_callback_root(unpack_user* u)
|
||||
{ return NULL; }
|
||||
{
|
||||
u->array_current = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int template_callback_uint8(unpack_user* u, uint8_t d, msgpack_unpack_object* o)
|
||||
{ *o = PyInt_FromLong((long)d); return 0; }
|
||||
@@ -52,8 +56,8 @@ static inline int template_callback_uint16(unpack_user* u, uint16_t d, msgpack_u
|
||||
|
||||
static inline int template_callback_uint32(unpack_user* u, uint32_t d, msgpack_unpack_object* o)
|
||||
{
|
||||
if (d >= 0x80000000UL) {
|
||||
*o = PyLong_FromUnsignedLongLong((unsigned long long)d);
|
||||
if (d > LONG_MAX) {
|
||||
*o = PyLong_FromUnsignedLong((unsigned long)d);
|
||||
} else {
|
||||
*o = PyInt_FromLong((long)d);
|
||||
}
|
||||
@@ -92,14 +96,32 @@ static inline int template_callback_false(unpack_user* u, msgpack_unpack_object*
|
||||
|
||||
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
|
||||
{
|
||||
/* TODO: use PyList_New(n). */
|
||||
*o = PyList_New(0);
|
||||
if (n > 0) {
|
||||
int cur = ++u->array_current;
|
||||
u->array_stack[cur].size = n;
|
||||
u->array_stack[cur].last = 0;
|
||||
*o = PyList_New(n);
|
||||
}
|
||||
else {
|
||||
*o = PyList_New(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int template_callback_array_item(unpack_user* u, msgpack_unpack_object* c, msgpack_unpack_object o)
|
||||
{
|
||||
PyList_Append(*c, o);
|
||||
int cur = u->array_current;
|
||||
int n = u->array_stack[cur].size;
|
||||
int last = u->array_stack[cur].last;
|
||||
|
||||
PyList_SetItem(*c, last, o);
|
||||
last++;
|
||||
if (last >= n) {
|
||||
u->array_current--;
|
||||
}
|
||||
else {
|
||||
u->array_stack[cur].last = last;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -112,13 +134,18 @@ static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_
|
||||
static inline int template_callback_map_item(unpack_user* u, msgpack_unpack_object* c, msgpack_unpack_object k, msgpack_unpack_object v)
|
||||
{
|
||||
PyDict_SetItem(*c, k, v);
|
||||
return 0;
|
||||
Py_DECREF(k);
|
||||
Py_DECREF(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o)
|
||||
{
|
||||
*o = PyString_FromStringAndSize(p, l);
|
||||
return 0;
|
||||
if (l < 16) { // without foundation
|
||||
PyString_InternInPlace(o);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "msgpack/unpack_template.h"
|
||||
|
Reference in New Issue
Block a user