/* Generated by Cython 0.14.1 on Mon Feb 28 08:49:26 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__amf0
#include "stdio.h"
#include "pythread.h"
#include "stdlib.h"
#include "string.h"
#include "math.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[] = {
  "amf0.pyx",
  "bool.pxd",
  "complex.pxd",
  "util.pxd",
  "codec.pxd",
  "amf3.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;
};

/* "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;
};

/* "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;
};

/* "amf3.pxd":51
 * 
 *     cdef object readBytes(self)
 *     cdef object readInteger(self, int signed=?)             # <<<<<<<<<<<<<<
 *     cdef object readByteArray(self)
 *     cdef object readProxy(self, obj)
 */

struct __pyx_opt_args_6cpyamf_4amf3_7Decoder_readInteger {
  int __pyx_n;
  int __pyx_signed;
};

/* "cpyamf/amf0.pyx":230
 *         return d
 * 
 *     cdef object readLongString(self, bint bytes=0):             # <<<<<<<<<<<<<<
 *         cdef unsigned long l
 *         cdef char *b = NULL
 */

struct __pyx_opt_args_6cpyamf_4amf0_7Decoder_readLongString {
  int __pyx_n;
  int bytes;
};

/* "cpyamf/amf0.pyx":351
 *         return self.writeType(TYPE_NULL)
 * 
 *     cpdef int writeList(self, object a, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write array to the stream.
 */

struct __pyx_opt_args_6cpyamf_4amf0_7Encoder_writeList {
  int __pyx_n;
  int is_proxy;
};

/* "cpyamf/amf0.pyx":512
 *         return self.stream.write('\x00\x00\x09', 3)
 * 
 *     cpdef int writeObject(self, o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write a Python object to the stream.
 */

struct __pyx_opt_args_6cpyamf_4amf0_7Encoder_writeObject {
  int __pyx_n;
  int is_proxy;
};

/* "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;
};

/* "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;
};

/* "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/amf0.pyx":47
 * 
 * 
 * cdef class Context(codec.Context):             # <<<<<<<<<<<<<<
 *     cdef amf3.Context amf3_context
 * 
 */

struct __pyx_obj_6cpyamf_4amf0_Context {
  struct __pyx_obj_6cpyamf_5codec_Context __pyx_base;
  struct __pyx_obj_6cpyamf_4amf3_Context *amf3_context;
};

/* "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;
};

/* "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/amf0.pyx":299
 * 
 * 
 * cdef class Encoder(codec.Encoder):             # <<<<<<<<<<<<<<
 *     """
 *     The AMF0 Encoder.
 */

struct __pyx_obj_6cpyamf_4amf0_Encoder {
  struct __pyx_obj_6cpyamf_5codec_Encoder __pyx_base;
  int use_amf3;
  struct __pyx_obj_6cpyamf_4amf0_Context *context;
  struct __pyx_obj_6cpyamf_4amf3_Encoder *amf3_encoder;
};

/* "cpyamf/amf0.pyx":59
 * 
 * 
 * cdef class Decoder(codec.Decoder):             # <<<<<<<<<<<<<<
 *     """
 *     """
 */

struct __pyx_obj_6cpyamf_4amf0_Decoder {
  struct __pyx_obj_6cpyamf_5codec_Decoder __pyx_base;
  int use_amf3;
  struct __pyx_obj_6cpyamf_4amf0_Context *context;
  struct __pyx_obj_6cpyamf_4amf3_Decoder *amf3_decoder;
};

/* "amf3.pxd":42
 * 
 * 
 * cdef class Decoder(codec.Decoder):             # <<<<<<<<<<<<<<
 *     cdef public bint use_proxies
 *     cdef readonly Context context
 */

struct __pyx_obj_6cpyamf_4amf3_Decoder {
  struct __pyx_obj_6cpyamf_5codec_Decoder __pyx_base;
  int use_proxies;
  struct __pyx_obj_6cpyamf_4amf3_Context *context;
};

/* "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;
};

/* "amf3.pxd":56
 * 
 * 
 * cdef class Encoder(codec.Encoder):             # <<<<<<<<<<<<<<
 *     cdef public bint use_proxies
 *     cdef readonly Context context
 */

struct __pyx_obj_6cpyamf_4amf3_Encoder {
  struct __pyx_obj_6cpyamf_5codec_Encoder __pyx_base;
  int use_proxies;
  struct __pyx_obj_6cpyamf_4amf3_Context *context;
};

/* "amf3.pxd":22
 * 
 * 
 * cdef class Context(codec.Context):             # <<<<<<<<<<<<<<
 *     cdef codec.IndexedCollection strings
 *     cdef dict classes
 */

struct __pyx_obj_6cpyamf_4amf3_Context {
  struct __pyx_obj_6cpyamf_5codec_Context __pyx_base;
  struct __pyx_obj_6cpyamf_5codec_IndexedCollection *strings;
  PyObject *classes;
  PyObject *class_ref;
  PyObject *proxied_objects;
  Py_ssize_t class_idx;
};

/* "amf3.pxd":4
 * 
 * 
 * cdef class ClassDefinition(object):             # <<<<<<<<<<<<<<
 *     """
 *     Holds transient class trait info for an individual encode/decode.
 */

struct __pyx_obj_6cpyamf_4amf3_ClassDefinition {
  PyObject_HEAD
  struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition *__pyx_vtab;
  PyObject *alias;
  Py_ssize_t ref;
  Py_ssize_t attr_len;
  int encoding;
  char *encoded_ref;
  Py_ssize_t encoded_ref_size;
  PyObject *static_properties;
};


struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition {
  int (*writeReference)(struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *);
};
static struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition *__pyx_vtabptr_6cpyamf_4amf3_ClassDefinition;


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

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;


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

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;


/* "cpyamf/amf0.pyx":47
 * 
 * 
 * cdef class Context(codec.Context):             # <<<<<<<<<<<<<<
 *     cdef amf3.Context amf3_context
 * 
 */

struct __pyx_vtabstruct_6cpyamf_4amf0_Context {
  struct __pyx_vtabstruct_6cpyamf_5codec_Context __pyx_base;
};
static struct __pyx_vtabstruct_6cpyamf_4amf0_Context *__pyx_vtabptr_6cpyamf_4amf0_Context;


/* "amf3.pxd":22
 * 
 * 
 * cdef class Context(codec.Context):             # <<<<<<<<<<<<<<
 *     cdef codec.IndexedCollection strings
 *     cdef dict classes
 */

struct __pyx_vtabstruct_6cpyamf_4amf3_Context {
  struct __pyx_vtabstruct_6cpyamf_5codec_Context __pyx_base;
  PyObject *(*getString)(struct __pyx_obj_6cpyamf_4amf3_Context *, Py_ssize_t, int __pyx_skip_dispatch);
  Py_ssize_t (*getStringReference)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch);
  Py_ssize_t (*addString)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch);
  int (*addProxyObject)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getProxyForObject)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getObjectForProxy)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*getClassByReference)(struct __pyx_obj_6cpyamf_4amf3_Context *, Py_ssize_t, int __pyx_skip_dispatch);
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *(*getClass)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch);
  Py_ssize_t (*addClass)(struct __pyx_obj_6cpyamf_4amf3_Context *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_6cpyamf_4amf3_Context *__pyx_vtabptr_6cpyamf_4amf3_Context;


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

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;


/* "amf3.pxd":56
 * 
 * 
 * cdef class Encoder(codec.Encoder):             # <<<<<<<<<<<<<<
 *     cdef public bint use_proxies
 *     cdef readonly Context context
 */

struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder {
  struct __pyx_vtabstruct_6cpyamf_5codec_Encoder __pyx_base;
  int (*writeByteArray)(struct __pyx_obj_6cpyamf_4amf3_Encoder *, PyObject *);
  int (*writeProxy)(struct __pyx_obj_6cpyamf_4amf3_Encoder *, PyObject *);
};
static struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *__pyx_vtabptr_6cpyamf_4amf3_Encoder;


/* "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;


/* "amf3.pxd":42
 * 
 * 
 * cdef class Decoder(codec.Decoder):             # <<<<<<<<<<<<<<
 *     cdef public bint use_proxies
 *     cdef readonly Context context
 */

struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder {
  struct __pyx_vtabstruct_6cpyamf_5codec_Decoder __pyx_base;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *(*_getClassDefinition)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, long);
  int (*_readStatic)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *);
  int (*_readDynamic)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *);
  PyObject *(*readBytes)(struct __pyx_obj_6cpyamf_4amf3_Decoder *);
  PyObject *(*readInteger)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_opt_args_6cpyamf_4amf3_7Decoder_readInteger *__pyx_optional_args);
  PyObject *(*readByteArray)(struct __pyx_obj_6cpyamf_4amf3_Decoder *);
  PyObject *(*readProxy)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, PyObject *);
};
static struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *__pyx_vtabptr_6cpyamf_4amf3_Decoder;


/* "codec.pxd":11
 * from cpyamf cimport util
 * 
 * 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;


/* "cpyamf/amf0.pyx":59
 * 
 * 
 * cdef class Decoder(codec.Decoder):             # <<<<<<<<<<<<<<
 *     """
 *     """
 */

struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder {
  struct __pyx_vtabstruct_6cpyamf_5codec_Decoder __pyx_base;
  PyObject *(*readBoolean)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
  PyObject *(*readBytes)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
  PyObject *(*readObjectAttributes)(struct __pyx_obj_6cpyamf_4amf0_Decoder *, PyObject *);
  PyObject *(*readTypedObject)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
  PyObject *(*readReference)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
  PyObject *(*readMixedArray)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
  PyObject *(*readLongString)(struct __pyx_obj_6cpyamf_4amf0_Decoder *, struct __pyx_opt_args_6cpyamf_4amf0_7Decoder_readLongString *__pyx_optional_args);
  PyObject *(*readAMF3)(struct __pyx_obj_6cpyamf_4amf0_Decoder *);
};
static struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *__pyx_vtabptr_6cpyamf_4amf0_Decoder;


/* "cpyamf/amf0.pyx":299
 * 
 * 
 * cdef class Encoder(codec.Encoder):             # <<<<<<<<<<<<<<
 *     """
 *     The AMF0 Encoder.
 */

struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder {
  struct __pyx_vtabstruct_6cpyamf_5codec_Encoder __pyx_base;
  int (*writeReference)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *);
  int (*_writeDict)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *);
  int (*_writeEndObject)(struct __pyx_obj_6cpyamf_4amf0_Encoder *);
  int (*writeAMF3)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *);
};
static struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *__pyx_vtabptr_6cpyamf_4amf0_Encoder;


/* "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;

#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_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

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

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

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*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 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 CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

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 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 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 int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* 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 libc.stdlib */

/* Module declarations from libc.string */

/* 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 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;
/* Module declarations from cpyamf.amf3 */

static PyTypeObject *__pyx_ptype_6cpyamf_4amf3_ClassDefinition = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4amf3_Context = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4amf3_Decoder = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4amf3_Encoder = 0;
/* Module declarations from cpyamf.amf0 */

static PyTypeObject *__pyx_ptype_6cpyamf_4amf0_Context = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4amf0_Decoder = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4amf0_Encoder = 0;
static char __pyx_v_6cpyamf_4amf0_TYPE_NUMBER;
static char __pyx_v_6cpyamf_4amf0_TYPE_BOOL;
static char __pyx_v_6cpyamf_4amf0_TYPE_STRING;
static char __pyx_v_6cpyamf_4amf0_TYPE_OBJECT;
static char __pyx_v_6cpyamf_4amf0_TYPE_MOVIECLIP;
static char __pyx_v_6cpyamf_4amf0_TYPE_NULL;
static char __pyx_v_6cpyamf_4amf0_TYPE_UNDEFINED;
static char __pyx_v_6cpyamf_4amf0_TYPE_REFERENCE;
static char __pyx_v_6cpyamf_4amf0_TYPE_MIXEDARRAY;
static char __pyx_v_6cpyamf_4amf0_TYPE_OBJECTTERM;
static char __pyx_v_6cpyamf_4amf0_TYPE_ARRAY;
static char __pyx_v_6cpyamf_4amf0_TYPE_DATE;
static char __pyx_v_6cpyamf_4amf0_TYPE_LONGSTRING;
static char __pyx_v_6cpyamf_4amf0_TYPE_UNSUPPORTED;
static char __pyx_v_6cpyamf_4amf0_TYPE_RECORDSET;
static char __pyx_v_6cpyamf_4amf0_TYPE_XML;
static char __pyx_v_6cpyamf_4amf0_TYPE_TYPEDOBJECT;
static char __pyx_v_6cpyamf_4amf0_TYPE_AMF3;
static PyObject *__pyx_v_6cpyamf_4amf0_ASObject = 0;
static PyObject *__pyx_v_6cpyamf_4amf0_UnknownClassAlias = 0;
#define __Pyx_MODULE_NAME "cpyamf.amf0"
static int __pyx_module_is_main_cpyamf__amf0 = 0;

/* Implementation of cpyamf.amf0 */
static PyObject *__pyx_builtin_OverflowError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_max;
static char __pyx_k_3[] = "Bad boolean read from stream";
static char __pyx_k_5[] = "\000\000\t";
static char __pyx_k_6[] = "readObjectAttributes";
static char __pyx_k_7[] = "TypedObjectClassAlias";
static char __pyx_k_8[] = "Unknown reference %d";
static char __pyx_k_9[] = "Unsupported ActionScript type";
static char __pyx_k_13[] = "utf-8";
static char __pyx_k_15[] = "expected str from xml.tostring";
static char __pyx_k_17[] = "\000\000";
static char __pyx_k_18[] = "getEncodableAttributes";
static char __pyx_k_19[] = "\nC-extension for L{pyamf.amf3} Python module in L{PyAMF<pyamf>}.\n\n:since: 0.6\n";
static char __pyx_k__a[] = "a";
static char __pyx_k__o[] = "o";
static char __pyx_k__max[] = "max";
static char __pyx_k__pop[] = "pop";
static char __pyx_k__xml[] = "xml";
static char __pyx_k__amf3[] = "amf3";
static char __pyx_k__peek[] = "peek";
static char __pyx_k__read[] = "read";
static char __pyx_k__seek[] = "seek";
static char __pyx_k__util[] = "util";
static char __pyx_k__alias[] = "alias";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__codec[] = "codec";
static char __pyx_k__items[] = "items";
static char __pyx_k__pyamf[] = "pyamf";
static char __pyx_k__write[] = "write";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__stream[] = "stream";
static char __pyx_k__strict[] = "strict";
static char __pyx_k__compile[] = "compile";
static char __pyx_k__context[] = "context";
static char __pyx_k__readXML[] = "readXML";
static char __pyx_k__ASObject[] = "ASObject";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__is_proxy[] = "is_proxy";
static char __pyx_k__readAMF3[] = "readAMF3";
static char __pyx_k__readDate[] = "readDate";
static char __pyx_k__readList[] = "readList";
static char __pyx_k__readNull[] = "readNull";
static char __pyx_k__tostring[] = "tostring";
static char __pyx_k__use_amf3[] = "use_amf3";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k__addObject[] = "addObject";
static char __pyx_k__anonymous[] = "anonymous";
static char __pyx_k__getObject[] = "getObject";
static char __pyx_k__readBytes[] = "readBytes";
static char __pyx_k__writeAMF3[] = "writeAMF3";
static char __pyx_k__writeList[] = "writeList";
static char __pyx_k__writeType[] = "writeType";
static char __pyx_k__MixedArray[] = "MixedArray";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k___writeDict[] = "_writeDict";
static char __pyx_k__fromstring[] = "fromstring";
static char __pyx_k__readNumber[] = "readNumber";
static char __pyx_k__readObject[] = "readObject";
static char __pyx_k__readString[] = "readString";
static char __pyx_k__read_short[] = "read_short";
static char __pyx_k__read_uchar[] = "read_uchar";
static char __pyx_k__read_ulong[] = "read_ulong";
static char __pyx_k__writeBytes[] = "writeBytes";
static char __pyx_k__DecodeError[] = "DecodeError";
static char __pyx_k__readBoolean[] = "readBoolean";
static char __pyx_k__readElement[] = "readElement";
static char __pyx_k__read_double[] = "read_double";
static char __pyx_k__read_ushort[] = "read_ushort";
static char __pyx_k__writeObject[] = "writeObject";
static char __pyx_k__write_ulong[] = "write_ulong";
static char __pyx_k__amf3_context[] = "amf3_context";
static char __pyx_k__amf3_decoder[] = "amf3_decoder";
static char __pyx_k__amf3_encoder[] = "amf3_encoder";
static char __pyx_k__get_datetime[] = "get_datetime";
static char __pyx_k__static_attrs[] = "static_attrs";
static char __pyx_k__writeElement[] = "writeElement";
static char __pyx_k__write_double[] = "write_double";
static char __pyx_k__write_ushort[] = "write_ushort";
static char __pyx_k__OverflowError[] = "OverflowError";
static char __pyx_k__getClassAlias[] = "getClassAlias";
static char __pyx_k__get_timestamp[] = "get_timestamp";
static char __pyx_k__readReference[] = "readReference";
static char __pyx_k__readUndefined[] = "readUndefined";
static char __pyx_k__ReferenceError[] = "ReferenceError";
static char __pyx_k__createInstance[] = "createInstance";
static char __pyx_k__readLongString[] = "readLongString";
static char __pyx_k__readMixedArray[] = "readMixedArray";
static char __pyx_k__writeReference[] = "writeReference";
static char __pyx_k___writeEndObject[] = "_writeEndObject";
static char __pyx_k__applyAttributes[] = "applyAttributes";
static char __pyx_k__readTypedObject[] = "readTypedObject";
static char __pyx_k__serialiseString[] = "serialiseString";
static char __pyx_k__timezone_offset[] = "timezone_offset";
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 PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_n_s_18;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_n_s_6;
static PyObject *__pyx_n_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__ASObject;
static PyObject *__pyx_n_s__DecodeError;
static PyObject *__pyx_n_s__MixedArray;
static PyObject *__pyx_n_s__OverflowError;
static PyObject *__pyx_n_s__ReferenceError;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__UnknownClassAlias;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___writeDict;
static PyObject *__pyx_n_s___writeEndObject;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__addObject;
static PyObject *__pyx_n_s__alias;
static PyObject *__pyx_n_s__amf3;
static PyObject *__pyx_n_s__amf3_context;
static PyObject *__pyx_n_s__amf3_decoder;
static PyObject *__pyx_n_s__amf3_encoder;
static PyObject *__pyx_n_s__anonymous;
static PyObject *__pyx_n_s__applyAttributes;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__codec;
static PyObject *__pyx_n_s__compile;
static PyObject *__pyx_n_s__context;
static PyObject *__pyx_n_s__createInstance;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__fromstring;
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__getStringForBytes;
static PyObject *__pyx_n_s__get_datetime;
static PyObject *__pyx_n_s__get_timestamp;
static PyObject *__pyx_n_s__is_proxy;
static PyObject *__pyx_n_s__items;
static PyObject *__pyx_n_s__max;
static PyObject *__pyx_n_s__o;
static PyObject *__pyx_n_s__peek;
static PyObject *__pyx_n_s__pop;
static PyObject *__pyx_n_s__pyamf;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__readAMF3;
static PyObject *__pyx_n_s__readBoolean;
static PyObject *__pyx_n_s__readBytes;
static PyObject *__pyx_n_s__readDate;
static PyObject *__pyx_n_s__readElement;
static PyObject *__pyx_n_s__readList;
static PyObject *__pyx_n_s__readLongString;
static PyObject *__pyx_n_s__readMixedArray;
static PyObject *__pyx_n_s__readNull;
static PyObject *__pyx_n_s__readNumber;
static PyObject *__pyx_n_s__readObject;
static PyObject *__pyx_n_s__readReference;
static PyObject *__pyx_n_s__readString;
static PyObject *__pyx_n_s__readTypedObject;
static PyObject *__pyx_n_s__readUndefined;
static PyObject *__pyx_n_s__readXML;
static PyObject *__pyx_n_s__read_double;
static PyObject *__pyx_n_s__read_short;
static PyObject *__pyx_n_s__read_uchar;
static PyObject *__pyx_n_s__read_ulong;
static PyObject *__pyx_n_s__read_ushort;
static PyObject *__pyx_n_s__seek;
static PyObject *__pyx_n_s__serialiseString;
static PyObject *__pyx_n_s__static_attrs;
static PyObject *__pyx_n_s__stream;
static PyObject *__pyx_n_s__strict;
static PyObject *__pyx_n_s__timezone_offset;
static PyObject *__pyx_n_s__tostring;
static PyObject *__pyx_n_s__use_amf3;
static PyObject *__pyx_n_s__util;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__writeAMF3;
static PyObject *__pyx_n_s__writeBytes;
static PyObject *__pyx_n_s__writeElement;
static PyObject *__pyx_n_s__writeList;
static PyObject *__pyx_n_s__writeObject;
static PyObject *__pyx_n_s__writeReference;
static PyObject *__pyx_n_s__writeType;
static PyObject *__pyx_n_s__write_double;
static PyObject *__pyx_n_s__write_ulong;
static PyObject *__pyx_n_s__write_ushort;
static PyObject *__pyx_n_s__xml;
static PyObject *__pyx_int_0;
static PyObject *__pyx_k_tuple_1;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_12;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_16;

/* "cpyamf/amf0.pyx":50
 *     cdef amf3.Context amf3_context
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         codec.Context.clear(self)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Context_clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  int __pyx_f_6cpyamf_4amf0_7Context_clear(struct __pyx_obj_6cpyamf_4amf0_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;
  int __pyx_t_4;
  __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 = 50; __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_4amf0_7Context_clear)) {
      __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 = 50; __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 = 50; __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/amf0.pyx":51
 * 
 *     cpdef int clear(self) except -1:
 *         codec.Context.clear(self)             # <<<<<<<<<<<<<<
 * 
 *         if self.amf3_context:
 */
  __pyx_t_3 = __pyx_vtabptr_6cpyamf_5codec_Context->clear(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self), 1); if (unlikely(__pyx_t_3 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":53
 *         codec.Context.clear(self)
 * 
 *         if self.amf3_context:             # <<<<<<<<<<<<<<
 *             self.amf3_context.clear()
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->amf3_context)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "cpyamf/amf0.pyx":54
 * 
 *         if self.amf3_context:
 *             self.amf3_context.clear()             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->amf3_context->__pyx_base.__pyx_vtab)->__pyx_base.clear(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->amf3_context), 0); if (unlikely(__pyx_t_3 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":56
 *             self.amf3_context.clear()
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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.amf0.Context.clear");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":50
 *     cdef amf3.Context amf3_context
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         codec.Context.clear(self)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Context_clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Context_clear(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_4amf0_Context *)((struct __pyx_obj_6cpyamf_4amf0_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.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 = 50; __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 = 50; __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.amf0.Context.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":67
 *     cdef amf3.Decoder amf3_decoder
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.use_amf3 = 0
 * 
 */

static int __pyx_pf_6cpyamf_4amf0_7Decoder___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Decoder___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/amf0.pyx":68
 * 
 *     def __cinit__(self):
 *         self.use_amf3 = 0             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *args, **kwargs):
 */
  ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->use_amf3 = 0;

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

/* "cpyamf/amf0.pyx":70
 *         self.use_amf3 = 0
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 *         self.context = kwargs.pop('context', None)
 */

static int __pyx_pf_6cpyamf_4amf0_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
  if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;

  /* "cpyamf/amf0.pyx":71
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)             # <<<<<<<<<<<<<<
 *         self.context = kwargs.pop('context', None)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_kwargs), __pyx_n_s__pop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->use_amf3 = __pyx_t_3;

  /* "cpyamf/amf0.pyx":72
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 *         self.context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if self.context is None:
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_kwargs), __pyx_n_s__pop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6cpyamf_4amf0_Context))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context));
  ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":74
 *         self.context = kwargs.pop('context', None)
 * 
 *         if self.context is None:             # <<<<<<<<<<<<<<
 *             self.context = Context()
 * 
 */
  __pyx_t_3 = (((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context) == Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf0.pyx":75
 * 
 *         if self.context is None:
 *             self.context = Context()             # <<<<<<<<<<<<<<
 * 
 *         codec.Codec.__init__(self, *args, **kwargs)
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf0_Context)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context));
    ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf0.pyx":77
 *             self.context = Context()
 * 
 *         codec.Codec.__init__(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cdef object readNumber(self):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_Codec)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_4 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":79
 *         codec.Codec.__init__(self, *args, **kwargs)
 * 
 *     cdef object readNumber(self):             # <<<<<<<<<<<<<<
 *         cdef double i
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readNumber(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  double __pyx_v_i;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("readNumber");

  /* "cpyamf/amf0.pyx":82
 *         cdef double i
 * 
 *         self.stream.read_double(&i)             # <<<<<<<<<<<<<<
 * 
 *         if floor(i) == i:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_double(__pyx_v_self->__pyx_base.__pyx_base.stream, (&__pyx_v_i)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":84
 *         self.stream.read_double(&i)
 * 
 *         if floor(i) == i:             # <<<<<<<<<<<<<<
 *             try:
 *                 return int(i)
 */
  __pyx_t_2 = (floor(__pyx_v_i) == __pyx_v_i);
  if (__pyx_t_2) {

    /* "cpyamf/amf0.pyx":85
 * 
 *         if floor(i) == i:
 *             try:             # <<<<<<<<<<<<<<
 *                 return int(i)
 *             except OverflowError:
 */
    {
      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/amf0.pyx":86
 *         if floor(i) == i:
 *             try:
 *                 return int(i)             # <<<<<<<<<<<<<<
 *             except OverflowError:
 *                 return i
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 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_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cpyamf/amf0.pyx":87
 *             try:
 *                 return int(i)
 *             except OverflowError:             # <<<<<<<<<<<<<<
 *                 return i
 * 
 */
      __pyx_t_1 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
      if (__pyx_t_1) {
        __Pyx_AddTraceback("cpyamf.amf0.Decoder.readNumber");
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);

        /* "cpyamf/amf0.pyx":88
 *                 return int(i)
 *             except OverflowError:
 *                 return i             # <<<<<<<<<<<<<<
 * 
 *         return i
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_6 = PyFloat_FromDouble(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_r = __pyx_t_6;
        __pyx_t_6 = 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_L7_except_return;
        __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_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_L7_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_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:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":90
 *                 return i
 * 
 *         return i             # <<<<<<<<<<<<<<
 * 
 *     cdef object readBoolean(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_i); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readNumber");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":92
 *         return i
 * 
 *     cdef object readBoolean(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned char b = self.stream.read_uchar()
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readBoolean(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  unsigned char __pyx_v_b;
  PyObject *__pyx_r = NULL;
  unsigned char __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("readBoolean");

  /* "cpyamf/amf0.pyx":93
 * 
 *     cdef object readBoolean(self):
 *         cdef unsigned char b = self.stream.read_uchar()             # <<<<<<<<<<<<<<
 * 
 *         if b == 1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_uchar(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_b = __pyx_t_1;

  /* "cpyamf/amf0.pyx":97
 *         if b == 1:
 *             return True
 *         elif b == 0:             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  switch (__pyx_v_b) {

    /* "cpyamf/amf0.pyx":95
 *         cdef unsigned char b = self.stream.read_uchar()
 * 
 *         if b == 1:             # <<<<<<<<<<<<<<
 *             return True
 *         elif b == 0:
 */
    case 1:

    /* "cpyamf/amf0.pyx":96
 * 
 *         if b == 1:
 *             return True             # <<<<<<<<<<<<<<
 *         elif b == 0:
 *             return False
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __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/amf0.pyx":97
 *         if b == 1:
 *             return True
 *         elif b == 0:             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    case 0:

    /* "cpyamf/amf0.pyx":98
 *             return True
 *         elif b == 0:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         raise pyamf.DecodeError('Bad boolean read from stream')
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __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/amf0.pyx":100
 *             return False
 * 
 *         raise pyamf.DecodeError('Bad boolean read from stream')             # <<<<<<<<<<<<<<
 * 
 *     cdef object readBytes(self):
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__DecodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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 = 100; __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readBoolean");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":102
 *         raise pyamf.DecodeError('Bad boolean read from stream')
 * 
 *     cdef object readBytes(self):             # <<<<<<<<<<<<<<
 *         cdef object u
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readBytes(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_u;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("readBytes");
  __pyx_v_u = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":105
 *         cdef object u
 * 
 *         u = self.readString()             # <<<<<<<<<<<<<<
 * 
 *         return self.context.getBytesForString(u)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readString(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_u);
  __pyx_v_u = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":107
 *         u = self.readString()
 * 
 *         return self.context.getBytesForString(u)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object readString(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getBytesForString(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_u, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __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.amf0.Decoder.readBytes");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_u);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":109
 *         return self.context.getBytesForString(u)
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned short l
 *         cdef char *b = NULL
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_2readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readString(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self, int __pyx_skip_dispatch) {
  unsigned short __pyx_v_l;
  char *__pyx_v_b;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  unsigned short __pyx_t_3;
  int __pyx_t_4;
  __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 = 109; __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_4amf0_7Decoder_2readString)) {
      __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 = 109; __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/amf0.pyx":111
 *     cpdef object readString(self):
 *         cdef unsigned short l
 *         cdef char *b = NULL             # <<<<<<<<<<<<<<
 * 
 *         l = self.stream.read_ushort()
 */
  __pyx_v_b = NULL;

  /* "cpyamf/amf0.pyx":113
 *         cdef char *b = NULL
 * 
 *         l = self.stream.read_ushort()             # <<<<<<<<<<<<<<
 * 
 *         self.stream.read(&b, l)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_ushort(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_3 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_3;

  /* "cpyamf/amf0.pyx":115
 *         l = self.stream.read_ushort()
 * 
 *         self.stream.read(&b, l)             # <<<<<<<<<<<<<<
 * 
 *         return PyUnicode_DecodeUTF8(b, <Py_ssize_t>l, 'strict')
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read(__pyx_v_self->__pyx_base.__pyx_base.stream, (&__pyx_v_b), __pyx_v_l); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":117
 *         self.stream.read(&b, l)
 * 
 *         return PyUnicode_DecodeUTF8(b, <Py_ssize_t>l, 'strict')             # <<<<<<<<<<<<<<
 * 
 *     cdef dict readObjectAttributes(self, object obj_attrs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyUnicode_DecodeUTF8(__pyx_v_b, ((Py_ssize_t)__pyx_v_l), __pyx_k__strict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __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_AddTraceback("cpyamf.amf0.Decoder.readString");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":109
 *         return self.context.getBytesForString(u)
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned short l
 *         cdef char *b = NULL
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_2readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_2readString(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_4amf0_Decoder *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.readString(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __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.amf0.Decoder.readString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":119
 *         return PyUnicode_DecodeUTF8(b, <Py_ssize_t>l, 'strict')
 * 
 *     cdef dict readObjectAttributes(self, object obj_attrs):             # <<<<<<<<<<<<<<
 *         cdef object key
 *         cdef char *peek = NULL
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readObjectAttributes(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self, PyObject *__pyx_v_obj_attrs) {
  PyObject *__pyx_v_key;
  char *__pyx_v_peek;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_seek __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("readObjectAttributes");
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":121
 *     cdef dict readObjectAttributes(self, object obj_attrs):
 *         cdef object key
 *         cdef char *peek = NULL             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_v_peek = NULL;

  /* "cpyamf/amf0.pyx":123
 *         cdef char *peek = NULL
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             self.stream.peek(&peek, 3)
 * 
 */
  while (1) {
    if (!1) break;

    /* "cpyamf/amf0.pyx":124
 * 
 *         while True:
 *             self.stream.peek(&peek, 3)             # <<<<<<<<<<<<<<
 * 
 *             if memcmp(peek, b'\x00\x00\x09', 3) == 0:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->peek(__pyx_v_self->__pyx_base.__pyx_base.stream, (&__pyx_v_peek), 3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":126
 *             self.stream.peek(&peek, 3)
 * 
 *             if memcmp(peek, b'\x00\x00\x09', 3) == 0:             # <<<<<<<<<<<<<<
 *                 self.stream.seek(3, 1)
 * 
 */
    __pyx_t_2 = (memcmp(__pyx_v_peek, __pyx_k_5, 3) == 0);
    if (__pyx_t_2) {

      /* "cpyamf/amf0.pyx":127
 * 
 *             if memcmp(peek, b'\x00\x00\x09', 3) == 0:
 *                 self.stream.seek(3, 1)             # <<<<<<<<<<<<<<
 * 
 *                 break
 */
      __pyx_t_4.__pyx_n = 1;
      __pyx_t_4.mode = 1;
      __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->seek(__pyx_v_self->__pyx_base.__pyx_base.stream, 3, 0, &__pyx_t_4); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cpyamf/amf0.pyx":129
 *                 self.stream.seek(3, 1)
 * 
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             key = self.readBytes()
 */
      goto __pyx_L4_break;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cpyamf/amf0.pyx":131
 *                 break
 * 
 *             key = self.readBytes()             # <<<<<<<<<<<<<<
 * 
 *             PyDict_SetItem(obj_attrs, key, self.readElement())
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readBytes(__pyx_v_self); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_v_key);
    __pyx_v_key = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cpyamf/amf0.pyx":133
 *             key = self.readBytes()
 * 
 *             PyDict_SetItem(obj_attrs, key, self.readElement())             # <<<<<<<<<<<<<<
 * 
 *         # discard the end marker (TYPE_OBJECTTERM)
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readElement(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyDict_SetItem(__pyx_v_obj_attrs, __pyx_v_key, __pyx_t_5); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L4_break:;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readObjectAttributes");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":137
 *         # discard the end marker (TYPE_OBJECTTERM)
 * 
 *     cdef object readObject(self):             # <<<<<<<<<<<<<<
 *         cdef object obj = ASObject()
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readObject(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("readObject");

  /* "cpyamf/amf0.pyx":138
 * 
 *     cdef object readObject(self):
 *         cdef object obj = ASObject()             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
  __pyx_t_1 = PyObject_Call(__pyx_v_6cpyamf_4amf0_ASObject, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":140
 *         cdef object obj = ASObject()
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.readObjectAttributes(obj)
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":142
 *         self.context.addObject(obj)
 * 
 *         self.readObjectAttributes(obj)             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readObjectAttributes(__pyx_v_self, __pyx_v_obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":144
 *         self.readObjectAttributes(obj)
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef object readTypedObject(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  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.amf0.Decoder.readObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":146
 *         return obj
 * 
 *     cdef object readTypedObject(self):             # <<<<<<<<<<<<<<
 *         cdef object class_alias = self.readString()
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readTypedObject(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_class_alias = 0;
  PyObject *__pyx_v_alias;
  PyObject *__pyx_v_obj;
  PyObject *__pyx_v_attrs = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("readTypedObject");
  __pyx_v_alias = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":147
 * 
 *     cdef object readTypedObject(self):
 *         cdef object class_alias = self.readString()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readString(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_class_alias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":149
 *         cdef object class_alias = self.readString()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             alias = self.context.getClassAlias(class_alias)
 *         except 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/amf0.pyx":150
 * 
 *         try:
 *             alias = self.context.getClassAlias(class_alias)             # <<<<<<<<<<<<<<
 *         except UnknownClassAlias:
 *             if self.strict:
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_class_alias, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __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_1); __pyx_t_1 = 0;

    /* "cpyamf/amf0.pyx":151
 *         try:
 *             alias = self.context.getClassAlias(class_alias)
 *         except UnknownClassAlias:             # <<<<<<<<<<<<<<
 *             if self.strict:
 *                 raise
 */
    __pyx_t_2 = PyErr_ExceptionMatches(__pyx_v_6cpyamf_4amf0_UnknownClassAlias);
    if (__pyx_t_2) {
      __Pyx_AddTraceback("cpyamf.amf0.Decoder.readTypedObject");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpyamf/amf0.pyx":152
 *             alias = self.context.getClassAlias(class_alias)
 *         except UnknownClassAlias:
 *             if self.strict:             # <<<<<<<<<<<<<<
 *                 raise
 * 
 */
      if (__pyx_v_self->__pyx_base.__pyx_base.strict) {

        /* "cpyamf/amf0.pyx":153
 *         except UnknownClassAlias:
 *             if self.strict:
 *                 raise             # <<<<<<<<<<<<<<
 * 
 *             alias = pyamf.TypedObjectClassAlias(class_alias)
 */
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_4);
        __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "cpyamf/amf0.pyx":155
 *                 raise
 * 
 *             alias = pyamf.TypedObjectClassAlias(class_alias)             # <<<<<<<<<<<<<<
 * 
 *         obj = alias.createInstance(codec=self)
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __Pyx_INCREF(__pyx_v_class_alias);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_class_alias);
      __Pyx_GIVEREF(__pyx_v_class_alias);
      __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_7;
      __pyx_t_7 = 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_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_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/amf0.pyx":157
 *             alias = pyamf.TypedObjectClassAlias(class_alias)
 * 
 *         obj = alias.createInstance(codec=self)             # <<<<<<<<<<<<<<
 *         self.context.addObject(obj)
 * 
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__createInstance); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__codec), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_obj);
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":158
 * 
 *         obj = alias.createInstance(codec=self)
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         cdef dict attrs = {}
 */
  __pyx_t_8 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":160
 *         self.context.addObject(obj)
 * 
 *         cdef dict attrs = {}             # <<<<<<<<<<<<<<
 * 
 *         self.readObjectAttributes(attrs)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_attrs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":162
 *         cdef dict attrs = {}
 * 
 *         self.readObjectAttributes(attrs)             # <<<<<<<<<<<<<<
 * 
 *         alias.applyAttributes(obj, attrs, codec=self)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readObjectAttributes(__pyx_v_self, ((PyObject *)__pyx_v_attrs))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":164
 *         self.readObjectAttributes(attrs)
 * 
 *         alias.applyAttributes(obj, attrs, codec=self)             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__applyAttributes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_INCREF(((PyObject *)__pyx_v_attrs));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_attrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_attrs));
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__codec), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cpyamf/amf0.pyx":166
 *         alias.applyAttributes(obj, attrs, codec=self)
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef object readReference(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readTypedObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_class_alias);
  __Pyx_DECREF(__pyx_v_alias);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_attrs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":168
 *         return obj
 * 
 *     cdef object readReference(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned short idx
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readReference(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  unsigned short __pyx_v_idx;
  PyObject *__pyx_v_o;
  PyObject *__pyx_r = NULL;
  unsigned short __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("readReference");
  __pyx_v_o = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":171
 *         cdef unsigned short idx
 * 
 *         idx = self.stream.read_ushort()             # <<<<<<<<<<<<<<
 *         o = self.context.getObject(idx)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_ushort(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_idx = __pyx_t_1;

  /* "cpyamf/amf0.pyx":172
 * 
 *         idx = self.stream.read_ushort()
 *         o = self.context.getObject(idx)             # <<<<<<<<<<<<<<
 * 
 *         if o is None:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_idx, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_o);
  __pyx_v_o = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf0.pyx":174
 *         o = self.context.getObject(idx)
 * 
 *         if o is None:             # <<<<<<<<<<<<<<
 *             raise pyamf.ReferenceError('Unknown reference %d' % (idx,))
 * 
 */
  __pyx_t_3 = (__pyx_v_o == Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf0.pyx":175
 * 
 *         if o is None:
 *             raise pyamf.ReferenceError('Unknown reference %d' % (idx,))             # <<<<<<<<<<<<<<
 * 
 *         return o
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); 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_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ReferenceError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(__pyx_v_idx); 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_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); 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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":177
 *             raise pyamf.ReferenceError('Unknown reference %d' % (idx,))
 * 
 *         return o             # <<<<<<<<<<<<<<
 * 
 *     cdef object readMixedArray(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_o);
  __pyx_r = __pyx_v_o;
  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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readReference");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_o);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":179
 *         return o
 * 
 *     cdef object readMixedArray(self):             # <<<<<<<<<<<<<<
 *         cdef unsigned long l
 *         cdef dict attrs
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readMixedArray(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  unsigned long __pyx_v_l;
  PyObject *__pyx_v_attrs;
  PyObject *__pyx_v_obj;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  unsigned long __pyx_t_4;
  void *__pyx_t_5;
  void *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("readMixedArray");
  __pyx_v_attrs = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":183
 *         cdef dict attrs
 * 
 *         obj = pyamf.MixedArray()             # <<<<<<<<<<<<<<
 *         self.context.addObject(obj)
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__MixedArray); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_obj);
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":184
 * 
 *         obj = pyamf.MixedArray()
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         l = self.stream.read_ulong()
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":186
 *         self.context.addObject(obj)
 * 
 *         l = self.stream.read_ulong()             # <<<<<<<<<<<<<<
 * 
 *         attrs = self.readObjectAttributes(obj)
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_4 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_4;

  /* "cpyamf/amf0.pyx":188
 *         l = self.stream.read_ulong()
 * 
 *         attrs = self.readObjectAttributes(obj)             # <<<<<<<<<<<<<<
 * 
 *         for key, value in attrs.iteritems():
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readObjectAttributes(__pyx_v_self, __pyx_v_obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_v_attrs));
  __pyx_v_attrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":190
 *         attrs = self.readObjectAttributes(obj)
 * 
 *         for key, value in attrs.iteritems():             # <<<<<<<<<<<<<<
 *             try:
 *                 key = int(key)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_attrs));
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = ((PyObject *)__pyx_v_attrs);
  __pyx_t_3 = 0;
  while (1) {
    if (!PyDict_Next(__pyx_t_1, (&__pyx_t_3), ((PyObject **)(&__pyx_t_5)), ((PyObject **)(&__pyx_t_6)))) break;
    __Pyx_INCREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_v_key);
    __pyx_v_key = ((PyObject *)__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = ((PyObject *)__pyx_t_6);

    /* "cpyamf/amf0.pyx":191
 * 
 *         for key, value in attrs.iteritems():
 *             try:             # <<<<<<<<<<<<<<
 *                 key = int(key)
 *             except ValueError:
 */
    {
      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/amf0.pyx":192
 *         for key, value in attrs.iteritems():
 *             try:
 *                 key = int(key)             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 pass
 */
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_INCREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
        __Pyx_GIVEREF(__pyx_v_key);
        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_key);
        __pyx_v_key = __pyx_t_7;
        __pyx_t_7 = 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_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cpyamf/amf0.pyx":193
 *             try:
 *                 key = int(key)
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 pass
 * 
 */
      __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_8) {
        PyErr_Restore(0,0,0);
        goto __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);
      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/amf0.pyx":196
 *                 pass
 * 
 *             obj[key] = value             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
    if (PyObject_SetItem(__pyx_v_obj, __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":198
 *             obj[key] = value
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef object readList(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  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_7);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readMixedArray");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_attrs);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":200
 *         return obj
 * 
 *     cdef object readList(self):             # <<<<<<<<<<<<<<
 *         cdef list obj = []
 *         cdef unsigned long l
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readList(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_obj = 0;
  unsigned long __pyx_v_l;
  unsigned long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  unsigned long __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("readList");

  /* "cpyamf/amf0.pyx":201
 * 
 *     cdef object readList(self):
 *         cdef list obj = []             # <<<<<<<<<<<<<<
 *         cdef unsigned long l
 *         cdef unsigned long i
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":205
 *         cdef unsigned long i
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 *         l = self.stream.read_ulong()
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), ((PyObject *)__pyx_v_obj), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":206
 * 
 *         self.context.addObject(obj)
 *         l = self.stream.read_ulong()             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < l:
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_3 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_3;

  /* "cpyamf/amf0.pyx":208
 *         l = self.stream.read_ulong()
 * 
 *         for i from 0 <= i < l:             # <<<<<<<<<<<<<<
 *             PyList_Append(obj, self.readElement())
 * 
 */
  __pyx_t_3 = __pyx_v_l;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "cpyamf/amf0.pyx":209
 * 
 *         for i from 0 <= i < l:
 *             PyList_Append(obj, self.readElement())             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readElement(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_obj), __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf0.pyx":211
 *             PyList_Append(obj, self.readElement())
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef object readDate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = ((PyObject *)__pyx_v_obj);
  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.amf0.Decoder.readList");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":213
 *         return obj
 * 
 *     cdef object readDate(self):             # <<<<<<<<<<<<<<
 *         cdef double ms
 *         cdef short tz
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readDate(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  double __pyx_v_ms;
  short __pyx_v_tz;
  PyObject *__pyx_v_d;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  short __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  __Pyx_RefNannySetupContext("readDate");
  __pyx_v_d = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":217
 *         cdef short tz
 * 
 *         self.stream.read_double(&ms)             # <<<<<<<<<<<<<<
 *         tz = self.stream.read_short()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_double(__pyx_v_self->__pyx_base.__pyx_base.stream, (&__pyx_v_ms)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":218
 * 
 *         self.stream.read_double(&ms)
 *         tz = self.stream.read_short()             # <<<<<<<<<<<<<<
 * 
 *         # Timezones are ignored
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_short(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_2 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_tz = __pyx_t_2;

  /* "cpyamf/amf0.pyx":221
 * 
 *         # Timezones are ignored
 *         d = util.get_datetime(ms / 1000.0)             # <<<<<<<<<<<<<<
 * 
 *         if self.timezone_offset:
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__get_datetime); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble((__pyx_v_ms / 1000.0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_v_d);
  __pyx_v_d = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf0.pyx":223
 *         d = util.get_datetime(ms / 1000.0)
 * 
 *         if self.timezone_offset:             # <<<<<<<<<<<<<<
 *             d = d + self.timezone_offset
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base.__pyx_base.timezone_offset); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_6) {

    /* "cpyamf/amf0.pyx":224
 * 
 *         if self.timezone_offset:
 *             d = d + self.timezone_offset             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(d)
 */
    __pyx_t_3 = PyNumber_Add(__pyx_v_d, __pyx_v_self->__pyx_base.__pyx_base.timezone_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_d);
    __pyx_v_d = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":226
 *             d = d + self.timezone_offset
 * 
 *         self.context.addObject(d)             # <<<<<<<<<<<<<<
 * 
 *         return d
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_d, 0); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":228
 *         self.context.addObject(d)
 * 
 *         return d             # <<<<<<<<<<<<<<
 * 
 *     cdef object readLongString(self, bint bytes=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_d);
  __pyx_r = __pyx_v_d;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readDate");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_d);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":230
 *         return d
 * 
 *     cdef object readLongString(self, bint bytes=0):             # <<<<<<<<<<<<<<
 *         cdef unsigned long l
 *         cdef char *b = NULL
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readLongString(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self, struct __pyx_opt_args_6cpyamf_4amf0_7Decoder_readLongString *__pyx_optional_args) {
  int __pyx_v_bytes = ((int)0);
  unsigned long __pyx_v_l;
  char *__pyx_v_b;
  PyObject *__pyx_v_s;
  PyObject *__pyx_r = NULL;
  unsigned long __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("readLongString");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_bytes = __pyx_optional_args->bytes;
    }
  }
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":232
 *     cdef object readLongString(self, bint bytes=0):
 *         cdef unsigned long l
 *         cdef char *b = NULL             # <<<<<<<<<<<<<<
 *         cdef object s
 * 
 */
  __pyx_v_b = NULL;

  /* "cpyamf/amf0.pyx":235
 *         cdef object s
 * 
 *         l = self.stream.read_ulong()             # <<<<<<<<<<<<<<
 * 
 *         self.stream.read(&b, l)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, 0); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_l = __pyx_t_1;

  /* "cpyamf/amf0.pyx":237
 *         l = self.stream.read_ulong()
 * 
 *         self.stream.read(&b, l)             # <<<<<<<<<<<<<<
 *         s = PyString_FromStringAndSize(b, <Py_ssize_t>l)
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->read(__pyx_v_self->__pyx_base.__pyx_base.stream, (&__pyx_v_b), __pyx_v_l); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":238
 * 
 *         self.stream.read(&b, l)
 *         s = PyString_FromStringAndSize(b, <Py_ssize_t>l)             # <<<<<<<<<<<<<<
 * 
 *         if bytes:
 */
  __pyx_t_3 = PyString_FromStringAndSize(__pyx_v_b, ((Py_ssize_t)__pyx_v_l)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf0.pyx":240
 *         s = PyString_FromStringAndSize(b, <Py_ssize_t>l)
 * 
 *         if bytes:             # <<<<<<<<<<<<<<
 *             return s
 * 
 */
  if (__pyx_v_bytes) {

    /* "cpyamf/amf0.pyx":241
 * 
 *         if bytes:
 *             return s             # <<<<<<<<<<<<<<
 * 
 *         return self.context.getStringForBytes(s)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_s);
    __pyx_r = __pyx_v_s;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":243
 *             return s
 * 
 *         return self.context.getStringForBytes(s)             # <<<<<<<<<<<<<<
 * 
 *     cdef object readXML(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getStringForBytes(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_s, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __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.amf0.Decoder.readLongString");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":245
 *         return self.context.getStringForBytes(s)
 * 
 *     cdef object readXML(self):             # <<<<<<<<<<<<<<
 *         cdef object data = self.readLongString()
 *         cdef object root = xml.fromstring(data)
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readXML(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_v_root = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("readXML");

  /* "cpyamf/amf0.pyx":246
 * 
 *     cdef object readXML(self):
 *         cdef object data = self.readLongString()             # <<<<<<<<<<<<<<
 *         cdef object root = xml.fromstring(data)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readLongString(__pyx_v_self, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":247
 *     cdef object readXML(self):
 *         cdef object data = self.readLongString()
 *         cdef object root = xml.fromstring(data)             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(root)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__xml); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __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 = 247; __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_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_root = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf0.pyx":249
 *         cdef object root = xml.fromstring(data)
 * 
 *         self.context.addObject(root)             # <<<<<<<<<<<<<<
 * 
 *         return root
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_root, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":251
 *         self.context.addObject(root)
 * 
 *         return root             # <<<<<<<<<<<<<<
 * 
 *     cdef object readAMF3(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_root);
  __pyx_r = __pyx_v_root;
  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.amf0.Decoder.readXML");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_root);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":253
 *         return root
 * 
 *     cdef object readAMF3(self):             # <<<<<<<<<<<<<<
 *         if self.amf3_decoder is None:
 *             self.context.amf3_context = amf3.Context()
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readAMF3(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("readAMF3");

  /* "cpyamf/amf0.pyx":254
 * 
 *     cdef object readAMF3(self):
 *         if self.amf3_decoder is None:             # <<<<<<<<<<<<<<
 *             self.context.amf3_context = amf3.Context()
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->amf3_decoder) == Py_None);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":255
 *     cdef object readAMF3(self):
 *         if self.amf3_decoder is None:
 *             self.context.amf3_context = amf3.Context()             # <<<<<<<<<<<<<<
 * 
 *             self.amf3_decoder = amf3.Decoder(
 */
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_Context)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->context->amf3_context);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->context->amf3_context));
    __pyx_v_self->context->amf3_context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cpyamf/amf0.pyx":257
 *             self.context.amf3_context = amf3.Context()
 * 
 *             self.amf3_decoder = amf3.Decoder(             # <<<<<<<<<<<<<<
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "cpyamf/amf0.pyx":258
 * 
 *             self.amf3_decoder = amf3.Decoder(
 *                 stream=self.stream,             # <<<<<<<<<<<<<<
 *                 context=self.context.amf3_context,
 *                 timezone_offset=self.timezone_offset)
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__stream), ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":259
 *             self.amf3_decoder = amf3.Decoder(
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,             # <<<<<<<<<<<<<<
 *                 timezone_offset=self.timezone_offset)
 * 
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__context), ((PyObject *)__pyx_v_self->context->amf3_context)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":260
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 *                 timezone_offset=self.timezone_offset)             # <<<<<<<<<<<<<<
 * 
 *         return self.amf3_decoder.readElement()
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__timezone_offset), __pyx_v_self->__pyx_base.__pyx_base.timezone_offset) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_Decoder)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

    /* "cpyamf/amf0.pyx":257
 *             self.context.amf3_context = amf3.Context()
 * 
 *             self.amf3_decoder = amf3.Decoder(             # <<<<<<<<<<<<<<
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 */
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->amf3_decoder);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->amf3_decoder));
    __pyx_v_self->amf3_decoder = ((struct __pyx_obj_6cpyamf_4amf3_Decoder *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":262
 *                 timezone_offset=self.timezone_offset)
 * 
 *         return self.amf3_decoder.readElement()             # <<<<<<<<<<<<<<
 * 
 *     cdef object readConcreteElement(self, char type):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->amf3_decoder->__pyx_base.__pyx_vtab)->__pyx_base.readElement(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self->amf3_decoder), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readAMF3");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":264
 *         return self.amf3_decoder.readElement()
 * 
 *     cdef object readConcreteElement(self, char type):             # <<<<<<<<<<<<<<
 *         if type == TYPE_NUMBER:
 *             return self.readNumber()
 */

static  PyObject *__pyx_f_6cpyamf_4amf0_7Decoder_readConcreteElement(struct __pyx_obj_6cpyamf_4amf0_Decoder *__pyx_v_self, char __pyx_v_type) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("readConcreteElement");

  /* "cpyamf/amf0.pyx":265
 * 
 *     cdef object readConcreteElement(self, char type):
 *         if type == TYPE_NUMBER:             # <<<<<<<<<<<<<<
 *             return self.readNumber()
 *         elif type == TYPE_BOOL:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_NUMBER);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":266
 *     cdef object readConcreteElement(self, char type):
 *         if type == TYPE_NUMBER:
 *             return self.readNumber()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_BOOL:
 *             return self.readBoolean()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readNumber(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __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;
  }

  /* "cpyamf/amf0.pyx":267
 *         if type == TYPE_NUMBER:
 *             return self.readNumber()
 *         elif type == TYPE_BOOL:             # <<<<<<<<<<<<<<
 *             return self.readBoolean()
 *         elif type == TYPE_STRING:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_BOOL);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":268
 *             return self.readNumber()
 *         elif type == TYPE_BOOL:
 *             return self.readBoolean()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_STRING:
 *             return self.readString()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readBoolean(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __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;
  }

  /* "cpyamf/amf0.pyx":269
 *         elif type == TYPE_BOOL:
 *             return self.readBoolean()
 *         elif type == TYPE_STRING:             # <<<<<<<<<<<<<<
 *             return self.readString()
 *         elif type == TYPE_OBJECT:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_STRING);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":270
 *             return self.readBoolean()
 *         elif type == TYPE_STRING:
 *             return self.readString()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_OBJECT:
 *             return self.readObject()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readString(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __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;
  }

  /* "cpyamf/amf0.pyx":271
 *         elif type == TYPE_STRING:
 *             return self.readString()
 *         elif type == TYPE_OBJECT:             # <<<<<<<<<<<<<<
 *             return self.readObject()
 *         elif type == TYPE_NULL:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_OBJECT);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":272
 *             return self.readString()
 *         elif type == TYPE_OBJECT:
 *             return self.readObject()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_NULL:
 *             return self.readNull()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readObject(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __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;
  }

  /* "cpyamf/amf0.pyx":273
 *         elif type == TYPE_OBJECT:
 *             return self.readObject()
 *         elif type == TYPE_NULL:             # <<<<<<<<<<<<<<
 *             return self.readNull()
 *         elif type == TYPE_UNDEFINED:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_NULL);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":274
 *             return self.readObject()
 *         elif type == TYPE_NULL:
 *             return self.readNull()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_UNDEFINED:
 *             return self.readUndefined()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readNull(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __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;
  }

  /* "cpyamf/amf0.pyx":275
 *         elif type == TYPE_NULL:
 *             return self.readNull()
 *         elif type == TYPE_UNDEFINED:             # <<<<<<<<<<<<<<
 *             return self.readUndefined()
 *         elif type == TYPE_REFERENCE:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_UNDEFINED);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":276
 *             return self.readNull()
 *         elif type == TYPE_UNDEFINED:
 *             return self.readUndefined()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_REFERENCE:
 *             return self.readReference()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readUndefined(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __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;
  }

  /* "cpyamf/amf0.pyx":277
 *         elif type == TYPE_UNDEFINED:
 *             return self.readUndefined()
 *         elif type == TYPE_REFERENCE:             # <<<<<<<<<<<<<<
 *             return self.readReference()
 *         elif type == TYPE_MIXEDARRAY:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_REFERENCE);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":278
 *             return self.readUndefined()
 *         elif type == TYPE_REFERENCE:
 *             return self.readReference()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_MIXEDARRAY:
 *             return self.readMixedArray()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readReference(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __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;
  }

  /* "cpyamf/amf0.pyx":279
 *         elif type == TYPE_REFERENCE:
 *             return self.readReference()
 *         elif type == TYPE_MIXEDARRAY:             # <<<<<<<<<<<<<<
 *             return self.readMixedArray()
 *         elif type == TYPE_ARRAY:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_MIXEDARRAY);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":280
 *             return self.readReference()
 *         elif type == TYPE_MIXEDARRAY:
 *             return self.readMixedArray()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_ARRAY:
 *             return self.readList()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readMixedArray(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __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;
  }

  /* "cpyamf/amf0.pyx":281
 *         elif type == TYPE_MIXEDARRAY:
 *             return self.readMixedArray()
 *         elif type == TYPE_ARRAY:             # <<<<<<<<<<<<<<
 *             return self.readList()
 *         elif type == TYPE_DATE:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_ARRAY);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":282
 *             return self.readMixedArray()
 *         elif type == TYPE_ARRAY:
 *             return self.readList()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_DATE:
 *             return self.readDate()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readList(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __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;
  }

  /* "cpyamf/amf0.pyx":283
 *         elif type == TYPE_ARRAY:
 *             return self.readList()
 *         elif type == TYPE_DATE:             # <<<<<<<<<<<<<<
 *             return self.readDate()
 *         elif type == TYPE_LONGSTRING:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_DATE);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":284
 *             return self.readList()
 *         elif type == TYPE_DATE:
 *             return self.readDate()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_LONGSTRING:
 *             return self.readLongString()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readDate(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __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;
  }

  /* "cpyamf/amf0.pyx":285
 *         elif type == TYPE_DATE:
 *             return self.readDate()
 *         elif type == TYPE_LONGSTRING:             # <<<<<<<<<<<<<<
 *             return self.readLongString()
 *         elif type == TYPE_UNSUPPORTED:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_LONGSTRING);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":286
 *             return self.readDate()
 *         elif type == TYPE_LONGSTRING:
 *             return self.readLongString()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_UNSUPPORTED:
 *             return self.readNull()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readLongString(__pyx_v_self, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __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;
  }

  /* "cpyamf/amf0.pyx":287
 *         elif type == TYPE_LONGSTRING:
 *             return self.readLongString()
 *         elif type == TYPE_UNSUPPORTED:             # <<<<<<<<<<<<<<
 *             return self.readNull()
 *         elif type == TYPE_XML:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_UNSUPPORTED);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":288
 *             return self.readLongString()
 *         elif type == TYPE_UNSUPPORTED:
 *             return self.readNull()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_XML:
 *             return self.readXML()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readNull(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __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;
  }

  /* "cpyamf/amf0.pyx":289
 *         elif type == TYPE_UNSUPPORTED:
 *             return self.readNull()
 *         elif type == TYPE_XML:             # <<<<<<<<<<<<<<
 *             return self.readXML()
 *         elif type == TYPE_TYPEDOBJECT:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_XML);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":290
 *             return self.readNull()
 *         elif type == TYPE_XML:
 *             return self.readXML()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_TYPEDOBJECT:
 *             return self.readTypedObject()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.readXML(((struct __pyx_obj_6cpyamf_5codec_Decoder *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __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;
  }

  /* "cpyamf/amf0.pyx":291
 *         elif type == TYPE_XML:
 *             return self.readXML()
 *         elif type == TYPE_TYPEDOBJECT:             # <<<<<<<<<<<<<<
 *             return self.readTypedObject()
 *         elif type == TYPE_AMF3:
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_TYPEDOBJECT);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":292
 *             return self.readXML()
 *         elif type == TYPE_TYPEDOBJECT:
 *             return self.readTypedObject()             # <<<<<<<<<<<<<<
 *         elif type == TYPE_AMF3:
 *             return self.readAMF3()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readTypedObject(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __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;
  }

  /* "cpyamf/amf0.pyx":293
 *         elif type == TYPE_TYPEDOBJECT:
 *             return self.readTypedObject()
 *         elif type == TYPE_AMF3:             # <<<<<<<<<<<<<<
 *             return self.readAMF3()
 * 
 */
  __pyx_t_1 = (__pyx_v_type == __pyx_v_6cpyamf_4amf0_TYPE_AMF3);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":294
 *             return self.readTypedObject()
 *         elif type == TYPE_AMF3:
 *             return self.readAMF3()             # <<<<<<<<<<<<<<
 * 
 *         raise pyamf.DecodeError("Unsupported ActionScript type")
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readAMF3(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __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/amf0.pyx":296
 *             return self.readAMF3()
 * 
 *         raise pyamf.DecodeError("Unsupported ActionScript type")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__DecodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __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_10), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __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 = 296; __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.readConcreteElement");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":63
 *     """
 * 
 *     cdef public bint use_amf3             # <<<<<<<<<<<<<<
 *     cdef readonly Context context
 *     cdef amf3.Decoder amf3_decoder
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_8use_amf3___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_8use_amf3___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_4amf0_Decoder *)__pyx_v_self)->use_amf3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __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.amf0.Decoder.use_amf3.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_4amf0_7Decoder_8use_amf3_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Decoder_8use_amf3_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[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->use_amf3 = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf0.Decoder.use_amf3.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":64
 * 
 *     cdef public bint use_amf3
 *     cdef readonly Context context             # <<<<<<<<<<<<<<
 *     cdef amf3.Decoder amf3_decoder
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_7context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Decoder_7context___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Decoder *)__pyx_v_self)->context);
  goto __pyx_L0;

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

/* "cpyamf/amf0.pyx":308
 *     cdef amf3.Encoder amf3_encoder
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.use_amf3 = 0
 * 
 */

static int __pyx_pf_6cpyamf_4amf0_7Encoder___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Encoder___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/amf0.pyx":309
 * 
 *     def __cinit__(self):
 *         self.use_amf3 = 0             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *args, **kwargs):
 */
  ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->use_amf3 = 0;

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

/* "cpyamf/amf0.pyx":311
 *         self.use_amf3 = 0
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 * 
 */

static int __pyx_pf_6cpyamf_4amf0_7Encoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Encoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 1))) return -1;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
  if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;

  /* "cpyamf/amf0.pyx":312
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)             # <<<<<<<<<<<<<<
 * 
 *         self.context = kwargs.pop('context', None)
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_kwargs), __pyx_n_s__pop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->use_amf3 = __pyx_t_3;

  /* "cpyamf/amf0.pyx":314
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 * 
 *         self.context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if self.context is None:
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_kwargs), __pyx_n_s__pop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6cpyamf_4amf0_Context))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context));
  ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":316
 *         self.context = kwargs.pop('context', None)
 * 
 *         if self.context is None:             # <<<<<<<<<<<<<<
 *             self.context = Context()
 * 
 */
  __pyx_t_3 = (((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context) == Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf0.pyx":317
 * 
 *         if self.context is None:
 *             self.context = Context()             # <<<<<<<<<<<<<<
 * 
 *         codec.Codec.__init__(self, *args, **kwargs)
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf0_Context)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context));
    ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf0.pyx":319
 *             self.context = Context()
 * 
 *         codec.Codec.__init__(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int writeReference(self, o) except -2:
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_Codec)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __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 = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_4 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":321
 *         codec.Codec.__init__(self, *args, **kwargs)
 * 
 *     cdef inline int writeReference(self, o) except -2:             # <<<<<<<<<<<<<<
 *         """
 *         Write reference to the data stream.
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf0_7Encoder_writeReference(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  Py_ssize_t __pyx_v_idx;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("writeReference");

  /* "cpyamf/amf0.pyx":325
 *         Write reference to the data stream.
 *         """
 *         cdef Py_ssize_t idx = self.context.getObjectReference(o)             # <<<<<<<<<<<<<<
 * 
 *         if idx == -1 or idx > 65535:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_o, 0); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_idx = __pyx_t_1;

  /* "cpyamf/amf0.pyx":327
 *         cdef Py_ssize_t idx = self.context.getObjectReference(o)
 * 
 *         if idx == -1 or idx > 65535:             # <<<<<<<<<<<<<<
 *             return -1
 * 
 */
  __pyx_t_2 = (__pyx_v_idx == -1);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_idx > 65535);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "cpyamf/amf0.pyx":328
 * 
 *         if idx == -1 or idx > 65535:
 *             return -1             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_REFERENCE)
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":330
 *             return -1
 * 
 *         self.writeType(TYPE_REFERENCE)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write_ushort(idx)
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_REFERENCE); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":332
 *         self.writeType(TYPE_REFERENCE)
 * 
 *         return self.stream.write_ushort(idx)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeBoolean(self, b) except -1:
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ushort(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_idx, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeReference");
  __pyx_r = -2;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":334
 *         return self.stream.write_ushort(idx)
 * 
 *     cdef int writeBoolean(self, b) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_BOOL)
 * 
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeBoolean(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_b) {
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("writeBoolean");

  /* "cpyamf/amf0.pyx":335
 * 
 *     cdef int writeBoolean(self, b) except -1:
 *         self.writeType(TYPE_BOOL)             # <<<<<<<<<<<<<<
 * 
 *         if b is True:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_BOOL); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":337
 *         self.writeType(TYPE_BOOL)
 * 
 *         if b is True:             # <<<<<<<<<<<<<<
 *             return self.writeType('\x01')
 *         else:
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__pyx_v_b == __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cpyamf/amf0.pyx":338
 * 
 *         if b is True:
 *             return self.writeType('\x01')             # <<<<<<<<<<<<<<
 *         else:
 *             return self.writeType('\x00')
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), '\x01'); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cpyamf/amf0.pyx":340
 *             return self.writeType('\x01')
 *         else:
 *             return self.writeType('\x00')             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeUndefined(self, data) except -1:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), '\x00'); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;
  }
  __pyx_L3:;

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

/* "cpyamf/amf0.pyx":342
 *             return self.writeType('\x00')
 * 
 *     cdef int writeUndefined(self, data) except -1:             # <<<<<<<<<<<<<<
 *         return self.writeType(TYPE_UNDEFINED)
 * 
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeUndefined(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_data) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeUndefined");

  /* "cpyamf/amf0.pyx":343
 * 
 *     cdef int writeUndefined(self, data) except -1:
 *         return self.writeType(TYPE_UNDEFINED)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeNull(self, n) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_UNDEFINED); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __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.amf0.Encoder.writeUndefined");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":345
 *         return self.writeType(TYPE_UNDEFINED)
 * 
 *     cdef int writeNull(self, n) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write null type to data stream.
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeNull(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeNull");

  /* "cpyamf/amf0.pyx":349
 *         Write null type to data stream.
 *         """
 *         return self.writeType(TYPE_NULL)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeList(self, object a, bint is_proxy=0) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_NULL); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __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.amf0.Encoder.writeNull");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":351
 *         return self.writeType(TYPE_NULL)
 * 
 *     cpdef int writeList(self, object a, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write array to the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeList(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_a, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4amf0_7Encoder_writeList *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_x;
  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;
  Py_ssize_t __pyx_t_6;
  __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 = 351; __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_4amf0_7Encoder_2writeList)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __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 = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      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 = 351; __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 = 351; __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/amf0.pyx":358
 *         cdef PyObject *x
 * 
 *         if self.writeReference(a) != -1:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeReference(__pyx_v_self, __pyx_v_a); if (unlikely(__pyx_t_4 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != -1);
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":359
 * 
 *         if self.writeReference(a) != -1:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(a)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":361
 *             return 0
 * 
 *         self.context.addObject(a)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_ARRAY)
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_a, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":363
 *         self.context.addObject(a)
 * 
 *         self.writeType(TYPE_ARRAY)             # <<<<<<<<<<<<<<
 *         size = PyList_GET_SIZE(a)
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_ARRAY); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":364
 * 
 *         self.writeType(TYPE_ARRAY)
 *         size = PyList_GET_SIZE(a)             # <<<<<<<<<<<<<<
 * 
 *         self.stream.write_ulong(size)
 */
  __pyx_v_size = PyList_GET_SIZE(__pyx_v_a);

  /* "cpyamf/amf0.pyx":366
 *         size = PyList_GET_SIZE(a)
 * 
 *         self.stream.write_ulong(size)             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < size:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_size, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":368
 *         self.stream.write_ulong(size)
 * 
 *         for i from 0 <= i < size:             # <<<<<<<<<<<<<<
 *             x = PyList_GET_ITEM(a, i)
 * 
 */
  __pyx_t_6 = __pyx_v_size;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

    /* "cpyamf/amf0.pyx":369
 * 
 *         for i from 0 <= i < size:
 *             x = PyList_GET_ITEM(a, i)             # <<<<<<<<<<<<<<
 * 
 *             self.writeElement(<object>x)
 */
    __pyx_v_x = PyList_GET_ITEM(__pyx_v_a, __pyx_v_i);

    /* "cpyamf/amf0.pyx":371
 *             x = PyList_GET_ITEM(a, i)
 * 
 *             self.writeElement(<object>x)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_x), 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/amf0.pyx":373
 *             self.writeElement(<object>x)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeTuple(self, object a) except -1:
 */
  __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_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeList");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":351
 *         return self.writeType(TYPE_NULL)
 * 
 *     cpdef int writeList(self, object a, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write array to the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpyamf_4amf0_7Encoder_2writeList[] = "\n        Write array to the stream.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 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__a,&__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__a);
      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 = 351; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_a = 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 = 351; __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 = 351; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_a = 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 = 351; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf0.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_4amf0_Encoder *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.writeList(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_a, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __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 = 351; __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.amf0.Encoder.writeList");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":375
 *         return 0
 * 
 *     cdef int writeTuple(self, object a) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size, i
 *         cdef PyObject *x
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeTuple(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_a) {
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_x;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("writeTuple");

  /* "cpyamf/amf0.pyx":379
 *         cdef PyObject *x
 * 
 *         if self.writeReference(a) != -1:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeReference(__pyx_v_self, __pyx_v_a); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != -1);
  if (__pyx_t_2) {

    /* "cpyamf/amf0.pyx":380
 * 
 *         if self.writeReference(a) != -1:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(a)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":382
 *             return 0
 * 
 *         self.context.addObject(a)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_ARRAY)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_a, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":384
 *         self.context.addObject(a)
 * 
 *         self.writeType(TYPE_ARRAY)             # <<<<<<<<<<<<<<
 *         size = PyTuple_GET_SIZE(a)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_ARRAY); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":385
 * 
 *         self.writeType(TYPE_ARRAY)
 *         size = PyTuple_GET_SIZE(a)             # <<<<<<<<<<<<<<
 * 
 *         self.stream.write_ulong(size)
 */
  __pyx_v_size = PyTuple_GET_SIZE(__pyx_v_a);

  /* "cpyamf/amf0.pyx":387
 *         size = PyTuple_GET_SIZE(a)
 * 
 *         self.stream.write_ulong(size)             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < size:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_size, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":389
 *         self.stream.write_ulong(size)
 * 
 *         for i from 0 <= i < size:             # <<<<<<<<<<<<<<
 *             x = PyTuple_GET_ITEM(a, i)
 * 
 */
  __pyx_t_3 = __pyx_v_size;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "cpyamf/amf0.pyx":390
 * 
 *         for i from 0 <= i < size:
 *             x = PyTuple_GET_ITEM(a, i)             # <<<<<<<<<<<<<<
 * 
 *             self.writeElement(<object>x)
 */
    __pyx_v_x = PyTuple_GET_ITEM(__pyx_v_a, __pyx_v_i);

    /* "cpyamf/amf0.pyx":392
 *             x = PyTuple_GET_ITEM(a, i)
 * 
 *             self.writeElement(<object>x)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_x), 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/amf0.pyx":394
 *             self.writeElement(<object>x)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeInt(self, object a) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf0.pyx":396
 *         return 0
 * 
 *     cdef int writeInt(self, object a) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_NUMBER)
 * 
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeInt(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_a) {
  int __pyx_r;
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("writeInt");

  /* "cpyamf/amf0.pyx":397
 * 
 *     cdef int writeInt(self, object a) except -1:
 *         self.writeType(TYPE_NUMBER)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write_double(a)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_NUMBER); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":399
 *         self.writeType(TYPE_NUMBER)
 * 
 *         return self.stream.write_double(a)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeNumber(self, n) except -1:
 */
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_a); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_double(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_t_2, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __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.amf0.Encoder.writeInt");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":401
 *         return self.stream.write_double(a)
 * 
 *     cdef int writeNumber(self, n) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_NUMBER)
 * 
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeNumber(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  int __pyx_r;
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("writeNumber");

  /* "cpyamf/amf0.pyx":402
 * 
 *     cdef int writeNumber(self, n) except -1:
 *         self.writeType(TYPE_NUMBER)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write_double(n)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_NUMBER); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":404
 *         self.writeType(TYPE_NUMBER)
 * 
 *         return self.stream.write_double(n)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeLong(self, object a):
 */
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_n); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_double(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_t_2, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __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.amf0.Encoder.writeNumber");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":406
 *         return self.stream.write_double(n)
 * 
 *     cdef int writeLong(self, object a):             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_NUMBER)
 * 
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeLong(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_a) {
  int __pyx_r;
  int __pyx_t_1;
  double __pyx_t_2;
  __Pyx_RefNannySetupContext("writeLong");

  /* "cpyamf/amf0.pyx":407
 * 
 *     cdef int writeLong(self, object a):
 *         self.writeType(TYPE_NUMBER)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write_double(a)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_NUMBER); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":409
 *         self.writeType(TYPE_NUMBER)
 * 
 *         return self.stream.write_double(a)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeBytes(self, s) except -1:
 */
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_a); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_double(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_t_2, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __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.amf0.Encoder.writeLong");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":411
 *         return self.stream.write_double(a)
 * 
 *     cdef int writeBytes(self, s) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write a string of bytes to the data stream.
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeBytes(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_s) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("writeBytes");

  /* "cpyamf/amf0.pyx":415
 *         Write a string of bytes to the data stream.
 *         """
 *         cdef Py_ssize_t l = PyString_GET_SIZE(s)             # <<<<<<<<<<<<<<
 * 
 *         if l > 0xffff:
 */
  __pyx_v_l = PyString_GET_SIZE(__pyx_v_s);

  /* "cpyamf/amf0.pyx":417
 *         cdef Py_ssize_t l = PyString_GET_SIZE(s)
 * 
 *         if l > 0xffff:             # <<<<<<<<<<<<<<
 *             self.writeType(TYPE_LONGSTRING)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_l > 0xffff);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":418
 * 
 *         if l > 0xffff:
 *             self.writeType(TYPE_LONGSTRING)             # <<<<<<<<<<<<<<
 *         else:
 *             self.writeType(TYPE_STRING)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_LONGSTRING); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cpyamf/amf0.pyx":420
 *             self.writeType(TYPE_LONGSTRING)
 *         else:
 *             self.writeType(TYPE_STRING)             # <<<<<<<<<<<<<<
 * 
 *         if l > 0xffff:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_STRING); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":422
 *             self.writeType(TYPE_STRING)
 * 
 *         if l > 0xffff:             # <<<<<<<<<<<<<<
 *             self.stream.write_ulong(l)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_l > 0xffff);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":423
 * 
 *         if l > 0xffff:
 *             self.stream.write_ulong(l)             # <<<<<<<<<<<<<<
 *         else:
 *             self.stream.write_ushort(l)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_l, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "cpyamf/amf0.pyx":425
 *             self.stream.write_ulong(l)
 *         else:
 *             self.stream.write_ushort(l)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write(PyString_AS_STRING(s), l)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ushort(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_l, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  /* "cpyamf/amf0.pyx":427
 *             self.stream.write_ushort(l)
 * 
 *         return self.stream.write(PyString_AS_STRING(s), l)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeString(self, u) except -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.__pyx_base.stream, PyString_AS_STRING(__pyx_v_s), __pyx_v_l); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __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.amf0.Encoder.writeBytes");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":429
 *         return self.stream.write(PyString_AS_STRING(s), l)
 * 
 *     cdef int writeString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write a unicode to the data stream.
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeString(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_u) {
  PyObject *__pyx_v_s = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("writeString");

  /* "cpyamf/amf0.pyx":433
 *         Write a unicode to the data stream.
 *         """
 *         cdef object s = self.context.getBytesForString(u)             # <<<<<<<<<<<<<<
 * 
 *         return self.writeBytes(s)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getBytesForString(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_u, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":435
 *         cdef object s = self.context.getBytesForString(u)
 * 
 *         return self.writeBytes(s)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int serialiseString(self, u) except -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeBytes(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_s); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __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_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":437
 *         return self.writeBytes(s)
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Similar to L{writeString} but does not encode a type byte.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_3serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static  int __pyx_f_6cpyamf_4amf0_7Encoder_serialiseString(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_u, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_l;
  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("serialiseString");
  __Pyx_INCREF(__pyx_v_u);
  /* 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 = 437; __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_4amf0_7Encoder_3serialiseString)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __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 = 437; __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 = 437; __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/amf0.pyx":441
 *         Similar to L{writeString} but does not encode a type byte.
 *         """
 *         if PyUnicode_CheckExact(u):             # <<<<<<<<<<<<<<
 *             u = self.context.getBytesForString(u)
 * 
 */
  __pyx_t_5 = PyUnicode_CheckExact(__pyx_v_u);
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":442
 *         """
 *         if PyUnicode_CheckExact(u):
 *             u = self.context.getBytesForString(u)             # <<<<<<<<<<<<<<
 * 
 *         cdef Py_ssize_t l = PyString_GET_SIZE(u)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getBytesForString(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_u, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_u);
    __pyx_v_u = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":444
 *             u = self.context.getBytesForString(u)
 * 
 *         cdef Py_ssize_t l = PyString_GET_SIZE(u)             # <<<<<<<<<<<<<<
 * 
 *         if l > 0xffff:
 */
  __pyx_v_l = PyString_GET_SIZE(__pyx_v_u);

  /* "cpyamf/amf0.pyx":446
 *         cdef Py_ssize_t l = PyString_GET_SIZE(u)
 * 
 *         if l > 0xffff:             # <<<<<<<<<<<<<<
 *             self.stream.write_ulong(l)
 *         else:
 */
  __pyx_t_5 = (__pyx_v_l > 0xffff);
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":447
 * 
 *         if l > 0xffff:
 *             self.stream.write_ulong(l)             # <<<<<<<<<<<<<<
 *         else:
 *             self.stream.write_ushort(l)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_l, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "cpyamf/amf0.pyx":449
 *             self.stream.write_ulong(l)
 *         else:
 *             self.stream.write_ushort(l)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write(PyString_AS_STRING(u), l)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ushort(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_l, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  /* "cpyamf/amf0.pyx":451
 *             self.stream.write_ushort(l)
 * 
 *         return self.stream.write(PyString_AS_STRING(u), l)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeXML(self, e) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.__pyx_base.stream, PyString_AS_STRING(__pyx_v_u), __pyx_v_l); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __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.amf0.Encoder.serialiseString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_u);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":437
 *         return self.writeBytes(s)
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Similar to L{writeString} but does not encode a type byte.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_3serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static char __pyx_doc_6cpyamf_4amf0_7Encoder_3serialiseString[] = "\n        Similar to L{writeString} but does not encode a type byte.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_3serialiseString(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_4amf0_Encoder *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.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 = 437; __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 = 437; __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.amf0.Encoder.serialiseString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":453
 *         return self.stream.write(PyString_AS_STRING(u), l)
 * 
 *     cdef int writeXML(self, e) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Writes an XML instance.
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeXML(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_e) {
  PyObject *__pyx_v_data;
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("writeXML");
  __pyx_v_data = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":457
 *         Writes an XML instance.
 *         """
 *         self.writeType(TYPE_XML)             # <<<<<<<<<<<<<<
 * 
 *         data = xml.tostring(e)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_XML); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":459
 *         self.writeType(TYPE_XML)
 * 
 *         data = xml.tostring(e)             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(data, unicode):
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__xml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__tostring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_e);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_e);
  __Pyx_GIVEREF(__pyx_v_e);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_data);
  __pyx_v_data = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cpyamf/amf0.pyx":461
 *         data = xml.tostring(e)
 * 
 *         if isinstance(data, unicode):             # <<<<<<<<<<<<<<
 *             data = data.encode('utf-8')
 * 
 */
  __pyx_t_5 = PyUnicode_Check(__pyx_v_data); 
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":462
 * 
 *         if isinstance(data, unicode):
 *             data = data.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         if not PyString_CheckExact(data):
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_data);
    __pyx_v_data = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":464
 *             data = data.encode('utf-8')
 * 
 *         if not PyString_CheckExact(data):             # <<<<<<<<<<<<<<
 *             raise TypeError('expected str from xml.tostring')
 * 
 */
  __pyx_t_5 = (!PyString_CheckExact(__pyx_v_data));
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":465
 * 
 *         if not PyString_CheckExact(data):
 *             raise TypeError('expected str from xml.tostring')             # <<<<<<<<<<<<<<
 * 
 *         cdef Py_ssize_t l = PyString_GET_SIZE(data)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf0.pyx":467
 *             raise TypeError('expected str from xml.tostring')
 * 
 *         cdef Py_ssize_t l = PyString_GET_SIZE(data)             # <<<<<<<<<<<<<<
 * 
 *         self.stream.write_ulong(l)
 */
  __pyx_v_l = PyString_GET_SIZE(__pyx_v_data);

  /* "cpyamf/amf0.pyx":469
 *         cdef Py_ssize_t l = PyString_GET_SIZE(data)
 * 
 *         self.stream.write_ulong(l)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write(PyString_AS_STRING(data), l)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_v_l, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":471
 *         self.stream.write_ulong(l)
 * 
 *         return self.stream.write(PyString_AS_STRING(data), l)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDateTime(self, d) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.__pyx_base.stream, PyString_AS_STRING(__pyx_v_data), __pyx_v_l); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __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_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeXML");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_data);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":473
 *         return self.stream.write(PyString_AS_STRING(data), l)
 * 
 *     cdef int writeDateTime(self, d) except -1:             # <<<<<<<<<<<<<<
 *         if self.timezone_offset is not None:
 *             d -= self.timezone_offset
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeDateTime(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_d) {
  PyObject *__pyx_v_secs;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  double __pyx_t_6;
  __Pyx_RefNannySetupContext("writeDateTime");
  __Pyx_INCREF(__pyx_v_d);
  __pyx_v_secs = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":474
 * 
 *     cdef int writeDateTime(self, d) except -1:
 *         if self.timezone_offset is not None:             # <<<<<<<<<<<<<<
 *             d -= self.timezone_offset
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.__pyx_base.timezone_offset != Py_None);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":475
 *     cdef int writeDateTime(self, d) except -1:
 *         if self.timezone_offset is not None:
 *             d -= self.timezone_offset             # <<<<<<<<<<<<<<
 * 
 *         secs = util.get_timestamp(d)
 */
    __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_v_d, __pyx_v_self->__pyx_base.__pyx_base.timezone_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_d);
    __pyx_v_d = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":477
 *             d -= self.timezone_offset
 * 
 *         secs = util.get_timestamp(d)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_DATE)
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__get_timestamp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_d);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_d);
  __Pyx_GIVEREF(__pyx_v_d);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_secs);
  __pyx_v_secs = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cpyamf/amf0.pyx":479
 *         secs = util.get_timestamp(d)
 * 
 *         self.writeType(TYPE_DATE)             # <<<<<<<<<<<<<<
 *         self.stream.write_double(secs * 1000.0)
 * 
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_DATE); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":480
 * 
 *         self.writeType(TYPE_DATE)
 *         self.stream.write_double(secs * 1000.0)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write('\x00\x00', 2)
 */
  __pyx_t_4 = PyFloat_FromDouble(1000.0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_secs, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_double(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_t_6, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":482
 *         self.stream.write_double(secs * 1000.0)
 * 
 *         return self.stream.write('\x00\x00', 2)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDict(self, dict o) except -1:
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_k_17, 2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeDateTime");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_secs);
  __Pyx_DECREF(__pyx_v_d);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":484
 *         return self.stream.write('\x00\x00', 2)
 * 
 *     cdef int writeDict(self, dict o) except -1:             # <<<<<<<<<<<<<<
 *         if self.writeReference(o) != -1:
 *             return 0
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeDict(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("writeDict");

  /* "cpyamf/amf0.pyx":485
 * 
 *     cdef int writeDict(self, dict o) except -1:
 *         if self.writeReference(o) != -1:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeReference(__pyx_v_self, ((PyObject *)__pyx_v_o)); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != -1);
  if (__pyx_t_2) {

    /* "cpyamf/amf0.pyx":486
 *     cdef int writeDict(self, dict o) except -1:
 *         if self.writeReference(o) != -1:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(o)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":488
 *             return 0
 * 
 *         self.context.addObject(o)             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_OBJECT)
 *         self._writeDict(o)
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), ((PyObject *)__pyx_v_o), 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":489
 * 
 *         self.context.addObject(o)
 *         self.writeType(TYPE_OBJECT)             # <<<<<<<<<<<<<<
 *         self._writeDict(o)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_OBJECT); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":490
 *         self.context.addObject(o)
 *         self.writeType(TYPE_OBJECT)
 *         self._writeDict(o)             # <<<<<<<<<<<<<<
 * 
 *         return self._writeEndObject()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeDict(__pyx_v_self, __pyx_v_o); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":492
 *         self._writeDict(o)
 * 
 *         return self._writeEndObject()             # <<<<<<<<<<<<<<
 * 
 *     cdef int _writeDict(self, dict attrs) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeEndObject(__pyx_v_self); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __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.amf0.Encoder.writeDict");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":494
 *         return self._writeEndObject()
 * 
 *     cdef int _writeDict(self, dict attrs) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write C{dict} to the data stream.
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder__writeDict(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_attrs) {
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  void *__pyx_t_3;
  void *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("_writeDict");
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":500
 *         @param o: The C{dict} data to be encoded to the AMF0 data stream.
 *         """
 *         for key, value in attrs.iteritems():             # <<<<<<<<<<<<<<
 *             if PyInt_Check(key) or PyLong_Check(key):
 *                 key = str(key)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_attrs));
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = ((PyObject *)__pyx_v_attrs);
  __pyx_t_2 = 0;
  while (1) {
    if (!PyDict_Next(__pyx_t_1, (&__pyx_t_2), ((PyObject **)(&__pyx_t_3)), ((PyObject **)(&__pyx_t_4)))) break;
    __Pyx_INCREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_v_key);
    __pyx_v_key = ((PyObject *)__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = ((PyObject *)__pyx_t_4);

    /* "cpyamf/amf0.pyx":501
 *         """
 *         for key, value in attrs.iteritems():
 *             if PyInt_Check(key) or PyLong_Check(key):             # <<<<<<<<<<<<<<
 *                 key = str(key)
 * 
 */
    __pyx_t_5 = PyInt_Check(__pyx_v_key);
    if (!__pyx_t_5) {
      __pyx_t_6 = PyLong_Check(__pyx_v_key);
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_5;
    }
    if (__pyx_t_7) {

      /* "cpyamf/amf0.pyx":502
 *         for key, value in attrs.iteritems():
 *             if PyInt_Check(key) or PyLong_Check(key):
 *                 key = str(key)             # <<<<<<<<<<<<<<
 * 
 *             self.serialiseString(key)
 */
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_INCREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_9;
      __pyx_t_9 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cpyamf/amf0.pyx":504
 *                 key = str(key)
 * 
 *             self.serialiseString(key)             # <<<<<<<<<<<<<<
 *             self.writeElement(value)
 * 
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_key, 0); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":505
 * 
 *             self.serialiseString(key)
 *             self.writeElement(value)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_value, 0); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":507
 *             self.writeElement(value)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int _writeEndObject(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder._writeDict");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":509
 *         return 0
 * 
 *     cdef inline int _writeEndObject(self) except -1:             # <<<<<<<<<<<<<<
 *         return self.stream.write('\x00\x00\x09', 3)
 * 
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf0_7Encoder__writeEndObject(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_writeEndObject");

  /* "cpyamf/amf0.pyx":510
 * 
 *     cdef inline int _writeEndObject(self) except -1:
 *         return self.stream.write('\x00\x00\x09', 3)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeObject(self, o, bint is_proxy=0) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_k_5, 3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __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.amf0.Encoder._writeEndObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":512
 *         return self.stream.write('\x00\x00\x09', 3)
 * 
 *     cpdef int writeObject(self, o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write a Python object to the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_4writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeObject(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_o, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4amf0_7Encoder_writeObject *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  PyObject *__pyx_v_alias;
  PyObject *__pyx_v_attrs = 0;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  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;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("writeObject");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_is_proxy = __pyx_optional_args->is_proxy;
    }
  }
  __pyx_v_alias = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = 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__writeObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __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_4amf0_7Encoder_4writeObject)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __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 = 512; __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 = 512; __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 = 512; __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/amf0.pyx":518
 *         @param o: The object data to be encoded to the AMF0 data stream.
 *         """
 *         if self.writeReference(o) != -1:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeReference(__pyx_v_self, __pyx_v_o); if (unlikely(__pyx_t_4 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != -1);
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":519
 *         """
 *         if self.writeReference(o) != -1:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(o)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":521
 *             return 0
 * 
 *         self.context.addObject(o)             # <<<<<<<<<<<<<<
 *         alias = self.context.getClassAlias(o.__class__)
 * 
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_o, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":522
 * 
 *         self.context.addObject(o)
 *         alias = self.context.getClassAlias(o.__class__)             # <<<<<<<<<<<<<<
 * 
 *         alias.compile()
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_o, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_alias);
  __pyx_v_alias = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf0.pyx":524
 *         alias = self.context.getClassAlias(o.__class__)
 * 
 *         alias.compile()             # <<<<<<<<<<<<<<
 * 
 *         if alias.amf3:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":526
 *         alias.compile()
 * 
 *         if alias.amf3:             # <<<<<<<<<<<<<<
 *             return self.writeAMF3(o)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__amf3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":527
 * 
 *         if alias.amf3:
 *             return self.writeAMF3(o)             # <<<<<<<<<<<<<<
 * 
 *         if alias.anonymous:
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeAMF3(__pyx_v_self, __pyx_v_o); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf0.pyx":529
 *             return self.writeAMF3(o)
 * 
 *         if alias.anonymous:             # <<<<<<<<<<<<<<
 *             self.writeType(TYPE_OBJECT)
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__anonymous); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/amf0.pyx":530
 * 
 *         if alias.anonymous:
 *             self.writeType(TYPE_OBJECT)             # <<<<<<<<<<<<<<
 *         else:
 *             self.writeType(TYPE_TYPEDOBJECT)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_OBJECT); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "cpyamf/amf0.pyx":532
 *             self.writeType(TYPE_OBJECT)
 *         else:
 *             self.writeType(TYPE_TYPEDOBJECT)             # <<<<<<<<<<<<<<
 *             self.serialiseString(alias.alias)
 * 
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_TYPEDOBJECT); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":533
 *         else:
 *             self.writeType(TYPE_TYPEDOBJECT)
 *             self.serialiseString(alias.alias)             # <<<<<<<<<<<<<<
 * 
 *         cdef dict attrs = alias.getEncodableAttributes(o, codec=self)
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__alias); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_1, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;

  /* "cpyamf/amf0.pyx":535
 *             self.serialiseString(alias.alias)
 * 
 *         cdef dict attrs = alias.getEncodableAttributes(o, codec=self)             # <<<<<<<<<<<<<<
 * 
 *         if len(attrs) and alias.static_attrs:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s_18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __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 = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__codec), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_attrs = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "cpyamf/amf0.pyx":537
 *         cdef dict attrs = alias.getEncodableAttributes(o, codec=self)
 * 
 *         if len(attrs) and alias.static_attrs:             # <<<<<<<<<<<<<<
 *             for key in alias.static_attrs:
 *                 value = attrs.pop(key)
 */
  if (unlikely(__pyx_v_attrs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_6 = PyDict_Size(((PyObject *)__pyx_v_attrs)); 
  if (__pyx_t_6) {
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); 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_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;
    __pyx_t_8 = __pyx_t_5;
  } else {
    __pyx_t_8 = __pyx_t_6;
  }
  if (__pyx_t_8) {

    /* "cpyamf/amf0.pyx":538
 * 
 *         if len(attrs) and alias.static_attrs:
 *             for key in alias.static_attrs:             # <<<<<<<<<<<<<<
 *                 value = attrs.pop(key)
 * 
 */
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
      __pyx_t_6 = 0; __pyx_t_3 = __pyx_t_7; __Pyx_INCREF(__pyx_t_3);
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++;
      } else {
        __pyx_t_7 = PyIter_Next(__pyx_t_3);
        if (!__pyx_t_7) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "cpyamf/amf0.pyx":539
 *         if len(attrs) and alias.static_attrs:
 *             for key in alias.static_attrs:
 *                 value = attrs.pop(key)             # <<<<<<<<<<<<<<
 * 
 *                 self.serialiseString(key)
 */
      __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_attrs), __pyx_n_s__pop); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "cpyamf/amf0.pyx":541
 *                 value = attrs.pop(key)
 * 
 *                 self.serialiseString(key)             # <<<<<<<<<<<<<<
 *                 self.writeElement(value)
 * 
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_key, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cpyamf/amf0.pyx":542
 * 
 *                 self.serialiseString(key)
 *                 self.writeElement(value)             # <<<<<<<<<<<<<<
 * 
 *         if attrs:
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_value, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/amf0.pyx":544
 *                 self.writeElement(value)
 * 
 *         if attrs:             # <<<<<<<<<<<<<<
 *             self._writeDict(attrs)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_attrs)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_8) {

    /* "cpyamf/amf0.pyx":545
 * 
 *         if attrs:
 *             self._writeDict(attrs)             # <<<<<<<<<<<<<<
 * 
 *         return self._writeEndObject()
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeDict(__pyx_v_self, __pyx_v_attrs); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "cpyamf/amf0.pyx":547
 *             self._writeDict(attrs)
 * 
 *         return self._writeEndObject()             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeMixedArray(self, o) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeEndObject(__pyx_v_self); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_alias);
  __Pyx_XDECREF(__pyx_v_attrs);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":512
 *         return self.stream.write('\x00\x00\x09', 3)
 * 
 *     cpdef int writeObject(self, o, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Write a Python object to the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_4writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpyamf_4amf0_7Encoder_4writeObject[] = "\n        Write a Python object to the stream.\n\n        @param o: The object data to be encoded to the AMF0 data stream.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_4writeObject(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 = 512; __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 = 512; __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 = 512; __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 = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf0.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_4amf0_Encoder *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.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 = 512; __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 = 512; __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.amf0.Encoder.writeObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":549
 *         return self._writeEndObject()
 * 
 *     cdef int writeMixedArray(self, o) except -1:             # <<<<<<<<<<<<<<
 *         if self.writeReference(o) != -1:
 *             return 0
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeMixedArray(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_v_max_index;
  PyObject *__pyx_v_y;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  unsigned long __pyx_t_9;
  __Pyx_RefNannySetupContext("writeMixedArray");
  __pyx_v_max_index = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_y = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf0.pyx":550
 * 
 *     cdef int writeMixedArray(self, o) except -1:
 *         if self.writeReference(o) != -1:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeReference(__pyx_v_self, __pyx_v_o); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != -1);
  if (__pyx_t_2) {

    /* "cpyamf/amf0.pyx":551
 *     cdef int writeMixedArray(self, o) except -1:
 *         if self.writeReference(o) != -1:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(o)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":553
 *             return 0
 * 
 *         self.context.addObject(o)             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_MIXEDARRAY)
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_o, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":554
 * 
 *         self.context.addObject(o)
 *         self.writeType(TYPE_MIXEDARRAY)             # <<<<<<<<<<<<<<
 * 
 *         # TODO: optimise this
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_MIXEDARRAY); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":558
 *         # TODO: optimise this
 *         # work out the highest integer index
 *         try:             # <<<<<<<<<<<<<<
 *             # list comprehensions to save the day
 *             max_index = max([y[0] for y in o.items()
 */
  {
    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/amf0.pyx":560
 *         try:
 *             # list comprehensions to save the day
 *             max_index = max([y[0] for y in o.items()             # <<<<<<<<<<<<<<
 *                 if isinstance(y[0], (int, long))])
 * 
 */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_5 = PyObject_GetAttr(__pyx_v_o, __pyx_n_s__items); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
        __pyx_t_3 = 0; __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5);
      } else {
        __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break;
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
        } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
          if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
        } else {
          __pyx_t_6 = PyIter_Next(__pyx_t_5);
          if (!__pyx_t_6) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            break;
          }
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_v_y);
        __pyx_v_y = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "cpyamf/amf0.pyx":561
 *             # list comprehensions to save the day
 *             max_index = max([y[0] for y in o.items()
 *                 if isinstance(y[0], (int, long))])             # <<<<<<<<<<<<<<
 * 
 *             if max_index < 0:
 */
        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_y, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_2 = PyInt_Check(__pyx_t_6); 
        if (!__pyx_t_2) {
          __pyx_t_7 = PyLong_Check(__pyx_t_6); 
          __pyx_t_8 = __pyx_t_7;
        } else {
          __pyx_t_8 = __pyx_t_2;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_8) {

          /* "cpyamf/amf0.pyx":560
 *         try:
 *             # list comprehensions to save the day
 *             max_index = max([y[0] for y in o.items()             # <<<<<<<<<<<<<<
 *                 if isinstance(y[0], (int, long))])
 * 
 */
          __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_y, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_6);
          if (unlikely(PyList_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L14;
        }
        __pyx_L14:;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __Pyx_INCREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_max_index);
      __pyx_v_max_index = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cpyamf/amf0.pyx":563
 *                 if isinstance(y[0], (int, long))])
 * 
 *             if max_index < 0:             # <<<<<<<<<<<<<<
 *                 max_index = 0
 *         except ValueError:
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_max_index, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_8) {

        /* "cpyamf/amf0.pyx":564
 * 
 *             if max_index < 0:
 *                 max_index = 0             # <<<<<<<<<<<<<<
 *         except ValueError:
 *             max_index = 0
 */
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_DECREF(__pyx_v_max_index);
        __pyx_v_max_index = __pyx_int_0;
        goto __pyx_L15;
      }
      __pyx_L15:;
    }
    __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_L4_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpyamf/amf0.pyx":565
 *             if max_index < 0:
 *                 max_index = 0
 *         except ValueError:             # <<<<<<<<<<<<<<
 *             max_index = 0
 * 
 */
    __pyx_t_1 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_1) {
      __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeMixedArray");
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);

      /* "cpyamf/amf0.pyx":566
 *                 max_index = 0
 *         except ValueError:
 *             max_index = 0             # <<<<<<<<<<<<<<
 * 
 *         self.stream.write_ulong(max_index)
 */
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_DECREF(__pyx_v_max_index);
      __pyx_v_max_index = __pyx_int_0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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:;
  }

  /* "cpyamf/amf0.pyx":568
 *             max_index = 0
 * 
 *         self.stream.write_ulong(max_index)             # <<<<<<<<<<<<<<
 * 
 *         self._writeDict(dict(o))
 */
  __pyx_t_9 = __Pyx_PyInt_AsUnsignedLong(__pyx_v_max_index); if (unlikely((__pyx_t_9 == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_ulong(__pyx_v_self->__pyx_base.__pyx_base.stream, __pyx_t_9, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":570
 *         self.stream.write_ulong(max_index)
 * 
 *         self._writeDict(dict(o))             # <<<<<<<<<<<<<<
 *         self._writeEndObject()
 * 
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeDict(__pyx_v_self, ((PyObject*)__pyx_t_5)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cpyamf/amf0.pyx":571
 * 
 *         self._writeDict(dict(o))
 *         self._writeEndObject()             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeAMF3(self, o) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_writeEndObject(__pyx_v_self); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpyamf.amf0.Encoder.writeMixedArray");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_max_index);
  __Pyx_DECREF(__pyx_v_y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":573
 *         self._writeEndObject()
 * 
 *     cdef int writeAMF3(self, o) except -1:             # <<<<<<<<<<<<<<
 *         if self.amf3_encoder is None:
 *             self.context.amf3_context = amf3.Context()
 */

static  int __pyx_f_6cpyamf_4amf0_7Encoder_writeAMF3(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_o) {
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("writeAMF3");

  /* "cpyamf/amf0.pyx":574
 * 
 *     cdef int writeAMF3(self, o) except -1:
 *         if self.amf3_encoder is None:             # <<<<<<<<<<<<<<
 *             self.context.amf3_context = amf3.Context()
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->amf3_encoder) == Py_None);
  if (__pyx_t_1) {

    /* "cpyamf/amf0.pyx":575
 *     cdef int writeAMF3(self, o) except -1:
 *         if self.amf3_encoder is None:
 *             self.context.amf3_context = amf3.Context()             # <<<<<<<<<<<<<<
 * 
 *             self.amf3_encoder = amf3.Encoder(
 */
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_Context)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->context->amf3_context);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->context->amf3_context));
    __pyx_v_self->context->amf3_context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cpyamf/amf0.pyx":577
 *             self.context.amf3_context = amf3.Context()
 * 
 *             self.amf3_encoder = amf3.Encoder(             # <<<<<<<<<<<<<<
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));

    /* "cpyamf/amf0.pyx":578
 * 
 *             self.amf3_encoder = amf3.Encoder(
 *                 stream=self.stream,             # <<<<<<<<<<<<<<
 *                 context=self.context.amf3_context,
 *                 timezone_offset=self.timezone_offset)
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__stream), ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":579
 *             self.amf3_encoder = amf3.Encoder(
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,             # <<<<<<<<<<<<<<
 *                 timezone_offset=self.timezone_offset)
 * 
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__context), ((PyObject *)__pyx_v_self->context->amf3_context)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf0.pyx":580
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 *                 timezone_offset=self.timezone_offset)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_AMF3)
 */
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__timezone_offset), __pyx_v_self->__pyx_base.__pyx_base.timezone_offset) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_Encoder)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

    /* "cpyamf/amf0.pyx":577
 *             self.context.amf3_context = amf3.Context()
 * 
 *             self.amf3_encoder = amf3.Encoder(             # <<<<<<<<<<<<<<
 *                 stream=self.stream,
 *                 context=self.context.amf3_context,
 */
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->amf3_encoder);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->amf3_encoder));
    __pyx_v_self->amf3_encoder = ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":582
 *                 timezone_offset=self.timezone_offset)
 * 
 *         self.writeType(TYPE_AMF3)             # <<<<<<<<<<<<<<
 *         self.amf3_encoder.writeElement(o)
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf0_TYPE_AMF3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf0.pyx":583
 * 
 *         self.writeType(TYPE_AMF3)
 *         self.amf3_encoder.writeElement(o)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->amf3_encoder->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self->amf3_encoder), __pyx_v_o, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

/* "cpyamf/amf0.pyx":585
 *         self.amf3_encoder.writeElement(o)
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:             # <<<<<<<<<<<<<<
 *         if self.use_amf3:
 *             return self.writeAMF3(element)
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf0_7Encoder_handleBasicTypes(struct __pyx_obj_6cpyamf_4amf0_Encoder *__pyx_v_self, PyObject *__pyx_v_element, PyObject *__pyx_v_py_type) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("handleBasicTypes");

  /* "cpyamf/amf0.pyx":586
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 *         if self.use_amf3:             # <<<<<<<<<<<<<<
 *             return self.writeAMF3(element)
 * 
 */
  if (__pyx_v_self->use_amf3) {

    /* "cpyamf/amf0.pyx":587
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 *         if self.use_amf3:
 *             return self.writeAMF3(element)             # <<<<<<<<<<<<<<
 * 
 *         return codec.Encoder.handleBasicTypes(self, element, py_type)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf0_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeAMF3(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf0.pyx":589
 *             return self.writeAMF3(element)
 * 
 *         return codec.Encoder.handleBasicTypes(self, element, py_type)             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_vtabptr_6cpyamf_5codec_Encoder->handleBasicTypes(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_element, __pyx_v_py_type); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __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.amf0.Encoder.handleBasicTypes");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf0.pyx":304
 *     """
 * 
 *     cdef public bint use_amf3             # <<<<<<<<<<<<<<
 *     cdef readonly Context context
 *     cdef amf3.Encoder amf3_encoder
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_8use_amf3___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_8use_amf3___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_4amf0_Encoder *)__pyx_v_self)->use_amf3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __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.amf0.Encoder.use_amf3.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6cpyamf_4amf0_7Encoder_8use_amf3_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_6cpyamf_4amf0_7Encoder_8use_amf3_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[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->use_amf3 = __pyx_t_1;

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

/* "cpyamf/amf0.pyx":305
 * 
 *     cdef public bint use_amf3
 *     cdef readonly Context context             # <<<<<<<<<<<<<<
 *     cdef amf3.Encoder amf3_encoder
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_7context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf0_7Encoder_7context___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_4amf0_Encoder *)__pyx_v_self)->context);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6cpyamf_4amf0_Context __pyx_vtable_6cpyamf_4amf0_Context;

static PyObject *__pyx_tp_new_6cpyamf_4amf0_Context(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf0_Context *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Context->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf0_Context *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Context*)__pyx_vtabptr_6cpyamf_4amf0_Context;
  p->amf3_context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf0_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Context *p = (struct __pyx_obj_6cpyamf_4amf0_Context *)o;
  Py_XDECREF(((PyObject *)p->amf3_context));
  __pyx_ptype_6cpyamf_5codec_Context->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf0_Context(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf0_Context *p = (struct __pyx_obj_6cpyamf_4amf0_Context *)o;
  if (__pyx_ptype_6cpyamf_5codec_Context->tp_traverse) {
    e = __pyx_ptype_6cpyamf_5codec_Context->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->amf3_context) {
    e = (*v)(((PyObject*)p->amf3_context), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf0_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Context *p = (struct __pyx_obj_6cpyamf_4amf0_Context *)o;
  PyObject* tmp;
  if (__pyx_ptype_6cpyamf_5codec_Context->tp_clear) {
    __pyx_ptype_6cpyamf_5codec_Context->tp_clear(o);
  }
  tmp = ((PyObject*)p->amf3_context);
  p->amf3_context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6cpyamf_4amf0_Context[] = {
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pf_6cpyamf_4amf0_7Context_clear, METH_NOARGS, __Pyx_DOCSTR(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_4amf0_Context = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf0.Context"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf0_Context), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf0_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*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf0_Context, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf0_Context, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf0_Context, /*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_4amf0_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 struct __pyx_vtabstruct_6cpyamf_4amf0_Decoder __pyx_vtable_6cpyamf_4amf0_Decoder;

static PyObject *__pyx_tp_new_6cpyamf_4amf0_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf0_Decoder *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Decoder->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf0_Decoder *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Decoder*)__pyx_vtabptr_6cpyamf_4amf0_Decoder;
  p->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)Py_None); Py_INCREF(Py_None);
  p->amf3_decoder = ((struct __pyx_obj_6cpyamf_4amf3_Decoder *)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_4amf0_7Decoder___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf0_Decoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Decoder *p = (struct __pyx_obj_6cpyamf_4amf0_Decoder *)o;
  Py_XDECREF(((PyObject *)p->context));
  Py_XDECREF(((PyObject *)p->amf3_decoder));
  __pyx_ptype_6cpyamf_5codec_Decoder->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf0_Decoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf0_Decoder *p = (struct __pyx_obj_6cpyamf_4amf0_Decoder *)o;
  if (__pyx_ptype_6cpyamf_5codec_Decoder->tp_traverse) {
    e = __pyx_ptype_6cpyamf_5codec_Decoder->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->context) {
    e = (*v)(((PyObject*)p->context), a); if (e) return e;
  }
  if (p->amf3_decoder) {
    e = (*v)(((PyObject*)p->amf3_decoder), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf0_Decoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Decoder *p = (struct __pyx_obj_6cpyamf_4amf0_Decoder *)o;
  PyObject* tmp;
  if (__pyx_ptype_6cpyamf_5codec_Decoder->tp_clear) {
    __pyx_ptype_6cpyamf_5codec_Decoder->tp_clear(o);
  }
  tmp = ((PyObject*)p->context);
  p->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->amf3_decoder);
  p->amf3_decoder = ((struct __pyx_obj_6cpyamf_4amf3_Decoder *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_4amf0_7Decoder_use_amf3(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf0_7Decoder_8use_amf3___get__(o);
}

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

static PyObject *__pyx_getprop_6cpyamf_4amf0_7Decoder_context(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf0_7Decoder_7context___get__(o);
}

static PyMethodDef __pyx_methods_6cpyamf_4amf0_Decoder[] = {
  {__Pyx_NAMESTR("readString"), (PyCFunction)__pyx_pf_6cpyamf_4amf0_7Decoder_2readString, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_4amf0_Decoder[] = {
  {(char *)"use_amf3", __pyx_getprop_6cpyamf_4amf0_7Decoder_use_amf3, __pyx_setprop_6cpyamf_4amf0_7Decoder_use_amf3, 0, 0},
  {(char *)"context", __pyx_getprop_6cpyamf_4amf0_7Decoder_context, 0, 0, 0},
  {0, 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_4amf0_Decoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf0.Decoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf0_Decoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf0_Decoder, /*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    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf0_Decoder, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf0_Decoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf0_Decoder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_4amf0_Decoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_4amf0_7Decoder_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_4amf0_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_4amf0_Encoder __pyx_vtable_6cpyamf_4amf0_Encoder;

static PyObject *__pyx_tp_new_6cpyamf_4amf0_Encoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf0_Encoder *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Encoder->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf0_Encoder *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Encoder*)__pyx_vtabptr_6cpyamf_4amf0_Encoder;
  p->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)Py_None); Py_INCREF(Py_None);
  p->amf3_encoder = ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_4amf0_7Encoder___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf0_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Encoder *p = (struct __pyx_obj_6cpyamf_4amf0_Encoder *)o;
  Py_XDECREF(((PyObject *)p->context));
  Py_XDECREF(((PyObject *)p->amf3_encoder));
  __pyx_ptype_6cpyamf_5codec_Encoder->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf0_Encoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf0_Encoder *p = (struct __pyx_obj_6cpyamf_4amf0_Encoder *)o;
  if (__pyx_ptype_6cpyamf_5codec_Encoder->tp_traverse) {
    e = __pyx_ptype_6cpyamf_5codec_Encoder->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->context) {
    e = (*v)(((PyObject*)p->context), a); if (e) return e;
  }
  if (p->amf3_encoder) {
    e = (*v)(((PyObject*)p->amf3_encoder), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf0_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf0_Encoder *p = (struct __pyx_obj_6cpyamf_4amf0_Encoder *)o;
  PyObject* tmp;
  if (__pyx_ptype_6cpyamf_5codec_Encoder->tp_clear) {
    __pyx_ptype_6cpyamf_5codec_Encoder->tp_clear(o);
  }
  tmp = ((PyObject*)p->context);
  p->context = ((struct __pyx_obj_6cpyamf_4amf0_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->amf3_encoder);
  p->amf3_encoder = ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_4amf0_7Encoder_use_amf3(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf0_7Encoder_8use_amf3___get__(o);
}

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

static PyObject *__pyx_getprop_6cpyamf_4amf0_7Encoder_context(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf0_7Encoder_7context___get__(o);
}

static PyMethodDef __pyx_methods_6cpyamf_4amf0_Encoder[] = {
  {__Pyx_NAMESTR("writeList"), (PyCFunction)__pyx_pf_6cpyamf_4amf0_7Encoder_2writeList, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf0_7Encoder_2writeList)},
  {__Pyx_NAMESTR("serialiseString"), (PyCFunction)__pyx_pf_6cpyamf_4amf0_7Encoder_3serialiseString, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf0_7Encoder_3serialiseString)},
  {__Pyx_NAMESTR("writeObject"), (PyCFunction)__pyx_pf_6cpyamf_4amf0_7Encoder_4writeObject, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf0_7Encoder_4writeObject)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_4amf0_Encoder[] = {
  {(char *)"use_amf3", __pyx_getprop_6cpyamf_4amf0_7Encoder_use_amf3, __pyx_setprop_6cpyamf_4amf0_7Encoder_use_amf3, 0, 0},
  {(char *)"context", __pyx_getprop_6cpyamf_4amf0_7Encoder_context, 0, 0, 0},
  {0, 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_4amf0_Encoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf0.Encoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf0_Encoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf0_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    The AMF0 Encoder.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf0_Encoder, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf0_Encoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf0_Encoder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_4amf0_Encoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_4amf0_7Encoder_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_4amf0_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 PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("amf0"),
    __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_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_n_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_n_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 1},
  {&__pyx_n_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 1},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__ASObject, __pyx_k__ASObject, sizeof(__pyx_k__ASObject), 0, 0, 1, 1},
  {&__pyx_n_s__DecodeError, __pyx_k__DecodeError, sizeof(__pyx_k__DecodeError), 0, 0, 1, 1},
  {&__pyx_n_s__MixedArray, __pyx_k__MixedArray, sizeof(__pyx_k__MixedArray), 0, 0, 1, 1},
  {&__pyx_n_s__OverflowError, __pyx_k__OverflowError, sizeof(__pyx_k__OverflowError), 0, 0, 1, 1},
  {&__pyx_n_s__ReferenceError, __pyx_k__ReferenceError, sizeof(__pyx_k__ReferenceError), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__UnknownClassAlias, __pyx_k__UnknownClassAlias, sizeof(__pyx_k__UnknownClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 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___writeDict, __pyx_k___writeDict, sizeof(__pyx_k___writeDict), 0, 0, 1, 1},
  {&__pyx_n_s___writeEndObject, __pyx_k___writeEndObject, sizeof(__pyx_k___writeEndObject), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__addObject, __pyx_k__addObject, sizeof(__pyx_k__addObject), 0, 0, 1, 1},
  {&__pyx_n_s__alias, __pyx_k__alias, sizeof(__pyx_k__alias), 0, 0, 1, 1},
  {&__pyx_n_s__amf3, __pyx_k__amf3, sizeof(__pyx_k__amf3), 0, 0, 1, 1},
  {&__pyx_n_s__amf3_context, __pyx_k__amf3_context, sizeof(__pyx_k__amf3_context), 0, 0, 1, 1},
  {&__pyx_n_s__amf3_decoder, __pyx_k__amf3_decoder, sizeof(__pyx_k__amf3_decoder), 0, 0, 1, 1},
  {&__pyx_n_s__amf3_encoder, __pyx_k__amf3_encoder, sizeof(__pyx_k__amf3_encoder), 0, 0, 1, 1},
  {&__pyx_n_s__anonymous, __pyx_k__anonymous, sizeof(__pyx_k__anonymous), 0, 0, 1, 1},
  {&__pyx_n_s__applyAttributes, __pyx_k__applyAttributes, sizeof(__pyx_k__applyAttributes), 0, 0, 1, 1},
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
  {&__pyx_n_s__codec, __pyx_k__codec, sizeof(__pyx_k__codec), 0, 0, 1, 1},
  {&__pyx_n_s__compile, __pyx_k__compile, sizeof(__pyx_k__compile), 0, 0, 1, 1},
  {&__pyx_n_s__context, __pyx_k__context, sizeof(__pyx_k__context), 0, 0, 1, 1},
  {&__pyx_n_s__createInstance, __pyx_k__createInstance, sizeof(__pyx_k__createInstance), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__fromstring, __pyx_k__fromstring, sizeof(__pyx_k__fromstring), 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__getStringForBytes, __pyx_k__getStringForBytes, sizeof(__pyx_k__getStringForBytes), 0, 0, 1, 1},
  {&__pyx_n_s__get_datetime, __pyx_k__get_datetime, sizeof(__pyx_k__get_datetime), 0, 0, 1, 1},
  {&__pyx_n_s__get_timestamp, __pyx_k__get_timestamp, sizeof(__pyx_k__get_timestamp), 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__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
  {&__pyx_n_s__max, __pyx_k__max, sizeof(__pyx_k__max), 0, 0, 1, 1},
  {&__pyx_n_s__o, __pyx_k__o, sizeof(__pyx_k__o), 0, 0, 1, 1},
  {&__pyx_n_s__peek, __pyx_k__peek, sizeof(__pyx_k__peek), 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__readAMF3, __pyx_k__readAMF3, sizeof(__pyx_k__readAMF3), 0, 0, 1, 1},
  {&__pyx_n_s__readBoolean, __pyx_k__readBoolean, sizeof(__pyx_k__readBoolean), 0, 0, 1, 1},
  {&__pyx_n_s__readBytes, __pyx_k__readBytes, sizeof(__pyx_k__readBytes), 0, 0, 1, 1},
  {&__pyx_n_s__readDate, __pyx_k__readDate, sizeof(__pyx_k__readDate), 0, 0, 1, 1},
  {&__pyx_n_s__readElement, __pyx_k__readElement, sizeof(__pyx_k__readElement), 0, 0, 1, 1},
  {&__pyx_n_s__readList, __pyx_k__readList, sizeof(__pyx_k__readList), 0, 0, 1, 1},
  {&__pyx_n_s__readLongString, __pyx_k__readLongString, sizeof(__pyx_k__readLongString), 0, 0, 1, 1},
  {&__pyx_n_s__readMixedArray, __pyx_k__readMixedArray, sizeof(__pyx_k__readMixedArray), 0, 0, 1, 1},
  {&__pyx_n_s__readNull, __pyx_k__readNull, sizeof(__pyx_k__readNull), 0, 0, 1, 1},
  {&__pyx_n_s__readNumber, __pyx_k__readNumber, sizeof(__pyx_k__readNumber), 0, 0, 1, 1},
  {&__pyx_n_s__readObject, __pyx_k__readObject, sizeof(__pyx_k__readObject), 0, 0, 1, 1},
  {&__pyx_n_s__readReference, __pyx_k__readReference, sizeof(__pyx_k__readReference), 0, 0, 1, 1},
  {&__pyx_n_s__readString, __pyx_k__readString, sizeof(__pyx_k__readString), 0, 0, 1, 1},
  {&__pyx_n_s__readTypedObject, __pyx_k__readTypedObject, sizeof(__pyx_k__readTypedObject), 0, 0, 1, 1},
  {&__pyx_n_s__readUndefined, __pyx_k__readUndefined, sizeof(__pyx_k__readUndefined), 0, 0, 1, 1},
  {&__pyx_n_s__readXML, __pyx_k__readXML, sizeof(__pyx_k__readXML), 0, 0, 1, 1},
  {&__pyx_n_s__read_double, __pyx_k__read_double, sizeof(__pyx_k__read_double), 0, 0, 1, 1},
  {&__pyx_n_s__read_short, __pyx_k__read_short, sizeof(__pyx_k__read_short), 0, 0, 1, 1},
  {&__pyx_n_s__read_uchar, __pyx_k__read_uchar, sizeof(__pyx_k__read_uchar), 0, 0, 1, 1},
  {&__pyx_n_s__read_ulong, __pyx_k__read_ulong, sizeof(__pyx_k__read_ulong), 0, 0, 1, 1},
  {&__pyx_n_s__read_ushort, __pyx_k__read_ushort, sizeof(__pyx_k__read_ushort), 0, 0, 1, 1},
  {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1},
  {&__pyx_n_s__serialiseString, __pyx_k__serialiseString, sizeof(__pyx_k__serialiseString), 0, 0, 1, 1},
  {&__pyx_n_s__static_attrs, __pyx_k__static_attrs, sizeof(__pyx_k__static_attrs), 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__timezone_offset, __pyx_k__timezone_offset, sizeof(__pyx_k__timezone_offset), 0, 0, 1, 1},
  {&__pyx_n_s__tostring, __pyx_k__tostring, sizeof(__pyx_k__tostring), 0, 0, 1, 1},
  {&__pyx_n_s__use_amf3, __pyx_k__use_amf3, sizeof(__pyx_k__use_amf3), 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__writeAMF3, __pyx_k__writeAMF3, sizeof(__pyx_k__writeAMF3), 0, 0, 1, 1},
  {&__pyx_n_s__writeBytes, __pyx_k__writeBytes, sizeof(__pyx_k__writeBytes), 0, 0, 1, 1},
  {&__pyx_n_s__writeElement, __pyx_k__writeElement, sizeof(__pyx_k__writeElement), 0, 0, 1, 1},
  {&__pyx_n_s__writeList, __pyx_k__writeList, sizeof(__pyx_k__writeList), 0, 0, 1, 1},
  {&__pyx_n_s__writeObject, __pyx_k__writeObject, sizeof(__pyx_k__writeObject), 0, 0, 1, 1},
  {&__pyx_n_s__writeReference, __pyx_k__writeReference, sizeof(__pyx_k__writeReference), 0, 0, 1, 1},
  {&__pyx_n_s__writeType, __pyx_k__writeType, sizeof(__pyx_k__writeType), 0, 0, 1, 1},
  {&__pyx_n_s__write_double, __pyx_k__write_double, sizeof(__pyx_k__write_double), 0, 0, 1, 1},
  {&__pyx_n_s__write_ulong, __pyx_k__write_ulong, sizeof(__pyx_k__write_ulong), 0, 0, 1, 1},
  {&__pyx_n_s__write_ushort, __pyx_k__write_ushort, sizeof(__pyx_k__write_ushort), 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_OverflowError = __Pyx_GetName(__pyx_b, __pyx_n_s__OverflowError); if (!__pyx_builtin_OverflowError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __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 = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_max = __Pyx_GetName(__pyx_b, __pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

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

  /* "cpyamf/amf0.pyx":71
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)             # <<<<<<<<<<<<<<
 *         self.context = kwargs.pop('context', None)
 * 
 */
  __pyx_k_tuple_1 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__use_amf3));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, ((PyObject *)__pyx_n_s__use_amf3));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__use_amf3));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));

  /* "cpyamf/amf0.pyx":72
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 *         self.context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if self.context is None:
 */
  __pyx_k_tuple_2 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__context));
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_n_s__context));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__context));
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

  /* "cpyamf/amf0.pyx":100
 *             return False
 * 
 *         raise pyamf.DecodeError('Bad boolean read from stream')             # <<<<<<<<<<<<<<
 * 
 *     cdef object readBytes(self):
 */
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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/amf0.pyx":296
 *             return self.readAMF3()
 * 
 *         raise pyamf.DecodeError("Unsupported ActionScript type")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));

  /* "cpyamf/amf0.pyx":312
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)             # <<<<<<<<<<<<<<
 * 
 *         self.context = kwargs.pop('context', None)
 */
  __pyx_k_tuple_11 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_11));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__use_amf3));
  PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_n_s__use_amf3));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__use_amf3));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_11, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));

  /* "cpyamf/amf0.pyx":314
 *         self.use_amf3 = kwargs.pop('use_amf3', 0)
 * 
 *         self.context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if self.context is None:
 */
  __pyx_k_tuple_12 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_12));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__context));
  PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_n_s__context));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__context));
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_12, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12));

  /* "cpyamf/amf0.pyx":462
 * 
 *         if isinstance(data, unicode):
 *             data = data.encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         if not PyString_CheckExact(data):
 */
  __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_14));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));

  /* "cpyamf/amf0.pyx":465
 * 
 *         if not PyString_CheckExact(data):
 *             raise TypeError('expected str from xml.tostring')             # <<<<<<<<<<<<<<
 * 
 *         cdef Py_ssize_t l = PyString_GET_SIZE(data)
 */
  __pyx_k_tuple_16 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_16));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_15));
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, ((PyObject *)__pyx_kp_s_15));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_15));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16));
  __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 initamf0(void); /*proto*/
PyMODINIT_FUNC initamf0(void)
#else
PyMODINIT_FUNC PyInit_amf0(void); /*proto*/
PyMODINIT_FUNC PyInit_amf0(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_amf0(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("amf0"), __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__amf0) {
    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_4amf0_ASObject = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf0_UnknownClassAlias = Py_None; Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_ptype_6cpyamf_5codec_Context = __Pyx_ImportType("cpyamf.codec", "Context", sizeof(struct __pyx_obj_6cpyamf_5codec_Context), 1); if (unlikely(!__pyx_ptype_6cpyamf_5codec_Context)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_5codec_Context = (struct __pyx_vtabstruct_6cpyamf_5codec_Context*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_5codec_Context->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_5codec_Context)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf0_Context = &__pyx_vtable_6cpyamf_4amf0_Context;
  __pyx_vtable_6cpyamf_4amf0_Context.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Context;
  __pyx_vtable_6cpyamf_4amf0_Context.__pyx_base.clear = (int (*)(struct __pyx_obj_6cpyamf_5codec_Context *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf0_7Context_clear;
  __pyx_type_6cpyamf_4amf0_Context.tp_base = __pyx_ptype_6cpyamf_5codec_Context;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf0_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf0_Context.tp_dict, __pyx_vtabptr_6cpyamf_4amf0_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_6cpyamf_4amf0_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf0_Context = &__pyx_type_6cpyamf_4amf0_Context;
  __pyx_ptype_6cpyamf_5codec_Decoder = __Pyx_ImportType("cpyamf.codec", "Decoder", sizeof(struct __pyx_obj_6cpyamf_5codec_Decoder), 1); if (unlikely(!__pyx_ptype_6cpyamf_5codec_Decoder)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_5codec_Decoder = (struct __pyx_vtabstruct_6cpyamf_5codec_Decoder*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_5codec_Decoder->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_5codec_Decoder)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf0_Decoder = &__pyx_vtable_6cpyamf_4amf0_Decoder;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Decoder;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readDate = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readDate;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readString = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf0_7Decoder_readString;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readObject;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readNumber = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readNumber;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readList = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readList;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readXML = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readXML;
  __pyx_vtable_6cpyamf_4amf0_Decoder.__pyx_base.readConcreteElement = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, char))__pyx_f_6cpyamf_4amf0_7Decoder_readConcreteElement;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readBoolean = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readBoolean;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readBytes = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readBytes;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readObjectAttributes = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Decoder_readObjectAttributes;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readTypedObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readTypedObject;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readReference = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readReference;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readMixedArray = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readMixedArray;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readLongString = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *, struct __pyx_opt_args_6cpyamf_4amf0_7Decoder_readLongString *__pyx_optional_args))__pyx_f_6cpyamf_4amf0_7Decoder_readLongString;
  __pyx_vtable_6cpyamf_4amf0_Decoder.readAMF3 = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf0_Decoder *))__pyx_f_6cpyamf_4amf0_7Decoder_readAMF3;
  __pyx_type_6cpyamf_4amf0_Decoder.tp_base = __pyx_ptype_6cpyamf_5codec_Decoder;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf0_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf0_Decoder.tp_dict, __pyx_vtabptr_6cpyamf_4amf0_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_6cpyamf_4amf0_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf0_Decoder = &__pyx_type_6cpyamf_4amf0_Decoder;
  __pyx_ptype_6cpyamf_5codec_Encoder = __Pyx_ImportType("cpyamf.codec", "Encoder", sizeof(struct __pyx_obj_6cpyamf_5codec_Encoder), 1); if (unlikely(!__pyx_ptype_6cpyamf_5codec_Encoder)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_5codec_Encoder = (struct __pyx_vtabstruct_6cpyamf_5codec_Encoder*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_5codec_Encoder->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_5codec_Encoder)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf0_Encoder = &__pyx_vtable_6cpyamf_4amf0_Encoder;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Encoder;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.serialiseString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf0_7Encoder_serialiseString;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeNull = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeNull;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeUndefined = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeUndefined;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeString;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeBytes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeBytes;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeBoolean = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeBoolean;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeInt = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeInt;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeLong = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeLong;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeNumber = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeNumber;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeDateTime = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeDateTime;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeXML = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeXML;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.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_4amf0_7Encoder_writeList;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeTuple = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeTuple;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.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_4amf0_7Encoder_writeObject;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeDict = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeDict;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.writeMixedArray = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeMixedArray;
  __pyx_vtable_6cpyamf_4amf0_Encoder.__pyx_base.handleBasicTypes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_handleBasicTypes;
  __pyx_vtable_6cpyamf_4amf0_Encoder.writeReference = (int (*)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeReference;
  __pyx_vtable_6cpyamf_4amf0_Encoder._writeDict = (int (*)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder__writeDict;
  __pyx_vtable_6cpyamf_4amf0_Encoder._writeEndObject = (int (*)(struct __pyx_obj_6cpyamf_4amf0_Encoder *))__pyx_f_6cpyamf_4amf0_7Encoder__writeEndObject;
  __pyx_vtable_6cpyamf_4amf0_Encoder.writeAMF3 = (int (*)(struct __pyx_obj_6cpyamf_4amf0_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf0_7Encoder_writeAMF3;
  __pyx_type_6cpyamf_4amf0_Encoder.tp_base = __pyx_ptype_6cpyamf_5codec_Encoder;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf0_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf0_Encoder.tp_dict, __pyx_vtabptr_6cpyamf_4amf0_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Encoder", (PyObject *)&__pyx_type_6cpyamf_4amf0_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf0_Encoder = &__pyx_type_6cpyamf_4amf0_Encoder;
  /*--- Type import code ---*/
  __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[1]; __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[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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[3]; __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[3]; __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[3]; __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[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_IndexedCollection = __Pyx_ImportType("cpyamf.codec", "IndexedCollection", sizeof(struct __pyx_obj_6cpyamf_5codec_IndexedCollection), 1); if (unlikely(!__pyx_ptype_6cpyamf_5codec_IndexedCollection)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_5codec_IndexedCollection = (struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_5codec_IndexedCollection->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_5codec_IndexedCollection)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_5codec_Codec = __Pyx_ImportType("cpyamf.codec", "Codec", sizeof(struct __pyx_obj_6cpyamf_5codec_Codec), 1); if (unlikely(!__pyx_ptype_6cpyamf_5codec_Codec)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_ClassDefinition = __Pyx_ImportType("cpyamf.amf3", "ClassDefinition", sizeof(struct __pyx_obj_6cpyamf_4amf3_ClassDefinition), 1); if (unlikely(!__pyx_ptype_6cpyamf_4amf3_ClassDefinition)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf3_ClassDefinition = (struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4amf3_ClassDefinition->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4amf3_ClassDefinition)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Context = __Pyx_ImportType("cpyamf.amf3", "Context", sizeof(struct __pyx_obj_6cpyamf_4amf3_Context), 1); if (unlikely(!__pyx_ptype_6cpyamf_4amf3_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf3_Context = (struct __pyx_vtabstruct_6cpyamf_4amf3_Context*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4amf3_Context->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4amf3_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Decoder = __Pyx_ImportType("cpyamf.amf3", "Decoder", sizeof(struct __pyx_obj_6cpyamf_4amf3_Decoder), 1); if (unlikely(!__pyx_ptype_6cpyamf_4amf3_Decoder)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf3_Decoder = (struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4amf3_Decoder->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4amf3_Decoder)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Encoder = __Pyx_ImportType("cpyamf.amf3", "Encoder", sizeof(struct __pyx_obj_6cpyamf_4amf3_Encoder), 1); if (unlikely(!__pyx_ptype_6cpyamf_4amf3_Encoder)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4amf3_Encoder = (struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4amf3_Encoder->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4amf3_Encoder)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "cpyamf/amf0.pyx":19
 * from cpyamf cimport codec, amf3
 * 
 * import pyamf             # <<<<<<<<<<<<<<
 * from pyamf import xml, util
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __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 = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":20
 * 
 * import pyamf
 * from pyamf import xml, util             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xml));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__xml));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xml));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__util));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__util));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__util));
  __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 = 20; __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__xml); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __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 = 20; __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__util); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __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 = 20; __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/amf0.pyx":23
 * 
 * 
 * cdef char TYPE_NUMBER      = '\x00'             # <<<<<<<<<<<<<<
 * cdef char TYPE_BOOL        = '\x01'
 * cdef char TYPE_STRING      = '\x02'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_NUMBER = '\x00';

  /* "cpyamf/amf0.pyx":24
 * 
 * cdef char TYPE_NUMBER      = '\x00'
 * cdef char TYPE_BOOL        = '\x01'             # <<<<<<<<<<<<<<
 * cdef char TYPE_STRING      = '\x02'
 * cdef char TYPE_OBJECT      = '\x03'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_BOOL = '\x01';

  /* "cpyamf/amf0.pyx":25
 * cdef char TYPE_NUMBER      = '\x00'
 * cdef char TYPE_BOOL        = '\x01'
 * cdef char TYPE_STRING      = '\x02'             # <<<<<<<<<<<<<<
 * cdef char TYPE_OBJECT      = '\x03'
 * cdef char TYPE_MOVIECLIP   = '\x04'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_STRING = '\x02';

  /* "cpyamf/amf0.pyx":26
 * cdef char TYPE_BOOL        = '\x01'
 * cdef char TYPE_STRING      = '\x02'
 * cdef char TYPE_OBJECT      = '\x03'             # <<<<<<<<<<<<<<
 * cdef char TYPE_MOVIECLIP   = '\x04'
 * cdef char TYPE_NULL        = '\x05'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_OBJECT = '\x03';

  /* "cpyamf/amf0.pyx":27
 * cdef char TYPE_STRING      = '\x02'
 * cdef char TYPE_OBJECT      = '\x03'
 * cdef char TYPE_MOVIECLIP   = '\x04'             # <<<<<<<<<<<<<<
 * cdef char TYPE_NULL        = '\x05'
 * cdef char TYPE_UNDEFINED   = '\x06'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_MOVIECLIP = '\x04';

  /* "cpyamf/amf0.pyx":28
 * cdef char TYPE_OBJECT      = '\x03'
 * cdef char TYPE_MOVIECLIP   = '\x04'
 * cdef char TYPE_NULL        = '\x05'             # <<<<<<<<<<<<<<
 * cdef char TYPE_UNDEFINED   = '\x06'
 * cdef char TYPE_REFERENCE   = '\x07'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_NULL = '\x05';

  /* "cpyamf/amf0.pyx":29
 * cdef char TYPE_MOVIECLIP   = '\x04'
 * cdef char TYPE_NULL        = '\x05'
 * cdef char TYPE_UNDEFINED   = '\x06'             # <<<<<<<<<<<<<<
 * cdef char TYPE_REFERENCE   = '\x07'
 * cdef char TYPE_MIXEDARRAY  = '\x08'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_UNDEFINED = '\x06';

  /* "cpyamf/amf0.pyx":30
 * cdef char TYPE_NULL        = '\x05'
 * cdef char TYPE_UNDEFINED   = '\x06'
 * cdef char TYPE_REFERENCE   = '\x07'             # <<<<<<<<<<<<<<
 * cdef char TYPE_MIXEDARRAY  = '\x08'
 * cdef char TYPE_OBJECTTERM  = '\x09'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_REFERENCE = '\x07';

  /* "cpyamf/amf0.pyx":31
 * cdef char TYPE_UNDEFINED   = '\x06'
 * cdef char TYPE_REFERENCE   = '\x07'
 * cdef char TYPE_MIXEDARRAY  = '\x08'             # <<<<<<<<<<<<<<
 * cdef char TYPE_OBJECTTERM  = '\x09'
 * cdef char TYPE_ARRAY       = '\x0A'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_MIXEDARRAY = '\x08';

  /* "cpyamf/amf0.pyx":32
 * cdef char TYPE_REFERENCE   = '\x07'
 * cdef char TYPE_MIXEDARRAY  = '\x08'
 * cdef char TYPE_OBJECTTERM  = '\x09'             # <<<<<<<<<<<<<<
 * cdef char TYPE_ARRAY       = '\x0A'
 * cdef char TYPE_DATE        = '\x0B'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_OBJECTTERM = '\t';

  /* "cpyamf/amf0.pyx":33
 * cdef char TYPE_MIXEDARRAY  = '\x08'
 * cdef char TYPE_OBJECTTERM  = '\x09'
 * cdef char TYPE_ARRAY       = '\x0A'             # <<<<<<<<<<<<<<
 * cdef char TYPE_DATE        = '\x0B'
 * cdef char TYPE_LONGSTRING  = '\x0C'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_ARRAY = '\n';

  /* "cpyamf/amf0.pyx":34
 * cdef char TYPE_OBJECTTERM  = '\x09'
 * cdef char TYPE_ARRAY       = '\x0A'
 * cdef char TYPE_DATE        = '\x0B'             # <<<<<<<<<<<<<<
 * cdef char TYPE_LONGSTRING  = '\x0C'
 * cdef char TYPE_UNSUPPORTED = '\x0D'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_DATE = '\x0B';

  /* "cpyamf/amf0.pyx":35
 * cdef char TYPE_ARRAY       = '\x0A'
 * cdef char TYPE_DATE        = '\x0B'
 * cdef char TYPE_LONGSTRING  = '\x0C'             # <<<<<<<<<<<<<<
 * cdef char TYPE_UNSUPPORTED = '\x0D'
 * cdef char TYPE_RECORDSET   = '\x0E'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_LONGSTRING = '\x0C';

  /* "cpyamf/amf0.pyx":36
 * cdef char TYPE_DATE        = '\x0B'
 * cdef char TYPE_LONGSTRING  = '\x0C'
 * cdef char TYPE_UNSUPPORTED = '\x0D'             # <<<<<<<<<<<<<<
 * cdef char TYPE_RECORDSET   = '\x0E'
 * cdef char TYPE_XML         = '\x0F'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_UNSUPPORTED = '\r';

  /* "cpyamf/amf0.pyx":37
 * cdef char TYPE_LONGSTRING  = '\x0C'
 * cdef char TYPE_UNSUPPORTED = '\x0D'
 * cdef char TYPE_RECORDSET   = '\x0E'             # <<<<<<<<<<<<<<
 * cdef char TYPE_XML         = '\x0F'
 * cdef char TYPE_TYPEDOBJECT = '\x10'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_RECORDSET = '\x0E';

  /* "cpyamf/amf0.pyx":38
 * cdef char TYPE_UNSUPPORTED = '\x0D'
 * cdef char TYPE_RECORDSET   = '\x0E'
 * cdef char TYPE_XML         = '\x0F'             # <<<<<<<<<<<<<<
 * cdef char TYPE_TYPEDOBJECT = '\x10'
 * cdef char TYPE_AMF3        = '\x11'
 */
  __pyx_v_6cpyamf_4amf0_TYPE_XML = '\x0F';

  /* "cpyamf/amf0.pyx":39
 * cdef char TYPE_RECORDSET   = '\x0E'
 * cdef char TYPE_XML         = '\x0F'
 * cdef char TYPE_TYPEDOBJECT = '\x10'             # <<<<<<<<<<<<<<
 * cdef char TYPE_AMF3        = '\x11'
 * 
 */
  __pyx_v_6cpyamf_4amf0_TYPE_TYPEDOBJECT = '\x10';

  /* "cpyamf/amf0.pyx":40
 * cdef char TYPE_XML         = '\x0F'
 * cdef char TYPE_TYPEDOBJECT = '\x10'
 * cdef char TYPE_AMF3        = '\x11'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_6cpyamf_4amf0_TYPE_AMF3 = '\x11';

  /* "cpyamf/amf0.pyx":43
 * 
 * 
 * cdef object ASObject = pyamf.ASObject             # <<<<<<<<<<<<<<
 * cdef object UnknownClassAlias = pyamf.UnknownClassAlias
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ASObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __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_4amf0_ASObject);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf0_ASObject);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_4amf0_ASObject = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf0.pyx":44
 * 
 * cdef object ASObject = pyamf.ASObject
 * cdef object UnknownClassAlias = pyamf.UnknownClassAlias             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__UnknownClassAlias); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __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_4amf0_UnknownClassAlias);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf0_UnknownClassAlias);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6cpyamf_4amf0_UnknownClassAlias = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf0.pyx":1
 * # 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.amf0");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cpyamf.amf0");
  }
  __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_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_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 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 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 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 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 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 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;
    }
}

#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;
}

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;
}

#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 */
