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

/* Type declarations */

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

struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_seek {
  int __pyx_n;
  int mode;
};

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

struct __pyx_opt_args_6cpyamf_4util_19cBufferedByteStream_truncate {
  int __pyx_n;
  Py_ssize_t size;
};

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

/* "cpyamf/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/amf3.pyx":700
 *         return 0
 * 
 *     cpdef int writeList(self, object n, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)
 *         cdef Py_ssize_t i
 */

struct __pyx_opt_args_6cpyamf_4amf3_7Encoder_writeList {
  int __pyx_n;
  int is_proxy;
};

/* "cpyamf/amf3.pyx":852
 *             self.writeElement(n[k])
 * 
 *     cpdef int writeObject(self, object obj, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref
 *         cdef object kls
 */

struct __pyx_opt_args_6cpyamf_4amf3_7Encoder_writeObject {
  int __pyx_n;
  int is_proxy;
};

/* "cpyamf/amf3.pyx":1095
 * 
 * 
 * cdef int decode_int(cBufferedByteStream stream, int sign=0) except? -1:             # <<<<<<<<<<<<<<
 *     cdef int n = 0
 *     cdef int result = 0
 */

struct __pyx_opt_args_6cpyamf_4amf3_decode_int {
  int __pyx_n;
  int sign;
};

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

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

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

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

struct __pyx_obj_6cpyamf_4util_BufferedByteStream {
  struct __pyx_obj_6cpyamf_4util_cBufferedByteStream __pyx_base;
};

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

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

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

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


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

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/amf3.pyx":138
 * 
 * 
 * cdef class Context(codec.Context):             # <<<<<<<<<<<<<<
 *     """
 *     I hold the AMF3 context for en/decoding streams.
 */

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;


/* "cpyamf/amf3.pyx":595
 * 
 * 
 * cdef class Encoder(codec.Encoder):             # <<<<<<<<<<<<<<
 *     """
 *     The AMF3 Encoder.
 */

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;


/* "cpyamf/amf3.pyx":250
 * 
 * 
 * cdef class Decoder(codec.Decoder):             # <<<<<<<<<<<<<<
 *     """
 *     Decodes an AMF3 data stream.
 */

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;


/* "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 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 void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

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

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

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

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

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}

static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        Py_INCREF(v);
        Py_DECREF(PyList_GET_ITEM(o, i));
        PyList_SET_ITEM(o, i, v);
        return 1;
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
        return PySequence_SetItem(o, i, v);
    else {
        PyObject *j = PyInt_FromSsize_t(i);
        return __Pyx_SetItemInt_Generic(o, j, v);
    }
}


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 void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */

#define __Pyx_PyObject_AsDouble(obj) \
    ((likely(PyFloat_CheckExact(obj))) ? \
     PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))

static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

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 void __Pyx_WriteUnraisable(const char *name); /*proto*/

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

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

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

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

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

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

/* Module declarations from cpyamf.util */

static PyTypeObject *__pyx_ptype_6cpyamf_4util_cBufferedByteStream = 0;
static PyTypeObject *__pyx_ptype_6cpyamf_4util_BufferedByteStream = 0;
/* Module declarations from 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 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 cython */

/* 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;
static char __pyx_v_6cpyamf_4amf3_TYPE_UNDEFINED;
static char __pyx_v_6cpyamf_4amf3_TYPE_NULL;
static char __pyx_v_6cpyamf_4amf3_TYPE_BOOL_FALSE;
static char __pyx_v_6cpyamf_4amf3_TYPE_BOOL_TRUE;
static char __pyx_v_6cpyamf_4amf3_TYPE_INTEGER;
static char __pyx_v_6cpyamf_4amf3_TYPE_NUMBER;
static char __pyx_v_6cpyamf_4amf3_TYPE_STRING;
static char __pyx_v_6cpyamf_4amf3_TYPE_XML;
static char __pyx_v_6cpyamf_4amf3_TYPE_DATE;
static char __pyx_v_6cpyamf_4amf3_TYPE_ARRAY;
static char __pyx_v_6cpyamf_4amf3_TYPE_OBJECT;
static char __pyx_v_6cpyamf_4amf3_TYPE_XMLSTRING;
static char __pyx_v_6cpyamf_4amf3_TYPE_BYTEARRAY;
static unsigned int __pyx_v_6cpyamf_4amf3_REFERENCE_BIT;
static char __pyx_v_6cpyamf_4amf3_REF_CHAR;
static long __pyx_v_6cpyamf_4amf3_MAX_29B_INT;
static long __pyx_v_6cpyamf_4amf3_MIN_29B_INT;
static int __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC;
static int __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_EXTERNAL;
static int __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_DYNAMIC;
static int __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_PROXY;
static PyObject *__pyx_v_6cpyamf_4amf3_ByteArrayType = 0;
static PyObject *__pyx_v_6cpyamf_4amf3_DataInput = 0;
static PyObject *__pyx_v_6cpyamf_4amf3_DataOutput = 0;
static PyObject *__pyx_v_6cpyamf_4amf3_empty_string = 0;
static PyObject *__pyx_v_6cpyamf_4amf3_empty_unicode = 0;
static PyObject *__pyx_v_6cpyamf_4amf3_undefined = 0;
static int __pyx_f_6cpyamf_4amf3_encode_int(long, char **); /*proto*/
static int __pyx_f_6cpyamf_4amf3_decode_int(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, struct __pyx_opt_args_6cpyamf_4amf3_decode_int *__pyx_optional_args); /*proto*/
static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3__encode_integer(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *, int); /*proto*/
static CYTHON_INLINE Py_ssize_t __pyx_f_6cpyamf_4amf3__read_ref(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *); /*proto*/
#define __Pyx_MODULE_NAME "cpyamf.amf3"
static int __pyx_module_is_main_cpyamf__amf3 = 0;

/* Implementation of cpyamf.amf3 */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_KeyError;
static char __pyx_k_1[] = "encodable_properties";
static char __pyx_k_3[] = "TypedObjectClassAlias";
static char __pyx_k_4[] = "Unknown reference";
static char __pyx_k_6[] = "Unknown object encoding";
static char __pyx_k_8[] = "Unsupported ActionScript type";
static char __pyx_k_11[] = "Expected str or unicode";
static char __pyx_k_13[] = "";
static char __pyx_k_14[] = "dicts cannot contain empty string keys";
static char __pyx_k_16[] = "Non int/str key value found in dict";
static char __pyx_k_18[] = "getEncodableAttributes";
static char __pyx_k_19[] = "Expected dict for encodable attributes";
static char __pyx_k_21[] = "utf-8";
static char __pyx_k_23[] = "Expected string from xml serialization";
static char __pyx_k_25[] = "\nC-extension for L{pyamf.amf3} Python module in L{PyAMF<pyamf>}.\n\n@since: 0.6\n";
static char __pyx_k__n[] = "n";
static char __pyx_k__obj[] = "obj";
static char __pyx_k__pop[] = "pop";
static char __pyx_k__ref[] = "ref";
static char __pyx_k__xml[] = "xml";
static char __pyx_k__amf3[] = "amf3";
static char __pyx_k__flex[] = "flex";
static char __pyx_k__keys[] = "keys";
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__zlib[] = "zlib";
static char __pyx_k__alias[] = "alias";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__codec[] = "codec";
static char __pyx_k__error[] = "error";
static char __pyx_k__index[] = "index";
static char __pyx_k__klass[] = "klass";
static char __pyx_k__pyamf[] = "pyamf";
static char __pyx_k__types[] = "types";
static char __pyx_k__write[] = "write";
static char __pyx_k__append[] = "append";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__stream[] = "stream";
static char __pyx_k__strict[] = "strict";
static char __pyx_k__classes[] = "classes";
static char __pyx_k__compile[] = "compile";
static char __pyx_k__context[] = "context";
static char __pyx_k__dynamic[] = "dynamic";
static char __pyx_k__proxied[] = "proxied";
static char __pyx_k__readXML[] = "readXML";
static char __pyx_k__strings[] = "strings";
static char __pyx_k__ASObject[] = "ASObject";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__addClass[] = "addClass";
static char __pyx_k__attr_len[] = "attr_len";
static char __pyx_k__encoding[] = "encoding";
static char __pyx_k__external[] = "external";
static char __pyx_k__getClass[] = "getClass";
static char __pyx_k__is_proxy[] = "is_proxy";
static char __pyx_k__readDate[] = "readDate";
static char __pyx_k__readList[] = "readList";
static char __pyx_k__tostring[] = "tostring";
static char __pyx_k__use_hash[] = "use_hash";
static char __pyx_k__ByteArray[] = "ByteArray";
static char __pyx_k__DataInput[] = "DataInput";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__Undefined[] = "Undefined";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k__addObject[] = "addObject";
static char __pyx_k__addString[] = "addString";
static char __pyx_k__anonymous[] = "anonymous";
static char __pyx_k__class_idx[] = "class_idx";
static char __pyx_k__class_ref[] = "class_ref";
static char __pyx_k__getObject[] = "getObject";
static char __pyx_k__getString[] = "getString";
static char __pyx_k__readBytes[] = "readBytes";
static char __pyx_k__readProxy[] = "readProxy";
static char __pyx_k__writeList[] = "writeList";
static char __pyx_k__writeType[] = "writeType";
static char __pyx_k__DataOutput[] = "DataOutput";
static char __pyx_k__MixedArray[] = "MixedArray";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__compressed[] = "compressed";
static char __pyx_k__decompress[] = "decompress";
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_uchar[] = "read_uchar";
static char __pyx_k__writeProxy[] = "writeProxy";
static char __pyx_k__DecodeError[] = "DecodeError";
static char __pyx_k__EncodeError[] = "EncodeError";
static char __pyx_k__ImportError[] = "ImportError";
static char __pyx_k____readamf__[] = "__readamf__";
static char __pyx_k___readStatic[] = "_readStatic";
static char __pyx_k__encoded_ref[] = "encoded_ref";
static char __pyx_k__readElement[] = "readElement";
static char __pyx_k__readInteger[] = "readInteger";
static char __pyx_k__read_double[] = "read_double";
static char __pyx_k__use_proxies[] = "use_proxies";
static char __pyx_k__writeNumber[] = "writeNumber";
static char __pyx_k__writeObject[] = "writeObject";
static char __pyx_k__write_uchar[] = "write_uchar";
static char __pyx_k____writeamf__[] = "__writeamf__";
static char __pyx_k___readDynamic[] = "_readDynamic";
static char __pyx_k__get_datetime[] = "get_datetime";
static char __pyx_k__proxy_object[] = "proxy_object";
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__getClassAlias[] = "getClassAlias";
static char __pyx_k__get_timestamp[] = "get_timestamp";
static char __pyx_k__readByteArray[] = "readByteArray";
static char __pyx_k__ReferenceError[] = "ReferenceError";
static char __pyx_k__addProxyObject[] = "addProxyObject";
static char __pyx_k__createInstance[] = "createInstance";
static char __pyx_k__getByReference[] = "getByReference";
static char __pyx_k__getReferenceTo[] = "getReferenceTo";
static char __pyx_k__unproxy_object[] = "unproxy_object";
static char __pyx_k__writeByteArray[] = "writeByteArray";
static char __pyx_k__writeReference[] = "writeReference";
static char __pyx_k__applyAttributes[] = "applyAttributes";
static char __pyx_k__proxied_objects[] = "proxied_objects";
static char __pyx_k__serialiseString[] = "serialiseString";
static char __pyx_k__timezone_offset[] = "timezone_offset";
static char __pyx_k__encoded_ref_size[] = "encoded_ref_size";
static char __pyx_k__UnknownClassAlias[] = "UnknownClassAlias";
static char __pyx_k__getBytesForString[] = "getBytesForString";
static char __pyx_k__getObjectForProxy[] = "getObjectForProxy";
static char __pyx_k__getProxyForObject[] = "getProxyForObject";
static char __pyx_k__static_properties[] = "static_properties";
static char __pyx_k__getObjectReference[] = "getObjectReference";
static char __pyx_k__getStringReference[] = "getStringReference";
static char __pyx_k___getClassDefinition[] = "_getClassDefinition";
static char __pyx_k__getClassByReference[] = "getClassByReference";
static char __pyx_k__use_proxies_default[] = "use_proxies_default";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_n_s_18;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_n_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__ASObject;
static PyObject *__pyx_n_s__ByteArray;
static PyObject *__pyx_n_s__DataInput;
static PyObject *__pyx_n_s__DataOutput;
static PyObject *__pyx_n_s__DecodeError;
static PyObject *__pyx_n_s__EncodeError;
static PyObject *__pyx_n_s__ImportError;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__MixedArray;
static PyObject *__pyx_n_s__ReferenceError;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__Undefined;
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____readamf__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s____writeamf__;
static PyObject *__pyx_n_s___getClassDefinition;
static PyObject *__pyx_n_s___readDynamic;
static PyObject *__pyx_n_s___readStatic;
static PyObject *__pyx_n_s__addClass;
static PyObject *__pyx_n_s__addObject;
static PyObject *__pyx_n_s__addProxyObject;
static PyObject *__pyx_n_s__addString;
static PyObject *__pyx_n_s__alias;
static PyObject *__pyx_n_s__amf3;
static PyObject *__pyx_n_s__anonymous;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__applyAttributes;
static PyObject *__pyx_n_s__attr_len;
static PyObject *__pyx_n_s__class_idx;
static PyObject *__pyx_n_s__class_ref;
static PyObject *__pyx_n_s__classes;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__codec;
static PyObject *__pyx_n_s__compile;
static PyObject *__pyx_n_s__compressed;
static PyObject *__pyx_n_s__context;
static PyObject *__pyx_n_s__createInstance;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__decompress;
static PyObject *__pyx_n_s__dynamic;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__encoded_ref;
static PyObject *__pyx_n_s__encoded_ref_size;
static PyObject *__pyx_n_s__encoding;
static PyObject *__pyx_n_s__error;
static PyObject *__pyx_n_s__external;
static PyObject *__pyx_n_s__flex;
static PyObject *__pyx_n_s__fromstring;
static PyObject *__pyx_n_s__getByReference;
static PyObject *__pyx_n_s__getBytesForString;
static PyObject *__pyx_n_s__getClass;
static PyObject *__pyx_n_s__getClassAlias;
static PyObject *__pyx_n_s__getClassByReference;
static PyObject *__pyx_n_s__getObject;
static PyObject *__pyx_n_s__getObjectForProxy;
static PyObject *__pyx_n_s__getObjectReference;
static PyObject *__pyx_n_s__getProxyForObject;
static PyObject *__pyx_n_s__getReferenceTo;
static PyObject *__pyx_n_s__getString;
static PyObject *__pyx_n_s__getStringReference;
static PyObject *__pyx_n_s__get_datetime;
static PyObject *__pyx_n_s__get_timestamp;
static PyObject *__pyx_n_s__index;
static PyObject *__pyx_n_s__is_proxy;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__klass;
static PyObject *__pyx_n_s__n;
static PyObject *__pyx_n_s__obj;
static PyObject *__pyx_n_s__peek;
static PyObject *__pyx_n_s__pop;
static PyObject *__pyx_n_s__proxied;
static PyObject *__pyx_n_s__proxied_objects;
static PyObject *__pyx_n_s__proxy_object;
static PyObject *__pyx_n_s__pyamf;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__readByteArray;
static PyObject *__pyx_n_s__readBytes;
static PyObject *__pyx_n_s__readDate;
static PyObject *__pyx_n_s__readElement;
static PyObject *__pyx_n_s__readInteger;
static PyObject *__pyx_n_s__readList;
static PyObject *__pyx_n_s__readNumber;
static PyObject *__pyx_n_s__readObject;
static PyObject *__pyx_n_s__readProxy;
static PyObject *__pyx_n_s__readString;
static PyObject *__pyx_n_s__readXML;
static PyObject *__pyx_n_s__read_double;
static PyObject *__pyx_n_s__read_uchar;
static PyObject *__pyx_n_s__ref;
static PyObject *__pyx_n_s__seek;
static PyObject *__pyx_n_s__serialiseString;
static PyObject *__pyx_n_s__static_attrs;
static PyObject *__pyx_n_s__static_properties;
static PyObject *__pyx_n_s__stream;
static PyObject *__pyx_n_s__strict;
static PyObject *__pyx_n_s__strings;
static PyObject *__pyx_n_s__timezone_offset;
static PyObject *__pyx_n_s__tostring;
static PyObject *__pyx_n_s__types;
static PyObject *__pyx_n_s__unproxy_object;
static PyObject *__pyx_n_s__use_hash;
static PyObject *__pyx_n_s__use_proxies;
static PyObject *__pyx_n_s__use_proxies_default;
static PyObject *__pyx_n_s__util;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__writeByteArray;
static PyObject *__pyx_n_s__writeElement;
static PyObject *__pyx_n_s__writeList;
static PyObject *__pyx_n_s__writeNumber;
static PyObject *__pyx_n_s__writeObject;
static PyObject *__pyx_n_s__writeProxy;
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_uchar;
static PyObject *__pyx_n_s__xml;
static PyObject *__pyx_n_s__zlib;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_7;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_12;
static PyObject *__pyx_k_tuple_15;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_20;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_26;
static PyObject *__pyx_k_tuple_27;

/* "cpyamf/amf3.pyx":69
 *     """
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.alias = None
 *         self.ref = -1
 */

static int __pyx_pf_6cpyamf_4amf3_15ClassDefinition___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf3_15ClassDefinition___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/amf3.pyx":70
 * 
 *     def __cinit__(self):
 *         self.alias = None             # <<<<<<<<<<<<<<
 *         self.ref = -1
 *         self.attr_len = -1
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias);
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias = Py_None;

  /* "cpyamf/amf3.pyx":71
 *     def __cinit__(self):
 *         self.alias = None
 *         self.ref = -1             # <<<<<<<<<<<<<<
 *         self.attr_len = -1
 *         self.encoding = -1
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->ref = -1;

  /* "cpyamf/amf3.pyx":72
 *         self.alias = None
 *         self.ref = -1
 *         self.attr_len = -1             # <<<<<<<<<<<<<<
 *         self.encoding = -1
 *         self.encoded_ref = NULL
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->attr_len = -1;

  /* "cpyamf/amf3.pyx":73
 *         self.ref = -1
 *         self.attr_len = -1
 *         self.encoding = -1             # <<<<<<<<<<<<<<
 *         self.encoded_ref = NULL
 *         self.encoded_ref_size = -1
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding = -1;

  /* "cpyamf/amf3.pyx":74
 *         self.attr_len = -1
 *         self.encoding = -1
 *         self.encoded_ref = NULL             # <<<<<<<<<<<<<<
 *         self.encoded_ref_size = -1
 * 
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoded_ref = NULL;

  /* "cpyamf/amf3.pyx":75
 *         self.encoding = -1
 *         self.encoded_ref = NULL
 *         self.encoded_ref_size = -1             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, alias):
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoded_ref_size = -1;

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

/* "cpyamf/amf3.pyx":77
 *         self.encoded_ref_size = -1
 * 
 *     def __init__(self, alias):             # <<<<<<<<<<<<<<
 *         self.alias = alias
 * 
 */

static int __pyx_pf_6cpyamf_4amf3_15ClassDefinition_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf3_15ClassDefinition_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_alias = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alias,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alias);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_alias = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_alias = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.ClassDefinition.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "cpyamf/amf3.pyx":78
 * 
 *     def __init__(self, alias):
 *         self.alias = alias             # <<<<<<<<<<<<<<
 * 
 *         alias.compile()
 */
  __Pyx_INCREF(__pyx_v_alias);
  __Pyx_GIVEREF(__pyx_v_alias);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias);
  __Pyx_DECREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias);
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias = __pyx_v_alias;

  /* "cpyamf/amf3.pyx":80
 *         self.alias = alias
 * 
 *         alias.compile()             # <<<<<<<<<<<<<<
 * 
 *         self.attr_len = 0
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__compile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __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 = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":82
 *         alias.compile()
 * 
 *         self.attr_len = 0             # <<<<<<<<<<<<<<
 *         self.static_properties = []
 * 
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->attr_len = 0;

  /* "cpyamf/amf3.pyx":83
 * 
 *         self.attr_len = 0
 *         self.static_properties = []             # <<<<<<<<<<<<<<
 * 
 *         if alias.static_attrs:
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties));
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":85
 *         self.static_properties = []
 * 
 *         if alias.static_attrs:             # <<<<<<<<<<<<<<
 *             self.attr_len = len(alias.static_attrs)
 *             self.static_properties = alias.static_attrs
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":86
 * 
 *         if alias.static_attrs:
 *             self.attr_len = len(alias.static_attrs)             # <<<<<<<<<<<<<<
 *             self.static_properties = alias.static_attrs
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->attr_len = __pyx_t_4;

    /* "cpyamf/amf3.pyx":87
 *         if alias.static_attrs:
 *             self.attr_len = len(alias.static_attrs)
 *             self.static_properties = alias.static_attrs             # <<<<<<<<<<<<<<
 * 
 *         self.encoding = OBJECT_ENCODING_DYNAMIC
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties));
    ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/amf3.pyx":89
 *             self.static_properties = alias.static_attrs
 * 
 *         self.encoding = OBJECT_ENCODING_DYNAMIC             # <<<<<<<<<<<<<<
 * 
 *         if alias.external:
 */
  ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding = __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_DYNAMIC;

  /* "cpyamf/amf3.pyx":91
 *         self.encoding = OBJECT_ENCODING_DYNAMIC
 * 
 *         if alias.external:             # <<<<<<<<<<<<<<
 *             self.encoding = OBJECT_ENCODING_EXTERNAL
 *         elif not alias.dynamic:
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__external); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":92
 * 
 *         if alias.external:
 *             self.encoding = OBJECT_ENCODING_EXTERNAL             # <<<<<<<<<<<<<<
 *         elif not alias.dynamic:
 *             if alias.encodable_properties is not None:
 */
    ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding = __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_EXTERNAL;
    goto __pyx_L7;
  }

  /* "cpyamf/amf3.pyx":93
 *         if alias.external:
 *             self.encoding = OBJECT_ENCODING_EXTERNAL
 *         elif not alias.dynamic:             # <<<<<<<<<<<<<<
 *             if alias.encodable_properties is not None:
 *                 if len(alias.static_attrs) == len(alias.encodable_properties):
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__dynamic); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (!__pyx_t_3);
  if (__pyx_t_5) {

    /* "cpyamf/amf3.pyx":94
 *             self.encoding = OBJECT_ENCODING_EXTERNAL
 *         elif not alias.dynamic:
 *             if alias.encodable_properties is not None:             # <<<<<<<<<<<<<<
 *                 if len(alias.static_attrs) == len(alias.encodable_properties):
 *                     self.encoding = OBJECT_ENCODING_STATIC
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = (__pyx_t_2 != Py_None);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_5) {

      /* "cpyamf/amf3.pyx":95
 *         elif not alias.dynamic:
 *             if alias.encodable_properties is not None:
 *                 if len(alias.static_attrs) == len(alias.encodable_properties):             # <<<<<<<<<<<<<<
 *                     self.encoding = OBJECT_ENCODING_STATIC
 *             else:
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__static_attrs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = (__pyx_t_4 == __pyx_t_6);
      if (__pyx_t_5) {

        /* "cpyamf/amf3.pyx":96
 *             if alias.encodable_properties is not None:
 *                 if len(alias.static_attrs) == len(alias.encodable_properties):
 *                     self.encoding = OBJECT_ENCODING_STATIC             # <<<<<<<<<<<<<<
 *             else:
 *                 self.encoding = OBJECT_ENCODING_STATIC
 */
        ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding = __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC;
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "cpyamf/amf3.pyx":98
 *                     self.encoding = OBJECT_ENCODING_STATIC
 *             else:
 *                 self.encoding = OBJECT_ENCODING_STATIC             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
      ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding = __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC;
    }
    __pyx_L8:;
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cpyamf.amf3.ClassDefinition.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":100
 *                 self.encoding = OBJECT_ENCODING_STATIC
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.encoded_ref != NULL:
 *             free(self.encoded_ref)
 */

static void __pyx_pf_6cpyamf_4amf3_15ClassDefinition_2__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_6cpyamf_4amf3_15ClassDefinition_2__dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "cpyamf/amf3.pyx":101
 * 
 *     def __dealloc__(self):
 *         if self.encoded_ref != NULL:             # <<<<<<<<<<<<<<
 *             free(self.encoded_ref)
 *             self.encoded_ref = NULL
 */
  __pyx_t_1 = (((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoded_ref != NULL);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":102
 *     def __dealloc__(self):
 *         if self.encoded_ref != NULL:
 *             free(self.encoded_ref)             # <<<<<<<<<<<<<<
 *             self.encoded_ref = NULL
 * 
 */
    free(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoded_ref);

    /* "cpyamf/amf3.pyx":103
 *         if self.encoded_ref != NULL:
 *             free(self.encoded_ref)
 *             self.encoded_ref = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeReference(self, cBufferedByteStream stream):
 */
    ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoded_ref = NULL;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __Pyx_RefNannyFinishContext();
}

/* "cpyamf/amf3.pyx":105
 *             self.encoded_ref = NULL
 * 
 *     cdef int writeReference(self, cBufferedByteStream stream):             # <<<<<<<<<<<<<<
 *         if self.encoded_ref != NULL:
 *             return stream.write(self.encoded_ref, self.encoded_ref_size)
 */

static  int __pyx_f_6cpyamf_4amf3_15ClassDefinition_writeReference(struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_self, struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *__pyx_v_stream) {
  Py_ssize_t __pyx_v_ref;
  char *__pyx_v_buf;
  int __pyx_v_ret;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("writeReference");

  /* "cpyamf/amf3.pyx":106
 * 
 *     cdef int writeReference(self, cBufferedByteStream stream):
 *         if self.encoded_ref != NULL:             # <<<<<<<<<<<<<<
 *             return stream.write(self.encoded_ref, self.encoded_ref_size)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->encoded_ref != NULL);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":107
 *     cdef int writeReference(self, cBufferedByteStream stream):
 *         if self.encoded_ref != NULL:
 *             return stream.write(self.encoded_ref, self.encoded_ref_size)             # <<<<<<<<<<<<<<
 * 
 *         cdef Py_ssize_t ref = 0
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream->__pyx_vtab)->write(__pyx_v_stream, __pyx_v_self->encoded_ref, __pyx_v_self->encoded_ref_size); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":109
 *             return stream.write(self.encoded_ref, self.encoded_ref_size)
 * 
 *         cdef Py_ssize_t ref = 0             # <<<<<<<<<<<<<<
 *         cdef char *buf
 *         cdef int ret = 0
 */
  __pyx_v_ref = 0;

  /* "cpyamf/amf3.pyx":111
 *         cdef Py_ssize_t ref = 0
 *         cdef char *buf
 *         cdef int ret = 0             # <<<<<<<<<<<<<<
 * 
 *         if self.encoding != OBJECT_ENCODING_EXTERNAL:
 */
  __pyx_v_ret = 0;

  /* "cpyamf/amf3.pyx":113
 *         cdef int ret = 0
 * 
 *         if self.encoding != OBJECT_ENCODING_EXTERNAL:             # <<<<<<<<<<<<<<
 *             ref += self.attr_len << 4
 * 
 */
  __pyx_t_1 = (__pyx_v_self->encoding != __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_EXTERNAL);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":114
 * 
 *         if self.encoding != OBJECT_ENCODING_EXTERNAL:
 *             ref += self.attr_len << 4             # <<<<<<<<<<<<<<
 * 
 *         ref |= self.encoding << 2 | REFERENCE_BIT << 1 | REFERENCE_BIT
 */
    __pyx_v_ref = (__pyx_v_ref + (__pyx_v_self->attr_len << 4));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":116
 *             ref += self.attr_len << 4
 * 
 *         ref |= self.encoding << 2 | REFERENCE_BIT << 1 | REFERENCE_BIT             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_v_ref = (__pyx_v_ref | (((__pyx_v_self->encoding << 2) | (__pyx_v_6cpyamf_4amf3_REFERENCE_BIT << 1)) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT));

  /* "cpyamf/amf3.pyx":118
 *         ref |= self.encoding << 2 | REFERENCE_BIT << 1 | REFERENCE_BIT
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             ret = encode_int(ref, &buf)
 * 
 */
  /*try:*/ {

    /* "cpyamf/amf3.pyx":119
 * 
 *         try:
 *             ret = encode_int(ref, &buf)             # <<<<<<<<<<<<<<
 * 
 *             stream.write(buf, ret)
 */
    __pyx_t_2 = __pyx_f_6cpyamf_4amf3_encode_int(__pyx_v_ref, (&__pyx_v_buf)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L6;}
    __pyx_v_ret = __pyx_t_2;

    /* "cpyamf/amf3.pyx":121
 *             ret = encode_int(ref, &buf)
 * 
 *             stream.write(buf, ret)             # <<<<<<<<<<<<<<
 *         finally:
 *             if buf != NULL:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream->__pyx_vtab)->write(__pyx_v_stream, __pyx_v_buf, __pyx_v_ret); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L6;}
  }

  /* "cpyamf/amf3.pyx":123
 *             stream.write(buf, ret)
 *         finally:
 *             if buf != NULL:             # <<<<<<<<<<<<<<
 *                 free(buf)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    __pyx_t_1 = (__pyx_v_buf != NULL);
    if (__pyx_t_1) {

      /* "cpyamf/amf3.pyx":124
 *         finally:
 *             if buf != NULL:
 *                 free(buf)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      free(__pyx_v_buf);
      goto __pyx_L9;
    }
    __pyx_L9:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "cpyamf/amf3.pyx":126
 *                 free(buf)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self.encoded_ref_size = encode_int(self.ref << 2 | REFERENCE_BIT, &self.encoded_ref)
 *         except:
 */
  {
    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/amf3.pyx":127
 * 
 *         try:
 *             self.encoded_ref_size = encode_int(self.ref << 2 | REFERENCE_BIT, &self.encoded_ref)             # <<<<<<<<<<<<<<
 *         except:
 *             if self.encoded_ref != NULL:
 */
      __pyx_t_2 = __pyx_f_6cpyamf_4amf3_encode_int(((__pyx_v_self->ref << 2) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT), (&__pyx_v_self->encoded_ref)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      __pyx_v_self->encoded_ref_size = __pyx_t_2;
    }
    __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_L17_try_end;
    __pyx_L10_error:;

    /* "cpyamf/amf3.pyx":128
 *         try:
 *             self.encoded_ref_size = encode_int(self.ref << 2 | REFERENCE_BIT, &self.encoded_ref)
 *         except:             # <<<<<<<<<<<<<<
 *             if self.encoded_ref != NULL:
 *                 free(self.encoded_ref)
 */
    /*except:*/ {
      __Pyx_AddTraceback("cpyamf.amf3.ClassDefinition.writeReference");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);

      /* "cpyamf/amf3.pyx":129
 *             self.encoded_ref_size = encode_int(self.ref << 2 | REFERENCE_BIT, &self.encoded_ref)
 *         except:
 *             if self.encoded_ref != NULL:             # <<<<<<<<<<<<<<
 *                 free(self.encoded_ref)
 *                 self.encoded_ref = NULL
 */
      __pyx_t_1 = (__pyx_v_self->encoded_ref != NULL);
      if (__pyx_t_1) {

        /* "cpyamf/amf3.pyx":130
 *         except:
 *             if self.encoded_ref != NULL:
 *                 free(self.encoded_ref)             # <<<<<<<<<<<<<<
 *                 self.encoded_ref = NULL
 * 
 */
        free(__pyx_v_self->encoded_ref);

        /* "cpyamf/amf3.pyx":131
 *             if self.encoded_ref != NULL:
 *                 free(self.encoded_ref)
 *                 self.encoded_ref = NULL             # <<<<<<<<<<<<<<
 * 
 *             raise
 */
        __pyx_v_self->encoded_ref = NULL;
        goto __pyx_L20;
      }
      __pyx_L20:;

      /* "cpyamf/amf3.pyx":133
 *                 self.encoded_ref = NULL
 * 
 *             raise             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_ErrRestore(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; 
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
      __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_L11_exception_handled;
    }
    __pyx_L12_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_L11_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_L17_try_end:;
  }

  /* "cpyamf/amf3.pyx":135
 *             raise
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("cpyamf.amf3.ClassDefinition.writeReference");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pxd":9
 *     """
 * 
 *     cdef readonly object alias             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t ref
 *     cdef readonly Py_ssize_t attr_len
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_5alias___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_5alias___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias);
  __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->alias;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pxd":11
 *     cdef readonly object alias
 *     cdef Py_ssize_t ref
 *     cdef readonly Py_ssize_t attr_len             # <<<<<<<<<<<<<<
 *     cdef readonly int encoding
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_8attr_len___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_8attr_len___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->attr_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __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.amf3.ClassDefinition.attr_len.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pxd":12
 *     cdef Py_ssize_t ref
 *     cdef readonly Py_ssize_t attr_len
 *     cdef readonly int encoding             # <<<<<<<<<<<<<<
 * 
 *     cdef char *encoded_ref
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_8encoding___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_8encoding___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __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.amf3.ClassDefinition.encoding.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pxd":17
 *     cdef Py_ssize_t encoded_ref_size
 * 
 *     cdef readonly list static_properties             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeReference(self, util.cBufferedByteStream stream)
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_17static_properties___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_15ClassDefinition_17static_properties___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_v_self)->static_properties);
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":143
 *     """
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.strings = codec.IndexedCollection(use_hash=1)
 *         self.classes = {}
 */

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

  /* "cpyamf/amf3.pyx":144
 * 
 *     def __cinit__(self):
 *         self.strings = codec.IndexedCollection(use_hash=1)             # <<<<<<<<<<<<<<
 *         self.classes = {}
 *         self.class_ref = {}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__use_hash), __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_IndexedCollection)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->strings);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->strings));
  ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->strings = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":145
 *     def __cinit__(self):
 *         self.strings = codec.IndexedCollection(use_hash=1)
 *         self.classes = {}             # <<<<<<<<<<<<<<
 *         self.class_ref = {}
 *         self.proxied_objects = {}
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->classes);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->classes));
  ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->classes = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":146
 *         self.strings = codec.IndexedCollection(use_hash=1)
 *         self.classes = {}
 *         self.class_ref = {}             # <<<<<<<<<<<<<<
 *         self.proxied_objects = {}
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->class_ref);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->class_ref));
  ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->class_ref = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":147
 *         self.classes = {}
 *         self.class_ref = {}
 *         self.proxied_objects = {}             # <<<<<<<<<<<<<<
 * 
 *         self.class_idx = 0
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->proxied_objects);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->proxied_objects));
  ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->proxied_objects = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":149
 *         self.proxied_objects = {}
 * 
 *         self.class_idx = 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef int clear(self) except -1:
 */
  ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->class_idx = 0;

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

/* "cpyamf/amf3.pyx":151
 *         self.class_idx = 0
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Clears the context.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_1clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  int __pyx_f_6cpyamf_4amf3_7Context_clear(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("clear");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clear); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __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_4amf3_7Context_1clear)) {
      __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 = 151; __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 = 151; __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/amf3.pyx":155
 *         Clears the context.
 *         """
 *         codec.Context.clear(self)             # <<<<<<<<<<<<<<
 * 
 *         self.strings.clear()
 */
  __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 = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":157
 *         codec.Context.clear(self)
 * 
 *         self.strings.clear()             # <<<<<<<<<<<<<<
 *         self.proxied_objects = {}
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->strings->__pyx_vtab)->clear(__pyx_v_self->strings, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":158
 * 
 *         self.strings.clear()
 *         self.proxied_objects = {}             # <<<<<<<<<<<<<<
 * 
 *         self.classes = {}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->proxied_objects);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->proxied_objects));
  __pyx_v_self->proxied_objects = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":160
 *         self.proxied_objects = {}
 * 
 *         self.classes = {}             # <<<<<<<<<<<<<<
 *         self.class_ref = {}
 *         self.class_idx = 0
 */
  __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_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->classes);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->classes));
  __pyx_v_self->classes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":161
 * 
 *         self.classes = {}
 *         self.class_ref = {}             # <<<<<<<<<<<<<<
 *         self.class_idx = 0
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->class_ref);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->class_ref));
  __pyx_v_self->class_ref = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":162
 *         self.classes = {}
 *         self.class_ref = {}
 *         self.class_idx = 0             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_v_self->class_idx = 0;

  /* "cpyamf/amf3.pyx":164
 *         self.class_idx = 0
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getString(self, Py_ssize_t ref):
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":151
 *         self.class_idx = 0
 * 
 *     cpdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Clears the context.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_1clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Context_1clear[] = "\n        Clears the context.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_1clear(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_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_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 = 151; __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 = 151; __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.amf3.Context.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":166
 *         return 0
 * 
 *     cpdef object getString(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.strings.getByReference(ref)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_2getString(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf3_7Context_getString(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, Py_ssize_t __pyx_v_ref, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("getString");
  /* 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__getString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __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_4amf3_7Context_2getString)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":167
 * 
 *     cpdef object getString(self, Py_ssize_t ref):
 *         return self.strings.getByReference(ref)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Py_ssize_t getStringReference(self, object s) except -2:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->strings->__pyx_vtab)->getByReference(__pyx_v_self->strings, __pyx_v_ref, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":166
 *         return 0
 * 
 *     cpdef object getString(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.strings.getByReference(ref)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_2getString(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_2getString(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref) {
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getString");
  assert(__pyx_arg_ref); {
    __pyx_v_ref = __Pyx_PyIndex_AsSsize_t(__pyx_arg_ref); if (unlikely((__pyx_v_ref == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.Context.getString");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getString(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_ref, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __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.amf3.Context.getString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":169
 *         return self.strings.getByReference(ref)
 * 
 *     cpdef Py_ssize_t getStringReference(self, object s) except -2:             # <<<<<<<<<<<<<<
 *         return self.strings.getReferenceTo(s)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_3getStringReference(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static  Py_ssize_t __pyx_f_6cpyamf_4amf3_7Context_getStringReference(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_s, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("getStringReference");
  /* 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__getStringReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __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_4amf3_7Context_3getStringReference)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __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/amf3.pyx":170
 * 
 *     cpdef Py_ssize_t getStringReference(self, object s) except -2:
 *         return self.strings.getReferenceTo(s)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Py_ssize_t addString(self, object s) except -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->strings->__pyx_vtab)->getReferenceTo(__pyx_v_self->strings, __pyx_v_s, 0); if (unlikely(__pyx_t_4 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __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.amf3.Context.getStringReference");
  __pyx_r = -2;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":169
 *         return self.strings.getByReference(ref)
 * 
 *     cpdef Py_ssize_t getStringReference(self, object s) except -2:             # <<<<<<<<<<<<<<
 *         return self.strings.getReferenceTo(s)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_3getStringReference(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_3getStringReference(PyObject *__pyx_v_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("getStringReference");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getStringReference(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_s, 1); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __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.amf3.Context.getStringReference");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":172
 *         return self.strings.getReferenceTo(s)
 * 
 *     cpdef Py_ssize_t addString(self, object s) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Returns -2 which signifies that s was empty
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_4addString(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static  Py_ssize_t __pyx_f_6cpyamf_4amf3_7Context_addString(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_s, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("addString");
  /* 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__addString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __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_4amf3_7Context_4addString)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __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/amf3.pyx":176
 *         Returns -2 which signifies that s was empty
 *         """
 *         return self.strings.append(s)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getClassByReference(self, Py_ssize_t ref):
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_5codec_IndexedCollection *)__pyx_v_self->strings->__pyx_vtab)->append(__pyx_v_self->strings, __pyx_v_s, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __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.amf3.Context.addString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":172
 *         return self.strings.getReferenceTo(s)
 * 
 *     cpdef Py_ssize_t addString(self, object s) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Returns -2 which signifies that s was empty
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_4addString(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Context_4addString[] = "\n        Returns -2 which signifies that s was empty\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_4addString(PyObject *__pyx_v_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("addString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->addString(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_s, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __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.amf3.Context.addString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":178
 *         return self.strings.append(s)
 * 
 *     cpdef object getClassByReference(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.class_ref.get(ref, None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_5getClassByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf3_7Context_getClassByReference(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, Py_ssize_t __pyx_v_ref, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("getClassByReference");
  /* 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__getClassByReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __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_4amf3_7Context_5getClassByReference)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":179
 * 
 *     cpdef object getClassByReference(self, Py_ssize_t ref):
 *         return self.class_ref.get(ref, None)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ClassDefinition getClass(self, object klass):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->class_ref == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->class_ref), __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf3.Context.getClassByReference");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":178
 *         return self.strings.append(s)
 * 
 *     cpdef object getClassByReference(self, Py_ssize_t ref):             # <<<<<<<<<<<<<<
 *         return self.class_ref.get(ref, None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_5getClassByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_5getClassByReference(PyObject *__pyx_v_self, PyObject *__pyx_arg_ref) {
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getClassByReference");
  assert(__pyx_arg_ref); {
    __pyx_v_ref = __Pyx_PyIndex_AsSsize_t(__pyx_arg_ref); if (unlikely((__pyx_v_ref == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.Context.getClassByReference");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getClassByReference(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_ref, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __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.amf3.Context.getClassByReference");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":181
 *         return self.class_ref.get(ref, None)
 * 
 *     cpdef ClassDefinition getClass(self, object klass):             # <<<<<<<<<<<<<<
 *         return self.classes.get(klass, None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_6getClass(PyObject *__pyx_v_self, PyObject *__pyx_v_klass); /*proto*/
static  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_f_6cpyamf_4amf3_7Context_getClass(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_klass, int __pyx_skip_dispatch) {
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("getClass");
  /* 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__getClass); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __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_4amf3_7Context_6getClass)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6cpyamf_4amf3_ClassDefinition))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":182
 * 
 *     cpdef ClassDefinition getClass(self, object klass):
 *         return self.classes.get(klass, None)             # <<<<<<<<<<<<<<
 * 
 *     cpdef Py_ssize_t addClass(self, ClassDefinition alias, klass) except? -1:
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(__pyx_v_self->classes == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_self->classes), __pyx_v_klass, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6cpyamf_4amf3_ClassDefinition))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)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.amf3.Context.getClass");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":181
 *         return self.class_ref.get(ref, None)
 * 
 *     cpdef ClassDefinition getClass(self, object klass):             # <<<<<<<<<<<<<<
 *         return self.classes.get(klass, None)
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_6getClass(PyObject *__pyx_v_self, PyObject *__pyx_v_klass); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_6getClass(PyObject *__pyx_v_self, PyObject *__pyx_v_klass) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getClass");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getClass(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_klass, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __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.amf3.Context.getClass");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":184
 *         return self.classes.get(klass, None)
 * 
 *     cpdef Py_ssize_t addClass(self, ClassDefinition alias, klass) except? -1:             # <<<<<<<<<<<<<<
 *         cdef object ref = self.class_idx
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_7addClass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  Py_ssize_t __pyx_f_6cpyamf_4amf3_7Context_addClass(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_alias, PyObject *__pyx_v_klass, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ref = 0;
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("addClass");
  /* 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__addClass); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __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_4amf3_7Context_7addClass)) {
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(((PyObject *)__pyx_v_alias));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_alias));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_alias));
      __Pyx_INCREF(__pyx_v_klass);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_klass);
      __Pyx_GIVEREF(__pyx_v_klass);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __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/amf3.pyx":185
 * 
 *     cpdef Py_ssize_t addClass(self, ClassDefinition alias, klass) except? -1:
 *         cdef object ref = self.class_idx             # <<<<<<<<<<<<<<
 * 
 *         self.class_ref[ref] = alias
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->class_idx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ref = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":187
 *         cdef object ref = self.class_idx
 * 
 *         self.class_ref[ref] = alias             # <<<<<<<<<<<<<<
 *         self.classes[klass] = alias
 * 
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->class_ref), __pyx_v_ref, ((PyObject *)__pyx_v_alias)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":188
 * 
 *         self.class_ref[ref] = alias
 *         self.classes[klass] = alias             # <<<<<<<<<<<<<<
 * 
 *         alias.ref = ref
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->classes), __pyx_v_klass, ((PyObject *)__pyx_v_alias)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":190
 *         self.classes[klass] = alias
 * 
 *         alias.ref = ref             # <<<<<<<<<<<<<<
 *         self.class_idx += 1
 * 
 */
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_v_ref); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_alias->ref = __pyx_t_4;

  /* "cpyamf/amf3.pyx":191
 * 
 *         alias.ref = ref
 *         self.class_idx += 1             # <<<<<<<<<<<<<<
 * 
 *         return ref
 */
  __pyx_v_self->class_idx = (__pyx_v_self->class_idx + 1);

  /* "cpyamf/amf3.pyx":193
 *         self.class_idx += 1
 * 
 *         return ref             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getProxyForObject(self, object obj):
 */
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_v_ref); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __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.amf3.Context.addClass");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":184
 *         return self.classes.get(klass, None)
 * 
 *     cpdef Py_ssize_t addClass(self, ClassDefinition alias, klass) except? -1:             # <<<<<<<<<<<<<<
 *         cdef object ref = self.class_idx
 * 
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_7addClass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_7addClass(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_alias = 0;
  PyObject *__pyx_v_klass = 0;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alias,&__pyx_n_s__klass,0};
  __Pyx_RefNannySetupContext("addClass");
  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__alias);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__klass);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("addClass", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "addClass") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_alias = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)values[0]);
    __pyx_v_klass = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_alias = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_klass = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("addClass", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.Context.addClass");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alias), __pyx_ptype_6cpyamf_4amf3_ClassDefinition, 1, "alias", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->addClass(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_alias, __pyx_v_klass, 1); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __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.amf3.Context.addClass");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":195
 *         return ref
 * 
 *     cpdef object getProxyForObject(self, object obj):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the proxied version of C{obj} as stored in the context, or
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_8getProxyForObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf3_7Context_getProxyForObject(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret;
  PyObject *__pyx_v_flex;
  PyObject *__pyx_v_proxied;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("getProxyForObject");
  __pyx_v_flex = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_proxied = 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__getProxyForObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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_4amf3_7Context_8getProxyForObject)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":203
 *         @since: 0.6
 *         """
 *         cdef PyObject *ret = PyDict_GetItem(self.proxied_objects, PyLong_FromVoidPtr(<void *>obj))             # <<<<<<<<<<<<<<
 * 
 *         if ret != NULL:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->proxied_objects);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromVoidPtr(((void *)__pyx_v_obj)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = PyDict_GetItem(__pyx_t_1, __pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":205
 *         cdef PyObject *ret = PyDict_GetItem(self.proxied_objects, PyLong_FromVoidPtr(<void *>obj))
 * 
 *         if ret != NULL:             # <<<<<<<<<<<<<<
 *             return <object>ret
 * 
 */
  __pyx_t_4 = (__pyx_v_ret != NULL);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":206
 * 
 *         if ret != NULL:
 *             return <object>ret             # <<<<<<<<<<<<<<
 * 
 *         from pyamf import flex
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = ((PyObject *)__pyx_v_ret);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":208
 *             return <object>ret
 * 
 *         from pyamf import flex             # <<<<<<<<<<<<<<
 * 
 *         proxied = flex.proxy_object(obj)
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__flex));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__flex));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__flex));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flex); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_flex);
  __pyx_v_flex = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":210
 *         from pyamf import flex
 * 
 *         proxied = flex.proxy_object(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.addProxyObject(obj, proxied)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_flex, __pyx_n_s__proxy_object); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __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_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_proxied);
  __pyx_v_proxied = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":212
 *         proxied = flex.proxy_object(obj)
 * 
 *         self.addProxyObject(obj, proxied)             # <<<<<<<<<<<<<<
 * 
 *         return proxied
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->__pyx_base.__pyx_vtab)->addProxyObject(__pyx_v_self, __pyx_v_obj, __pyx_v_proxied, 0); if (unlikely(__pyx_t_5 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":214
 *         self.addProxyObject(obj, proxied)
 * 
 *         return proxied             # <<<<<<<<<<<<<<
 * 
 *     cpdef object getObjectForProxy(self, object proxy):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_proxied);
  __pyx_r = __pyx_v_proxied;
  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.amf3.Context.getProxyForObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_flex);
  __Pyx_DECREF(__pyx_v_proxied);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":195
 *         return ref
 * 
 *     cpdef object getProxyForObject(self, object obj):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the proxied version of C{obj} as stored in the context, or
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_8getProxyForObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Context_8getProxyForObject[] = "\n        Returns the proxied version of C{obj} as stored in the context, or\n        creates a new proxied object and returns that.\n\n        @see: L{pyamf.flex.proxy_object}\n        @since: 0.6\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_8getProxyForObject(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getProxyForObject");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getProxyForObject(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_obj, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __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.amf3.Context.getProxyForObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":216
 *         return proxied
 * 
 *     cpdef object getObjectForProxy(self, object proxy):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the unproxied version of C{proxy} as stored in the context, or
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_9getObjectForProxy(PyObject *__pyx_v_self, PyObject *__pyx_v_proxy); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf3_7Context_getObjectForProxy(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_proxy, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ret;
  PyObject *__pyx_v_flex;
  PyObject *__pyx_v_obj;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("getObjectForProxy");
  __pyx_v_flex = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_obj = 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__getObjectForProxy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __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_4amf3_7Context_9getObjectForProxy)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_proxy);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_proxy);
      __Pyx_GIVEREF(__pyx_v_proxy);
      __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 = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":224
 *         @since: 0.6
 *         """
 *         cdef PyObject *ret = PyDict_GetItem(self.proxied_objects, PyLong_FromVoidPtr(<void *>proxy))             # <<<<<<<<<<<<<<
 * 
 *         if ret != NULL:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->proxied_objects);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromVoidPtr(((void *)__pyx_v_proxy)); 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_v_ret = PyDict_GetItem(__pyx_t_1, __pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":226
 *         cdef PyObject *ret = PyDict_GetItem(self.proxied_objects, PyLong_FromVoidPtr(<void *>proxy))
 * 
 *         if ret != NULL:             # <<<<<<<<<<<<<<
 *             return <object>ret
 * 
 */
  __pyx_t_4 = (__pyx_v_ret != NULL);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":227
 * 
 *         if ret != NULL:
 *             return <object>ret             # <<<<<<<<<<<<<<
 * 
 *         from pyamf import flex
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = ((PyObject *)__pyx_v_ret);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":229
 *             return <object>ret
 * 
 *         from pyamf import flex             # <<<<<<<<<<<<<<
 * 
 *         obj = flex.unproxy_object(proxy)
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__flex));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__flex));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__flex));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flex); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_flex);
  __pyx_v_flex = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":231
 *         from pyamf import flex
 * 
 *         obj = flex.unproxy_object(proxy)             # <<<<<<<<<<<<<<
 * 
 *         self.addProxyObject(obj, proxy)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_flex, __pyx_n_s__unproxy_object); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_proxy);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_proxy);
  __Pyx_GIVEREF(__pyx_v_proxy);
  __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 = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_obj);
  __pyx_v_obj = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":233
 *         obj = flex.unproxy_object(proxy)
 * 
 *         self.addProxyObject(obj, proxy)             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->__pyx_base.__pyx_vtab)->addProxyObject(__pyx_v_self, __pyx_v_obj, __pyx_v_proxy, 0); if (unlikely(__pyx_t_5 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":235
 *         self.addProxyObject(obj, proxy)
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cpdef int addProxyObject(self, object obj, object proxied) except? -1:
 */
  __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_3);
  __Pyx_AddTraceback("cpyamf.amf3.Context.getObjectForProxy");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_flex);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":216
 *         return proxied
 * 
 *     cpdef object getObjectForProxy(self, object proxy):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the unproxied version of C{proxy} as stored in the context, or
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_9getObjectForProxy(PyObject *__pyx_v_self, PyObject *__pyx_v_proxy); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Context_9getObjectForProxy[] = "\n        Returns the unproxied version of C{proxy} as stored in the context, or\n        unproxies the proxy and returns that 'raw' object.\n\n        @see: L{pyamf.flex.unproxy_object}\n        @since: 0.6\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_9getObjectForProxy(PyObject *__pyx_v_self, PyObject *__pyx_v_proxy) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getObjectForProxy");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->getObjectForProxy(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_proxy, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __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.amf3.Context.getObjectForProxy");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":237
 *         return obj
 * 
 *     cpdef int addProxyObject(self, object obj, object proxied) except? -1:             # <<<<<<<<<<<<<<
 *         """
 *         Stores a reference to the unproxied and proxied versions of C{obj} for
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_10addProxyObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_4amf3_7Context_addProxyObject(struct __pyx_obj_6cpyamf_4amf3_Context *__pyx_v_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_proxied, int __pyx_skip_dispatch) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("addProxyObject");
  /* 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__addProxyObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __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_4amf3_7Context_10addProxyObject)) {
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __Pyx_INCREF(__pyx_v_proxied);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_proxied);
      __Pyx_GIVEREF(__pyx_v_proxied);
      __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 = 237; __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 = 237; __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/amf3.pyx":244
 *         @since: 0.6
 *         """
 *         self.proxied_objects[PyLong_FromVoidPtr(<void *>obj)] = proxied             # <<<<<<<<<<<<<<
 *         self.proxied_objects[PyLong_FromVoidPtr(<void *>proxied)] = obj
 * 
 */
  __pyx_t_1 = PyLong_FromVoidPtr(((void *)__pyx_v_obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->proxied_objects), __pyx_t_1, __pyx_v_proxied) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":245
 *         """
 *         self.proxied_objects[PyLong_FromVoidPtr(<void *>obj)] = proxied
 *         self.proxied_objects[PyLong_FromVoidPtr(<void *>proxied)] = obj             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_1 = PyLong_FromVoidPtr(((void *)__pyx_v_proxied)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->proxied_objects), __pyx_t_1, __pyx_v_obj) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":247
 *         self.proxied_objects[PyLong_FromVoidPtr(<void *>proxied)] = obj
 * 
 *         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_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cpyamf.amf3.Context.addProxyObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":237
 *         return obj
 * 
 *     cpdef int addProxyObject(self, object obj, object proxied) except? -1:             # <<<<<<<<<<<<<<
 *         """
 *         Stores a reference to the unproxied and proxied versions of C{obj} for
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_10addProxyObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Context_10addProxyObject[] = "\n        Stores a reference to the unproxied and proxied versions of C{obj} for\n        later retrieval.\n\n        @since: 0.6\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Context_10addProxyObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_proxied = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__proxied,0};
  __Pyx_RefNannySetupContext("addProxyObject");
  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__obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__proxied);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("addProxyObject", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "addProxyObject") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_obj = values[0];
    __pyx_v_proxied = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_obj = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_proxied = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("addProxyObject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.Context.addProxyObject");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self)->__pyx_base.__pyx_vtab)->addProxyObject(((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_self), __pyx_v_obj, __pyx_v_proxied, 1); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __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 = 237; __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.amf3.Context.addProxyObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":255
 *     """
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         context = kwargs.pop('context', None)
 * 
 */

static int __pyx_pf_6cpyamf_4amf3_7Decoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf3_7Decoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_v_context;
  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;
  __pyx_v_context = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":256
 * 
 *     def __init__(self, *args, **kwargs):
 *         context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if context is 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 = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __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_context);
  __pyx_v_context = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":258
 *         context = kwargs.pop('context', None)
 * 
 *         if context is None:             # <<<<<<<<<<<<<<
 *             context = Context()
 * 
 */
  __pyx_t_3 = (__pyx_v_context == Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":259
 * 
 *         if context is None:
 *             context = Context()             # <<<<<<<<<<<<<<
 * 
 *         self.context = context
 */
    __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 = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_context);
    __pyx_v_context = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":261
 *             context = Context()
 * 
 *         self.context = context             # <<<<<<<<<<<<<<
 * 
 *         codec.Decoder.__init__(self, *args, **kwargs)
 */
  if (!(likely(((__pyx_v_context) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_context, __pyx_ptype_6cpyamf_4amf3_Context))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_context);
  __Pyx_GIVEREF(__pyx_v_context);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Decoder *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Decoder *)__pyx_v_self)->context));
  ((struct __pyx_obj_6cpyamf_4amf3_Decoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_context);

  /* "cpyamf/amf3.pyx":263
 *         self.context = context
 * 
 *         codec.Decoder.__init__(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cdef object readInteger(self, int signed=1):
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_Decoder)), __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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.amf3.Decoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_DECREF(__pyx_v_context);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":265
 *         codec.Decoder.__init__(self, *args, **kwargs)
 * 
 *     cdef object readInteger(self, int signed=1):             # <<<<<<<<<<<<<<
 *         """
 *         Reads and returns an integer from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readInteger(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, struct __pyx_opt_args_6cpyamf_4amf3_7Decoder_readInteger *__pyx_optional_args) {
  int __pyx_v_signed = ((int)1);
  int __pyx_v_r;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  struct __pyx_opt_args_6cpyamf_4amf3_decode_int __pyx_t_3;
  __Pyx_RefNannySetupContext("readInteger");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_signed = __pyx_optional_args->__pyx_signed;
    }
  }

  /* "cpyamf/amf3.pyx":274
 *         format.
 *         """
 *         cdef int r = decode_int(self.stream, signed)             # <<<<<<<<<<<<<<
 * 
 *         return <object>r
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.sign = __pyx_v_signed;
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3_decode_int(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), &__pyx_t_3); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_r = __pyx_t_2;

  /* "cpyamf/amf3.pyx":276
 *         cdef int r = decode_int(self.stream, signed)
 * 
 *         return <object>r             # <<<<<<<<<<<<<<
 * 
 *     cdef object readNumber(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __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.amf3.Decoder.readInteger");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":278
 *         return <object>r
 * 
 *     cdef object readNumber(self):             # <<<<<<<<<<<<<<
 *         cdef double d
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readNumber(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  double __pyx_v_d;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("readNumber");

  /* "cpyamf/amf3.pyx":281
 *         cdef double d
 * 
 *         self.stream.read_double(&d)             # <<<<<<<<<<<<<<
 * 
 *         return d
 */
  __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_d)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":283
 *         self.stream.read_double(&d)
 * 
 *         return d             # <<<<<<<<<<<<<<
 * 
 *     cdef object readBytes(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __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.amf3.Decoder.readNumber");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":285
 *         return d
 * 
 *     cdef object readBytes(self):             # <<<<<<<<<<<<<<
 *         cdef object s = self.readString()
 * 
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readBytes(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("readBytes");

  /* "cpyamf/amf3.pyx":286
 * 
 *     cdef object readBytes(self):
 *         cdef object s = self.readString()             # <<<<<<<<<<<<<<
 * 
 *         return self.context.getBytesForString(s)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

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

/* "cpyamf/amf3.pyx":290
 *         return self.context.getBytesForString(s)
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads and returns a string from the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_1readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readString(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_r;
  PyObject *__pyx_v_s;
  char *__pyx_v_buf;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("readString");
  __pyx_v_s = 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__readString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __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_4amf3_7Decoder_1readString)) {
      __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 = 290; __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/amf3.pyx":294
 *         Reads and returns a string from the stream.
 *         """
 *         cdef Py_ssize_t r = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 *         cdef object s
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_r = __pyx_t_3;

  /* "cpyamf/amf3.pyx":297
 *         cdef object s
 * 
 *         if r & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             # read a string reference
 *             return self.context.getString(r >> 1)
 */
  __pyx_t_4 = ((__pyx_v_r & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":299
 *         if r & REFERENCE_BIT == 0:
 *             # read a string reference
 *             return self.context.getString(r >> 1)             # <<<<<<<<<<<<<<
 * 
 *         r >>= 1
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getString(__pyx_v_self->context, (__pyx_v_r >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":301
 *             return self.context.getString(r >> 1)
 * 
 *         r >>= 1             # <<<<<<<<<<<<<<
 * 
 *         if r == 0:
 */
  __pyx_v_r = (__pyx_v_r >> 1);

  /* "cpyamf/amf3.pyx":303
 *         r >>= 1
 * 
 *         if r == 0:             # <<<<<<<<<<<<<<
 *             return empty_unicode
 * 
 */
  __pyx_t_4 = (__pyx_v_r == 0);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":304
 * 
 *         if r == 0:
 *             return empty_unicode             # <<<<<<<<<<<<<<
 * 
 *         cdef char *buf = NULL
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_unicode));
    __pyx_r = ((PyObject *)__pyx_v_6cpyamf_4amf3_empty_unicode);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":306
 *             return empty_unicode
 * 
 *         cdef char *buf = NULL             # <<<<<<<<<<<<<<
 * 
 *         self.stream.read(&buf, r)
 */
  __pyx_v_buf = NULL;

  /* "cpyamf/amf3.pyx":308
 *         cdef char *buf = NULL
 * 
 *         self.stream.read(&buf, r)             # <<<<<<<<<<<<<<
 *         s = PyUnicode_DecodeUTF8(buf, r, 'strict')
 * 
 */
  __pyx_t_5 = ((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_buf), __pyx_v_r); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":309
 * 
 *         self.stream.read(&buf, r)
 *         s = PyUnicode_DecodeUTF8(buf, r, 'strict')             # <<<<<<<<<<<<<<
 * 
 *         self.context.addString(s)
 */
  __pyx_t_1 = PyUnicode_DecodeUTF8(__pyx_v_buf, __pyx_v_r, __pyx_k__strict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":311
 *         s = PyUnicode_DecodeUTF8(buf, r, 'strict')
 * 
 *         self.context.addString(s)             # <<<<<<<<<<<<<<
 * 
 *         return s
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->addString(__pyx_v_self->context, __pyx_v_s, 0); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":313
 *         self.context.addString(s)
 * 
 *         return s             # <<<<<<<<<<<<<<
 * 
 *     cdef object readDate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  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.amf3.Decoder.readString");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":290
 *         return self.context.getBytesForString(s)
 * 
 *     cpdef object readString(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads and returns a string from the stream.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_1readString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Decoder_1readString[] = "\n        Reads and returns a string from the stream.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_1readString(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_4amf3_Decoder *)((struct __pyx_obj_6cpyamf_4amf3_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 = 290; __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.amf3.Decoder.readString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":315
 *         return s
 * 
 *     cdef object readDate(self):             # <<<<<<<<<<<<<<
 *         """
 *         Read date from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readDate(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  Py_ssize_t __pyx_v_ref;
  double __pyx_v_ms;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("readDate");

  /* "cpyamf/amf3.pyx":321
 *         The timezone is ignored as the date is always in UTC.
 *         """
 *         cdef Py_ssize_t ref = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 * 
 *         if ref & REFERENCE_BIT == 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ref = __pyx_t_2;

  /* "cpyamf/amf3.pyx":323
 *         cdef Py_ssize_t ref = _read_ref(self.stream)
 * 
 *         if ref & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             return self.context.getObject(ref >> 1)
 * 
 */
  __pyx_t_3 = ((__pyx_v_ref & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":324
 * 
 *         if ref & REFERENCE_BIT == 0:
 *             return self.context.getObject(ref >> 1)             # <<<<<<<<<<<<<<
 * 
 *         cdef double ms
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), (__pyx_v_ref >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":328
 *         cdef double ms
 * 
 *         self.stream.read_double(&ms)             # <<<<<<<<<<<<<<
 * 
 *         cdef object result = util.get_datetime(ms / 1000.0)
 */
  __pyx_t_4 = ((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_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":330
 *         self.stream.read_double(&ms)
 * 
 *         cdef object result = util.get_datetime(ms / 1000.0)             # <<<<<<<<<<<<<<
 * 
 *         if self.timezone_offset is not None:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__get_datetime); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble((__pyx_v_ms / 1000.0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":332
 *         cdef object result = util.get_datetime(ms / 1000.0)
 * 
 *         if self.timezone_offset is not None:             # <<<<<<<<<<<<<<
 *             result += self.timezone_offset
 * 
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.__pyx_base.timezone_offset != Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":333
 * 
 *         if self.timezone_offset is not None:
 *             result += self.timezone_offset             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(result)
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_v_self->__pyx_base.__pyx_base.timezone_offset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":335
 *             result += self.timezone_offset
 * 
 *         self.context.addObject(result)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_result, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":337
 *         self.context.addObject(result)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef object readList(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readDate");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":339
 *         return result
 * 
 *     cdef object readList(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads an array from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readList(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  int __pyx_v_size;
  int __pyx_v_i;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_tmp;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_el;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("readList");
  __pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_tmp = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_key = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_el = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":343
 *         Reads an array from the stream.
 *         """
 *         cdef int size = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef list result
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_size = __pyx_t_2;

  /* "cpyamf/amf3.pyx":349
 *         cdef unicode key
 * 
 *         if size & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             return self.context.getObject(size >> 1)
 * 
 */
  __pyx_t_3 = ((__pyx_v_size & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":350
 * 
 *         if size & REFERENCE_BIT == 0:
 *             return self.context.getObject(size >> 1)             # <<<<<<<<<<<<<<
 * 
 *         size >>= 1
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), (__pyx_v_size >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":352
 *             return self.context.getObject(size >> 1)
 * 
 *         size >>= 1             # <<<<<<<<<<<<<<
 *         key = self.readString()
 * 
 */
  __pyx_v_size = (__pyx_v_size >> 1);

  /* "cpyamf/amf3.pyx":353
 * 
 *         size >>= 1
 *         key = self.readString()             # <<<<<<<<<<<<<<
 * 
 *         if PyUnicode_GetSize(key) == 0:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_key));
  __pyx_v_key = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":355
 *         key = self.readString()
 * 
 *         if PyUnicode_GetSize(key) == 0:             # <<<<<<<<<<<<<<
 *             # integer indexes only -> python list
 *             result = []
 */
  __pyx_t_2 = PyUnicode_GetSize(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (__pyx_t_2 == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":357
 *         if PyUnicode_GetSize(key) == 0:
 *             # integer indexes only -> python list
 *             result = []             # <<<<<<<<<<<<<<
 *             self.context.addObject(result)
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":358
 *             # integer indexes only -> python list
 *             result = []
 *             self.context.addObject(result)             # <<<<<<<<<<<<<<
 * 
 *             for i from 0 <= i < size:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_result), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf3.pyx":360
 *             self.context.addObject(result)
 * 
 *             for i from 0 <= i < size:             # <<<<<<<<<<<<<<
 *                 result.append(self.readElement())
 * 
 */
    __pyx_t_4 = __pyx_v_size;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

      /* "cpyamf/amf3.pyx":361
 * 
 *             for i from 0 <= i < size:
 *                 result.append(self.readElement())             # <<<<<<<<<<<<<<
 * 
 *             return result
 */
      if (unlikely(__pyx_v_result == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }

    /* "cpyamf/amf3.pyx":363
 *                 result.append(self.readElement())
 * 
 *             return result             # <<<<<<<<<<<<<<
 * 
 *         tmp = pyamf.MixedArray()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_result));
    __pyx_r = ((PyObject *)__pyx_v_result);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":365
 *             return result
 * 
 *         tmp = pyamf.MixedArray()             # <<<<<<<<<<<<<<
 *         self.context.addObject(result)
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__MixedArray); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_v_tmp);
  __pyx_v_tmp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":366
 * 
 *         tmp = pyamf.MixedArray()
 *         self.context.addObject(result)             # <<<<<<<<<<<<<<
 * 
 *         while PyUnicode_GetSize(key):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_result), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":368
 *         self.context.addObject(result)
 * 
 *         while PyUnicode_GetSize(key):             # <<<<<<<<<<<<<<
 *             tmp[key] = self.readElement()
 *             key = self.readString()
 */
  while (1) {
    __pyx_t_2 = PyUnicode_GetSize(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!__pyx_t_2) break;

    /* "cpyamf/amf3.pyx":369
 * 
 *         while PyUnicode_GetSize(key):
 *             tmp[key] = self.readElement()             # <<<<<<<<<<<<<<
 *             key = self.readString()
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyObject_SetItem(__pyx_v_tmp, ((PyObject *)__pyx_v_key), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":370
 *         while PyUnicode_GetSize(key):
 *             tmp[key] = self.readElement()
 *             key = self.readString()             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < size:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_key));
    __pyx_v_key = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "cpyamf/amf3.pyx":372
 *             key = self.readString()
 * 
 *         for i from 0 <= i < size:             # <<<<<<<<<<<<<<
 *             el = self.readElement()
 *             tmp[i] = el
 */
  __pyx_t_4 = __pyx_v_size;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

    /* "cpyamf/amf3.pyx":373
 * 
 *         for i from 0 <= i < size:
 *             el = self.readElement()             # <<<<<<<<<<<<<<
 *             tmp[i] = el
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_el);
    __pyx_v_el = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":374
 *         for i from 0 <= i < size:
 *             el = self.readElement()
 *             tmp[i] = el             # <<<<<<<<<<<<<<
 * 
 *         return tmp
 */
    if (__Pyx_SetItemInt(__pyx_v_tmp, __pyx_v_i, __pyx_v_el, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/amf3.pyx":376
 *             tmp[i] = el
 * 
 *         return tmp             # <<<<<<<<<<<<<<
 * 
 *     cdef ClassDefinition _getClassDefinition(self, long ref):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_tmp);
  __pyx_r = __pyx_v_tmp;
  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_6);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readList");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_tmp);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_el);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":378
 *         return tmp
 * 
 *     cdef ClassDefinition _getClassDefinition(self, long ref):             # <<<<<<<<<<<<<<
 *         """
 *         Reads class definition from the stream.
 */

static  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_f_6cpyamf_4amf3_7Decoder__getClassDefinition(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, long __pyx_v_ref) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_alias = 0;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_class_def = 0;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  __Pyx_RefNannySetupContext("_getClassDefinition");

  /* "cpyamf/amf3.pyx":382
 *         Reads class definition from the stream.
 *         """
 *         if ref & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             return self.context.getClassByReference(ref >> 1)
 * 
 */
  __pyx_t_1 = ((__pyx_v_ref & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":383
 *         """
 *         if ref & REFERENCE_BIT == 0:
 *             return self.context.getClassByReference(ref >> 1)             # <<<<<<<<<<<<<<
 * 
 *         ref >>= 1
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getClassByReference(__pyx_v_self->context, (__pyx_v_ref >> 1), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6cpyamf_4amf3_ClassDefinition))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":385
 *             return self.context.getClassByReference(ref >> 1)
 * 
 *         ref >>= 1             # <<<<<<<<<<<<<<
 * 
 *         cdef object name = self.readString()
 */
  __pyx_v_ref = (__pyx_v_ref >> 1);

  /* "cpyamf/amf3.pyx":387
 *         ref >>= 1
 * 
 *         cdef object name = self.readString()             # <<<<<<<<<<<<<<
 *         cdef object alias = None
 *         cdef Py_ssize_t i
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_name = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":388
 * 
 *         cdef object name = self.readString()
 *         cdef object alias = None             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 * 
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_alias = Py_None;

  /* "cpyamf/amf3.pyx":391
 *         cdef Py_ssize_t i
 * 
 *         if PyUnicode_GET_SIZE(name) == 0:             # <<<<<<<<<<<<<<
 *             name = pyamf.ASObject
 * 
 */
  __pyx_t_1 = (PyUnicode_GET_SIZE(__pyx_v_name) == 0);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":392
 * 
 *         if PyUnicode_GET_SIZE(name) == 0:
 *             name = pyamf.ASObject             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ASObject); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":394
 *             name = pyamf.ASObject
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             alias = self.context.getClassAlias(name)
 *         except pyamf.UnknownClassAlias:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "cpyamf/amf3.pyx":395
 * 
 *         try:
 *             alias = self.context.getClassAlias(name)             # <<<<<<<<<<<<<<
 *         except pyamf.UnknownClassAlias:
 *             if self.strict:
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_name, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_3;
      __pyx_t_3 = 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_3); __pyx_t_3 = 0;

    /* "cpyamf/amf3.pyx":396
 *         try:
 *             alias = self.context.getClassAlias(name)
 *         except pyamf.UnknownClassAlias:             # <<<<<<<<<<<<<<
 *             if self.strict:
 *                 raise
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__UnknownClassAlias); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {
      __Pyx_AddTraceback("cpyamf.amf3.Decoder._getClassDefinition");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_5);

      /* "cpyamf/amf3.pyx":397
 *             alias = self.context.getClassAlias(name)
 *         except pyamf.UnknownClassAlias:
 *             if self.strict:             # <<<<<<<<<<<<<<
 *                 raise
 * 
 */
      if (__pyx_v_self->__pyx_base.__pyx_base.strict) {

        /* "cpyamf/amf3.pyx":398
 *         except pyamf.UnknownClassAlias:
 *             if self.strict:
 *                 raise             # <<<<<<<<<<<<<<
 * 
 *             alias = pyamf.TypedObjectClassAlias(name)
 */
        __Pyx_GIVEREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_ErrRestore(__pyx_t_2, __pyx_t_3, __pyx_t_5);
        __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_5 = 0; 
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        goto __pyx_L15;
      }
      __pyx_L15:;

      /* "cpyamf/amf3.pyx":400
 *                 raise
 * 
 *             alias = pyamf.TypedObjectClassAlias(name)             # <<<<<<<<<<<<<<
 * 
 *         cdef ClassDefinition class_def = ClassDefinition(alias)
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __Pyx_INCREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_alias);
      __pyx_v_alias = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try_end:;
  }

  /* "cpyamf/amf3.pyx":402
 *             alias = pyamf.TypedObjectClassAlias(name)
 * 
 *         cdef ClassDefinition class_def = ClassDefinition(alias)             # <<<<<<<<<<<<<<
 * 
 *         class_def.encoding = ref & 0x03
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_INCREF(__pyx_v_alias);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_alias);
  __Pyx_GIVEREF(__pyx_v_alias);
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_ClassDefinition)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_v_class_def = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":404
 *         cdef ClassDefinition class_def = ClassDefinition(alias)
 * 
 *         class_def.encoding = ref & 0x03             # <<<<<<<<<<<<<<
 *         class_def.attr_len = ref >> 2
 *         class_def.static_properties = []
 */
  __pyx_v_class_def->encoding = (__pyx_v_ref & 0x03);

  /* "cpyamf/amf3.pyx":405
 * 
 *         class_def.encoding = ref & 0x03
 *         class_def.attr_len = ref >> 2             # <<<<<<<<<<<<<<
 *         class_def.static_properties = []
 * 
 */
  __pyx_v_class_def->attr_len = (__pyx_v_ref >> 2);

  /* "cpyamf/amf3.pyx":406
 *         class_def.encoding = ref & 0x03
 *         class_def.attr_len = ref >> 2
 *         class_def.static_properties = []             # <<<<<<<<<<<<<<
 * 
 *         if class_def.attr_len > 0:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __Pyx_GOTREF(__pyx_v_class_def->static_properties);
  __Pyx_DECREF(((PyObject *)__pyx_v_class_def->static_properties));
  __pyx_v_class_def->static_properties = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":408
 *         class_def.static_properties = []
 * 
 *         if class_def.attr_len > 0:             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < class_def.attr_len:
 *                 class_def.static_properties.append(self.readString())
 */
  __pyx_t_1 = (__pyx_v_class_def->attr_len > 0);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":409
 * 
 *         if class_def.attr_len > 0:
 *             for i from 0 <= i < class_def.attr_len:             # <<<<<<<<<<<<<<
 *                 class_def.static_properties.append(self.readString())
 * 
 */
    __pyx_t_9 = __pyx_v_class_def->attr_len;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {

      /* "cpyamf/amf3.pyx":410
 *         if class_def.attr_len > 0:
 *             for i from 0 <= i < class_def.attr_len:
 *                 class_def.static_properties.append(self.readString())             # <<<<<<<<<<<<<<
 * 
 *         self.context.addClass(class_def, alias.klass)
 */
      if (unlikely(__pyx_v_class_def->static_properties == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyList_Append(__pyx_v_class_def->static_properties, __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "cpyamf/amf3.pyx":412
 *                 class_def.static_properties.append(self.readString())
 * 
 *         self.context.addClass(class_def, alias.klass)             # <<<<<<<<<<<<<<
 * 
 *         return class_def
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__klass); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->addClass(__pyx_v_self->context, __pyx_v_class_def, __pyx_t_3, 0); if (unlikely(__pyx_t_9 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":414
 *         self.context.addClass(class_def, alias.klass)
 * 
 *         return class_def             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_class_def));
  __pyx_r = __pyx_v_class_def;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder._getClassDefinition");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_alias);
  __Pyx_XDECREF((PyObject *)__pyx_v_class_def);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":417
 * 
 *     @cython.boundscheck(False)
 *     cdef int _readStatic(self, ClassDefinition class_def, dict obj) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Decoder__readStatic(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_class_def, PyObject *__pyx_v_obj) {
  Py_ssize_t __pyx_v_i;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_readStatic");

  /* "cpyamf/amf3.pyx":420
 *         cdef Py_ssize_t i
 * 
 *         for 0 <= i < class_def.attr_len:             # <<<<<<<<<<<<<<
 *             obj[class_def.static_properties[i]] = self.readElement()
 * 
 */
  __pyx_t_1 = __pyx_v_class_def->attr_len;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "cpyamf/amf3.pyx":421
 * 
 *         for 0 <= i < class_def.attr_len:
 *             obj[class_def.static_properties[i]] = self.readElement()             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_class_def->static_properties), __pyx_v_i, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(((PyObject *)__pyx_v_obj), __pyx_t_3, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cpyamf/amf3.pyx":423
 *             obj[class_def.static_properties[i]] = self.readElement()
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int _readDynamic(self, ClassDefinition class_def, dict obj) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":425
 *         return 0
 * 
 *     cdef int _readDynamic(self, ClassDefinition class_def, dict obj) except -1:             # <<<<<<<<<<<<<<
 *         cdef object attr
 *         cdef char *peek
 */

static  int __pyx_f_6cpyamf_4amf3_7Decoder__readDynamic(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_class_def, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_attr;
  char *__pyx_v_peek;
  int __pyx_r;
  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("_readDynamic");
  __pyx_v_attr = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":430
 * 
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             self.stream.peek(&peek, 1)
 * 
 */
  while (1) {
    if (!1) break;

    /* "cpyamf/amf3.pyx":431
 * 
 *         while True:
 *             self.stream.peek(&peek, 1)             # <<<<<<<<<<<<<<
 * 
 *             if peek[0] == REF_CHAR:
 */
    __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), 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf3.pyx":433
 *             self.stream.peek(&peek, 1)
 * 
 *             if peek[0] == REF_CHAR:             # <<<<<<<<<<<<<<
 *                 self.stream.seek(1, 1)
 * 
 */
    __pyx_t_2 = ((__pyx_v_peek[0]) == __pyx_v_6cpyamf_4amf3_REF_CHAR);
    if (__pyx_t_2) {

      /* "cpyamf/amf3.pyx":434
 * 
 *             if peek[0] == REF_CHAR:
 *                 self.stream.seek(1, 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, 1, 0, &__pyx_t_4); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cpyamf/amf3.pyx":436
 *                 self.stream.seek(1, 1)
 * 
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             attr = self.readBytes()
 */
      goto __pyx_L4_break;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cpyamf/amf3.pyx":438
 *                 break
 * 
 *             attr = self.readBytes()             # <<<<<<<<<<<<<<
 * 
 *             PyDict_SetItem(obj, attr, self.readElement())
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readBytes(__pyx_v_self); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_v_attr);
    __pyx_v_attr = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cpyamf/amf3.pyx":440
 *             attr = self.readBytes()
 * 
 *             PyDict_SetItem(obj, attr, self.readElement())             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyDict_SetItem(((PyObject *)__pyx_v_obj), __pyx_v_attr, __pyx_t_5); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L4_break:;

  /* "cpyamf/amf3.pyx":442
 *             PyDict_SetItem(obj, attr, self.readElement())
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef object readObject(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder._readDynamic");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":444
 *         return 0
 * 
 *     cdef object readObject(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads an object from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readObject(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  int __pyx_v_ref;
  PyObject *__pyx_v_obj;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_class_def = 0;
  PyObject *__pyx_v_alias = 0;
  PyObject *__pyx_v_obj_attrs = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("readObject");
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":452
 *         @raise pyamf.DecodeError: Unknown object encoding.
 *         """
 *         cdef int ref = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 *         cdef object obj
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ref = __pyx_t_2;

  /* "cpyamf/amf3.pyx":455
 *         cdef object obj
 * 
 *         if ref & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             obj = self.context.getObject(ref >> 1)
 * 
 */
  __pyx_t_3 = ((__pyx_v_ref & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":456
 * 
 *         if ref & REFERENCE_BIT == 0:
 *             obj = self.context.getObject(ref >> 1)             # <<<<<<<<<<<<<<
 * 
 *             if obj is None:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), (__pyx_v_ref >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_obj);
    __pyx_v_obj = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":458
 *             obj = self.context.getObject(ref >> 1)
 * 
 *             if obj is None:             # <<<<<<<<<<<<<<
 *                 raise pyamf.ReferenceError('Unknown reference')
 * 
 */
    __pyx_t_3 = (__pyx_v_obj == Py_None);
    if (__pyx_t_3) {

      /* "cpyamf/amf3.pyx":459
 * 
 *             if obj is None:
 *                 raise pyamf.ReferenceError('Unknown reference')             # <<<<<<<<<<<<<<
 * 
 *             if self.use_proxies == 1:
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__ReferenceError); 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_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "cpyamf/amf3.pyx":461
 *                 raise pyamf.ReferenceError('Unknown reference')
 * 
 *             if self.use_proxies == 1:             # <<<<<<<<<<<<<<
 *                 return self.readProxy(obj)
 * 
 */
    __pyx_t_3 = (__pyx_v_self->use_proxies == 1);
    if (__pyx_t_3) {

      /* "cpyamf/amf3.pyx":462
 * 
 *             if self.use_proxies == 1:
 *                 return self.readProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *             return obj
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readProxy(__pyx_v_self, __pyx_v_obj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cpyamf/amf3.pyx":464
 *                 return self.readProxy(obj)
 * 
 *             return obj             # <<<<<<<<<<<<<<
 * 
 *         cdef ClassDefinition class_def = self._getClassDefinition(ref >> 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_obj);
    __pyx_r = __pyx_v_obj;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":466
 *             return obj
 * 
 *         cdef ClassDefinition class_def = self._getClassDefinition(ref >> 1)             # <<<<<<<<<<<<<<
 *         cdef object alias = class_def.alias
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_getClassDefinition(__pyx_v_self, (__pyx_v_ref >> 1))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_class_def = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":467
 * 
 *         cdef ClassDefinition class_def = self._getClassDefinition(ref >> 1)
 *         cdef object alias = class_def.alias             # <<<<<<<<<<<<<<
 * 
 *         obj = alias.createInstance(codec=self)
 */
  __Pyx_INCREF(__pyx_v_class_def->alias);
  __pyx_v_alias = __pyx_v_class_def->alias;

  /* "cpyamf/amf3.pyx":469
 *         cdef object alias = class_def.alias
 * 
 *         obj = alias.createInstance(codec=self)             # <<<<<<<<<<<<<<
 *         cdef dict obj_attrs = {}
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__createInstance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __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 = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_v_obj);
  __pyx_v_obj = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cpyamf/amf3.pyx":470
 * 
 *         obj = alias.createInstance(codec=self)
 *         cdef dict obj_attrs = {}             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_v_obj_attrs = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cpyamf/amf3.pyx":472
 *         cdef dict obj_attrs = {}
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         if class_def.encoding == OBJECT_ENCODING_DYNAMIC:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":474
 *         self.context.addObject(obj)
 * 
 *         if class_def.encoding == OBJECT_ENCODING_DYNAMIC:             # <<<<<<<<<<<<<<
 *             self._readStatic(class_def, obj_attrs)
 *             self._readDynamic(class_def, obj_attrs)
 */
  __pyx_t_3 = (__pyx_v_class_def->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_DYNAMIC);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":475
 * 
 *         if class_def.encoding == OBJECT_ENCODING_DYNAMIC:
 *             self._readStatic(class_def, obj_attrs)             # <<<<<<<<<<<<<<
 *             self._readDynamic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_STATIC:
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_readStatic(__pyx_v_self, __pyx_v_class_def, __pyx_v_obj_attrs); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf3.pyx":476
 *         if class_def.encoding == OBJECT_ENCODING_DYNAMIC:
 *             self._readStatic(class_def, obj_attrs)
 *             self._readDynamic(class_def, obj_attrs)             # <<<<<<<<<<<<<<
 *         elif class_def.encoding == OBJECT_ENCODING_STATIC:
 *             self._readStatic(class_def, obj_attrs)
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_readDynamic(__pyx_v_self, __pyx_v_class_def, __pyx_v_obj_attrs); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }

  /* "cpyamf/amf3.pyx":477
 *             self._readStatic(class_def, obj_attrs)
 *             self._readDynamic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_STATIC:             # <<<<<<<<<<<<<<
 *             self._readStatic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_EXTERNAL or class_def.encoding == OBJECT_ENCODING_PROXY:
 */
  __pyx_t_3 = (__pyx_v_class_def->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":478
 *             self._readDynamic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_STATIC:
 *             self._readStatic(class_def, obj_attrs)             # <<<<<<<<<<<<<<
 *         elif class_def.encoding == OBJECT_ENCODING_EXTERNAL or class_def.encoding == OBJECT_ENCODING_PROXY:
 *             obj.__readamf__(DataInput(self))
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_readStatic(__pyx_v_self, __pyx_v_class_def, __pyx_v_obj_attrs); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }

  /* "cpyamf/amf3.pyx":479
 *         elif class_def.encoding == OBJECT_ENCODING_STATIC:
 *             self._readStatic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_EXTERNAL or class_def.encoding == OBJECT_ENCODING_PROXY:             # <<<<<<<<<<<<<<
 *             obj.__readamf__(DataInput(self))
 * 
 */
  __pyx_t_3 = (__pyx_v_class_def->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_EXTERNAL);
  if (!__pyx_t_3) {
    __pyx_t_7 = (__pyx_v_class_def->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_PROXY);
    __pyx_t_8 = __pyx_t_7;
  } else {
    __pyx_t_8 = __pyx_t_3;
  }
  if (__pyx_t_8) {

    /* "cpyamf/amf3.pyx":480
 *             self._readStatic(class_def, obj_attrs)
 *         elif class_def.encoding == OBJECT_ENCODING_EXTERNAL or class_def.encoding == OBJECT_ENCODING_PROXY:
 *             obj.__readamf__(DataInput(self))             # <<<<<<<<<<<<<<
 * 
 *             if self.use_proxies == 1:
 */
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_obj, __pyx_n_s____readamf__); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_1 = PyObject_Call(__pyx_v_6cpyamf_4amf3_DataInput, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":482
 *             obj.__readamf__(DataInput(self))
 * 
 *             if self.use_proxies == 1:             # <<<<<<<<<<<<<<
 *                 return self.readProxy(obj)
 * 
 */
    __pyx_t_8 = (__pyx_v_self->use_proxies == 1);
    if (__pyx_t_8) {

      /* "cpyamf/amf3.pyx":483
 * 
 *             if self.use_proxies == 1:
 *                 return self.readProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *             return obj
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readProxy(__pyx_v_self, __pyx_v_obj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "cpyamf/amf3.pyx":485
 *                 return self.readProxy(obj)
 * 
 *             return obj             # <<<<<<<<<<<<<<
 *         else:
 *             raise pyamf.DecodeError("Unknown object encoding")
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_obj);
    __pyx_r = __pyx_v_obj;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":487
 *             return obj
 *         else:
 *             raise pyamf.DecodeError("Unknown object encoding")             # <<<<<<<<<<<<<<
 * 
 *         alias.applyAttributes(obj, obj_attrs, codec=self)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DecodeError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "cpyamf/amf3.pyx":489
 *             raise pyamf.DecodeError("Unknown object encoding")
 * 
 *         alias.applyAttributes(obj, obj_attrs, codec=self)             # <<<<<<<<<<<<<<
 * 
 *         if self.use_proxies:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__applyAttributes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_INCREF(((PyObject *)__pyx_v_obj_attrs));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_obj_attrs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_obj_attrs));
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__codec), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cpyamf/amf3.pyx":491
 *         alias.applyAttributes(obj, obj_attrs, codec=self)
 * 
 *         if self.use_proxies:             # <<<<<<<<<<<<<<
 *             return self.readProxy(obj)
 * 
 */
  if (__pyx_v_self->use_proxies) {

    /* "cpyamf/amf3.pyx":492
 * 
 *         if self.use_proxies:
 *             return self.readProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_9 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readProxy(__pyx_v_self, __pyx_v_obj); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "cpyamf/amf3.pyx":494
 *             return self.readProxy(obj)
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef object readXML(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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readObject");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_XDECREF((PyObject *)__pyx_v_class_def);
  __Pyx_XDECREF(__pyx_v_alias);
  __Pyx_XDECREF(__pyx_v_obj_attrs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":496
 *         return obj
 * 
 *     cdef object readXML(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads an XML object from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readXML(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  int __pyx_v_ref;
  char *__pyx_v_buf;
  PyObject *__pyx_v_s;
  PyObject *__pyx_v_x;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("readXML");
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":500
 *         Reads an XML object from the stream.
 *         """
 *         cdef int ref = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 * 
 *         if ref & REFERENCE_BIT == 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ref = __pyx_t_2;

  /* "cpyamf/amf3.pyx":502
 *         cdef int ref = _read_ref(self.stream)
 * 
 *         if ref & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             return self.context.getObject(ref >> 1)
 * 
 */
  __pyx_t_3 = ((__pyx_v_ref & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":503
 * 
 *         if ref & REFERENCE_BIT == 0:
 *             return self.context.getObject(ref >> 1)             # <<<<<<<<<<<<<<
 * 
 *         ref >>= 1
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), (__pyx_v_ref >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":505
 *             return self.context.getObject(ref >> 1)
 * 
 *         ref >>= 1             # <<<<<<<<<<<<<<
 * 
 *         cdef char *buf = NULL
 */
  __pyx_v_ref = (__pyx_v_ref >> 1);

  /* "cpyamf/amf3.pyx":507
 *         ref >>= 1
 * 
 *         cdef char *buf = NULL             # <<<<<<<<<<<<<<
 *         cdef object s
 * 
 */
  __pyx_v_buf = NULL;

  /* "cpyamf/amf3.pyx":510
 *         cdef object s
 * 
 *         self.stream.read(&buf, ref)             # <<<<<<<<<<<<<<
 *         s = PyString_FromStringAndSize(buf, ref)
 * 
 */
  __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_buf), __pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":511
 * 
 *         self.stream.read(&buf, ref)
 *         s = PyString_FromStringAndSize(buf, ref)             # <<<<<<<<<<<<<<
 * 
 *         x = xml.fromstring(s)
 */
  __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_buf, __pyx_v_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":513
 *         s = PyString_FromStringAndSize(buf, ref)
 * 
 *         x = xml.fromstring(s)             # <<<<<<<<<<<<<<
 *         self.context.addObject(x)
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__xml); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fromstring); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __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 = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_x);
  __pyx_v_x = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cpyamf/amf3.pyx":514
 * 
 *         x = xml.fromstring(s)
 *         self.context.addObject(x)             # <<<<<<<<<<<<<<
 * 
 *         return x
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_x, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":516
 *         self.context.addObject(x)
 * 
 *         return x             # <<<<<<<<<<<<<<
 * 
 *     cdef object readByteArray(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_x);
  __pyx_r = __pyx_v_x;
  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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readXML");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":518
 *         return x
 * 
 *     cdef object readByteArray(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reads a string of data from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readByteArray(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self) {
  int __pyx_v_ref;
  char *__pyx_v_buf;
  PyObject *__pyx_v_s;
  PyObject *__pyx_v_compressed = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("readByteArray");
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":527
 *         @note: This is not supported in ActionScript 1.0 and 2.0.
 *         """
 *         cdef int ref = _read_ref(self.stream)             # <<<<<<<<<<<<<<
 * 
 *         if ref & REFERENCE_BIT == 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__read_ref(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ref = __pyx_t_2;

  /* "cpyamf/amf3.pyx":529
 *         cdef int ref = _read_ref(self.stream)
 * 
 *         if ref & REFERENCE_BIT == 0:             # <<<<<<<<<<<<<<
 *             return self.context.getObject(ref >> 1)
 * 
 */
  __pyx_t_3 = ((__pyx_v_ref & __pyx_v_6cpyamf_4amf3_REFERENCE_BIT) == 0);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":530
 * 
 *         if ref & REFERENCE_BIT == 0:
 *             return self.context.getObject(ref >> 1)             # <<<<<<<<<<<<<<
 * 
 *         cdef char *buf = NULL
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), (__pyx_v_ref >> 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":532
 *             return self.context.getObject(ref >> 1)
 * 
 *         cdef char *buf = NULL             # <<<<<<<<<<<<<<
 *         cdef object s
 *         cdef object compressed = None
 */
  __pyx_v_buf = NULL;

  /* "cpyamf/amf3.pyx":534
 *         cdef char *buf = NULL
 *         cdef object s
 *         cdef object compressed = None             # <<<<<<<<<<<<<<
 * 
 *         ref >>= 1
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_compressed = Py_None;

  /* "cpyamf/amf3.pyx":536
 *         cdef object compressed = None
 * 
 *         ref >>= 1             # <<<<<<<<<<<<<<
 * 
 *         self.stream.read(&buf, ref)
 */
  __pyx_v_ref = (__pyx_v_ref >> 1);

  /* "cpyamf/amf3.pyx":538
 *         ref >>= 1
 * 
 *         self.stream.read(&buf, ref)             # <<<<<<<<<<<<<<
 *         s = PyString_FromStringAndSize(buf, ref)
 * 
 */
  __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_buf), __pyx_v_ref); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":539
 * 
 *         self.stream.read(&buf, ref)
 *         s = PyString_FromStringAndSize(buf, ref)             # <<<<<<<<<<<<<<
 * 
 *         if zlib:
 */
  __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_buf, __pyx_v_ref); 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_v_s);
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":541
 *         s = PyString_FromStringAndSize(buf, ref)
 * 
 *         if zlib:             # <<<<<<<<<<<<<<
 *             try:
 *                 s = zlib.decompress(s)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__zlib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":542
 * 
 *         if zlib:
 *             try:             # <<<<<<<<<<<<<<
 *                 s = zlib.decompress(s)
 *                 compressed = True
 */
    {
      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/amf3.pyx":543
 *         if zlib:
 *             try:
 *                 s = zlib.decompress(s)             # <<<<<<<<<<<<<<
 *                 compressed = True
 *             except zlib.error:
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__zlib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__decompress); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __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 = 543; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        __Pyx_INCREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_v_s);
        __pyx_v_s = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "cpyamf/amf3.pyx":544
 *             try:
 *                 s = zlib.decompress(s)
 *                 compressed = True             # <<<<<<<<<<<<<<
 *             except zlib.error:
 *                 compressed = False
 */
        __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_v_compressed);
        __pyx_v_compressed = __pyx_t_6;
        __pyx_t_6 = 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_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cpyamf/amf3.pyx":545
 *                 s = zlib.decompress(s)
 *                 compressed = True
 *             except zlib.error:             # <<<<<<<<<<<<<<
 *                 compressed = False
 * 
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__zlib); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_4 = PyErr_ExceptionMatches(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_4) {
        __Pyx_AddTraceback("cpyamf.amf3.Decoder.readByteArray");
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_5);

        /* "cpyamf/amf3.pyx":546
 *                 compressed = True
 *             except zlib.error:
 *                 compressed = False             # <<<<<<<<<<<<<<
 * 
 *             s = (<object>ByteArrayType)(s)
 */
        __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_v_compressed);
        __pyx_v_compressed = __pyx_t_7;
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L12_try_end:;
    }

    /* "cpyamf/amf3.pyx":548
 *                 compressed = False
 * 
 *             s = (<object>ByteArrayType)(s)             # <<<<<<<<<<<<<<
 * 
 *         s.compressed = compressed
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_s);
    __Pyx_GIVEREF(__pyx_v_s);
    __pyx_t_6 = PyObject_Call(__pyx_v_6cpyamf_4amf3_ByteArrayType, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":550
 *             s = (<object>ByteArrayType)(s)
 * 
 *         s.compressed = compressed             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(s)
 */
  if (PyObject_SetAttr(__pyx_v_s, __pyx_n_s__compressed, __pyx_v_compressed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":552
 *         s.compressed = compressed
 * 
 *         self.context.addObject(s)             # <<<<<<<<<<<<<<
 * 
 *         return s
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_s, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":554
 *         self.context.addObject(s)
 * 
 *         return s             # <<<<<<<<<<<<<<
 * 
 *     cdef object readProxy(self, obj):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readByteArray");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_compressed);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":556
 *         return s
 * 
 *     cdef object readProxy(self, obj):             # <<<<<<<<<<<<<<
 *         """
 *         Decodes a proxied object from the stream.
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readProxy(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("readProxy");

  /* "cpyamf/amf3.pyx":562
 *         @since: 0.6
 *         """
 *         return self.context.getObjectForProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *     cdef object readConcreteElement(self, char t):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getObjectForProxy(__pyx_v_self->context, __pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __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.amf3.Decoder.readProxy");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":564
 *         return self.context.getObjectForProxy(obj)
 * 
 *     cdef object readConcreteElement(self, char t):             # <<<<<<<<<<<<<<
 *         if t == TYPE_STRING:
 *             return self.readString()
 */

static  PyObject *__pyx_f_6cpyamf_4amf3_7Decoder_readConcreteElement(struct __pyx_obj_6cpyamf_4amf3_Decoder *__pyx_v_self, char __pyx_v_t) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  struct __pyx_opt_args_6cpyamf_4amf3_7Decoder_readInteger __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("readConcreteElement");

  /* "cpyamf/amf3.pyx":565
 * 
 *     cdef object readConcreteElement(self, char t):
 *         if t == TYPE_STRING:             # <<<<<<<<<<<<<<
 *             return self.readString()
 *         elif t == TYPE_OBJECT:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_STRING);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":566
 *     cdef object readConcreteElement(self, char t):
 *         if t == TYPE_STRING:
 *             return self.readString()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_OBJECT:
 *             return self.readObject()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 566; __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/amf3.pyx":567
 *         if t == TYPE_STRING:
 *             return self.readString()
 *         elif t == TYPE_OBJECT:             # <<<<<<<<<<<<<<
 *             return self.readObject()
 *         elif t == TYPE_UNDEFINED:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_OBJECT);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":568
 *             return self.readString()
 *         elif t == TYPE_OBJECT:
 *             return self.readObject()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_UNDEFINED:
 *             return undefined
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 568; __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/amf3.pyx":569
 *         elif t == TYPE_OBJECT:
 *             return self.readObject()
 *         elif t == TYPE_UNDEFINED:             # <<<<<<<<<<<<<<
 *             return undefined
 *         elif t == TYPE_NULL:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_UNDEFINED);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":570
 *             return self.readObject()
 *         elif t == TYPE_UNDEFINED:
 *             return undefined             # <<<<<<<<<<<<<<
 *         elif t == TYPE_NULL:
 *             return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_6cpyamf_4amf3_undefined);
    __pyx_r = __pyx_v_6cpyamf_4amf3_undefined;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "cpyamf/amf3.pyx":571
 *         elif t == TYPE_UNDEFINED:
 *             return undefined
 *         elif t == TYPE_NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         elif t == TYPE_BOOL_FALSE:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_NULL);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":572
 *             return undefined
 *         elif t == TYPE_NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         elif t == TYPE_BOOL_FALSE:
 *             return False
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "cpyamf/amf3.pyx":573
 *         elif t == TYPE_NULL:
 *             return None
 *         elif t == TYPE_BOOL_FALSE:             # <<<<<<<<<<<<<<
 *             return False
 *         elif t == TYPE_BOOL_TRUE:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_BOOL_FALSE);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":574
 *             return None
 *         elif t == TYPE_BOOL_FALSE:
 *             return False             # <<<<<<<<<<<<<<
 *         elif t == TYPE_BOOL_TRUE:
 *             return True
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __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/amf3.pyx":575
 *         elif t == TYPE_BOOL_FALSE:
 *             return False
 *         elif t == TYPE_BOOL_TRUE:             # <<<<<<<<<<<<<<
 *             return True
 *         elif t == TYPE_INTEGER:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_BOOL_TRUE);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":576
 *             return False
 *         elif t == TYPE_BOOL_TRUE:
 *             return True             # <<<<<<<<<<<<<<
 *         elif t == TYPE_INTEGER:
 *             return self.readInteger(1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __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/amf3.pyx":577
 *         elif t == TYPE_BOOL_TRUE:
 *             return True
 *         elif t == TYPE_INTEGER:             # <<<<<<<<<<<<<<
 *             return self.readInteger(1)
 *         elif t == TYPE_NUMBER:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_INTEGER);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":578
 *             return True
 *         elif t == TYPE_INTEGER:
 *             return self.readInteger(1)             # <<<<<<<<<<<<<<
 *         elif t == TYPE_NUMBER:
 *             return self.readNumber()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.__pyx_signed = 1;
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readInteger(__pyx_v_self, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __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/amf3.pyx":579
 *         elif t == TYPE_INTEGER:
 *             return self.readInteger(1)
 *         elif t == TYPE_NUMBER:             # <<<<<<<<<<<<<<
 *             return self.readNumber()
 *         elif t == TYPE_ARRAY:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_NUMBER);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":580
 *             return self.readInteger(1)
 *         elif t == TYPE_NUMBER:
 *             return self.readNumber()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_ARRAY:
 *             return self.readList()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 580; __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/amf3.pyx":581
 *         elif t == TYPE_NUMBER:
 *             return self.readNumber()
 *         elif t == TYPE_ARRAY:             # <<<<<<<<<<<<<<
 *             return self.readList()
 *         elif t == TYPE_DATE:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_ARRAY);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":582
 *             return self.readNumber()
 *         elif t == TYPE_ARRAY:
 *             return self.readList()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_DATE:
 *             return self.readDate()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 582; __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/amf3.pyx":583
 *         elif t == TYPE_ARRAY:
 *             return self.readList()
 *         elif t == TYPE_DATE:             # <<<<<<<<<<<<<<
 *             return self.readDate()
 *         elif t == TYPE_BYTEARRAY:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_DATE);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":584
 *             return self.readList()
 *         elif t == TYPE_DATE:
 *             return self.readDate()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_BYTEARRAY:
 *             return self.readByteArray()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 584; __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/amf3.pyx":585
 *         elif t == TYPE_DATE:
 *             return self.readDate()
 *         elif t == TYPE_BYTEARRAY:             # <<<<<<<<<<<<<<
 *             return self.readByteArray()
 *         elif t == TYPE_XML:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_BYTEARRAY);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":586
 *             return self.readDate()
 *         elif t == TYPE_BYTEARRAY:
 *             return self.readByteArray()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_XML:
 *             return self.readXML()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Decoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->readByteArray(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __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/amf3.pyx":587
 *         elif t == TYPE_BYTEARRAY:
 *             return self.readByteArray()
 *         elif t == TYPE_XML:             # <<<<<<<<<<<<<<
 *             return self.readXML()
 *         elif t == TYPE_XMLSTRING:
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_XML);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":588
 *             return self.readByteArray()
 *         elif t == TYPE_XML:
 *             return self.readXML()             # <<<<<<<<<<<<<<
 *         elif t == TYPE_XMLSTRING:
 *             return self.readXML()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 588; __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/amf3.pyx":589
 *         elif t == TYPE_XML:
 *             return self.readXML()
 *         elif t == TYPE_XMLSTRING:             # <<<<<<<<<<<<<<
 *             return self.readXML()
 * 
 */
  __pyx_t_1 = (__pyx_v_t == __pyx_v_6cpyamf_4amf3_TYPE_XMLSTRING);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":590
 *             return self.readXML()
 *         elif t == TYPE_XMLSTRING:
 *             return self.readXML()             # <<<<<<<<<<<<<<
 * 
 *         raise pyamf.DecodeError("Unsupported ActionScript type")
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 590; __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/amf3.pyx":592
 *             return self.readXML()
 * 
 *         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 = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__DecodeError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __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_4);
  __Pyx_AddTraceback("cpyamf.amf3.Decoder.readConcreteElement");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_11use_proxies___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_11use_proxies___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_4amf3_Decoder *)__pyx_v_self)->use_proxies); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __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.amf3.Decoder.use_proxies.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

/* "cpyamf/amf3.pxd":44
 * cdef class Decoder(codec.Decoder):
 *     cdef public bint use_proxies
 *     cdef readonly Context context             # <<<<<<<<<<<<<<
 * 
 *     cdef ClassDefinition _getClassDefinition(self, long ref)
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Decoder_7context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_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_4amf3_Decoder *)__pyx_v_self)->context));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_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/amf3.pyx":600
 *     """
 * 
 *     def __init__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         self.use_proxies = kwargs.pop('use_proxies', amf3.use_proxies_default)
 *         context = kwargs.pop('context', None)
 */

static int __pyx_pf_6cpyamf_4amf3_7Encoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_6cpyamf_4amf3_7Encoder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_v_context;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  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;
  __pyx_v_context = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":601
 * 
 *     def __init__(self, *args, **kwargs):
 *         self.use_proxies = kwargs.pop('use_proxies', amf3.use_proxies_default)             # <<<<<<<<<<<<<<
 *         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 = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__amf3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__use_proxies_default); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __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(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__use_proxies));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__use_proxies));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__use_proxies));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __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 = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->use_proxies = __pyx_t_4;

  /* "cpyamf/amf3.pyx":602
 *     def __init__(self, *args, **kwargs):
 *         self.use_proxies = kwargs.pop('use_proxies', amf3.use_proxies_default)
 *         context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if context is None:
 */
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_kwargs), __pyx_n_s__pop); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __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 = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_context);
  __pyx_v_context = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":604
 *         context = kwargs.pop('context', None)
 * 
 *         if context is None:             # <<<<<<<<<<<<<<
 *             context = Context()
 * 
 */
  __pyx_t_4 = (__pyx_v_context == Py_None);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":605
 * 
 *         if context is None:
 *             context = Context()             # <<<<<<<<<<<<<<
 * 
 *         self.context = context
 */
    __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 = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_context);
    __pyx_v_context = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":607
 *             context = Context()
 * 
 *         self.context = context             # <<<<<<<<<<<<<<
 * 
 *         codec.Encoder.__init__(self, *args, **kwargs)
 */
  if (!(likely(((__pyx_v_context) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_context, __pyx_ptype_6cpyamf_4amf3_Context))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_context);
  __Pyx_GIVEREF(__pyx_v_context);
  __Pyx_GOTREF(((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->context));
  ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)__pyx_v_context);

  /* "cpyamf/amf3.pyx":609
 *         self.context = context
 * 
 *         codec.Encoder.__init__(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int writeNull(self, n) except -1:
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_5codec_Encoder)), __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __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_5);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_DECREF(__pyx_v_context);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":611
 *         codec.Encoder.__init__(self, *args, **kwargs)
 * 
 *     cdef inline int writeNull(self, n) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Writes a C{null} value to the stream.
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3_7Encoder_writeNull(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeNull");

  /* "cpyamf/amf3.pyx":615
 *         Writes a C{null} value to the stream.
 *         """
 *         return self.writeType(TYPE_NULL)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int writeUndefined(self, n) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_NULL); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __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.amf3.Encoder.writeNull");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":617
 *         return self.writeType(TYPE_NULL)
 * 
 *     cdef inline int writeUndefined(self, n) except -1:             # <<<<<<<<<<<<<<
 *         return self.writeType(TYPE_UNDEFINED)
 * 
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3_7Encoder_writeUndefined(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeUndefined");

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

/* "cpyamf/amf3.pyx":620
 *         return self.writeType(TYPE_UNDEFINED)
 * 
 *     cdef inline int writeBoolean(self, n) except -1:             # <<<<<<<<<<<<<<
 *         if n is True:
 *             return self.writeType(TYPE_BOOL_TRUE)
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3_7Encoder_writeBoolean(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("writeBoolean");

  /* "cpyamf/amf3.pyx":621
 * 
 *     cdef inline int writeBoolean(self, n) except -1:
 *         if n is True:             # <<<<<<<<<<<<<<
 *             return self.writeType(TYPE_BOOL_TRUE)
 * 
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_v_n == __pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cpyamf/amf3.pyx":622
 *     cdef inline int writeBoolean(self, n) except -1:
 *         if n is True:
 *             return self.writeType(TYPE_BOOL_TRUE)             # <<<<<<<<<<<<<<
 * 
 *         return self.writeType(TYPE_BOOL_FALSE)
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_BOOL_TRUE); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":624
 *             return self.writeType(TYPE_BOOL_TRUE)
 * 
 *         return self.writeType(TYPE_BOOL_FALSE)             # <<<<<<<<<<<<<<
 * 
 *     cpdef int serialiseString(self, u) except -1:
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_BOOL_FALSE); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":626
 *         return self.writeType(TYPE_BOOL_FALSE)
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Serialises a unicode object.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static  int __pyx_f_6cpyamf_4amf3_7Encoder_serialiseString(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_u, int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_l;
  int __pyx_v_is_unicode;
  PyObject *__pyx_v_r;
  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;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("serialiseString");
  __Pyx_INCREF(__pyx_v_u);
  __pyx_v_r = 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__serialiseString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __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_4amf3_7Encoder_1serialiseString)) {
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __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 = 626; __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 = 626; __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/amf3.pyx":631
 *         """
 *         cdef Py_ssize_t l
 *         cdef bint is_unicode = 0             # <<<<<<<<<<<<<<
 * 
 *         if PyUnicode_Check(u):
 */
  __pyx_v_is_unicode = 0;

  /* "cpyamf/amf3.pyx":633
 *         cdef bint is_unicode = 0
 * 
 *         if PyUnicode_Check(u):             # <<<<<<<<<<<<<<
 *             l = PyUnicode_GET_SIZE(u)
 *             is_unicode = 1
 */
  __pyx_t_5 = PyUnicode_Check(__pyx_v_u);
  if (__pyx_t_5) {

    /* "cpyamf/amf3.pyx":634
 * 
 *         if PyUnicode_Check(u):
 *             l = PyUnicode_GET_SIZE(u)             # <<<<<<<<<<<<<<
 *             is_unicode = 1
 *         elif PyString_Check(u):
 */
    __pyx_v_l = PyUnicode_GET_SIZE(__pyx_v_u);

    /* "cpyamf/amf3.pyx":635
 *         if PyUnicode_Check(u):
 *             l = PyUnicode_GET_SIZE(u)
 *             is_unicode = 1             # <<<<<<<<<<<<<<
 *         elif PyString_Check(u):
 *             l = PyString_GET_SIZE(u)
 */
    __pyx_v_is_unicode = 1;
    goto __pyx_L3;
  }

  /* "cpyamf/amf3.pyx":636
 *             l = PyUnicode_GET_SIZE(u)
 *             is_unicode = 1
 *         elif PyString_Check(u):             # <<<<<<<<<<<<<<
 *             l = PyString_GET_SIZE(u)
 *         else:
 */
  __pyx_t_5 = PyString_Check(__pyx_v_u);
  if (__pyx_t_5) {

    /* "cpyamf/amf3.pyx":637
 *             is_unicode = 1
 *         elif PyString_Check(u):
 *             l = PyString_GET_SIZE(u)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('Expected str or unicode')
 */
    __pyx_v_l = PyString_GET_SIZE(__pyx_v_u);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":639
 *             l = PyString_GET_SIZE(u)
 *         else:
 *             raise TypeError('Expected str or unicode')             # <<<<<<<<<<<<<<
 * 
 *         if l == 0:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":641
 *             raise TypeError('Expected str or unicode')
 * 
 *         if l == 0:             # <<<<<<<<<<<<<<
 *             # '' is a special case
 *             return self.stream.write(&REF_CHAR, 1)
 */
  __pyx_t_5 = (__pyx_v_l == 0);
  if (__pyx_t_5) {

    /* "cpyamf/amf3.pyx":643
 *         if l == 0:
 *             # '' is a special case
 *             return self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 * 
 *         r = self.context.getStringReference(u)
 */
    __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, (&__pyx_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":645
 *             return self.stream.write(&REF_CHAR, 1)
 * 
 *         r = self.context.getStringReference(u)             # <<<<<<<<<<<<<<
 * 
 *         if r != -1:
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getStringReference(__pyx_v_self->context, __pyx_v_u, 0); if (unlikely(__pyx_t_6 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_r);
  __pyx_v_r = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":647
 *         r = self.context.getStringReference(u)
 * 
 *         if r != -1:             # <<<<<<<<<<<<<<
 *             # we have a reference
 *             return _encode_integer(self.stream, r << 1)
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_r, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __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 = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cpyamf/amf3.pyx":649
 *         if r != -1:
 *             # we have a reference
 *             return _encode_integer(self.stream, r << 1)             # <<<<<<<<<<<<<<
 * 
 *         self.context.addString(u)
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_Lshift(__pyx_v_r, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __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 = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":651
 *             return _encode_integer(self.stream, r << 1)
 * 
 *         self.context.addString(u)             # <<<<<<<<<<<<<<
 * 
 *         if is_unicode:
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->addString(__pyx_v_self->context, __pyx_v_u, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":653
 *         self.context.addString(u)
 * 
 *         if is_unicode:             # <<<<<<<<<<<<<<
 *             u = self.context.getBytesForString(u)
 *             l = PyString_GET_SIZE(u)
 */
  if (__pyx_v_is_unicode) {

    /* "cpyamf/amf3.pyx":654
 * 
 *         if is_unicode:
 *             u = self.context.getBytesForString(u)             # <<<<<<<<<<<<<<
 *             l = PyString_GET_SIZE(u)
 * 
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 654; __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/amf3.pyx":655
 *         if is_unicode:
 *             u = self.context.getBytesForString(u)
 *             l = PyString_GET_SIZE(u)             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)
 */
    __pyx_v_l = PyString_GET_SIZE(__pyx_v_u);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/amf3.pyx":657
 *             l = PyString_GET_SIZE(u)
 * 
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write(PyString_AS_STRING(u), l)
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), ((__pyx_v_l << 1) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":659
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)
 * 
 *         return self.stream.write(PyString_AS_STRING(u), l)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeString(self, object s) except -1:
 */
  __pyx_t_7 = ((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_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_7;
  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.amf3.Encoder.serialiseString");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_r);
  __Pyx_DECREF(__pyx_v_u);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":626
 *         return self.writeType(TYPE_BOOL_FALSE)
 * 
 *     cpdef int serialiseString(self, u) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Serialises a unicode object.
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u); /*proto*/
static char __pyx_doc_6cpyamf_4amf3_7Encoder_1serialiseString[] = "\n        Serialises a unicode object.\n        ";
static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_1serialiseString(PyObject *__pyx_v_self, PyObject *__pyx_v_u) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("serialiseString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)((struct __pyx_obj_6cpyamf_4amf3_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 = 626; __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 = 626; __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.amf3.Encoder.serialiseString");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":661
 *         return self.stream.write(PyString_AS_STRING(u), l)
 * 
 *     cdef int writeString(self, object s) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_STRING)
 *         self.serialiseString(s)
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeString(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_s) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeString");

  /* "cpyamf/amf3.pyx":662
 * 
 *     cdef int writeString(self, object s) except -1:
 *         self.writeType(TYPE_STRING)             # <<<<<<<<<<<<<<
 *         self.serialiseString(s)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_STRING); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":663
 *     cdef int writeString(self, object s) except -1:
 *         self.writeType(TYPE_STRING)
 *         self.serialiseString(s)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeBytes(self, object s) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_s, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

/* "cpyamf/amf3.pyx":665
 *         self.serialiseString(s)
 * 
 *     cdef int writeBytes(self, object s) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_STRING)
 *         self.serialiseString(s)
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeBytes(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_s) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("writeBytes");

  /* "cpyamf/amf3.pyx":666
 * 
 *     cdef int writeBytes(self, object s) except -1:
 *         self.writeType(TYPE_STRING)             # <<<<<<<<<<<<<<
 *         self.serialiseString(s)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_STRING); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":667
 *     cdef int writeBytes(self, object s) except -1:
 *         self.writeType(TYPE_STRING)
 *         self.serialiseString(s)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeInt(self, object n) except -1:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_s, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

/* "cpyamf/amf3.pyx":669
 *         self.serialiseString(s)
 * 
 *     cdef int writeInt(self, object n) except -1:             # <<<<<<<<<<<<<<
 *         cdef long x = PyInt_AS_LONG(n)
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeInt(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  long __pyx_v_x;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  double __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("writeInt");

  /* "cpyamf/amf3.pyx":670
 * 
 *     cdef int writeInt(self, object n) except -1:
 *         cdef long x = PyInt_AS_LONG(n)             # <<<<<<<<<<<<<<
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:
 */
  __pyx_v_x = PyInt_AS_LONG(__pyx_v_n);

  /* "cpyamf/amf3.pyx":672
 *         cdef long x = PyInt_AS_LONG(n)
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:             # <<<<<<<<<<<<<<
 *             return self.writeNumber(float(n))
 * 
 */
  __pyx_t_1 = (__pyx_v_x < __pyx_v_6cpyamf_4amf3_MIN_29B_INT);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_x > __pyx_v_6cpyamf_4amf3_MAX_29B_INT);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":673
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:
 *             return self.writeNumber(float(n))             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_INTEGER)
 */
    __pyx_t_4 = __Pyx_PyObject_AsDouble(__pyx_v_n); if (unlikely(__pyx_t_4 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyFloat_FromDouble(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeNumber(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":675
 *             return self.writeNumber(float(n))
 * 
 *         self.writeType(TYPE_INTEGER)             # <<<<<<<<<<<<<<
 *         _encode_integer(self.stream, x)
 * 
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_INTEGER); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":676
 * 
 *         self.writeType(TYPE_INTEGER)
 *         _encode_integer(self.stream, x)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeLong(self, object n) except -1:
 */
  __pyx_t_5 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_5), __pyx_v_x); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

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

/* "cpyamf/amf3.pyx":678
 *         _encode_integer(self.stream, x)
 * 
 *     cdef int writeLong(self, object n) except -1:             # <<<<<<<<<<<<<<
 *         cdef long x
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeLong(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  long __pyx_v_x;
  int __pyx_r;
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("writeLong");

  /* "cpyamf/amf3.pyx":681
 *         cdef long x
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             x = PyLong_AsLong(n)
 *         except:
 */
  {
    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/amf3.pyx":682
 * 
 *         try:
 *             x = PyLong_AsLong(n)             # <<<<<<<<<<<<<<
 *         except:
 *             return self.writeNumber(float(n))
 */
      __pyx_t_1 = PyLong_AsLong(__pyx_v_n); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_x = __pyx_t_1;
    }
    __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:;

    /* "cpyamf/amf3.pyx":683
 *         try:
 *             x = PyLong_AsLong(n)
 *         except:             # <<<<<<<<<<<<<<
 *             return self.writeNumber(float(n))
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeLong");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpyamf/amf3.pyx":684
 *             x = PyLong_AsLong(n)
 *         except:
 *             return self.writeNumber(float(n))             # <<<<<<<<<<<<<<
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:
 */
      __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_n); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __pyx_t_6 = PyFloat_FromDouble(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeNumber(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  /* "cpyamf/amf3.pyx":686
 *             return self.writeNumber(float(n))
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:             # <<<<<<<<<<<<<<
 *             return self.writeNumber(float(n))
 * 
 */
  __pyx_t_8 = (__pyx_v_x < __pyx_v_6cpyamf_4amf3_MIN_29B_INT);
  if (!__pyx_t_8) {
    __pyx_t_9 = (__pyx_v_x > __pyx_v_6cpyamf_4amf3_MAX_29B_INT);
    __pyx_t_10 = __pyx_t_9;
  } else {
    __pyx_t_10 = __pyx_t_8;
  }
  if (__pyx_t_10) {

    /* "cpyamf/amf3.pyx":687
 * 
 *         if x < MIN_29B_INT or x > MAX_29B_INT:
 *             return self.writeNumber(float(n))             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_INTEGER)
 */
    __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_n); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyFloat_FromDouble(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeNumber(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "cpyamf/amf3.pyx":689
 *             return self.writeNumber(float(n))
 * 
 *         self.writeType(TYPE_INTEGER)             # <<<<<<<<<<<<<<
 *         _encode_integer(self.stream, x)
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_INTEGER); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":690
 * 
 *         self.writeType(TYPE_INTEGER)
 *         _encode_integer(self.stream, x)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeNumber(self, object n) except -1:
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_4), __pyx_v_x); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeLong");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":692
 *         _encode_integer(self.stream, x)
 * 
 *     cdef int writeNumber(self, object n) except -1:             # <<<<<<<<<<<<<<
 *         cdef double x = PyFloat_AS_DOUBLE(n)
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeNumber(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  double __pyx_v_x;
  int __pyx_r;
  double __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("writeNumber");

  /* "cpyamf/amf3.pyx":693
 * 
 *     cdef int writeNumber(self, object n) except -1:
 *         cdef double x = PyFloat_AS_DOUBLE(n)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_NUMBER)
 */
  __pyx_t_1 = PyFloat_AS_DOUBLE(__pyx_v_n); if (unlikely(__pyx_t_1 == -1.0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_x = __pyx_t_1;

  /* "cpyamf/amf3.pyx":695
 *         cdef double x = PyFloat_AS_DOUBLE(n)
 * 
 *         self.writeType(TYPE_NUMBER)             # <<<<<<<<<<<<<<
 *         self.stream.write_double(x)
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_NUMBER); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":696
 * 
 *         self.writeType(TYPE_NUMBER)
 *         self.stream.write_double(x)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_2 = ((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_v_x, 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":698
 *         self.stream.write_double(x)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeList(self, object n, bint is_proxy=0) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":700
 *         return 0
 * 
 *     cpdef int writeList(self, object n, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)
 *         cdef Py_ssize_t i
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeList(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4amf3_7Encoder_writeList *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  Py_ssize_t __pyx_v_ref;
  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;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __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 = 700; __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_4amf3_7Encoder_2writeList)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __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 = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_n);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_n);
      __Pyx_GIVEREF(__pyx_v_n);
      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 = 700; __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 = 700; __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/amf3.pyx":701
 * 
 *     cpdef int writeList(self, object n, bint is_proxy=0) except -1:
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef PyObject *x
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_5 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ref = __pyx_t_5;

  /* "cpyamf/amf3.pyx":705
 *         cdef PyObject *x
 * 
 *         if self.use_proxies == 1 and not is_proxy:             # <<<<<<<<<<<<<<
 *             # Encode lists as ArrayCollections
 *             return self.writeProxy(n)
 */
  __pyx_t_6 = (__pyx_v_self->use_proxies == 1);
  if (__pyx_t_6) {
    __pyx_t_7 = (!__pyx_v_is_proxy);
    __pyx_t_8 = __pyx_t_7;
  } else {
    __pyx_t_8 = __pyx_t_6;
  }
  if (__pyx_t_8) {

    /* "cpyamf/amf3.pyx":707
 *         if self.use_proxies == 1 and not is_proxy:
 *             # Encode lists as ArrayCollections
 *             return self.writeProxy(n)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_ARRAY)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeProxy(__pyx_v_self, __pyx_v_n); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":709
 *             return self.writeProxy(n)
 * 
 *         self.writeType(TYPE_ARRAY)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_ARRAY); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":711
 *         self.writeType(TYPE_ARRAY)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             return _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_8 = (__pyx_v_ref != -1);
  if (__pyx_t_8) {

    /* "cpyamf/amf3.pyx":712
 * 
 *         if ref != -1:
 *             return _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(n)
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), (__pyx_v_ref << 1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":714
 *             return _encode_integer(self.stream, ref << 1)
 * 
 *         self.context.addObject(n)             # <<<<<<<<<<<<<<
 *         ref = PyList_GET_SIZE(n)
 * 
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":715
 * 
 *         self.context.addObject(n)
 *         ref = PyList_GET_SIZE(n)             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)
 */
  __pyx_v_ref = PyList_GET_SIZE(__pyx_v_n);

  /* "cpyamf/amf3.pyx":717
 *         ref = PyList_GET_SIZE(n)
 * 
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType('\x01')
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), ((__pyx_v_ref << 1) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":719
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)
 * 
 *         self.writeType('\x01')             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < ref:
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":721
 *         self.writeType('\x01')
 * 
 *         for i from 0 <= i < ref:             # <<<<<<<<<<<<<<
 *             x = PyList_GET_ITEM(n, i)
 * 
 */
  __pyx_t_5 = __pyx_v_ref;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {

    /* "cpyamf/amf3.pyx":722
 * 
 *         for i from 0 <= i < ref:
 *             x = PyList_GET_ITEM(n, i)             # <<<<<<<<<<<<<<
 * 
 *             self.writeElement(<object>x)
 */
    __pyx_v_x = PyList_GET_ITEM(__pyx_v_n, __pyx_v_i);

    /* "cpyamf/amf3.pyx":724
 *             x = PyList_GET_ITEM(n, i)
 * 
 *             self.writeElement(<object>x)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/amf3.pyx":726
 *             self.writeElement(<object>x)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeTuple(self, object n) 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.amf3.Encoder.writeList");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":700
 *         return 0
 * 
 *     cpdef int writeList(self, object n, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)
 *         cdef Py_ssize_t i
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_2writeList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n = 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__n,&__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__n);
      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 = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_n = 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 = 700; __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 = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_n = 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 = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.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_4amf3_Encoder *)((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.writeList(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_n, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __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 = 700; __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.amf3.Encoder.writeList");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":728
 *         return 0
 * 
 *     cdef int writeTuple(self, object n) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)
 *         cdef Py_ssize_t i
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeTuple(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  Py_ssize_t __pyx_v_ref;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_x;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("writeTuple");

  /* "cpyamf/amf3.pyx":729
 * 
 *     cdef int writeTuple(self, object n) except -1:
 *         cdef Py_ssize_t ref = self.context.getObjectReference(n)             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t i
 *         cdef PyObject *x
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ref = __pyx_t_1;

  /* "cpyamf/amf3.pyx":733
 *         cdef PyObject *x
 * 
 *         self.writeType(TYPE_ARRAY)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_ARRAY); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":735
 *         self.writeType(TYPE_ARRAY)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             return _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_3 = (__pyx_v_ref != -1);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":736
 * 
 *         if ref != -1:
 *             return _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(n)
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_2 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_4), (__pyx_v_ref << 1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":738
 *             return _encode_integer(self.stream, ref << 1)
 * 
 *         self.context.addObject(n)             # <<<<<<<<<<<<<<
 * 
 *         ref = PyTuple_GET_SIZE(n)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":740
 *         self.context.addObject(n)
 * 
 *         ref = PyTuple_GET_SIZE(n)             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)
 */
  __pyx_v_ref = PyTuple_GET_SIZE(__pyx_v_n);

  /* "cpyamf/amf3.pyx":742
 *         ref = PyTuple_GET_SIZE(n)
 * 
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 *         self.writeType('\x01')
 * 
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_4), ((__pyx_v_ref << 1) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cpyamf/amf3.pyx":743
 * 
 *         _encode_integer(self.stream, (ref << 1) | REFERENCE_BIT)
 *         self.writeType('\x01')             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < ref:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":745
 *         self.writeType('\x01')
 * 
 *         for i from 0 <= i < ref:             # <<<<<<<<<<<<<<
 *             x = PyTuple_GET_ITEM(n, i)
 * 
 */
  __pyx_t_1 = __pyx_v_ref;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "cpyamf/amf3.pyx":746
 * 
 *         for i from 0 <= i < ref:
 *             x = PyTuple_GET_ITEM(n, i)             # <<<<<<<<<<<<<<
 * 
 *             self.writeElement(<object>x)
 */
    __pyx_v_x = PyTuple_GET_ITEM(__pyx_v_n, __pyx_v_i);

    /* "cpyamf/amf3.pyx":748
 *             x = PyTuple_GET_ITEM(n, i)
 * 
 *             self.writeElement(<object>x)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cpyamf/amf3.pyx":750
 *             self.writeElement(<object>x)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDict(self, dict obj) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

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

/* "cpyamf/amf3.pyx":752
 *         return 0
 * 
 *     cdef int writeDict(self, dict obj) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t idx = 0
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeDict(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  Py_ssize_t __pyx_v_idx;
  PyObject *__pyx_v_ref;
  int __pyx_v_class_ref;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_definition = 0;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  void *__pyx_t_8;
  void *__pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("writeDict");
  __pyx_v_ref = 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/amf3.pyx":753
 * 
 *     cdef int writeDict(self, dict obj) except -1:
 *         cdef Py_ssize_t idx = 0             # <<<<<<<<<<<<<<
 * 
 *         if self.use_proxies:
 */
  __pyx_v_idx = 0;

  /* "cpyamf/amf3.pyx":755
 *         cdef Py_ssize_t idx = 0
 * 
 *         if self.use_proxies:             # <<<<<<<<<<<<<<
 *             return self.writeProxy(obj)
 * 
 */
  if (__pyx_v_self->use_proxies) {

    /* "cpyamf/amf3.pyx":756
 * 
 *         if self.use_proxies:
 *             return self.writeProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_OBJECT)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeProxy(__pyx_v_self, ((PyObject *)__pyx_v_obj)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":758
 *             return self.writeProxy(obj)
 * 
 *         self.writeType(TYPE_OBJECT)             # <<<<<<<<<<<<<<
 * 
 *         ref = self.context.getObjectReference(obj)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_OBJECT); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":760
 *         self.writeType(TYPE_OBJECT)
 * 
 *         ref = self.context.getObjectReference(obj)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), ((PyObject *)__pyx_v_obj), 0); if (unlikely(__pyx_t_2 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_ref);
  __pyx_v_ref = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":762
 *         ref = self.context.getObjectReference(obj)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_ref, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":763
 * 
 *         if ref != -1:
 *             _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Lshift(__pyx_v_ref, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_3), __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpyamf/amf3.pyx":765
 *             _encode_integer(self.stream, ref << 1)
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":767
 *             return 0
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         cdef bint class_ref = 0
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":769
 *         self.context.addObject(obj)
 * 
 *         cdef bint class_ref = 0             # <<<<<<<<<<<<<<
 *         cdef ClassDefinition definition = self.context.getClass(dict)
 * 
 */
  __pyx_v_class_ref = 0;

  /* "cpyamf/amf3.pyx":770
 * 
 *         cdef bint class_ref = 0
 *         cdef ClassDefinition definition = self.context.getClass(dict)             # <<<<<<<<<<<<<<
 * 
 *         if not definition:
 */
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getClass(__pyx_v_self->context, ((PyObject *)((PyObject*)(&PyDict_Type))), 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_definition = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":772
 *         cdef ClassDefinition definition = self.context.getClass(dict)
 * 
 *         if not definition:             # <<<<<<<<<<<<<<
 *             definition = ClassDefinition(self.context.getClassAlias(dict))
 *             self.context.addClass(definition, dict)
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_definition)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = (!__pyx_t_4);
  if (__pyx_t_7) {

    /* "cpyamf/amf3.pyx":773
 * 
 *         if not definition:
 *             definition = ClassDefinition(self.context.getClassAlias(dict))             # <<<<<<<<<<<<<<
 *             self.context.addClass(definition, dict)
 *         else:
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), ((PyObject *)((PyObject*)(&PyDict_Type))), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __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 = 773; __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(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_ClassDefinition)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_definition));
    __pyx_v_definition = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cpyamf/amf3.pyx":774
 *         if not definition:
 *             definition = ClassDefinition(self.context.getClassAlias(dict))
 *             self.context.addClass(definition, dict)             # <<<<<<<<<<<<<<
 *         else:
 *             class_ref = 1
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->addClass(__pyx_v_self->context, __pyx_v_definition, ((PyObject *)((PyObject*)(&PyDict_Type))), 0); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":776
 *             self.context.addClass(definition, dict)
 *         else:
 *             class_ref = 1             # <<<<<<<<<<<<<<
 * 
 *         definition.writeReference(self.stream)
 */
    __pyx_v_class_ref = 1;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":778
 *             class_ref = 1
 * 
 *         definition.writeReference(self.stream)             # <<<<<<<<<<<<<<
 * 
 *         if class_ref == 0:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_3);
  ((struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition *)__pyx_v_definition->__pyx_vtab)->writeReference(__pyx_v_definition, ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_3));
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":780
 *         definition.writeReference(self.stream)
 * 
 *         if class_ref == 0:             # <<<<<<<<<<<<<<
 *             self.stream.write(&REF_CHAR, 1)
 * 
 */
  __pyx_t_7 = (__pyx_v_class_ref == 0);
  if (__pyx_t_7) {

    /* "cpyamf/amf3.pyx":781
 * 
 *         if class_ref == 0:
 *             self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 * 
 *         for key, value in obj.iteritems():
 */
    __pyx_t_6 = ((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_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/amf3.pyx":783
 *             self.stream.write(&REF_CHAR, 1)
 * 
 *         for key, value in obj.iteritems():             # <<<<<<<<<<<<<<
 *             if PyInt_Check(key) or PyLong_Check(key):
 *                 key = str(key)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = ((PyObject *)__pyx_v_obj);
  __pyx_t_2 = 0;
  while (1) {
    if (!PyDict_Next(__pyx_t_3, (&__pyx_t_2), ((PyObject **)(&__pyx_t_8)), ((PyObject **)(&__pyx_t_9)))) break;
    __Pyx_INCREF(((PyObject *)__pyx_t_8));
    __Pyx_DECREF(__pyx_v_key);
    __pyx_v_key = ((PyObject *)__pyx_t_8);
    __Pyx_INCREF(((PyObject *)__pyx_t_9));
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = ((PyObject *)__pyx_t_9);

    /* "cpyamf/amf3.pyx":784
 * 
 *         for key, value in obj.iteritems():
 *             if PyInt_Check(key) or PyLong_Check(key):             # <<<<<<<<<<<<<<
 *                 key = str(key)
 * 
 */
    __pyx_t_7 = PyInt_Check(__pyx_v_key);
    if (!__pyx_t_7) {
      __pyx_t_4 = PyLong_Check(__pyx_v_key);
      __pyx_t_10 = __pyx_t_4;
    } else {
      __pyx_t_10 = __pyx_t_7;
    }
    if (__pyx_t_10) {

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

    /* "cpyamf/amf3.pyx":787
 *                 key = str(key)
 * 
 *             self.serialiseString(key)             # <<<<<<<<<<<<<<
 *             self.writeElement(value)
 * 
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf3.pyx":788
 * 
 *             self.serialiseString(key)
 *             self.writeElement(value)             # <<<<<<<<<<<<<<
 * 
 *         return self.stream.write(&REF_CHAR, 1)
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":790
 *             self.writeElement(value)
 * 
 *         return self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeMixedArray(self, object n) except -1:
 */
  __pyx_t_6 = ((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_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeDict");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_ref);
  __Pyx_XDECREF((PyObject *)__pyx_v_definition);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":792
 *         return self.stream.write(&REF_CHAR, 1)
 * 
 *     cdef int writeMixedArray(self, object n) except -1:             # <<<<<<<<<<<<<<
 *         # Design bug in AMF3 that cannot read/write empty key strings
 *         # http://www.docuverse.com/blog/donpark/2007/05/14/flash-9-amf3-bug
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeMixedArray(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_n) {
  PyObject *__pyx_v_ref;
  PyObject *__pyx_v_keys;
  PyObject *__pyx_v_int_keys;
  PyObject *__pyx_v_str_keys;
  PyObject *__pyx_v_x;
  Py_ssize_t __pyx_v_l;
  PyObject *__pyx_v_k;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("writeMixedArray");
  __pyx_v_ref = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_keys = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_int_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_str_keys = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":796
 *         # http://www.docuverse.com/blog/donpark/2007/05/14/flash-9-amf3-bug
 *         # for more info
 *         if '' in n:             # <<<<<<<<<<<<<<
 *             raise pyamf.EncodeError("dicts cannot contain empty string keys")
 * 
 */
  __pyx_t_1 = ((PySequence_Contains(__pyx_v_n, ((PyObject *)__pyx_kp_s_13)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":797
 *         # for more info
 *         if '' in n:
 *             raise pyamf.EncodeError("dicts cannot contain empty string keys")             # <<<<<<<<<<<<<<
 * 
 *         if self.use_proxies:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__EncodeError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __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 = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":799
 *             raise pyamf.EncodeError("dicts cannot contain empty string keys")
 * 
 *         if self.use_proxies:             # <<<<<<<<<<<<<<
 *             return self.writeProxy(n)
 * 
 */
  if (__pyx_v_self->use_proxies) {

    /* "cpyamf/amf3.pyx":800
 * 
 *         if self.use_proxies:
 *             return self.writeProxy(n)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_ARRAY)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeProxy(__pyx_v_self, __pyx_v_n); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":802
 *             return self.writeProxy(n)
 * 
 *         self.writeType(TYPE_ARRAY)             # <<<<<<<<<<<<<<
 * 
 *         ref = self.context.getObjectReference(n)
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_ARRAY); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":804
 *         self.writeType(TYPE_ARRAY)
 * 
 *         ref = self.context.getObjectReference(n)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_5 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_ref);
  __pyx_v_ref = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":806
 *         ref = self.context.getObjectReference(n)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             return _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_ref, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":807
 * 
 *         if ref != -1:
 *             return _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(n)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Lshift(__pyx_v_ref, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __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 = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_2), __pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":809
 *             return _encode_integer(self.stream, ref << 1)
 * 
 *         self.context.addObject(n)             # <<<<<<<<<<<<<<
 * 
 *         # The AMF3 spec demands that all str based indicies be listed first
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.addObject(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_n, 0); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":812
 * 
 *         # The AMF3 spec demands that all str based indicies be listed first
 *         keys = n.keys()             # <<<<<<<<<<<<<<
 *         int_keys = []
 *         str_keys = []
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_n, __pyx_n_s__keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_keys);
  __pyx_v_keys = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":813
 *         # The AMF3 spec demands that all str based indicies be listed first
 *         keys = n.keys()
 *         int_keys = []             # <<<<<<<<<<<<<<
 *         str_keys = []
 * 
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_v_int_keys));
  __pyx_v_int_keys = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":814
 *         keys = n.keys()
 *         int_keys = []
 *         str_keys = []             # <<<<<<<<<<<<<<
 * 
 *         for x in keys:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_v_str_keys));
  __pyx_v_str_keys = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":816
 *         str_keys = []
 * 
 *         for x in keys:             # <<<<<<<<<<<<<<
 *             if isinstance(x, (int, long)):
 *                 int_keys.append(x)
 */
  if (PyList_CheckExact(__pyx_v_keys) || PyTuple_CheckExact(__pyx_v_keys)) {
    __pyx_t_5 = 0; __pyx_t_3 = __pyx_v_keys; __Pyx_INCREF(__pyx_t_3);
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_3))) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
    } else {
      __pyx_t_2 = PyIter_Next(__pyx_t_3);
      if (!__pyx_t_2) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cpyamf/amf3.pyx":817
 * 
 *         for x in keys:
 *             if isinstance(x, (int, long)):             # <<<<<<<<<<<<<<
 *                 int_keys.append(x)
 *             elif isinstance(x, (str, unicode)):
 */
    __Pyx_INCREF(__pyx_v_x);
    __pyx_t_2 = __pyx_v_x;
    __pyx_t_1 = PyInt_Check(__pyx_t_2); 
    if (!__pyx_t_1) {
      __pyx_t_7 = PyLong_Check(__pyx_t_2); 
      __pyx_t_8 = __pyx_t_7;
    } else {
      __pyx_t_8 = __pyx_t_1;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_8) {

      /* "cpyamf/amf3.pyx":818
 *         for x in keys:
 *             if isinstance(x, (int, long)):
 *                 int_keys.append(x)             # <<<<<<<<<<<<<<
 *             elif isinstance(x, (str, unicode)):
 *                 str_keys.append(x)
 */
      if (unlikely(__pyx_v_int_keys == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_6 = PyList_Append(__pyx_v_int_keys, __pyx_v_x); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }

    /* "cpyamf/amf3.pyx":819
 *             if isinstance(x, (int, long)):
 *                 int_keys.append(x)
 *             elif isinstance(x, (str, unicode)):             # <<<<<<<<<<<<<<
 *                 str_keys.append(x)
 *             else:
 */
    __Pyx_INCREF(__pyx_v_x);
    __pyx_t_2 = __pyx_v_x;
    __pyx_t_8 = PyString_Check(__pyx_t_2); 
    if (!__pyx_t_8) {
      __pyx_t_1 = PyUnicode_Check(__pyx_t_2); 
      __pyx_t_7 = __pyx_t_1;
    } else {
      __pyx_t_7 = __pyx_t_8;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {

      /* "cpyamf/amf3.pyx":820
 *                 int_keys.append(x)
 *             elif isinstance(x, (str, unicode)):
 *                 str_keys.append(x)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Non int/str key value found in dict")
 */
      if (unlikely(__pyx_v_str_keys == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_6 = PyList_Append(__pyx_v_str_keys, __pyx_v_x); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    /*else*/ {

      /* "cpyamf/amf3.pyx":822
 *                 str_keys.append(x)
 *             else:
 *                 raise ValueError("Non int/str key value found in dict")             # <<<<<<<<<<<<<<
 * 
 *         # Make sure the integer keys are within range
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __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 = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L8:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":825
 * 
 *         # Make sure the integer keys are within range
 *         l = len(int_keys)             # <<<<<<<<<<<<<<
 * 
 *         for x in int_keys:
 */
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_int_keys)); 
  __pyx_v_l = __pyx_t_5;

  /* "cpyamf/amf3.pyx":827
 *         l = len(int_keys)
 * 
 *         for x in int_keys:             # <<<<<<<<<<<<<<
 *             if l < x <= 0:
 *                 # treat as a string key
 */
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = 0; __pyx_t_3 = ((PyObject *)__pyx_v_int_keys); __Pyx_INCREF(__pyx_t_3);
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++;
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cpyamf/amf3.pyx":828
 * 
 *         for x in int_keys:
 *             if l < x <= 0:             # <<<<<<<<<<<<<<
 *                 # treat as a string key
 *                 str_keys.append(x)
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_l); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_v_x, Py_LT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__Pyx_PyObject_IsTrue(__pyx_t_9)) {
      __Pyx_DECREF(__pyx_t_9);
      __pyx_t_9 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_LE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_7) {

      /* "cpyamf/amf3.pyx":830
 *             if l < x <= 0:
 *                 # treat as a string key
 *                 str_keys.append(x)             # <<<<<<<<<<<<<<
 *                 del int_keys[int_keys.index(x)]
 * 
 */
      if (unlikely(__pyx_v_str_keys == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_6 = PyList_Append(__pyx_v_str_keys, __pyx_v_x); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cpyamf/amf3.pyx":831
 *                 # treat as a string key
 *                 str_keys.append(x)
 *                 del int_keys[int_keys.index(x)]             # <<<<<<<<<<<<<<
 * 
 *         int_keys.sort()
 */
      __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_int_keys), __pyx_n_s__index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (PyObject_DelItem(((PyObject *)__pyx_v_int_keys), __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L11;
    }
    __pyx_L11:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":833
 *                 del int_keys[int_keys.index(x)]
 * 
 *         int_keys.sort()             # <<<<<<<<<<<<<<
 * 
 *         # If integer keys don't start at 0, they will be treated as strings
 */
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'sort'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_6 = PyList_Sort(((PyObject *)__pyx_v_int_keys)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":836
 * 
 *         # If integer keys don't start at 0, they will be treated as strings
 *         if len(int_keys) > 0 and int_keys[0] != 0:             # <<<<<<<<<<<<<<
 *             for x in int_keys:
 *                 str_keys.append(str(x))
 */
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_int_keys)); 
  __pyx_t_7 = (__pyx_t_5 > 0);
  if (__pyx_t_7) {
    __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_int_keys), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_1 = __pyx_t_8;
  } else {
    __pyx_t_1 = __pyx_t_7;
  }
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":837
 *         # If integer keys don't start at 0, they will be treated as strings
 *         if len(int_keys) > 0 and int_keys[0] != 0:
 *             for x in int_keys:             # <<<<<<<<<<<<<<
 *                 str_keys.append(str(x))
 *                 del int_keys[int_keys.index(x)]
 */
    if (unlikely(__pyx_v_int_keys == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_5 = 0; __pyx_t_10 = ((PyObject *)__pyx_v_int_keys); __Pyx_INCREF(__pyx_t_10);
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
      __Pyx_DECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "cpyamf/amf3.pyx":838
 *         if len(int_keys) > 0 and int_keys[0] != 0:
 *             for x in int_keys:
 *                 str_keys.append(str(x))             # <<<<<<<<<<<<<<
 *                 del int_keys[int_keys.index(x)]
 * 
 */
      if (unlikely(__pyx_v_str_keys == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_6 = PyList_Append(__pyx_v_str_keys, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cpyamf/amf3.pyx":839
 *             for x in int_keys:
 *                 str_keys.append(str(x))
 *                 del int_keys[int_keys.index(x)]             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, len(int_keys) << 1 | REFERENCE_BIT)
 */
      __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_int_keys), __pyx_n_s__index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      if (PyObject_DelItem(((PyObject *)__pyx_v_int_keys), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "cpyamf/amf3.pyx":841
 *                 del int_keys[int_keys.index(x)]
 * 
 *         _encode_integer(self.stream, len(int_keys) << 1 | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 * 
 *         for x in str_keys:
 */
  __pyx_t_10 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_10);
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_int_keys)); 
  __pyx_t_6 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_10), ((__pyx_t_5 << 1) | __pyx_v_6cpyamf_4amf3_REFERENCE_BIT)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cpyamf/amf3.pyx":843
 *         _encode_integer(self.stream, len(int_keys) << 1 | REFERENCE_BIT)
 * 
 *         for x in str_keys:             # <<<<<<<<<<<<<<
 *             self.serialiseString(x)
 *             self.writeElement(n[x])
 */
  if (unlikely(__pyx_v_str_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = 0; __pyx_t_10 = ((PyObject *)__pyx_v_str_keys); __Pyx_INCREF(__pyx_t_10);
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
    __pyx_t_9 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
    __Pyx_DECREF(__pyx_v_x);
    __pyx_v_x = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cpyamf/amf3.pyx":844
 * 
 *         for x in str_keys:
 *             self.serialiseString(x)             # <<<<<<<<<<<<<<
 *             self.writeElement(n[x])
 * 
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_x, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cpyamf/amf3.pyx":845
 *         for x in str_keys:
 *             self.serialiseString(x)
 *             self.writeElement(n[x])             # <<<<<<<<<<<<<<
 * 
 *         self.stream.write_uchar(0x01)
 */
    __pyx_t_9 = PyObject_GetItem(__pyx_v_n, __pyx_v_x); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_9, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cpyamf/amf3.pyx":847
 *             self.writeElement(n[x])
 * 
 *         self.stream.write_uchar(0x01)             # <<<<<<<<<<<<<<
 * 
 *         for k in int_keys:
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_self->__pyx_base.__pyx_base.stream->__pyx_vtab)->write_uchar(__pyx_v_self->__pyx_base.__pyx_base.stream, 0x01, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":849
 *         self.stream.write_uchar(0x01)
 * 
 *         for k in int_keys:             # <<<<<<<<<<<<<<
 *             self.writeElement(n[k])
 * 
 */
  if (unlikely(__pyx_v_int_keys == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = 0; __pyx_t_10 = ((PyObject *)__pyx_v_int_keys); __Pyx_INCREF(__pyx_t_10);
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_10)) break;
    __pyx_t_9 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++;
    __Pyx_DECREF(__pyx_v_k);
    __pyx_v_k = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cpyamf/amf3.pyx":850
 * 
 *         for k in int_keys:
 *             self.writeElement(n[k])             # <<<<<<<<<<<<<<
 * 
 *     cpdef int writeObject(self, object obj, bint is_proxy=0) except -1:
 */
    __pyx_t_9 = PyObject_GetItem(__pyx_v_n, __pyx_v_k); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_9, 0); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeMixedArray");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_ref);
  __Pyx_DECREF(__pyx_v_keys);
  __Pyx_DECREF(__pyx_v_int_keys);
  __Pyx_DECREF(__pyx_v_str_keys);
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_DECREF(__pyx_v_k);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":852
 *             self.writeElement(n[k])
 * 
 *     cpdef int writeObject(self, object obj, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref
 *         cdef object kls
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeObject(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch, struct __pyx_opt_args_6cpyamf_4amf3_7Encoder_writeObject *__pyx_optional_args) {
  int __pyx_v_is_proxy = ((int)0);
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_v_kls;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *__pyx_v_definition;
  PyObject *__pyx_v_alias = 0;
  int __pyx_v_class_ref;
  int __pyx_v_ret;
  char *__pyx_v_buf;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_attrs;
  PyObject *__pyx_v_attr;
  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;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __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_kls = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_definition = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_attrs = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_attr = 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 = 852; __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_4amf3_7Encoder_3writeObject)) {
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_is_proxy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __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 = 852; __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);
      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 = 852; __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 = 852; __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/amf3.pyx":856
 *         cdef object kls
 *         cdef ClassDefinition definition
 *         cdef object alias = None             # <<<<<<<<<<<<<<
 *         cdef int class_ref = 0
 *         cdef int ret = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_alias = Py_None;

  /* "cpyamf/amf3.pyx":857
 *         cdef ClassDefinition definition
 *         cdef object alias = None
 *         cdef int class_ref = 0             # <<<<<<<<<<<<<<
 *         cdef int ret = 0
 *         cdef char *buf = NULL
 */
  __pyx_v_class_ref = 0;

  /* "cpyamf/amf3.pyx":858
 *         cdef object alias = None
 *         cdef int class_ref = 0
 *         cdef int ret = 0             # <<<<<<<<<<<<<<
 *         cdef char *buf = NULL
 *         cdef PyObject *key
 */
  __pyx_v_ret = 0;

  /* "cpyamf/amf3.pyx":859
 *         cdef int class_ref = 0
 *         cdef int ret = 0
 *         cdef char *buf = NULL             # <<<<<<<<<<<<<<
 *         cdef PyObject *key
 *         cdef PyObject *value
 */
  __pyx_v_buf = NULL;

  /* "cpyamf/amf3.pyx":864
 *         cdef object attrs
 * 
 *         if self.use_proxies and not is_proxy:             # <<<<<<<<<<<<<<
 *             return self.writeProxy(obj)
 * 
 */
  if (__pyx_v_self->use_proxies) {
    __pyx_t_5 = (!__pyx_v_is_proxy);
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_v_self->use_proxies;
  }
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":865
 * 
 *         if self.use_proxies and not is_proxy:
 *             return self.writeProxy(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_OBJECT)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeProxy(__pyx_v_self, __pyx_v_obj); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":867
 *             return self.writeProxy(obj)
 * 
 *         self.writeType(TYPE_OBJECT)             # <<<<<<<<<<<<<<
 * 
 *         ref = self.context.getObjectReference(obj)
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_OBJECT); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":869
 *         self.writeType(TYPE_OBJECT)
 * 
 *         ref = self.context.getObjectReference(obj)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_7 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ref = __pyx_t_7;

  /* "cpyamf/amf3.pyx":871
 *         ref = self.context.getObjectReference(obj)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_6 = (__pyx_v_ref != -1);
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":872
 * 
 *         if ref != -1:
 *             _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_1), (__pyx_v_ref << 1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":874
 *             _encode_integer(self.stream, ref << 1)
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":876
 *             return 0
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         # object is not referenced, serialise it
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":879
 * 
 *         # object is not referenced, serialise it
 *         kls = obj.__class__             # <<<<<<<<<<<<<<
 *         definition = self.context.getClass(kls)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_obj, __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_kls);
  __pyx_v_kls = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":880
 *         # object is not referenced, serialise it
 *         kls = obj.__class__
 *         definition = self.context.getClass(kls)             # <<<<<<<<<<<<<<
 * 
 *         if definition:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getClass(__pyx_v_self->context, __pyx_v_kls, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_v_definition));
  __pyx_v_definition = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":882
 *         definition = self.context.getClass(kls)
 * 
 *         if definition:             # <<<<<<<<<<<<<<
 *             class_ref = 1
 *             alias = definition.alias
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_definition)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":883
 * 
 *         if definition:
 *             class_ref = 1             # <<<<<<<<<<<<<<
 *             alias = definition.alias
 *         else:
 */
    __pyx_v_class_ref = 1;

    /* "cpyamf/amf3.pyx":884
 *         if definition:
 *             class_ref = 1
 *             alias = definition.alias             # <<<<<<<<<<<<<<
 *         else:
 *             alias = self.context.getClassAlias(kls)
 */
    __Pyx_INCREF(__pyx_v_definition->alias);
    __Pyx_DECREF(__pyx_v_alias);
    __pyx_v_alias = __pyx_v_definition->alias;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":886
 *             alias = definition.alias
 *         else:
 *             alias = self.context.getClassAlias(kls)             # <<<<<<<<<<<<<<
 *             definition = ClassDefinition(alias)
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getClassAlias(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_kls, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_alias);
    __pyx_v_alias = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cpyamf/amf3.pyx":887
 *         else:
 *             alias = self.context.getClassAlias(kls)
 *             definition = ClassDefinition(alias)             # <<<<<<<<<<<<<<
 * 
 *             self.context.addClass(definition, alias.klass)
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_alias);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_alias);
    __Pyx_GIVEREF(__pyx_v_alias);
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6cpyamf_4amf3_ClassDefinition)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_definition));
    __pyx_v_definition = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cpyamf/amf3.pyx":889
 *             definition = ClassDefinition(alias)
 * 
 *             self.context.addClass(definition, alias.klass)             # <<<<<<<<<<<<<<
 * 
 *         definition.writeReference(self.stream)
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__klass); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->addClass(__pyx_v_self->context, __pyx_v_definition, __pyx_t_2, 0); if (unlikely(__pyx_t_7 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":891
 *             self.context.addClass(definition, alias.klass)
 * 
 *         definition.writeReference(self.stream)             # <<<<<<<<<<<<<<
 * 
 *         if class_ref == 0:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_2);
  ((struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition *)__pyx_v_definition->__pyx_vtab)->writeReference(__pyx_v_definition, ((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":893
 *         definition.writeReference(self.stream)
 * 
 *         if class_ref == 0:             # <<<<<<<<<<<<<<
 *             if alias.anonymous:
 *                 self.stream.write(&REF_CHAR, 1)
 */
  __pyx_t_6 = (__pyx_v_class_ref == 0);
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":894
 * 
 *         if class_ref == 0:
 *             if alias.anonymous:             # <<<<<<<<<<<<<<
 *                 self.stream.write(&REF_CHAR, 1)
 *             else:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__anonymous); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {

      /* "cpyamf/amf3.pyx":895
 *         if class_ref == 0:
 *             if alias.anonymous:
 *                 self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.serialiseString(alias.alias)
 */
      __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, (&__pyx_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    /*else*/ {

      /* "cpyamf/amf3.pyx":897
 *                 self.stream.write(&REF_CHAR, 1)
 *             else:
 *                 self.serialiseString(alias.alias)             # <<<<<<<<<<<<<<
 * 
 *             # work out what the final reference for the class will be.
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__alias); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_t_2, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cpyamf/amf3.pyx":904
 *             # again.
 * 
 *         if alias.external:             # <<<<<<<<<<<<<<
 *             obj.__writeamf__(DataOutput(self))
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s__external); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":905
 * 
 *         if alias.external:
 *             obj.__writeamf__(DataOutput(self))             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_obj, __pyx_n_s____writeamf__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_3 = PyObject_Call(__pyx_v_6cpyamf_4amf3_DataOutput, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __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 = 905; __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpyamf/amf3.pyx":907
 *             obj.__writeamf__(DataOutput(self))
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         attrs = alias.getEncodableAttributes(obj, codec=self)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "cpyamf/amf3.pyx":909
 *             return 0
 * 
 *         attrs = alias.getEncodableAttributes(obj, codec=self)             # <<<<<<<<<<<<<<
 * 
 *         if PyDict_CheckExact(attrs) != 1:
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_alias, __pyx_n_s_18); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__codec), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_attrs);
  __pyx_v_attrs = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cpyamf/amf3.pyx":911
 *         attrs = alias.getEncodableAttributes(obj, codec=self)
 * 
 *         if PyDict_CheckExact(attrs) != 1:             # <<<<<<<<<<<<<<
 *             raise TypeError('Expected dict for encodable attributes')
 * 
 */
  __pyx_t_6 = (PyDict_CheckExact(__pyx_v_attrs) != 1);
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":912
 * 
 *         if PyDict_CheckExact(attrs) != 1:
 *             raise TypeError('Expected dict for encodable attributes')             # <<<<<<<<<<<<<<
 * 
 *         if definition.attr_len > 0:
 */
    __pyx_t_8 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "cpyamf/amf3.pyx":914
 *             raise TypeError('Expected dict for encodable attributes')
 * 
 *         if definition.attr_len > 0:             # <<<<<<<<<<<<<<
 *             if class_ref == 0:
 *                 for attr in definition.static_properties:
 */
  __pyx_t_6 = (__pyx_v_definition->attr_len > 0);
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":915
 * 
 *         if definition.attr_len > 0:
 *             if class_ref == 0:             # <<<<<<<<<<<<<<
 *                 for attr in definition.static_properties:
 *                     self.serialiseString(attr)
 */
    __pyx_t_6 = (__pyx_v_class_ref == 0);
    if (__pyx_t_6) {

      /* "cpyamf/amf3.pyx":916
 *         if definition.attr_len > 0:
 *             if class_ref == 0:
 *                 for attr in definition.static_properties:             # <<<<<<<<<<<<<<
 *                     self.serialiseString(attr)
 * 
 */
      if (unlikely(__pyx_v_definition->static_properties == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_7 = 0; __pyx_t_8 = ((PyObject *)__pyx_v_definition->static_properties); __Pyx_INCREF(__pyx_t_8);
      for (;;) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_8)) break;
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
        __Pyx_DECREF(__pyx_v_attr);
        __pyx_v_attr = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "cpyamf/amf3.pyx":917
 *             if class_ref == 0:
 *                 for attr in definition.static_properties:
 *                     self.serialiseString(attr)             # <<<<<<<<<<<<<<
 * 
 *             for attr in definition.static_properties:
 */
        __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_attr, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "cpyamf/amf3.pyx":919
 *                     self.serialiseString(attr)
 * 
 *             for attr in definition.static_properties:             # <<<<<<<<<<<<<<
 *                 value = PyDict_GetItem(attrs, attr)
 * 
 */
    if (unlikely(__pyx_v_definition->static_properties == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_7 = 0; __pyx_t_8 = ((PyObject *)__pyx_v_definition->static_properties); __Pyx_INCREF(__pyx_t_8);
    for (;;) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_8)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++;
      __Pyx_DECREF(__pyx_v_attr);
      __pyx_v_attr = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cpyamf/amf3.pyx":920
 * 
 *             for attr in definition.static_properties:
 *                 value = PyDict_GetItem(attrs, attr)             # <<<<<<<<<<<<<<
 * 
 *                 if value == NULL:
 */
      __pyx_v_value = PyDict_GetItem(__pyx_v_attrs, __pyx_v_attr);

      /* "cpyamf/amf3.pyx":922
 *                 value = PyDict_GetItem(attrs, attr)
 * 
 *                 if value == NULL:             # <<<<<<<<<<<<<<
 *                     raise KeyError
 * 
 */
      __pyx_t_6 = (__pyx_v_value == NULL);
      if (__pyx_t_6) {

        /* "cpyamf/amf3.pyx":923
 * 
 *                 if value == NULL:
 *                     raise KeyError             # <<<<<<<<<<<<<<
 * 
 *                 if PyDict_DelItem(attrs, attr) == -1:
 */
        __Pyx_Raise(__pyx_builtin_KeyError, 0, 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L16;
      }
      __pyx_L16:;

      /* "cpyamf/amf3.pyx":925
 *                     raise KeyError
 * 
 *                 if PyDict_DelItem(attrs, attr) == -1:             # <<<<<<<<<<<<<<
 *                     return -1
 * 
 */
      __pyx_t_4 = PyDict_DelItem(__pyx_v_attrs, __pyx_v_attr); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = (__pyx_t_4 == -1);
      if (__pyx_t_6) {

        /* "cpyamf/amf3.pyx":926
 * 
 *                 if PyDict_DelItem(attrs, attr) == -1:
 *                     return -1             # <<<<<<<<<<<<<<
 * 
 *                 self.writeElement(<object>value)
 */
        __pyx_r = -1;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L0;
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "cpyamf/amf3.pyx":928
 *                     return -1
 * 
 *                 self.writeElement(<object>value)             # <<<<<<<<<<<<<<
 * 
 *             if definition.encoding == OBJECT_ENCODING_STATIC:
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_value), 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cpyamf/amf3.pyx":930
 *                 self.writeElement(<object>value)
 * 
 *             if definition.encoding == OBJECT_ENCODING_STATIC:             # <<<<<<<<<<<<<<
 *                 return 0
 * 
 */
    __pyx_t_6 = (__pyx_v_definition->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC);
    if (__pyx_t_6) {

      /* "cpyamf/amf3.pyx":931
 * 
 *             if definition.encoding == OBJECT_ENCODING_STATIC:
 *                 return 0             # <<<<<<<<<<<<<<
 * 
 *         if definition.encoding == OBJECT_ENCODING_DYNAMIC:
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L18;
    }
    __pyx_L18:;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "cpyamf/amf3.pyx":933
 *                 return 0
 * 
 *         if definition.encoding == OBJECT_ENCODING_DYNAMIC:             # <<<<<<<<<<<<<<
 *             ref = 0
 *             key = NULL
 */
  __pyx_t_6 = (__pyx_v_definition->encoding == __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_DYNAMIC);
  if (__pyx_t_6) {

    /* "cpyamf/amf3.pyx":934
 * 
 *         if definition.encoding == OBJECT_ENCODING_DYNAMIC:
 *             ref = 0             # <<<<<<<<<<<<<<
 *             key = NULL
 *             value = NULL
 */
    __pyx_v_ref = 0;

    /* "cpyamf/amf3.pyx":935
 *         if definition.encoding == OBJECT_ENCODING_DYNAMIC:
 *             ref = 0
 *             key = NULL             # <<<<<<<<<<<<<<
 *             value = NULL
 * 
 */
    __pyx_v_key = NULL;

    /* "cpyamf/amf3.pyx":936
 *             ref = 0
 *             key = NULL
 *             value = NULL             # <<<<<<<<<<<<<<
 * 
 *             while PyDict_Next(attrs, &ref, &key, &value):
 */
    __pyx_v_value = NULL;

    /* "cpyamf/amf3.pyx":938
 *             value = NULL
 * 
 *             while PyDict_Next(attrs, &ref, &key, &value):             # <<<<<<<<<<<<<<
 *                 self.serialiseString(<object>key)
 *                 self.writeElement(<object>value)
 */
    while (1) {
      __pyx_t_4 = PyDict_Next(__pyx_v_attrs, (&__pyx_v_ref), (&__pyx_v_key), (&__pyx_v_value));
      if (!__pyx_t_4) break;

      /* "cpyamf/amf3.pyx":939
 * 
 *             while PyDict_Next(attrs, &ref, &key, &value):
 *                 self.serialiseString(<object>key)             # <<<<<<<<<<<<<<
 *                 self.writeElement(<object>value)
 * 
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.serialiseString(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_key), 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cpyamf/amf3.pyx":940
 *             while PyDict_Next(attrs, &ref, &key, &value):
 *                 self.serialiseString(<object>key)
 *                 self.writeElement(<object>value)             # <<<<<<<<<<<<<<
 * 
 *             self.stream.write(&REF_CHAR, 1)
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeElement(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), ((PyObject *)__pyx_v_value), 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cpyamf/amf3.pyx":942
 *                 self.writeElement(<object>value)
 * 
 *             self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __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, (&__pyx_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L19;
  }
  __pyx_L19:;

  /* "cpyamf/amf3.pyx":944
 *             self.stream.write(&REF_CHAR, 1)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeByteArray(self, object obj) 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_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeObject");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_kls);
  __Pyx_DECREF((PyObject *)__pyx_v_definition);
  __Pyx_XDECREF(__pyx_v_alias);
  __Pyx_DECREF(__pyx_v_attrs);
  __Pyx_DECREF(__pyx_v_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":852
 *             self.writeElement(n[k])
 * 
 *     cpdef int writeObject(self, object obj, bint is_proxy=0) except -1:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t ref
 *         cdef object kls
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_3writeObject(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 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__obj,&__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__obj);
      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 = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_obj = 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 = 852; __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 = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_obj = 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 = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cpyamf.amf3.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_4amf3_Encoder *)((struct __pyx_obj_6cpyamf_4amf3_Encoder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.writeObject(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_obj, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __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 = 852; __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.amf3.Encoder.writeObject");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":946
 *         return 0
 * 
 *     cdef int writeByteArray(self, object obj) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Writes a L{ByteArray} to the data stream.
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeByteArray(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  Py_ssize_t __pyx_v_ref;
  PyObject *__pyx_v_buf;
  PyObject *__pyx_v_l;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("writeByteArray");
  __pyx_v_buf = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":956
 *         cdef object buf
 * 
 *         self.writeType(TYPE_BYTEARRAY)             # <<<<<<<<<<<<<<
 * 
 *         ref = self.context.getObjectReference(obj)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_BYTEARRAY); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":958
 *         self.writeType(TYPE_BYTEARRAY)
 * 
 *         ref = self.context.getObjectReference(obj)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_2 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ref = __pyx_t_2;

  /* "cpyamf/amf3.pyx":960
 *         ref = self.context.getObjectReference(obj)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_3 = (__pyx_v_ref != -1);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":961
 * 
 *         if ref != -1:
 *             _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_1 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_4), (__pyx_v_ref << 1)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpyamf/amf3.pyx":963
 *             _encode_integer(self.stream, ref << 1)
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":965
 *             return 0
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         buf = str(obj)
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":967
 *         self.context.addObject(obj)
 * 
 *         buf = str(obj)             # <<<<<<<<<<<<<<
 *         l = PyString_GET_SIZE(buf)
 * 
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_v_buf);
  __pyx_v_buf = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cpyamf/amf3.pyx":968
 * 
 *         buf = str(obj)
 *         l = PyString_GET_SIZE(buf)             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)
 */
  __pyx_t_5 = PyInt_FromSsize_t(PyString_GET_SIZE(__pyx_v_buf)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_v_l);
  __pyx_v_l = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cpyamf/amf3.pyx":970
 *         l = PyString_GET_SIZE(buf)
 * 
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 *         self.stream.write(PyString_AS_STRING(buf), l)
 * 
 */
  __pyx_t_5 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_4 = PyNumber_Lshift(__pyx_v_l, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_6cpyamf_4amf3_REFERENCE_BIT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Or(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_5), __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cpyamf/amf3.pyx":971
 * 
 *         _encode_integer(self.stream, (l << 1) | REFERENCE_BIT)
 *         self.stream.write(PyString_AS_STRING(buf), l)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_l); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((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_buf), __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":973
 *         self.stream.write(PyString_AS_STRING(buf), l)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeXML(self, obj) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeByteArray");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_buf);
  __Pyx_DECREF(__pyx_v_l);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":975
 *         return 0
 * 
 *     cdef int writeXML(self, obj) except -1:             # <<<<<<<<<<<<<<
 *         self.writeType(TYPE_XMLSTRING)
 * 
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeXML(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_v_s;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("writeXML");
  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);

  /* "cpyamf/amf3.pyx":976
 * 
 *     cdef int writeXML(self, obj) except -1:
 *         self.writeType(TYPE_XMLSTRING)             # <<<<<<<<<<<<<<
 * 
 *         i = self.context.getObjectReference(obj)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_XMLSTRING); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":978
 *         self.writeType(TYPE_XMLSTRING)
 * 
 *         i = self.context.getObjectReference(obj)             # <<<<<<<<<<<<<<
 * 
 *         if i != -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_2 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_v_i);
  __pyx_v_i = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cpyamf/amf3.pyx":980
 *         i = self.context.getObjectReference(obj)
 * 
 *         if i != -1:             # <<<<<<<<<<<<<<
 *             _encode_integer(self.stream, i << 1)
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_i, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":981
 * 
 *         if i != -1:
 *             _encode_integer(self.stream, i << 1)             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Lshift(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_3), __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cpyamf/amf3.pyx":983
 *             _encode_integer(self.stream, i << 1)
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":985
 *             return 0
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         s = xml.tostring(obj).encode('utf-8')
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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 = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":987
 *         self.context.addObject(obj)
 * 
 *         s = xml.tostring(obj).encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         if not PyString_CheckExact(s):
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__xml); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__tostring); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __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_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cpyamf/amf3.pyx":989
 *         s = xml.tostring(obj).encode('utf-8')
 * 
 *         if not PyString_CheckExact(s):             # <<<<<<<<<<<<<<
 *             raise TypeError('Expected string from xml serialization')
 * 
 */
  __pyx_t_4 = (!PyString_CheckExact(__pyx_v_s));
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":990
 * 
 *         if not PyString_CheckExact(s):
 *             raise TypeError('Expected string from xml serialization')             # <<<<<<<<<<<<<<
 * 
 *         i = PyString_GET_SIZE(s)
 */
    __pyx_t_7 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":992
 *             raise TypeError('Expected string from xml serialization')
 * 
 *         i = PyString_GET_SIZE(s)             # <<<<<<<<<<<<<<
 * 
 *         _encode_integer(self.stream, (i << 1) | REFERENCE_BIT)
 */
  __pyx_t_7 = PyInt_FromSsize_t(PyString_GET_SIZE(__pyx_v_s)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_v_i);
  __pyx_v_i = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "cpyamf/amf3.pyx":994
 *         i = PyString_GET_SIZE(s)
 * 
 *         _encode_integer(self.stream, (i << 1) | REFERENCE_BIT)             # <<<<<<<<<<<<<<
 *         self.stream.write(PyString_AS_STRING(s), i)
 * 
 */
  __pyx_t_7 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_3 = PyNumber_Lshift(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_6cpyamf_4amf3_REFERENCE_BIT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyNumber_Or(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_1 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_7), __pyx_t_6); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cpyamf/amf3.pyx":995
 * 
 *         _encode_integer(self.stream, (i << 1) | REFERENCE_BIT)
 *         self.stream.write(PyString_AS_STRING(s), i)             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __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(__pyx_v_self->__pyx_base.__pyx_base.stream, PyString_AS_STRING(__pyx_v_s), __pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":997
 *         self.stream.write(PyString_AS_STRING(s), i)
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeDateTime(self, obj) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cpyamf.amf3.Encoder.writeXML");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_i);
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":999
 *         return 0
 * 
 *     cdef int writeDateTime(self, obj) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Writes an L{datetime.datetime} object to the stream
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeDateTime(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  Py_ssize_t __pyx_v_ref;
  double __pyx_v_ms;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  __Pyx_RefNannySetupContext("writeDateTime");
  __Pyx_INCREF(__pyx_v_obj);

  /* "cpyamf/amf3.pyx":1003
 *         Writes an L{datetime.datetime} object to the stream
 *         """
 *         cdef Py_ssize_t ref = self.context.getObjectReference(obj)             # <<<<<<<<<<<<<<
 * 
 *         self.writeType(TYPE_DATE)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->__pyx_base.getObjectReference(((struct __pyx_obj_6cpyamf_5codec_Context *)__pyx_v_self->context), __pyx_v_obj, 0); if (unlikely(__pyx_t_1 == -2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ref = __pyx_t_1;

  /* "cpyamf/amf3.pyx":1005
 *         cdef Py_ssize_t ref = self.context.getObjectReference(obj)
 * 
 *         self.writeType(TYPE_DATE)             # <<<<<<<<<<<<<<
 * 
 *         if ref != -1:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeType(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_6cpyamf_4amf3_TYPE_DATE); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":1007
 *         self.writeType(TYPE_DATE)
 * 
 *         if ref != -1:             # <<<<<<<<<<<<<<
 *             _encode_integer(self.stream, ref << 1)
 * 
 */
  __pyx_t_3 = (__pyx_v_ref != -1);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":1008
 * 
 *         if ref != -1:
 *             _encode_integer(self.stream, ref << 1)             # <<<<<<<<<<<<<<
 * 
 *             return 0
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.stream);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_2 = __pyx_f_6cpyamf_4amf3__encode_integer(((struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *)__pyx_t_4), (__pyx_v_ref << 1)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cpyamf/amf3.pyx":1010
 *             _encode_integer(self.stream, ref << 1)
 * 
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *         self.context.addObject(obj)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":1012
 *             return 0
 * 
 *         self.context.addObject(obj)             # <<<<<<<<<<<<<<
 *         self.stream.write(&REF_CHAR, 1)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_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_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":1013
 * 
 *         self.context.addObject(obj)
 *         self.stream.write(&REF_CHAR, 1)             # <<<<<<<<<<<<<<
 * 
 *         if self.timezone_offset is not None:
 */
  __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, (&__pyx_v_6cpyamf_4amf3_REF_CHAR), 1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cpyamf/amf3.pyx":1015
 *         self.stream.write(&REF_CHAR, 1)
 * 
 *         if self.timezone_offset is not None:             # <<<<<<<<<<<<<<
 *             obj -= self.timezone_offset
 * 
 */
  __pyx_t_3 = (__pyx_v_self->__pyx_base.__pyx_base.timezone_offset != Py_None);
  if (__pyx_t_3) {

    /* "cpyamf/amf3.pyx":1016
 * 
 *         if self.timezone_offset is not None:
 *             obj -= self.timezone_offset             # <<<<<<<<<<<<<<
 * 
 *         ms = <double>util.get_timestamp(obj)
 */
    __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_v_obj, __pyx_v_self->__pyx_base.__pyx_base.timezone_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_v_obj);
    __pyx_v_obj = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cpyamf/amf3.pyx":1018
 *             obj -= self.timezone_offset
 * 
 *         ms = <double>util.get_timestamp(obj)             # <<<<<<<<<<<<<<
 *         self.stream.write_double(ms * 1000.0)
 * 
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__util); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__get_timestamp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_ms = __pyx_t_7;

  /* "cpyamf/amf3.pyx":1019
 * 
 *         ms = <double>util.get_timestamp(obj)
 *         self.stream.write_double(ms * 1000.0)             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeProxy(self, obj) except -1:
 */
  __pyx_t_2 = ((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_v_ms * 1000.0), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __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.amf3.Encoder.writeDateTime");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":1021
 *         self.stream.write_double(ms * 1000.0)
 * 
 *     cdef int writeProxy(self, obj) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Encodes a proxied object to the stream.
 */

static  int __pyx_f_6cpyamf_4amf3_7Encoder_writeProxy(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_proxy = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  struct __pyx_opt_args_6cpyamf_5codec_7Encoder_writeObject __pyx_t_3;
  __Pyx_RefNannySetupContext("writeProxy");

  /* "cpyamf/amf3.pyx":1027
 *         @since: 0.6
 *         """
 *         cdef object proxy = self.context.getProxyForObject(obj)             # <<<<<<<<<<<<<<
 * 
 *         return self.writeObject(proxy, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Context *)__pyx_v_self->context->__pyx_base.__pyx_vtab)->getProxyForObject(__pyx_v_self->context, __pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_proxy = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":1029
 *         cdef object proxy = self.context.getProxyForObject(obj)
 * 
 *         return self.writeObject(proxy, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 */
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.is_proxy = 1;
  __pyx_t_2 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.writeObject(((struct __pyx_obj_6cpyamf_5codec_Encoder *)__pyx_v_self), __pyx_v_proxy, 0, &__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __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.amf3.Encoder.writeProxy");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_proxy);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":1031
 *         return self.writeObject(proxy, 1)
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:             # <<<<<<<<<<<<<<
 *         cdef int ret = codec.Encoder.handleBasicTypes(self, element, py_type)
 * 
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3_7Encoder_handleBasicTypes(struct __pyx_obj_6cpyamf_4amf3_Encoder *__pyx_v_self, PyObject *__pyx_v_element, PyObject *__pyx_v_py_type) {
  int __pyx_v_ret;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("handleBasicTypes");

  /* "cpyamf/amf3.pyx":1032
 * 
 *     cdef inline int handleBasicTypes(self, object element, object py_type) except -1:
 *         cdef int ret = codec.Encoder.handleBasicTypes(self, element, py_type)             # <<<<<<<<<<<<<<
 * 
 *         if ret == 1: # not handled
 */
  __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 = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ret = __pyx_t_1;

  /* "cpyamf/amf3.pyx":1034
 *         cdef int ret = codec.Encoder.handleBasicTypes(self, element, py_type)
 * 
 *         if ret == 1: # not handled             # <<<<<<<<<<<<<<
 *             if py_type is ByteArrayType:
 *                 return self.writeByteArray(element)
 */
  __pyx_t_2 = (__pyx_v_ret == 1);
  if (__pyx_t_2) {

    /* "cpyamf/amf3.pyx":1035
 * 
 *         if ret == 1: # not handled
 *             if py_type is ByteArrayType:             # <<<<<<<<<<<<<<
 *                 return self.writeByteArray(element)
 * 
 */
    __pyx_t_2 = (__pyx_v_py_type == __pyx_v_6cpyamf_4amf3_ByteArrayType);
    if (__pyx_t_2) {

      /* "cpyamf/amf3.pyx":1036
 *         if ret == 1: # not handled
 *             if py_type is ByteArrayType:
 *                 return self.writeByteArray(element)             # <<<<<<<<<<<<<<
 * 
 *         return ret
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4amf3_Encoder *)__pyx_v_self->__pyx_base.__pyx_vtab)->writeByteArray(__pyx_v_self, __pyx_v_element); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_t_1;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":1038
 *                 return self.writeByteArray(element)
 * 
 *         return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

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

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

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_11use_proxies___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_11use_proxies___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_4amf3_Encoder *)__pyx_v_self)->use_proxies); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __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.amf3.Encoder.use_proxies.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

/* "cpyamf/amf3.pxd":58
 * cdef class Encoder(codec.Encoder):
 *     cdef public bint use_proxies
 *     cdef readonly Context context             # <<<<<<<<<<<<<<
 * 
 *     cdef int writeByteArray(self, object obj) except -1
 */

static PyObject *__pyx_pf_6cpyamf_4amf3_7Encoder_7context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_6cpyamf_4amf3_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_4amf3_Encoder *)__pyx_v_self)->context));
  __pyx_r = ((PyObject *)((struct __pyx_obj_6cpyamf_4amf3_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;
}

/* "cpyamf/amf3.pyx":1041
 * 
 * 
 * cdef int encode_int(long i, char **buf) except -1:             # <<<<<<<<<<<<<<
 *     # Use typecasting to get the twos complement representation of i
 *     cdef unsigned long n = (<unsigned long*>(<void *>(&i)))[0]
 */

static  int __pyx_f_6cpyamf_4amf3_encode_int(long __pyx_v_i, char **__pyx_v_buf) {
  unsigned long __pyx_v_n;
  unsigned long __pyx_v_real_value;
  unsigned char __pyx_v_count;
  char *__pyx_v_bytes;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2;
  __Pyx_RefNannySetupContext("encode_int");

  /* "cpyamf/amf3.pyx":1043
 * cdef int encode_int(long i, char **buf) except -1:
 *     # Use typecasting to get the twos complement representation of i
 *     cdef unsigned long n = (<unsigned long*>(<void *>(&i)))[0]             # <<<<<<<<<<<<<<
 * 
 *     cdef unsigned long real_value = n
 */
  __pyx_v_n = (((unsigned long *)((void *)(&__pyx_v_i)))[0]);

  /* "cpyamf/amf3.pyx":1045
 *     cdef unsigned long n = (<unsigned long*>(<void *>(&i)))[0]
 * 
 *     cdef unsigned long real_value = n             # <<<<<<<<<<<<<<
 *     cdef unsigned char count = 0
 *     cdef char *bytes = NULL
 */
  __pyx_v_real_value = __pyx_v_n;

  /* "cpyamf/amf3.pyx":1046
 * 
 *     cdef unsigned long real_value = n
 *     cdef unsigned char count = 0             # <<<<<<<<<<<<<<
 *     cdef char *bytes = NULL
 * 
 */
  __pyx_v_count = 0;

  /* "cpyamf/amf3.pyx":1047
 *     cdef unsigned long real_value = n
 *     cdef unsigned char count = 0
 *     cdef char *bytes = NULL             # <<<<<<<<<<<<<<
 * 
 *     if n > 0x1fffff:
 */
  __pyx_v_bytes = NULL;

  /* "cpyamf/amf3.pyx":1049
 *     cdef char *bytes = NULL
 * 
 *     if n > 0x1fffff:             # <<<<<<<<<<<<<<
 *         bytes = <char *>malloc(4)
 * 
 */
  __pyx_t_1 = (__pyx_v_n > 0x1fffff);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":1050
 * 
 *     if n > 0x1fffff:
 *         bytes = <char *>malloc(4)             # <<<<<<<<<<<<<<
 * 
 *         if bytes == NULL:
 */
    __pyx_v_bytes = ((char *)malloc(4));

    /* "cpyamf/amf3.pyx":1052
 *         bytes = <char *>malloc(4)
 * 
 *         if bytes == NULL:             # <<<<<<<<<<<<<<
 *             PyErr_NoMemory()
 * 
 */
    __pyx_t_1 = (__pyx_v_bytes == NULL);
    if (__pyx_t_1) {

      /* "cpyamf/amf3.pyx":1053
 * 
 *         if bytes == NULL:
 *             PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         n = n >> 1
 */
      __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "cpyamf/amf3.pyx":1055
 *             PyErr_NoMemory()
 * 
 *         n = n >> 1             # <<<<<<<<<<<<<<
 *         bytes[count] = 0x80 | ((n >> 21) & 0xff)
 *         count += 1
 */
    __pyx_v_n = (__pyx_v_n >> 1);

    /* "cpyamf/amf3.pyx":1056
 * 
 *         n = n >> 1
 *         bytes[count] = 0x80 | ((n >> 21) & 0xff)             # <<<<<<<<<<<<<<
 *         count += 1
 * 
 */
    (__pyx_v_bytes[__pyx_v_count]) = (0x80 | ((__pyx_v_n >> 21) & 0xff));

    /* "cpyamf/amf3.pyx":1057
 *         n = n >> 1
 *         bytes[count] = 0x80 | ((n >> 21) & 0xff)
 *         count += 1             # <<<<<<<<<<<<<<
 * 
 *     if n > 0x3fff:
 */
    __pyx_v_count = (__pyx_v_count + 1);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cpyamf/amf3.pyx":1059
 *         count += 1
 * 
 *     if n > 0x3fff:             # <<<<<<<<<<<<<<
 *         if bytes == NULL:
 *             bytes = <char *>malloc(3)
 */
  __pyx_t_1 = (__pyx_v_n > 0x3fff);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":1060
 * 
 *     if n > 0x3fff:
 *         if bytes == NULL:             # <<<<<<<<<<<<<<
 *             bytes = <char *>malloc(3)
 * 
 */
    __pyx_t_1 = (__pyx_v_bytes == NULL);
    if (__pyx_t_1) {

      /* "cpyamf/amf3.pyx":1061
 *     if n > 0x3fff:
 *         if bytes == NULL:
 *             bytes = <char *>malloc(3)             # <<<<<<<<<<<<<<
 * 
 *             if bytes == NULL:
 */
      __pyx_v_bytes = ((char *)malloc(3));

      /* "cpyamf/amf3.pyx":1063
 *             bytes = <char *>malloc(3)
 * 
 *             if bytes == NULL:             # <<<<<<<<<<<<<<
 *                 PyErr_NoMemory()
 * 
 */
      __pyx_t_1 = (__pyx_v_bytes == NULL);
      if (__pyx_t_1) {

        /* "cpyamf/amf3.pyx":1064
 * 
 *             if bytes == NULL:
 *                 PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         bytes[count] = 0x80 | ((n >> 14) & 0xff)
 */
        __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cpyamf/amf3.pyx":1066
 *                 PyErr_NoMemory()
 * 
 *         bytes[count] = 0x80 | ((n >> 14) & 0xff)             # <<<<<<<<<<<<<<
 *         count += 1
 * 
 */
    (__pyx_v_bytes[__pyx_v_count]) = (0x80 | ((__pyx_v_n >> 14) & 0xff));

    /* "cpyamf/amf3.pyx":1067
 * 
 *         bytes[count] = 0x80 | ((n >> 14) & 0xff)
 *         count += 1             # <<<<<<<<<<<<<<
 * 
 *     if n > 0x7f:
 */
    __pyx_v_count = (__pyx_v_count + 1);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":1069
 *         count += 1
 * 
 *     if n > 0x7f:             # <<<<<<<<<<<<<<
 *         if bytes == NULL:
 *             bytes = <char *>malloc(2)
 */
  __pyx_t_1 = (__pyx_v_n > 0x7f);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":1070
 * 
 *     if n > 0x7f:
 *         if bytes == NULL:             # <<<<<<<<<<<<<<
 *             bytes = <char *>malloc(2)
 * 
 */
    __pyx_t_1 = (__pyx_v_bytes == NULL);
    if (__pyx_t_1) {

      /* "cpyamf/amf3.pyx":1071
 *     if n > 0x7f:
 *         if bytes == NULL:
 *             bytes = <char *>malloc(2)             # <<<<<<<<<<<<<<
 * 
 *             if bytes == NULL:
 */
      __pyx_v_bytes = ((char *)malloc(2));

      /* "cpyamf/amf3.pyx":1073
 *             bytes = <char *>malloc(2)
 * 
 *             if bytes == NULL:             # <<<<<<<<<<<<<<
 *                 PyErr_NoMemory()
 * 
 */
      __pyx_t_1 = (__pyx_v_bytes == NULL);
      if (__pyx_t_1) {

        /* "cpyamf/amf3.pyx":1074
 * 
 *             if bytes == NULL:
 *                 PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         bytes[count] = 0x80 | ((n >> 7) & 0xff)
 */
        __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L10;
      }
      __pyx_L10:;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "cpyamf/amf3.pyx":1076
 *                 PyErr_NoMemory()
 * 
 *         bytes[count] = 0x80 | ((n >> 7) & 0xff)             # <<<<<<<<<<<<<<
 *         count += 1
 * 
 */
    (__pyx_v_bytes[__pyx_v_count]) = (0x80 | ((__pyx_v_n >> 7) & 0xff));

    /* "cpyamf/amf3.pyx":1077
 * 
 *         bytes[count] = 0x80 | ((n >> 7) & 0xff)
 *         count += 1             # <<<<<<<<<<<<<<
 * 
 *     if bytes == NULL:
 */
    __pyx_v_count = (__pyx_v_count + 1);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "cpyamf/amf3.pyx":1079
 *         count += 1
 * 
 *     if bytes == NULL:             # <<<<<<<<<<<<<<
 *         bytes = <char *>malloc(1)
 * 
 */
  __pyx_t_1 = (__pyx_v_bytes == NULL);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":1080
 * 
 *     if bytes == NULL:
 *         bytes = <char *>malloc(1)             # <<<<<<<<<<<<<<
 * 
 *         if bytes == NULL:
 */
    __pyx_v_bytes = ((char *)malloc(1));

    /* "cpyamf/amf3.pyx":1082
 *         bytes = <char *>malloc(1)
 * 
 *         if bytes == NULL:             # <<<<<<<<<<<<<<
 *             PyErr_NoMemory()
 * 
 */
    __pyx_t_1 = (__pyx_v_bytes == NULL);
    if (__pyx_t_1) {

      /* "cpyamf/amf3.pyx":1083
 * 
 *         if bytes == NULL:
 *             PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     if real_value > 0x1fffff:
 */
      __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L12;
    }
    __pyx_L12:;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "cpyamf/amf3.pyx":1085
 *             PyErr_NoMemory()
 * 
 *     if real_value > 0x1fffff:             # <<<<<<<<<<<<<<
 *         bytes[count] = real_value & 0xff
 *     else:
 */
  __pyx_t_1 = (__pyx_v_real_value > 0x1fffff);
  if (__pyx_t_1) {

    /* "cpyamf/amf3.pyx":1086
 * 
 *     if real_value > 0x1fffff:
 *         bytes[count] = real_value & 0xff             # <<<<<<<<<<<<<<
 *     else:
 *         bytes[count] = real_value & 0x7f
 */
    (__pyx_v_bytes[__pyx_v_count]) = (__pyx_v_real_value & 0xff);
    goto __pyx_L13;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":1088
 *         bytes[count] = real_value & 0xff
 *     else:
 *         bytes[count] = real_value & 0x7f             # <<<<<<<<<<<<<<
 * 
 *     buf[0] = bytes
 */
    (__pyx_v_bytes[__pyx_v_count]) = (__pyx_v_real_value & 0x7f);
  }
  __pyx_L13:;

  /* "cpyamf/amf3.pyx":1090
 *         bytes[count] = real_value & 0x7f
 * 
 *     buf[0] = bytes             # <<<<<<<<<<<<<<
 * 
 *     return count + 1
 */
  (__pyx_v_buf[0]) = __pyx_v_bytes;

  /* "cpyamf/amf3.pyx":1092
 *     buf[0] = bytes
 * 
 *     return count + 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_count + 1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf3.encode_int");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":1095
 * 
 * 
 * cdef int decode_int(cBufferedByteStream stream, int sign=0) except? -1:             # <<<<<<<<<<<<<<
 *     cdef int n = 0
 *     cdef int result = 0
 */

static  int __pyx_f_6cpyamf_4amf3_decode_int(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *__pyx_v_stream, struct __pyx_opt_args_6cpyamf_4amf3_decode_int *__pyx_optional_args) {
  int __pyx_v_sign = ((int)0);
  int __pyx_v_n;
  int __pyx_v_result;
  unsigned char __pyx_v_b;
  int __pyx_r;
  unsigned char __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("decode_int");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_sign = __pyx_optional_args->sign;
    }
  }

  /* "cpyamf/amf3.pyx":1096
 * 
 * cdef int decode_int(cBufferedByteStream stream, int sign=0) except? -1:
 *     cdef int n = 0             # <<<<<<<<<<<<<<
 *     cdef int result = 0
 *     cdef unsigned char b = stream.read_uchar()
 */
  __pyx_v_n = 0;

  /* "cpyamf/amf3.pyx":1097
 * cdef int decode_int(cBufferedByteStream stream, int sign=0) except? -1:
 *     cdef int n = 0
 *     cdef int result = 0             # <<<<<<<<<<<<<<
 *     cdef unsigned char b = stream.read_uchar()
 * 
 */
  __pyx_v_result = 0;

  /* "cpyamf/amf3.pyx":1098
 *     cdef int n = 0
 *     cdef int result = 0
 *     cdef unsigned char b = stream.read_uchar()             # <<<<<<<<<<<<<<
 * 
 *     while b & 0x80 != 0 and n < 3:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream->__pyx_vtab)->read_uchar(__pyx_v_stream, 0); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_b = __pyx_t_1;

  /* "cpyamf/amf3.pyx":1100
 *     cdef unsigned char b = stream.read_uchar()
 * 
 *     while b & 0x80 != 0 and n < 3:             # <<<<<<<<<<<<<<
 *         result <<= 7
 *         result |= b & 0x7f
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_b & 0x80) != 0);
    if (__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_n < 3);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    if (!__pyx_t_4) break;

    /* "cpyamf/amf3.pyx":1101
 * 
 *     while b & 0x80 != 0 and n < 3:
 *         result <<= 7             # <<<<<<<<<<<<<<
 *         result |= b & 0x7f
 * 
 */
    __pyx_v_result = (__pyx_v_result << 7);

    /* "cpyamf/amf3.pyx":1102
 *     while b & 0x80 != 0 and n < 3:
 *         result <<= 7
 *         result |= b & 0x7f             # <<<<<<<<<<<<<<
 * 
 *         b = stream.read_uchar()
 */
    __pyx_v_result = (__pyx_v_result | (__pyx_v_b & 0x7f));

    /* "cpyamf/amf3.pyx":1104
 *         result |= b & 0x7f
 * 
 *         b = stream.read_uchar()             # <<<<<<<<<<<<<<
 * 
 *         n += 1
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream->__pyx_vtab)->read_uchar(__pyx_v_stream, 0); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_b = __pyx_t_1;

    /* "cpyamf/amf3.pyx":1106
 *         b = stream.read_uchar()
 * 
 *         n += 1             # <<<<<<<<<<<<<<
 * 
 *     if n < 3:
 */
    __pyx_v_n = (__pyx_v_n + 1);
  }

  /* "cpyamf/amf3.pyx":1108
 *         n += 1
 * 
 *     if n < 3:             # <<<<<<<<<<<<<<
 *         result <<= 7
 *         result |= b
 */
  __pyx_t_4 = (__pyx_v_n < 3);
  if (__pyx_t_4) {

    /* "cpyamf/amf3.pyx":1109
 * 
 *     if n < 3:
 *         result <<= 7             # <<<<<<<<<<<<<<
 *         result |= b
 *     else:
 */
    __pyx_v_result = (__pyx_v_result << 7);

    /* "cpyamf/amf3.pyx":1110
 *     if n < 3:
 *         result <<= 7
 *         result |= b             # <<<<<<<<<<<<<<
 *     else:
 *         result <<= 8
 */
    __pyx_v_result = (__pyx_v_result | __pyx_v_b);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "cpyamf/amf3.pyx":1112
 *         result |= b
 *     else:
 *         result <<= 8             # <<<<<<<<<<<<<<
 *         result |= b
 * 
 */
    __pyx_v_result = (__pyx_v_result << 8);

    /* "cpyamf/amf3.pyx":1113
 *     else:
 *         result <<= 8
 *         result |= b             # <<<<<<<<<<<<<<
 * 
 *         if result & 0x10000000 != 0:
 */
    __pyx_v_result = (__pyx_v_result | __pyx_v_b);

    /* "cpyamf/amf3.pyx":1115
 *         result |= b
 * 
 *         if result & 0x10000000 != 0:             # <<<<<<<<<<<<<<
 *             if sign == 1:
 *                 result -= 0x20000000
 */
    __pyx_t_4 = ((__pyx_v_result & 0x10000000) != 0);
    if (__pyx_t_4) {

      /* "cpyamf/amf3.pyx":1116
 * 
 *         if result & 0x10000000 != 0:
 *             if sign == 1:             # <<<<<<<<<<<<<<
 *                 result -= 0x20000000
 *             else:
 */
      __pyx_t_4 = (__pyx_v_sign == 1);
      if (__pyx_t_4) {

        /* "cpyamf/amf3.pyx":1117
 *         if result & 0x10000000 != 0:
 *             if sign == 1:
 *                 result -= 0x20000000             # <<<<<<<<<<<<<<
 *             else:
 *                 result <<= 1
 */
        __pyx_v_result = (__pyx_v_result - 0x20000000);
        goto __pyx_L7;
      }
      /*else*/ {

        /* "cpyamf/amf3.pyx":1119
 *                 result -= 0x20000000
 *             else:
 *                 result <<= 1             # <<<<<<<<<<<<<<
 *                 result += 1
 * 
 */
        __pyx_v_result = (__pyx_v_result << 1);

        /* "cpyamf/amf3.pyx":1120
 *             else:
 *                 result <<= 1
 *                 result += 1             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
        __pyx_v_result = (__pyx_v_result + 1);
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L5:;

  /* "cpyamf/amf3.pyx":1122
 *                 result += 1
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf3.decode_int");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":1125
 * 
 * 
 * cdef inline int _encode_integer(cBufferedByteStream stream, int i) except -1:             # <<<<<<<<<<<<<<
 *     cdef char *buf = NULL
 *     cdef int size = 0
 */

static CYTHON_INLINE int __pyx_f_6cpyamf_4amf3__encode_integer(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *__pyx_v_stream, int __pyx_v_i) {
  char *__pyx_v_buf;
  int __pyx_v_size;
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_encode_integer");

  /* "cpyamf/amf3.pyx":1126
 * 
 * cdef inline int _encode_integer(cBufferedByteStream stream, int i) except -1:
 *     cdef char *buf = NULL             # <<<<<<<<<<<<<<
 *     cdef int size = 0
 * 
 */
  __pyx_v_buf = NULL;

  /* "cpyamf/amf3.pyx":1127
 * cdef inline int _encode_integer(cBufferedByteStream stream, int i) except -1:
 *     cdef char *buf = NULL
 *     cdef int size = 0             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
  __pyx_v_size = 0;

  /* "cpyamf/amf3.pyx":1129
 *     cdef int size = 0
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         size = encode_int(i, &buf)
 * 
 */
  /*try:*/ {

    /* "cpyamf/amf3.pyx":1130
 * 
 *     try:
 *         size = encode_int(i, &buf)             # <<<<<<<<<<<<<<
 * 
 *         return stream.write(buf, size)
 */
    __pyx_t_1 = __pyx_f_6cpyamf_4amf3_encode_int(__pyx_v_i, (&__pyx_v_buf)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __pyx_v_size = __pyx_t_1;

    /* "cpyamf/amf3.pyx":1132
 *         size = encode_int(i, &buf)
 * 
 *         return stream.write(buf, size)             # <<<<<<<<<<<<<<
 *     finally:
 *         free(buf)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream *)__pyx_v_stream->__pyx_vtab)->write(__pyx_v_stream, __pyx_v_buf, __pyx_v_size); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __pyx_r = __pyx_t_1;
    goto __pyx_L3;
  }

  /* "cpyamf/amf3.pyx":1134
 *         return stream.write(buf, size)
 *     finally:
 *         free(buf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    free(__pyx_v_buf);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf3._encode_integer");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpyamf/amf3.pyx":1137
 * 
 * 
 * cdef inline Py_ssize_t _read_ref(cBufferedByteStream stream) except -1:             # <<<<<<<<<<<<<<
 *     return <Py_ssize_t>decode_int(stream, 0)
 */

static CYTHON_INLINE Py_ssize_t __pyx_f_6cpyamf_4amf3__read_ref(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *__pyx_v_stream) {
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  struct __pyx_opt_args_6cpyamf_4amf3_decode_int __pyx_t_2;
  __Pyx_RefNannySetupContext("_read_ref");

  /* "cpyamf/amf3.pyx":1138
 * 
 * cdef inline Py_ssize_t _read_ref(cBufferedByteStream stream) except -1:
 *     return <Py_ssize_t>decode_int(stream, 0)             # <<<<<<<<<<<<<<
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.sign = 0;
  __pyx_t_1 = __pyx_f_6cpyamf_4amf3_decode_int(__pyx_v_stream, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((Py_ssize_t)__pyx_t_1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpyamf.amf3._read_ref");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6cpyamf_4amf3_ClassDefinition __pyx_vtable_6cpyamf_4amf3_ClassDefinition;

static PyObject *__pyx_tp_new_6cpyamf_4amf3_ClassDefinition(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)o);
  p->__pyx_vtab = __pyx_vtabptr_6cpyamf_4amf3_ClassDefinition;
  p->alias = Py_None; Py_INCREF(Py_None);
  p->static_properties = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_4amf3_15ClassDefinition___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf3_ClassDefinition(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *p = (struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_6cpyamf_4amf3_15ClassDefinition_2__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->alias);
  Py_XDECREF(((PyObject *)p->static_properties));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf3_ClassDefinition(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *p = (struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)o;
  if (p->alias) {
    e = (*v)(p->alias, a); if (e) return e;
  }
  if (p->static_properties) {
    e = (*v)(p->static_properties, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf3_ClassDefinition(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *p = (struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->alias);
  p->alias = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->static_properties);
  p->static_properties = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_15ClassDefinition_alias(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_15ClassDefinition_5alias___get__(o);
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_15ClassDefinition_attr_len(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_15ClassDefinition_8attr_len___get__(o);
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_15ClassDefinition_encoding(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_15ClassDefinition_8encoding___get__(o);
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_15ClassDefinition_static_properties(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_15ClassDefinition_17static_properties___get__(o);
}

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

static struct PyGetSetDef __pyx_getsets_6cpyamf_4amf3_ClassDefinition[] = {
  {(char *)"alias", __pyx_getprop_6cpyamf_4amf3_15ClassDefinition_alias, 0, 0, 0},
  {(char *)"attr_len", __pyx_getprop_6cpyamf_4amf3_15ClassDefinition_attr_len, 0, 0, 0},
  {(char *)"encoding", __pyx_getprop_6cpyamf_4amf3_15ClassDefinition_encoding, 0, 0, 0},
  {(char *)"static_properties", __pyx_getprop_6cpyamf_4amf3_15ClassDefinition_static_properties, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ClassDefinition = {
  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_ClassDefinition = {
  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_ClassDefinition = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ClassDefinition = {
  #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_4amf3_ClassDefinition = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf3.ClassDefinition"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf3_ClassDefinition), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf3_ClassDefinition, /*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_ClassDefinition, /*tp_as_number*/
  &__pyx_tp_as_sequence_ClassDefinition, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ClassDefinition, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ClassDefinition, /*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    Holds transient class trait info for an individual encode/decode.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf3_ClassDefinition, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf3_ClassDefinition, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf3_ClassDefinition, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_4amf3_ClassDefinition, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_4amf3_15ClassDefinition_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_4amf3_ClassDefinition, /*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_4amf3_Context __pyx_vtable_6cpyamf_4amf3_Context;

static PyObject *__pyx_tp_new_6cpyamf_4amf3_Context(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf3_Context *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Context->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf3_Context *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Context*)__pyx_vtabptr_6cpyamf_4amf3_Context;
  p->strings = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)Py_None); Py_INCREF(Py_None);
  p->classes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->class_ref = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->proxied_objects = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_6cpyamf_4amf3_7Context___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf3_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Context *p = (struct __pyx_obj_6cpyamf_4amf3_Context *)o;
  Py_XDECREF(((PyObject *)p->strings));
  Py_XDECREF(((PyObject *)p->classes));
  Py_XDECREF(((PyObject *)p->class_ref));
  Py_XDECREF(((PyObject *)p->proxied_objects));
  __pyx_ptype_6cpyamf_5codec_Context->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf3_Context(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf3_Context *p = (struct __pyx_obj_6cpyamf_4amf3_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->strings) {
    e = (*v)(((PyObject*)p->strings), a); if (e) return e;
  }
  if (p->classes) {
    e = (*v)(p->classes, a); if (e) return e;
  }
  if (p->class_ref) {
    e = (*v)(p->class_ref, a); if (e) return e;
  }
  if (p->proxied_objects) {
    e = (*v)(p->proxied_objects, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf3_Context(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Context *p = (struct __pyx_obj_6cpyamf_4amf3_Context *)o;
  PyObject* tmp;
  if (__pyx_ptype_6cpyamf_5codec_Context->tp_clear) {
    __pyx_ptype_6cpyamf_5codec_Context->tp_clear(o);
  }
  tmp = ((PyObject*)p->strings);
  p->strings = ((struct __pyx_obj_6cpyamf_5codec_IndexedCollection *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->classes);
  p->classes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->class_ref);
  p->class_ref = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->proxied_objects);
  p->proxied_objects = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6cpyamf_4amf3_Context[] = {
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_1clear, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Context_1clear)},
  {__Pyx_NAMESTR("getString"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_2getString, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getStringReference"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_3getStringReference, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("addString"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_4addString, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Context_4addString)},
  {__Pyx_NAMESTR("getClassByReference"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_5getClassByReference, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getClass"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_6getClass, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("addClass"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_7addClass, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getProxyForObject"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_8getProxyForObject, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Context_8getProxyForObject)},
  {__Pyx_NAMESTR("getObjectForProxy"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_9getObjectForProxy, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Context_9getObjectForProxy)},
  {__Pyx_NAMESTR("addProxyObject"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Context_10addProxyObject, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Context_10addProxyObject)},
  {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_4amf3_Context = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf3.Context"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf3_Context), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf3_Context, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Context, /*tp_as_number*/
  &__pyx_tp_as_sequence_Context, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Context, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Context, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    I hold the AMF3 context for en/decoding streams.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf3_Context, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf3_Context, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf3_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_4amf3_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_4amf3_Decoder __pyx_vtable_6cpyamf_4amf3_Decoder;

static PyObject *__pyx_tp_new_6cpyamf_4amf3_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf3_Decoder *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Decoder->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf3_Decoder *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Decoder*)__pyx_vtabptr_6cpyamf_4amf3_Decoder;
  p->context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf3_Decoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Decoder *p = (struct __pyx_obj_6cpyamf_4amf3_Decoder *)o;
  Py_XDECREF(((PyObject *)p->context));
  __pyx_ptype_6cpyamf_5codec_Decoder->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf3_Decoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf3_Decoder *p = (struct __pyx_obj_6cpyamf_4amf3_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;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf3_Decoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Decoder *p = (struct __pyx_obj_6cpyamf_4amf3_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_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_7Decoder_use_proxies(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_7Decoder_11use_proxies___get__(o);
}

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

static PyObject *__pyx_getprop_6cpyamf_4amf3_7Decoder_context(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_7Decoder_7context___get__(o);
}

static PyMethodDef __pyx_methods_6cpyamf_4amf3_Decoder[] = {
  {__Pyx_NAMESTR("readString"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Decoder_1readString, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Decoder_1readString)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_4amf3_Decoder[] = {
  {(char *)"use_proxies", __pyx_getprop_6cpyamf_4amf3_7Decoder_use_proxies, __pyx_setprop_6cpyamf_4amf3_7Decoder_use_proxies, 0, 0},
  {(char *)"context", __pyx_getprop_6cpyamf_4amf3_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_4amf3_Decoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf3.Decoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf3_Decoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf3_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    Decodes an AMF3 data stream.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf3_Decoder, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf3_Decoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf3_Decoder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_4amf3_Decoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_4amf3_7Decoder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_4amf3_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_4amf3_Encoder __pyx_vtable_6cpyamf_4amf3_Encoder;

static PyObject *__pyx_tp_new_6cpyamf_4amf3_Encoder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6cpyamf_4amf3_Encoder *p;
  PyObject *o = __pyx_ptype_6cpyamf_5codec_Encoder->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_6cpyamf_4amf3_Encoder *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6cpyamf_5codec_Encoder*)__pyx_vtabptr_6cpyamf_4amf3_Encoder;
  p->context = ((struct __pyx_obj_6cpyamf_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6cpyamf_4amf3_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Encoder *p = (struct __pyx_obj_6cpyamf_4amf3_Encoder *)o;
  Py_XDECREF(((PyObject *)p->context));
  __pyx_ptype_6cpyamf_5codec_Encoder->tp_dealloc(o);
}

static int __pyx_tp_traverse_6cpyamf_4amf3_Encoder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6cpyamf_4amf3_Encoder *p = (struct __pyx_obj_6cpyamf_4amf3_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;
  }
  return 0;
}

static int __pyx_tp_clear_6cpyamf_4amf3_Encoder(PyObject *o) {
  struct __pyx_obj_6cpyamf_4amf3_Encoder *p = (struct __pyx_obj_6cpyamf_4amf3_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_4amf3_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6cpyamf_4amf3_7Encoder_use_proxies(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_7Encoder_11use_proxies___get__(o);
}

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

static PyObject *__pyx_getprop_6cpyamf_4amf3_7Encoder_context(PyObject *o, void *x) {
  return __pyx_pf_6cpyamf_4amf3_7Encoder_7context___get__(o);
}

static PyMethodDef __pyx_methods_6cpyamf_4amf3_Encoder[] = {
  {__Pyx_NAMESTR("serialiseString"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Encoder_1serialiseString, METH_O, __Pyx_DOCSTR(__pyx_doc_6cpyamf_4amf3_7Encoder_1serialiseString)},
  {__Pyx_NAMESTR("writeList"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Encoder_2writeList, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("writeObject"), (PyCFunction)__pyx_pf_6cpyamf_4amf3_7Encoder_3writeObject, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6cpyamf_4amf3_Encoder[] = {
  {(char *)"use_proxies", __pyx_getprop_6cpyamf_4amf3_7Encoder_use_proxies, __pyx_setprop_6cpyamf_4amf3_7Encoder_use_proxies, 0, 0},
  {(char *)"context", __pyx_getprop_6cpyamf_4amf3_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_4amf3_Encoder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("cpyamf.amf3.Encoder"), /*tp_name*/
  sizeof(struct __pyx_obj_6cpyamf_4amf3_Encoder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6cpyamf_4amf3_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 AMF3 Encoder.\n    "), /*tp_doc*/
  __pyx_tp_traverse_6cpyamf_4amf3_Encoder, /*tp_traverse*/
  __pyx_tp_clear_6cpyamf_4amf3_Encoder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6cpyamf_4amf3_Encoder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6cpyamf_4amf3_Encoder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_6cpyamf_4amf3_7Encoder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6cpyamf_4amf3_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("amf3"),
    __Pyx_DOCSTR(__pyx_k_25), /* 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_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_n_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 1},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_n_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 1},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s__ASObject, __pyx_k__ASObject, sizeof(__pyx_k__ASObject), 0, 0, 1, 1},
  {&__pyx_n_s__ByteArray, __pyx_k__ByteArray, sizeof(__pyx_k__ByteArray), 0, 0, 1, 1},
  {&__pyx_n_s__DataInput, __pyx_k__DataInput, sizeof(__pyx_k__DataInput), 0, 0, 1, 1},
  {&__pyx_n_s__DataOutput, __pyx_k__DataOutput, sizeof(__pyx_k__DataOutput), 0, 0, 1, 1},
  {&__pyx_n_s__DecodeError, __pyx_k__DecodeError, sizeof(__pyx_k__DecodeError), 0, 0, 1, 1},
  {&__pyx_n_s__EncodeError, __pyx_k__EncodeError, sizeof(__pyx_k__EncodeError), 0, 0, 1, 1},
  {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__MixedArray, __pyx_k__MixedArray, sizeof(__pyx_k__MixedArray), 0, 0, 1, 1},
  {&__pyx_n_s__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__Undefined, __pyx_k__Undefined, sizeof(__pyx_k__Undefined), 0, 0, 1, 1},
  {&__pyx_n_s__UnknownClassAlias, __pyx_k__UnknownClassAlias, sizeof(__pyx_k__UnknownClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s__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____readamf__, __pyx_k____readamf__, sizeof(__pyx_k____readamf__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s____writeamf__, __pyx_k____writeamf__, sizeof(__pyx_k____writeamf__), 0, 0, 1, 1},
  {&__pyx_n_s___getClassDefinition, __pyx_k___getClassDefinition, sizeof(__pyx_k___getClassDefinition), 0, 0, 1, 1},
  {&__pyx_n_s___readDynamic, __pyx_k___readDynamic, sizeof(__pyx_k___readDynamic), 0, 0, 1, 1},
  {&__pyx_n_s___readStatic, __pyx_k___readStatic, sizeof(__pyx_k___readStatic), 0, 0, 1, 1},
  {&__pyx_n_s__addClass, __pyx_k__addClass, sizeof(__pyx_k__addClass), 0, 0, 1, 1},
  {&__pyx_n_s__addObject, __pyx_k__addObject, sizeof(__pyx_k__addObject), 0, 0, 1, 1},
  {&__pyx_n_s__addProxyObject, __pyx_k__addProxyObject, sizeof(__pyx_k__addProxyObject), 0, 0, 1, 1},
  {&__pyx_n_s__addString, __pyx_k__addString, sizeof(__pyx_k__addString), 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__anonymous, __pyx_k__anonymous, sizeof(__pyx_k__anonymous), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__applyAttributes, __pyx_k__applyAttributes, sizeof(__pyx_k__applyAttributes), 0, 0, 1, 1},
  {&__pyx_n_s__attr_len, __pyx_k__attr_len, sizeof(__pyx_k__attr_len), 0, 0, 1, 1},
  {&__pyx_n_s__class_idx, __pyx_k__class_idx, sizeof(__pyx_k__class_idx), 0, 0, 1, 1},
  {&__pyx_n_s__class_ref, __pyx_k__class_ref, sizeof(__pyx_k__class_ref), 0, 0, 1, 1},
  {&__pyx_n_s__classes, __pyx_k__classes, sizeof(__pyx_k__classes), 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__compressed, __pyx_k__compressed, sizeof(__pyx_k__compressed), 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__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__decompress, __pyx_k__decompress, sizeof(__pyx_k__decompress), 0, 0, 1, 1},
  {&__pyx_n_s__dynamic, __pyx_k__dynamic, sizeof(__pyx_k__dynamic), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__encoded_ref, __pyx_k__encoded_ref, sizeof(__pyx_k__encoded_ref), 0, 0, 1, 1},
  {&__pyx_n_s__encoded_ref_size, __pyx_k__encoded_ref_size, sizeof(__pyx_k__encoded_ref_size), 0, 0, 1, 1},
  {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1},
  {&__pyx_n_s__error, __pyx_k__error, sizeof(__pyx_k__error), 0, 0, 1, 1},
  {&__pyx_n_s__external, __pyx_k__external, sizeof(__pyx_k__external), 0, 0, 1, 1},
  {&__pyx_n_s__flex, __pyx_k__flex, sizeof(__pyx_k__flex), 0, 0, 1, 1},
  {&__pyx_n_s__fromstring, __pyx_k__fromstring, sizeof(__pyx_k__fromstring), 0, 0, 1, 1},
  {&__pyx_n_s__getByReference, __pyx_k__getByReference, sizeof(__pyx_k__getByReference), 0, 0, 1, 1},
  {&__pyx_n_s__getBytesForString, __pyx_k__getBytesForString, sizeof(__pyx_k__getBytesForString), 0, 0, 1, 1},
  {&__pyx_n_s__getClass, __pyx_k__getClass, sizeof(__pyx_k__getClass), 0, 0, 1, 1},
  {&__pyx_n_s__getClassAlias, __pyx_k__getClassAlias, sizeof(__pyx_k__getClassAlias), 0, 0, 1, 1},
  {&__pyx_n_s__getClassByReference, __pyx_k__getClassByReference, sizeof(__pyx_k__getClassByReference), 0, 0, 1, 1},
  {&__pyx_n_s__getObject, __pyx_k__getObject, sizeof(__pyx_k__getObject), 0, 0, 1, 1},
  {&__pyx_n_s__getObjectForProxy, __pyx_k__getObjectForProxy, sizeof(__pyx_k__getObjectForProxy), 0, 0, 1, 1},
  {&__pyx_n_s__getObjectReference, __pyx_k__getObjectReference, sizeof(__pyx_k__getObjectReference), 0, 0, 1, 1},
  {&__pyx_n_s__getProxyForObject, __pyx_k__getProxyForObject, sizeof(__pyx_k__getProxyForObject), 0, 0, 1, 1},
  {&__pyx_n_s__getReferenceTo, __pyx_k__getReferenceTo, sizeof(__pyx_k__getReferenceTo), 0, 0, 1, 1},
  {&__pyx_n_s__getString, __pyx_k__getString, sizeof(__pyx_k__getString), 0, 0, 1, 1},
  {&__pyx_n_s__getStringReference, __pyx_k__getStringReference, sizeof(__pyx_k__getStringReference), 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__index, __pyx_k__index, sizeof(__pyx_k__index), 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__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__klass, __pyx_k__klass, sizeof(__pyx_k__klass), 0, 0, 1, 1},
  {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
  {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 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__proxied, __pyx_k__proxied, sizeof(__pyx_k__proxied), 0, 0, 1, 1},
  {&__pyx_n_s__proxied_objects, __pyx_k__proxied_objects, sizeof(__pyx_k__proxied_objects), 0, 0, 1, 1},
  {&__pyx_n_s__proxy_object, __pyx_k__proxy_object, sizeof(__pyx_k__proxy_object), 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__readByteArray, __pyx_k__readByteArray, sizeof(__pyx_k__readByteArray), 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__readInteger, __pyx_k__readInteger, sizeof(__pyx_k__readInteger), 0, 0, 1, 1},
  {&__pyx_n_s__readList, __pyx_k__readList, sizeof(__pyx_k__readList), 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__readProxy, __pyx_k__readProxy, sizeof(__pyx_k__readProxy), 0, 0, 1, 1},
  {&__pyx_n_s__readString, __pyx_k__readString, sizeof(__pyx_k__readString), 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_uchar, __pyx_k__read_uchar, sizeof(__pyx_k__read_uchar), 0, 0, 1, 1},
  {&__pyx_n_s__ref, __pyx_k__ref, sizeof(__pyx_k__ref), 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__static_properties, __pyx_k__static_properties, sizeof(__pyx_k__static_properties), 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__strings, __pyx_k__strings, sizeof(__pyx_k__strings), 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__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
  {&__pyx_n_s__unproxy_object, __pyx_k__unproxy_object, sizeof(__pyx_k__unproxy_object), 0, 0, 1, 1},
  {&__pyx_n_s__use_hash, __pyx_k__use_hash, sizeof(__pyx_k__use_hash), 0, 0, 1, 1},
  {&__pyx_n_s__use_proxies, __pyx_k__use_proxies, sizeof(__pyx_k__use_proxies), 0, 0, 1, 1},
  {&__pyx_n_s__use_proxies_default, __pyx_k__use_proxies_default, sizeof(__pyx_k__use_proxies_default), 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__writeByteArray, __pyx_k__writeByteArray, sizeof(__pyx_k__writeByteArray), 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__writeNumber, __pyx_k__writeNumber, sizeof(__pyx_k__writeNumber), 0, 0, 1, 1},
  {&__pyx_n_s__writeObject, __pyx_k__writeObject, sizeof(__pyx_k__writeObject), 0, 0, 1, 1},
  {&__pyx_n_s__writeProxy, __pyx_k__writeProxy, sizeof(__pyx_k__writeProxy), 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_uchar, __pyx_k__write_uchar, sizeof(__pyx_k__write_uchar), 0, 0, 1, 1},
  {&__pyx_n_s__xml, __pyx_k__xml, sizeof(__pyx_k__xml), 0, 0, 1, 1},
  {&__pyx_n_s__zlib, __pyx_k__zlib, sizeof(__pyx_k__zlib), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __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 = 639; __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 = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

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

  /* "cpyamf/amf3.pyx":256
 * 
 *     def __init__(self, *args, **kwargs):
 *         context = kwargs.pop('context', None)             # <<<<<<<<<<<<<<
 * 
 *         if context is None:
 */
  __pyx_k_tuple_2 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __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/amf3.pyx":459
 * 
 *             if obj is None:
 *                 raise pyamf.ReferenceError('Unknown reference')             # <<<<<<<<<<<<<<
 * 
 *             if self.use_proxies == 1:
 */
  __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "cpyamf/amf3.pyx":487
 *             return obj
 *         else:
 *             raise pyamf.DecodeError("Unknown object encoding")             # <<<<<<<<<<<<<<
 * 
 *         alias.applyAttributes(obj, obj_attrs, codec=self)
 */
  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));

  /* "cpyamf/amf3.pyx":592
 *             return self.readXML()
 * 
 *         raise pyamf.DecodeError("Unsupported ActionScript type")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

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

  /* "cpyamf/amf3.pyx":639
 *             l = PyString_GET_SIZE(u)
 *         else:
 *             raise TypeError('Expected str or unicode')             # <<<<<<<<<<<<<<
 * 
 *         if l == 0:
 */
  __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_12));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
  PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_s_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12));

  /* "cpyamf/amf3.pyx":797
 *         # for more info
 *         if '' in n:
 *             raise pyamf.EncodeError("dicts cannot contain empty string keys")             # <<<<<<<<<<<<<<
 * 
 *         if self.use_proxies:
 */
  __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
  PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));

  /* "cpyamf/amf3.pyx":822
 *                 str_keys.append(x)
 *             else:
 *                 raise ValueError("Non int/str key value found in dict")             # <<<<<<<<<<<<<<
 * 
 *         # Make sure the integer keys are within range
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));

  /* "cpyamf/amf3.pyx":912
 * 
 *         if PyDict_CheckExact(attrs) != 1:
 *             raise TypeError('Expected dict for encodable attributes')             # <<<<<<<<<<<<<<
 * 
 *         if definition.attr_len > 0:
 */
  __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_20));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
  PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));

  /* "cpyamf/amf3.pyx":987
 *         self.context.addObject(obj)
 * 
 *         s = xml.tostring(obj).encode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         if not PyString_CheckExact(s):
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_22));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));

  /* "cpyamf/amf3.pyx":990
 * 
 *         if not PyString_CheckExact(s):
 *             raise TypeError('Expected string from xml serialization')             # <<<<<<<<<<<<<<
 * 
 *         i = PyString_GET_SIZE(s)
 */
  __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_24));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
  PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));

  /* "cpyamf/amf3.pyx":59
 * cdef object DataInput = amf3.DataInput
 * cdef object DataOutput = amf3.DataOutput
 * cdef str empty_string = str('')             # <<<<<<<<<<<<<<
 * cdef unicode empty_unicode = empty_string.decode('utf-8')
 * cdef object undefined = pyamf.Undefined
 */
  __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_26));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
  PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));

  /* "cpyamf/amf3.pyx":60
 * cdef object DataOutput = amf3.DataOutput
 * cdef str empty_string = str('')
 * cdef unicode empty_unicode = empty_string.decode('utf-8')             # <<<<<<<<<<<<<<
 * cdef object undefined = pyamf.Undefined
 * 
 */
  __pyx_k_tuple_27 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_27));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27));
  __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;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__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 initamf3(void); /*proto*/
PyMODINIT_FUNC initamf3(void)
#else
PyMODINIT_FUNC PyInit_amf3(void); /*proto*/
PyMODINIT_FUNC PyInit_amf3(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = 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_amf3(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("amf3"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_25), 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__amf3) {
    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_4amf3_ByteArrayType = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf3_DataInput = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf3_DataOutput = Py_None; Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf3_empty_string = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf3_empty_unicode = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6cpyamf_4amf3_undefined = Py_None; Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6cpyamf_4amf3_ClassDefinition = &__pyx_vtable_6cpyamf_4amf3_ClassDefinition;
  __pyx_vtable_6cpyamf_4amf3_ClassDefinition.writeReference = (int (*)(struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, struct __pyx_obj_6cpyamf_4util_cBufferedByteStream *))__pyx_f_6cpyamf_4amf3_15ClassDefinition_writeReference;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf3_ClassDefinition) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf3_ClassDefinition.tp_dict, __pyx_vtabptr_6cpyamf_4amf3_ClassDefinition) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "ClassDefinition", (PyObject *)&__pyx_type_6cpyamf_4amf3_ClassDefinition) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_ClassDefinition = &__pyx_type_6cpyamf_4amf3_ClassDefinition;
  __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_4amf3_Context = &__pyx_vtable_6cpyamf_4amf3_Context;
  __pyx_vtable_6cpyamf_4amf3_Context.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Context;
  __pyx_vtable_6cpyamf_4amf3_Context.__pyx_base.clear = (int (*)(struct __pyx_obj_6cpyamf_5codec_Context *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_clear;
  __pyx_vtable_6cpyamf_4amf3_Context.getString = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Context *, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getString;
  __pyx_vtable_6cpyamf_4amf3_Context.getStringReference = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getStringReference;
  __pyx_vtable_6cpyamf_4amf3_Context.addString = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_addString;
  __pyx_vtable_6cpyamf_4amf3_Context.addProxyObject = (int (*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_addProxyObject;
  __pyx_vtable_6cpyamf_4amf3_Context.getProxyForObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getProxyForObject;
  __pyx_vtable_6cpyamf_4amf3_Context.getObjectForProxy = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getObjectForProxy;
  __pyx_vtable_6cpyamf_4amf3_Context.getClassByReference = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Context *, Py_ssize_t, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getClassByReference;
  __pyx_vtable_6cpyamf_4amf3_Context.getClass = (struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *(*)(struct __pyx_obj_6cpyamf_4amf3_Context *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_getClass;
  __pyx_vtable_6cpyamf_4amf3_Context.addClass = (Py_ssize_t (*)(struct __pyx_obj_6cpyamf_4amf3_Context *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Context_addClass;
  __pyx_type_6cpyamf_4amf3_Context.tp_base = __pyx_ptype_6cpyamf_5codec_Context;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf3_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf3_Context.tp_dict, __pyx_vtabptr_6cpyamf_4amf3_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_6cpyamf_4amf3_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Context = &__pyx_type_6cpyamf_4amf3_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_4amf3_Decoder = &__pyx_vtable_6cpyamf_4amf3_Decoder;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Decoder;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readDate = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readDate;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readString = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Decoder_readString;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readObject = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readObject;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readNumber = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readNumber;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readList = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readList;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readXML = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readXML;
  __pyx_vtable_6cpyamf_4amf3_Decoder.__pyx_base.readConcreteElement = (PyObject *(*)(struct __pyx_obj_6cpyamf_5codec_Decoder *, char))__pyx_f_6cpyamf_4amf3_7Decoder_readConcreteElement;
  __pyx_vtable_6cpyamf_4amf3_Decoder._getClassDefinition = (struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *(*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, long))__pyx_f_6cpyamf_4amf3_7Decoder__getClassDefinition;
  __pyx_vtable_6cpyamf_4amf3_Decoder._readStatic = (int (*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *))__pyx_f_6cpyamf_4amf3_7Decoder__readStatic;
  __pyx_vtable_6cpyamf_4amf3_Decoder._readDynamic = (int (*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_obj_6cpyamf_4amf3_ClassDefinition *, PyObject *))__pyx_f_6cpyamf_4amf3_7Decoder__readDynamic;
  __pyx_vtable_6cpyamf_4amf3_Decoder.readBytes = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readBytes;
  __pyx_vtable_6cpyamf_4amf3_Decoder.readInteger = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, struct __pyx_opt_args_6cpyamf_4amf3_7Decoder_readInteger *__pyx_optional_args))__pyx_f_6cpyamf_4amf3_7Decoder_readInteger;
  __pyx_vtable_6cpyamf_4amf3_Decoder.readByteArray = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *))__pyx_f_6cpyamf_4amf3_7Decoder_readByteArray;
  __pyx_vtable_6cpyamf_4amf3_Decoder.readProxy = (PyObject *(*)(struct __pyx_obj_6cpyamf_4amf3_Decoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Decoder_readProxy;
  __pyx_type_6cpyamf_4amf3_Decoder.tp_base = __pyx_ptype_6cpyamf_5codec_Decoder;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf3_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf3_Decoder.tp_dict, __pyx_vtabptr_6cpyamf_4amf3_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_6cpyamf_4amf3_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Decoder = &__pyx_type_6cpyamf_4amf3_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_4amf3_Encoder = &__pyx_vtable_6cpyamf_4amf3_Encoder;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base = *__pyx_vtabptr_6cpyamf_5codec_Encoder;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.serialiseString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6cpyamf_4amf3_7Encoder_serialiseString;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeNull = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeNull;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeUndefined = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeUndefined;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeString = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeString;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeBytes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeBytes;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeBoolean = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeBoolean;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeInt = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeInt;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeLong = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeLong;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeNumber = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeNumber;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeDateTime = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeDateTime;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeXML = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeXML;
  __pyx_vtable_6cpyamf_4amf3_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_4amf3_7Encoder_writeList;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeTuple = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeTuple;
  __pyx_vtable_6cpyamf_4amf3_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_4amf3_7Encoder_writeObject;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeDict = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeDict;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.writeMixedArray = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeMixedArray;
  __pyx_vtable_6cpyamf_4amf3_Encoder.__pyx_base.handleBasicTypes = (int (*)(struct __pyx_obj_6cpyamf_5codec_Encoder *, PyObject *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_handleBasicTypes;
  __pyx_vtable_6cpyamf_4amf3_Encoder.writeByteArray = (int (*)(struct __pyx_obj_6cpyamf_4amf3_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeByteArray;
  __pyx_vtable_6cpyamf_4amf3_Encoder.writeProxy = (int (*)(struct __pyx_obj_6cpyamf_4amf3_Encoder *, PyObject *))__pyx_f_6cpyamf_4amf3_7Encoder_writeProxy;
  __pyx_type_6cpyamf_4amf3_Encoder.tp_base = __pyx_ptype_6cpyamf_5codec_Encoder;
  if (PyType_Ready(&__pyx_type_6cpyamf_4amf3_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6cpyamf_4amf3_Encoder.tp_dict, __pyx_vtabptr_6cpyamf_4amf3_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Encoder", (PyObject *)&__pyx_type_6cpyamf_4amf3_Encoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4amf3_Encoder = &__pyx_type_6cpyamf_4amf3_Encoder;
  /*--- Type import code ---*/
  __pyx_ptype_6cpyamf_4util_cBufferedByteStream = __Pyx_ImportType("cpyamf.util", "cBufferedByteStream", sizeof(struct __pyx_obj_6cpyamf_4util_cBufferedByteStream), 1); if (unlikely(!__pyx_ptype_6cpyamf_4util_cBufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4util_cBufferedByteStream = (struct __pyx_vtabstruct_6cpyamf_4util_cBufferedByteStream*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4util_cBufferedByteStream->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4util_cBufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6cpyamf_4util_BufferedByteStream = __Pyx_ImportType("cpyamf.util", "BufferedByteStream", sizeof(struct __pyx_obj_6cpyamf_4util_BufferedByteStream), 1); if (unlikely(!__pyx_ptype_6cpyamf_4util_BufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_6cpyamf_4util_BufferedByteStream = (struct __pyx_vtabstruct_6cpyamf_4util_BufferedByteStream*)__Pyx_GetVtable(__pyx_ptype_6cpyamf_4util_BufferedByteStream->tp_dict); if (unlikely(!__pyx_vtabptr_6cpyamf_4util_BufferedByteStream)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_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[3]; __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[3]; __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[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[4]; __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[5]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

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

  /* "cpyamf/amf3.pyx":18
 * from cpyamf cimport codec
 * import pyamf
 * from pyamf import util, amf3, xml             # <<<<<<<<<<<<<<
 * import types
 * 
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__util));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__util));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__util));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__amf3));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__amf3));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__amf3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xml));
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__xml));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xml));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__pyamf), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__util); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __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 = 18; __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__amf3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__amf3, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__xml); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __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 = 18; __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/amf3.pyx":19
 * import pyamf
 * from pyamf import util, amf3, xml
 * import types             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cpyamf/amf3.pyx":22
 * 
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import zlib
 * except ImportError:
 */
  {
    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/amf3.pyx":23
 * 
 * try:
 *     import zlib             # <<<<<<<<<<<<<<
 * except ImportError:
 *     zlib = None
 */
      __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__zlib), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__zlib, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cpyamf/amf3.pyx":24
 * try:
 *     import zlib
 * except ImportError:             # <<<<<<<<<<<<<<
 *     zlib = None
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("cpyamf.amf3");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "cpyamf/amf3.pyx":25
 *     import zlib
 * except ImportError:
 *     zlib = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__zlib, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L3_exception_handled;
    }
    __pyx_L4_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_L3_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_L9_try_end:;
  }

  /* "cpyamf/amf3.pyx":28
 * 
 * 
 * cdef char TYPE_UNDEFINED = '\x00'             # <<<<<<<<<<<<<<
 * cdef char TYPE_NULL = '\x01'
 * cdef char TYPE_BOOL_FALSE = '\x02'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_UNDEFINED = '\x00';

  /* "cpyamf/amf3.pyx":29
 * 
 * cdef char TYPE_UNDEFINED = '\x00'
 * cdef char TYPE_NULL = '\x01'             # <<<<<<<<<<<<<<
 * cdef char TYPE_BOOL_FALSE = '\x02'
 * cdef char TYPE_BOOL_TRUE = '\x03'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_NULL = '\x01';

  /* "cpyamf/amf3.pyx":30
 * cdef char TYPE_UNDEFINED = '\x00'
 * cdef char TYPE_NULL = '\x01'
 * cdef char TYPE_BOOL_FALSE = '\x02'             # <<<<<<<<<<<<<<
 * cdef char TYPE_BOOL_TRUE = '\x03'
 * cdef char TYPE_INTEGER = '\x04'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_BOOL_FALSE = '\x02';

  /* "cpyamf/amf3.pyx":31
 * cdef char TYPE_NULL = '\x01'
 * cdef char TYPE_BOOL_FALSE = '\x02'
 * cdef char TYPE_BOOL_TRUE = '\x03'             # <<<<<<<<<<<<<<
 * cdef char TYPE_INTEGER = '\x04'
 * cdef char TYPE_NUMBER = '\x05'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_BOOL_TRUE = '\x03';

  /* "cpyamf/amf3.pyx":32
 * cdef char TYPE_BOOL_FALSE = '\x02'
 * cdef char TYPE_BOOL_TRUE = '\x03'
 * cdef char TYPE_INTEGER = '\x04'             # <<<<<<<<<<<<<<
 * cdef char TYPE_NUMBER = '\x05'
 * cdef char TYPE_STRING = '\x06'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_INTEGER = '\x04';

  /* "cpyamf/amf3.pyx":33
 * cdef char TYPE_BOOL_TRUE = '\x03'
 * cdef char TYPE_INTEGER = '\x04'
 * cdef char TYPE_NUMBER = '\x05'             # <<<<<<<<<<<<<<
 * cdef char TYPE_STRING = '\x06'
 * cdef char TYPE_XML = '\x07'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_NUMBER = '\x05';

  /* "cpyamf/amf3.pyx":34
 * cdef char TYPE_INTEGER = '\x04'
 * cdef char TYPE_NUMBER = '\x05'
 * cdef char TYPE_STRING = '\x06'             # <<<<<<<<<<<<<<
 * cdef char TYPE_XML = '\x07'
 * cdef char TYPE_DATE = '\x08'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_STRING = '\x06';

  /* "cpyamf/amf3.pyx":35
 * cdef char TYPE_NUMBER = '\x05'
 * cdef char TYPE_STRING = '\x06'
 * cdef char TYPE_XML = '\x07'             # <<<<<<<<<<<<<<
 * cdef char TYPE_DATE = '\x08'
 * cdef char TYPE_ARRAY = '\x09'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_XML = '\x07';

  /* "cpyamf/amf3.pyx":36
 * cdef char TYPE_STRING = '\x06'
 * cdef char TYPE_XML = '\x07'
 * cdef char TYPE_DATE = '\x08'             # <<<<<<<<<<<<<<
 * cdef char TYPE_ARRAY = '\x09'
 * cdef char TYPE_OBJECT = '\x0A'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_DATE = '\x08';

  /* "cpyamf/amf3.pyx":37
 * cdef char TYPE_XML = '\x07'
 * cdef char TYPE_DATE = '\x08'
 * cdef char TYPE_ARRAY = '\x09'             # <<<<<<<<<<<<<<
 * cdef char TYPE_OBJECT = '\x0A'
 * cdef char TYPE_XMLSTRING = '\x0B'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_ARRAY = '\t';

  /* "cpyamf/amf3.pyx":38
 * cdef char TYPE_DATE = '\x08'
 * cdef char TYPE_ARRAY = '\x09'
 * cdef char TYPE_OBJECT = '\x0A'             # <<<<<<<<<<<<<<
 * cdef char TYPE_XMLSTRING = '\x0B'
 * cdef char TYPE_BYTEARRAY = '\x0C'
 */
  __pyx_v_6cpyamf_4amf3_TYPE_OBJECT = '\n';

  /* "cpyamf/amf3.pyx":39
 * cdef char TYPE_ARRAY = '\x09'
 * cdef char TYPE_OBJECT = '\x0A'
 * cdef char TYPE_XMLSTRING = '\x0B'             # <<<<<<<<<<<<<<
 * cdef char TYPE_BYTEARRAY = '\x0C'
 * 
 */
  __pyx_v_6cpyamf_4amf3_TYPE_XMLSTRING = '\x0B';

  /* "cpyamf/amf3.pyx":40
 * cdef char TYPE_OBJECT = '\x0A'
 * cdef char TYPE_XMLSTRING = '\x0B'
 * cdef char TYPE_BYTEARRAY = '\x0C'             # <<<<<<<<<<<<<<
 * 
 * cdef unsigned int REFERENCE_BIT = 0x01
 */
  __pyx_v_6cpyamf_4amf3_TYPE_BYTEARRAY = '\x0C';

  /* "cpyamf/amf3.pyx":42
 * cdef char TYPE_BYTEARRAY = '\x0C'
 * 
 * cdef unsigned int REFERENCE_BIT = 0x01             # <<<<<<<<<<<<<<
 * cdef char REF_CHAR = '\x01'
 * 
 */
  __pyx_v_6cpyamf_4amf3_REFERENCE_BIT = 0x01;

  /* "cpyamf/amf3.pyx":43
 * 
 * cdef unsigned int REFERENCE_BIT = 0x01
 * cdef char REF_CHAR = '\x01'             # <<<<<<<<<<<<<<
 * 
 * #: The maximum that can be represented by an signed 29 bit integer.
 */
  __pyx_v_6cpyamf_4amf3_REF_CHAR = '\x01';

  /* "cpyamf/amf3.pyx":46
 * 
 * #: The maximum that can be represented by an signed 29 bit integer.
 * cdef long MAX_29B_INT = 0x0FFFFFFF             # <<<<<<<<<<<<<<
 * 
 * #: The minimum that can be represented by an signed 29 bit integer.
 */
  __pyx_v_6cpyamf_4amf3_MAX_29B_INT = 0x0FFFFFFF;

  /* "cpyamf/amf3.pyx":49
 * 
 * #: The minimum that can be represented by an signed 29 bit integer.
 * cdef long MIN_29B_INT = -0x10000000             # <<<<<<<<<<<<<<
 * 
 * cdef int OBJECT_ENCODING_STATIC = 0x00
 */
  __pyx_v_6cpyamf_4amf3_MIN_29B_INT = -268435456;

  /* "cpyamf/amf3.pyx":51
 * cdef long MIN_29B_INT = -0x10000000
 * 
 * cdef int OBJECT_ENCODING_STATIC = 0x00             # <<<<<<<<<<<<<<
 * cdef int OBJECT_ENCODING_EXTERNAL = 0x01
 * cdef int OBJECT_ENCODING_DYNAMIC = 0x02
 */
  __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_STATIC = 0x00;

  /* "cpyamf/amf3.pyx":52
 * 
 * cdef int OBJECT_ENCODING_STATIC = 0x00
 * cdef int OBJECT_ENCODING_EXTERNAL = 0x01             # <<<<<<<<<<<<<<
 * cdef int OBJECT_ENCODING_DYNAMIC = 0x02
 * cdef int OBJECT_ENCODING_PROXY = 0x03
 */
  __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_EXTERNAL = 0x01;

  /* "cpyamf/amf3.pyx":53
 * cdef int OBJECT_ENCODING_STATIC = 0x00
 * cdef int OBJECT_ENCODING_EXTERNAL = 0x01
 * cdef int OBJECT_ENCODING_DYNAMIC = 0x02             # <<<<<<<<<<<<<<
 * cdef int OBJECT_ENCODING_PROXY = 0x03
 * 
 */
  __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_DYNAMIC = 0x02;

  /* "cpyamf/amf3.pyx":54
 * cdef int OBJECT_ENCODING_EXTERNAL = 0x01
 * cdef int OBJECT_ENCODING_DYNAMIC = 0x02
 * cdef int OBJECT_ENCODING_PROXY = 0x03             # <<<<<<<<<<<<<<
 * 
 * cdef object ByteArrayType = amf3.ByteArray
 */
  __pyx_v_6cpyamf_4amf3_OBJECT_ENCODING_PROXY = 0x03;

  /* "cpyamf/amf3.pyx":56
 * cdef int OBJECT_ENCODING_PROXY = 0x03
 * 
 * cdef object ByteArrayType = amf3.ByteArray             # <<<<<<<<<<<<<<
 * cdef object DataInput = amf3.DataInput
 * cdef object DataOutput = amf3.DataOutput
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__amf3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ByteArray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_4amf3_ByteArrayType);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf3_ByteArrayType);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_4amf3_ByteArrayType = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":57
 * 
 * cdef object ByteArrayType = amf3.ByteArray
 * cdef object DataInput = amf3.DataInput             # <<<<<<<<<<<<<<
 * cdef object DataOutput = amf3.DataOutput
 * cdef str empty_string = str('')
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__amf3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DataInput); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_4amf3_DataInput);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf3_DataInput);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_v_6cpyamf_4amf3_DataInput = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cpyamf/amf3.pyx":58
 * cdef object ByteArrayType = amf3.ByteArray
 * cdef object DataInput = amf3.DataInput
 * cdef object DataOutput = amf3.DataOutput             # <<<<<<<<<<<<<<
 * cdef str empty_string = str('')
 * cdef unicode empty_unicode = empty_string.decode('utf-8')
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__amf3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__DataOutput); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_4amf3_DataOutput);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf3_DataOutput);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_4amf3_DataOutput = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":59
 * cdef object DataInput = amf3.DataInput
 * cdef object DataOutput = amf3.DataOutput
 * cdef str empty_string = str('')             # <<<<<<<<<<<<<<
 * cdef unicode empty_unicode = empty_string.decode('utf-8')
 * cdef object undefined = pyamf.Undefined
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_string));
  __Pyx_DECREF(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_string));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_4amf3_empty_string = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":60
 * cdef object DataOutput = amf3.DataOutput
 * cdef str empty_string = str('')
 * cdef unicode empty_unicode = empty_string.decode('utf-8')             # <<<<<<<<<<<<<<
 * cdef object undefined = pyamf.Undefined
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_string), __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_unicode));
  __Pyx_DECREF(((PyObject *)__pyx_v_6cpyamf_4amf3_empty_unicode));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_v_6cpyamf_4amf3_empty_unicode = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cpyamf/amf3.pyx":61
 * cdef str empty_string = str('')
 * cdef unicode empty_unicode = empty_string.decode('utf-8')
 * cdef object undefined = pyamf.Undefined             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__pyamf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__Undefined); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GOTREF(__pyx_v_6cpyamf_4amf3_undefined);
  __Pyx_DECREF(__pyx_v_6cpyamf_4amf3_undefined);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6cpyamf_4amf3_undefined = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpyamf/amf3.pyx":1
 * # Copyright (c) The PyAMF Project.             # <<<<<<<<<<<<<<
 * # See LICENSE.txt for details.
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 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);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    __Pyx_AddTraceback("init cpyamf.amf3");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cpyamf.amf3");
  }
  __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 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_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;
}


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



#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 double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
        return PyFloat_AsDouble(obj);
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-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;
    }
}

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
