diff options
author | Naoki INADA <inada-n@klab.jp> | 2009-12-17 11:13:47 +0900 |
---|---|---|
committer | Naoki INADA <inada-n@klab.jp> | 2009-12-17 11:13:47 +0900 |
commit | 77e3e59620d65589451c833fa01e9c9e5f39624d (patch) | |
tree | 9486f063c73b9c82acad8ecfbe42c1f22fd48882 /msgpack/_msgpack.pyx | |
parent | af7c4d2a60086503ee9c124f8cc79a05c2fabe70 (diff) | |
download | msgpack-python-77e3e59620d65589451c833fa01e9c9e5f39624d.tar.gz |
Add `use_tuple` option that returns tuple for array object to Unpacker.
Diffstat (limited to 'msgpack/_msgpack.pyx')
-rw-r--r-- | msgpack/_msgpack.pyx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx index dcabc0f..b20ad7b 100644 --- a/msgpack/_msgpack.pyx +++ b/msgpack/_msgpack.pyx @@ -151,7 +151,11 @@ def packb(object o): packs = packb cdef extern from "unpack.h": + ctypedef struct msgpack_user: + int use_tuple + ctypedef struct template_context: + msgpack_user user PyObject* obj size_t count unsigned int ct @@ -170,6 +174,7 @@ def unpackb(object packed_bytes): cdef size_t off = 0 cdef int ret template_init(&ctx) + ctx.user.use_tuple = 0 ret = template_execute(&ctx, p, len(packed_bytes), &off) if ret == 1: return template_data(&ctx) @@ -225,6 +230,7 @@ cdef class Unpacker(object): cdef object file_like cdef int read_size cdef object waiting_bytes + cdef int use_tuple def __cinit__(self): self.buf = NULL @@ -233,9 +239,10 @@ cdef class Unpacker(object): if self.buf: free(self.buf); - def __init__(self, file_like=None, int read_size=0): + def __init__(self, file_like=None, int read_size=0, use_tuple=0): if read_size == 0: read_size = 1024*1024 + self.use_tuple = use_tuple self.file_like = file_like self.read_size = read_size self.waiting_bytes = [] @@ -244,6 +251,7 @@ cdef class Unpacker(object): self.buf_head = 0 self.buf_tail = 0 template_init(&self.ctx) + self.ctx.user.use_tuple = use_tuple def feed(self, next_bytes): if not isinstance(next_bytes, str): |