/* Generated by Cython 0.14.1 on Mon Feb 28 08:49:37 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__cpyamf__codec
#include "stdio.h"
#include "pythread.h"
#include "datetime.h"

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "codec.pyx",
  "codec.pxd",
  "util.pxd",
  "bool.pxd",
  "complex.pxd",
};

/* Type declarations */

/* "util.pxd":28
 *     cpdef bint at_eof(self) except -1
 *     cpdef inline Py_ssize_t remaining(self) except -1
 *     cpdef int seek(self, Py_ssize_t pos, int mode=*) except -1             # <<<<<<<<<<<<<<
 *     cpdef object getvalue(self)
 *     cdef Py_ssize_t peek(self, char **buf, Py_ssize_t size) except -1
 */

struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_seek {
  int __pyx_n;
  int mode;
};

/* "util.pxd":31
 *     cpdef object getvalue(self)
 *     cdef Py_ssize_t peek(self, char **buf, Py_ssize_t size) except -1
 *     cpdef int truncate(self, Py_ssize_t size=?) except -1             # <<<<<<<<<<<<<<
 *     cpdef int consume(self) except -1
 *     cdef int unpack_int(self, unsigned int num_bytes, void *ret) except -1
 */

struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_truncate {
  int __pyx_n;
  Py_ssize_t size;
};

/* "cpyamf/codec.pxd":102
 *     cdef int writeDate(self, object o) except -1
 *     cdef int writeXML(self, object o) except -1
 *     cpdef int writeList(self, object o, bint is_proxy=?) except -1             # <<<<<<<<<<<<<<
 *     cdef int writeTuple(self, object o) except -1
 *     cdef int writeSequence(self, object iterable) except -1
 */

struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeList {
  int __pyx_n;
  int is_proxy;
};

/* "cpyamf/codec.pxd":105
 *     cdef int writeTuple(self, object o) except -1
 *     cdef int writeSequence(self, object iterable) except -1
 *     cpdef int writeObject(self, object o, bint is_proxy=?) except -1             # <<<<<<<<<<<<<<
 *     cdef int writeDict(self, dict o) except -1
 *     cdef int writeMixedArray(self, object o) except -1
 */

struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject {
  int __pyx_n;
  int is_proxy;
};

/* "cpyamf/codec.pxd":54
 * 
 * 
 * cdef class Codec(object):             # <<<<<<<<<<<<<<
 *     """
 *     Base class for Encoder/Decoder classes. Provides base functionality for
 */

struct __pyx_obj_6cpyamf_5codec_Codec {
  PyObject_HEAD
  struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *stream;
  int strict;
  PyObject *timezone_offset;
};

/* "cpyamf/codec.pxd":65
 * 
 * 
 * cdef class Decoder(Codec):             # <<<<<<<<<<<<<<
 *     cdef object readDate(self)
 *     cpdef object readString(self)
 */

struct __pyx_obj_6cpyamf_5codec_Decoder {
  struct __pyx_obj_6cpyamf_5codec_Codec __pyx_base;
  struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *__pyx_vtab;
};

/* "util.pxd":5
 * 
 * 
 * cdef class cBufferedByteStream:             # <<<<<<<<<<<<<<
 *     """
 *     The c version of BufferedByteStream.
 */

struct __pyx_obj_6cpyamf_4util_cBufferedByteStream {
  PyObject_HEAD
  struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *__pyx_vtab;
  char endian;
  char *buffer;
  int closed;
  Py_ssize_t pos;
  Py_ssize_t size;
  Py_ssize_t length;
  Py_ssize_t min_buf_size;
};

/* "util.pxd":61
 * 
 * 
 * cdef class BufferedByteStream(cBufferedByteStream):             # <<<<<<<<<<<<<<
 *     """
 *     A file like object that mimics StringIO with some extra helper methods.
 */

struct __pyx_obj_6cpyamf_4util_BufferedByteStream {
  struct __pyx_obj_6cpyamf_4util_cBufferedByteStream __pyx_base;
};

/* "cpyamf/codec.pyx":619
 * 
 * 
 * cdef class _CustomTypeFunc(object):             # <<<<<<<<<<<<<<
 *     """
 *     Support for custom type mappings when encoding.
 */

struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc {
  PyObject_HEAD
  struct __pyx_obj_6cpyamf_5codec_Encoder *encoder;
  PyObject *func;
};

/* "cpyamf/codec.pxd":11
 * from cpyamf cimport util
 * 
 * cdef class IndexedCollection(object):             # <<<<<<<<<<<<<<
 *     """
 *     Provides reference functionality for amf contexts.
 */

struct __pyx_obj_6cpyamf_5codec_IndexedCollection {
  PyObject_HEAD
  struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *__pyx_vtab;
  int use_hash;
  PyObject **data;
  PyObject *refs;
  Py_ssize_t size;
  Py_ssize_t length;
};

/* "cpyamf/codec.pxd":32
 * 
 * 
 * cdef class Context(object):             # <<<<<<<<<<<<<<
 *     """
 *     C based version of ``pyamf.BaseContext``
 */

struct __pyx_obj_6cpyamf_5codec_Context {
  PyObject_HEAD
  struct __pyx_vtabstruct_6cpyamf_5codec_Context *__pyx_vtab;
  PyObject *class_aliases;
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *objects;
  PyObject *unicodes;
  PyObject *_strings;
  PyObject *extra;
};

/* "cpyamf/codec.pxd":81
 * 
 * 
 * cdef class Encoder(Codec):             # <<<<<<<<<<<<<<
 *     """
 *     """
 */

struct __pyx_obj_6cpyamf_5codec_Encoder {
  struct __pyx_obj_6cpyamf_5codec_Codec __pyx_base;
  struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *__pyx_vtab;
  PyObject *func_cache;
  PyObject *use_write_object;
  PyObject *bucket;
};


/* "cpyamf/codec.pyx":196
 * 
 * 
 * cdef class Context(object):             # <<<<<<<<<<<<<<
 *     """
 *     I hold the AMF context for en/decoding streams.
 */

struct __pyx_vtabstruct_6cpyamf_5codec_Context {
  int (*clear)(struct __pyx_obj_6cpyamf_5codec_Context *, int __pyx_skip_dispatch);
  PyObject *(*getClassAlias)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getObject)(struct __pyx_obj_6cpyamf_5codec_Context *, Py_ssize_t, int __pyx_skip_dispatch);
  Py_ssize_t (*getObjectReference)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch);
  Py_ssize_t (*addObject)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getStringForBytes)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getBytesForString)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Context *__pyx_vtabptr_6cpyamf_5codec_Context;


/* "cpyamf/codec.pyx":330
 * 
 * 
 * cdef class Decoder(Codec):             # <<<<<<<<<<<<<<
 *     """
 *     Base AMF decoder.
 */

struct __pyx_vtabstruct_6cpyamf_5codec_Decoder {
  PyObject *(*readDate)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readString)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch);
  PyObject *(*readObject)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readNumber)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readNull)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readUndefined)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readList)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readXML)(struct __pyx_obj_6cpyamf_5codec_Decoder *);
  PyObject *(*readElement)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch);
  PyObject *(*readConcreteElement)(struct __pyx_obj_6cpyamf_5codec_Decoder *, char);
  int (*send)(struct __pyx_obj_6cpyamf_5codec_Decoder *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *__pyx_vtabptr_6cpyamf_5codec_Decoder;


/* "util.pxd":5
 * 
 * 
 * cdef class cBufferedByteStream:             # <<<<<<<<<<<<<<
 *     """
 *     The c version of BufferedByteStream.
 */

struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream {
  Py_ssize_t (*tell)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  int (*write)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, char *, Py_ssize_t);
  int (*_init_buffer)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *);
  int (*_actually_increase_buffer)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, Py_ssize_t);
  int (*_increase_buffer)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, Py_ssize_t);
  int (*has_available)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, Py_ssize_t);
  int (*read)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, char **, Py_ssize_t);
  int (*at_eof)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  Py_ssize_t (*remaining)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  int (*seek)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, Py_ssize_t, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_seek *__pyx_optional_args);
  PyObject *(*getvalue)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  Py_ssize_t (*peek)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, char **, Py_ssize_t);
  int (*truncate)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_truncate *__pyx_optional_args);
  int (*consume)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  int (*unpack_int)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, unsigned int, void *);
  int (*pack_int)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int, long);
  int (*pack_uint)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int, unsigned long);
  unsigned char (*read_uchar)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  char (*read_char)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  unsigned short (*read_ushort)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  short (*read_short)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  unsigned long (*read_24bit_uint)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  long (*read_24bit_int)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  unsigned long (*read_ulong)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  long (*read_long)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int __pyx_skip_dispatch);
  int (*write_uchar)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, unsigned char, int __pyx_skip_dispatch);
  int (*write_char)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, char, int __pyx_skip_dispatch);
  int (*write_ushort)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, unsigned short, int __pyx_skip_dispatch);
  int (*write_short)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, short, int __pyx_skip_dispatch);
  int (*write_24bit_uint)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, unsigned long, int __pyx_skip_dispatch);
  int (*write_24bit_int)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, long, int __pyx_skip_dispatch);
  int (*write_ulong)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, unsigned long, int __pyx_skip_dispatch);
  int (*write_long)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, long, int __pyx_skip_dispatch);
  PyObject *(*read_utf8_string)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, Py_ssize_t, int __pyx_skip_dispatch);
  int (*write_utf8_string)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, PyObject *, int __pyx_skip_dispatch);
  int (*read_double)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, double *);
  int (*write_double)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, double, int __pyx_skip_dispatch);
  int (*read_float)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, float *);
  int (*write_float)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, float, int __pyx_skip_dispatch);
  int (*append)(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *__pyx_vtabptr_6cpyamf_4util_cBufferedByteStream;


/* "cpyamf/codec.pyx":38
 * 
 * 
 * cdef class IndexedCollection(object):             # <<<<<<<<<<<<<<
 *     """
 *     Provides reference functionality for amf contexts.
 */

struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection {
  int (*_actually_increase_size)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *);
  int (*_increase_size)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *);
  void (*_clear)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *);
  int (*clear)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, int __pyx_skip_dispatch);
  PyObject *(*_ref)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *);
  PyObject *(*getByReference)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, Py_ssize_t, int __pyx_skip_dispatch);
  Py_ssize_t (*getReferenceTo)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *, int __pyx_skip_dispatch);
  Py_ssize_t (*append)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *__pyx_vtabptr_6cpyamf_5codec_IndexedCollection;


/* "util.pxd":61
 * 
 * 
 * cdef class BufferedByteStream(cBufferedByteStream):             # <<<<<<<<<<<<<<
 *     """
 *     A file like object that mimics StringIO with some extra helper methods.
 */

struct __pyx_vtabstruct_6cpyamf_4util_BufferedByteStream {
  struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream __pyx_base;
};
static struct __pyx_vtabstruct_6cpyamf_4util_BufferedByteStream *__pyx_vtabptr_6cpyamf_4util_BufferedByteStream;


/* "cpyamf/codec.pyx":404
 * 
 * 
 * cdef class Encoder(Codec):             # <<<<<<<<<<<<<<
 *     """
 *     Base AMF encoder.
 */

struct __pyx_vtabstruct_6cpyamf_5codec_Encoder {
  int (*serialiseString)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch);
  int (*writeType)(struct __pyx_obj_6cpyamf_5codec_Encoder *, char);
  int (*writeNull)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeUndefined)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeString)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeBytes)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeBoolean)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeInt)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeLong)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeNumber)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeDateTime)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeDate)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeXML)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeList)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeList *__pyx_optional_args);
  int (*writeTuple)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeSequence)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeObject)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject *__pyx_optional_args);
  int (*writeDict)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeMixedArray)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*writeGenerator)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *);
  int (*handleBasicTypes)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *);
  int (*checkBadTypes)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *);
  int (*writeElement)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch);
  int (*send)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *__pyx_vtabptr_6cpyamf_5codec_Encoder;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        /* these presumably have safe hash functions */
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        PyObject *m;
        m = __Pyx_GetAttrString(d, "get");
        if (!m) return NULL;
        value = PyObject_CallFunctionObjArgs(m, key,
            (default_value == Py_None) ? NULL : default_value, NULL);
        Py_DECREF(m);
    }
#endif
    return value;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    if (unlikely(d == Py_None)) {
        __Pyx_RaiseNoneIndexingError();
        return NULL;
    }
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred())
            PyErr_SetObject(PyExc_KeyError, key);
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void* __Pyx_GetVtable(PyObject *dict); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from cpyamf */

/* Module declarations from cpyamf.util */

static PyTypeObject *__pyx_ptype_6cpyamf_4util_cBufferedByteStream = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4util_BufferedByteStream = 0;
/* Module declarations from cpython.version */

/* Module declarations from cpython.ref */

/* Module declarations from cpython.exc */

/* Module declarations from cpython.module */

/* Module declarations from cpython.mem */

/* Module declarations from cpython.tuple */

/* Module declarations from cpython.list */

/* Module declarations from libc.stdio */

/* Module declarations from cpython.object */

/* Module declarations from cpython.sequence */

/* Module declarations from cpython.mapping */

/* Module declarations from cpython.iterator */

/* Module declarations from cpython.type */

/* Module declarations from cpython.number */

/* Module declarations from cpython.int */

/* Module declarations from __builtin__ */

/* Module declarations from cpython.bool */

static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
/* Module declarations from cpython.long */

/* Module declarations from cpython.float */

/* Module declarations from __builtin__ */

/* Module declarations from cpython.complex */

static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
/* Module declarations from cpython.string */

/* Module declarations from cpython.unicode */

/* Module declarations from cpython.dict */

/* Module declarations from cpython.instance */

/* Module declarations from cpython.function */

/* Module declarations from cpython.method */

/* Module declarations from cpython.weakref */

/* Module declarations from cpython.getargs */

/* Module declarations from cpython.pythread */

/* Module declarations from cpython.cobject */

/* Module declarations from cpython.oldbuffer */

/* Module declarations from cpython.set */

/* Module declarations from cpython.buffer */

/* Module declarations from cpython.bytes */

/* Module declarations from cpython.pycapsule */

/* Module declarations from cpython */

/* Module declarations from cpyamf.codec */

static PyTypeObject *__pyx_ptype_6cpyamf_5codec_IndexedCollection = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_5codec_Context = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_5codec_Codec = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_5codec_Decoder = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_5codec_Encoder = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_5codec__CustomTypeFunc = 0;
static PyObject *__pyx_v_6cpyamf_5codec_MixedArray = 0;
static PyObject *__pyx_v_6cpyamf_5codec_Undefined = 0;
static PyObject *__pyx_v_6cpyamf_5codec_BuiltinFunctionType = 0;
static PyObject *__pyx_v_6cpyamf_5codec_GeneratorType = 0;
static PyObject *__pyx_f_6cpyamf_5codec_get_custom_type_func(PyObject *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "cpyamf.codec"
static int __pyx_module_is_main_cpyamf__codec = 0;

/* Implementation of cpyamf.codec */
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_basestring;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_callable;
static char __pyx_k_2[] = "_actually_increase_size";
static char __pyx_k_3[] = "utf-8";
static char __pyx_k_8[] = "Cannot encode modules";
static char __pyx_k_10[] = "Cannot encode methods";
static char __pyx_k_12[] = "Cannot encode functions";
static char __pyx_k_14[] = "Cannot encode class objects";
static char __pyx_k_16[] = "A datetime.time instance was found but AMF has no way to encode time objects. Please use datetime.datetime instead";
static char __pyx_k_19[] = "\nC-extension for L{pyamf.amf3} Python module in L{PyAMF<pyamf>}.\n\n@since: 0.4\n";
static char __pyx_k__o[] = "o";
static char __pyx_k__pop[] = "pop";
static char __pyx_k__xml[] = "xml";
static char __pyx_k___ref[] = "_ref";
static char __pyx_k__data[] = "data";
static char __pyx_k__func[] = "func";
static char __pyx_k__next[] = "next";
static char __pyx_k__read[] = "read";
static char __pyx_k__refs[] = "refs";
static char __pyx_k__seek[] = "seek";
static char __pyx_k__send[] = "send";
static char __pyx_k__size[] = "size";
static char __pyx_k__tell[] = "tell";
static char __pyx_k__time[] = "time";
static char __pyx_k__util[] = "util";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__defer[] = "defer";
static char __pyx_k__extra[] = "extra";
static char __pyx_k__pyamf[] = "pyamf";
static char __pyx_k__types[] = "types";
static char __pyx_k__write[] = "write";
static char __pyx_k___clear[] = "_clear";
static char __pyx_k__append[] = "append";
static char __pyx_k__at_eof[] = "at_eof";
static char __pyx_k__bucket[] = "bucket";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__is_xml[] = "is_xml";
static char __pyx_k__length[] = "length";
static char __pyx_k__stream[] = "stream";
static char __pyx_k__strict[] = "strict";
static char __pyx_k__IOError[] = "IOError";
static char __pyx_k__combine[] = "combine";
static char __pyx_k__context[] = "context";
static char __pyx_k__encoder[] = "encoder";
static char __pyx_k__objects[] = "objects";
static char __pyx_k__EOStream[] = "EOStream";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k__TYPE_MAP[] = "TYPE_MAP";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k___strings[] = "_strings";
static char __pyx_k__callable[] = "callable";
static char __pyx_k__datetime[] = "datetime";
static char __pyx_k__external[] = "external";
static char __pyx_k__is_proxy[] = "is_proxy";
static char __pyx_k__unicodes[] = "unicodes";
static char __pyx_k__use_hash[] = "use_hash";
static char __pyx_k__writeInt[] = "writeInt";
static char __pyx_k__writeXML[] = "writeXML";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__Undefined[] = "Undefined";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k__addObject[] = "addObject";
static char __pyx_k__getObject[] = "getObject";
static char __pyx_k__iteritems[] = "iteritems";
static char __pyx_k__read_char[] = "read_char";
static char __pyx_k__writeDate[] = "writeDate";
static char __pyx_k__writeDict[] = "writeDict";
static char __pyx_k__writeList[] = "writeList";
static char __pyx_k__writeLong[] = "writeLong";
static char __pyx_k__writeNull[] = "writeNull";
static char __pyx_k__ClassAlias[] = "ClassAlias";
static char __pyx_k__IndexError[] = "IndexError";
static char __pyx_k__MixedArray[] = "MixedArray";
static char __pyx_k__basestring[] = "basestring";
static char __pyx_k__func_cache[] = "func_cache";
static char __pyx_k__readString[] = "readString";
static char __pyx_k__writeBytes[] = "writeBytes";
static char __pyx_k__writeTuple[] = "writeTuple";
static char __pyx_k__EncodeError[] = "EncodeError";
static char __pyx_k__readElement[] = "readElement";
static char __pyx_k__writeNumber[] = "writeNumber";
static char __pyx_k__writeObject[] = "writeObject";
static char __pyx_k__writeString[] = "writeString";
static char __pyx_k__writeBoolean[] = "writeBoolean";
static char __pyx_k__writeElement[] = "writeElement";
static char __pyx_k__GeneratorType[] = "GeneratorType";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k__checkBadTypes[] = "checkBadTypes";
static char __pyx_k__class_aliases[] = "class_aliases";
static char __pyx_k__getClassAlias[] = "getClassAlias";
static char __pyx_k__writeDateTime[] = "writeDateTime";
static char __pyx_k__writeSequence[] = "writeSequence";
static char __pyx_k__AttributeError[] = "AttributeError";
static char __pyx_k___increase_size[] = "_increase_size";
static char __pyx_k__getByReference[] = "getByReference";
static char __pyx_k__getReferenceTo[] = "getReferenceTo";
static char __pyx_k__get_class_meta[] = "get_class_meta";
static char __pyx_k__writeGenerator[] = "writeGenerator";
static char __pyx_k__writeUndefined[] = "writeUndefined";
static char __pyx_k__get_class_alias[] = "get_class_alias";
static char __pyx_k__serialiseString[] = "serialiseString";
static char __pyx_k__timezone_offset[] = "timezone_offset";
static char __pyx_k__writeMixedArray[] = "writeMixedArray";
static char __pyx_k__handleBasicTypes[] = "handleBasicTypes";
static char __pyx_k__use_write_object[] = "use_write_object";
static char __pyx_k__UnknownClassAlias[] = "UnknownClassAlias";
static char __pyx_k__getBytesForString[] = "getBytesForString";
static char __pyx_k__getStringForBytes[] = "getStringForBytes";
static char __pyx_k__getObjectReference[] = "getObjectReference";
static char __pyx_k__BuiltinFunctionType[] = "BuiltinFunctionType";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static char __pyx_k__readConcreteElement[] = "readConcreteElement";
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_n_s_2;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__AttributeError;
static PyObject *__pyx_n_s__BuiltinFunctionType;
static PyObject *__pyx_n_s__ClassAlias;
static PyObject *__pyx_n_s__EOStream;
static PyObject *__pyx_n_s__EncodeError;
static PyObject *__pyx_n_s__GeneratorType;
static PyObject *__pyx_n_s__IOError;
static PyObject *__pyx_n_s__IndexError;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__MixedArray;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__TYPE_MAP;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__Undefined;
static PyObject *__pyx_n_s__UnknownClassAlias;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___clear;
static PyObject *__pyx_n_s___increase_size;
static PyObject *__pyx_n_s___ref;
static PyObject *__pyx_n_s___strings;
static PyObject *__pyx_n_s__addObject;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__at_eof;
static PyObject *__pyx_n_s__basestring;
static PyObject *__pyx_n_s__bucket;
static PyObject *__pyx_n_s__callable;
static PyObject *__pyx_n_s__checkBadTypes;
static PyObject *__pyx_n_s__class_aliases;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__combine;
static PyObject *__pyx_n_s__context;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__datetime;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__defer;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__encoder;
static PyObject *__pyx_n_s__external;
static PyObject *__pyx_n_s__extra;
static PyObject *__pyx_n_s__func;
static PyObject *__pyx_n_s__func_cache;
static PyObject *__pyx_n_s__getByReference;
static PyObject *__pyx_n_s__getBytesForString;
static PyObject *__pyx_n_s__getClassAlias;
static PyObject *__pyx_n_s__getObject;
static PyObject *__pyx_n_s__getObjectReference;
static PyObject *__pyx_n_s__getReferenceTo;
static PyObject *__pyx_n_s__getStringForBytes;
static PyObject *__pyx_n_s__get_class_alias;
static PyObject *__pyx_n_s__get_class_meta;
static PyObject *__pyx_n_s__handleBasicTypes;
static PyObject *__pyx_n_s__is_proxy;
static PyObject *__pyx_n_s__is_xml;
static PyObject *__pyx_n_s__iteritems;
static PyObject *__pyx_n_s__length;
static PyObject *__pyx_n_s__next;
static PyObject *__pyx_n_s__o;
static PyObject *__pyx_n_s__objects;
static PyObject *__pyx_n_s__pop;
static PyObject *__pyx_n_s__pyamf;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__readConcreteElement;
static PyObject *__pyx_n_s__readElement;
static PyObject *__pyx_n_s__readString;
static PyObject *__pyx_n_s__read_char;
static PyObject *__pyx_n_s__refs;
static PyObject *__pyx_n_s__seek;
static PyObject *__pyx_n_s__send;
static PyObject *__pyx_n_s__serialiseString;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__stream;
static PyObject *__pyx_n_s__strict;
static PyObject *__pyx_n_s__tell;
static PyObject *__pyx_n_s__time;
static PyObject *__pyx_n_s__timezone_offset;
static PyObject *__pyx_n_s__types;
static PyObject *__pyx_n_s__unicodes;
static PyObject *__pyx_n_s__use_hash;
static PyObject *__pyx_n_s__use_write_object;
static PyObject *__pyx_n_s__util;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__writeBoolean;
static PyObject *__pyx_n_s__writeBytes;
static PyObject *__pyx_n_s__writeDate;
static PyObject *__pyx_n_s__writeDateTime;
static PyObject *__pyx_n_s__writeDict;
static PyObject *__pyx_n_s__writeElement;
static PyObject *__pyx_n_s__writeGenerator;
static PyObject *__pyx_n_s__writeInt;
static PyObject *__pyx_n_s__writeList;
static PyObject *__pyx_n_s__writeLong;
static PyObject *__pyx_n_s__writeMixedArray;
static PyObject *__pyx_n_s__writeNull;
static PyObject *__pyx_n_s__writeNumber;
static PyObject *__pyx_n_s__writeObject;
static PyObject *__pyx_n_s__writeSequence;
static PyObject *__pyx_n_s__writeString;
static PyObject *__pyx_n_s__writeTuple;
static PyObject *__pyx_n_s__writeUndefined;
static PyObject *__pyx_n_s__writeXML;
static PyObject *__pyx_n_s__xml;
static PyObject *__pyx_int_0;
static PyObject *__pyx_k_1;
static PyObject *__pyx_k_6;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_7;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_tuple_15;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_18;

/* "cpyamf/codec.pyx":45
 *     """
 * 
 *     def __cinit__(self, bint use_hash=0):             # <<<<<<<<<<<<<<
 *         self.use_hash = use_hash
 * 
 */

static int __pyx_pf_6cpyamf_5codec_17IndexedCollection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_17IndexedCollection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_use_hash;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__use_hash,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_hash);
        if (value) { values[0] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_use_hash = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_use_hash == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_use_hash = ((int)0);
    }
  } else {
    __pyx_v_use_hash = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_use_hash = __Pyx_PyObject_IsTrue(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_use_hash == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__cinit__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "cpyamf/codec.pyx":46
 * 
 *     def __cinit__(self, bint use_hash=0):
 *         self.use_hash = use_hash             # <<<<<<<<<<<<<<
 * 
 *         self.data = NULL
 */
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->use_hash = __pyx_v_use_hash;

  /* "cpyamf/codec.pyx":48
 *         self.use_hash = use_hash
 * 
 *         self.data = NULL             # <<<<<<<<<<<<<<
 *         self.refs = {}
 *         self.size = -1
 */
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->data = NULL;

  /* "cpyamf/codec.pyx":49
 * 
 *         self.data = NULL
 *         self.refs = {}             # <<<<<<<<<<<<<<
 *         self.size = -1
 *         self.length = -1
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->refs);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->refs));
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->refs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":50
 *         self.data = NULL
 *         self.refs = {}
 *         self.size = -1             # <<<<<<<<<<<<<<
 *         self.length = -1
 * 
 */
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->size = -1;

  /* "cpyamf/codec.pyx":51
 *         self.refs = {}
 *         self.size = -1
 *         self.length = -1             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, use_hash=False):
 */
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->length = -1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":53
 *         self.length = -1
 * 
 *     def __init__(self, use_hash=False):             # <<<<<<<<<<<<<<
 *         self.use_hash = use_hash
 * 
 */

static int __pyx_pf_6cpyamf_5codec_17IndexedCollection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_17IndexedCollection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_use_hash = 0;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__use_hash,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    values[0] = __pyx_k_1;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_hash);
        if (value) { values[0] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_use_hash = values[0];
  } else {
    __pyx_v_use_hash = __pyx_k_1;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_use_hash = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "cpyamf/codec.pyx":54
 * 
 *     def __init__(self, use_hash=False):
 *         self.use_hash = use_hash             # <<<<<<<<<<<<<<
 * 
 *         self.clear()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_use_hash); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->use_hash = __pyx_t_1;

  /* "cpyamf/codec.pyx":56
 *         self.use_hash = use_hash
 * 
 *         self.clear()             # <<<<<<<<<<<<<<
 * 
 *     cdef void _clear(self):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->clear(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":58
 *         self.clear()
 * 
 *     cdef void _clear(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 * 
 */

static  void __pyx_f_6cpyamf_5codec_17IndexedCollection__clear(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self) {
  Py_ssize_t __pyx_v_i;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3;
  __Pyx_RefNannySetupContext("_clear");

  /* "cpyamf/codec.pyx":61
 *         cdef Py_ssize_t i
 * 
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < self.length:
 *                 Py_DECREF(<object>self.data[i])
 */
  __pyx_t_1 = (__pyx_v_self->data != NULL);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":62
 * 
 *         if self.data != NULL:
 *             for i from 0 <= i < self.length:             # <<<<<<<<<<<<<<
 *                 Py_DECREF(<object>self.data[i])
 * 
 */
    __pyx_t_2 = __pyx_v_self->length;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

      /* "cpyamf/codec.pyx":63
 *         if self.data != NULL:
 *             for i from 0 <= i < self.length:
 *                 Py_DECREF(<object>self.data[i])             # <<<<<<<<<<<<<<
 * 
 *             PyMem_Free(self.data)
 */
      __pyx_t_3 = (__pyx_v_self->data[__pyx_v_i]);
      Py_DECREF(((PyObject *)__pyx_t_3));
    }

    /* "cpyamf/codec.pyx":65
 *                 Py_DECREF(<object>self.data[i])
 * 
 *             PyMem_Free(self.data)             # <<<<<<<<<<<<<<
 *             self.data = NULL
 * 
 */
    PyMem_Free(__pyx_v_self->data);

    /* "cpyamf/codec.pyx":66
 * 
 *             PyMem_Free(self.data)
 *             self.data = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_v_self->data = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "cpyamf/codec.pyx":68
 *             self.data = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self._clear()
 * 
 */

static void __pyx_pf_6cpyamf_5codec_17IndexedCollection_2__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6cpyamf_5codec_17IndexedCollection_2__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "cpyamf/codec.pyx":69
 * 
 *     def __dealloc__(self):
 *         self._clear()             # <<<<<<<<<<<<<<
 * 
 *     cdef int _actually_increase_size(self) except -1:
 */
  ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->_clear(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self));

  __Pyx_RefNannyFinishContext();
}

/* "cpyamf/codec.pyx":71
 *         self._clear()
 * 
 *     cdef int _actually_increase_size(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t new_len = self.length
 *         cdef Py_ssize_t current_size = self.size
 */

static  int __pyx_f_6cpyamf_5codec_17IndexedCollection__actually_increase_size(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self) {
  Py_ssize_t __pyx_v_new_len;
  Py_ssize_t __pyx_v_current_size;
  PyObject **__pyx_v_cpy;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2;
  __Pyx_RefNannySetupContext("_actually_increase_size");

  /* "cpyamf/codec.pyx":72
 * 
 *     cdef int _actually_increase_size(self) except -1:
 *         cdef Py_ssize_t new_len = self.length             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t current_size = self.size
 *         cdef PyObject **cpy
 */
  __pyx_v_new_len = __pyx_v_self->length;

  /* "cpyamf/codec.pyx":73
 *     cdef int _actually_increase_size(self) except -1:
 *         cdef Py_ssize_t new_len = self.length
 *         cdef Py_ssize_t current_size = self.size             # <<<<<<<<<<<<<<
 *         cdef PyObject **cpy
 * 
 */
  __pyx_v_current_size = __pyx_v_self->size;

  /* "cpyamf/codec.pyx":76
 *         cdef PyObject **cpy
 * 
 *         while new_len >= current_size:             # <<<<<<<<<<<<<<
 *             current_size *= 2
 * 
 */
  while (1) {
    __pyx_t_1 = (__pyx_v_new_len >= __pyx_v_current_size);
    if (!__pyx_t_1) break;

    /* "cpyamf/codec.pyx":77
 * 
 *         while new_len >= current_size:
 *             current_size *= 2             # <<<<<<<<<<<<<<
 * 
 *         if current_size != self.size:
 */
    __pyx_v_current_size = (__pyx_v_current_size * 2);
  }

  /* "cpyamf/codec.pyx":79
 *             current_size *= 2
 * 
 *         if current_size != self.size:             # <<<<<<<<<<<<<<
 *             self.size = current_size
 * 
 */
  __pyx_t_1 = (__pyx_v_current_size != __pyx_v_self->size);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":80
 * 
 *         if current_size != self.size:
 *             self.size = current_size             # <<<<<<<<<<<<<<
 * 
 *             cpy = <PyObject **>PyMem_Realloc(self.data, sizeof(PyObject *) * self.size)
 */
    __pyx_v_self->size = __pyx_v_current_size;

    /* "cpyamf/codec.pyx":82
 *             self.size = current_size
 * 
 *             cpy = <PyObject **>PyMem_Realloc(self.data, sizeof(PyObject *) * self.size)             # <<<<<<<<<<<<<<
 * 
 *             if cpy == NULL:
 */
    __pyx_v_cpy = ((PyObject **)PyMem_Realloc(__pyx_v_self->data, ((sizeof(PyObject *)) * __pyx_v_self->size)));

    /* "cpyamf/codec.pyx":84
 *             cpy = <PyObject **>PyMem_Realloc(self.data, sizeof(PyObject *) * self.size)
 * 
 *             if cpy == NULL:             # <<<<<<<<<<<<<<
 *                 self._clear()
 * 
 */
    __pyx_t_1 = (__pyx_v_cpy == NULL);
    if (__pyx_t_1) {

      /* "cpyamf/codec.pyx":85
 * 
 *             if cpy == NULL:
 *                 self._clear()             # <<<<<<<<<<<<<<
 * 
 *                 PyErr_NoMemory()
 */
      ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_clear(__pyx_v_self);

      /* "cpyamf/codec.pyx":87
 *                 self._clear()
 * 
 *                 PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *             self.data = cpy
 */
      __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cpyamf/codec.pyx":89
 *                 PyErr_NoMemory()
 * 
 *             self.data = cpy             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_v_self->data = __pyx_v_cpy;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/codec.pyx":91
 *             self.data = cpy
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int _increase_size(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection._actually_increase_size");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":93
 *         return 0
 * 
 *     cdef inline int _increase_size(self) except -1:             # <<<<<<<<<<<<<<
 *         if self.length < self.size:
 *             return 0
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_5codec_17IndexedCollection__increase_size(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_increase_size");

  /* "cpyamf/codec.pyx":94
 * 
 *     cdef inline int _increase_size(self) except -1:
 *         if self.length < self.size:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_1 = (__pyx_v_self->length < __pyx_v_self->size);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":95
 *     cdef inline int _increase_size(self) except -1:
 *         if self.length < self.size:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         return self._actually_increase_size()
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":97
 *             return 0
 * 
 *         return self._actually_increase_size()             # <<<<<<<<<<<<<<
 * 
 *     cpdef int clear(self) except -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_actually_increase_size(__pyx_v_self); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection._increase_size");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":99
 *         return self._actually_increase_size()
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         self._clear()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  int __pyx_f_6cpyamf_5codec_17IndexedCollection_clear(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5;
  __Pyx_RefNannySetupContext("clear");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clear); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_17IndexedCollection_3clear)) {
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":100
 * 
 *     cpdef int clear(self) except -1:
 *         self._clear()             # <<<<<<<<<<<<<<
 * 
 *         self.length = 0
 */
  ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_clear(__pyx_v_self);

  /* "cpyamf/codec.pyx":102
 *         self._clear()
 * 
 *         self.length = 0             # <<<<<<<<<<<<<<
 *         self.size = 64
 * 
 */
  __pyx_v_self->length = 0;

  /* "cpyamf/codec.pyx":103
 * 
 *         self.length = 0
 *         self.size = 64             # <<<<<<<<<<<<<<
 * 
 *         self.data = <PyObject **>PyMem_Malloc(sizeof(PyObject *) * self.size)
 */
  __pyx_v_self->size = 64;

  /* "cpyamf/codec.pyx":105
 *         self.size = 64
 * 
 *         self.data = <PyObject **>PyMem_Malloc(sizeof(PyObject *) * self.size)             # <<<<<<<<<<<<<<
 * 
 *         if self.data == NULL:
 */
  __pyx_v_self->data = ((PyObject **)PyMem_Malloc(((sizeof(PyObject *)) * __pyx_v_self->size)));

  /* "cpyamf/codec.pyx":107
 *         self.data = <PyObject **>PyMem_Malloc(sizeof(PyObject *) * self.size)
 * 
 *         if self.data == NULL:             # <<<<<<<<<<<<<<
 *             PyErr_NoMemory()
 * 
 */
  __pyx_t_4 = (__pyx_v_self->data == NULL);
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":108
 * 
 *         if self.data == NULL:
 *             PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         self.refs = {}
 */
    __pyx_t_5 = PyErr_NoMemory(); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":110
 *             PyErr_NoMemory()
 * 
 *         self.refs = {}             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->refs);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->refs));
  __pyx_v_self->refs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":112
 *         self.refs = {}
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getByReference(self, Py_ssize_t ref):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.clear");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":99
 *         return self._actually_increase_size()
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         self._clear()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("clear");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->clear(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":114
 *         return 0
 * 
 *     cpdef object getByReference(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         if ref < 0 or ref >= self.length:
 *             return None
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_4getByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_17IndexedCollection_getByReference(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self, Py_ssize_t __pyx_v_ref, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7;
  __Pyx_RefNannySetupContext("getByReference");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getByReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_17IndexedCollection_4getByReference)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":115
 * 
 *     cpdef object getByReference(self, Py_ssize_t ref):
 *         if ref < 0 or ref >= self.length:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_4 = (__pyx_v_ref < 0);
  if (!__pyx_t_4) {
    __pyx_t_5 = (__pyx_v_ref >= __pyx_v_self->length);
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_4;
  }
  if (__pyx_t_6) {

    /* "cpyamf/codec.pyx":116
 *     cpdef object getByReference(self, Py_ssize_t ref):
 *         if ref < 0 or ref >= self.length:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         return <object>self.data[ref]
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":118
 *             return None
 * 
 *         return <object>self.data[ref]             # <<<<<<<<<<<<<<
 * 
 *     cdef inline object _ref(self, object obj):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = (__pyx_v_self->data[__pyx_v_ref]);
  __Pyx_INCREF(((PyObject *)__pyx_t_7));
  __pyx_r = ((PyObject *)__pyx_t_7);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.getByReference");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":114
 *         return 0
 * 
 *     cpdef object getByReference(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         if ref < 0 or ref >= self.length:
 *             return None
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_4getByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_4getByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref) {
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getByReference");
  assert(__pyx_arg_ref); {
    __pyx_v_ref = __Pyx_PyIndex_AsSsize_t(__pyx_arg_ref); if (unlikely((__pyx_v_ref == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.getByReference");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->getByReference(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), __pyx_v_ref, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.getByReference");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":120
 *         return <object>self.data[ref]
 * 
 *     cdef inline object _ref(self, object obj):             # <<<<<<<<<<<<<<
 *         if self.use_hash:
 *             return hash(obj)
 */

static CYTHON_INLINE PyObject *__pyx_f_6cpyamf_5codec_17IndexedCollection__ref(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_ref");

  /* "cpyamf/codec.pyx":121
 * 
 *     cdef inline object _ref(self, object obj):
 *         if self.use_hash:             # <<<<<<<<<<<<<<
 *             return hash(obj)
 * 
 */
  if (__pyx_v_self->use_hash) {

    /* "cpyamf/codec.pyx":122
 *     cdef inline object _ref(self, object obj):
 *         if self.use_hash:
 *             return hash(obj)             # <<<<<<<<<<<<<<
 * 
 *         return PyLong_FromVoidPtr(<void *>obj)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyObject_Hash(__pyx_v_obj); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":124
 *             return hash(obj)
 * 
 *         return PyLong_FromVoidPtr(<void *>obj)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Py_ssize_t getReferenceTo(self, object obj) except -2:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyLong_FromVoidPtr(((void *)__pyx_v_obj)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection._ref");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":126
 *         return PyLong_FromVoidPtr(<void *>obj)
 * 
 *     cpdef Py_ssize_t getReferenceTo(self, object obj) except -2:             # <<<<<<<<<<<<<<
 *         cdef object p = self.refs.get(self._ref(obj), None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_5getReferenceTo(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static  Py_ssize_t __pyx_f_6cpyamf_5codec_17IndexedCollection_getReferenceTo(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_p = 0;
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("getReferenceTo");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getReferenceTo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_17IndexedCollection_5getReferenceTo)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":127
 * 
 *     cpdef Py_ssize_t getReferenceTo(self, object obj) except -2:
 *         cdef object p = self.refs.get(self._ref(obj), None)             # <<<<<<<<<<<<<<
 * 
 *         if p is None:
 */
  if (unlikely(__pyx_v_self->refs == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_ref(__pyx_v_self, __pyx_v_obj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->refs), __pyx_t_1, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_p = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/codec.pyx":129
 *         cdef object p = self.refs.get(self._ref(obj), None)
 * 
 *         if p is None:             # <<<<<<<<<<<<<<
 *             return -1
 * 
 */
  __pyx_t_5 = (__pyx_v_p == Py_None);
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":130
 * 
 *         if p is None:
 *             return -1             # <<<<<<<<<<<<<<
 * 
 *         return <Py_ssize_t>PyInt_AS_LONG(<object>p)
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":132
 *             return -1
 * 
 *         return <Py_ssize_t>PyInt_AS_LONG(<object>p)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Py_ssize_t append(self, object obj) except -1:
 */
  __pyx_r = ((Py_ssize_t)PyInt_AS_LONG(__pyx_v_p));
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.getReferenceTo");
  __pyx_r = -2;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":126
 *         return PyLong_FromVoidPtr(<void *>obj)
 * 
 *     cpdef Py_ssize_t getReferenceTo(self, object obj) except -2:             # <<<<<<<<<<<<<<
 *         cdef object p = self.refs.get(self._ref(obj), None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_5getReferenceTo(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_5getReferenceTo(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("getReferenceTo");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->getReferenceTo(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), __pyx_v_obj, 1); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.getReferenceTo");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":134
 *         return <Py_ssize_t>PyInt_AS_LONG(<object>p)
 * 
 *     cpdef Py_ssize_t append(self, object obj) except -1:             # <<<<<<<<<<<<<<
 *         self._increase_size()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_6append(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static  Py_ssize_t __pyx_f_6cpyamf_5codec_17IndexedCollection_append(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_h = 0;
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("append");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_17IndexedCollection_6append)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":135
 * 
 *     cpdef Py_ssize_t append(self, object obj) except -1:
 *         self._increase_size()             # <<<<<<<<<<<<<<
 * 
 *         cdef object h = self._ref(obj)
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_increase_size(__pyx_v_self); if (unlikely(__pyx_t_5 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":137
 *         self._increase_size()
 * 
 *         cdef object h = self._ref(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.refs[h] = <object>self.length
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->__pyx_vtab)->_ref(__pyx_v_self, __pyx_v_obj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_h = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":139
 *         cdef object h = self._ref(obj)
 * 
 *         self.refs[h] = <object>self.length             # <<<<<<<<<<<<<<
 *         self.data[self.length] = <PyObject *>obj
 *         Py_INCREF(obj)
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->refs), __pyx_v_h, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":140
 * 
 *         self.refs[h] = <object>self.length
 *         self.data[self.length] = <PyObject *>obj             # <<<<<<<<<<<<<<
 *         Py_INCREF(obj)
 * 
 */
  (__pyx_v_self->data[__pyx_v_self->length]) = ((PyObject *)__pyx_v_obj);

  /* "cpyamf/codec.pyx":141
 *         self.refs[h] = <object>self.length
 *         self.data[self.length] = <PyObject *>obj
 *         Py_INCREF(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.length += 1
 */
  Py_INCREF(__pyx_v_obj);

  /* "cpyamf/codec.pyx":143
 *         Py_INCREF(obj)
 * 
 *         self.length += 1             # <<<<<<<<<<<<<<
 * 
 *         return self.length - 1
 */
  __pyx_v_self->length = (__pyx_v_self->length + 1);

  /* "cpyamf/codec.pyx":145
 *         self.length += 1
 * 
 *         return self.length - 1             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_r = (__pyx_v_self->length - 1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.append");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_h);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":134
 *         return <Py_ssize_t>PyInt_AS_LONG(<object>p)
 * 
 *     cpdef Py_ssize_t append(self, object obj) except -1:             # <<<<<<<<<<<<<<
 *         self._increase_size()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_6append(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_6append(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("append");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->append(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), __pyx_v_obj, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.append");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":147
 *         return self.length - 1
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef list x = []
 *         cdef Py_ssize_t idx
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_x = 0;
  Py_ssize_t __pyx_v_idx;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__iter__");

  /* "cpyamf/codec.pyx":148
 * 
 *     def __iter__(self):
 *         cdef list x = []             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t idx
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_x = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":151
 *         cdef Py_ssize_t idx
 * 
 *         for idx from 0 <= idx < self.length:             # <<<<<<<<<<<<<<
 *             x.append(<object>self.data[idx])
 * 
 */
  __pyx_t_2 = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->length;
  for (__pyx_v_idx = 0; __pyx_v_idx < __pyx_t_2; __pyx_v_idx++) {

    /* "cpyamf/codec.pyx":152
 * 
 *         for idx from 0 <= idx < self.length:
 *             x.append(<object>self.data[idx])             # <<<<<<<<<<<<<<
 * 
 *         return iter(x)
 */
    if (unlikely(__pyx_v_x == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_3 = (((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->data[__pyx_v_idx]);
    __pyx_t_4 = PyList_Append(__pyx_v_x, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/codec.pyx":154
 *             x.append(<object>self.data[idx])
 * 
 *         return iter(x)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":156
 *         return iter(x)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self.length
 * 
 */

static Py_ssize_t __pyx_pf_6cpyamf_5codec_17IndexedCollection_8__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_6cpyamf_5codec_17IndexedCollection_8__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannySetupContext("__len__");

  /* "cpyamf/codec.pyx":157
 * 
 *     def __len__(self):
 *         return self.length             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self, object other, int op):
 */
  __pyx_r = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->length;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":159
 *         return self.length
 * 
 *     def __richcmp__(self, object other, int op):             # <<<<<<<<<<<<<<
 *         cdef int equal
 *         cdef Py_ssize_t i
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
  int __pyx_v_equal;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_s = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  __Pyx_RefNannySetupContext("__richcmp__");

  /* "cpyamf/codec.pyx":162
 *         cdef int equal
 *         cdef Py_ssize_t i
 *         cdef IndexedCollection s = self # this is necessary because cython does not see the c-space vars of the class for this func             # <<<<<<<<<<<<<<
 * 
 *         if PyDict_Check(other) == 1:
 */
  if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_6cpyamf_5codec_IndexedCollection))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_self);
  __pyx_v_s = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self);

  /* "cpyamf/codec.pyx":164
 *         cdef IndexedCollection s = self # this is necessary because cython does not see the c-space vars of the class for this func
 * 
 *         if PyDict_Check(other) == 1:             # <<<<<<<<<<<<<<
 *             equal = s.refs == other
 *         elif PyList_Check(other) != 1:
 */
  __pyx_t_1 = (PyDict_Check(__pyx_v_other) == 1);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":165
 * 
 *         if PyDict_Check(other) == 1:
 *             equal = s.refs == other             # <<<<<<<<<<<<<<
 *         elif PyList_Check(other) != 1:
 *             equal = 0
 */
    __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_s->refs), __pyx_v_other, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_equal = __pyx_t_3;
    goto __pyx_L5;
  }

  /* "cpyamf/codec.pyx":166
 *         if PyDict_Check(other) == 1:
 *             equal = s.refs == other
 *         elif PyList_Check(other) != 1:             # <<<<<<<<<<<<<<
 *             equal = 0
 *         else:
 */
  __pyx_t_1 = (PyList_Check(__pyx_v_other) != 1);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":167
 *             equal = s.refs == other
 *         elif PyList_Check(other) != 1:
 *             equal = 0             # <<<<<<<<<<<<<<
 *         else:
 *             equal = 0
 */
    __pyx_v_equal = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "cpyamf/codec.pyx":169
 *             equal = 0
 *         else:
 *             equal = 0             # <<<<<<<<<<<<<<
 * 
 *             if PyList_GET_SIZE(other) == s.length:
 */
    __pyx_v_equal = 0;

    /* "cpyamf/codec.pyx":171
 *             equal = 0
 * 
 *             if PyList_GET_SIZE(other) == s.length:             # <<<<<<<<<<<<<<
 *                 equal = 1
 * 
 */
    __pyx_t_1 = (PyList_GET_SIZE(__pyx_v_other) == __pyx_v_s->length);
    if (__pyx_t_1) {

      /* "cpyamf/codec.pyx":172
 * 
 *             if PyList_GET_SIZE(other) == s.length:
 *                 equal = 1             # <<<<<<<<<<<<<<
 * 
 *                 for i from 0 <= i < s.length:
 */
      __pyx_v_equal = 1;

      /* "cpyamf/codec.pyx":174
 *                 equal = 1
 * 
 *                 for i from 0 <= i < s.length:             # <<<<<<<<<<<<<<
 *                     if <object>PyList_GET_ITEM(other, i) != <object>s.data[i]:
 *                         equal = 0
 */
      __pyx_t_4 = __pyx_v_s->length;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

        /* "cpyamf/codec.pyx":175
 * 
 *                 for i from 0 <= i < s.length:
 *                     if <object>PyList_GET_ITEM(other, i) != <object>s.data[i]:             # <<<<<<<<<<<<<<
 *                         equal = 0
 * 
 */
        __pyx_t_5 = PyList_GET_ITEM(__pyx_v_other, __pyx_v_i);
        __pyx_t_6 = (__pyx_v_s->data[__pyx_v_i]);
        __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6), Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_1) {

          /* "cpyamf/codec.pyx":176
 *                 for i from 0 <= i < s.length:
 *                     if <object>PyList_GET_ITEM(other, i) != <object>s.data[i]:
 *                         equal = 0             # <<<<<<<<<<<<<<
 * 
 *                         break
 */
          __pyx_v_equal = 0;

          /* "cpyamf/codec.pyx":178
 *                         equal = 0
 * 
 *                         break             # <<<<<<<<<<<<<<
 * 
 *         if op == 2: # ==
 */
          goto __pyx_L8_break;
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
      __pyx_L8_break:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L5:;

  /* "cpyamf/codec.pyx":182
 *         if op == 2: # ==
 *             return equal
 *         elif op == 3: # !=             # <<<<<<<<<<<<<<
 *             return not equal
 *         else:
 */
  switch (__pyx_v_op) {

    /* "cpyamf/codec.pyx":180
 *                         break
 * 
 *         if op == 2: # ==             # <<<<<<<<<<<<<<
 *             return equal
 *         elif op == 3: # !=
 */
    case 2:

    /* "cpyamf/codec.pyx":181
 * 
 *         if op == 2: # ==
 *             return equal             # <<<<<<<<<<<<<<
 *         elif op == 3: # !=
 *             return not equal
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_equal); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;

    /* "cpyamf/codec.pyx":182
 *         if op == 2: # ==
 *             return equal
 *         elif op == 3: # !=             # <<<<<<<<<<<<<<
 *             return not equal
 *         else:
 */
    case 3:

    /* "cpyamf/codec.pyx":183
 *             return equal
 *         elif op == 3: # !=
 *             return not equal             # <<<<<<<<<<<<<<
 *         else:
 *             raise NotImplementedError
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong((!__pyx_v_equal)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;
    default:

    /* "cpyamf/codec.pyx":185
 *             return not equal
 *         else:
 *             raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, idx):
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__richcmp__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":187
 *             raise NotImplementedError
 * 
 *     def __getitem__(self, idx):             # <<<<<<<<<<<<<<
 *         return self.getByReference(idx)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_10__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_idx); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_10__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__getitem__");

  /* "cpyamf/codec.pyx":188
 * 
 *     def __getitem__(self, idx):
 *         return self.getByReference(idx)             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->__pyx_vtab)->getByReference(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self), __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":190
 *         return self.getByReference(idx)
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         cdef IndexedCollection n = IndexedCollection(self.use_hash)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *__pyx_v_n = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__copy__");

  /* "cpyamf/codec.pyx":191
 * 
 *     def __copy__(self):
 *         cdef IndexedCollection n = IndexedCollection(self.use_hash)             # <<<<<<<<<<<<<<
 * 
 *         return n
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->use_hash); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_IndexedCollection)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_n = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":193
 *         cdef IndexedCollection n = IndexedCollection(self.use_hash)
 * 
 *         return n             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_n));
  __pyx_r = ((PyObject *)__pyx_v_n);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.__copy__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_n);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pxd":16
 *     """
 * 
 *     cdef public bint use_hash             # <<<<<<<<<<<<<<
 *     cdef PyObject **data
 *     cdef dict refs
 */

static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->use_hash); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.use_hash.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__");
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_v_self)->use_hash = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.IndexedCollection.use_hash.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":206
 *     """
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.objects = IndexedCollection()
 * 
 */

static int __pyx_pf_6cpyamf_5codec_7Context___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_7Context___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "cpyamf/codec.pyx":207
 * 
 *     def __cinit__(self):
 *         self.objects = IndexedCollection()             # <<<<<<<<<<<<<<
 * 
 *         self.clear()
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_IndexedCollection)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->objects);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->objects));
  ((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->objects = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":209
 *         self.objects = IndexedCollection()
 * 
 *         self.clear()             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->clear(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), 0); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Context.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":211
 *         self.clear()
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.clear()
 * 
 */

static int __pyx_pf_6cpyamf_5codec_7Context_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_7Context_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "cpyamf/codec.pyx":212
 * 
 *     def __init__(self):
 *         self.clear()             # <<<<<<<<<<<<<<
 * 
 *     cpdef int clear(self) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->clear(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), 0); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Context.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":214
 *         self.clear()
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         self.objects.clear()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_2clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Context_clear(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("clear");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clear); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_2clear)) {
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":215
 * 
 *     cpdef int clear(self) except -1:
 *         self.objects.clear()             # <<<<<<<<<<<<<<
 * 
 *         self.class_aliases = {}
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->objects->__pyx_vtab)->clear(__pyx_v_self->objects, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":217
 *         self.objects.clear()
 * 
 *         self.class_aliases = {}             # <<<<<<<<<<<<<<
 *         self.unicodes = {}
 *         self._strings = {}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->class_aliases);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->class_aliases));
  __pyx_v_self->class_aliases = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":218
 * 
 *         self.class_aliases = {}
 *         self.unicodes = {}             # <<<<<<<<<<<<<<
 *         self._strings = {}
 *         self.extra = {}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->unicodes);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->unicodes));
  __pyx_v_self->unicodes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":219
 *         self.class_aliases = {}
 *         self.unicodes = {}
 *         self._strings = {}             # <<<<<<<<<<<<<<
 *         self.extra = {}
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->_strings);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_strings));
  __pyx_v_self->_strings = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":220
 *         self.unicodes = {}
 *         self._strings = {}
 *         self.extra = {}             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->extra);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->extra));
  __pyx_v_self->extra = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":222
 *         self.extra = {}
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline object getObject(self, Py_ssize_t ref):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Context.clear");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":214
 *         self.clear()
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         self.objects.clear()
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_2clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_2clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("clear");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->clear(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), 1); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Context.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":224
 *         return 0
 * 
 *     cpdef inline object getObject(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.objects.getByReference(ref)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_3getObject(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_6cpyamf_5codec_7Context_getObject(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, Py_ssize_t __pyx_v_ref, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("getObject");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_3getObject)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":225
 * 
 *     cpdef inline object getObject(self, Py_ssize_t ref):
 *         return self.objects.getByReference(ref)             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline Py_ssize_t getObjectReference(self, object obj) except -2:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->objects->__pyx_vtab)->getByReference(__pyx_v_self->objects, __pyx_v_ref, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Context.getObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":224
 *         return 0
 * 
 *     cpdef inline object getObject(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.objects.getByReference(ref)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_3getObject(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_3getObject(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref) {
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getObject");
  assert(__pyx_arg_ref); {
    __pyx_v_ref = __Pyx_PyIndex_AsSsize_t(__pyx_arg_ref); if (unlikely((__pyx_v_ref == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.Context.getObject");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_ref, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Context.getObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":227
 *         return self.objects.getByReference(ref)
 * 
 *     cpdef inline Py_ssize_t getObjectReference(self, object obj) except -2:             # <<<<<<<<<<<<<<
 *         return self.objects.getReferenceTo(obj)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_4getObjectReference(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static CYTHON_INLINE Py_ssize_t __pyx_f_6cpyamf_5codec_7Context_getObjectReference(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("getObjectReference");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getObjectReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_4getObjectReference)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":228
 * 
 *     cpdef inline Py_ssize_t getObjectReference(self, object obj) except -2:
 *         return self.objects.getReferenceTo(obj)             # <<<<<<<<<<<<<<
 * 
 *     cpdef inline Py_ssize_t addObject(self, object obj) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->objects->__pyx_vtab)->getReferenceTo(__pyx_v_self->objects, __pyx_v_obj, 0); if (unlikely(__pyx_t_4 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Context.getObjectReference");
  __pyx_r = -2;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":227
 *         return self.objects.getByReference(ref)
 * 
 *     cpdef inline Py_ssize_t getObjectReference(self, object obj) except -2:             # <<<<<<<<<<<<<<
 *         return self.objects.getReferenceTo(obj)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_4getObjectReference(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_4getObjectReference(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("getObjectReference");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_obj, 1); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Context.getObjectReference");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":230
 *         return self.objects.getReferenceTo(obj)
 * 
 *     cpdef inline Py_ssize_t addObject(self, object obj) except -1:             # <<<<<<<<<<<<<<
 *         return self.objects.append(obj)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_5addObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static CYTHON_INLINE Py_ssize_t __pyx_f_6cpyamf_5codec_7Context_addObject(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("addObject");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__addObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_5addObject)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":231
 * 
 *     cpdef inline Py_ssize_t addObject(self, object obj) except -1:
 *         return self.objects.append(obj)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getClassAlias(self, object klass):
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->objects->__pyx_vtab)->append(__pyx_v_self->objects, __pyx_v_obj, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Context.addObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":230
 *         return self.objects.getReferenceTo(obj)
 * 
 *     cpdef inline Py_ssize_t addObject(self, object obj) except -1:             # <<<<<<<<<<<<<<
 *         return self.objects.append(obj)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_5addObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_5addObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("addObject");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_obj, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Context.addObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":233
 *         return self.objects.append(obj)
 * 
 *     cpdef object getClassAlias(self, object klass):             # <<<<<<<<<<<<<<
 *         """
 *         Gets a class alias based on the supplied C{klass}.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_6getClassAlias(PyObject *__pyx_v_self, PyObject *__pyx_v_klass); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_7Context_getClassAlias(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, PyObject *__pyx_v_klass, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_alias;
  PyObject *__pyx_v_meta;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("getClassAlias");
  __pyx_v_alias = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_meta = Py_None; __Pyx_INCREF(Py_None);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getClassAlias); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_6getClassAlias)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":240
 *         @return: The L{ClassAlias} that is linked to C{klass}
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self.class_aliases[klass]
 *         except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":241
 *         """
 *         try:
 *             return self.class_aliases[klass]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             pass
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->class_aliases), __pyx_v_klass); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/codec.pyx":242
 *         try:
 *             return self.class_aliases[klass]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             pass
 * 
 */
    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_4) {
      PyErr_Restore(0,0,0);
      goto __pyx_L4_exception_handled;
    }
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  /* "cpyamf/codec.pyx":245
 *             pass
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             alias = pyamf.get_class_alias(klass)
 *         except pyamf.UnknownClassAlias:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":246
 * 
 *         try:
 *             alias = pyamf.get_class_alias(klass)             # <<<<<<<<<<<<<<
 *         except pyamf.UnknownClassAlias:
 *             if isinstance(klass, basestring):
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__get_class_alias); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L18_try_end;
    __pyx_L11_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpyamf/codec.pyx":247
 *         try:
 *             alias = pyamf.get_class_alias(klass)
 *         except pyamf.UnknownClassAlias:             # <<<<<<<<<<<<<<
 *             if isinstance(klass, basestring):
 *                 raise
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__UnknownClassAlias); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
      __Pyx_AddTraceback("cpyamf.codec.Context.getClassAlias");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "cpyamf/codec.pyx":248
 *             alias = pyamf.get_class_alias(klass)
 *         except pyamf.UnknownClassAlias:
 *             if isinstance(klass, basestring):             # <<<<<<<<<<<<<<
 *                 raise
 * 
 */
      __pyx_t_5 = PyObject_IsInstance(__pyx_v_klass, __pyx_builtin_basestring); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      if (__pyx_t_5) {

        /* "cpyamf/codec.pyx":249
 *         except pyamf.UnknownClassAlias:
 *             if isinstance(klass, basestring):
 *                 raise             # <<<<<<<<<<<<<<
 * 
 *             # no alias has been found yet .. check subclasses
 */
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_3);
        __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
        __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; 
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        goto __pyx_L21;
      }
      __pyx_L21:;

      /* "cpyamf/codec.pyx":252
 * 
 *             # no alias has been found yet .. check subclasses
 *             alias = util.get_class_alias(klass) or pyamf.ClassAlias             # <<<<<<<<<<<<<<
 *             meta = util.get_class_meta(klass)
 *             alias = alias(klass, defer=True, **meta)
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__get_class_alias); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      if (!__pyx_t_5) {
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__ClassAlias); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
      } else {
        __pyx_t_6 = __pyx_t_8;
        __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "cpyamf/codec.pyx":253
 *             # no alias has been found yet .. check subclasses
 *             alias = util.get_class_alias(klass) or pyamf.ClassAlias
 *             meta = util.get_class_meta(klass)             # <<<<<<<<<<<<<<
 *             alias = alias(klass, defer=True, **meta)
 * 
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__get_class_meta); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_meta);
      __pyx_v_meta = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "cpyamf/codec.pyx":254
 *             alias = util.get_class_alias(klass) or pyamf.ClassAlias
 *             meta = util.get_class_meta(klass)
 *             alias = alias(klass, defer=True, **meta)             # <<<<<<<<<<<<<<
 * 
 *             self.class_aliases[klass] = alias
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__defer), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PyDict_Update(((PyObject *)__pyx_t_6), __pyx_v_meta) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_v_alias, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "cpyamf/codec.pyx":256
 *             alias = alias(klass, defer=True, **meta)
 * 
 *             self.class_aliases[klass] = alias             # <<<<<<<<<<<<<<
 * 
 *         return alias
 */
      if (PyDict_SetItem(((PyObject *)__pyx_v_self->class_aliases), __pyx_v_klass, __pyx_v_alias) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L12_exception_handled;
    }
    __pyx_L13_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L12_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L18_try_end:;
  }

  /* "cpyamf/codec.pyx":258
 *             self.class_aliases[klass] = alias
 * 
 *         return alias             # <<<<<<<<<<<<<<
 * 
 *     cpdef unicode getStringForBytes(self, object s):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_alias);
  __pyx_r = __pyx_v_alias;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpyamf.codec.Context.getClassAlias");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_alias);
  __Pyx_DECREF(__pyx_v_meta);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":233
 *         return self.objects.append(obj)
 * 
 *     cpdef object getClassAlias(self, object klass):             # <<<<<<<<<<<<<<
 *         """
 *         Gets a class alias based on the supplied C{klass}.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_6getClassAlias(PyObject *__pyx_v_self, PyObject *__pyx_v_klass); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Context_6getClassAlias[] = "\n        Gets a class alias based on the supplied C{klass}.\n\n        @param klass: The class object.\n        @return: The L{ClassAlias} that is linked to C{klass}\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_6getClassAlias(PyObject *__pyx_v_self, PyObject *__pyx_v_klass) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getClassAlias");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_klass, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Context.getClassAlias");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":260
 *         return alias
 * 
 *     cpdef unicode getStringForBytes(self, object s):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the corresponding unicode object for a given string. If there
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_7getStringForBytes(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_7Context_getStringForBytes(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, PyObject *__pyx_v_s, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = 0;
  PyObject *__pyx_v_u = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("getStringForBytes");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getStringForBytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_7getStringForBytes)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":267
 *         @since: 0.6
 *         """
 *         cdef object ret = self.unicodes.get(s, None)             # <<<<<<<<<<<<<<
 * 
 *         if ret is not None:
 */
  if (unlikely(__pyx_v_self->unicodes == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->unicodes), __pyx_v_s, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":269
 *         cdef object ret = self.unicodes.get(s, None)
 * 
 *         if ret is not None:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_4 = (__pyx_v_ret != Py_None);
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":270
 * 
 *         if ret is not None:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         cdef unicode u = s.decode('utf-8')
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(PyUnicode_CheckExact(__pyx_v_ret))||((__pyx_v_ret) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_v_ret)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = ((PyObject*)__pyx_v_ret);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":272
 *             return ret
 * 
 *         cdef unicode u = s.decode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self.unicodes[s] = u
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_s, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_u = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpyamf/codec.pyx":274
 *         cdef unicode u = s.decode('utf-8')
 * 
 *         self.unicodes[s] = u             # <<<<<<<<<<<<<<
 *         self._strings[u] = s
 * 
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->unicodes), __pyx_v_s, ((PyObject *)__pyx_v_u)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":275
 * 
 *         self.unicodes[s] = u
 *         self._strings[u] = s             # <<<<<<<<<<<<<<
 * 
 *         return u
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->_strings), ((PyObject *)__pyx_v_u), __pyx_v_s) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":277
 *         self._strings[u] = s
 * 
 *         return u             # <<<<<<<<<<<<<<
 * 
 *     cpdef str getBytesForString(self, object u):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_u));
  __pyx_r = __pyx_v_u;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Context.getStringForBytes");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_u);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":260
 *         return alias
 * 
 *     cpdef unicode getStringForBytes(self, object s):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the corresponding unicode object for a given string. If there
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_7getStringForBytes(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Context_7getStringForBytes[] = "\n        Returns the corresponding unicode object for a given string. If there\n        is no unicode object, one is created.\n\n        @since: 0.6\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_7getStringForBytes(PyObject *__pyx_v_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getStringForBytes");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->getStringForBytes(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_s, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Context.getStringForBytes");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":279
 *         return u
 * 
 *     cpdef str getBytesForString(self, object u):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the corresponding utf-8 encoded string for a given unicode
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_8getBytesForString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_7Context_getBytesForString(struct __pyx_obj_6cpyamf_5codec_Context *__pyx_v_self, PyObject *__pyx_v_u, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret = 0;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("getBytesForString");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getBytesForString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Context_8getBytesForString)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_u);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_u);
      __Pyx_GIVEREF(__pyx_v_u);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":286
 *         @since: 0.6
 *         """
 *         cdef object ret = self._strings.get(u, None)             # <<<<<<<<<<<<<<
 * 
 *         if ret is not None:
 */
  if (unlikely(__pyx_v_self->_strings == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->_strings), __pyx_v_u, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":288
 *         cdef object ret = self._strings.get(u, None)
 * 
 *         if ret is not None:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  __pyx_t_4 = (__pyx_v_ret != Py_None);
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":289
 * 
 *         if ret is not None:
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         cdef str s = u.encode('utf-8')
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(PyString_CheckExact(__pyx_v_ret))||((__pyx_v_ret) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_ret)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_ret);
    __pyx_r = ((PyObject*)__pyx_v_ret);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":291
 *             return ret
 * 
 *         cdef str s = u.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self.unicodes[s] = u
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_u, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_s = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpyamf/codec.pyx":293
 *         cdef str s = u.encode('utf-8')
 * 
 *         self.unicodes[s] = u             # <<<<<<<<<<<<<<
 *         self._strings[u] = s
 * 
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->unicodes), ((PyObject *)__pyx_v_s), __pyx_v_u) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":294
 * 
 *         self.unicodes[s] = u
 *         self._strings[u] = s             # <<<<<<<<<<<<<<
 * 
 *         return s
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->_strings), __pyx_v_u, ((PyObject *)__pyx_v_s)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":296
 *         self._strings[u] = s
 * 
 *         return s             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_s));
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Context.getBytesForString");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":279
 *         return u
 * 
 *     cpdef str getBytesForString(self, object u):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the corresponding utf-8 encoded string for a given unicode
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_8getBytesForString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Context_8getBytesForString[] = "\n        Returns the corresponding utf-8 encoded string for a given unicode\n        object. If there is no string, one is encoded.\n\n        @since: 0.6\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_8getBytesForString(PyObject *__pyx_v_self, PyObject *__pyx_v_u) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getBytesForString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_5codec_Context *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->__pyx_vtab)->getBytesForString(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), __pyx_v_u, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Context.getBytesForString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pxd":41
 *     cdef dict unicodes
 *     cdef dict _strings
 *     cdef public dict extra             # <<<<<<<<<<<<<<
 * 
 *     cpdef int clear(self) except? -1
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Context_5extra___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Context_5extra___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_7Context_5extra_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_5codec_7Context_5extra_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__set__");
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra));
  ((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra = ((PyObject*)__pyx_v_value);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Context.extra.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_7Context_5extra_2__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6cpyamf_5codec_7Context_5extra_2__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__del__");
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra));
  ((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self)->extra = ((PyObject*)Py_None);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":306
 * 
 *     property stream:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return <BufferedByteStream>self.stream
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_6stream___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_6stream___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "cpyamf/codec.pyx":307
 *     property stream:
 *         def __get__(self):
 *             return <BufferedByteStream>self.stream             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4util_BufferedByteStream *)((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream)));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":309
 *             return <BufferedByteStream>self.stream
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             if not isinstance(value, BufferedByteStream):
 *                 value = BufferedByteStream(value)
 */

static int __pyx_pf_6cpyamf_5codec_5Codec_6stream_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec_6stream_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__set__");
  __Pyx_INCREF(__pyx_v_value);

  /* "cpyamf/codec.pyx":310
 * 
 *         def __set__(self, value):
 *             if not isinstance(value, BufferedByteStream):             # <<<<<<<<<<<<<<
 *                 value = BufferedByteStream(value)
 * 
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_value, ((PyObject*)__pyx_ptype_6cpyamf_4util_BufferedByteStream)); 
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "cpyamf/codec.pyx":311
 *         def __set__(self, value):
 *             if not isinstance(value, BufferedByteStream):
 *                 value = BufferedByteStream(value)             # <<<<<<<<<<<<<<
 * 
 *             self.stream = <cBufferedByteStream>value
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4util_BufferedByteStream)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/codec.pyx":313
 *                 value = BufferedByteStream(value)
 * 
 *             self.stream = <cBufferedByteStream>value             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_v_value)));
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream));
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream = ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_v_value);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.codec.Codec.stream.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":315
 *             self.stream = <cBufferedByteStream>value
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.stream = None
 *         self.strict = 0
 */

static int __pyx_pf_6cpyamf_5codec_5Codec___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "cpyamf/codec.pyx":316
 * 
 *     def __cinit__(self):
 *         self.stream = None             # <<<<<<<<<<<<<<
 *         self.strict = 0
 *         self.timezone_offset = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream));
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream = ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)Py_None);

  /* "cpyamf/codec.pyx":317
 *     def __cinit__(self):
 *         self.stream = None
 *         self.strict = 0             # <<<<<<<<<<<<<<
 *         self.timezone_offset = None
 * 
 */
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->strict = 0;

  /* "cpyamf/codec.pyx":318
 *         self.stream = None
 *         self.strict = 0
 *         self.timezone_offset = None             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, stream=None, strict=False, timezone_offset=None):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset = Py_None;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":320
 *         self.timezone_offset = None
 * 
 *     def __init__(self, stream=None, strict=False, timezone_offset=None):             # <<<<<<<<<<<<<<
 *         if not isinstance(stream, BufferedByteStream):
 *             stream = BufferedByteStream(stream)
 */

static int __pyx_pf_6cpyamf_5codec_5Codec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stream = 0;
  PyObject *__pyx_v_strict = 0;
  PyObject *__pyx_v_timezone_offset = 0;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__stream,&__pyx_n_s__strict,&__pyx_n_s__timezone_offset,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = __pyx_k_6;
    values[2] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream);
        if (value) { values[0] = value; kw_args--; }
      }
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__strict);
        if (value) { values[1] = value; kw_args--; }
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timezone_offset);
        if (value) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_stream = values[0];
    __pyx_v_strict = values[1];
    __pyx_v_timezone_offset = values[2];
  } else {
    __pyx_v_stream = ((PyObject *)Py_None);
    __pyx_v_strict = __pyx_k_6;
    __pyx_v_timezone_offset = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_timezone_offset = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_strict = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_stream = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.Codec.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_stream);

  /* "cpyamf/codec.pyx":321
 * 
 *     def __init__(self, stream=None, strict=False, timezone_offset=None):
 *         if not isinstance(stream, BufferedByteStream):             # <<<<<<<<<<<<<<
 *             stream = BufferedByteStream(stream)
 * 
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_stream, ((PyObject*)__pyx_ptype_6cpyamf_4util_BufferedByteStream)); 
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "cpyamf/codec.pyx":322
 *     def __init__(self, stream=None, strict=False, timezone_offset=None):
 *         if not isinstance(stream, BufferedByteStream):
 *             stream = BufferedByteStream(stream)             # <<<<<<<<<<<<<<
 * 
 *         self.stream = <cBufferedByteStream>stream
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_v_stream);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stream);
    __Pyx_GIVEREF(__pyx_v_stream);
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4util_BufferedByteStream)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_stream);
    __pyx_v_stream = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/codec.pyx":324
 *             stream = BufferedByteStream(stream)
 * 
 *         self.stream = <cBufferedByteStream>stream             # <<<<<<<<<<<<<<
 *         self.strict = strict
 * 
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream)));
  __Pyx_GIVEREF(__pyx_v_stream);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream));
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->stream = ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream);

  /* "cpyamf/codec.pyx":325
 * 
 *         self.stream = <cBufferedByteStream>stream
 *         self.strict = strict             # <<<<<<<<<<<<<<
 * 
 *         self.timezone_offset = timezone_offset
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_strict); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->strict = __pyx_t_2;

  /* "cpyamf/codec.pyx":327
 *         self.strict = strict
 * 
 *         self.timezone_offset = timezone_offset             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(__pyx_v_timezone_offset);
  __Pyx_GIVEREF(__pyx_v_timezone_offset);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset = __pyx_v_timezone_offset;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.codec.Codec.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_stream);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pxd":61
 * 
 *     cdef util.cBufferedByteStream stream
 *     cdef public bint strict             # <<<<<<<<<<<<<<
 *     cdef public object timezone_offset
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_6strict___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_6strict___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->strict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Codec.strict.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_5Codec_6strict_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec_6strict_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__");
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->strict = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Codec.strict.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pxd":62
 *     cdef util.cBufferedByteStream stream
 *     cdef public bint strict
 *     cdef public object timezone_offset             # <<<<<<<<<<<<<<
 * 
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  __pyx_r = ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__set__");
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset = __pyx_v_value;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_2__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_2__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__del__");
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset);
  ((struct __pyx_obj_6cpyamf_5codec_Codec *)__pyx_v_self)->timezone_offset = Py_None;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":335
 *     """
 * 
 *     cdef object readDate(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readDate(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readDate");

  /* "cpyamf/codec.pyx":336
 * 
 *     cdef object readDate(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cpdef object readString(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readDate");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":338
 *         raise NotImplementedError
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readString(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("readString");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__readString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Decoder_readString)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":339
 * 
 *     cpdef object readString(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef object readObject(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readString");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":338
 *         raise NotImplementedError
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("readString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *)((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)->__pyx_vtab)->readString(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":341
 *         raise NotImplementedError
 * 
 *     cdef object readObject(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readObject(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readObject");

  /* "cpyamf/codec.pyx":342
 * 
 *     cdef object readObject(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef object readNumber(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":344
 *         raise NotImplementedError
 * 
 *     cdef object readNumber(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readNumber(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readNumber");

  /* "cpyamf/codec.pyx":345
 * 
 *     cdef object readNumber(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef inline object readNull(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readNumber");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":347
 *         raise NotImplementedError
 * 
 *     cdef inline object readNull(self):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readNull(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readNull");

  /* "cpyamf/codec.pyx":348
 * 
 *     cdef inline object readNull(self):
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     cdef inline object readUndefined(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":350
 *         return None
 * 
 *     cdef inline object readUndefined(self):             # <<<<<<<<<<<<<<
 *         return Undefined
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readUndefined(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readUndefined");

  /* "cpyamf/codec.pyx":351
 * 
 *     cdef inline object readUndefined(self):
 *         return Undefined             # <<<<<<<<<<<<<<
 * 
 *     cdef object readList(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_6cpyamf_5codec_Undefined);
  __pyx_r = __pyx_v_6cpyamf_5codec_Undefined;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":353
 *         return Undefined
 * 
 *     cdef object readList(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readList(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readList");

  /* "cpyamf/codec.pyx":354
 * 
 *     cdef object readList(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef object readXML(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readList");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":356
 *         raise NotImplementedError
 * 
 *     cdef object readXML(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readXML(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readXML");

  /* "cpyamf/codec.pyx":357
 * 
 *     cdef object readXML(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cpdef object readElement(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readXML");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":359
 *         raise NotImplementedError
 * 
 *     cpdef object readElement(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads an element from the data stream.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_1readElement(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readElement(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_pos;
  char __pyx_v_t;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  char __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("readElement");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__readElement); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Decoder_1readElement)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":363
 *         Reads an element from the data stream.
 *         """
 *         cdef Py_ssize_t pos = self.stream.tell()             # <<<<<<<<<<<<<<
 *         cdef char t
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->tell(__pyx_v_self->__pyx_base.stream, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_pos = __pyx_t_3;

  /* "cpyamf/codec.pyx":366
 *         cdef char t
 * 
 *         if self.stream.at_eof():             # <<<<<<<<<<<<<<
 *             raise pyamf.EOStream
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->at_eof(__pyx_v_self->__pyx_base.stream, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":367
 * 
 *         if self.stream.at_eof():
 *             raise pyamf.EOStream             # <<<<<<<<<<<<<<
 * 
 *         t = self.stream.read_char()
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__EOStream); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":369
 *             raise pyamf.EOStream
 * 
 *         t = self.stream.read_char()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->read_char(__pyx_v_self->__pyx_base.stream, 0); if (unlikely(__pyx_t_5 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_t = __pyx_t_5;

  /* "cpyamf/codec.pyx":371
 *         t = self.stream.read_char()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return self.readConcreteElement(t)
 *         except IOError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":372
 * 
 *         try:
 *             return self.readConcreteElement(t)             # <<<<<<<<<<<<<<
 *         except IOError:
 *             self.stream.seek(pos)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *)__pyx_v_self->__pyx_vtab)->readConcreteElement(__pyx_v_self, __pyx_v_t); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L8_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L11_try_end;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpyamf/codec.pyx":373
 *         try:
 *             return self.readConcreteElement(t)
 *         except IOError:             # <<<<<<<<<<<<<<
 *             self.stream.seek(pos)
 * 
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_IOError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("cpyamf.codec.Decoder.readElement");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "cpyamf/codec.pyx":374
 *             return self.readConcreteElement(t)
 *         except IOError:
 *             self.stream.seek(pos)             # <<<<<<<<<<<<<<
 * 
 *             raise
 */
      __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->seek(__pyx_v_self->__pyx_base.stream, __pyx_v_pos, 0, NULL); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}

      /* "cpyamf/codec.pyx":376
 *             self.stream.seek(pos)
 * 
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     cdef object readConcreteElement(self, char t):
 */
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_7);
      __Pyx_ErrRestore(__pyx_t_2, __pyx_t_1, __pyx_t_7);
      __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0; 
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L11_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readElement");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":359
 *         raise NotImplementedError
 * 
 *     cpdef object readElement(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads an element from the data stream.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_1readElement(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Decoder_1readElement[] = "\n        Reads an element from the data stream.\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_1readElement(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("readElement");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *)((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)->__pyx_vtab)->readElement(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readElement");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":378
 *             raise
 * 
 *     cdef object readConcreteElement(self, char t):             # <<<<<<<<<<<<<<
 *         """
 *         The workhorse function. Overridden in subclasses
 */

static  PyObject *__pyx_f_6cpyamf_5codec_7Decoder_readConcreteElement(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self, char __pyx_v_t) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("readConcreteElement");

  /* "cpyamf/codec.pyx":382
 *         The workhorse function. Overridden in subclasses
 *         """
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cpdef int send(self, data) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Decoder.readConcreteElement");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":384
 *         raise NotImplementedError
 * 
 *     cpdef int send(self, data) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Add data for the decoder to work on.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_2send(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Decoder_send(struct __pyx_obj_6cpyamf_5codec_Decoder *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("send");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__send); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Decoder_2send)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":388
 *         Add data for the decoder to work on.
 *         """
 *         return self.stream.append(data)             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->append(__pyx_v_self->__pyx_base.stream, __pyx_v_data, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.send");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":384
 *         raise NotImplementedError
 * 
 *     cpdef int send(self, data) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Add data for the decoder to work on.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_2send(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Decoder_2send[] = "\n        Add data for the decoder to work on.\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_2send(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("send");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *)((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), __pyx_v_data, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.send");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":390
 *         return self.stream.append(data)
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Part of the iterator protocol.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_3__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Decoder_3__next__[] = "\n        Part of the iterator protocol.\n        ";
struct wrapperbase __pyx_wrapperbase_6cpyamf_5codec_7Decoder_3__next__;
static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_3__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__next__");

  /* "cpyamf/codec.pyx":394
 *         Part of the iterator protocol.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self.readElement()
 *         except pyamf.EOStream:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":395
 *         """
 *         try:
 *             return self.readElement()             # <<<<<<<<<<<<<<
 *         except pyamf.EOStream:
 *             # all data was successfully decoded from the stream
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Decoder *)((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)->__pyx_vtab)->readElement(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L9_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L9_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/codec.pyx":396
 *         try:
 *             return self.readElement()
 *         except pyamf.EOStream:             # <<<<<<<<<<<<<<
 *             # all data was successfully decoded from the stream
 *             raise StopIteration
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__EOStream); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {
      __Pyx_AddTraceback("cpyamf.codec.Decoder.__next__");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpyamf/codec.pyx":398
 *         except pyamf.EOStream:
 *             # all data was successfully decoded from the stream
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.codec.Decoder.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":400
 *             raise StopIteration
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_4__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Decoder_4__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "cpyamf/codec.pyx":401
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":409
 *     """
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.func_cache = {}
 *         self.use_write_object = []
 */

static int __pyx_pf_6cpyamf_5codec_7Encoder___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_7Encoder___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "cpyamf/codec.pyx":410
 * 
 *     def __cinit__(self):
 *         self.func_cache = {}             # <<<<<<<<<<<<<<
 *         self.use_write_object = []
 *         self.bucket = []
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->func_cache);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->func_cache));
  ((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->func_cache = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":411
 *     def __cinit__(self):
 *         self.func_cache = {}
 *         self.use_write_object = []             # <<<<<<<<<<<<<<
 *         self.bucket = []
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->use_write_object);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->use_write_object));
  ((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->use_write_object = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":412
 *         self.func_cache = {}
 *         self.use_write_object = []
 *         self.bucket = []             # <<<<<<<<<<<<<<
 * 
 *     cpdef int serialiseString(self, u) except -1:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->bucket);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->bucket));
  ((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->bucket = __pyx_t_1;
  __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":414
 *         self.bucket = []
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Encoder_serialiseString(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_u, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("serialiseString");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__serialiseString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Encoder_1serialiseString)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_u);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_u);
      __Pyx_GIVEREF(__pyx_v_u);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":415
 * 
 *     cpdef int serialiseString(self, u) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int writeType(self, char type) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.serialiseString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":414
 *         self.bucket = []
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("serialiseString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_u, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.serialiseString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":417
 *         raise NotImplementedError
 * 
 *     cdef inline int writeType(self, char type) except -1:             # <<<<<<<<<<<<<<
 *         return self.stream.write(<char *>&type, 1)
 * 
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_5codec_7Encoder_writeType(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, char __pyx_v_type) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeType");

  /* "cpyamf/codec.pyx":418
 * 
 *     cdef inline int writeType(self, char type) except -1:
 *         return self.stream.write(<char *>&type, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeNull(self, object o) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.stream, (&__pyx_v_type), 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeType");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":420
 *         return self.stream.write(<char *>&type, 1)
 * 
 *     cdef int writeNull(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeNull(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeNull");

  /* "cpyamf/codec.pyx":421
 * 
 *     cdef int writeNull(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeUndefined(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeNull");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":423
 *         raise NotImplementedError
 * 
 *     cdef int writeUndefined(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeUndefined(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeUndefined");

  /* "cpyamf/codec.pyx":424
 * 
 *     cdef int writeUndefined(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeString(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeUndefined");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":426
 *         raise NotImplementedError
 * 
 *     cdef int writeString(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeString(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeString");

  /* "cpyamf/codec.pyx":427
 * 
 *     cdef int writeString(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeBytes(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":429
 *         raise NotImplementedError
 * 
 *     cdef int writeBytes(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeBytes(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeBytes");

  /* "cpyamf/codec.pyx":430
 * 
 *     cdef int writeBytes(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeBoolean(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeBytes");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":432
 *         raise NotImplementedError
 * 
 *     cdef int writeBoolean(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeBoolean(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeBoolean");

  /* "cpyamf/codec.pyx":433
 * 
 *     cdef int writeBoolean(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeInt(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeBoolean");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":435
 *         raise NotImplementedError
 * 
 *     cdef int writeInt(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeInt(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeInt");

  /* "cpyamf/codec.pyx":436
 * 
 *     cdef int writeInt(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeLong(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeInt");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":438
 *         raise NotImplementedError
 * 
 *     cdef int writeLong(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeLong(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeLong");

  /* "cpyamf/codec.pyx":439
 * 
 *     cdef int writeLong(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeNumber(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeLong");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":441
 *         raise NotImplementedError
 * 
 *     cdef int writeNumber(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeNumber(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeNumber");

  /* "cpyamf/codec.pyx":442
 * 
 *     cdef int writeNumber(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDateTime(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeNumber");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":444
 *         raise NotImplementedError
 * 
 *     cdef int writeDateTime(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeDateTime(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeDateTime");

  /* "cpyamf/codec.pyx":445
 * 
 *     cdef int writeDateTime(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDate(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeDateTime");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":447
 *         raise NotImplementedError
 * 
 *     cdef int writeDate(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         o = datetime.datetime.combine(o, datetime.time(0, 0, 0, 0))
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeDate(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("writeDate");
  __Pyx_INCREF(__pyx_v_o);

  /* "cpyamf/codec.pyx":448
 * 
 *     cdef int writeDate(self, object o) except -1:
 *         o = datetime.datetime.combine(o, datetime.time(0, 0, 0, 0))             # <<<<<<<<<<<<<<
 * 
 *         self.writeDateTime(o)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__datetime); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__datetime); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__combine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__datetime); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_o);
  __pyx_v_o = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":450
 *         o = datetime.datetime.combine(o, datetime.time(0, 0, 0, 0))
 * 
 *         self.writeDateTime(o)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeXML(self, object o) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeDateTime(__pyx_v_self, __pyx_v_o); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeDate");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_o);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":452
 *         self.writeDateTime(o)
 * 
 *     cdef int writeXML(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeXML(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeXML");

  /* "cpyamf/codec.pyx":453
 * 
 *     cdef int writeXML(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeList(self, object o, bint is_proxy=0) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeXML");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":455
 *         raise NotImplementedError
 * 
 *     cpdef int writeList(self, object o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Encoder_writeList(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeList *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("writeList");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_is_proxy = __pyx_optional_args->is_proxy;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__writeList); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Encoder_2writeList)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_o);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
      __Pyx_GIVEREF(__pyx_v_o);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":456
 * 
 *     cpdef int writeList(self, object o, bint is_proxy=0) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeTuple(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeList");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":455
 *         raise NotImplementedError
 * 
 *     cpdef int writeList(self, object o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_o = 0;
  int __pyx_v_is_proxy;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeList __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__o,&__pyx_n_s__is_proxy,0};
  __Pyx_RefNannySetupContext("writeList");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__is_proxy);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "writeList") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_o = values[0];
    if (values[1]) {
      __pyx_v_is_proxy = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_is_proxy == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_is_proxy = ((int)0);
    }
  } else {
    __pyx_v_is_proxy = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_is_proxy = __Pyx_PyObject_IsTrue(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_is_proxy == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_o = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("writeList", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeList");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.is_proxy = __pyx_v_is_proxy;
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->writeList(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_o, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeList");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":458
 *         raise NotImplementedError
 * 
 *     cdef int writeTuple(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeTuple(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeTuple");

  /* "cpyamf/codec.pyx":459
 * 
 *     cdef int writeTuple(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDict(self, dict o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeTuple");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":461
 *         raise NotImplementedError
 * 
 *     cdef int writeDict(self, dict o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeDict(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeDict");

  /* "cpyamf/codec.pyx":462
 * 
 *     cdef int writeDict(self, dict o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeGenerator(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeDict");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":464
 *         raise NotImplementedError
 * 
 *     cdef int writeGenerator(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         cdef object n = getattr(o, 'next')
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeGenerator(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_v_n = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("writeGenerator");

  /* "cpyamf/codec.pyx":465
 * 
 *     cdef int writeGenerator(self, object o) except -1:
 *         cdef object n = getattr(o, 'next')             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_o, ((PyObject *)__pyx_n_s__next)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_n = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":467
 *         cdef object n = getattr(o, 'next')
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             try:
 *                 self.writeElement(n())
 */
  while (1) {
    if (!1) break;

    /* "cpyamf/codec.pyx":468
 * 
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 self.writeElement(n())
 *             except StopIteration:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "cpyamf/codec.pyx":469
 *         while True:
 *             try:
 *                 self.writeElement(n())             # <<<<<<<<<<<<<<
 *             except StopIteration:
 *                 return 0
 */
        __pyx_t_1 = PyObject_Call(__pyx_v_n, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeElement(__pyx_v_self, __pyx_t_1, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cpyamf/codec.pyx":470
 *             try:
 *                 self.writeElement(n())
 *             except StopIteration:             # <<<<<<<<<<<<<<
 *                 return 0
 * 
 */
      __pyx_t_2 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
      if (__pyx_t_2) {
        __Pyx_AddTraceback("cpyamf.codec.Encoder.writeGenerator");
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);

        /* "cpyamf/codec.pyx":471
 *                 self.writeElement(n())
 *             except StopIteration:
 *                 return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeSequence(self, object iterable) except -1:
 */
        __pyx_r = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_except_return;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L8_except_return:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L0;
      __pyx_L6_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L12_try_end:;
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeGenerator");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":473
 *                 return 0
 * 
 *     cdef int writeSequence(self, object iterable) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Encodes an iterable. The default is to write If the iterable has an al
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeSequence(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_iterable) {
  PyObject *__pyx_v_alias;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("writeSequence");
  __pyx_v_alias = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/codec.pyx":477
 *         Encodes an iterable. The default is to write If the iterable has an al
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             alias = self.context.getClassAlias(iterable.__class__)
 *         except (AttributeError, pyamf.UnknownClassAlias):
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":478
 *         """
 *         try:
 *             alias = self.context.getClassAlias(iterable.__class__)             # <<<<<<<<<<<<<<
 *         except (AttributeError, pyamf.UnknownClassAlias):
 *             return self.writeList(iterable)
 */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__context); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getClassAlias); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_iterable, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/codec.pyx":479
 *         try:
 *             alias = self.context.getClassAlias(iterable.__class__)
 *         except (AttributeError, pyamf.UnknownClassAlias):             # <<<<<<<<<<<<<<
 *             return self.writeList(iterable)
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__UnknownClassAlias); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || PyErr_ExceptionMatches(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {
      __Pyx_AddTraceback("cpyamf.codec.Encoder.writeSequence");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "cpyamf/codec.pyx":480
 *             alias = self.context.getClassAlias(iterable.__class__)
 *         except (AttributeError, pyamf.UnknownClassAlias):
 *             return self.writeList(iterable)             # <<<<<<<<<<<<<<
 * 
 *         if alias.external:
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeList(__pyx_v_self, __pyx_v_iterable, 0, NULL); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  /* "cpyamf/codec.pyx":482
 *             return self.writeList(iterable)
 * 
 *         if alias.external:             # <<<<<<<<<<<<<<
 *             # a is a subclassed list with a registered alias - push to the
 *             # correct method
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__external); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":485
 *             # a is a subclassed list with a registered alias - push to the
 *             # correct method
 *             self.use_write_object.append(type(iterable))             # <<<<<<<<<<<<<<
 * 
 *             return self.writeObject(iterable)
 */
    if (unlikely(__pyx_v_self->use_write_object == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_4 = PyList_Append(__pyx_v_self->use_write_object, ((PyObject *)Py_TYPE(__pyx_v_iterable))); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/codec.pyx":487
 *             self.use_write_object.append(type(iterable))
 * 
 *             return self.writeObject(iterable)             # <<<<<<<<<<<<<<
 * 
 *         return self.writeList(iterable)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeObject(__pyx_v_self, __pyx_v_iterable, 0, NULL); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "cpyamf/codec.pyx":489
 *             return self.writeObject(iterable)
 * 
 *         return self.writeList(iterable)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeObject(self, object o, bint is_proxy=0) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeList(__pyx_v_self, __pyx_v_iterable, 0, NULL); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeSequence");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_alias);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":491
 *         return self.writeList(iterable)
 * 
 *     cpdef int writeObject(self, object o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Encoder_writeObject(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("writeObject");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_is_proxy = __pyx_optional_args->is_proxy;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__writeObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Encoder_3writeObject)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_o);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
      __Pyx_GIVEREF(__pyx_v_o);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":492
 * 
 *     cpdef int writeObject(self, object o, bint is_proxy=0) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeMixedArray(self, object o) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":491
 *         return self.writeList(iterable)
 * 
 *     cpdef int writeObject(self, object o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_o = 0;
  int __pyx_v_is_proxy;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__o,&__pyx_n_s__is_proxy,0};
  __Pyx_RefNannySetupContext("writeObject");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__is_proxy);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "writeObject") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_o = values[0];
    if (values[1]) {
      __pyx_v_is_proxy = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_is_proxy == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_is_proxy = ((int)0);
    }
  } else {
    __pyx_v_is_proxy = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_is_proxy = __Pyx_PyObject_IsTrue(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_is_proxy == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_o = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("writeObject", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeObject");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.is_proxy = __pyx_v_is_proxy;
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->writeObject(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_o, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":494
 *         raise NotImplementedError
 * 
 *     cdef int writeMixedArray(self, object o) except -1:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_writeMixedArray(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("writeMixedArray");

  /* "cpyamf/codec.pyx":495
 * 
 *     cdef int writeMixedArray(self, object o) except -1:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeMixedArray");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":497
 *         raise NotImplementedError
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         @return: 0 = handled, -1 = error, 1 = not handled
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_5codec_7Encoder_handleBasicTypes(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_element, PyObject *__pyx_v_py_type) {
  int __pyx_v_ret;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("handleBasicTypes");

  /* "cpyamf/codec.pyx":501
 *         @return: 0 = handled, -1 = error, 1 = not handled
 *         """
 *         cdef int ret = 1             # <<<<<<<<<<<<<<
 * 
 *         if PyString_Check(element):
 */
  __pyx_v_ret = 1;

  /* "cpyamf/codec.pyx":503
 *         cdef int ret = 1
 * 
 *         if PyString_Check(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeBytes(element)
 *         elif PyUnicode_Check(element):
 */
  __pyx_t_1 = PyString_Check(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":504
 * 
 *         if PyString_Check(element):
 *             ret = self.writeBytes(element)             # <<<<<<<<<<<<<<
 *         elif PyUnicode_Check(element):
 *             ret = self.writeString(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeBytes(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":505
 *         if PyString_Check(element):
 *             ret = self.writeBytes(element)
 *         elif PyUnicode_Check(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeString(element)
 *         elif element is None:
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":506
 *             ret = self.writeBytes(element)
 *         elif PyUnicode_Check(element):
 *             ret = self.writeString(element)             # <<<<<<<<<<<<<<
 *         elif element is None:
 *             ret = self.writeNull(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeString(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":507
 *         elif PyUnicode_Check(element):
 *             ret = self.writeString(element)
 *         elif element is None:             # <<<<<<<<<<<<<<
 *             ret = self.writeNull(element)
 *         elif PyBool_Check(element):
 */
  __pyx_t_1 = (__pyx_v_element == Py_None);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":508
 *             ret = self.writeString(element)
 *         elif element is None:
 *             ret = self.writeNull(element)             # <<<<<<<<<<<<<<
 *         elif PyBool_Check(element):
 *             ret = self.writeBoolean(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeNull(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":509
 *         elif element is None:
 *             ret = self.writeNull(element)
 *         elif PyBool_Check(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeBoolean(element)
 *         elif PyInt_CheckExact(element):
 */
  __pyx_t_1 = PyBool_Check(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":510
 *             ret = self.writeNull(element)
 *         elif PyBool_Check(element):
 *             ret = self.writeBoolean(element)             # <<<<<<<<<<<<<<
 *         elif PyInt_CheckExact(element):
 *             ret = self.writeInt(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeBoolean(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":511
 *         elif PyBool_Check(element):
 *             ret = self.writeBoolean(element)
 *         elif PyInt_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeInt(element)
 *         elif PyLong_CheckExact(element):
 */
  __pyx_t_1 = PyInt_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":512
 *             ret = self.writeBoolean(element)
 *         elif PyInt_CheckExact(element):
 *             ret = self.writeInt(element)             # <<<<<<<<<<<<<<
 *         elif PyLong_CheckExact(element):
 *             ret = self.writeLong(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeInt(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":513
 *         elif PyInt_CheckExact(element):
 *             ret = self.writeInt(element)
 *         elif PyLong_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeLong(element)
 *         elif PyFloat_CheckExact(element):
 */
  __pyx_t_1 = PyLong_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":514
 *             ret = self.writeInt(element)
 *         elif PyLong_CheckExact(element):
 *             ret = self.writeLong(element)             # <<<<<<<<<<<<<<
 *         elif PyFloat_CheckExact(element):
 *             ret = self.writeNumber(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeLong(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":515
 *         elif PyLong_CheckExact(element):
 *             ret = self.writeLong(element)
 *         elif PyFloat_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeNumber(element)
 *         elif PyList_CheckExact(element):
 */
  __pyx_t_1 = PyFloat_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":516
 *             ret = self.writeLong(element)
 *         elif PyFloat_CheckExact(element):
 *             ret = self.writeNumber(element)             # <<<<<<<<<<<<<<
 *         elif PyList_CheckExact(element):
 *             ret = self.writeList(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeNumber(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":517
 *         elif PyFloat_CheckExact(element):
 *             ret = self.writeNumber(element)
 *         elif PyList_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeList(element)
 *         elif PyTuple_CheckExact(element):
 */
  __pyx_t_1 = PyList_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":518
 *             ret = self.writeNumber(element)
 *         elif PyList_CheckExact(element):
 *             ret = self.writeList(element)             # <<<<<<<<<<<<<<
 *         elif PyTuple_CheckExact(element):
 *             ret = self.writeTuple(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeList(__pyx_v_self, __pyx_v_element, 0, NULL); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":519
 *         elif PyList_CheckExact(element):
 *             ret = self.writeList(element)
 *         elif PyTuple_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeTuple(element)
 *         elif element is Undefined:
 */
  __pyx_t_1 = PyTuple_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":520
 *             ret = self.writeList(element)
 *         elif PyTuple_CheckExact(element):
 *             ret = self.writeTuple(element)             # <<<<<<<<<<<<<<
 *         elif element is Undefined:
 *             ret = self.writeUndefined(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeTuple(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":521
 *         elif PyTuple_CheckExact(element):
 *             ret = self.writeTuple(element)
 *         elif element is Undefined:             # <<<<<<<<<<<<<<
 *             ret = self.writeUndefined(element)
 *         elif PyDict_CheckExact(element):
 */
  __pyx_t_1 = (__pyx_v_element == __pyx_v_6cpyamf_5codec_Undefined);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":522
 *             ret = self.writeTuple(element)
 *         elif element is Undefined:
 *             ret = self.writeUndefined(element)             # <<<<<<<<<<<<<<
 *         elif PyDict_CheckExact(element):
 *             ret = self.writeDict(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeUndefined(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":523
 *         elif element is Undefined:
 *             ret = self.writeUndefined(element)
 *         elif PyDict_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeDict(element)
 *         elif PyDateTime_CheckExact(element):
 */
  __pyx_t_1 = PyDict_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":524
 *             ret = self.writeUndefined(element)
 *         elif PyDict_CheckExact(element):
 *             ret = self.writeDict(element)             # <<<<<<<<<<<<<<
 *         elif PyDateTime_CheckExact(element):
 *             ret = self.writeDateTime(element)
 */
    if (!(likely(PyDict_CheckExact(__pyx_v_element))||((__pyx_v_element) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_v_element)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeDict(__pyx_v_self, ((PyObject*)__pyx_v_element)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":525
 *         elif PyDict_CheckExact(element):
 *             ret = self.writeDict(element)
 *         elif PyDateTime_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeDateTime(element)
 *         elif PyDate_CheckExact(element):
 */
  __pyx_t_2 = PyDateTime_CheckExact(__pyx_v_element);
  if (__pyx_t_2) {

    /* "cpyamf/codec.pyx":526
 *             ret = self.writeDict(element)
 *         elif PyDateTime_CheckExact(element):
 *             ret = self.writeDateTime(element)             # <<<<<<<<<<<<<<
 *         elif PyDate_CheckExact(element):
 *             ret = self.writeDate(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeDateTime(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":527
 *         elif PyDateTime_CheckExact(element):
 *             ret = self.writeDateTime(element)
 *         elif PyDate_CheckExact(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeDate(element)
 *         elif py_type is MixedArray:
 */
  __pyx_t_2 = PyDate_CheckExact(__pyx_v_element);
  if (__pyx_t_2) {

    /* "cpyamf/codec.pyx":528
 *             ret = self.writeDateTime(element)
 *         elif PyDate_CheckExact(element):
 *             ret = self.writeDate(element)             # <<<<<<<<<<<<<<
 *         elif py_type is MixedArray:
 *             ret = self.writeMixedArray(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeDate(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":529
 *         elif PyDate_CheckExact(element):
 *             ret = self.writeDate(element)
 *         elif py_type is MixedArray:             # <<<<<<<<<<<<<<
 *             ret = self.writeMixedArray(element)
 *         elif py_type is GeneratorType:
 */
  __pyx_t_1 = (__pyx_v_py_type == __pyx_v_6cpyamf_5codec_MixedArray);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":530
 *             ret = self.writeDate(element)
 *         elif py_type is MixedArray:
 *             ret = self.writeMixedArray(element)             # <<<<<<<<<<<<<<
 *         elif py_type is GeneratorType:
 *             ret = self.writeGenerator(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeMixedArray(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":531
 *         elif py_type is MixedArray:
 *             ret = self.writeMixedArray(element)
 *         elif py_type is GeneratorType:             # <<<<<<<<<<<<<<
 *             ret = self.writeGenerator(element)
 *         elif PySequence_Contains(self.use_write_object, py_type):
 */
  __pyx_t_1 = (__pyx_v_py_type == __pyx_v_6cpyamf_5codec_GeneratorType);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":532
 *             ret = self.writeMixedArray(element)
 *         elif py_type is GeneratorType:
 *             ret = self.writeGenerator(element)             # <<<<<<<<<<<<<<
 *         elif PySequence_Contains(self.use_write_object, py_type):
 *             ret = self.writeObject(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeGenerator(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":533
 *         elif py_type is GeneratorType:
 *             ret = self.writeGenerator(element)
 *         elif PySequence_Contains(self.use_write_object, py_type):             # <<<<<<<<<<<<<<
 *             ret = self.writeObject(element)
 *         elif isinstance(element, (list, tuple)):
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->use_write_object);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_2 = PySequence_Contains(__pyx_t_3, __pyx_v_py_type); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cpyamf/codec.pyx":534
 *             ret = self.writeGenerator(element)
 *         elif PySequence_Contains(self.use_write_object, py_type):
 *             ret = self.writeObject(element)             # <<<<<<<<<<<<<<
 *         elif isinstance(element, (list, tuple)):
 *             ret = self.writeSequence(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeObject(__pyx_v_self, __pyx_v_element, 0, NULL); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":535
 *         elif PySequence_Contains(self.use_write_object, py_type):
 *             ret = self.writeObject(element)
 *         elif isinstance(element, (list, tuple)):             # <<<<<<<<<<<<<<
 *             ret = self.writeSequence(element)
 *         elif xml.is_xml(element):
 */
  __Pyx_INCREF(__pyx_v_element);
  __pyx_t_3 = __pyx_v_element;
  __pyx_t_1 = PyList_Check(__pyx_t_3); 
  if (!__pyx_t_1) {
    __pyx_t_4 = PyTuple_Check(__pyx_t_3); 
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":536
 *             ret = self.writeObject(element)
 *         elif isinstance(element, (list, tuple)):
 *             ret = self.writeSequence(element)             # <<<<<<<<<<<<<<
 *         elif xml.is_xml(element):
 *             ret = self.writeXML(element)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeSequence(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":537
 *         elif isinstance(element, (list, tuple)):
 *             ret = self.writeSequence(element)
 *         elif xml.is_xml(element):             # <<<<<<<<<<<<<<
 *             ret = self.writeXML(element)
 * 
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__xml); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__is_xml); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_element);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_element);
  __Pyx_GIVEREF(__pyx_v_element);
  __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":538
 *             ret = self.writeSequence(element)
 *         elif xml.is_xml(element):
 *             ret = self.writeXML(element)             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeXML(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_ret = __pyx_t_2;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":540
 *             ret = self.writeXML(element)
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     cdef int checkBadTypes(self, object element, object py_type) except -1:
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.handleBasicTypes");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":542
 *         return ret
 * 
 *     cdef int checkBadTypes(self, object element, object py_type) except -1:             # <<<<<<<<<<<<<<
 *         if PyModule_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode modules")
 */

static  int __pyx_f_6cpyamf_5codec_7Encoder_checkBadTypes(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_element, PyObject *__pyx_v_py_type) {
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("checkBadTypes");

  /* "cpyamf/codec.pyx":543
 * 
 *     cdef int checkBadTypes(self, object element, object py_type) except -1:
 *         if PyModule_CheckExact(element):             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError("Cannot encode modules")
 *         elif PyMethod_Check(element):
 */
  __pyx_t_1 = PyModule_CheckExact(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":544
 *     cdef int checkBadTypes(self, object element, object py_type) except -1:
 *         if PyModule_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode modules")             # <<<<<<<<<<<<<<
 *         elif PyMethod_Check(element):
 *             raise pyamf.EncodeError("Cannot encode methods")
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":545
 *         if PyModule_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode modules")
 *         elif PyMethod_Check(element):             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError("Cannot encode methods")
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 */
  __pyx_t_1 = PyMethod_Check(__pyx_v_element);
  if (__pyx_t_1) {

    /* "cpyamf/codec.pyx":546
 *             raise pyamf.EncodeError("Cannot encode modules")
 *         elif PyMethod_Check(element):
 *             raise pyamf.EncodeError("Cannot encode methods")             # <<<<<<<<<<<<<<
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 *             raise pyamf.EncodeError("Cannot encode functions")
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":547
 *         elif PyMethod_Check(element):
 *             raise pyamf.EncodeError("Cannot encode methods")
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError("Cannot encode functions")
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 */
  __pyx_t_1 = PyFunction_Check(__pyx_v_element);
  if (!__pyx_t_1) {
    __pyx_t_4 = (__pyx_v_py_type == __pyx_v_6cpyamf_5codec_BuiltinFunctionType);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":548
 *             raise pyamf.EncodeError("Cannot encode methods")
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 *             raise pyamf.EncodeError("Cannot encode functions")             # <<<<<<<<<<<<<<
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode class objects")
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":549
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 *             raise pyamf.EncodeError("Cannot encode functions")
 *         elif PyClass_Check(element) or PyType_CheckExact(element):             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError("Cannot encode class objects")
 *         elif PyTime_CheckExact(element):
 */
  __pyx_t_5 = PyClass_Check(__pyx_v_element);
  if (!__pyx_t_5) {
    __pyx_t_1 = PyType_CheckExact(__pyx_v_element);
    __pyx_t_4 = __pyx_t_1;
  } else {
    __pyx_t_4 = __pyx_t_5;
  }
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":550
 *             raise pyamf.EncodeError("Cannot encode functions")
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode class objects")             # <<<<<<<<<<<<<<
 *         elif PyTime_CheckExact(element):
 *             raise pyamf.EncodeError('A datetime.time instance was found but '
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "cpyamf/codec.pyx":551
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode class objects")
 *         elif PyTime_CheckExact(element):             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError('A datetime.time instance was found but '
 *                 'AMF has no way to encode time objects. Please use '
 */
  __pyx_t_6 = PyTime_CheckExact(__pyx_v_element);
  if (__pyx_t_6) {

    /* "cpyamf/codec.pyx":552
 *             raise pyamf.EncodeError("Cannot encode class objects")
 *         elif PyTime_CheckExact(element):
 *             raise pyamf.EncodeError('A datetime.time instance was found but '             # <<<<<<<<<<<<<<
 *                 'AMF has no way to encode time objects. Please use '
 *                 'datetime.datetime instead')
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":556
 *                 'datetime.datetime instead')
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeElement(self, object element) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.checkBadTypes");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":558
 *         return 0
 * 
 *     cpdef int writeElement(self, object element) except -1:             # <<<<<<<<<<<<<<
 *         cdef int ret = 0
 *         cdef object py_type = type(element)
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_4writeElement(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Encoder_writeElement(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_element, int __pyx_skip_dispatch) {
  int __pyx_v_ret;
  PyObject *__pyx_v_py_type = 0;
  PyObject *__pyx_v_func = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("writeElement");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__writeElement); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Encoder_4writeElement)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_element);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_element);
      __Pyx_GIVEREF(__pyx_v_element);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":559
 * 
 *     cpdef int writeElement(self, object element) except -1:
 *         cdef int ret = 0             # <<<<<<<<<<<<<<
 *         cdef object py_type = type(element)
 *         cdef object func = None
 */
  __pyx_v_ret = 0;

  /* "cpyamf/codec.pyx":560
 *     cpdef int writeElement(self, object element) except -1:
 *         cdef int ret = 0
 *         cdef object py_type = type(element)             # <<<<<<<<<<<<<<
 *         cdef object func = None
 *         cdef int use_proxy
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_element)));
  __pyx_v_py_type = ((PyObject *)Py_TYPE(__pyx_v_element));

  /* "cpyamf/codec.pyx":561
 *         cdef int ret = 0
 *         cdef object py_type = type(element)
 *         cdef object func = None             # <<<<<<<<<<<<<<
 *         cdef int use_proxy
 * 
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_func = Py_None;

  /* "cpyamf/codec.pyx":564
 *         cdef int use_proxy
 * 
 *         ret = self.handleBasicTypes(element, py_type)             # <<<<<<<<<<<<<<
 * 
 *         if ret == 1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->handleBasicTypes(__pyx_v_self, __pyx_v_element, __pyx_v_py_type); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ret = __pyx_t_4;

  /* "cpyamf/codec.pyx":566
 *         ret = self.handleBasicTypes(element, py_type)
 * 
 *         if ret == 1:             # <<<<<<<<<<<<<<
 *             # encoding was not handled by basic types
 *             func = self.func_cache.get(py_type, None)
 */
  __pyx_t_5 = (__pyx_v_ret == 1);
  if (__pyx_t_5) {

    /* "cpyamf/codec.pyx":568
 *         if ret == 1:
 *             # encoding was not handled by basic types
 *             func = self.func_cache.get(py_type, None)             # <<<<<<<<<<<<<<
 * 
 *             if func is None:
 */
    if (unlikely(__pyx_v_self->func_cache == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->func_cache), __pyx_v_py_type, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_func);
    __pyx_v_func = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpyamf/codec.pyx":570
 *             func = self.func_cache.get(py_type, None)
 * 
 *             if func is None:             # <<<<<<<<<<<<<<
 *                 func = get_custom_type_func(self, element)
 * 
 */
    __pyx_t_5 = (__pyx_v_func == Py_None);
    if (__pyx_t_5) {

      /* "cpyamf/codec.pyx":571
 * 
 *             if func is None:
 *                 func = get_custom_type_func(self, element)             # <<<<<<<<<<<<<<
 * 
 *                 if func is None:
 */
      __pyx_t_1 = __pyx_f_6cpyamf_5codec_get_custom_type_func(((PyObject *)__pyx_v_self), __pyx_v_element); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_func);
      __pyx_v_func = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "cpyamf/codec.pyx":573
 *                 func = get_custom_type_func(self, element)
 * 
 *                 if func is None:             # <<<<<<<<<<<<<<
 *                     self.checkBadTypes(element, py_type)
 *                     self.use_write_object.append(py_type)
 */
      __pyx_t_5 = (__pyx_v_func == Py_None);
      if (__pyx_t_5) {

        /* "cpyamf/codec.pyx":574
 * 
 *                 if func is None:
 *                     self.checkBadTypes(element, py_type)             # <<<<<<<<<<<<<<
 *                     self.use_write_object.append(py_type)
 * 
 */
        __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->checkBadTypes(__pyx_v_self, __pyx_v_element, __pyx_v_py_type); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cpyamf/codec.pyx":575
 *                 if func is None:
 *                     self.checkBadTypes(element, py_type)
 *                     self.use_write_object.append(py_type)             # <<<<<<<<<<<<<<
 * 
 *                     return self.writeObject(element)
 */
        if (unlikely(__pyx_v_self->use_write_object == Py_None)) {
          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
        }
        __pyx_t_4 = PyList_Append(__pyx_v_self->use_write_object, __pyx_v_py_type); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cpyamf/codec.pyx":577
 *                     self.use_write_object.append(py_type)
 * 
 *                     return self.writeObject(element)             # <<<<<<<<<<<<<<
 * 
 *                 self.func_cache[py_type] = func
 */
        __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)__pyx_v_self->__pyx_vtab)->writeObject(__pyx_v_self, __pyx_v_element, 0, NULL); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_r = __pyx_t_4;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "cpyamf/codec.pyx":579
 *                     return self.writeObject(element)
 * 
 *                 self.func_cache[py_type] = func             # <<<<<<<<<<<<<<
 * 
 *             func(element)
 */
      if (PyDict_SetItem(((PyObject *)__pyx_v_self->func_cache), __pyx_v_py_type, __pyx_v_func) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "cpyamf/codec.pyx":581
 *                 self.func_cache[py_type] = func
 * 
 *             func(element)             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_element);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_element);
    __Pyx_GIVEREF(__pyx_v_element);
    __pyx_t_3 = PyObject_Call(__pyx_v_func, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/codec.pyx":583
 *             func(element)
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     cpdef int send(self, data) except -1:
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeElement");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_py_type);
  __Pyx_XDECREF(__pyx_v_func);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":558
 *         return 0
 * 
 *     cpdef int writeElement(self, object element) except -1:             # <<<<<<<<<<<<<<
 *         cdef int ret = 0
 *         cdef object py_type = type(element)
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_4writeElement(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_4writeElement(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("writeElement");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_element, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.writeElement");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":585
 *         return ret
 * 
 *     cpdef int send(self, data) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Add data for the decoder to work on.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static  int __pyx_f_6cpyamf_5codec_7Encoder_send(struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("send");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__send); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_6cpyamf_5codec_7Encoder_5send)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/codec.pyx":589
 *         Add data for the decoder to work on.
 *         """
 *         self.bucket.append(data)             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  if (unlikely(__pyx_v_self->bucket == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_4 = PyList_Append(__pyx_v_self->bucket, __pyx_v_data); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.send");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":585
 *         return ret
 * 
 *     cpdef int send(self, data) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Add data for the decoder to work on.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Encoder_5send[] = "\n        Add data for the decoder to work on.\n        ";
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("send");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_data, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.send");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":591
 *         self.bucket.append(data)
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """
 *         Part of the iterator protocol.
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_6__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6cpyamf_5codec_7Encoder_6__next__[] = "\n        Part of the iterator protocol.\n        ";
struct wrapperbase __pyx_wrapperbase_6cpyamf_5codec_7Encoder_6__next__;
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_6__next__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_v_start_pos;
  Py_ssize_t __pyx_v_end_pos;
  char *__pyx_v_buf;
  PyObject *__pyx_v_element;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("__next__");
  __pyx_v_element = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/codec.pyx":598
 *         cdef char *buf
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             element = self.bucket.pop(0)
 *         except IndexError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/codec.pyx":599
 * 
 *         try:
 *             element = self.bucket.pop(0)             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             raise StopIteration
 */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->bucket), __pyx_n_s__pop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_element);
      __pyx_v_element = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpyamf/codec.pyx":600
 *         try:
 *             element = self.bucket.pop(0)
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("cpyamf.codec.Encoder.__next__");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpyamf/codec.pyx":601
 *             element = self.bucket.pop(0)
 *         except IndexError:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         start_pos = self.stream.tell()
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "cpyamf/codec.pyx":603
 *             raise StopIteration
 * 
 *         start_pos = self.stream.tell()             # <<<<<<<<<<<<<<
 * 
 *         self.writeElement(element)
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream->__pyx_vtab)->tell(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_start_pos = __pyx_t_5;

  /* "cpyamf/codec.pyx":605
 *         start_pos = self.stream.tell()
 * 
 *         self.writeElement(element)             # <<<<<<<<<<<<<<
 * 
 *         end_pos = self.stream.tell()
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_vtab)->writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_element, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":607
 *         self.writeElement(element)
 * 
 *         end_pos = self.stream.tell()             # <<<<<<<<<<<<<<
 * 
 *         self.stream.seek(start_pos)
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream->__pyx_vtab)->tell(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_end_pos = __pyx_t_5;

  /* "cpyamf/codec.pyx":609
 *         end_pos = self.stream.tell()
 * 
 *         self.stream.seek(start_pos)             # <<<<<<<<<<<<<<
 * 
 *         self.stream.read(&buf, end_pos - start_pos)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream->__pyx_vtab)->seek(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream, __pyx_v_start_pos, 0, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":611
 *         self.stream.seek(start_pos)
 * 
 *         self.stream.read(&buf, end_pos - start_pos)             # <<<<<<<<<<<<<<
 * 
 *         return PyString_FromStringAndSize(buf, end_pos - start_pos)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream->__pyx_vtab)->read(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self)->__pyx_base.stream, (&__pyx_v_buf), (__pyx_v_end_pos - __pyx_v_start_pos)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":613
 *         self.stream.read(&buf, end_pos - start_pos)
 * 
 *         return PyString_FromStringAndSize(buf, end_pos - start_pos)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyString_FromStringAndSize(__pyx_v_buf, (__pyx_v_end_pos - __pyx_v_start_pos)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.codec.Encoder.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_element);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":615
 *         return PyString_FromStringAndSize(buf, end_pos - start_pos)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_7Encoder_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "cpyamf/codec.pyx":616
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":627
 *     cdef object func
 * 
 *     def __cinit__(self, Encoder encoder, func):             # <<<<<<<<<<<<<<
 *         self.encoder = encoder
 *         self.func = func
 */

static int __pyx_pf_6cpyamf_5codec_15_CustomTypeFunc___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_5codec_15_CustomTypeFunc___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6cpyamf_5codec_Encoder *__pyx_v_encoder = 0;
  PyObject *__pyx_v_func = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__encoder,&__pyx_n_s__func,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoder);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__func);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_encoder = ((struct __pyx_obj_6cpyamf_5codec_Encoder *)values[0]);
    __pyx_v_func = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_encoder = ((struct __pyx_obj_6cpyamf_5codec_Encoder *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_func = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.codec._CustomTypeFunc.__cinit__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoder), __pyx_ptype_6cpyamf_5codec_Encoder, 1, "encoder", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/codec.pyx":628
 * 
 *     def __cinit__(self, Encoder encoder, func):
 *         self.encoder = encoder             # <<<<<<<<<<<<<<
 *         self.func = func
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_encoder));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_encoder));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder));
  ((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder = __pyx_v_encoder;

  /* "cpyamf/codec.pyx":629
 *     def __cinit__(self, Encoder encoder, func):
 *         self.encoder = encoder
 *         self.func = func             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, data, **kwargs):
 */
  __Pyx_INCREF(__pyx_v_func);
  __Pyx_GIVEREF(__pyx_v_func);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->func);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->func);
  ((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->func = __pyx_v_func;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.codec._CustomTypeFunc.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":631
 *         self.func = func
 * 
 *     def __call__(self, data, **kwargs):             # <<<<<<<<<<<<<<
 *         ret = self.func(data, encoder=self.encoder)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_5codec_15_CustomTypeFunc_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_5codec_15_CustomTypeFunc_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_v_ret;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__data,0};
  __Pyx_RefNannySetupContext("__call__");
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_data = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_AddTraceback("cpyamf.codec._CustomTypeFunc.__call__");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_ret = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/codec.pyx":632
 * 
 *     def __call__(self, data, **kwargs):
 *         ret = self.func(data, encoder=self.encoder)             # <<<<<<<<<<<<<<
 * 
 *         if ret is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
  __Pyx_GIVEREF(__pyx_v_data);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__encoder), ((PyObject *)((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyEval_CallObjectWithKeywords(((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->func, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_ret);
  __pyx_v_ret = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/codec.pyx":634
 *         ret = self.func(data, encoder=self.encoder)
 * 
 *         if ret is not None:             # <<<<<<<<<<<<<<
 *             self.encoder.writeElement(ret)
 * 
 */
  __pyx_t_4 = (__pyx_v_ret != Py_None);
  if (__pyx_t_4) {

    /* "cpyamf/codec.pyx":635
 * 
 *         if ret is not None:
 *             self.encoder.writeElement(ret)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_5codec_Encoder *)((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder->__pyx_vtab)->writeElement(((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)__pyx_v_self)->encoder, __pyx_v_ret, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.codec._CustomTypeFunc.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_DECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/codec.pyx":638
 * 
 * 
 * cdef object get_custom_type_func(object encoder, object data):             # <<<<<<<<<<<<<<
 *     cdef _CustomTypeFunc ret
 * 
 */

static  PyObject *__pyx_f_6cpyamf_5codec_get_custom_type_func(PyObject *__pyx_v_encoder, PyObject *__pyx_v_data) {
  PyObject *__pyx_v_type_;
  PyObject *__pyx_v_func;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  __Pyx_RefNannySetupContext("get_custom_type_func");
  __pyx_v_type_ = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_func = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/codec.pyx":641
 *     cdef _CustomTypeFunc ret
 * 
 *     for type_, func in pyamf.TYPE_MAP.iteritems():             # <<<<<<<<<<<<<<
 *         try:
 *             if isinstance(data, type_):
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__TYPE_MAP); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__iteritems); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2);
  } else {
    __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else {
      __pyx_t_3 = PyIter_Next(__pyx_t_2);
      if (!__pyx_t_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if (PyTuple_CheckExact(__pyx_t_3) && likely(PyTuple_GET_SIZE(__pyx_t_3) == 2)) {
      PyObject* tuple = __pyx_t_3;
      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_type_);
      __pyx_v_type_ = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_func);
      __pyx_v_func = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_type_);
      __pyx_v_type_ = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_func);
      __pyx_v_func = __pyx_t_5;
      __pyx_t_5 = 0;
    }

    /* "cpyamf/codec.pyx":642
 * 
 *     for type_, func in pyamf.TYPE_MAP.iteritems():
 *         try:             # <<<<<<<<<<<<<<
 *             if isinstance(data, type_):
 *                 return _CustomTypeFunc(encoder, func)
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "cpyamf/codec.pyx":643
 *     for type_, func in pyamf.TYPE_MAP.iteritems():
 *         try:
 *             if isinstance(data, type_):             # <<<<<<<<<<<<<<
 *                 return _CustomTypeFunc(encoder, func)
 *         except TypeError:
 */
        __pyx_t_7 = PyObject_IsInstance(__pyx_v_data, __pyx_v_type_); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        if (__pyx_t_7) {

          /* "cpyamf/codec.pyx":644
 *         try:
 *             if isinstance(data, type_):
 *                 return _CustomTypeFunc(encoder, func)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             if callable(type_) and type_(data):
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_INCREF(__pyx_v_encoder);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_encoder);
          __Pyx_GIVEREF(__pyx_v_encoder);
          __Pyx_INCREF(__pyx_v_func);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_func);
          __Pyx_GIVEREF(__pyx_v_func);
          __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec__CustomTypeFunc)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_r = __pyx_t_5;
          __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L9_try_return;
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L12_try_end;
      __pyx_L9_try_return:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L0;
      __pyx_L5_error:;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cpyamf/codec.pyx":645
 *             if isinstance(data, type_):
 *                 return _CustomTypeFunc(encoder, func)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             if callable(type_) and type_(data):
 *                 return _CustomTypeFunc(encoder, func)
 */
      __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_8) {
        __Pyx_AddTraceback("cpyamf.codec.get_custom_type_func");
        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);

        /* "cpyamf/codec.pyx":646
 *                 return _CustomTypeFunc(encoder, func)
 *         except TypeError:
 *             if callable(type_) and type_(data):             # <<<<<<<<<<<<<<
 *                 return _CustomTypeFunc(encoder, func)
 * 
 */
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        __Pyx_INCREF(__pyx_v_type_);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_type_);
        __Pyx_GIVEREF(__pyx_v_type_);
        __pyx_t_9 = PyObject_Call(__pyx_builtin_callable, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (__pyx_t_7) {
          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_9));
          __Pyx_INCREF(__pyx_v_data);
          PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_data);
          __Pyx_GIVEREF(__pyx_v_data);
          __pyx_t_6 = PyObject_Call(__pyx_v_type_, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_11 = __pyx_t_10;
        } else {
          __pyx_t_11 = __pyx_t_7;
        }
        if (__pyx_t_11) {

          /* "cpyamf/codec.pyx":647
 *         except TypeError:
 *             if callable(type_) and type_(data):
 *                 return _CustomTypeFunc(encoder, func)             # <<<<<<<<<<<<<<
 * 
 *     return None
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
          __Pyx_INCREF(__pyx_v_encoder);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_encoder);
          __Pyx_GIVEREF(__pyx_v_encoder);
          __Pyx_INCREF(__pyx_v_func);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_func);
          __Pyx_GIVEREF(__pyx_v_func);
          __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec__CustomTypeFunc)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
          __pyx_r = __pyx_t_9;
          __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L8_except_return;
          goto __pyx_L16;
        }
        __pyx_L16:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L8_except_return:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L0;
      __pyx_L6_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L12_try_end:;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":649
 *                 return _CustomTypeFunc(encoder, func)
 * 
 *     return None             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpyamf.codec.get_custom_type_func");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_type_);
  __Pyx_DECREF(__pyx_v_func);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection __pyx_vtable_6cpyamf_5codec_IndexedCollection;

static PyObject *__pyx_tp_new_6cpyamf_5codec_IndexedCollection(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)o);
  p->__pyx_vtab = __pyx_vtabptr_6cpyamf_5codec_IndexedCollection;
  p->refs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_5codec_17IndexedCollection___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_5codec_IndexedCollection(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *p = (struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_6cpyamf_5codec_17IndexedCollection_2__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->refs));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6cpyamf_5codec_IndexedCollection(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *p = (struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)o;
  if (p->refs) {
    e = (*v)(p->refs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_5codec_IndexedCollection(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *p = (struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->refs);
  p->refs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_6cpyamf_5codec_IndexedCollection(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_6cpyamf_5codec_17IndexedCollection_use_hash(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash___get__(o);
}

static int __pyx_setprop_6cpyamf_5codec_17IndexedCollection_use_hash(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6cpyamf_5codec_17IndexedCollection_8use_hash_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_6cpyamf_5codec_IndexedCollection[] = {
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pf_6cpyamf_5codec_17IndexedCollection_3clear, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getByReference"), (PyCFunction)__pyx_pf_6cpyamf_5codec_17IndexedCollection_4getByReference, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getReferenceTo"), (PyCFunction)__pyx_pf_6cpyamf_5codec_17IndexedCollection_5getReferenceTo, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pf_6cpyamf_5codec_17IndexedCollection_6append, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__copy__"), (PyCFunction)__pyx_pf_6cpyamf_5codec_17IndexedCollection_11__copy__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_5codec_IndexedCollection[] = {
  {(char *)"use_hash", __pyx_getprop_6cpyamf_5codec_17IndexedCollection_use_hash, __pyx_setprop_6cpyamf_5codec_17IndexedCollection_use_hash, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_IndexedCollection = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_IndexedCollection = {
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_8__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_6cpyamf_5codec_IndexedCollection, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_IndexedCollection = {
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_8__len__, /*mp_length*/
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_10__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_IndexedCollection = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec_IndexedCollection = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec.IndexedCollection"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec_IndexedCollection), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec_IndexedCollection, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_IndexedCollection, /*tp_as_number*/
  &__pyx_tp_as_sequence_IndexedCollection, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_IndexedCollection, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_IndexedCollection, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Provides reference functionality for amf contexts.\n\n    @see: L{pyamf.codec.IndexedCollection} for complete documentation\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec_IndexedCollection, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec_IndexedCollection, /*tp_clear*/
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_9__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_7__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec_IndexedCollection, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_5codec_IndexedCollection, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_5codec_17IndexedCollection_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec_IndexedCollection, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Context __pyx_vtable_6cpyamf_5codec_Context;

static PyObject *__pyx_tp_new_6cpyamf_5codec_Context(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec_Context *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec_Context *)o);
  p->__pyx_vtab = __pyx_vtabptr_6cpyamf_5codec_Context;
  p->class_aliases = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->objects = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)Py_None); Py_INCREF(Py_None);
  p->unicodes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_strings = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->extra = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_5codec_7Context___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_5codec_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Context *p = (struct __pyx_obj_6cpyamf_5codec_Context *)o;
  Py_XDECREF(((PyObject *)p->class_aliases));
  Py_XDECREF(((PyObject *)p->objects));
  Py_XDECREF(((PyObject *)p->unicodes));
  Py_XDECREF(((PyObject *)p->_strings));
  Py_XDECREF(((PyObject *)p->extra));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6cpyamf_5codec_Context(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_5codec_Context *p = (struct __pyx_obj_6cpyamf_5codec_Context *)o;
  if (p->class_aliases) {
    e = (*v)(p->class_aliases, a); if (e) return e;
  }
  if (p->objects) {
    e = (*v)(((PyObject*)p->objects), a); if (e) return e;
  }
  if (p->unicodes) {
    e = (*v)(p->unicodes, a); if (e) return e;
  }
  if (p->_strings) {
    e = (*v)(p->_strings, a); if (e) return e;
  }
  if (p->extra) {
    e = (*v)(p->extra, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_5codec_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Context *p = (struct __pyx_obj_6cpyamf_5codec_Context *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->class_aliases);
  p->class_aliases = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->objects);
  p->objects = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->unicodes);
  p->unicodes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_strings);
  p->_strings = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->extra);
  p->extra = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_5codec_7Context_extra(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_5codec_7Context_5extra___get__(o);
}

static int __pyx_setprop_6cpyamf_5codec_7Context_extra(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6cpyamf_5codec_7Context_5extra_1__set__(o, v);
  }
  else {
    return __pyx_pf_6cpyamf_5codec_7Context_5extra_2__del__(o);
  }
}

static PyMethodDef __pyx_methods_6cpyamf_5codec_Context[] = {
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_2clear, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getObject"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_3getObject, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getObjectReference"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_4getObjectReference, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("addObject"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_5addObject, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getClassAlias"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_6getClassAlias, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Context_6getClassAlias)},
  {__Pyx_NAMESTR("getStringForBytes"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_7getStringForBytes, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Context_7getStringForBytes)},
  {__Pyx_NAMESTR("getBytesForString"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Context_8getBytesForString, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Context_8getBytesForString)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_5codec_Context[] = {
  {(char *)"extra", __pyx_getprop_6cpyamf_5codec_7Context_extra, __pyx_setprop_6cpyamf_5codec_7Context_extra, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Context = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Context = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Context = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Context = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec_Context = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec.Context"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec_Context), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec_Context, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Context, /*tp_as_number*/
  &__pyx_tp_as_sequence_Context, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Context, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Context, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    I hold the AMF context for en/decoding streams.\n\n    @ivar objects: An indexed collection of referencable objects encountered\n        during en/decoding.\n    @type objects: L{util.IndexedCollection}\n    @ivar class_aliases: A L{dict} of C{class} to L{ClassAlias}\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec_Context, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec_Context, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec_Context, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_5codec_Context, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_5codec_7Context_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec_Context, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_6cpyamf_5codec_Codec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec_Codec *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec_Codec *)o);
  p->stream = ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)Py_None); Py_INCREF(Py_None);
  p->timezone_offset = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_5codec_5Codec___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_5codec_Codec(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Codec *p = (struct __pyx_obj_6cpyamf_5codec_Codec *)o;
  Py_XDECREF(((PyObject *)p->stream));
  Py_XDECREF(p->timezone_offset);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6cpyamf_5codec_Codec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_5codec_Codec *p = (struct __pyx_obj_6cpyamf_5codec_Codec *)o;
  if (p->stream) {
    e = (*v)(((PyObject*)p->stream), a); if (e) return e;
  }
  if (p->timezone_offset) {
    e = (*v)(p->timezone_offset, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_5codec_Codec(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Codec *p = (struct __pyx_obj_6cpyamf_5codec_Codec *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->stream);
  p->stream = ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->timezone_offset);
  p->timezone_offset = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_5codec_5Codec_stream(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_5codec_5Codec_6stream___get__(o);
}

static int __pyx_setprop_6cpyamf_5codec_5Codec_stream(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6cpyamf_5codec_5Codec_6stream_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6cpyamf_5codec_5Codec_strict(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_5codec_5Codec_6strict___get__(o);
}

static int __pyx_setprop_6cpyamf_5codec_5Codec_strict(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6cpyamf_5codec_5Codec_6strict_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_6cpyamf_5codec_5Codec_timezone_offset(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset___get__(o);
}

static int __pyx_setprop_6cpyamf_5codec_5Codec_timezone_offset(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_1__set__(o, v);
  }
  else {
    return __pyx_pf_6cpyamf_5codec_5Codec_15timezone_offset_2__del__(o);
  }
}

static PyMethodDef __pyx_methods_6cpyamf_5codec_Codec[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_5codec_Codec[] = {
  {(char *)"stream", __pyx_getprop_6cpyamf_5codec_5Codec_stream, __pyx_setprop_6cpyamf_5codec_5Codec_stream, 0, 0},
  {(char *)"strict", __pyx_getprop_6cpyamf_5codec_5Codec_strict, __pyx_setprop_6cpyamf_5codec_5Codec_strict, 0, 0},
  {(char *)"timezone_offset", __pyx_getprop_6cpyamf_5codec_5Codec_timezone_offset, __pyx_setprop_6cpyamf_5codec_5Codec_timezone_offset, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Codec = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Codec = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Codec = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Codec = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec_Codec = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec.Codec"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec_Codec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec_Codec, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Codec, /*tp_as_number*/
  &__pyx_tp_as_sequence_Codec, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Codec, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Codec, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Base class for Encoder/Decoder classes. Provides base functionality for\n    managing codecs.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec_Codec, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec_Codec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec_Codec, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_5codec_Codec, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_5codec_5Codec_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec_Codec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Decoder __pyx_vtable_6cpyamf_5codec_Decoder;

static PyObject *__pyx_tp_new_6cpyamf_5codec_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec_Decoder *p;
  PyObject *o = __pyx_tp_new_6cpyamf_5codec_Codec(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec_Decoder *)o);
  p->__pyx_vtab = __pyx_vtabptr_6cpyamf_5codec_Decoder;
  return o;
}

static PyMethodDef __pyx_methods_6cpyamf_5codec_Decoder[] = {
  {__Pyx_NAMESTR("readString"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Decoder_readString, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("readElement"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Decoder_1readElement, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Decoder_1readElement)},
  {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Decoder_2send, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Decoder_2send)},
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Decoder_3__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Decoder_3__next__)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Decoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Decoder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Decoder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Decoder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec_Decoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec.Decoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec_Decoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec_Codec, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Decoder, /*tp_as_number*/
  &__pyx_tp_as_sequence_Decoder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Decoder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Decoder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Base AMF decoder.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec_Codec, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec_Codec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_6cpyamf_5codec_7Decoder_4__iter__, /*tp_iter*/
  __pyx_pf_6cpyamf_5codec_7Decoder_3__next__, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec_Decoder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec_Decoder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6cpyamf_5codec_Encoder __pyx_vtable_6cpyamf_5codec_Encoder;

static PyObject *__pyx_tp_new_6cpyamf_5codec_Encoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec_Encoder *p;
  PyObject *o = __pyx_tp_new_6cpyamf_5codec_Codec(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec_Encoder *)o);
  p->__pyx_vtab = __pyx_vtabptr_6cpyamf_5codec_Encoder;
  p->func_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->use_write_object = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->bucket = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_5codec_7Encoder___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_5codec_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Encoder *p = (struct __pyx_obj_6cpyamf_5codec_Encoder *)o;
  Py_XDECREF(((PyObject *)p->func_cache));
  Py_XDECREF(((PyObject *)p->use_write_object));
  Py_XDECREF(((PyObject *)p->bucket));
  __pyx_tp_dealloc_6cpyamf_5codec_Codec(o);
}

static int __pyx_tp_traverse_6cpyamf_5codec_Encoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_5codec_Encoder *p = (struct __pyx_obj_6cpyamf_5codec_Encoder *)o;
  e = __pyx_tp_traverse_6cpyamf_5codec_Codec(o, v, a); if (e) return e;
  if (p->func_cache) {
    e = (*v)(p->func_cache, a); if (e) return e;
  }
  if (p->use_write_object) {
    e = (*v)(p->use_write_object, a); if (e) return e;
  }
  if (p->bucket) {
    e = (*v)(p->bucket, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_5codec_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec_Encoder *p = (struct __pyx_obj_6cpyamf_5codec_Encoder *)o;
  PyObject* tmp;
  __pyx_tp_clear_6cpyamf_5codec_Codec(o);
  tmp = ((PyObject*)p->func_cache);
  p->func_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->use_write_object);
  p->use_write_object = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->bucket);
  p->bucket = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6cpyamf_5codec_Encoder[] = {
  {__Pyx_NAMESTR("serialiseString"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_1serialiseString, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("writeList"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_2writeList, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("writeObject"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_3writeObject, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("writeElement"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_4writeElement, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_5send, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Encoder_5send)},
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6cpyamf_5codec_7Encoder_6__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6cpyamf_5codec_7Encoder_6__next__)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Encoder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Encoder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Encoder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Encoder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec_Encoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec.Encoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec_Encoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec_Encoder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Encoder, /*tp_as_number*/
  &__pyx_tp_as_sequence_Encoder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Encoder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Encoder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Base AMF encoder.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec_Encoder, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec_Encoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_6cpyamf_5codec_7Encoder_7__iter__, /*tp_iter*/
  __pyx_pf_6cpyamf_5codec_7Encoder_6__next__, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec_Encoder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec_Encoder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_6cpyamf_5codec__CustomTypeFunc(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)o);
  p->encoder = ((struct __pyx_obj_6cpyamf_5codec_Encoder *)Py_None); Py_INCREF(Py_None);
  p->func = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_5codec_15_CustomTypeFunc___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_5codec__CustomTypeFunc(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *p = (struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)o;
  Py_XDECREF(((PyObject *)p->encoder));
  Py_XDECREF(p->func);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6cpyamf_5codec__CustomTypeFunc(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *p = (struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)o;
  if (p->encoder) {
    e = (*v)(((PyObject*)p->encoder), a); if (e) return e;
  }
  if (p->func) {
    e = (*v)(p->func, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_5codec__CustomTypeFunc(PyObject *o) {
  struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *p = (struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->encoder);
  p->encoder = ((struct __pyx_obj_6cpyamf_5codec_Encoder *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->func);
  p->func = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6cpyamf_5codec__CustomTypeFunc[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__CustomTypeFunc = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__CustomTypeFunc = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__CustomTypeFunc = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__CustomTypeFunc = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6cpyamf_5codec__CustomTypeFunc = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.codec._CustomTypeFunc"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_5codec__CustomTypeFunc), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_5codec__CustomTypeFunc, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number__CustomTypeFunc, /*tp_as_number*/
  &__pyx_tp_as_sequence__CustomTypeFunc, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__CustomTypeFunc, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_6cpyamf_5codec_15_CustomTypeFunc_1__call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__CustomTypeFunc, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Support for custom type mappings when encoding.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_5codec__CustomTypeFunc, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_5codec__CustomTypeFunc, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_5codec__CustomTypeFunc, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_5codec__CustomTypeFunc, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("codec"),
    __Pyx_DOCSTR(__pyx_k_19), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s__BuiltinFunctionType, __pyx_k__BuiltinFunctionType, sizeof(__pyx_k__BuiltinFunctionType), 0, 0, 1, 1},
  {&__pyx_n_s__ClassAlias, __pyx_k__ClassAlias, sizeof(__pyx_k__ClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s__EOStream, __pyx_k__EOStream, sizeof(__pyx_k__EOStream), 0, 0, 1, 1},
  {&__pyx_n_s__EncodeError, __pyx_k__EncodeError, sizeof(__pyx_k__EncodeError), 0, 0, 1, 1},
  {&__pyx_n_s__GeneratorType, __pyx_k__GeneratorType, sizeof(__pyx_k__GeneratorType), 0, 0, 1, 1},
  {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
  {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__MixedArray, __pyx_k__MixedArray, sizeof(__pyx_k__MixedArray), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__TYPE_MAP, __pyx_k__TYPE_MAP, sizeof(__pyx_k__TYPE_MAP), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__Undefined, __pyx_k__Undefined, sizeof(__pyx_k__Undefined), 0, 0, 1, 1},
  {&__pyx_n_s__UnknownClassAlias, __pyx_k__UnknownClassAlias, sizeof(__pyx_k__UnknownClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___clear, __pyx_k___clear, sizeof(__pyx_k___clear), 0, 0, 1, 1},
  {&__pyx_n_s___increase_size, __pyx_k___increase_size, sizeof(__pyx_k___increase_size), 0, 0, 1, 1},
  {&__pyx_n_s___ref, __pyx_k___ref, sizeof(__pyx_k___ref), 0, 0, 1, 1},
  {&__pyx_n_s___strings, __pyx_k___strings, sizeof(__pyx_k___strings), 0, 0, 1, 1},
  {&__pyx_n_s__addObject, __pyx_k__addObject, sizeof(__pyx_k__addObject), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__at_eof, __pyx_k__at_eof, sizeof(__pyx_k__at_eof), 0, 0, 1, 1},
  {&__pyx_n_s__basestring, __pyx_k__basestring, sizeof(__pyx_k__basestring), 0, 0, 1, 1},
  {&__pyx_n_s__bucket, __pyx_k__bucket, sizeof(__pyx_k__bucket), 0, 0, 1, 1},
  {&__pyx_n_s__callable, __pyx_k__callable, sizeof(__pyx_k__callable), 0, 0, 1, 1},
  {&__pyx_n_s__checkBadTypes, __pyx_k__checkBadTypes, sizeof(__pyx_k__checkBadTypes), 0, 0, 1, 1},
  {&__pyx_n_s__class_aliases, __pyx_k__class_aliases, sizeof(__pyx_k__class_aliases), 0, 0, 1, 1},
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
  {&__pyx_n_s__combine, __pyx_k__combine, sizeof(__pyx_k__combine), 0, 0, 1, 1},
  {&__pyx_n_s__context, __pyx_k__context, sizeof(__pyx_k__context), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__datetime, __pyx_k__datetime, sizeof(__pyx_k__datetime), 0, 0, 1, 1},
  {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__defer, __pyx_k__defer, sizeof(__pyx_k__defer), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__encoder, __pyx_k__encoder, sizeof(__pyx_k__encoder), 0, 0, 1, 1},
  {&__pyx_n_s__external, __pyx_k__external, sizeof(__pyx_k__external), 0, 0, 1, 1},
  {&__pyx_n_s__extra, __pyx_k__extra, sizeof(__pyx_k__extra), 0, 0, 1, 1},
  {&__pyx_n_s__func, __pyx_k__func, sizeof(__pyx_k__func), 0, 0, 1, 1},
  {&__pyx_n_s__func_cache, __pyx_k__func_cache, sizeof(__pyx_k__func_cache), 0, 0, 1, 1},
  {&__pyx_n_s__getByReference, __pyx_k__getByReference, sizeof(__pyx_k__getByReference), 0, 0, 1, 1},
  {&__pyx_n_s__getBytesForString, __pyx_k__getBytesForString, sizeof(__pyx_k__getBytesForString), 0, 0, 1, 1},
  {&__pyx_n_s__getClassAlias, __pyx_k__getClassAlias, sizeof(__pyx_k__getClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s__getObject, __pyx_k__getObject, sizeof(__pyx_k__getObject), 0, 0, 1, 1},
  {&__pyx_n_s__getObjectReference, __pyx_k__getObjectReference, sizeof(__pyx_k__getObjectReference), 0, 0, 1, 1},
  {&__pyx_n_s__getReferenceTo, __pyx_k__getReferenceTo, sizeof(__pyx_k__getReferenceTo), 0, 0, 1, 1},
  {&__pyx_n_s__getStringForBytes, __pyx_k__getStringForBytes, sizeof(__pyx_k__getStringForBytes), 0, 0, 1, 1},
  {&__pyx_n_s__get_class_alias, __pyx_k__get_class_alias, sizeof(__pyx_k__get_class_alias), 0, 0, 1, 1},
  {&__pyx_n_s__get_class_meta, __pyx_k__get_class_meta, sizeof(__pyx_k__get_class_meta), 0, 0, 1, 1},
  {&__pyx_n_s__handleBasicTypes, __pyx_k__handleBasicTypes, sizeof(__pyx_k__handleBasicTypes), 0, 0, 1, 1},
  {&__pyx_n_s__is_proxy, __pyx_k__is_proxy, sizeof(__pyx_k__is_proxy), 0, 0, 1, 1},
  {&__pyx_n_s__is_xml, __pyx_k__is_xml, sizeof(__pyx_k__is_xml), 0, 0, 1, 1},
  {&__pyx_n_s__iteritems, __pyx_k__iteritems, sizeof(__pyx_k__iteritems), 0, 0, 1, 1},
  {&__pyx_n_s__length, __pyx_k__length, sizeof(__pyx_k__length), 0, 0, 1, 1},
  {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1},
  {&__pyx_n_s__o, __pyx_k__o, sizeof(__pyx_k__o), 0, 0, 1, 1},
  {&__pyx_n_s__objects, __pyx_k__objects, sizeof(__pyx_k__objects), 0, 0, 1, 1},
  {&__pyx_n_s__pop, __pyx_k__pop, sizeof(__pyx_k__pop), 0, 0, 1, 1},
  {&__pyx_n_s__pyamf, __pyx_k__pyamf, sizeof(__pyx_k__pyamf), 0, 0, 1, 1},
  {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1},
  {&__pyx_n_s__readConcreteElement, __pyx_k__readConcreteElement, sizeof(__pyx_k__readConcreteElement), 0, 0, 1, 1},
  {&__pyx_n_s__readElement, __pyx_k__readElement, sizeof(__pyx_k__readElement), 0, 0, 1, 1},
  {&__pyx_n_s__readString, __pyx_k__readString, sizeof(__pyx_k__readString), 0, 0, 1, 1},
  {&__pyx_n_s__read_char, __pyx_k__read_char, sizeof(__pyx_k__read_char), 0, 0, 1, 1},
  {&__pyx_n_s__refs, __pyx_k__refs, sizeof(__pyx_k__refs), 0, 0, 1, 1},
  {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1},
  {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1},
  {&__pyx_n_s__serialiseString, __pyx_k__serialiseString, sizeof(__pyx_k__serialiseString), 0, 0, 1, 1},
  {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
  {&__pyx_n_s__stream, __pyx_k__stream, sizeof(__pyx_k__stream), 0, 0, 1, 1},
  {&__pyx_n_s__strict, __pyx_k__strict, sizeof(__pyx_k__strict), 0, 0, 1, 1},
  {&__pyx_n_s__tell, __pyx_k__tell, sizeof(__pyx_k__tell), 0, 0, 1, 1},
  {&__pyx_n_s__time, __pyx_k__time, sizeof(__pyx_k__time), 0, 0, 1, 1},
  {&__pyx_n_s__timezone_offset, __pyx_k__timezone_offset, sizeof(__pyx_k__timezone_offset), 0, 0, 1, 1},
  {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
  {&__pyx_n_s__unicodes, __pyx_k__unicodes, sizeof(__pyx_k__unicodes), 0, 0, 1, 1},
  {&__pyx_n_s__use_hash, __pyx_k__use_hash, sizeof(__pyx_k__use_hash), 0, 0, 1, 1},
  {&__pyx_n_s__use_write_object, __pyx_k__use_write_object, sizeof(__pyx_k__use_write_object), 0, 0, 1, 1},
  {&__pyx_n_s__util, __pyx_k__util, sizeof(__pyx_k__util), 0, 0, 1, 1},
  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
  {&__pyx_n_s__writeBoolean, __pyx_k__writeBoolean, sizeof(__pyx_k__writeBoolean), 0, 0, 1, 1},
  {&__pyx_n_s__writeBytes, __pyx_k__writeBytes, sizeof(__pyx_k__writeBytes), 0, 0, 1, 1},
  {&__pyx_n_s__writeDate, __pyx_k__writeDate, sizeof(__pyx_k__writeDate), 0, 0, 1, 1},
  {&__pyx_n_s__writeDateTime, __pyx_k__writeDateTime, sizeof(__pyx_k__writeDateTime), 0, 0, 1, 1},
  {&__pyx_n_s__writeDict, __pyx_k__writeDict, sizeof(__pyx_k__writeDict), 0, 0, 1, 1},
  {&__pyx_n_s__writeElement, __pyx_k__writeElement, sizeof(__pyx_k__writeElement), 0, 0, 1, 1},
  {&__pyx_n_s__writeGenerator, __pyx_k__writeGenerator, sizeof(__pyx_k__writeGenerator), 0, 0, 1, 1},
  {&__pyx_n_s__writeInt, __pyx_k__writeInt, sizeof(__pyx_k__writeInt), 0, 0, 1, 1},
  {&__pyx_n_s__writeList, __pyx_k__writeList, sizeof(__pyx_k__writeList), 0, 0, 1, 1},
  {&__pyx_n_s__writeLong, __pyx_k__writeLong, sizeof(__pyx_k__writeLong), 0, 0, 1, 1},
  {&__pyx_n_s__writeMixedArray, __pyx_k__writeMixedArray, sizeof(__pyx_k__writeMixedArray), 0, 0, 1, 1},
  {&__pyx_n_s__writeNull, __pyx_k__writeNull, sizeof(__pyx_k__writeNull), 0, 0, 1, 1},
  {&__pyx_n_s__writeNumber, __pyx_k__writeNumber, sizeof(__pyx_k__writeNumber), 0, 0, 1, 1},
  {&__pyx_n_s__writeObject, __pyx_k__writeObject, sizeof(__pyx_k__writeObject), 0, 0, 1, 1},
  {&__pyx_n_s__writeSequence, __pyx_k__writeSequence, sizeof(__pyx_k__writeSequence), 0, 0, 1, 1},
  {&__pyx_n_s__writeString, __pyx_k__writeString, sizeof(__pyx_k__writeString), 0, 0, 1, 1},
  {&__pyx_n_s__writeTuple, __pyx_k__writeTuple, sizeof(__pyx_k__writeTuple), 0, 0, 1, 1},
  {&__pyx_n_s__writeUndefined, __pyx_k__writeUndefined, sizeof(__pyx_k__writeUndefined), 0, 0, 1, 1},
  {&__pyx_n_s__writeXML, __pyx_k__writeXML, sizeof(__pyx_k__writeXML), 0, 0, 1, 1},
  {&__pyx_n_s__xml, __pyx_k__xml, sizeof(__pyx_k__xml), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_basestring = __Pyx_GetName(__pyx_b, __pyx_n_s__basestring); if (!__pyx_builtin_basestring) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_callable = __Pyx_GetName(__pyx_b, __pyx_n_s__callable); if (!__pyx_builtin_callable) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "cpyamf/codec.pyx":272
 *             return ret
 * 
 *         cdef unicode u = s.decode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self.unicodes[s] = u
 */
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));

  /* "cpyamf/codec.pyx":291
 *             return ret
 * 
 *         cdef str s = u.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self.unicodes[s] = u
 */
  __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "cpyamf/codec.pyx":448
 * 
 *     cdef int writeDate(self, object o) except -1:
 *         o = datetime.datetime.combine(o, datetime.time(0, 0, 0, 0))             # <<<<<<<<<<<<<<
 * 
 *         self.writeDateTime(o)
 */
  __pyx_k_tuple_7 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 3, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));

  /* "cpyamf/codec.pyx":544
 *     cdef int checkBadTypes(self, object element, object py_type) except -1:
 *         if PyModule_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode modules")             # <<<<<<<<<<<<<<
 *         elif PyMethod_Check(element):
 *             raise pyamf.EncodeError("Cannot encode methods")
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

  /* "cpyamf/codec.pyx":546
 *             raise pyamf.EncodeError("Cannot encode modules")
 *         elif PyMethod_Check(element):
 *             raise pyamf.EncodeError("Cannot encode methods")             # <<<<<<<<<<<<<<
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 *             raise pyamf.EncodeError("Cannot encode functions")
 */
  __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_11));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
  PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));

  /* "cpyamf/codec.pyx":548
 *             raise pyamf.EncodeError("Cannot encode methods")
 *         elif PyFunction_Check(element) or py_type is BuiltinFunctionType:
 *             raise pyamf.EncodeError("Cannot encode functions")             # <<<<<<<<<<<<<<
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode class objects")
 */
  __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_13));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
  PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));

  /* "cpyamf/codec.pyx":550
 *             raise pyamf.EncodeError("Cannot encode functions")
 *         elif PyClass_Check(element) or PyType_CheckExact(element):
 *             raise pyamf.EncodeError("Cannot encode class objects")             # <<<<<<<<<<<<<<
 *         elif PyTime_CheckExact(element):
 *             raise pyamf.EncodeError('A datetime.time instance was found but '
 */
  __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
  PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));

  /* "cpyamf/codec.pyx":552
 *             raise pyamf.EncodeError("Cannot encode class objects")
 *         elif PyTime_CheckExact(element):
 *             raise pyamf.EncodeError('A datetime.time instance was found but '             # <<<<<<<<<<<<<<
 *                 'AMF has no way to encode time objects. Please use '
 *                 'datetime.datetime instead')
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));

  /* "cpyamf/codec.pyx":599
 * 
 *         try:
 *             element = self.bucket.pop(0)             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             raise StopIteration
 */
  __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_18));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcodec(void); /*proto*/
PyMODINIT_FUNC initcodec(void)
#else
PyMODINIT_FUNC PyInit_codec(void); /*proto*/
PyMODINIT_FUNC PyInit_codec(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_codec(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("codec"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_19), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __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;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_cpyamf__codec) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____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;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_6cpyamf_5codec_MixedArray = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_5codec_Undefined = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_5codec_BuiltinFunctionType = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_5codec_GeneratorType = Py_None; Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6cpyamf_5codec_IndexedCollection = &__pyx_vtable_6cpyamf_5codec_IndexedCollection;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection._actually_increase_size = (int (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *))__pyx_f_6cpyamf_5codec_17IndexedCollection__actually_increase_size;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection._increase_size = (int (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *))__pyx_f_6cpyamf_5codec_17IndexedCollection__increase_size;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection._clear = (void (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *))__pyx_f_6cpyamf_5codec_17IndexedCollection__clear;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection.clear = (int (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_17IndexedCollection_clear;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection._ref = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *))__pyx_f_6cpyamf_5codec_17IndexedCollection__ref;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection.getByReference = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_17IndexedCollection_getByReference;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection.getReferenceTo = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_17IndexedCollection_getReferenceTo;
  __pyx_vtable_6cpyamf_5codec_IndexedCollection.append = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_5codec_IndexedCollection *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_17IndexedCollection_append;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec_IndexedCollection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_5codec_IndexedCollection.tp_dict, __pyx_vtabptr_6cpyamf_5codec_IndexedCollection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "IndexedCollection", (PyObject *)&__pyx_type_6cpyamf_5codec_IndexedCollection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_IndexedCollection = &__pyx_type_6cpyamf_5codec_IndexedCollection;
  __pyx_vtabptr_6cpyamf_5codec_Context = &__pyx_vtable_6cpyamf_5codec_Context;
  __pyx_vtable_6cpyamf_5codec_Context.clear = (int (*)(struct __pyx_obj_6cpyamf_5codec_Context *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_clear;
  __pyx_vtable_6cpyamf_5codec_Context.getClassAlias = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_getClassAlias;
  __pyx_vtable_6cpyamf_5codec_Context.getObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Context *, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_getObject;
  __pyx_vtable_6cpyamf_5codec_Context.getObjectReference = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_getObjectReference;
  __pyx_vtable_6cpyamf_5codec_Context.addObject = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_addObject;
  __pyx_vtable_6cpyamf_5codec_Context.getStringForBytes = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_getStringForBytes;
  __pyx_vtable_6cpyamf_5codec_Context.getBytesForString = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Context_getBytesForString;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_5codec_Context.tp_dict, __pyx_vtabptr_6cpyamf_5codec_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_6cpyamf_5codec_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_Context = &__pyx_type_6cpyamf_5codec_Context;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec_Codec) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Codec", (PyObject *)&__pyx_type_6cpyamf_5codec_Codec) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_Codec = &__pyx_type_6cpyamf_5codec_Codec;
  __pyx_vtabptr_6cpyamf_5codec_Decoder = &__pyx_vtable_6cpyamf_5codec_Decoder;
  __pyx_vtable_6cpyamf_5codec_Decoder.readDate = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readDate;
  __pyx_vtable_6cpyamf_5codec_Decoder.readString = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Decoder_readString;
  __pyx_vtable_6cpyamf_5codec_Decoder.readObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readObject;
  __pyx_vtable_6cpyamf_5codec_Decoder.readNumber = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readNumber;
  __pyx_vtable_6cpyamf_5codec_Decoder.readNull = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readNull;
  __pyx_vtable_6cpyamf_5codec_Decoder.readUndefined = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readUndefined;
  __pyx_vtable_6cpyamf_5codec_Decoder.readList = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readList;
  __pyx_vtable_6cpyamf_5codec_Decoder.readXML = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_5codec_7Decoder_readXML;
  __pyx_vtable_6cpyamf_5codec_Decoder.readElement = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Decoder_readElement;
  __pyx_vtable_6cpyamf_5codec_Decoder.readConcreteElement = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, char))__pyx_f_6cpyamf_5codec_7Decoder_readConcreteElement;
  __pyx_vtable_6cpyamf_5codec_Decoder.send = (int (*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Decoder_send;
  __pyx_type_6cpyamf_5codec_Decoder.tp_base = __pyx_ptype_6cpyamf_5codec_Codec;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6cpyamf_5codec_Decoder, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6cpyamf_5codec_7Decoder_3__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6cpyamf_5codec_7Decoder_3__next__.doc = __pyx_doc_6cpyamf_5codec_7Decoder_3__next__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6cpyamf_5codec_7Decoder_3__next__;
    }
  }
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_5codec_Decoder.tp_dict, __pyx_vtabptr_6cpyamf_5codec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_6cpyamf_5codec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_Decoder = &__pyx_type_6cpyamf_5codec_Decoder;
  __pyx_vtabptr_6cpyamf_5codec_Encoder = &__pyx_vtable_6cpyamf_5codec_Encoder;
  __pyx_vtable_6cpyamf_5codec_Encoder.serialiseString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Encoder_serialiseString;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeType = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, char))__pyx_f_6cpyamf_5codec_7Encoder_writeType;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeNull = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeNull;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeUndefined = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeUndefined;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeString;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeBytes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeBytes;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeBoolean = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeBoolean;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeInt = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeInt;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeLong = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeLong;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeNumber = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeNumber;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeDateTime = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeDateTime;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeDate = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeDate;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeXML = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeXML;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeList = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeList *__pyx_optional_args))__pyx_f_6cpyamf_5codec_7Encoder_writeList;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeTuple = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeTuple;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeSequence = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeSequence;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeObject = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject *__pyx_optional_args))__pyx_f_6cpyamf_5codec_7Encoder_writeObject;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeDict = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeDict;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeMixedArray = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeMixedArray;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeGenerator = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_writeGenerator;
  __pyx_vtable_6cpyamf_5codec_Encoder.handleBasicTypes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_handleBasicTypes;
  __pyx_vtable_6cpyamf_5codec_Encoder.checkBadTypes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *))__pyx_f_6cpyamf_5codec_7Encoder_checkBadTypes;
  __pyx_vtable_6cpyamf_5codec_Encoder.writeElement = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Encoder_writeElement;
  __pyx_vtable_6cpyamf_5codec_Encoder.send = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_5codec_7Encoder_send;
  __pyx_type_6cpyamf_5codec_Encoder.tp_base = __pyx_ptype_6cpyamf_5codec_Codec;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6cpyamf_5codec_Encoder, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6cpyamf_5codec_7Encoder_6__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6cpyamf_5codec_7Encoder_6__next__.doc = __pyx_doc_6cpyamf_5codec_7Encoder_6__next__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6cpyamf_5codec_7Encoder_6__next__;
    }
  }
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_5codec_Encoder.tp_dict, __pyx_vtabptr_6cpyamf_5codec_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Encoder", (PyObject *)&__pyx_type_6cpyamf_5codec_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_Encoder = &__pyx_type_6cpyamf_5codec_Encoder;
  if (PyType_Ready(&__pyx_type_6cpyamf_5codec__CustomTypeFunc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_CustomTypeFunc", (PyObject *)&__pyx_type_6cpyamf_5codec__CustomTypeFunc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec__CustomTypeFunc = &__pyx_type_6cpyamf_5codec__CustomTypeFunc;
  /*--- Type import code ---*/
  __pyx_ptype_6cpyamf_4util_cBufferedByteStream = __Pyx_ImportType("cpyamf.util", "cBufferedByteStream", sizeof(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream), 1); if (unlikely(!__pyx_ptype_6cpyamf_4util_cBufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4util_cBufferedByteStream = (struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4util_cBufferedByteStream->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4util_cBufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4util_BufferedByteStream = __Pyx_ImportType("cpyamf.util", "BufferedByteStream", sizeof(struct __pyx_obj_6cpyamf_4util_BufferedByteStream), 1); if (unlikely(!__pyx_ptype_6cpyamf_4util_BufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4util_BufferedByteStream = (struct __pyx_vtabstruct_6cpyamf_4util_BufferedByteStream*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4util_BufferedByteStream->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4util_BufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "cpyamf/codec.pyx":24
 * from cpyamf.util cimport cBufferedByteStream, BufferedByteStream
 * 
 * import types             # <<<<<<<<<<<<<<
 * import pyamf
 * from pyamf import util, xml
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":25
 * 
 * import types
 * import pyamf             # <<<<<<<<<<<<<<
 * from pyamf import util, xml
 * import datetime
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pyamf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":26
 * import types
 * import pyamf
 * from pyamf import util, xml             # <<<<<<<<<<<<<<
 * import datetime
 * 
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__util));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__util));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__util));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xml));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__xml));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xml));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__util); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__util, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__xml); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__xml, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":27
 * import pyamf
 * from pyamf import util, xml
 * import datetime             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__datetime), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__datetime, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":30
 * 
 * 
 * cdef object MixedArray = pyamf.MixedArray             # <<<<<<<<<<<<<<
 * cdef object Undefined = pyamf.Undefined
 * cdef object BuiltinFunctionType = types.BuiltinFunctionType
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__MixedArray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_5codec_MixedArray);
  __Pyx_DECREF(__pyx_v_6cpyamf_5codec_MixedArray);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_5codec_MixedArray = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":31
 * 
 * cdef object MixedArray = pyamf.MixedArray
 * cdef object Undefined = pyamf.Undefined             # <<<<<<<<<<<<<<
 * cdef object BuiltinFunctionType = types.BuiltinFunctionType
 * cdef object GeneratorType = types.GeneratorType
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__Undefined); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_5codec_Undefined);
  __Pyx_DECREF(__pyx_v_6cpyamf_5codec_Undefined);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6cpyamf_5codec_Undefined = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":32
 * cdef object MixedArray = pyamf.MixedArray
 * cdef object Undefined = pyamf.Undefined
 * cdef object BuiltinFunctionType = types.BuiltinFunctionType             # <<<<<<<<<<<<<<
 * cdef object GeneratorType = types.GeneratorType
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__BuiltinFunctionType); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_5codec_BuiltinFunctionType);
  __Pyx_DECREF(__pyx_v_6cpyamf_5codec_BuiltinFunctionType);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_5codec_BuiltinFunctionType = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/codec.pyx":33
 * cdef object Undefined = pyamf.Undefined
 * cdef object BuiltinFunctionType = types.BuiltinFunctionType
 * cdef object GeneratorType = types.GeneratorType             # <<<<<<<<<<<<<<
 * 
 * PyDateTime_IMPORT
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__GeneratorType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_5codec_GeneratorType);
  __Pyx_DECREF(__pyx_v_6cpyamf_5codec_GeneratorType);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6cpyamf_5codec_GeneratorType = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":35
 * cdef object GeneratorType = types.GeneratorType
 * 
 * PyDateTime_IMPORT             # <<<<<<<<<<<<<<
 * 
 * 
 */
  PyDateTime_IMPORT;

  /* "cpyamf/codec.pyx":53
 *         self.length = -1
 * 
 *     def __init__(self, use_hash=False):             # <<<<<<<<<<<<<<
 *         self.use_hash = use_hash
 * 
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_1 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":320
 *         self.timezone_offset = None
 * 
 *     def __init__(self, stream=None, strict=False, timezone_offset=None):             # <<<<<<<<<<<<<<
 *         if not isinstance(stream, BufferedByteStream):
 *             stream = BufferedByteStream(stream)
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_6 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpyamf/codec.pyx":1
 * # cython: boundscheck=False             # <<<<<<<<<<<<<<
 * # Copyright (c) The PyAMF Project.
 * # See LICENSE.txt for details.
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "cpython/type.pxd":2
 * 
 * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
 *     # The C structure of the objects used to describe built-in types.
 * 
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    __Pyx_AddTraceback("init cpyamf.codec");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cpyamf.codec");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
            "too many values to unpack (expected %d)", (int)expected);
        #else
            "too many values to unpack (expected %zd)", expected);
        #endif
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = PyObject_GetAttr(o, n);
    if (!r) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return NULL;
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    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) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
