1 /* Generated by Cython 0.15.1 on Tue Mar 27 07:16:06 2012 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6     #error Python headers needed to compile C extensions, please install development version of Python.
7 #else
8 
9 #include <stddef.h> /* For offsetof */
10 #ifndef offsetof
11 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
12 #endif
13 
14 #if !defined(WIN32) && !defined(MS_WINDOWS)
15   #ifndef __stdcall
16     #define __stdcall
17   #endif
18   #ifndef __cdecl
19     #define __cdecl
20   #endif
21   #ifndef __fastcall
22     #define __fastcall
23   #endif
24 #endif
25 
26 #ifndef DL_IMPORT
27   #define DL_IMPORT(t) t
28 #endif
29 #ifndef DL_EXPORT
30   #define DL_EXPORT(t) t
31 #endif
32 
33 #ifndef PY_LONG_LONG
34   #define PY_LONG_LONG LONG_LONG
35 #endif
36 
37 #if PY_VERSION_HEX < 0x02040000
38   #define METH_COEXIST 0
39   #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
40   #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
41 #endif
42 
43 #if PY_VERSION_HEX < 0x02050000
44   typedef int Py_ssize_t;
45   #define PY_SSIZE_T_MAX INT_MAX
46   #define PY_SSIZE_T_MIN INT_MIN
47   #define PY_FORMAT_SIZE_T ""
48   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
49   #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
50   #define PyNumber_Index(o)    PyNumber_Int(o)
51   #define PyIndex_Check(o)     PyNumber_Check(o)
52   #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
53 #endif
54 
55 #if PY_VERSION_HEX < 0x02060000
56   #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
57   #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
58   #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
59   #define PyVarObject_HEAD_INIT(type, size) \
60           PyObject_HEAD_INIT(type) size,
61   #define PyType_Modified(t)
62 
63   typedef struct {
64      void *buf;
65      PyObject *obj;
66      Py_ssize_t len;
67      Py_ssize_t itemsize;
68      int readonly;
69      int ndim;
70      char *format;
71      Py_ssize_t *shape;
72      Py_ssize_t *strides;
73      Py_ssize_t *suboffsets;
74      void *internal;
75   } Py_buffer;
76 
77   #define PyBUF_SIMPLE 0
78   #define PyBUF_WRITABLE 0x0001
79   #define PyBUF_FORMAT 0x0004
80   #define PyBUF_ND 0x0008
81   #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
82   #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
83   #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
84   #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
85   #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
86 
87 #endif
88 
89 #if PY_MAJOR_VERSION < 3
90   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
91 #else
92   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
93 #endif
94 
95 #if PY_MAJOR_VERSION >= 3
96   #define Py_TPFLAGS_CHECKTYPES 0
97   #define Py_TPFLAGS_HAVE_INDEX 0
98 #endif
99 
100 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
101   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
102 #endif
103 
104 #if PY_MAJOR_VERSION >= 3
105   #define PyBaseString_Type            PyUnicode_Type
106   #define PyStringObject               PyUnicodeObject
107   #define PyString_Type                PyUnicode_Type
108   #define PyString_Check               PyUnicode_Check
109   #define PyString_CheckExact          PyUnicode_CheckExact
110 #endif
111 
112 #if PY_VERSION_HEX < 0x02060000
113   #define PyBytesObject                PyStringObject
114   #define PyBytes_Type                 PyString_Type
115   #define PyBytes_Check                PyString_Check
116   #define PyBytes_CheckExact           PyString_CheckExact
117   #define PyBytes_FromString           PyString_FromString
118   #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
119   #define PyBytes_FromFormat           PyString_FromFormat
120   #define PyBytes_DecodeEscape         PyString_DecodeEscape
121   #define PyBytes_AsString             PyString_AsString
122   #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
123   #define PyBytes_Size                 PyString_Size
124   #define PyBytes_AS_STRING            PyString_AS_STRING
125   #define PyBytes_GET_SIZE             PyString_GET_SIZE
126   #define PyBytes_Repr                 PyString_Repr
127   #define PyBytes_Concat               PyString_Concat
128   #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
129 #endif
130 
131 #if PY_VERSION_HEX < 0x02060000
132   #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
133   #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
134 #endif
135 #ifndef PySet_CheckExact
136   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
137 #endif
138 
139 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
140 
141 #if PY_MAJOR_VERSION >= 3
142   #define PyIntObject                  PyLongObject
143   #define PyInt_Type                   PyLong_Type
144   #define PyInt_Check(op)              PyLong_Check(op)
145   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
146   #define PyInt_FromString             PyLong_FromString
147   #define PyInt_FromUnicode            PyLong_FromUnicode
148   #define PyInt_FromLong               PyLong_FromLong
149   #define PyInt_FromSize_t             PyLong_FromSize_t
150   #define PyInt_FromSsize_t            PyLong_FromSsize_t
151   #define PyInt_AsLong                 PyLong_AsLong
152   #define PyInt_AS_LONG                PyLong_AS_LONG
153   #define PyInt_AsSsize_t              PyLong_AsSsize_t
154   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
155   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
156 #endif
157 
158 #if PY_MAJOR_VERSION >= 3
159   #define PyBoolObject                 PyLongObject
160 #endif
161 
162 #if PY_VERSION_HEX < 0x03020000
163   typedef long Py_hash_t;
164   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
165   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
166 #else
167   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
168   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
169 #endif
170 
171 
172 #if PY_MAJOR_VERSION >= 3
173   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
174   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
175 #else
176   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
177   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
178 #endif
179 
180 #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
181   #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
182   #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
183   #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
184 #else
185   #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
186         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
187         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
188             (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
189   #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
190         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
191         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
192             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
193   #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
194         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
195         (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
196             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
197 #endif
198 
199 #if PY_MAJOR_VERSION >= 3
200   #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
201 #endif
202 
203 #if PY_VERSION_HEX < 0x02050000
204   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
205   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
206   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
207 #else
208   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
209   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
210   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
211 #endif
212 
213 #if PY_VERSION_HEX < 0x02050000
214   #define __Pyx_NAMESTR(n) ((char *)(n))
215   #define __Pyx_DOCSTR(n)  ((char *)(n))
216 #else
217   #define __Pyx_NAMESTR(n) (n)
218   #define __Pyx_DOCSTR(n)  (n)
219 #endif
220 
221 #ifndef __PYX_EXTERN_C
222   #ifdef __cplusplus
223     #define __PYX_EXTERN_C extern "C"
224   #else
225     #define __PYX_EXTERN_C extern
226   #endif
227 #endif
228 
229 #if defined(WIN32) || defined(MS_WINDOWS)
230 #define _USE_MATH_DEFINES
231 #endif
232 #include <math.h>
233 #define __PYX_HAVE__iocpsupport
234 #define __PYX_HAVE_API__iocpsupport
235 #include "io.h"
236 #include "errno.h"
237 #include "winsock2.h"
238 #include "ws2tcpip.h"
239 #include "windows.h"
240 #include "python.h"
241 #include "string.h"
242 #include "winsock_pointers.h"
243 #ifdef _OPENMP
244 #include <omp.h>
245 #endif /* _OPENMP */
246 
247 #ifdef PYREX_WITHOUT_ASSERTIONS
248 #define CYTHON_WITHOUT_ASSERTIONS
249 #endif
250 
251 
252 /* inline attribute */
253 #ifndef CYTHON_INLINE
254   #if defined(__GNUC__)
255     #define CYTHON_INLINE __inline__
256   #elif defined(_MSC_VER)
257     #define CYTHON_INLINE __inline
258   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
259     #define CYTHON_INLINE inline
260   #else
261     #define CYTHON_INLINE
262   #endif
263 #endif
264 
265 /* unused attribute */
266 #ifndef CYTHON_UNUSED
267 # if defined(__GNUC__)
268 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
269 #     define CYTHON_UNUSED __attribute__ ((__unused__))
270 #   else
271 #     define CYTHON_UNUSED
272 #   endif
273 # elif defined(__ICC) || defined(__INTEL_COMPILER)
274 #   define CYTHON_UNUSED __attribute__ ((__unused__))
275 # else
276 #   define CYTHON_UNUSED
277 # endif
278 #endif
279 
280 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*/
281 
282 
283 /* Type Conversion Predeclarations */
284 
285 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
286 #define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
287 
288 #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
289 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
290 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
291 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
292 
293 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
294 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
295 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
296 
297 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
298 
299 
300 #ifdef __GNUC__
301   /* Test for GCC > 2.95 */
302   #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
303     #define likely(x)   __builtin_expect(!!(x), 1)
304     #define unlikely(x) __builtin_expect(!!(x), 0)
305   #else /* __GNUC__ > 2 ... */
306     #define likely(x)   (x)
307     #define unlikely(x) (x)
308   #endif /* __GNUC__ > 2 ... */
309 #else /* __GNUC__ */
310   #define likely(x)   (x)
311   #define unlikely(x) (x)
312 #endif /* __GNUC__ */
313 
314 static PyObject *__pyx_m;
315 static PyObject *__pyx_b;
316 static PyObject *__pyx_empty_tuple;
317 static PyObject *__pyx_empty_bytes;
318 static int __pyx_lineno;
319 static int __pyx_clineno = 0;
320 static const char * __pyx_cfilenm= __FILE__;
321 static const char *__pyx_filename;
322 
323 
324 static const char *__pyx_f[] = {
325   "iocpsupport.pyx",
326   "acceptex.pxi",
327   "connectex.pxi",
328   "wsarecv.pxi",
329   "wsasend.pxi",
330 };
331 
332 /* "iocpsupport.pyx":6
333  *
334  * # HANDLE and SOCKET are pointer-sized (they are 64 bit wide in 64-bit builds)
335  * ctypedef size_t HANDLE             # <<<<<<<<<<<<<<
336  * ctypedef size_t SOCKET
337  * ctypedef unsigned long DWORD
338  */
339 typedef size_t __pyx_t_11iocpsupport_HANDLE;
340 
341 /* "iocpsupport.pyx":7
342  * # HANDLE and SOCKET are pointer-sized (they are 64 bit wide in 64-bit builds)
343  * ctypedef size_t HANDLE
344  * ctypedef size_t SOCKET             # <<<<<<<<<<<<<<
345  * ctypedef unsigned long DWORD
346  * # it's really a pointer, but we use it as an integer
347  */
348 typedef size_t __pyx_t_11iocpsupport_SOCKET;
349 
350 /* "iocpsupport.pyx":8
351  * ctypedef size_t HANDLE
352  * ctypedef size_t SOCKET
353  * ctypedef unsigned long DWORD             # <<<<<<<<<<<<<<
354  * # it's really a pointer, but we use it as an integer
355  * ctypedef size_t ULONG_PTR
356  */
357 typedef unsigned long __pyx_t_11iocpsupport_DWORD;
358 
359 /* "iocpsupport.pyx":10
360  * ctypedef unsigned long DWORD
361  * # it's really a pointer, but we use it as an integer
362  * ctypedef size_t ULONG_PTR             # <<<<<<<<<<<<<<
363  * ctypedef int BOOL
364  *
365  */
366 typedef size_t __pyx_t_11iocpsupport_ULONG_PTR;
367 
368 /* "iocpsupport.pyx":11
369  * # it's really a pointer, but we use it as an integer
370  * ctypedef size_t ULONG_PTR
371  * ctypedef int BOOL             # <<<<<<<<<<<<<<
372  *
373  * cdef extern from 'io.h':
374  */
375 typedef int __pyx_t_11iocpsupport_BOOL;
376 
377 /*--- Type declarations ---*/
378 struct __pyx_obj_11iocpsupport_CompletionPort;
379 struct __pyx_t_11iocpsupport_myOVERLAPPED;
380 
381 /* "iocpsupport.pyx":124
382  * #    BOOL (*lpTransmitFile)(SOCKET s, HANDLE hFile, DWORD size, DWORD buffer_size, OVERLAPPED *ov, TRANSMIT_FILE_BUFFERS *buff, DWORD flags)
383  *
384  * cdef struct myOVERLAPPED:             # <<<<<<<<<<<<<<
385  *     OVERLAPPED ov
386  *     PyObject *obj
387  */
388 struct __pyx_t_11iocpsupport_myOVERLAPPED {
389   OVERLAPPED ov;
390   struct PyObject *obj;
391 };
392 
393 /* "iocpsupport.pyx":148
394  *             setattr(self, k, v)
395  *
396  * cdef class CompletionPort:             # <<<<<<<<<<<<<<
397  *     cdef HANDLE port
398  *     def __init__(self):
399  */
400 struct __pyx_obj_11iocpsupport_CompletionPort {
401   PyObject_HEAD
402   __pyx_t_11iocpsupport_HANDLE port;
403 };
404 
405 
406 #ifndef CYTHON_REFNANNY
407   #define CYTHON_REFNANNY 0
408 #endif
409 
410 #if CYTHON_REFNANNY
411   typedef struct {
412     void (*INCREF)(void*, PyObject*, int);
413     void (*DECREF)(void*, PyObject*, int);
414     void (*GOTREF)(void*, PyObject*, int);
415     void (*GIVEREF)(void*, PyObject*, int);
416     void* (*SetupContext)(const char*, int, const char*);
417     void (*FinishContext)(void**);
418   } __Pyx_RefNannyAPIStruct;
419   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
420   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
421   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
422   #define __Pyx_RefNannySetupContext(name)           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
423   #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
424   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
425   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
426   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
427   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
428   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
429   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
430   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
431   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
432 #else
433   #define __Pyx_RefNannyDeclarations
434   #define __Pyx_RefNannySetupContext(name)
435   #define __Pyx_RefNannyFinishContext()
436   #define __Pyx_INCREF(r) Py_INCREF(r)
437   #define __Pyx_DECREF(r) Py_DECREF(r)
438   #define __Pyx_GOTREF(r)
439   #define __Pyx_GIVEREF(r)
440   #define __Pyx_XINCREF(r) Py_XINCREF(r)
441   #define __Pyx_XDECREF(r) Py_XDECREF(r)
442   #define __Pyx_XGOTREF(r)
443   #define __Pyx_XGIVEREF(r)
444 #endif /* CYTHON_REFNANNY */
445 
446 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
447 
448 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
449 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
450 
451 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
452 
453 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
454     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
455 
456 static void __Pyx_RaiseDoubleKeywordsError(
457     const char* func_name, PyObject* kw_name); /*proto*/
458 
459 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
460 
461 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
462 
463 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
464 
465 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
466 
467 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
468     const char* function_name, int kw_allowed); /*proto*/
469 
470 
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)471 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
472     PyObject *r;
473     if (!j) return NULL;
474     r = PyObject_GetItem(o, j);
475     Py_DECREF(j);
476     return r;
477 }
478 
479 
480 #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
481                                                     __Pyx_GetItemInt_List_Fast(o, i) : \
482                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
483 
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i)484 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
485     if (likely(o != Py_None)) {
486         if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
487             PyObject *r = PyList_GET_ITEM(o, i);
488             Py_INCREF(r);
489             return r;
490         }
491         else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
492             PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
493             Py_INCREF(r);
494             return r;
495         }
496     }
497     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
498 }
499 
500 #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
501                                                     __Pyx_GetItemInt_Tuple_Fast(o, i) : \
502                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
503 
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i)504 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
505     if (likely(o != Py_None)) {
506         if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
507             PyObject *r = PyTuple_GET_ITEM(o, i);
508             Py_INCREF(r);
509             return r;
510         }
511         else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
512             PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
513             Py_INCREF(r);
514             return r;
515         }
516     }
517     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
518 }
519 
520 
521 #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
522                                                     __Pyx_GetItemInt_Fast(o, i) : \
523                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
524 
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i)525 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
526     PyObject *r;
527     if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
528         r = PyList_GET_ITEM(o, i);
529         Py_INCREF(r);
530     }
531     else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
532         r = PyTuple_GET_ITEM(o, i);
533         Py_INCREF(r);
534     }
535     else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
536         r = PySequence_GetItem(o, i);
537     }
538     else {
539         r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
540     }
541     return r;
542 }
543 
544 static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
545 
546 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
547                                    PyObject *modname); /*proto*/
548 
549 #define __pyx_binding_PyCFunctionType_USED 1
550 
551 typedef struct {
552     PyCFunctionObject func;
553 } __pyx_binding_PyCFunctionType_object;
554 
555 static PyTypeObject __pyx_binding_PyCFunctionType_type;
556 static PyTypeObject *__pyx_binding_PyCFunctionType = NULL;
557 
558 static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module); /* proto */
559 #define __pyx_binding_PyCFunctionType_New(ml, self) __pyx_binding_PyCFunctionType_NewEx(ml, self, NULL)
560 
561 static int __pyx_binding_PyCFunctionType_init(void); /* proto */
562 
563 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
564 
565 #include <string.h>
566 
567 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
568 
569 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
570 
571 #if PY_MAJOR_VERSION >= 3
572 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
573 #else
574 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
575 #endif
576 
577 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
578 
579 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
580 
581 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
582 
583 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
584 
585 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
586 
587 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
588 
589 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
590 
591 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
592 
593 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
594 
595 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
596 
597 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
598 
599 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
600 
601 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
602 
603 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
604 
605 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
606 
607 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
608 
609 static int __Pyx_check_binary_version(void);
610 
611 static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
612                                int __pyx_lineno, const char *__pyx_filename); /*proto*/
613 
614 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
615 
616 /* Module declarations from 'iocpsupport' */
617 static PyTypeObject *__pyx_ptype_11iocpsupport_CompletionPort = 0;
618 static struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_f_11iocpsupport_makeOV(void); /*proto*/
619 static void __pyx_f_11iocpsupport_raise_error(int, PyObject *); /*proto*/
620 static PyObject *__pyx_f_11iocpsupport__makesockaddr(struct sockaddr *, Py_ssize_t); /*proto*/
621 static PyObject *__pyx_f_11iocpsupport_fillinetaddr(struct sockaddr_in *, PyObject *); /*proto*/
622 static PyObject *__pyx_f_11iocpsupport_fillinet6addr(struct sockaddr_in6 *, PyObject *); /*proto*/
623 static int __pyx_f_11iocpsupport_getAddrFamily(__pyx_t_11iocpsupport_SOCKET); /*proto*/
624 #define __Pyx_MODULE_NAME "iocpsupport"
625 int __pyx_module_is_main_iocpsupport = 0;
626 
627 /* Implementation of 'iocpsupport' */
628 static PyObject *__pyx_builtin_ValueError;
629 static PyObject *__pyx_builtin_MemoryError;
630 static PyObject *__pyx_builtin_RuntimeError;
631 static char __pyx_k_1[] = "CreateIoCompletionPort";
632 static char __pyx_k_2[] = "PostQueuedCompletionStatus";
633 static char __pyx_k_3[] = ":";
634 static char __pyx_k_5[] = "[";
635 static char __pyx_k_6[] = "]";
636 static char __pyx_k_7[] = "invalid IP address";
637 static char __pyx_k_8[] = "%";
638 static char __pyx_k_10[] = "invalid IPv6 address %r";
639 static char __pyx_k_11[] = "undefined error occurred during address parsing";
640 static char __pyx_k_12[] = "ConnectEx is not available on this system";
641 static char __pyx_k_13[] = "unsupported address family";
642 static char __pyx_k_14[] = "second argument needs to be a list";
643 static char __pyx_k_15[] = "length of address length buffer needs to be sizeof(int)";
644 static char __pyx_k_16[] = "Failed to initialize Winsock function vectors";
645 static char __pyx_k__s[] = "s";
646 static char __pyx_k__key[] = "key";
647 static char __pyx_k__obj[] = "obj";
648 static char __pyx_k__addr[] = "addr";
649 static char __pyx_k__buff[] = "buff";
650 static char __pyx_k__recv[] = "recv";
651 static char __pyx_k__self[] = "self";
652 static char __pyx_k__send[] = "send";
653 static char __pyx_k__Event[] = "Event";
654 static char __pyx_k__bytes[] = "bytes";
655 static char __pyx_k__flags[] = "flags";
656 static char __pyx_k__owner[] = "owner";
657 static char __pyx_k__split[] = "split";
658 static char __pyx_k__accept[] = "accept";
659 static char __pyx_k__handle[] = "handle";
660 static char __pyx_k__rsplit[] = "rsplit";
661 static char __pyx_k__socket[] = "socket";
662 static char __pyx_k__connect[] = "connect";
663 static char __pyx_k____init__[] = "__init__";
664 static char __pyx_k____main__[] = "__main__";
665 static char __pyx_k____test__[] = "__test__";
666 static char __pyx_k__bufflist[] = "bufflist";
667 static char __pyx_k__callback[] = "callback";
668 static char __pyx_k__recvfrom[] = "recvfrom";
669 static char __pyx_k__accepting[] = "accepting";
670 static char __pyx_k__addr_buff[] = "addr_buff";
671 static char __pyx_k__listening[] = "listening";
672 static char __pyx_k__ValueError[] = "ValueError";
673 static char __pyx_k__getsockopt[] = "getsockopt";
674 static char __pyx_k__maxAddrLen[] = "maxAddrLen";
675 static char __pyx_k__MemoryError[] = "MemoryError";
676 static char __pyx_k__iocpsupport[] = "iocpsupport";
677 static char __pyx_k__RuntimeError[] = "RuntimeError";
678 static char __pyx_k__WindowsError[] = "WindowsError";
679 static char __pyx_k__makesockaddr[] = "makesockaddr";
680 static char __pyx_k__addr_len_buff[] = "addr_len_buff";
681 static char __pyx_k__have_connectex[] = "have_connectex";
682 static char __pyx_k__get_accept_addrs[] = "get_accept_addrs";
683 static char __pyx_k__AllocateReadBuffer[] = "AllocateReadBuffer";
684 static char __pyx_k__WSAAddressToString[] = "WSAAddressToString";
685 static PyObject *__pyx_n_s_1;
686 static PyObject *__pyx_kp_s_10;
687 static PyObject *__pyx_kp_s_11;
688 static PyObject *__pyx_kp_s_12;
689 static PyObject *__pyx_kp_s_13;
690 static PyObject *__pyx_kp_s_15;
691 static PyObject *__pyx_kp_s_16;
692 static PyObject *__pyx_n_s_2;
693 static PyObject *__pyx_kp_s_3;
694 static PyObject *__pyx_kp_s_5;
695 static PyObject *__pyx_kp_s_6;
696 static PyObject *__pyx_kp_s_7;
697 static PyObject *__pyx_kp_s_8;
698 static PyObject *__pyx_n_s__AllocateReadBuffer;
699 static PyObject *__pyx_n_s__Event;
700 static PyObject *__pyx_n_s__MemoryError;
701 static PyObject *__pyx_n_s__RuntimeError;
702 static PyObject *__pyx_n_s__ValueError;
703 static PyObject *__pyx_n_s__WSAAddressToString;
704 static PyObject *__pyx_n_s__WindowsError;
705 static PyObject *__pyx_n_s____init__;
706 static PyObject *__pyx_n_s____main__;
707 static PyObject *__pyx_n_s____test__;
708 static PyObject *__pyx_n_s__accept;
709 static PyObject *__pyx_n_s__accepting;
710 static PyObject *__pyx_n_s__addr;
711 static PyObject *__pyx_n_s__addr_buff;
712 static PyObject *__pyx_n_s__addr_len_buff;
713 static PyObject *__pyx_n_s__buff;
714 static PyObject *__pyx_n_s__bufflist;
715 static PyObject *__pyx_n_s__bytes;
716 static PyObject *__pyx_n_s__callback;
717 static PyObject *__pyx_n_s__connect;
718 static PyObject *__pyx_n_s__flags;
719 static PyObject *__pyx_n_s__get_accept_addrs;
720 static PyObject *__pyx_n_s__getsockopt;
721 static PyObject *__pyx_n_s__handle;
722 static PyObject *__pyx_n_s__have_connectex;
723 static PyObject *__pyx_n_s__iocpsupport;
724 static PyObject *__pyx_n_s__key;
725 static PyObject *__pyx_n_s__listening;
726 static PyObject *__pyx_n_s__makesockaddr;
727 static PyObject *__pyx_n_s__maxAddrLen;
728 static PyObject *__pyx_n_s__obj;
729 static PyObject *__pyx_n_s__owner;
730 static PyObject *__pyx_n_s__recv;
731 static PyObject *__pyx_n_s__recvfrom;
732 static PyObject *__pyx_n_s__rsplit;
733 static PyObject *__pyx_n_s__s;
734 static PyObject *__pyx_n_s__self;
735 static PyObject *__pyx_n_s__send;
736 static PyObject *__pyx_n_s__socket;
737 static PyObject *__pyx_n_s__split;
738 static PyObject *__pyx_int_0;
739 static PyObject *__pyx_int_1;
740 static PyObject *__pyx_k_tuple_4;
741 static PyObject *__pyx_k_tuple_9;
742 
743 /* "iocpsupport.pyx":128
744  *     PyObject *obj
745  *
746  * cdef myOVERLAPPED *makeOV() except NULL:             # <<<<<<<<<<<<<<
747  *     cdef myOVERLAPPED *res
748  *     res = <myOVERLAPPED *>PyMem_Malloc(sizeof(myOVERLAPPED))
749  */
750 
__pyx_f_11iocpsupport_makeOV(void)751 static struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_f_11iocpsupport_makeOV(void) {
752   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_res;
753   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_r;
754   __Pyx_RefNannyDeclarations
755   void *__pyx_t_1;
756   int __pyx_t_2;
757   int __pyx_lineno = 0;
758   const char *__pyx_filename = NULL;
759   int __pyx_clineno = 0;
760   __Pyx_RefNannySetupContext("makeOV");
761 
762   /* "iocpsupport.pyx":130
763  * cdef myOVERLAPPED *makeOV() except NULL:
764  *     cdef myOVERLAPPED *res
765  *     res = <myOVERLAPPED *>PyMem_Malloc(sizeof(myOVERLAPPED))             # <<<<<<<<<<<<<<
766  *     if not res:
767  *         raise MemoryError
768  */
769   __pyx_t_1 = PyMem_Malloc((sizeof(struct __pyx_t_11iocpsupport_myOVERLAPPED))); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
770   __pyx_v_res = ((struct __pyx_t_11iocpsupport_myOVERLAPPED *)__pyx_t_1);
771 
772   /* "iocpsupport.pyx":131
773  *     cdef myOVERLAPPED *res
774  *     res = <myOVERLAPPED *>PyMem_Malloc(sizeof(myOVERLAPPED))
775  *     if not res:             # <<<<<<<<<<<<<<
776  *         raise MemoryError
777  *     memset(res, 0, sizeof(myOVERLAPPED))
778  */
779   __pyx_t_2 = (!(__pyx_v_res != 0));
780   if (__pyx_t_2) {
781 
782     /* "iocpsupport.pyx":132
783  *     res = <myOVERLAPPED *>PyMem_Malloc(sizeof(myOVERLAPPED))
784  *     if not res:
785  *         raise MemoryError             # <<<<<<<<<<<<<<
786  *     memset(res, 0, sizeof(myOVERLAPPED))
787  *     return res
788  */
789     PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
790     goto __pyx_L3;
791   }
792   __pyx_L3:;
793 
794   /* "iocpsupport.pyx":133
795  *     if not res:
796  *         raise MemoryError
797  *     memset(res, 0, sizeof(myOVERLAPPED))             # <<<<<<<<<<<<<<
798  *     return res
799  *
800  */
801   memset(__pyx_v_res, 0, (sizeof(struct __pyx_t_11iocpsupport_myOVERLAPPED)));
802 
803   /* "iocpsupport.pyx":134
804  *         raise MemoryError
805  *     memset(res, 0, sizeof(myOVERLAPPED))
806  *     return res             # <<<<<<<<<<<<<<
807  *
808  * cdef void raise_error(int err, object message) except *:
809  */
810   __pyx_r = __pyx_v_res;
811   goto __pyx_L0;
812 
813   __pyx_r = 0;
814   goto __pyx_L0;
815   __pyx_L1_error:;
816   __Pyx_AddTraceback("iocpsupport.makeOV", __pyx_clineno, __pyx_lineno, __pyx_filename);
817   __pyx_r = NULL;
818   __pyx_L0:;
819   __Pyx_RefNannyFinishContext();
820   return __pyx_r;
821 }
822 
823 /* "iocpsupport.pyx":136
824  *     return res
825  *
826  * cdef void raise_error(int err, object message) except *:             # <<<<<<<<<<<<<<
827  *     if not err:
828  *         err = GetLastError()
829  */
830 
__pyx_f_11iocpsupport_raise_error(int __pyx_v_err,PyObject * __pyx_v_message)831 static void __pyx_f_11iocpsupport_raise_error(int __pyx_v_err, PyObject *__pyx_v_message) {
832   __Pyx_RefNannyDeclarations
833   int __pyx_t_1;
834   PyObject *__pyx_t_2 = NULL;
835   PyObject *__pyx_t_3 = NULL;
836   PyObject *__pyx_t_4 = NULL;
837   int __pyx_lineno = 0;
838   const char *__pyx_filename = NULL;
839   int __pyx_clineno = 0;
840   __Pyx_RefNannySetupContext("raise_error");
841 
842   /* "iocpsupport.pyx":137
843  *
844  * cdef void raise_error(int err, object message) except *:
845  *     if not err:             # <<<<<<<<<<<<<<
846  *         err = GetLastError()
847  *     raise WindowsError(message, err)
848  */
849   __pyx_t_1 = (!__pyx_v_err);
850   if (__pyx_t_1) {
851 
852     /* "iocpsupport.pyx":138
853  * cdef void raise_error(int err, object message) except *:
854  *     if not err:
855  *         err = GetLastError()             # <<<<<<<<<<<<<<
856  *     raise WindowsError(message, err)
857  *
858  */
859     __pyx_v_err = GetLastError();
860     goto __pyx_L3;
861   }
862   __pyx_L3:;
863 
864   /* "iocpsupport.pyx":139
865  *     if not err:
866  *         err = GetLastError()
867  *     raise WindowsError(message, err)             # <<<<<<<<<<<<<<
868  *
869  * class Event:
870  */
871   __pyx_t_2 = __Pyx_GetName(__pyx_b, __pyx_n_s__WindowsError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
872   __Pyx_GOTREF(__pyx_t_2);
873   __pyx_t_3 = PyInt_FromLong(__pyx_v_err); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
874   __Pyx_GOTREF(__pyx_t_3);
875   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
876   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
877   __Pyx_INCREF(__pyx_v_message);
878   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_message);
879   __Pyx_GIVEREF(__pyx_v_message);
880   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
881   __Pyx_GIVEREF(__pyx_t_3);
882   __pyx_t_3 = 0;
883   __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
884   __Pyx_GOTREF(__pyx_t_3);
885   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
886   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
887   __Pyx_Raise(__pyx_t_3, 0, 0, 0);
888   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
889   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
890 
891   goto __pyx_L0;
892   __pyx_L1_error:;
893   __Pyx_XDECREF(__pyx_t_2);
894   __Pyx_XDECREF(__pyx_t_3);
895   __Pyx_XDECREF(__pyx_t_4);
896   __Pyx_AddTraceback("iocpsupport.raise_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
897   __pyx_L0:;
898   __Pyx_RefNannyFinishContext();
899 }
900 
901 /* "iocpsupport.pyx":142
902  *
903  * class Event:
904  *     def __init__(self, callback, owner, **kw):             # <<<<<<<<<<<<<<
905  *         self.callback = callback
906  *         self.owner = owner
907  */
908 
909 static PyObject *__pyx_pf_11iocpsupport_5Event___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
910 static PyMethodDef __pyx_mdef_11iocpsupport_5Event___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_11iocpsupport_5Event___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_5Event___init__(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)911 static PyObject *__pyx_pf_11iocpsupport_5Event___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
912   PyObject *__pyx_v_self = 0;
913   PyObject *__pyx_v_callback = 0;
914   PyObject *__pyx_v_owner = 0;
915   PyObject *__pyx_v_kw = 0;
916   PyObject *__pyx_v_k = NULL;
917   PyObject *__pyx_v_v = NULL;
918   PyObject *__pyx_r = NULL;
919   __Pyx_RefNannyDeclarations
920   PyObject *__pyx_t_1 = NULL;
921   PyObject *__pyx_t_2 = NULL;
922   Py_ssize_t __pyx_t_3;
923   PyObject *(*__pyx_t_4)(PyObject *);
924   PyObject *__pyx_t_5 = NULL;
925   PyObject *__pyx_t_6 = NULL;
926   PyObject *__pyx_t_7 = NULL;
927   PyObject *(*__pyx_t_8)(PyObject *);
928   int __pyx_t_9;
929   int __pyx_lineno = 0;
930   const char *__pyx_filename = NULL;
931   int __pyx_clineno = 0;
932   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__callback,&__pyx_n_s__owner,0};
933   __Pyx_RefNannySetupContext("__init__");
934   __pyx_self = __pyx_self;
935   __pyx_v_kw = PyDict_New(); if (unlikely(!__pyx_v_kw)) return NULL;
936   __Pyx_GOTREF(__pyx_v_kw);
937   {
938     PyObject* values[3] = {0,0,0};
939     if (unlikely(__pyx_kwds)) {
940       Py_ssize_t kw_args;
941       switch (PyTuple_GET_SIZE(__pyx_args)) {
942         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
943         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
944         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
945         case  0: break;
946         default: goto __pyx_L5_argtuple_error;
947       }
948       kw_args = PyDict_Size(__pyx_kwds);
949       switch (PyTuple_GET_SIZE(__pyx_args)) {
950         case  0:
951         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
952         if (likely(values[0])) kw_args--;
953         else goto __pyx_L5_argtuple_error;
954         case  1:
955         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
956         if (likely(values[1])) kw_args--;
957         else {
958           __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
959         }
960         case  2:
961         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__owner);
962         if (likely(values[2])) kw_args--;
963         else {
964           __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
965         }
966       }
967       if (unlikely(kw_args > 0)) {
968         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kw, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
969       }
970     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
971       goto __pyx_L5_argtuple_error;
972     } else {
973       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
974       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
975       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
976     }
977     __pyx_v_self = values[0];
978     __pyx_v_callback = values[1];
979     __pyx_v_owner = values[2];
980   }
981   goto __pyx_L4_argument_unpacking_done;
982   __pyx_L5_argtuple_error:;
983   __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
984   __pyx_L3_error:;
985   __Pyx_DECREF(__pyx_v_kw); __pyx_v_kw = 0;
986   __Pyx_AddTraceback("iocpsupport.Event.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
987   __Pyx_RefNannyFinishContext();
988   return NULL;
989   __pyx_L4_argument_unpacking_done:;
990 
991   /* "iocpsupport.pyx":143
992  * class Event:
993  *     def __init__(self, callback, owner, **kw):
994  *         self.callback = callback             # <<<<<<<<<<<<<<
995  *         self.owner = owner
996  *         for k, v in kw.items():
997  */
998   if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
999 
1000   /* "iocpsupport.pyx":144
1001  *     def __init__(self, callback, owner, **kw):
1002  *         self.callback = callback
1003  *         self.owner = owner             # <<<<<<<<<<<<<<
1004  *         for k, v in kw.items():
1005  *             setattr(self, k, v)
1006  */
1007   if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__owner, __pyx_v_owner) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1008 
1009   /* "iocpsupport.pyx":145
1010  *         self.callback = callback
1011  *         self.owner = owner
1012  *         for k, v in kw.items():             # <<<<<<<<<<<<<<
1013  *             setattr(self, k, v)
1014  *
1015  */
1016   if (unlikely(((PyObject *)__pyx_v_kw) == Py_None)) {
1017     PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1018   }
1019   __pyx_t_1 = PyDict_Items(__pyx_v_kw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1020   __Pyx_GOTREF(__pyx_t_1);
1021   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
1022     __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
1023     __pyx_t_4 = NULL;
1024   } else {
1025     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1026     __Pyx_GOTREF(__pyx_t_2);
1027     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
1028   }
1029   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1030   for (;;) {
1031     if (PyList_CheckExact(__pyx_t_2)) {
1032       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
1033       __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
1034     } else if (PyTuple_CheckExact(__pyx_t_2)) {
1035       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
1036       __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
1037     } else {
1038       __pyx_t_1 = __pyx_t_4(__pyx_t_2);
1039       if (unlikely(!__pyx_t_1)) {
1040         if (PyErr_Occurred()) {
1041           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
1042           else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1043         }
1044         break;
1045       }
1046       __Pyx_GOTREF(__pyx_t_1);
1047     }
1048     if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
1049       PyObject* sequence = __pyx_t_1;
1050       if (likely(PyTuple_CheckExact(sequence))) {
1051         if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
1052           if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
1053           else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
1054           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1055         }
1056         __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
1057         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
1058       } else {
1059         if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
1060           if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
1061           else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
1062           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1063         }
1064         __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
1065         __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
1066       }
1067       __Pyx_INCREF(__pyx_t_5);
1068       __Pyx_INCREF(__pyx_t_6);
1069       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1070     } else {
1071       Py_ssize_t index = -1;
1072       __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1073       __Pyx_GOTREF(__pyx_t_7);
1074       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1075       __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
1076       index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
1077       __Pyx_GOTREF(__pyx_t_5);
1078       index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed;
1079       __Pyx_GOTREF(__pyx_t_6);
1080       if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1081       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1082       goto __pyx_L9_unpacking_done;
1083       __pyx_L8_unpacking_failed:;
1084       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1085       if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
1086       if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
1087       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1088       __pyx_L9_unpacking_done:;
1089     }
1090     __Pyx_XDECREF(__pyx_v_k);
1091     __pyx_v_k = __pyx_t_5;
1092     __pyx_t_5 = 0;
1093     __Pyx_XDECREF(__pyx_v_v);
1094     __pyx_v_v = __pyx_t_6;
1095     __pyx_t_6 = 0;
1096 
1097     /* "iocpsupport.pyx":146
1098  *         self.owner = owner
1099  *         for k, v in kw.items():
1100  *             setattr(self, k, v)             # <<<<<<<<<<<<<<
1101  *
1102  * cdef class CompletionPort:
1103  */
1104     __pyx_t_9 = PyObject_SetAttr(__pyx_v_self, __pyx_v_k, __pyx_v_v); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1105   }
1106   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1107 
1108   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1109   goto __pyx_L0;
1110   __pyx_L1_error:;
1111   __Pyx_XDECREF(__pyx_t_1);
1112   __Pyx_XDECREF(__pyx_t_2);
1113   __Pyx_XDECREF(__pyx_t_5);
1114   __Pyx_XDECREF(__pyx_t_6);
1115   __Pyx_XDECREF(__pyx_t_7);
1116   __Pyx_AddTraceback("iocpsupport.Event.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1117   __pyx_r = NULL;
1118   __pyx_L0:;
1119   __Pyx_XDECREF(__pyx_v_kw);
1120   __Pyx_XDECREF(__pyx_v_k);
1121   __Pyx_XDECREF(__pyx_v_v);
1122   __Pyx_XGIVEREF(__pyx_r);
1123   __Pyx_RefNannyFinishContext();
1124   return __pyx_r;
1125 }
1126 
1127 /* "iocpsupport.pyx":150
1128  * cdef class CompletionPort:
1129  *     cdef HANDLE port
1130  *     def __init__(self):             # <<<<<<<<<<<<<<
1131  *         cdef HANDLE res
1132  *         res = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0)
1133  */
1134 
1135 static int __pyx_pf_11iocpsupport_14CompletionPort___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pf_11iocpsupport_14CompletionPort___init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1136 static int __pyx_pf_11iocpsupport_14CompletionPort___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1137   __pyx_t_11iocpsupport_HANDLE __pyx_v_res;
1138   int __pyx_r;
1139   __Pyx_RefNannyDeclarations
1140   int __pyx_t_1;
1141   PyObject *__pyx_t_2 = NULL;
1142   int __pyx_lineno = 0;
1143   const char *__pyx_filename = NULL;
1144   int __pyx_clineno = 0;
1145   __Pyx_RefNannySetupContext("__init__");
1146   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
1147     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
1148   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
1149 
1150   /* "iocpsupport.pyx":152
1151  *     def __init__(self):
1152  *         cdef HANDLE res
1153  *         res = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0)             # <<<<<<<<<<<<<<
1154  *         if not res:
1155  *             raise_error(0, 'CreateIoCompletionPort')
1156  */
1157   __pyx_v_res = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
1158 
1159   /* "iocpsupport.pyx":153
1160  *         cdef HANDLE res
1161  *         res = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0)
1162  *         if not res:             # <<<<<<<<<<<<<<
1163  *             raise_error(0, 'CreateIoCompletionPort')
1164  *         self.port = res
1165  */
1166   __pyx_t_1 = (!__pyx_v_res);
1167   if (__pyx_t_1) {
1168 
1169     /* "iocpsupport.pyx":154
1170  *         res = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0)
1171  *         if not res:
1172  *             raise_error(0, 'CreateIoCompletionPort')             # <<<<<<<<<<<<<<
1173  *         self.port = res
1174  *
1175  */
1176     __pyx_t_2 = ((PyObject *)__pyx_n_s_1);
1177     __Pyx_INCREF(__pyx_t_2);
1178     __pyx_f_11iocpsupport_raise_error(0, __pyx_t_2); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1179     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1180     goto __pyx_L5;
1181   }
1182   __pyx_L5:;
1183 
1184   /* "iocpsupport.pyx":155
1185  *         if not res:
1186  *             raise_error(0, 'CreateIoCompletionPort')
1187  *         self.port = res             # <<<<<<<<<<<<<<
1188  *
1189  *     def addHandle(self, HANDLE handle, size_t key=0):
1190  */
1191   ((struct __pyx_obj_11iocpsupport_CompletionPort *)__pyx_v_self)->port = __pyx_v_res;
1192 
1193   __pyx_r = 0;
1194   goto __pyx_L0;
1195   __pyx_L1_error:;
1196   __Pyx_XDECREF(__pyx_t_2);
1197   __Pyx_AddTraceback("iocpsupport.CompletionPort.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1198   __pyx_r = -1;
1199   __pyx_L0:;
1200   __Pyx_RefNannyFinishContext();
1201   return __pyx_r;
1202 }
1203 
1204 /* "iocpsupport.pyx":157
1205  *         self.port = res
1206  *
1207  *     def addHandle(self, HANDLE handle, size_t key=0):             # <<<<<<<<<<<<<<
1208  *         cdef HANDLE res
1209  *         res = CreateIoCompletionPort(handle, self.port, key, 0)
1210  */
1211 
1212 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_1addHandle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pf_11iocpsupport_14CompletionPort_1addHandle(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1213 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_1addHandle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1214   __pyx_t_11iocpsupport_HANDLE __pyx_v_handle;
1215   size_t __pyx_v_key;
1216   __pyx_t_11iocpsupport_HANDLE __pyx_v_res;
1217   PyObject *__pyx_r = NULL;
1218   __Pyx_RefNannyDeclarations
1219   int __pyx_t_1;
1220   PyObject *__pyx_t_2 = NULL;
1221   int __pyx_lineno = 0;
1222   const char *__pyx_filename = NULL;
1223   int __pyx_clineno = 0;
1224   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__handle,&__pyx_n_s__key,0};
1225   __Pyx_RefNannySetupContext("addHandle");
1226   {
1227     PyObject* values[2] = {0,0};
1228     if (unlikely(__pyx_kwds)) {
1229       Py_ssize_t kw_args;
1230       switch (PyTuple_GET_SIZE(__pyx_args)) {
1231         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1232         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1233         case  0: break;
1234         default: goto __pyx_L5_argtuple_error;
1235       }
1236       kw_args = PyDict_Size(__pyx_kwds);
1237       switch (PyTuple_GET_SIZE(__pyx_args)) {
1238         case  0:
1239         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__handle);
1240         if (likely(values[0])) kw_args--;
1241         else goto __pyx_L5_argtuple_error;
1242         case  1:
1243         if (kw_args > 0) {
1244           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
1245           if (value) { values[1] = value; kw_args--; }
1246         }
1247       }
1248       if (unlikely(kw_args > 0)) {
1249         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "addHandle") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1250       }
1251     } else {
1252       switch (PyTuple_GET_SIZE(__pyx_args)) {
1253         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1254         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1255         break;
1256         default: goto __pyx_L5_argtuple_error;
1257       }
1258     }
1259     __pyx_v_handle = __Pyx_PyInt_AsSize_t(values[0]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1260     if (values[1]) {
1261       __pyx_v_key = __Pyx_PyInt_AsSize_t(values[1]); if (unlikely((__pyx_v_key == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1262     } else {
1263       __pyx_v_key = ((size_t)0);
1264     }
1265   }
1266   goto __pyx_L4_argument_unpacking_done;
1267   __pyx_L5_argtuple_error:;
1268   __Pyx_RaiseArgtupleInvalid("addHandle", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1269   __pyx_L3_error:;
1270   __Pyx_AddTraceback("iocpsupport.CompletionPort.addHandle", __pyx_clineno, __pyx_lineno, __pyx_filename);
1271   __Pyx_RefNannyFinishContext();
1272   return NULL;
1273   __pyx_L4_argument_unpacking_done:;
1274 
1275   /* "iocpsupport.pyx":159
1276  *     def addHandle(self, HANDLE handle, size_t key=0):
1277  *         cdef HANDLE res
1278  *         res = CreateIoCompletionPort(handle, self.port, key, 0)             # <<<<<<<<<<<<<<
1279  *         if not res:
1280  *             raise_error(0, 'CreateIoCompletionPort')
1281  */
1282   __pyx_v_res = CreateIoCompletionPort(__pyx_v_handle, ((struct __pyx_obj_11iocpsupport_CompletionPort *)__pyx_v_self)->port, __pyx_v_key, 0);
1283 
1284   /* "iocpsupport.pyx":160
1285  *         cdef HANDLE res
1286  *         res = CreateIoCompletionPort(handle, self.port, key, 0)
1287  *         if not res:             # <<<<<<<<<<<<<<
1288  *             raise_error(0, 'CreateIoCompletionPort')
1289  *
1290  */
1291   __pyx_t_1 = (!__pyx_v_res);
1292   if (__pyx_t_1) {
1293 
1294     /* "iocpsupport.pyx":161
1295  *         res = CreateIoCompletionPort(handle, self.port, key, 0)
1296  *         if not res:
1297  *             raise_error(0, 'CreateIoCompletionPort')             # <<<<<<<<<<<<<<
1298  *
1299  *     def getEvent(self, long timeout):
1300  */
1301     __pyx_t_2 = ((PyObject *)__pyx_n_s_1);
1302     __Pyx_INCREF(__pyx_t_2);
1303     __pyx_f_11iocpsupport_raise_error(0, __pyx_t_2); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1304     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1305     goto __pyx_L6;
1306   }
1307   __pyx_L6:;
1308 
1309   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1310   goto __pyx_L0;
1311   __pyx_L1_error:;
1312   __Pyx_XDECREF(__pyx_t_2);
1313   __Pyx_AddTraceback("iocpsupport.CompletionPort.addHandle", __pyx_clineno, __pyx_lineno, __pyx_filename);
1314   __pyx_r = NULL;
1315   __pyx_L0:;
1316   __Pyx_XGIVEREF(__pyx_r);
1317   __Pyx_RefNannyFinishContext();
1318   return __pyx_r;
1319 }
1320 
1321 /* "iocpsupport.pyx":163
1322  *             raise_error(0, 'CreateIoCompletionPort')
1323  *
1324  *     def getEvent(self, long timeout):             # <<<<<<<<<<<<<<
1325  *         cdef PyThreadState *_save
1326  *         cdef unsigned long bytes, rc
1327  */
1328 
1329 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_2getEvent(PyObject *__pyx_v_self, PyObject *__pyx_arg_timeout); /*proto*/
__pyx_pf_11iocpsupport_14CompletionPort_2getEvent(PyObject * __pyx_v_self,PyObject * __pyx_arg_timeout)1330 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_2getEvent(PyObject *__pyx_v_self, PyObject *__pyx_arg_timeout) {
1331   long __pyx_v_timeout;
1332   struct PyThreadState *__pyx_v__save;
1333   unsigned long __pyx_v_bytes;
1334   unsigned long __pyx_v_rc;
1335   size_t __pyx_v_key;
1336   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
1337   PyObject *__pyx_v_obj = NULL;
1338   PyObject *__pyx_r = NULL;
1339   __Pyx_RefNannyDeclarations
1340   int __pyx_t_1;
1341   PyObject *__pyx_t_2 = NULL;
1342   PyObject *__pyx_t_3 = NULL;
1343   PyObject *__pyx_t_4 = NULL;
1344   PyObject *__pyx_t_5 = NULL;
1345   int __pyx_lineno = 0;
1346   const char *__pyx_filename = NULL;
1347   int __pyx_clineno = 0;
1348   __Pyx_RefNannySetupContext("getEvent");
1349   assert(__pyx_arg_timeout); {
1350     __pyx_v_timeout = __Pyx_PyInt_AsLong(__pyx_arg_timeout); if (unlikely((__pyx_v_timeout == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1351   }
1352   goto __pyx_L4_argument_unpacking_done;
1353   __pyx_L3_error:;
1354   __Pyx_AddTraceback("iocpsupport.CompletionPort.getEvent", __pyx_clineno, __pyx_lineno, __pyx_filename);
1355   __Pyx_RefNannyFinishContext();
1356   return NULL;
1357   __pyx_L4_argument_unpacking_done:;
1358 
1359   /* "iocpsupport.pyx":169
1360  *         cdef myOVERLAPPED *ov
1361  *
1362  *         _save = PyEval_SaveThread()             # <<<<<<<<<<<<<<
1363  *         rc = GetQueuedCompletionStatus(self.port, &bytes, &key, <OVERLAPPED **>&ov, timeout)
1364  *         PyEval_RestoreThread(_save)
1365  */
1366   __pyx_v__save = PyEval_SaveThread();
1367 
1368   /* "iocpsupport.pyx":170
1369  *
1370  *         _save = PyEval_SaveThread()
1371  *         rc = GetQueuedCompletionStatus(self.port, &bytes, &key, <OVERLAPPED **>&ov, timeout)             # <<<<<<<<<<<<<<
1372  *         PyEval_RestoreThread(_save)
1373  *
1374  */
1375   __pyx_v_rc = GetQueuedCompletionStatus(((struct __pyx_obj_11iocpsupport_CompletionPort *)__pyx_v_self)->port, (&__pyx_v_bytes), (&__pyx_v_key), ((OVERLAPPED **)(&__pyx_v_ov)), __pyx_v_timeout);
1376 
1377   /* "iocpsupport.pyx":171
1378  *         _save = PyEval_SaveThread()
1379  *         rc = GetQueuedCompletionStatus(self.port, &bytes, &key, <OVERLAPPED **>&ov, timeout)
1380  *         PyEval_RestoreThread(_save)             # <<<<<<<<<<<<<<
1381  *
1382  *         if not rc:
1383  */
1384   PyEval_RestoreThread(__pyx_v__save);
1385 
1386   /* "iocpsupport.pyx":173
1387  *         PyEval_RestoreThread(_save)
1388  *
1389  *         if not rc:             # <<<<<<<<<<<<<<
1390  *             rc = GetLastError()
1391  *         else:
1392  */
1393   __pyx_t_1 = (!__pyx_v_rc);
1394   if (__pyx_t_1) {
1395 
1396     /* "iocpsupport.pyx":174
1397  *
1398  *         if not rc:
1399  *             rc = GetLastError()             # <<<<<<<<<<<<<<
1400  *         else:
1401  *             rc = 0
1402  */
1403     __pyx_v_rc = GetLastError();
1404     goto __pyx_L5;
1405   }
1406   /*else*/ {
1407 
1408     /* "iocpsupport.pyx":176
1409  *             rc = GetLastError()
1410  *         else:
1411  *             rc = 0             # <<<<<<<<<<<<<<
1412  *
1413  *         obj = None
1414  */
1415     __pyx_v_rc = 0;
1416   }
1417   __pyx_L5:;
1418 
1419   /* "iocpsupport.pyx":178
1420  *             rc = 0
1421  *
1422  *         obj = None             # <<<<<<<<<<<<<<
1423  *         if ov:
1424  *             if ov.obj:
1425  */
1426   __Pyx_INCREF(Py_None);
1427   __pyx_v_obj = Py_None;
1428 
1429   /* "iocpsupport.pyx":179
1430  *
1431  *         obj = None
1432  *         if ov:             # <<<<<<<<<<<<<<
1433  *             if ov.obj:
1434  *                 obj = <object>ov.obj
1435  */
1436   __pyx_t_1 = (__pyx_v_ov != 0);
1437   if (__pyx_t_1) {
1438 
1439     /* "iocpsupport.pyx":180
1440  *         obj = None
1441  *         if ov:
1442  *             if ov.obj:             # <<<<<<<<<<<<<<
1443  *                 obj = <object>ov.obj
1444  *                 Py_DECREF(obj) # we are stealing a reference here
1445  */
1446     __pyx_t_1 = (__pyx_v_ov->obj != 0);
1447     if (__pyx_t_1) {
1448 
1449       /* "iocpsupport.pyx":181
1450  *         if ov:
1451  *             if ov.obj:
1452  *                 obj = <object>ov.obj             # <<<<<<<<<<<<<<
1453  *                 Py_DECREF(obj) # we are stealing a reference here
1454  *             PyMem_Free(ov)
1455  */
1456       __Pyx_INCREF(((PyObject *)__pyx_v_ov->obj));
1457       __Pyx_DECREF(__pyx_v_obj);
1458       __pyx_v_obj = ((PyObject *)__pyx_v_ov->obj);
1459 
1460       /* "iocpsupport.pyx":182
1461  *             if ov.obj:
1462  *                 obj = <object>ov.obj
1463  *                 Py_DECREF(obj) # we are stealing a reference here             # <<<<<<<<<<<<<<
1464  *             PyMem_Free(ov)
1465  *
1466  */
1467       Py_DECREF(__pyx_v_obj);
1468       goto __pyx_L7;
1469     }
1470     __pyx_L7:;
1471 
1472     /* "iocpsupport.pyx":183
1473  *                 obj = <object>ov.obj
1474  *                 Py_DECREF(obj) # we are stealing a reference here
1475  *             PyMem_Free(ov)             # <<<<<<<<<<<<<<
1476  *
1477  *         return (rc, bytes, key, obj)
1478  */
1479     PyMem_Free(__pyx_v_ov);
1480     goto __pyx_L6;
1481   }
1482   __pyx_L6:;
1483 
1484   /* "iocpsupport.pyx":185
1485  *             PyMem_Free(ov)
1486  *
1487  *         return (rc, bytes, key, obj)             # <<<<<<<<<<<<<<
1488  *
1489  *     def postEvent(self, unsigned long bytes, size_t key, obj):
1490  */
1491   __Pyx_XDECREF(__pyx_r);
1492   __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_rc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1493   __Pyx_GOTREF(__pyx_t_2);
1494   __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1495   __Pyx_GOTREF(__pyx_t_3);
1496   __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_key); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1497   __Pyx_GOTREF(__pyx_t_4);
1498   __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1499   __Pyx_GOTREF(((PyObject *)__pyx_t_5));
1500   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
1501   __Pyx_GIVEREF(__pyx_t_2);
1502   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
1503   __Pyx_GIVEREF(__pyx_t_3);
1504   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
1505   __Pyx_GIVEREF(__pyx_t_4);
1506   __Pyx_INCREF(__pyx_v_obj);
1507   PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_obj);
1508   __Pyx_GIVEREF(__pyx_v_obj);
1509   __pyx_t_2 = 0;
1510   __pyx_t_3 = 0;
1511   __pyx_t_4 = 0;
1512   __pyx_r = ((PyObject *)__pyx_t_5);
1513   __pyx_t_5 = 0;
1514   goto __pyx_L0;
1515 
1516   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1517   goto __pyx_L0;
1518   __pyx_L1_error:;
1519   __Pyx_XDECREF(__pyx_t_2);
1520   __Pyx_XDECREF(__pyx_t_3);
1521   __Pyx_XDECREF(__pyx_t_4);
1522   __Pyx_XDECREF(__pyx_t_5);
1523   __Pyx_AddTraceback("iocpsupport.CompletionPort.getEvent", __pyx_clineno, __pyx_lineno, __pyx_filename);
1524   __pyx_r = NULL;
1525   __pyx_L0:;
1526   __Pyx_XDECREF(__pyx_v_obj);
1527   __Pyx_XGIVEREF(__pyx_r);
1528   __Pyx_RefNannyFinishContext();
1529   return __pyx_r;
1530 }
1531 
1532 /* "iocpsupport.pyx":187
1533  *         return (rc, bytes, key, obj)
1534  *
1535  *     def postEvent(self, unsigned long bytes, size_t key, obj):             # <<<<<<<<<<<<<<
1536  *         cdef myOVERLAPPED *ov
1537  *         cdef unsigned long rc
1538  */
1539 
1540 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_3postEvent(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pf_11iocpsupport_14CompletionPort_3postEvent(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1541 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_3postEvent(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1542   unsigned long __pyx_v_bytes;
1543   size_t __pyx_v_key;
1544   PyObject *__pyx_v_obj = 0;
1545   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
1546   unsigned long __pyx_v_rc;
1547   PyObject *__pyx_r = NULL;
1548   __Pyx_RefNannyDeclarations
1549   int __pyx_t_1;
1550   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_2;
1551   PyObject *__pyx_t_3 = NULL;
1552   int __pyx_lineno = 0;
1553   const char *__pyx_filename = NULL;
1554   int __pyx_clineno = 0;
1555   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key,&__pyx_n_s__obj,0};
1556   __Pyx_RefNannySetupContext("postEvent");
1557   {
1558     PyObject* values[3] = {0,0,0};
1559     if (unlikely(__pyx_kwds)) {
1560       Py_ssize_t kw_args;
1561       switch (PyTuple_GET_SIZE(__pyx_args)) {
1562         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1563         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1564         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1565         case  0: break;
1566         default: goto __pyx_L5_argtuple_error;
1567       }
1568       kw_args = PyDict_Size(__pyx_kwds);
1569       switch (PyTuple_GET_SIZE(__pyx_args)) {
1570         case  0:
1571         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bytes);
1572         if (likely(values[0])) kw_args--;
1573         else goto __pyx_L5_argtuple_error;
1574         case  1:
1575         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
1576         if (likely(values[1])) kw_args--;
1577         else {
1578           __Pyx_RaiseArgtupleInvalid("postEvent", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1579         }
1580         case  2:
1581         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
1582         if (likely(values[2])) kw_args--;
1583         else {
1584           __Pyx_RaiseArgtupleInvalid("postEvent", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1585         }
1586       }
1587       if (unlikely(kw_args > 0)) {
1588         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "postEvent") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1589       }
1590     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1591       goto __pyx_L5_argtuple_error;
1592     } else {
1593       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1594       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1595       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1596     }
1597     __pyx_v_bytes = __Pyx_PyInt_AsUnsignedLong(values[0]); if (unlikely((__pyx_v_bytes == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1598     __pyx_v_key = __Pyx_PyInt_AsSize_t(values[1]); if (unlikely((__pyx_v_key == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1599     __pyx_v_obj = values[2];
1600   }
1601   goto __pyx_L4_argument_unpacking_done;
1602   __pyx_L5_argtuple_error:;
1603   __Pyx_RaiseArgtupleInvalid("postEvent", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1604   __pyx_L3_error:;
1605   __Pyx_AddTraceback("iocpsupport.CompletionPort.postEvent", __pyx_clineno, __pyx_lineno, __pyx_filename);
1606   __Pyx_RefNannyFinishContext();
1607   return NULL;
1608   __pyx_L4_argument_unpacking_done:;
1609 
1610   /* "iocpsupport.pyx":191
1611  *         cdef unsigned long rc
1612  *
1613  *         if obj is not None:             # <<<<<<<<<<<<<<
1614  *             ov = makeOV()
1615  *             Py_INCREF(obj) # give ov its own reference to obj
1616  */
1617   __pyx_t_1 = (__pyx_v_obj != Py_None);
1618   if (__pyx_t_1) {
1619 
1620     /* "iocpsupport.pyx":192
1621  *
1622  *         if obj is not None:
1623  *             ov = makeOV()             # <<<<<<<<<<<<<<
1624  *             Py_INCREF(obj) # give ov its own reference to obj
1625  *             ov.obj = <PyObject *>obj
1626  */
1627     __pyx_t_2 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1628     __pyx_v_ov = __pyx_t_2;
1629 
1630     /* "iocpsupport.pyx":193
1631  *         if obj is not None:
1632  *             ov = makeOV()
1633  *             Py_INCREF(obj) # give ov its own reference to obj             # <<<<<<<<<<<<<<
1634  *             ov.obj = <PyObject *>obj
1635  *         else:
1636  */
1637     Py_INCREF(__pyx_v_obj);
1638 
1639     /* "iocpsupport.pyx":194
1640  *             ov = makeOV()
1641  *             Py_INCREF(obj) # give ov its own reference to obj
1642  *             ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
1643  *         else:
1644  *             ov = NULL
1645  */
1646     __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
1647     goto __pyx_L6;
1648   }
1649   /*else*/ {
1650 
1651     /* "iocpsupport.pyx":196
1652  *             ov.obj = <PyObject *>obj
1653  *         else:
1654  *             ov = NULL             # <<<<<<<<<<<<<<
1655  *
1656  *         rc = PostQueuedCompletionStatus(self.port, bytes, key, <OVERLAPPED *>ov)
1657  */
1658     __pyx_v_ov = NULL;
1659   }
1660   __pyx_L6:;
1661 
1662   /* "iocpsupport.pyx":198
1663  *             ov = NULL
1664  *
1665  *         rc = PostQueuedCompletionStatus(self.port, bytes, key, <OVERLAPPED *>ov)             # <<<<<<<<<<<<<<
1666  *         if not rc:
1667  *             if ov:
1668  */
1669   __pyx_v_rc = PostQueuedCompletionStatus(((struct __pyx_obj_11iocpsupport_CompletionPort *)__pyx_v_self)->port, __pyx_v_bytes, __pyx_v_key, ((OVERLAPPED *)__pyx_v_ov));
1670 
1671   /* "iocpsupport.pyx":199
1672  *
1673  *         rc = PostQueuedCompletionStatus(self.port, bytes, key, <OVERLAPPED *>ov)
1674  *         if not rc:             # <<<<<<<<<<<<<<
1675  *             if ov:
1676  *                 Py_DECREF(obj)
1677  */
1678   __pyx_t_1 = (!__pyx_v_rc);
1679   if (__pyx_t_1) {
1680 
1681     /* "iocpsupport.pyx":200
1682  *         rc = PostQueuedCompletionStatus(self.port, bytes, key, <OVERLAPPED *>ov)
1683  *         if not rc:
1684  *             if ov:             # <<<<<<<<<<<<<<
1685  *                 Py_DECREF(obj)
1686  *                 PyMem_Free(ov)
1687  */
1688     __pyx_t_1 = (__pyx_v_ov != 0);
1689     if (__pyx_t_1) {
1690 
1691       /* "iocpsupport.pyx":201
1692  *         if not rc:
1693  *             if ov:
1694  *                 Py_DECREF(obj)             # <<<<<<<<<<<<<<
1695  *                 PyMem_Free(ov)
1696  *             raise_error(0, 'PostQueuedCompletionStatus')
1697  */
1698       Py_DECREF(__pyx_v_obj);
1699 
1700       /* "iocpsupport.pyx":202
1701  *             if ov:
1702  *                 Py_DECREF(obj)
1703  *                 PyMem_Free(ov)             # <<<<<<<<<<<<<<
1704  *             raise_error(0, 'PostQueuedCompletionStatus')
1705  *
1706  */
1707       PyMem_Free(__pyx_v_ov);
1708       goto __pyx_L8;
1709     }
1710     __pyx_L8:;
1711 
1712     /* "iocpsupport.pyx":203
1713  *                 Py_DECREF(obj)
1714  *                 PyMem_Free(ov)
1715  *             raise_error(0, 'PostQueuedCompletionStatus')             # <<<<<<<<<<<<<<
1716  *
1717  *     def __del__(self):
1718  */
1719     __pyx_t_3 = ((PyObject *)__pyx_n_s_2);
1720     __Pyx_INCREF(__pyx_t_3);
1721     __pyx_f_11iocpsupport_raise_error(0, __pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1722     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1723     goto __pyx_L7;
1724   }
1725   __pyx_L7:;
1726 
1727   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1728   goto __pyx_L0;
1729   __pyx_L1_error:;
1730   __Pyx_XDECREF(__pyx_t_3);
1731   __Pyx_AddTraceback("iocpsupport.CompletionPort.postEvent", __pyx_clineno, __pyx_lineno, __pyx_filename);
1732   __pyx_r = NULL;
1733   __pyx_L0:;
1734   __Pyx_XGIVEREF(__pyx_r);
1735   __Pyx_RefNannyFinishContext();
1736   return __pyx_r;
1737 }
1738 
1739 /* "iocpsupport.pyx":205
1740  *             raise_error(0, 'PostQueuedCompletionStatus')
1741  *
1742  *     def __del__(self):             # <<<<<<<<<<<<<<
1743  *         CloseHandle(self.port)
1744  *
1745  */
1746 
1747 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_4__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pf_11iocpsupport_14CompletionPort_4__del__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1748 static PyObject *__pyx_pf_11iocpsupport_14CompletionPort_4__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1749   PyObject *__pyx_r = NULL;
1750   __Pyx_RefNannyDeclarations
1751   __Pyx_RefNannySetupContext("__del__");
1752 
1753   /* "iocpsupport.pyx":206
1754  *
1755  *     def __del__(self):
1756  *         CloseHandle(self.port)             # <<<<<<<<<<<<<<
1757  *
1758  * def makesockaddr(object buff):
1759  */
1760   CloseHandle(((struct __pyx_obj_11iocpsupport_CompletionPort *)__pyx_v_self)->port);
1761 
1762   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1763   __Pyx_XGIVEREF(__pyx_r);
1764   __Pyx_RefNannyFinishContext();
1765   return __pyx_r;
1766 }
1767 
1768 /* "iocpsupport.pyx":208
1769  *         CloseHandle(self.port)
1770  *
1771  * def makesockaddr(object buff):             # <<<<<<<<<<<<<<
1772  *     cdef void *mem_buffer
1773  *     cdef Py_ssize_t size
1774  */
1775 
1776 static PyObject *__pyx_pf_11iocpsupport_makesockaddr(PyObject *__pyx_self, PyObject *__pyx_v_buff); /*proto*/
1777 static PyMethodDef __pyx_mdef_11iocpsupport_makesockaddr = {__Pyx_NAMESTR("makesockaddr"), (PyCFunction)__pyx_pf_11iocpsupport_makesockaddr, METH_O, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_makesockaddr(PyObject * __pyx_self,PyObject * __pyx_v_buff)1778 static PyObject *__pyx_pf_11iocpsupport_makesockaddr(PyObject *__pyx_self, PyObject *__pyx_v_buff) {
1779   void *__pyx_v_mem_buffer;
1780   Py_ssize_t __pyx_v_size;
1781   PyObject *__pyx_r = NULL;
1782   __Pyx_RefNannyDeclarations
1783   int __pyx_t_1;
1784   PyObject *__pyx_t_2 = NULL;
1785   int __pyx_lineno = 0;
1786   const char *__pyx_filename = NULL;
1787   int __pyx_clineno = 0;
1788   __Pyx_RefNannySetupContext("makesockaddr");
1789   __pyx_self = __pyx_self;
1790 
1791   /* "iocpsupport.pyx":212
1792  *     cdef Py_ssize_t size
1793  *
1794  *     PyObject_AsReadBuffer(buff, &mem_buffer, &size)             # <<<<<<<<<<<<<<
1795  *     # XXX: this should really return the address family as well
1796  *     return _makesockaddr(<sockaddr *>mem_buffer, size)
1797  */
1798   __pyx_t_1 = PyObject_AsReadBuffer(__pyx_v_buff, (&__pyx_v_mem_buffer), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1799 
1800   /* "iocpsupport.pyx":214
1801  *     PyObject_AsReadBuffer(buff, &mem_buffer, &size)
1802  *     # XXX: this should really return the address family as well
1803  *     return _makesockaddr(<sockaddr *>mem_buffer, size)             # <<<<<<<<<<<<<<
1804  *
1805  * cdef object _makesockaddr(sockaddr *addr, Py_ssize_t len):
1806  */
1807   __Pyx_XDECREF(__pyx_r);
1808   __pyx_t_2 = __pyx_f_11iocpsupport__makesockaddr(((struct sockaddr *)__pyx_v_mem_buffer), __pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1809   __Pyx_GOTREF(__pyx_t_2);
1810   __pyx_r = __pyx_t_2;
1811   __pyx_t_2 = 0;
1812   goto __pyx_L0;
1813 
1814   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1815   goto __pyx_L0;
1816   __pyx_L1_error:;
1817   __Pyx_XDECREF(__pyx_t_2);
1818   __Pyx_AddTraceback("iocpsupport.makesockaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
1819   __pyx_r = NULL;
1820   __pyx_L0:;
1821   __Pyx_XGIVEREF(__pyx_r);
1822   __Pyx_RefNannyFinishContext();
1823   return __pyx_r;
1824 }
1825 
1826 /* "iocpsupport.pyx":216
1827  *     return _makesockaddr(<sockaddr *>mem_buffer, size)
1828  *
1829  * cdef object _makesockaddr(sockaddr *addr, Py_ssize_t len):             # <<<<<<<<<<<<<<
1830  *     cdef sockaddr_in *sin
1831  *     cdef sockaddr_in6 *sin6
1832  */
1833 
__pyx_f_11iocpsupport__makesockaddr(struct sockaddr * __pyx_v_addr,Py_ssize_t __pyx_v_len)1834 static PyObject *__pyx_f_11iocpsupport__makesockaddr(struct sockaddr *__pyx_v_addr, Py_ssize_t __pyx_v_len) {
1835   struct sockaddr_in *__pyx_v_sin;
1836   struct sockaddr_in6 *__pyx_v_sin6;
1837   char __pyx_v_buff[256];
1838   int __pyx_v_rc;
1839   __pyx_t_11iocpsupport_DWORD __pyx_v_buff_size;
1840   PyObject *__pyx_v_host = NULL;
1841   unsigned short __pyx_v_sa_port;
1842   PyObject *__pyx_v_port = NULL;
1843   PyObject *__pyx_r = NULL;
1844   __Pyx_RefNannyDeclarations
1845   int __pyx_t_1;
1846   PyObject *__pyx_t_2 = NULL;
1847   PyObject *__pyx_t_3 = NULL;
1848   PyObject *__pyx_t_4 = NULL;
1849   unsigned short __pyx_t_5;
1850   PyObject *__pyx_t_6 = NULL;
1851   PyObject *(*__pyx_t_7)(PyObject *);
1852   int __pyx_lineno = 0;
1853   const char *__pyx_filename = NULL;
1854   int __pyx_clineno = 0;
1855   __Pyx_RefNannySetupContext("_makesockaddr");
1856 
1857   /* "iocpsupport.pyx":221
1858  *     cdef char buff[256]
1859  *     cdef int rc
1860  *     cdef DWORD buff_size = sizeof(buff)             # <<<<<<<<<<<<<<
1861  *     if not len:
1862  *         return None
1863  */
1864   __pyx_v_buff_size = (sizeof(__pyx_v_buff));
1865 
1866   /* "iocpsupport.pyx":222
1867  *     cdef int rc
1868  *     cdef DWORD buff_size = sizeof(buff)
1869  *     if not len:             # <<<<<<<<<<<<<<
1870  *         return None
1871  *     if addr.sa_family == AF_INET:
1872  */
1873   __pyx_t_1 = (!__pyx_v_len);
1874   if (__pyx_t_1) {
1875 
1876     /* "iocpsupport.pyx":223
1877  *     cdef DWORD buff_size = sizeof(buff)
1878  *     if not len:
1879  *         return None             # <<<<<<<<<<<<<<
1880  *     if addr.sa_family == AF_INET:
1881  *         sin = <sockaddr_in *>addr
1882  */
1883     __Pyx_XDECREF(__pyx_r);
1884     __Pyx_INCREF(Py_None);
1885     __pyx_r = Py_None;
1886     goto __pyx_L0;
1887     goto __pyx_L3;
1888   }
1889   __pyx_L3:;
1890 
1891   /* "iocpsupport.pyx":227
1892  *         sin = <sockaddr_in *>addr
1893  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)
1894  *     elif addr.sa_family == AF_INET6:             # <<<<<<<<<<<<<<
1895  *         sin6 = <sockaddr_in6 *>addr
1896  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)
1897  */
1898   switch (__pyx_v_addr->sa_family) {
1899 
1900     /* "iocpsupport.pyx":224
1901  *     if not len:
1902  *         return None
1903  *     if addr.sa_family == AF_INET:             # <<<<<<<<<<<<<<
1904  *         sin = <sockaddr_in *>addr
1905  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)
1906  */
1907     case AF_INET:
1908 
1909     /* "iocpsupport.pyx":225
1910  *         return None
1911  *     if addr.sa_family == AF_INET:
1912  *         sin = <sockaddr_in *>addr             # <<<<<<<<<<<<<<
1913  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)
1914  *     elif addr.sa_family == AF_INET6:
1915  */
1916     __pyx_v_sin = ((struct sockaddr_in *)__pyx_v_addr);
1917 
1918     /* "iocpsupport.pyx":226
1919  *     if addr.sa_family == AF_INET:
1920  *         sin = <sockaddr_in *>addr
1921  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)             # <<<<<<<<<<<<<<
1922  *     elif addr.sa_family == AF_INET6:
1923  *         sin6 = <sockaddr_in6 *>addr
1924  */
1925     __Pyx_XDECREF(__pyx_r);
1926     __pyx_t_2 = PyString_FromString(inet_ntoa(__pyx_v_sin->sin_addr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1927     __Pyx_GOTREF(__pyx_t_2);
1928     __pyx_t_3 = PyInt_FromLong(ntohs(__pyx_v_sin->sin_port)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1929     __Pyx_GOTREF(__pyx_t_3);
1930     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1931     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
1932     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
1933     __Pyx_GIVEREF(__pyx_t_2);
1934     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
1935     __Pyx_GIVEREF(__pyx_t_3);
1936     __pyx_t_2 = 0;
1937     __pyx_t_3 = 0;
1938     __pyx_r = ((PyObject *)__pyx_t_4);
1939     __pyx_t_4 = 0;
1940     goto __pyx_L0;
1941     break;
1942 
1943     /* "iocpsupport.pyx":227
1944  *         sin = <sockaddr_in *>addr
1945  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)
1946  *     elif addr.sa_family == AF_INET6:             # <<<<<<<<<<<<<<
1947  *         sin6 = <sockaddr_in6 *>addr
1948  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)
1949  */
1950     case AF_INET6:
1951 
1952     /* "iocpsupport.pyx":228
1953  *         return PyString_FromString(inet_ntoa(sin.sin_addr)), ntohs(sin.sin_port)
1954  *     elif addr.sa_family == AF_INET6:
1955  *         sin6 = <sockaddr_in6 *>addr             # <<<<<<<<<<<<<<
1956  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)
1957  *         if rc == SOCKET_ERROR:
1958  */
1959     __pyx_v_sin6 = ((struct sockaddr_in6 *)__pyx_v_addr);
1960 
1961     /* "iocpsupport.pyx":229
1962  *     elif addr.sa_family == AF_INET6:
1963  *         sin6 = <sockaddr_in6 *>addr
1964  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)             # <<<<<<<<<<<<<<
1965  *         if rc == SOCKET_ERROR:
1966  *             raise_error(0, 'WSAAddressToString')
1967  */
1968     __pyx_v_rc = WSAAddressToStringA(__pyx_v_addr, (sizeof(struct sockaddr_in6)), NULL, __pyx_v_buff, (&__pyx_v_buff_size));
1969 
1970     /* "iocpsupport.pyx":230
1971  *         sin6 = <sockaddr_in6 *>addr
1972  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)
1973  *         if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
1974  *             raise_error(0, 'WSAAddressToString')
1975  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)
1976  */
1977     __pyx_t_1 = (__pyx_v_rc == SOCKET_ERROR);
1978     if (__pyx_t_1) {
1979 
1980       /* "iocpsupport.pyx":231
1981  *         rc = WSAAddressToStringA(addr, sizeof(sockaddr_in6), NULL, buff, &buff_size)
1982  *         if rc == SOCKET_ERROR:
1983  *             raise_error(0, 'WSAAddressToString')             # <<<<<<<<<<<<<<
1984  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)
1985  *         host, port = host.rsplit(':', 1)
1986  */
1987       __pyx_t_4 = ((PyObject *)__pyx_n_s__WSAAddressToString);
1988       __Pyx_INCREF(__pyx_t_4);
1989       __pyx_f_11iocpsupport_raise_error(0, __pyx_t_4); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1990       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1991       goto __pyx_L4;
1992     }
1993     __pyx_L4:;
1994 
1995     /* "iocpsupport.pyx":232
1996  *         if rc == SOCKET_ERROR:
1997  *             raise_error(0, 'WSAAddressToString')
1998  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)             # <<<<<<<<<<<<<<
1999  *         host, port = host.rsplit(':', 1)
2000  *         port = int(port)
2001  */
2002     __pyx_t_4 = PyString_FromString(__pyx_v_buff); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2003     __Pyx_GOTREF(__pyx_t_4);
2004     __pyx_t_5 = ntohs(__pyx_v_sin6->sin6_port);
2005     __pyx_v_host = __pyx_t_4;
2006     __pyx_t_4 = 0;
2007     __pyx_v_sa_port = __pyx_t_5;
2008 
2009     /* "iocpsupport.pyx":233
2010  *             raise_error(0, 'WSAAddressToString')
2011  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)
2012  *         host, port = host.rsplit(':', 1)             # <<<<<<<<<<<<<<
2013  *         port = int(port)
2014  *         assert host[0] == '['
2015  */
2016     __pyx_t_4 = PyObject_GetAttr(__pyx_v_host, __pyx_n_s__rsplit); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2017     __Pyx_GOTREF(__pyx_t_4);
2018     __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2019     __Pyx_GOTREF(__pyx_t_3);
2020     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2021     if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
2022       PyObject* sequence = __pyx_t_3;
2023       if (likely(PyTuple_CheckExact(sequence))) {
2024         if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
2025           if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
2026           else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
2027           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2028         }
2029         __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
2030         __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
2031       } else {
2032         if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
2033           if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
2034           else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
2035           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2036         }
2037         __pyx_t_4 = PyList_GET_ITEM(sequence, 0);
2038         __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
2039       }
2040       __Pyx_INCREF(__pyx_t_4);
2041       __Pyx_INCREF(__pyx_t_2);
2042       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2043     } else {
2044       Py_ssize_t index = -1;
2045       __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2046       __Pyx_GOTREF(__pyx_t_6);
2047       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2048       __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
2049       index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
2050       __Pyx_GOTREF(__pyx_t_4);
2051       index = 1; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
2052       __Pyx_GOTREF(__pyx_t_2);
2053       if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2054       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2055       goto __pyx_L6_unpacking_done;
2056       __pyx_L5_unpacking_failed:;
2057       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2058       if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
2059       if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
2060       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2061       __pyx_L6_unpacking_done:;
2062     }
2063     __Pyx_DECREF(__pyx_v_host);
2064     __pyx_v_host = __pyx_t_4;
2065     __pyx_t_4 = 0;
2066     __pyx_v_port = __pyx_t_2;
2067     __pyx_t_2 = 0;
2068 
2069     /* "iocpsupport.pyx":234
2070  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)
2071  *         host, port = host.rsplit(':', 1)
2072  *         port = int(port)             # <<<<<<<<<<<<<<
2073  *         assert host[0] == '['
2074  *         assert host[-1] == ']'
2075  */
2076     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2077     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
2078     __Pyx_INCREF(__pyx_v_port);
2079     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_port);
2080     __Pyx_GIVEREF(__pyx_v_port);
2081     __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2082     __Pyx_GOTREF(__pyx_t_2);
2083     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2084     __Pyx_DECREF(__pyx_v_port);
2085     __pyx_v_port = __pyx_t_2;
2086     __pyx_t_2 = 0;
2087 
2088     /* "iocpsupport.pyx":235
2089  *         host, port = host.rsplit(':', 1)
2090  *         port = int(port)
2091  *         assert host[0] == '['             # <<<<<<<<<<<<<<
2092  *         assert host[-1] == ']'
2093  *         assert port == sa_port
2094  */
2095     #ifndef CYTHON_WITHOUT_ASSERTIONS
2096     __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_host, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2097     __Pyx_GOTREF(__pyx_t_2);
2098     __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_2, ((PyObject *)__pyx_kp_s_5), Py_EQ); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2099     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2100     if (unlikely(!__pyx_t_1)) {
2101       PyErr_SetNone(PyExc_AssertionError);
2102       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2103     }
2104     #endif
2105 
2106     /* "iocpsupport.pyx":236
2107  *         port = int(port)
2108  *         assert host[0] == '['
2109  *         assert host[-1] == ']'             # <<<<<<<<<<<<<<
2110  *         assert port == sa_port
2111  *         return host[1:-1], port
2112  */
2113     #ifndef CYTHON_WITHOUT_ASSERTIONS
2114     __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_host, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2115     __Pyx_GOTREF(__pyx_t_2);
2116     __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_2, ((PyObject *)__pyx_kp_s_6), Py_EQ); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2117     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2118     if (unlikely(!__pyx_t_1)) {
2119       PyErr_SetNone(PyExc_AssertionError);
2120       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2121     }
2122     #endif
2123 
2124     /* "iocpsupport.pyx":237
2125  *         assert host[0] == '['
2126  *         assert host[-1] == ']'
2127  *         assert port == sa_port             # <<<<<<<<<<<<<<
2128  *         return host[1:-1], port
2129  *     else:
2130  */
2131     #ifndef CYTHON_WITHOUT_ASSERTIONS
2132     __pyx_t_2 = PyInt_FromLong(__pyx_v_sa_port); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2133     __Pyx_GOTREF(__pyx_t_2);
2134     __pyx_t_3 = PyObject_RichCompare(__pyx_v_port, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2135     __Pyx_GOTREF(__pyx_t_3);
2136     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2137     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2138     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2139     if (unlikely(!__pyx_t_1)) {
2140       PyErr_SetNone(PyExc_AssertionError);
2141       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2142     }
2143     #endif
2144 
2145     /* "iocpsupport.pyx":238
2146  *         assert host[-1] == ']'
2147  *         assert port == sa_port
2148  *         return host[1:-1], port             # <<<<<<<<<<<<<<
2149  *     else:
2150  *         return PyString_FromStringAndSize(addr.sa_data, sizeof(addr.sa_data))
2151  */
2152     __Pyx_XDECREF(__pyx_r);
2153     __pyx_t_3 = __Pyx_PySequence_GetSlice(__pyx_v_host, 1, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2154     __Pyx_GOTREF(__pyx_t_3);
2155     __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2156     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
2157     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
2158     __Pyx_GIVEREF(__pyx_t_3);
2159     __Pyx_INCREF(__pyx_v_port);
2160     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_port);
2161     __Pyx_GIVEREF(__pyx_v_port);
2162     __pyx_t_3 = 0;
2163     __pyx_r = ((PyObject *)__pyx_t_2);
2164     __pyx_t_2 = 0;
2165     goto __pyx_L0;
2166     break;
2167     default:
2168 
2169     /* "iocpsupport.pyx":240
2170  *         return host[1:-1], port
2171  *     else:
2172  *         return PyString_FromStringAndSize(addr.sa_data, sizeof(addr.sa_data))             # <<<<<<<<<<<<<<
2173  *
2174  *
2175  */
2176     __Pyx_XDECREF(__pyx_r);
2177     __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_addr->sa_data, (sizeof(__pyx_v_addr->sa_data))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2178     __Pyx_GOTREF(__pyx_t_2);
2179     __pyx_r = __pyx_t_2;
2180     __pyx_t_2 = 0;
2181     goto __pyx_L0;
2182     break;
2183   }
2184 
2185   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2186   goto __pyx_L0;
2187   __pyx_L1_error:;
2188   __Pyx_XDECREF(__pyx_t_2);
2189   __Pyx_XDECREF(__pyx_t_3);
2190   __Pyx_XDECREF(__pyx_t_4);
2191   __Pyx_XDECREF(__pyx_t_6);
2192   __Pyx_AddTraceback("iocpsupport._makesockaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
2193   __pyx_r = 0;
2194   __pyx_L0:;
2195   __Pyx_XDECREF(__pyx_v_host);
2196   __Pyx_XDECREF(__pyx_v_port);
2197   __Pyx_XGIVEREF(__pyx_r);
2198   __Pyx_RefNannyFinishContext();
2199   return __pyx_r;
2200 }
2201 
2202 /* "iocpsupport.pyx":243
2203  *
2204  *
2205  * cdef object fillinetaddr(sockaddr_in *dest, object addr):             # <<<<<<<<<<<<<<
2206  *     cdef unsigned short port
2207  *     cdef unsigned long res
2208  */
2209 
__pyx_f_11iocpsupport_fillinetaddr(struct sockaddr_in * __pyx_v_dest,PyObject * __pyx_v_addr)2210 static PyObject *__pyx_f_11iocpsupport_fillinetaddr(struct sockaddr_in *__pyx_v_dest, PyObject *__pyx_v_addr) {
2211   unsigned short __pyx_v_port;
2212   unsigned long __pyx_v_res;
2213   char *__pyx_v_hoststr;
2214   PyObject *__pyx_v_host = NULL;
2215   PyObject *__pyx_r = NULL;
2216   __Pyx_RefNannyDeclarations
2217   PyObject *__pyx_t_1 = NULL;
2218   PyObject *__pyx_t_2 = NULL;
2219   PyObject *__pyx_t_3 = NULL;
2220   PyObject *(*__pyx_t_4)(PyObject *);
2221   unsigned short __pyx_t_5;
2222   char *__pyx_t_6;
2223   int __pyx_t_7;
2224   int __pyx_lineno = 0;
2225   const char *__pyx_filename = NULL;
2226   int __pyx_clineno = 0;
2227   __Pyx_RefNannySetupContext("fillinetaddr");
2228 
2229   /* "iocpsupport.pyx":247
2230  *     cdef unsigned long res
2231  *     cdef char *hoststr
2232  *     host, port = addr             # <<<<<<<<<<<<<<
2233  *
2234  *     hoststr = PyString_AsString(host)
2235  */
2236   if ((likely(PyTuple_CheckExact(__pyx_v_addr))) || (PyList_CheckExact(__pyx_v_addr))) {
2237     PyObject* sequence = __pyx_v_addr;
2238     if (likely(PyTuple_CheckExact(sequence))) {
2239       if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
2240         if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
2241         else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
2242         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2243       }
2244       __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
2245       __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
2246     } else {
2247       if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
2248         if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
2249         else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
2250         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2251       }
2252       __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
2253       __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
2254     }
2255     __Pyx_INCREF(__pyx_t_1);
2256     __Pyx_INCREF(__pyx_t_2);
2257   } else {
2258     Py_ssize_t index = -1;
2259     __pyx_t_3 = PyObject_GetIter(__pyx_v_addr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2260     __Pyx_GOTREF(__pyx_t_3);
2261     __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
2262     index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
2263     __Pyx_GOTREF(__pyx_t_1);
2264     index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
2265     __Pyx_GOTREF(__pyx_t_2);
2266     if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2267     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2268     goto __pyx_L4_unpacking_done;
2269     __pyx_L3_unpacking_failed:;
2270     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2271     if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
2272     if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
2273     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2274     __pyx_L4_unpacking_done:;
2275   }
2276   __pyx_t_5 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_2); if (unlikely((__pyx_t_5 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2277   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2278   __pyx_v_host = __pyx_t_1;
2279   __pyx_t_1 = 0;
2280   __pyx_v_port = __pyx_t_5;
2281 
2282   /* "iocpsupport.pyx":249
2283  *     host, port = addr
2284  *
2285  *     hoststr = PyString_AsString(host)             # <<<<<<<<<<<<<<
2286  *     res = inet_addr(hoststr)
2287  *     if res == INADDR_ANY:
2288  */
2289   __pyx_t_6 = PyString_AsString(__pyx_v_host); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2290   __pyx_v_hoststr = __pyx_t_6;
2291 
2292   /* "iocpsupport.pyx":250
2293  *
2294  *     hoststr = PyString_AsString(host)
2295  *     res = inet_addr(hoststr)             # <<<<<<<<<<<<<<
2296  *     if res == INADDR_ANY:
2297  *         raise ValueError, 'invalid IP address'
2298  */
2299   __pyx_v_res = inet_addr(__pyx_v_hoststr);
2300 
2301   /* "iocpsupport.pyx":251
2302  *     hoststr = PyString_AsString(host)
2303  *     res = inet_addr(hoststr)
2304  *     if res == INADDR_ANY:             # <<<<<<<<<<<<<<
2305  *         raise ValueError, 'invalid IP address'
2306  *     dest.sin_addr.s_addr = res
2307  */
2308   __pyx_t_7 = (__pyx_v_res == INADDR_ANY);
2309   if (__pyx_t_7) {
2310 
2311     /* "iocpsupport.pyx":252
2312  *     res = inet_addr(hoststr)
2313  *     if res == INADDR_ANY:
2314  *         raise ValueError, 'invalid IP address'             # <<<<<<<<<<<<<<
2315  *     dest.sin_addr.s_addr = res
2316  *
2317  */
2318     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_7), 0, 0);
2319     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2320     goto __pyx_L5;
2321   }
2322   __pyx_L5:;
2323 
2324   /* "iocpsupport.pyx":253
2325  *     if res == INADDR_ANY:
2326  *         raise ValueError, 'invalid IP address'
2327  *     dest.sin_addr.s_addr = res             # <<<<<<<<<<<<<<
2328  *
2329  *     dest.sin_port = htons(port)
2330  */
2331   __pyx_v_dest->sin_addr.s_addr = __pyx_v_res;
2332 
2333   /* "iocpsupport.pyx":255
2334  *     dest.sin_addr.s_addr = res
2335  *
2336  *     dest.sin_port = htons(port)             # <<<<<<<<<<<<<<
2337  *
2338  *
2339  */
2340   __pyx_v_dest->sin_port = htons(__pyx_v_port);
2341 
2342   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2343   goto __pyx_L0;
2344   __pyx_L1_error:;
2345   __Pyx_XDECREF(__pyx_t_1);
2346   __Pyx_XDECREF(__pyx_t_2);
2347   __Pyx_XDECREF(__pyx_t_3);
2348   __Pyx_AddTraceback("iocpsupport.fillinetaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
2349   __pyx_r = 0;
2350   __pyx_L0:;
2351   __Pyx_XDECREF(__pyx_v_host);
2352   __Pyx_XGIVEREF(__pyx_r);
2353   __Pyx_RefNannyFinishContext();
2354   return __pyx_r;
2355 }
2356 
2357 /* "iocpsupport.pyx":258
2358  *
2359  *
2360  * cdef object fillinet6addr(sockaddr_in6 *dest, object addr):             # <<<<<<<<<<<<<<
2361  *     cdef unsigned short port
2362  *     cdef unsigned long res
2363  */
2364 
__pyx_f_11iocpsupport_fillinet6addr(struct sockaddr_in6 * __pyx_v_dest,PyObject * __pyx_v_addr)2365 static PyObject *__pyx_f_11iocpsupport_fillinet6addr(struct sockaddr_in6 *__pyx_v_dest, PyObject *__pyx_v_addr) {
2366   unsigned short __pyx_v_port;
2367   char *__pyx_v_hoststr;
2368   int __pyx_v_addrlen;
2369   PyObject *__pyx_v_host = NULL;
2370   PyObject *__pyx_v_flow = NULL;
2371   PyObject *__pyx_v_scope = NULL;
2372   int __pyx_v_parseresult;
2373   PyObject *__pyx_r = NULL;
2374   __Pyx_RefNannyDeclarations
2375   PyObject *__pyx_t_1 = NULL;
2376   PyObject *__pyx_t_2 = NULL;
2377   PyObject *__pyx_t_3 = NULL;
2378   PyObject *__pyx_t_4 = NULL;
2379   PyObject *__pyx_t_5 = NULL;
2380   PyObject *(*__pyx_t_6)(PyObject *);
2381   unsigned short __pyx_t_7;
2382   char *__pyx_t_8;
2383   int __pyx_t_9;
2384   unsigned long __pyx_t_10;
2385   int __pyx_lineno = 0;
2386   const char *__pyx_filename = NULL;
2387   int __pyx_clineno = 0;
2388   __Pyx_RefNannySetupContext("fillinet6addr");
2389 
2390   /* "iocpsupport.pyx":262
2391  *     cdef unsigned long res
2392  *     cdef char *hoststr
2393  *     cdef int addrlen = sizeof(sockaddr_in6)             # <<<<<<<<<<<<<<
2394  *     host, port, flow, scope = addr
2395  *     host = host.split("%")[0] # remove scope ID, if any
2396  */
2397   __pyx_v_addrlen = (sizeof(struct sockaddr_in6));
2398 
2399   /* "iocpsupport.pyx":263
2400  *     cdef char *hoststr
2401  *     cdef int addrlen = sizeof(sockaddr_in6)
2402  *     host, port, flow, scope = addr             # <<<<<<<<<<<<<<
2403  *     host = host.split("%")[0] # remove scope ID, if any
2404  *
2405  */
2406   if ((likely(PyTuple_CheckExact(__pyx_v_addr))) || (PyList_CheckExact(__pyx_v_addr))) {
2407     PyObject* sequence = __pyx_v_addr;
2408     if (likely(PyTuple_CheckExact(sequence))) {
2409       if (unlikely(PyTuple_GET_SIZE(sequence) != 4)) {
2410         if (PyTuple_GET_SIZE(sequence) > 4) __Pyx_RaiseTooManyValuesError(4);
2411         else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
2412         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2413       }
2414       __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
2415       __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
2416       __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2);
2417       __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3);
2418     } else {
2419       if (unlikely(PyList_GET_SIZE(sequence) != 4)) {
2420         if (PyList_GET_SIZE(sequence) > 4) __Pyx_RaiseTooManyValuesError(4);
2421         else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
2422         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2423       }
2424       __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
2425       __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
2426       __pyx_t_3 = PyList_GET_ITEM(sequence, 2);
2427       __pyx_t_4 = PyList_GET_ITEM(sequence, 3);
2428     }
2429     __Pyx_INCREF(__pyx_t_1);
2430     __Pyx_INCREF(__pyx_t_2);
2431     __Pyx_INCREF(__pyx_t_3);
2432     __Pyx_INCREF(__pyx_t_4);
2433   } else {
2434     Py_ssize_t index = -1;
2435     __pyx_t_5 = PyObject_GetIter(__pyx_v_addr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2436     __Pyx_GOTREF(__pyx_t_5);
2437     __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
2438     index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
2439     __Pyx_GOTREF(__pyx_t_1);
2440     index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
2441     __Pyx_GOTREF(__pyx_t_2);
2442     index = 2; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
2443     __Pyx_GOTREF(__pyx_t_3);
2444     index = 3; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
2445     __Pyx_GOTREF(__pyx_t_4);
2446     if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2447     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2448     goto __pyx_L4_unpacking_done;
2449     __pyx_L3_unpacking_failed:;
2450     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2451     if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
2452     if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
2453     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2454     __pyx_L4_unpacking_done:;
2455   }
2456   __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_2); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2457   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2458   __pyx_v_host = __pyx_t_1;
2459   __pyx_t_1 = 0;
2460   __pyx_v_port = __pyx_t_7;
2461   __pyx_v_flow = __pyx_t_3;
2462   __pyx_t_3 = 0;
2463   __pyx_v_scope = __pyx_t_4;
2464   __pyx_t_4 = 0;
2465 
2466   /* "iocpsupport.pyx":264
2467  *     cdef int addrlen = sizeof(sockaddr_in6)
2468  *     host, port, flow, scope = addr
2469  *     host = host.split("%")[0] # remove scope ID, if any             # <<<<<<<<<<<<<<
2470  *
2471  *     hoststr = PyString_AsString(host)
2472  */
2473   __pyx_t_4 = PyObject_GetAttr(__pyx_v_host, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2474   __Pyx_GOTREF(__pyx_t_4);
2475   __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2476   __Pyx_GOTREF(__pyx_t_3);
2477   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2478   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2479   __Pyx_GOTREF(__pyx_t_4);
2480   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2481   __Pyx_DECREF(__pyx_v_host);
2482   __pyx_v_host = __pyx_t_4;
2483   __pyx_t_4 = 0;
2484 
2485   /* "iocpsupport.pyx":266
2486  *     host = host.split("%")[0] # remove scope ID, if any
2487  *
2488  *     hoststr = PyString_AsString(host)             # <<<<<<<<<<<<<<
2489  *     cdef int parseresult = WSAStringToAddressA(hoststr, AF_INET6, NULL,
2490  *                                                <sockaddr *>dest, &addrlen)
2491  */
2492   __pyx_t_8 = PyString_AsString(__pyx_v_host); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2493   __pyx_v_hoststr = __pyx_t_8;
2494 
2495   /* "iocpsupport.pyx":268
2496  *     hoststr = PyString_AsString(host)
2497  *     cdef int parseresult = WSAStringToAddressA(hoststr, AF_INET6, NULL,
2498  *                                                <sockaddr *>dest, &addrlen)             # <<<<<<<<<<<<<<
2499  *     if parseresult == SOCKET_ERROR:
2500  *         raise ValueError, 'invalid IPv6 address %r' % (host,)
2501  */
2502   __pyx_v_parseresult = WSAStringToAddressA(__pyx_v_hoststr, AF_INET6, NULL, ((struct sockaddr *)__pyx_v_dest), (&__pyx_v_addrlen));
2503 
2504   /* "iocpsupport.pyx":269
2505  *     cdef int parseresult = WSAStringToAddressA(hoststr, AF_INET6, NULL,
2506  *                                                <sockaddr *>dest, &addrlen)
2507  *     if parseresult == SOCKET_ERROR:             # <<<<<<<<<<<<<<
2508  *         raise ValueError, 'invalid IPv6 address %r' % (host,)
2509  *     if parseresult != 0:
2510  */
2511   __pyx_t_9 = (__pyx_v_parseresult == SOCKET_ERROR);
2512   if (__pyx_t_9) {
2513 
2514     /* "iocpsupport.pyx":270
2515  *                                                <sockaddr *>dest, &addrlen)
2516  *     if parseresult == SOCKET_ERROR:
2517  *         raise ValueError, 'invalid IPv6 address %r' % (host,)             # <<<<<<<<<<<<<<
2518  *     if parseresult != 0:
2519  *         raise RuntimeError, 'undefined error occurred during address parsing'
2520  */
2521     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2522     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
2523     __Pyx_INCREF(__pyx_v_host);
2524     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_host);
2525     __Pyx_GIVEREF(__pyx_v_host);
2526     __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2527     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
2528     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
2529     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), 0, 0);
2530     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2531     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2532     goto __pyx_L5;
2533   }
2534   __pyx_L5:;
2535 
2536   /* "iocpsupport.pyx":271
2537  *     if parseresult == SOCKET_ERROR:
2538  *         raise ValueError, 'invalid IPv6 address %r' % (host,)
2539  *     if parseresult != 0:             # <<<<<<<<<<<<<<
2540  *         raise RuntimeError, 'undefined error occurred during address parsing'
2541  *     # sin6_host field was handled by WSAStringToAddress
2542  */
2543   __pyx_t_9 = (__pyx_v_parseresult != 0);
2544   if (__pyx_t_9) {
2545 
2546     /* "iocpsupport.pyx":272
2547  *         raise ValueError, 'invalid IPv6 address %r' % (host,)
2548  *     if parseresult != 0:
2549  *         raise RuntimeError, 'undefined error occurred during address parsing'             # <<<<<<<<<<<<<<
2550  *     # sin6_host field was handled by WSAStringToAddress
2551  *     dest.sin6_port = htons(port)
2552  */
2553     __Pyx_Raise(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_kp_s_11), 0, 0);
2554     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2555     goto __pyx_L6;
2556   }
2557   __pyx_L6:;
2558 
2559   /* "iocpsupport.pyx":274
2560  *         raise RuntimeError, 'undefined error occurred during address parsing'
2561  *     # sin6_host field was handled by WSAStringToAddress
2562  *     dest.sin6_port = htons(port)             # <<<<<<<<<<<<<<
2563  *     dest.sin6_flowinfo = flow
2564  *     dest.sin6_scope_id = scope
2565  */
2566   __pyx_v_dest->sin6_port = htons(__pyx_v_port);
2567 
2568   /* "iocpsupport.pyx":275
2569  *     # sin6_host field was handled by WSAStringToAddress
2570  *     dest.sin6_port = htons(port)
2571  *     dest.sin6_flowinfo = flow             # <<<<<<<<<<<<<<
2572  *     dest.sin6_scope_id = scope
2573  *
2574  */
2575   __pyx_t_10 = __Pyx_PyInt_AsUnsignedLong(__pyx_v_flow); if (unlikely((__pyx_t_10 == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2576   __pyx_v_dest->sin6_flowinfo = __pyx_t_10;
2577 
2578   /* "iocpsupport.pyx":276
2579  *     dest.sin6_port = htons(port)
2580  *     dest.sin6_flowinfo = flow
2581  *     dest.sin6_scope_id = scope             # <<<<<<<<<<<<<<
2582  *
2583  *
2584  */
2585   __pyx_t_10 = __Pyx_PyInt_AsUnsignedLong(__pyx_v_scope); if (unlikely((__pyx_t_10 == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2586   __pyx_v_dest->sin6_scope_id = __pyx_t_10;
2587 
2588   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2589   goto __pyx_L0;
2590   __pyx_L1_error:;
2591   __Pyx_XDECREF(__pyx_t_1);
2592   __Pyx_XDECREF(__pyx_t_2);
2593   __Pyx_XDECREF(__pyx_t_3);
2594   __Pyx_XDECREF(__pyx_t_4);
2595   __Pyx_XDECREF(__pyx_t_5);
2596   __Pyx_AddTraceback("iocpsupport.fillinet6addr", __pyx_clineno, __pyx_lineno, __pyx_filename);
2597   __pyx_r = 0;
2598   __pyx_L0:;
2599   __Pyx_XDECREF(__pyx_v_host);
2600   __Pyx_XDECREF(__pyx_v_flow);
2601   __Pyx_XDECREF(__pyx_v_scope);
2602   __Pyx_XGIVEREF(__pyx_r);
2603   __Pyx_RefNannyFinishContext();
2604   return __pyx_r;
2605 }
2606 
2607 /* "iocpsupport.pyx":279
2608  *
2609  *
2610  * def AllocateReadBuffer(int size):             # <<<<<<<<<<<<<<
2611  *     return PyBuffer_New(size)
2612  *
2613  */
2614 
2615 static PyObject *__pyx_pf_11iocpsupport_1AllocateReadBuffer(PyObject *__pyx_self, PyObject *__pyx_arg_size); /*proto*/
2616 static PyMethodDef __pyx_mdef_11iocpsupport_1AllocateReadBuffer = {__Pyx_NAMESTR("AllocateReadBuffer"), (PyCFunction)__pyx_pf_11iocpsupport_1AllocateReadBuffer, METH_O, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_1AllocateReadBuffer(PyObject * __pyx_self,PyObject * __pyx_arg_size)2617 static PyObject *__pyx_pf_11iocpsupport_1AllocateReadBuffer(PyObject *__pyx_self, PyObject *__pyx_arg_size) {
2618   int __pyx_v_size;
2619   PyObject *__pyx_r = NULL;
2620   __Pyx_RefNannyDeclarations
2621   PyObject *__pyx_t_1 = NULL;
2622   int __pyx_lineno = 0;
2623   const char *__pyx_filename = NULL;
2624   int __pyx_clineno = 0;
2625   __Pyx_RefNannySetupContext("AllocateReadBuffer");
2626   __pyx_self = __pyx_self;
2627   assert(__pyx_arg_size); {
2628     __pyx_v_size = __Pyx_PyInt_AsInt(__pyx_arg_size); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2629   }
2630   goto __pyx_L4_argument_unpacking_done;
2631   __pyx_L3_error:;
2632   __Pyx_AddTraceback("iocpsupport.AllocateReadBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
2633   __Pyx_RefNannyFinishContext();
2634   return NULL;
2635   __pyx_L4_argument_unpacking_done:;
2636 
2637   /* "iocpsupport.pyx":280
2638  *
2639  * def AllocateReadBuffer(int size):
2640  *     return PyBuffer_New(size)             # <<<<<<<<<<<<<<
2641  *
2642  * def maxAddrLen(long s):
2643  */
2644   __Pyx_XDECREF(__pyx_r);
2645   __pyx_t_1 = PyBuffer_New(__pyx_v_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2646   __Pyx_GOTREF(__pyx_t_1);
2647   __pyx_r = __pyx_t_1;
2648   __pyx_t_1 = 0;
2649   goto __pyx_L0;
2650 
2651   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2652   goto __pyx_L0;
2653   __pyx_L1_error:;
2654   __Pyx_XDECREF(__pyx_t_1);
2655   __Pyx_AddTraceback("iocpsupport.AllocateReadBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
2656   __pyx_r = NULL;
2657   __pyx_L0:;
2658   __Pyx_XGIVEREF(__pyx_r);
2659   __Pyx_RefNannyFinishContext();
2660   return __pyx_r;
2661 }
2662 
2663 /* "iocpsupport.pyx":282
2664  *     return PyBuffer_New(size)
2665  *
2666  * def maxAddrLen(long s):             # <<<<<<<<<<<<<<
2667  *     cdef WSAPROTOCOL_INFO wsa_pi
2668  *     cdef int size, rc
2669  */
2670 
2671 static PyObject *__pyx_pf_11iocpsupport_2maxAddrLen(PyObject *__pyx_self, PyObject *__pyx_arg_s); /*proto*/
2672 static PyMethodDef __pyx_mdef_11iocpsupport_2maxAddrLen = {__Pyx_NAMESTR("maxAddrLen"), (PyCFunction)__pyx_pf_11iocpsupport_2maxAddrLen, METH_O, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_2maxAddrLen(PyObject * __pyx_self,PyObject * __pyx_arg_s)2673 static PyObject *__pyx_pf_11iocpsupport_2maxAddrLen(PyObject *__pyx_self, PyObject *__pyx_arg_s) {
2674   long __pyx_v_s;
2675   WSAPROTOCOL_INFO __pyx_v_wsa_pi;
2676   int __pyx_v_size;
2677   int __pyx_v_rc;
2678   PyObject *__pyx_r = NULL;
2679   __Pyx_RefNannyDeclarations
2680   int __pyx_t_1;
2681   PyObject *__pyx_t_2 = NULL;
2682   int __pyx_lineno = 0;
2683   const char *__pyx_filename = NULL;
2684   int __pyx_clineno = 0;
2685   __Pyx_RefNannySetupContext("maxAddrLen");
2686   __pyx_self = __pyx_self;
2687   assert(__pyx_arg_s); {
2688     __pyx_v_s = __Pyx_PyInt_AsLong(__pyx_arg_s); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2689   }
2690   goto __pyx_L4_argument_unpacking_done;
2691   __pyx_L3_error:;
2692   __Pyx_AddTraceback("iocpsupport.maxAddrLen", __pyx_clineno, __pyx_lineno, __pyx_filename);
2693   __Pyx_RefNannyFinishContext();
2694   return NULL;
2695   __pyx_L4_argument_unpacking_done:;
2696 
2697   /* "iocpsupport.pyx":286
2698  *     cdef int size, rc
2699  *
2700  *     size = sizeof(wsa_pi)             # <<<<<<<<<<<<<<
2701  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2702  *     if rc == SOCKET_ERROR:
2703  */
2704   __pyx_v_size = (sizeof(__pyx_v_wsa_pi));
2705 
2706   /* "iocpsupport.pyx":287
2707  *
2708  *     size = sizeof(wsa_pi)
2709  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)             # <<<<<<<<<<<<<<
2710  *     if rc == SOCKET_ERROR:
2711  *         raise_error(WSAGetLastError(), 'getsockopt')
2712  */
2713   __pyx_v_rc = getsockopt(__pyx_v_s, SOL_SOCKET, SO_PROTOCOL_INFO, ((char *)(&__pyx_v_wsa_pi)), (&__pyx_v_size));
2714 
2715   /* "iocpsupport.pyx":288
2716  *     size = sizeof(wsa_pi)
2717  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2718  *     if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
2719  *         raise_error(WSAGetLastError(), 'getsockopt')
2720  *     return wsa_pi.iMaxSockAddr
2721  */
2722   __pyx_t_1 = (__pyx_v_rc == SOCKET_ERROR);
2723   if (__pyx_t_1) {
2724 
2725     /* "iocpsupport.pyx":289
2726  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2727  *     if rc == SOCKET_ERROR:
2728  *         raise_error(WSAGetLastError(), 'getsockopt')             # <<<<<<<<<<<<<<
2729  *     return wsa_pi.iMaxSockAddr
2730  *
2731  */
2732     __pyx_t_2 = ((PyObject *)__pyx_n_s__getsockopt);
2733     __Pyx_INCREF(__pyx_t_2);
2734     __pyx_f_11iocpsupport_raise_error(WSAGetLastError(), __pyx_t_2); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2735     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2736     goto __pyx_L5;
2737   }
2738   __pyx_L5:;
2739 
2740   /* "iocpsupport.pyx":290
2741  *     if rc == SOCKET_ERROR:
2742  *         raise_error(WSAGetLastError(), 'getsockopt')
2743  *     return wsa_pi.iMaxSockAddr             # <<<<<<<<<<<<<<
2744  *
2745  * cdef int getAddrFamily(SOCKET s) except *:
2746  */
2747   __Pyx_XDECREF(__pyx_r);
2748   __pyx_t_2 = PyInt_FromLong(__pyx_v_wsa_pi.iMaxSockAddr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2749   __Pyx_GOTREF(__pyx_t_2);
2750   __pyx_r = __pyx_t_2;
2751   __pyx_t_2 = 0;
2752   goto __pyx_L0;
2753 
2754   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2755   goto __pyx_L0;
2756   __pyx_L1_error:;
2757   __Pyx_XDECREF(__pyx_t_2);
2758   __Pyx_AddTraceback("iocpsupport.maxAddrLen", __pyx_clineno, __pyx_lineno, __pyx_filename);
2759   __pyx_r = NULL;
2760   __pyx_L0:;
2761   __Pyx_XGIVEREF(__pyx_r);
2762   __Pyx_RefNannyFinishContext();
2763   return __pyx_r;
2764 }
2765 
2766 /* "iocpsupport.pyx":292
2767  *     return wsa_pi.iMaxSockAddr
2768  *
2769  * cdef int getAddrFamily(SOCKET s) except *:             # <<<<<<<<<<<<<<
2770  *     cdef WSAPROTOCOL_INFO wsa_pi
2771  *     cdef int size, rc
2772  */
2773 
__pyx_f_11iocpsupport_getAddrFamily(__pyx_t_11iocpsupport_SOCKET __pyx_v_s)2774 static int __pyx_f_11iocpsupport_getAddrFamily(__pyx_t_11iocpsupport_SOCKET __pyx_v_s) {
2775   WSAPROTOCOL_INFO __pyx_v_wsa_pi;
2776   int __pyx_v_size;
2777   int __pyx_v_rc;
2778   int __pyx_r;
2779   __Pyx_RefNannyDeclarations
2780   int __pyx_t_1;
2781   PyObject *__pyx_t_2 = NULL;
2782   int __pyx_lineno = 0;
2783   const char *__pyx_filename = NULL;
2784   int __pyx_clineno = 0;
2785   __Pyx_RefNannySetupContext("getAddrFamily");
2786 
2787   /* "iocpsupport.pyx":296
2788  *     cdef int size, rc
2789  *
2790  *     size = sizeof(wsa_pi)             # <<<<<<<<<<<<<<
2791  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2792  *     if rc == SOCKET_ERROR:
2793  */
2794   __pyx_v_size = (sizeof(__pyx_v_wsa_pi));
2795 
2796   /* "iocpsupport.pyx":297
2797  *
2798  *     size = sizeof(wsa_pi)
2799  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)             # <<<<<<<<<<<<<<
2800  *     if rc == SOCKET_ERROR:
2801  *         raise_error(WSAGetLastError(), 'getsockopt')
2802  */
2803   __pyx_v_rc = getsockopt(__pyx_v_s, SOL_SOCKET, SO_PROTOCOL_INFO, ((char *)(&__pyx_v_wsa_pi)), (&__pyx_v_size));
2804 
2805   /* "iocpsupport.pyx":298
2806  *     size = sizeof(wsa_pi)
2807  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2808  *     if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
2809  *         raise_error(WSAGetLastError(), 'getsockopt')
2810  *     return wsa_pi.iAddressFamily
2811  */
2812   __pyx_t_1 = (__pyx_v_rc == SOCKET_ERROR);
2813   if (__pyx_t_1) {
2814 
2815     /* "iocpsupport.pyx":299
2816  *     rc = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, <char *>&wsa_pi, &size)
2817  *     if rc == SOCKET_ERROR:
2818  *         raise_error(WSAGetLastError(), 'getsockopt')             # <<<<<<<<<<<<<<
2819  *     return wsa_pi.iAddressFamily
2820  *
2821  */
2822     __pyx_t_2 = ((PyObject *)__pyx_n_s__getsockopt);
2823     __Pyx_INCREF(__pyx_t_2);
2824     __pyx_f_11iocpsupport_raise_error(WSAGetLastError(), __pyx_t_2); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2825     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2826     goto __pyx_L3;
2827   }
2828   __pyx_L3:;
2829 
2830   /* "iocpsupport.pyx":300
2831  *     if rc == SOCKET_ERROR:
2832  *         raise_error(WSAGetLastError(), 'getsockopt')
2833  *     return wsa_pi.iAddressFamily             # <<<<<<<<<<<<<<
2834  *
2835  * import socket # for WSAStartup
2836  */
2837   __pyx_r = __pyx_v_wsa_pi.iAddressFamily;
2838   goto __pyx_L0;
2839 
2840   __pyx_r = 0;
2841   goto __pyx_L0;
2842   __pyx_L1_error:;
2843   __Pyx_XDECREF(__pyx_t_2);
2844   __Pyx_AddTraceback("iocpsupport.getAddrFamily", __pyx_clineno, __pyx_lineno, __pyx_filename);
2845   __pyx_r = 0;
2846   __pyx_L0:;
2847   __Pyx_RefNannyFinishContext();
2848   return __pyx_r;
2849 }
2850 
2851 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":5
2852  *
2853  *
2854  * def accept(long listening, long accepting, object buff, object obj):             # <<<<<<<<<<<<<<
2855  *     """
2856  *     CAUTION: unlike system AcceptEx(), this function returns 0 on success
2857  */
2858 
2859 static PyObject *__pyx_pf_11iocpsupport_3accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2860 static char __pyx_doc_11iocpsupport_3accept[] = "\n    CAUTION: unlike system AcceptEx(), this function returns 0 on success\n    ";
2861 static PyMethodDef __pyx_mdef_11iocpsupport_3accept = {__Pyx_NAMESTR("accept"), (PyCFunction)__pyx_pf_11iocpsupport_3accept, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_11iocpsupport_3accept)};
__pyx_pf_11iocpsupport_3accept(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2862 static PyObject *__pyx_pf_11iocpsupport_3accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2863   long __pyx_v_listening;
2864   long __pyx_v_accepting;
2865   PyObject *__pyx_v_buff = 0;
2866   PyObject *__pyx_v_obj = 0;
2867   unsigned long __pyx_v_bytes;
2868   int __pyx_v_rc;
2869   Py_ssize_t __pyx_v_size;
2870   void *__pyx_v_mem_buffer;
2871   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
2872   PyObject *__pyx_r = NULL;
2873   __Pyx_RefNannyDeclarations
2874   int __pyx_t_1;
2875   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_2;
2876   int __pyx_t_3;
2877   PyObject *__pyx_t_4 = NULL;
2878   int __pyx_lineno = 0;
2879   const char *__pyx_filename = NULL;
2880   int __pyx_clineno = 0;
2881   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__listening,&__pyx_n_s__accepting,&__pyx_n_s__buff,&__pyx_n_s__obj,0};
2882   __Pyx_RefNannySetupContext("accept");
2883   __pyx_self = __pyx_self;
2884   {
2885     PyObject* values[4] = {0,0,0,0};
2886     if (unlikely(__pyx_kwds)) {
2887       Py_ssize_t kw_args;
2888       switch (PyTuple_GET_SIZE(__pyx_args)) {
2889         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2890         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2891         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2892         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2893         case  0: break;
2894         default: goto __pyx_L5_argtuple_error;
2895       }
2896       kw_args = PyDict_Size(__pyx_kwds);
2897       switch (PyTuple_GET_SIZE(__pyx_args)) {
2898         case  0:
2899         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__listening);
2900         if (likely(values[0])) kw_args--;
2901         else goto __pyx_L5_argtuple_error;
2902         case  1:
2903         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__accepting);
2904         if (likely(values[1])) kw_args--;
2905         else {
2906           __Pyx_RaiseArgtupleInvalid("accept", 1, 4, 4, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2907         }
2908         case  2:
2909         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buff);
2910         if (likely(values[2])) kw_args--;
2911         else {
2912           __Pyx_RaiseArgtupleInvalid("accept", 1, 4, 4, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2913         }
2914         case  3:
2915         values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
2916         if (likely(values[3])) kw_args--;
2917         else {
2918           __Pyx_RaiseArgtupleInvalid("accept", 1, 4, 4, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2919         }
2920       }
2921       if (unlikely(kw_args > 0)) {
2922         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "accept") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2923       }
2924     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
2925       goto __pyx_L5_argtuple_error;
2926     } else {
2927       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2928       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2929       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2930       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2931     }
2932     __pyx_v_listening = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_listening == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2933     __pyx_v_accepting = __Pyx_PyInt_AsLong(values[1]); if (unlikely((__pyx_v_accepting == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2934     __pyx_v_buff = values[2];
2935     __pyx_v_obj = values[3];
2936   }
2937   goto __pyx_L4_argument_unpacking_done;
2938   __pyx_L5_argtuple_error:;
2939   __Pyx_RaiseArgtupleInvalid("accept", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2940   __pyx_L3_error:;
2941   __Pyx_AddTraceback("iocpsupport.accept", __pyx_clineno, __pyx_lineno, __pyx_filename);
2942   __Pyx_RefNannyFinishContext();
2943   return NULL;
2944   __pyx_L4_argument_unpacking_done:;
2945 
2946   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":15
2947  *     cdef myOVERLAPPED *ov
2948  *
2949  *     PyObject_AsWriteBuffer(buff, &mem_buffer, &size)             # <<<<<<<<<<<<<<
2950  *
2951  *     ov = makeOV()
2952  */
2953   __pyx_t_1 = PyObject_AsWriteBuffer(__pyx_v_buff, (&__pyx_v_mem_buffer), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2954 
2955   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":17
2956  *     PyObject_AsWriteBuffer(buff, &mem_buffer, &size)
2957  *
2958  *     ov = makeOV()             # <<<<<<<<<<<<<<
2959  *     if obj is not None:
2960  *         ov.obj = <PyObject *>obj
2961  */
2962   __pyx_t_2 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2963   __pyx_v_ov = __pyx_t_2;
2964 
2965   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":18
2966  *
2967  *     ov = makeOV()
2968  *     if obj is not None:             # <<<<<<<<<<<<<<
2969  *         ov.obj = <PyObject *>obj
2970  *
2971  */
2972   __pyx_t_3 = (__pyx_v_obj != Py_None);
2973   if (__pyx_t_3) {
2974 
2975     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":19
2976  *     ov = makeOV()
2977  *     if obj is not None:
2978  *         ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
2979  *
2980  *     rc = lpAcceptEx(listening, accepting, mem_buffer, 0,
2981  */
2982     __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
2983     goto __pyx_L6;
2984   }
2985   __pyx_L6:;
2986 
2987   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":23
2988  *     rc = lpAcceptEx(listening, accepting, mem_buffer, 0,
2989  *                     <DWORD>size / 2, <DWORD>size / 2,
2990  *                     &bytes, <OVERLAPPED *>ov)             # <<<<<<<<<<<<<<
2991  *     if not rc:
2992  *         rc = WSAGetLastError()
2993  */
2994   __pyx_v_rc = lpAcceptEx(__pyx_v_listening, __pyx_v_accepting, __pyx_v_mem_buffer, 0, (((__pyx_t_11iocpsupport_DWORD)__pyx_v_size) / 2), (((__pyx_t_11iocpsupport_DWORD)__pyx_v_size) / 2), (&__pyx_v_bytes), ((OVERLAPPED *)__pyx_v_ov));
2995 
2996   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":24
2997  *                     <DWORD>size / 2, <DWORD>size / 2,
2998  *                     &bytes, <OVERLAPPED *>ov)
2999  *     if not rc:             # <<<<<<<<<<<<<<
3000  *         rc = WSAGetLastError()
3001  *         if rc != ERROR_IO_PENDING:
3002  */
3003   __pyx_t_3 = (!__pyx_v_rc);
3004   if (__pyx_t_3) {
3005 
3006     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":25
3007  *                     &bytes, <OVERLAPPED *>ov)
3008  *     if not rc:
3009  *         rc = WSAGetLastError()             # <<<<<<<<<<<<<<
3010  *         if rc != ERROR_IO_PENDING:
3011  *             PyMem_Free(ov)
3012  */
3013     __pyx_v_rc = WSAGetLastError();
3014 
3015     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":26
3016  *     if not rc:
3017  *         rc = WSAGetLastError()
3018  *         if rc != ERROR_IO_PENDING:             # <<<<<<<<<<<<<<
3019  *             PyMem_Free(ov)
3020  *             return rc
3021  */
3022     __pyx_t_3 = (__pyx_v_rc != ERROR_IO_PENDING);
3023     if (__pyx_t_3) {
3024 
3025       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":27
3026  *         rc = WSAGetLastError()
3027  *         if rc != ERROR_IO_PENDING:
3028  *             PyMem_Free(ov)             # <<<<<<<<<<<<<<
3029  *             return rc
3030  *
3031  */
3032       PyMem_Free(__pyx_v_ov);
3033 
3034       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":28
3035  *         if rc != ERROR_IO_PENDING:
3036  *             PyMem_Free(ov)
3037  *             return rc             # <<<<<<<<<<<<<<
3038  *
3039  *     # operation is in progress
3040  */
3041       __Pyx_XDECREF(__pyx_r);
3042       __pyx_t_4 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3043       __Pyx_GOTREF(__pyx_t_4);
3044       __pyx_r = __pyx_t_4;
3045       __pyx_t_4 = 0;
3046       goto __pyx_L0;
3047       goto __pyx_L8;
3048     }
3049     __pyx_L8:;
3050     goto __pyx_L7;
3051   }
3052   __pyx_L7:;
3053 
3054   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":31
3055  *
3056  *     # operation is in progress
3057  *     Py_XINCREF(obj)             # <<<<<<<<<<<<<<
3058  *     return 0
3059  *
3060  */
3061   Py_XINCREF(__pyx_v_obj);
3062 
3063   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":32
3064  *     # operation is in progress
3065  *     Py_XINCREF(obj)
3066  *     return 0             # <<<<<<<<<<<<<<
3067  *
3068  * def get_accept_addrs(long s, object buff):
3069  */
3070   __Pyx_XDECREF(__pyx_r);
3071   __Pyx_INCREF(__pyx_int_0);
3072   __pyx_r = __pyx_int_0;
3073   goto __pyx_L0;
3074 
3075   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3076   goto __pyx_L0;
3077   __pyx_L1_error:;
3078   __Pyx_XDECREF(__pyx_t_4);
3079   __Pyx_AddTraceback("iocpsupport.accept", __pyx_clineno, __pyx_lineno, __pyx_filename);
3080   __pyx_r = NULL;
3081   __pyx_L0:;
3082   __Pyx_XGIVEREF(__pyx_r);
3083   __Pyx_RefNannyFinishContext();
3084   return __pyx_r;
3085 }
3086 
3087 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":34
3088  *     return 0
3089  *
3090  * def get_accept_addrs(long s, object buff):             # <<<<<<<<<<<<<<
3091  *     cdef WSAPROTOCOL_INFO wsa_pi
3092  *     cdef int locallen, remotelen
3093  */
3094 
3095 static PyObject *__pyx_pf_11iocpsupport_4get_accept_addrs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3096 static PyMethodDef __pyx_mdef_11iocpsupport_4get_accept_addrs = {__Pyx_NAMESTR("get_accept_addrs"), (PyCFunction)__pyx_pf_11iocpsupport_4get_accept_addrs, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_4get_accept_addrs(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3097 static PyObject *__pyx_pf_11iocpsupport_4get_accept_addrs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3098   long __pyx_v_s;
3099   PyObject *__pyx_v_buff = 0;
3100   int __pyx_v_locallen;
3101   int __pyx_v_remotelen;
3102   Py_ssize_t __pyx_v_size;
3103   void *__pyx_v_mem_buffer;
3104   struct sockaddr *__pyx_v_localaddr;
3105   struct sockaddr *__pyx_v_remoteaddr;
3106   PyObject *__pyx_r = NULL;
3107   __Pyx_RefNannyDeclarations
3108   int __pyx_t_1;
3109   PyObject *__pyx_t_2 = NULL;
3110   PyObject *__pyx_t_3 = NULL;
3111   PyObject *__pyx_t_4 = NULL;
3112   PyObject *__pyx_t_5 = NULL;
3113   int __pyx_lineno = 0;
3114   const char *__pyx_filename = NULL;
3115   int __pyx_clineno = 0;
3116   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__buff,0};
3117   __Pyx_RefNannySetupContext("get_accept_addrs");
3118   __pyx_self = __pyx_self;
3119   {
3120     PyObject* values[2] = {0,0};
3121     if (unlikely(__pyx_kwds)) {
3122       Py_ssize_t kw_args;
3123       switch (PyTuple_GET_SIZE(__pyx_args)) {
3124         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3125         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3126         case  0: break;
3127         default: goto __pyx_L5_argtuple_error;
3128       }
3129       kw_args = PyDict_Size(__pyx_kwds);
3130       switch (PyTuple_GET_SIZE(__pyx_args)) {
3131         case  0:
3132         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
3133         if (likely(values[0])) kw_args--;
3134         else goto __pyx_L5_argtuple_error;
3135         case  1:
3136         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buff);
3137         if (likely(values[1])) kw_args--;
3138         else {
3139           __Pyx_RaiseArgtupleInvalid("get_accept_addrs", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3140         }
3141       }
3142       if (unlikely(kw_args > 0)) {
3143         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_accept_addrs") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3144       }
3145     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3146       goto __pyx_L5_argtuple_error;
3147     } else {
3148       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3149       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3150     }
3151     __pyx_v_s = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3152     __pyx_v_buff = values[1];
3153   }
3154   goto __pyx_L4_argument_unpacking_done;
3155   __pyx_L5_argtuple_error:;
3156   __Pyx_RaiseArgtupleInvalid("get_accept_addrs", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3157   __pyx_L3_error:;
3158   __Pyx_AddTraceback("iocpsupport.get_accept_addrs", __pyx_clineno, __pyx_lineno, __pyx_filename);
3159   __Pyx_RefNannyFinishContext();
3160   return NULL;
3161   __pyx_L4_argument_unpacking_done:;
3162 
3163   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":41
3164  *     cdef sockaddr *localaddr, *remoteaddr
3165  *
3166  *     PyObject_AsReadBuffer(buff, &mem_buffer, &size)             # <<<<<<<<<<<<<<
3167  *
3168  *     lpGetAcceptExSockaddrs(mem_buffer, 0, <DWORD>size / 2, <DWORD>size / 2,
3169  */
3170   __pyx_t_1 = PyObject_AsReadBuffer(__pyx_v_buff, (&__pyx_v_mem_buffer), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3171 
3172   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":44
3173  *
3174  *     lpGetAcceptExSockaddrs(mem_buffer, 0, <DWORD>size / 2, <DWORD>size / 2,
3175  *                            &localaddr, &locallen, &remoteaddr, &remotelen)             # <<<<<<<<<<<<<<
3176  *     return remoteaddr.sa_family, _makesockaddr(localaddr, locallen), _makesockaddr(remoteaddr, remotelen)
3177  *
3178  */
3179   lpGetAcceptExSockaddrs(__pyx_v_mem_buffer, 0, (((__pyx_t_11iocpsupport_DWORD)__pyx_v_size) / 2), (((__pyx_t_11iocpsupport_DWORD)__pyx_v_size) / 2), (&__pyx_v_localaddr), (&__pyx_v_locallen), (&__pyx_v_remoteaddr), (&__pyx_v_remotelen));
3180 
3181   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":45
3182  *     lpGetAcceptExSockaddrs(mem_buffer, 0, <DWORD>size / 2, <DWORD>size / 2,
3183  *                            &localaddr, &locallen, &remoteaddr, &remotelen)
3184  *     return remoteaddr.sa_family, _makesockaddr(localaddr, locallen), _makesockaddr(remoteaddr, remotelen)             # <<<<<<<<<<<<<<
3185  *
3186  */
3187   __Pyx_XDECREF(__pyx_r);
3188   __pyx_t_2 = PyInt_FromLong(__pyx_v_remoteaddr->sa_family); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3189   __Pyx_GOTREF(__pyx_t_2);
3190   __pyx_t_3 = __pyx_f_11iocpsupport__makesockaddr(__pyx_v_localaddr, __pyx_v_locallen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3191   __Pyx_GOTREF(__pyx_t_3);
3192   __pyx_t_4 = __pyx_f_11iocpsupport__makesockaddr(__pyx_v_remoteaddr, __pyx_v_remotelen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3193   __Pyx_GOTREF(__pyx_t_4);
3194   __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3195   __Pyx_GOTREF(((PyObject *)__pyx_t_5));
3196   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
3197   __Pyx_GIVEREF(__pyx_t_2);
3198   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
3199   __Pyx_GIVEREF(__pyx_t_3);
3200   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
3201   __Pyx_GIVEREF(__pyx_t_4);
3202   __pyx_t_2 = 0;
3203   __pyx_t_3 = 0;
3204   __pyx_t_4 = 0;
3205   __pyx_r = ((PyObject *)__pyx_t_5);
3206   __pyx_t_5 = 0;
3207   goto __pyx_L0;
3208 
3209   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3210   goto __pyx_L0;
3211   __pyx_L1_error:;
3212   __Pyx_XDECREF(__pyx_t_2);
3213   __Pyx_XDECREF(__pyx_t_3);
3214   __Pyx_XDECREF(__pyx_t_4);
3215   __Pyx_XDECREF(__pyx_t_5);
3216   __Pyx_AddTraceback("iocpsupport.get_accept_addrs", __pyx_clineno, __pyx_lineno, __pyx_filename);
3217   __pyx_r = NULL;
3218   __pyx_L0:;
3219   __Pyx_XGIVEREF(__pyx_r);
3220   __Pyx_RefNannyFinishContext();
3221   return __pyx_r;
3222 }
3223 
3224 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":5
3225  *
3226  *
3227  * def connect(long s, object addr, object obj):             # <<<<<<<<<<<<<<
3228  *     """
3229  *     CAUTION: unlike system ConnectEx(), this function returns 0 on success
3230  */
3231 
3232 static PyObject *__pyx_pf_11iocpsupport_5connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3233 static char __pyx_doc_11iocpsupport_5connect[] = "\n    CAUTION: unlike system ConnectEx(), this function returns 0 on success\n    ";
3234 static PyMethodDef __pyx_mdef_11iocpsupport_5connect = {__Pyx_NAMESTR("connect"), (PyCFunction)__pyx_pf_11iocpsupport_5connect, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_11iocpsupport_5connect)};
__pyx_pf_11iocpsupport_5connect(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3235 static PyObject *__pyx_pf_11iocpsupport_5connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3236   long __pyx_v_s;
3237   PyObject *__pyx_v_addr = 0;
3238   PyObject *__pyx_v_obj = 0;
3239   int __pyx_v_family;
3240   int __pyx_v_rc;
3241   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
3242   struct sockaddr_in __pyx_v_ipv4_name;
3243   struct sockaddr_in6 __pyx_v_ipv6_name;
3244   struct sockaddr *__pyx_v_name;
3245   int __pyx_v_namelen;
3246   PyObject *__pyx_r = NULL;
3247   __Pyx_RefNannyDeclarations
3248   PyObject *__pyx_t_1 = NULL;
3249   int __pyx_t_2;
3250   int __pyx_t_3;
3251   int __pyx_t_4;
3252   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_5;
3253   int __pyx_lineno = 0;
3254   const char *__pyx_filename = NULL;
3255   int __pyx_clineno = 0;
3256   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__addr,&__pyx_n_s__obj,0};
3257   __Pyx_RefNannySetupContext("connect");
3258   __pyx_self = __pyx_self;
3259   {
3260     PyObject* values[3] = {0,0,0};
3261     if (unlikely(__pyx_kwds)) {
3262       Py_ssize_t kw_args;
3263       switch (PyTuple_GET_SIZE(__pyx_args)) {
3264         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3265         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3266         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3267         case  0: break;
3268         default: goto __pyx_L5_argtuple_error;
3269       }
3270       kw_args = PyDict_Size(__pyx_kwds);
3271       switch (PyTuple_GET_SIZE(__pyx_args)) {
3272         case  0:
3273         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
3274         if (likely(values[0])) kw_args--;
3275         else goto __pyx_L5_argtuple_error;
3276         case  1:
3277         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__addr);
3278         if (likely(values[1])) kw_args--;
3279         else {
3280           __Pyx_RaiseArgtupleInvalid("connect", 1, 3, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3281         }
3282         case  2:
3283         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
3284         if (likely(values[2])) kw_args--;
3285         else {
3286           __Pyx_RaiseArgtupleInvalid("connect", 1, 3, 3, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3287         }
3288       }
3289       if (unlikely(kw_args > 0)) {
3290         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "connect") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3291       }
3292     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3293       goto __pyx_L5_argtuple_error;
3294     } else {
3295       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3296       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3297       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3298     }
3299     __pyx_v_s = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3300     __pyx_v_addr = values[1];
3301     __pyx_v_obj = values[2];
3302   }
3303   goto __pyx_L4_argument_unpacking_done;
3304   __pyx_L5_argtuple_error:;
3305   __Pyx_RaiseArgtupleInvalid("connect", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3306   __pyx_L3_error:;
3307   __Pyx_AddTraceback("iocpsupport.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
3308   __Pyx_RefNannyFinishContext();
3309   return NULL;
3310   __pyx_L4_argument_unpacking_done:;
3311 
3312   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":16
3313  *     cdef int namelen
3314  *
3315  *     if not have_connectex:             # <<<<<<<<<<<<<<
3316  *         raise ValueError, 'ConnectEx is not available on this system'
3317  *
3318  */
3319   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__have_connectex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3320   __Pyx_GOTREF(__pyx_t_1);
3321   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3322   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3323   __pyx_t_3 = (!__pyx_t_2);
3324   if (__pyx_t_3) {
3325 
3326     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":17
3327  *
3328  *     if not have_connectex:
3329  *         raise ValueError, 'ConnectEx is not available on this system'             # <<<<<<<<<<<<<<
3330  *
3331  *     family = getAddrFamily(s)
3332  */
3333     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_12), 0, 0);
3334     {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3335     goto __pyx_L6;
3336   }
3337   __pyx_L6:;
3338 
3339   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":19
3340  *         raise ValueError, 'ConnectEx is not available on this system'
3341  *
3342  *     family = getAddrFamily(s)             # <<<<<<<<<<<<<<
3343  *     if family == AF_INET:
3344  *         name = <sockaddr *>&ipv4_name
3345  */
3346   __pyx_t_4 = __pyx_f_11iocpsupport_getAddrFamily(__pyx_v_s); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3347   __pyx_v_family = __pyx_t_4;
3348 
3349   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":24
3350  *         namelen = sizeof(ipv4_name)
3351  *         fillinetaddr(&ipv4_name, addr)
3352  *     elif family == AF_INET6:             # <<<<<<<<<<<<<<
3353  *         name = <sockaddr *>&ipv6_name
3354  *         namelen = sizeof(ipv6_name)
3355  */
3356   switch (__pyx_v_family) {
3357 
3358     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":20
3359  *
3360  *     family = getAddrFamily(s)
3361  *     if family == AF_INET:             # <<<<<<<<<<<<<<
3362  *         name = <sockaddr *>&ipv4_name
3363  *         namelen = sizeof(ipv4_name)
3364  */
3365     case AF_INET:
3366 
3367     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":21
3368  *     family = getAddrFamily(s)
3369  *     if family == AF_INET:
3370  *         name = <sockaddr *>&ipv4_name             # <<<<<<<<<<<<<<
3371  *         namelen = sizeof(ipv4_name)
3372  *         fillinetaddr(&ipv4_name, addr)
3373  */
3374     __pyx_v_name = ((struct sockaddr *)(&__pyx_v_ipv4_name));
3375 
3376     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":22
3377  *     if family == AF_INET:
3378  *         name = <sockaddr *>&ipv4_name
3379  *         namelen = sizeof(ipv4_name)             # <<<<<<<<<<<<<<
3380  *         fillinetaddr(&ipv4_name, addr)
3381  *     elif family == AF_INET6:
3382  */
3383     __pyx_v_namelen = (sizeof(__pyx_v_ipv4_name));
3384 
3385     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":23
3386  *         name = <sockaddr *>&ipv4_name
3387  *         namelen = sizeof(ipv4_name)
3388  *         fillinetaddr(&ipv4_name, addr)             # <<<<<<<<<<<<<<
3389  *     elif family == AF_INET6:
3390  *         name = <sockaddr *>&ipv6_name
3391  */
3392     __pyx_t_1 = __pyx_f_11iocpsupport_fillinetaddr((&__pyx_v_ipv4_name), __pyx_v_addr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3393     __Pyx_GOTREF(__pyx_t_1);
3394     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3395     break;
3396 
3397     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":24
3398  *         namelen = sizeof(ipv4_name)
3399  *         fillinetaddr(&ipv4_name, addr)
3400  *     elif family == AF_INET6:             # <<<<<<<<<<<<<<
3401  *         name = <sockaddr *>&ipv6_name
3402  *         namelen = sizeof(ipv6_name)
3403  */
3404     case AF_INET6:
3405 
3406     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":25
3407  *         fillinetaddr(&ipv4_name, addr)
3408  *     elif family == AF_INET6:
3409  *         name = <sockaddr *>&ipv6_name             # <<<<<<<<<<<<<<
3410  *         namelen = sizeof(ipv6_name)
3411  *         fillinet6addr(&ipv6_name, addr)
3412  */
3413     __pyx_v_name = ((struct sockaddr *)(&__pyx_v_ipv6_name));
3414 
3415     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":26
3416  *     elif family == AF_INET6:
3417  *         name = <sockaddr *>&ipv6_name
3418  *         namelen = sizeof(ipv6_name)             # <<<<<<<<<<<<<<
3419  *         fillinet6addr(&ipv6_name, addr)
3420  *     else:
3421  */
3422     __pyx_v_namelen = (sizeof(__pyx_v_ipv6_name));
3423 
3424     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":27
3425  *         name = <sockaddr *>&ipv6_name
3426  *         namelen = sizeof(ipv6_name)
3427  *         fillinet6addr(&ipv6_name, addr)             # <<<<<<<<<<<<<<
3428  *     else:
3429  *         raise ValueError, 'unsupported address family'
3430  */
3431     __pyx_t_1 = __pyx_f_11iocpsupport_fillinet6addr((&__pyx_v_ipv6_name), __pyx_v_addr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3432     __Pyx_GOTREF(__pyx_t_1);
3433     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3434     break;
3435     default:
3436 
3437     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":29
3438  *         fillinet6addr(&ipv6_name, addr)
3439  *     else:
3440  *         raise ValueError, 'unsupported address family'             # <<<<<<<<<<<<<<
3441  *     name.sa_family = family
3442  *
3443  */
3444     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_13), 0, 0);
3445     {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3446     break;
3447   }
3448 
3449   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":30
3450  *     else:
3451  *         raise ValueError, 'unsupported address family'
3452  *     name.sa_family = family             # <<<<<<<<<<<<<<
3453  *
3454  *     ov = makeOV()
3455  */
3456   __pyx_v_name->sa_family = __pyx_v_family;
3457 
3458   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":32
3459  *     name.sa_family = family
3460  *
3461  *     ov = makeOV()             # <<<<<<<<<<<<<<
3462  *     if obj is not None:
3463  *         ov.obj = <PyObject *>obj
3464  */
3465   __pyx_t_5 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3466   __pyx_v_ov = __pyx_t_5;
3467 
3468   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":33
3469  *
3470  *     ov = makeOV()
3471  *     if obj is not None:             # <<<<<<<<<<<<<<
3472  *         ov.obj = <PyObject *>obj
3473  *
3474  */
3475   __pyx_t_3 = (__pyx_v_obj != Py_None);
3476   if (__pyx_t_3) {
3477 
3478     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":34
3479  *     ov = makeOV()
3480  *     if obj is not None:
3481  *         ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
3482  *
3483  *     rc = lpConnectEx(s, name, namelen, NULL, 0, NULL, <OVERLAPPED *>ov)
3484  */
3485     __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
3486     goto __pyx_L7;
3487   }
3488   __pyx_L7:;
3489 
3490   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":36
3491  *         ov.obj = <PyObject *>obj
3492  *
3493  *     rc = lpConnectEx(s, name, namelen, NULL, 0, NULL, <OVERLAPPED *>ov)             # <<<<<<<<<<<<<<
3494  *
3495  *     if not rc:
3496  */
3497   __pyx_v_rc = lpConnectEx(__pyx_v_s, __pyx_v_name, __pyx_v_namelen, NULL, 0, NULL, ((OVERLAPPED *)__pyx_v_ov));
3498 
3499   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":38
3500  *     rc = lpConnectEx(s, name, namelen, NULL, 0, NULL, <OVERLAPPED *>ov)
3501  *
3502  *     if not rc:             # <<<<<<<<<<<<<<
3503  *         rc = WSAGetLastError()
3504  *         if rc != ERROR_IO_PENDING:
3505  */
3506   __pyx_t_3 = (!__pyx_v_rc);
3507   if (__pyx_t_3) {
3508 
3509     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":39
3510  *
3511  *     if not rc:
3512  *         rc = WSAGetLastError()             # <<<<<<<<<<<<<<
3513  *         if rc != ERROR_IO_PENDING:
3514  *             PyMem_Free(ov)
3515  */
3516     __pyx_v_rc = WSAGetLastError();
3517 
3518     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":40
3519  *     if not rc:
3520  *         rc = WSAGetLastError()
3521  *         if rc != ERROR_IO_PENDING:             # <<<<<<<<<<<<<<
3522  *             PyMem_Free(ov)
3523  *             return rc
3524  */
3525     __pyx_t_3 = (__pyx_v_rc != ERROR_IO_PENDING);
3526     if (__pyx_t_3) {
3527 
3528       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":41
3529  *         rc = WSAGetLastError()
3530  *         if rc != ERROR_IO_PENDING:
3531  *             PyMem_Free(ov)             # <<<<<<<<<<<<<<
3532  *             return rc
3533  *
3534  */
3535       PyMem_Free(__pyx_v_ov);
3536 
3537       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":42
3538  *         if rc != ERROR_IO_PENDING:
3539  *             PyMem_Free(ov)
3540  *             return rc             # <<<<<<<<<<<<<<
3541  *
3542  *     # operation is in progress
3543  */
3544       __Pyx_XDECREF(__pyx_r);
3545       __pyx_t_1 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3546       __Pyx_GOTREF(__pyx_t_1);
3547       __pyx_r = __pyx_t_1;
3548       __pyx_t_1 = 0;
3549       goto __pyx_L0;
3550       goto __pyx_L9;
3551     }
3552     __pyx_L9:;
3553     goto __pyx_L8;
3554   }
3555   __pyx_L8:;
3556 
3557   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":45
3558  *
3559  *     # operation is in progress
3560  *     Py_XINCREF(obj)             # <<<<<<<<<<<<<<
3561  *     return 0
3562  *
3563  */
3564   Py_XINCREF(__pyx_v_obj);
3565 
3566   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":46
3567  *     # operation is in progress
3568  *     Py_XINCREF(obj)
3569  *     return 0             # <<<<<<<<<<<<<<
3570  *
3571  */
3572   __Pyx_XDECREF(__pyx_r);
3573   __Pyx_INCREF(__pyx_int_0);
3574   __pyx_r = __pyx_int_0;
3575   goto __pyx_L0;
3576 
3577   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3578   goto __pyx_L0;
3579   __pyx_L1_error:;
3580   __Pyx_XDECREF(__pyx_t_1);
3581   __Pyx_AddTraceback("iocpsupport.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
3582   __pyx_r = NULL;
3583   __pyx_L0:;
3584   __Pyx_XGIVEREF(__pyx_r);
3585   __Pyx_RefNannyFinishContext();
3586   return __pyx_r;
3587 }
3588 
3589 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":5
3590  *
3591  *
3592  * def recv(long s, object bufflist, object obj, unsigned long flags = 0):             # <<<<<<<<<<<<<<
3593  *     cdef int rc, res
3594  *     cdef myOVERLAPPED *ov
3595  */
3596 
3597 static PyObject *__pyx_pf_11iocpsupport_6recv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3598 static PyMethodDef __pyx_mdef_11iocpsupport_6recv = {__Pyx_NAMESTR("recv"), (PyCFunction)__pyx_pf_11iocpsupport_6recv, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_6recv(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3599 static PyObject *__pyx_pf_11iocpsupport_6recv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3600   long __pyx_v_s;
3601   PyObject *__pyx_v_bufflist = 0;
3602   PyObject *__pyx_v_obj = 0;
3603   unsigned long __pyx_v_flags;
3604   int __pyx_v_rc;
3605   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
3606   WSABUF *__pyx_v_ws_buf;
3607   unsigned long __pyx_v_bytes;
3608   struct PyObject **__pyx_v_buffers;
3609   Py_ssize_t __pyx_v_i;
3610   Py_ssize_t __pyx_v_size;
3611   Py_ssize_t __pyx_v_buffcount;
3612   PyObject *__pyx_r = NULL;
3613   __Pyx_RefNannyDeclarations
3614   PyObject *__pyx_t_1 = NULL;
3615   void *__pyx_t_2;
3616   Py_ssize_t __pyx_t_3;
3617   int __pyx_t_4;
3618   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_5;
3619   int __pyx_t_6;
3620   PyObject *__pyx_t_7 = NULL;
3621   PyObject *__pyx_t_8 = NULL;
3622   int __pyx_lineno = 0;
3623   const char *__pyx_filename = NULL;
3624   int __pyx_clineno = 0;
3625   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__bufflist,&__pyx_n_s__obj,&__pyx_n_s__flags,0};
3626   __Pyx_RefNannySetupContext("recv");
3627   __pyx_self = __pyx_self;
3628   {
3629     PyObject* values[4] = {0,0,0,0};
3630     if (unlikely(__pyx_kwds)) {
3631       Py_ssize_t kw_args;
3632       switch (PyTuple_GET_SIZE(__pyx_args)) {
3633         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3634         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3635         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3636         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3637         case  0: break;
3638         default: goto __pyx_L5_argtuple_error;
3639       }
3640       kw_args = PyDict_Size(__pyx_kwds);
3641       switch (PyTuple_GET_SIZE(__pyx_args)) {
3642         case  0:
3643         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
3644         if (likely(values[0])) kw_args--;
3645         else goto __pyx_L5_argtuple_error;
3646         case  1:
3647         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bufflist);
3648         if (likely(values[1])) kw_args--;
3649         else {
3650           __Pyx_RaiseArgtupleInvalid("recv", 0, 3, 4, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3651         }
3652         case  2:
3653         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
3654         if (likely(values[2])) kw_args--;
3655         else {
3656           __Pyx_RaiseArgtupleInvalid("recv", 0, 3, 4, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3657         }
3658         case  3:
3659         if (kw_args > 0) {
3660           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
3661           if (value) { values[3] = value; kw_args--; }
3662         }
3663       }
3664       if (unlikely(kw_args > 0)) {
3665         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3666       }
3667     } else {
3668       switch (PyTuple_GET_SIZE(__pyx_args)) {
3669         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3670         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3671         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3672         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3673         break;
3674         default: goto __pyx_L5_argtuple_error;
3675       }
3676     }
3677     __pyx_v_s = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3678     __pyx_v_bufflist = values[1];
3679     __pyx_v_obj = values[2];
3680     if (values[3]) {
3681       __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[3]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3682     } else {
3683       __pyx_v_flags = ((unsigned long)0);
3684     }
3685   }
3686   goto __pyx_L4_argument_unpacking_done;
3687   __pyx_L5_argtuple_error:;
3688   __Pyx_RaiseArgtupleInvalid("recv", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3689   __pyx_L3_error:;
3690   __Pyx_AddTraceback("iocpsupport.recv", __pyx_clineno, __pyx_lineno, __pyx_filename);
3691   __Pyx_RefNannyFinishContext();
3692   return NULL;
3693   __pyx_L4_argument_unpacking_done:;
3694   __Pyx_INCREF(__pyx_v_bufflist);
3695 
3696   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":13
3697  *     cdef Py_ssize_t i, size, buffcount
3698  *
3699  *     bufflist = PySequence_Fast(bufflist, 'second argument needs to be a list')             # <<<<<<<<<<<<<<
3700  *     buffcount = PySequence_Fast_GET_SIZE(bufflist)
3701  *     buffers = PySequence_Fast_ITEMS(bufflist)
3702  */
3703   __pyx_t_1 = PySequence_Fast(__pyx_v_bufflist, __pyx_k_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3704   __Pyx_GOTREF(__pyx_t_1);
3705   __Pyx_DECREF(__pyx_v_bufflist);
3706   __pyx_v_bufflist = __pyx_t_1;
3707   __pyx_t_1 = 0;
3708 
3709   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":14
3710  *
3711  *     bufflist = PySequence_Fast(bufflist, 'second argument needs to be a list')
3712  *     buffcount = PySequence_Fast_GET_SIZE(bufflist)             # <<<<<<<<<<<<<<
3713  *     buffers = PySequence_Fast_ITEMS(bufflist)
3714  *
3715  */
3716   __pyx_v_buffcount = PySequence_Fast_GET_SIZE(__pyx_v_bufflist);
3717 
3718   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":15
3719  *     bufflist = PySequence_Fast(bufflist, 'second argument needs to be a list')
3720  *     buffcount = PySequence_Fast_GET_SIZE(bufflist)
3721  *     buffers = PySequence_Fast_ITEMS(bufflist)             # <<<<<<<<<<<<<<
3722  *
3723  *     ws_buf = <WSABUF *>PyMem_Malloc(buffcount*sizeof(WSABUF))
3724  */
3725   __pyx_v_buffers = PySequence_Fast_ITEMS(__pyx_v_bufflist);
3726 
3727   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":17
3728  *     buffers = PySequence_Fast_ITEMS(bufflist)
3729  *
3730  *     ws_buf = <WSABUF *>PyMem_Malloc(buffcount*sizeof(WSABUF))             # <<<<<<<<<<<<<<
3731  *
3732  *     try:
3733  */
3734   __pyx_t_2 = PyMem_Malloc((__pyx_v_buffcount * (sizeof(WSABUF)))); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3735   __pyx_v_ws_buf = ((WSABUF *)__pyx_t_2);
3736 
3737   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":19
3738  *     ws_buf = <WSABUF *>PyMem_Malloc(buffcount*sizeof(WSABUF))
3739  *
3740  *     try:             # <<<<<<<<<<<<<<
3741  *         for i from 0 <= i < buffcount:
3742  *             PyObject_AsWriteBuffer(<object>buffers[i], <void **>&ws_buf[i].buf, &size)
3743  */
3744   /*try:*/ {
3745 
3746     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":20
3747  *
3748  *     try:
3749  *         for i from 0 <= i < buffcount:             # <<<<<<<<<<<<<<
3750  *             PyObject_AsWriteBuffer(<object>buffers[i], <void **>&ws_buf[i].buf, &size)
3751  *             ws_buf[i].len = <DWORD>size
3752  */
3753     __pyx_t_3 = __pyx_v_buffcount;
3754     for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {
3755 
3756       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":21
3757  *     try:
3758  *         for i from 0 <= i < buffcount:
3759  *             PyObject_AsWriteBuffer(<object>buffers[i], <void **>&ws_buf[i].buf, &size)             # <<<<<<<<<<<<<<
3760  *             ws_buf[i].len = <DWORD>size
3761  *
3762  */
3763       __pyx_t_1 = ((PyObject *)(__pyx_v_buffers[__pyx_v_i]));
3764       __Pyx_INCREF(__pyx_t_1);
3765       __pyx_t_4 = PyObject_AsWriteBuffer(__pyx_t_1, ((void **)(&(__pyx_v_ws_buf[__pyx_v_i]).buf)), (&__pyx_v_size)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L7;}
3766       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3767 
3768       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":22
3769  *         for i from 0 <= i < buffcount:
3770  *             PyObject_AsWriteBuffer(<object>buffers[i], <void **>&ws_buf[i].buf, &size)
3771  *             ws_buf[i].len = <DWORD>size             # <<<<<<<<<<<<<<
3772  *
3773  *         ov = makeOV()
3774  */
3775       (__pyx_v_ws_buf[__pyx_v_i]).len = ((__pyx_t_11iocpsupport_DWORD)__pyx_v_size);
3776     }
3777 
3778     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":24
3779  *             ws_buf[i].len = <DWORD>size
3780  *
3781  *         ov = makeOV()             # <<<<<<<<<<<<<<
3782  *         if obj is not None:
3783  *             ov.obj = <PyObject *>obj
3784  */
3785     __pyx_t_5 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L7;}
3786     __pyx_v_ov = __pyx_t_5;
3787 
3788     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":25
3789  *
3790  *         ov = makeOV()
3791  *         if obj is not None:             # <<<<<<<<<<<<<<
3792  *             ov.obj = <PyObject *>obj
3793  *
3794  */
3795     __pyx_t_6 = (__pyx_v_obj != Py_None);
3796     if (__pyx_t_6) {
3797 
3798       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":26
3799  *         ov = makeOV()
3800  *         if obj is not None:
3801  *             ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
3802  *
3803  *         rc = WSARecv(s, ws_buf, <DWORD>buffcount, &bytes, &flags, <OVERLAPPED *>ov, NULL)
3804  */
3805       __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
3806       goto __pyx_L11;
3807     }
3808     __pyx_L11:;
3809 
3810     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":28
3811  *             ov.obj = <PyObject *>obj
3812  *
3813  *         rc = WSARecv(s, ws_buf, <DWORD>buffcount, &bytes, &flags, <OVERLAPPED *>ov, NULL)             # <<<<<<<<<<<<<<
3814  *
3815  *         if rc == SOCKET_ERROR:
3816  */
3817     __pyx_v_rc = WSARecv(__pyx_v_s, __pyx_v_ws_buf, ((__pyx_t_11iocpsupport_DWORD)__pyx_v_buffcount), (&__pyx_v_bytes), (&__pyx_v_flags), ((OVERLAPPED *)__pyx_v_ov), NULL);
3818 
3819     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":30
3820  *         rc = WSARecv(s, ws_buf, <DWORD>buffcount, &bytes, &flags, <OVERLAPPED *>ov, NULL)
3821  *
3822  *         if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
3823  *             rc = WSAGetLastError()
3824  *             if rc != ERROR_IO_PENDING:
3825  */
3826     __pyx_t_6 = (__pyx_v_rc == SOCKET_ERROR);
3827     if (__pyx_t_6) {
3828 
3829       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":31
3830  *
3831  *         if rc == SOCKET_ERROR:
3832  *             rc = WSAGetLastError()             # <<<<<<<<<<<<<<
3833  *             if rc != ERROR_IO_PENDING:
3834  *                 PyMem_Free(ov)
3835  */
3836       __pyx_v_rc = WSAGetLastError();
3837 
3838       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":32
3839  *         if rc == SOCKET_ERROR:
3840  *             rc = WSAGetLastError()
3841  *             if rc != ERROR_IO_PENDING:             # <<<<<<<<<<<<<<
3842  *                 PyMem_Free(ov)
3843  *                 return rc, 0
3844  */
3845       __pyx_t_6 = (__pyx_v_rc != ERROR_IO_PENDING);
3846       if (__pyx_t_6) {
3847 
3848         /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":33
3849  *             rc = WSAGetLastError()
3850  *             if rc != ERROR_IO_PENDING:
3851  *                 PyMem_Free(ov)             # <<<<<<<<<<<<<<
3852  *                 return rc, 0
3853  *
3854  */
3855         PyMem_Free(__pyx_v_ov);
3856 
3857         /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":34
3858  *             if rc != ERROR_IO_PENDING:
3859  *                 PyMem_Free(ov)
3860  *                 return rc, 0             # <<<<<<<<<<<<<<
3861  *
3862  *         Py_XINCREF(obj)
3863  */
3864         __Pyx_XDECREF(__pyx_r);
3865         __pyx_t_1 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L7;}
3866         __Pyx_GOTREF(__pyx_t_1);
3867         __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L7;}
3868         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
3869         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
3870         __Pyx_GIVEREF(__pyx_t_1);
3871         __Pyx_INCREF(__pyx_int_0);
3872         PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_0);
3873         __Pyx_GIVEREF(__pyx_int_0);
3874         __pyx_t_1 = 0;
3875         __pyx_r = ((PyObject *)__pyx_t_7);
3876         __pyx_t_7 = 0;
3877         goto __pyx_L6;
3878         goto __pyx_L13;
3879       }
3880       __pyx_L13:;
3881       goto __pyx_L12;
3882     }
3883     __pyx_L12:;
3884 
3885     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":36
3886  *                 return rc, 0
3887  *
3888  *         Py_XINCREF(obj)             # <<<<<<<<<<<<<<
3889  *         return rc, bytes
3890  *     finally:
3891  */
3892     Py_XINCREF(__pyx_v_obj);
3893 
3894     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":37
3895  *
3896  *         Py_XINCREF(obj)
3897  *         return rc, bytes             # <<<<<<<<<<<<<<
3898  *     finally:
3899  *         PyMem_Free(ws_buf)
3900  */
3901     __Pyx_XDECREF(__pyx_r);
3902     __pyx_t_7 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L7;}
3903     __Pyx_GOTREF(__pyx_t_7);
3904     __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L7;}
3905     __Pyx_GOTREF(__pyx_t_1);
3906     __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L7;}
3907     __Pyx_GOTREF(((PyObject *)__pyx_t_8));
3908     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
3909     __Pyx_GIVEREF(__pyx_t_7);
3910     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
3911     __Pyx_GIVEREF(__pyx_t_1);
3912     __pyx_t_7 = 0;
3913     __pyx_t_1 = 0;
3914     __pyx_r = ((PyObject *)__pyx_t_8);
3915     __pyx_t_8 = 0;
3916     goto __pyx_L6;
3917   }
3918 
3919   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":39
3920  *         return rc, bytes
3921  *     finally:
3922  *         PyMem_Free(ws_buf)             # <<<<<<<<<<<<<<
3923  *
3924  * def recvfrom(long s, object buff, object addr_buff, object addr_len_buff, object obj, unsigned long flags = 0):
3925  */
3926   /*finally:*/ {
3927     int __pyx_why;
3928     PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
3929     int __pyx_exc_lineno;
3930     __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
3931     __pyx_why = 0; goto __pyx_L8;
3932     __pyx_L6: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
3933     __pyx_why = 3; goto __pyx_L8;
3934     __pyx_L7: {
3935       __pyx_why = 4;
3936       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3937       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3938       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
3939       __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
3940       __pyx_exc_lineno = __pyx_lineno;
3941       goto __pyx_L8;
3942     }
3943     __pyx_L8:;
3944     PyMem_Free(__pyx_v_ws_buf);
3945     switch (__pyx_why) {
3946       case 3: goto __pyx_L0;
3947       case 4: {
3948         __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
3949         __pyx_lineno = __pyx_exc_lineno;
3950         __pyx_exc_type = 0;
3951         __pyx_exc_value = 0;
3952         __pyx_exc_tb = 0;
3953         goto __pyx_L1_error;
3954       }
3955     }
3956   }
3957 
3958   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3959   goto __pyx_L0;
3960   __pyx_L1_error:;
3961   __Pyx_XDECREF(__pyx_t_1);
3962   __Pyx_XDECREF(__pyx_t_7);
3963   __Pyx_XDECREF(__pyx_t_8);
3964   __Pyx_AddTraceback("iocpsupport.recv", __pyx_clineno, __pyx_lineno, __pyx_filename);
3965   __pyx_r = NULL;
3966   __pyx_L0:;
3967   __Pyx_XDECREF(__pyx_v_bufflist);
3968   __Pyx_XGIVEREF(__pyx_r);
3969   __Pyx_RefNannyFinishContext();
3970   return __pyx_r;
3971 }
3972 
3973 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":41
3974  *         PyMem_Free(ws_buf)
3975  *
3976  * def recvfrom(long s, object buff, object addr_buff, object addr_len_buff, object obj, unsigned long flags = 0):             # <<<<<<<<<<<<<<
3977  *     cdef int rc, c_addr_buff_len, c_addr_len_buff_len
3978  *     cdef myOVERLAPPED *ov
3979  */
3980 
3981 static PyObject *__pyx_pf_11iocpsupport_7recvfrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3982 static PyMethodDef __pyx_mdef_11iocpsupport_7recvfrom = {__Pyx_NAMESTR("recvfrom"), (PyCFunction)__pyx_pf_11iocpsupport_7recvfrom, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_7recvfrom(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3983 static PyObject *__pyx_pf_11iocpsupport_7recvfrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3984   long __pyx_v_s;
3985   PyObject *__pyx_v_buff = 0;
3986   PyObject *__pyx_v_addr_buff = 0;
3987   PyObject *__pyx_v_addr_len_buff = 0;
3988   PyObject *__pyx_v_obj = 0;
3989   unsigned long __pyx_v_flags;
3990   int __pyx_v_rc;
3991   int __pyx_v_c_addr_buff_len;
3992   int __pyx_v_c_addr_len_buff_len;
3993   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
3994   WSABUF __pyx_v_ws_buf;
3995   unsigned long __pyx_v_bytes;
3996   struct sockaddr *__pyx_v_c_addr_buff;
3997   int *__pyx_v_c_addr_len_buff;
3998   Py_ssize_t __pyx_v_size;
3999   PyObject *__pyx_r = NULL;
4000   __Pyx_RefNannyDeclarations
4001   int __pyx_t_1;
4002   int __pyx_t_2;
4003   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_3;
4004   PyObject *__pyx_t_4 = NULL;
4005   PyObject *__pyx_t_5 = NULL;
4006   PyObject *__pyx_t_6 = NULL;
4007   int __pyx_lineno = 0;
4008   const char *__pyx_filename = NULL;
4009   int __pyx_clineno = 0;
4010   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__buff,&__pyx_n_s__addr_buff,&__pyx_n_s__addr_len_buff,&__pyx_n_s__obj,&__pyx_n_s__flags,0};
4011   __Pyx_RefNannySetupContext("recvfrom");
4012   __pyx_self = __pyx_self;
4013   {
4014     PyObject* values[6] = {0,0,0,0,0,0};
4015     if (unlikely(__pyx_kwds)) {
4016       Py_ssize_t kw_args;
4017       switch (PyTuple_GET_SIZE(__pyx_args)) {
4018         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
4019         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4020         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4021         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4022         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4023         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4024         case  0: break;
4025         default: goto __pyx_L5_argtuple_error;
4026       }
4027       kw_args = PyDict_Size(__pyx_kwds);
4028       switch (PyTuple_GET_SIZE(__pyx_args)) {
4029         case  0:
4030         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
4031         if (likely(values[0])) kw_args--;
4032         else goto __pyx_L5_argtuple_error;
4033         case  1:
4034         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buff);
4035         if (likely(values[1])) kw_args--;
4036         else {
4037           __Pyx_RaiseArgtupleInvalid("recvfrom", 0, 5, 6, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4038         }
4039         case  2:
4040         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__addr_buff);
4041         if (likely(values[2])) kw_args--;
4042         else {
4043           __Pyx_RaiseArgtupleInvalid("recvfrom", 0, 5, 6, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4044         }
4045         case  3:
4046         values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__addr_len_buff);
4047         if (likely(values[3])) kw_args--;
4048         else {
4049           __Pyx_RaiseArgtupleInvalid("recvfrom", 0, 5, 6, 3); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4050         }
4051         case  4:
4052         values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
4053         if (likely(values[4])) kw_args--;
4054         else {
4055           __Pyx_RaiseArgtupleInvalid("recvfrom", 0, 5, 6, 4); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4056         }
4057         case  5:
4058         if (kw_args > 0) {
4059           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
4060           if (value) { values[5] = value; kw_args--; }
4061         }
4062       }
4063       if (unlikely(kw_args > 0)) {
4064         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recvfrom") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4065       }
4066     } else {
4067       switch (PyTuple_GET_SIZE(__pyx_args)) {
4068         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
4069         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4070         values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4071         values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4072         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4073         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4074         break;
4075         default: goto __pyx_L5_argtuple_error;
4076       }
4077     }
4078     __pyx_v_s = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4079     __pyx_v_buff = values[1];
4080     __pyx_v_addr_buff = values[2];
4081     __pyx_v_addr_len_buff = values[3];
4082     __pyx_v_obj = values[4];
4083     if (values[5]) {
4084       __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[5]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4085     } else {
4086       __pyx_v_flags = ((unsigned long)0);
4087     }
4088   }
4089   goto __pyx_L4_argument_unpacking_done;
4090   __pyx_L5_argtuple_error:;
4091   __Pyx_RaiseArgtupleInvalid("recvfrom", 0, 5, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4092   __pyx_L3_error:;
4093   __Pyx_AddTraceback("iocpsupport.recvfrom", __pyx_clineno, __pyx_lineno, __pyx_filename);
4094   __Pyx_RefNannyFinishContext();
4095   return NULL;
4096   __pyx_L4_argument_unpacking_done:;
4097 
4098   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":50
4099  *     cdef Py_ssize_t size
4100  *
4101  *     PyObject_AsWriteBuffer(buff, <void **>&ws_buf.buf, &size)             # <<<<<<<<<<<<<<
4102  *     ws_buf.len = <DWORD>size
4103  *     PyObject_AsWriteBuffer(addr_buff, <void **>&c_addr_buff, &size)
4104  */
4105   __pyx_t_1 = PyObject_AsWriteBuffer(__pyx_v_buff, ((void **)(&__pyx_v_ws_buf.buf)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4106 
4107   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":51
4108  *
4109  *     PyObject_AsWriteBuffer(buff, <void **>&ws_buf.buf, &size)
4110  *     ws_buf.len = <DWORD>size             # <<<<<<<<<<<<<<
4111  *     PyObject_AsWriteBuffer(addr_buff, <void **>&c_addr_buff, &size)
4112  *     c_addr_buff_len = <int>size
4113  */
4114   __pyx_v_ws_buf.len = ((__pyx_t_11iocpsupport_DWORD)__pyx_v_size);
4115 
4116   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":52
4117  *     PyObject_AsWriteBuffer(buff, <void **>&ws_buf.buf, &size)
4118  *     ws_buf.len = <DWORD>size
4119  *     PyObject_AsWriteBuffer(addr_buff, <void **>&c_addr_buff, &size)             # <<<<<<<<<<<<<<
4120  *     c_addr_buff_len = <int>size
4121  *     PyObject_AsWriteBuffer(addr_len_buff, <void **>&c_addr_len_buff, &size)
4122  */
4123   __pyx_t_1 = PyObject_AsWriteBuffer(__pyx_v_addr_buff, ((void **)(&__pyx_v_c_addr_buff)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4124 
4125   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":53
4126  *     ws_buf.len = <DWORD>size
4127  *     PyObject_AsWriteBuffer(addr_buff, <void **>&c_addr_buff, &size)
4128  *     c_addr_buff_len = <int>size             # <<<<<<<<<<<<<<
4129  *     PyObject_AsWriteBuffer(addr_len_buff, <void **>&c_addr_len_buff, &size)
4130  *     c_addr_len_buff_len = <int>size
4131  */
4132   __pyx_v_c_addr_buff_len = ((int)__pyx_v_size);
4133 
4134   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":54
4135  *     PyObject_AsWriteBuffer(addr_buff, <void **>&c_addr_buff, &size)
4136  *     c_addr_buff_len = <int>size
4137  *     PyObject_AsWriteBuffer(addr_len_buff, <void **>&c_addr_len_buff, &size)             # <<<<<<<<<<<<<<
4138  *     c_addr_len_buff_len = <int>size
4139  *
4140  */
4141   __pyx_t_1 = PyObject_AsWriteBuffer(__pyx_v_addr_len_buff, ((void **)(&__pyx_v_c_addr_len_buff)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4142 
4143   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":55
4144  *     c_addr_buff_len = <int>size
4145  *     PyObject_AsWriteBuffer(addr_len_buff, <void **>&c_addr_len_buff, &size)
4146  *     c_addr_len_buff_len = <int>size             # <<<<<<<<<<<<<<
4147  *
4148  *     if c_addr_len_buff_len != sizeof(int):
4149  */
4150   __pyx_v_c_addr_len_buff_len = ((int)__pyx_v_size);
4151 
4152   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":57
4153  *     c_addr_len_buff_len = <int>size
4154  *
4155  *     if c_addr_len_buff_len != sizeof(int):             # <<<<<<<<<<<<<<
4156  *         raise ValueError, 'length of address length buffer needs to be sizeof(int)'
4157  *
4158  */
4159   __pyx_t_2 = (__pyx_v_c_addr_len_buff_len != (sizeof(int)));
4160   if (__pyx_t_2) {
4161 
4162     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":58
4163  *
4164  *     if c_addr_len_buff_len != sizeof(int):
4165  *         raise ValueError, 'length of address length buffer needs to be sizeof(int)'             # <<<<<<<<<<<<<<
4166  *
4167  *     c_addr_len_buff[0] = c_addr_buff_len
4168  */
4169     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_15), 0, 0);
4170     {__pyx_filename = __pyx_f[3]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4171     goto __pyx_L6;
4172   }
4173   __pyx_L6:;
4174 
4175   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":60
4176  *         raise ValueError, 'length of address length buffer needs to be sizeof(int)'
4177  *
4178  *     c_addr_len_buff[0] = c_addr_buff_len             # <<<<<<<<<<<<<<
4179  *
4180  *     ov = makeOV()
4181  */
4182   (__pyx_v_c_addr_len_buff[0]) = __pyx_v_c_addr_buff_len;
4183 
4184   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":62
4185  *     c_addr_len_buff[0] = c_addr_buff_len
4186  *
4187  *     ov = makeOV()             # <<<<<<<<<<<<<<
4188  *     if obj is not None:
4189  *         ov.obj = <PyObject *>obj
4190  */
4191   __pyx_t_3 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4192   __pyx_v_ov = __pyx_t_3;
4193 
4194   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":63
4195  *
4196  *     ov = makeOV()
4197  *     if obj is not None:             # <<<<<<<<<<<<<<
4198  *         ov.obj = <PyObject *>obj
4199  *
4200  */
4201   __pyx_t_2 = (__pyx_v_obj != Py_None);
4202   if (__pyx_t_2) {
4203 
4204     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":64
4205  *     ov = makeOV()
4206  *     if obj is not None:
4207  *         ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
4208  *
4209  *     rc = WSARecvFrom(s, &ws_buf, 1, &bytes, &flags, c_addr_buff, c_addr_len_buff, <OVERLAPPED *>ov, NULL)
4210  */
4211     __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
4212     goto __pyx_L7;
4213   }
4214   __pyx_L7:;
4215 
4216   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":66
4217  *         ov.obj = <PyObject *>obj
4218  *
4219  *     rc = WSARecvFrom(s, &ws_buf, 1, &bytes, &flags, c_addr_buff, c_addr_len_buff, <OVERLAPPED *>ov, NULL)             # <<<<<<<<<<<<<<
4220  *
4221  *     if rc == SOCKET_ERROR:
4222  */
4223   __pyx_v_rc = WSARecvFrom(__pyx_v_s, (&__pyx_v_ws_buf), 1, (&__pyx_v_bytes), (&__pyx_v_flags), __pyx_v_c_addr_buff, __pyx_v_c_addr_len_buff, ((OVERLAPPED *)__pyx_v_ov), NULL);
4224 
4225   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":68
4226  *     rc = WSARecvFrom(s, &ws_buf, 1, &bytes, &flags, c_addr_buff, c_addr_len_buff, <OVERLAPPED *>ov, NULL)
4227  *
4228  *     if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
4229  *         rc = WSAGetLastError()
4230  *         if rc != ERROR_IO_PENDING:
4231  */
4232   __pyx_t_2 = (__pyx_v_rc == SOCKET_ERROR);
4233   if (__pyx_t_2) {
4234 
4235     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":69
4236  *
4237  *     if rc == SOCKET_ERROR:
4238  *         rc = WSAGetLastError()             # <<<<<<<<<<<<<<
4239  *         if rc != ERROR_IO_PENDING:
4240  *             PyMem_Free(ov)
4241  */
4242     __pyx_v_rc = WSAGetLastError();
4243 
4244     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":70
4245  *     if rc == SOCKET_ERROR:
4246  *         rc = WSAGetLastError()
4247  *         if rc != ERROR_IO_PENDING:             # <<<<<<<<<<<<<<
4248  *             PyMem_Free(ov)
4249  *             return rc, 0
4250  */
4251     __pyx_t_2 = (__pyx_v_rc != ERROR_IO_PENDING);
4252     if (__pyx_t_2) {
4253 
4254       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":71
4255  *         rc = WSAGetLastError()
4256  *         if rc != ERROR_IO_PENDING:
4257  *             PyMem_Free(ov)             # <<<<<<<<<<<<<<
4258  *             return rc, 0
4259  *
4260  */
4261       PyMem_Free(__pyx_v_ov);
4262 
4263       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":72
4264  *         if rc != ERROR_IO_PENDING:
4265  *             PyMem_Free(ov)
4266  *             return rc, 0             # <<<<<<<<<<<<<<
4267  *
4268  *     Py_XINCREF(obj)
4269  */
4270       __Pyx_XDECREF(__pyx_r);
4271       __pyx_t_4 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4272       __Pyx_GOTREF(__pyx_t_4);
4273       __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4274       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
4275       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
4276       __Pyx_GIVEREF(__pyx_t_4);
4277       __Pyx_INCREF(__pyx_int_0);
4278       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
4279       __Pyx_GIVEREF(__pyx_int_0);
4280       __pyx_t_4 = 0;
4281       __pyx_r = ((PyObject *)__pyx_t_5);
4282       __pyx_t_5 = 0;
4283       goto __pyx_L0;
4284       goto __pyx_L9;
4285     }
4286     __pyx_L9:;
4287     goto __pyx_L8;
4288   }
4289   __pyx_L8:;
4290 
4291   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":74
4292  *             return rc, 0
4293  *
4294  *     Py_XINCREF(obj)             # <<<<<<<<<<<<<<
4295  *     return rc, bytes
4296  *
4297  */
4298   Py_XINCREF(__pyx_v_obj);
4299 
4300   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":75
4301  *
4302  *     Py_XINCREF(obj)
4303  *     return rc, bytes             # <<<<<<<<<<<<<<
4304  *
4305  */
4306   __Pyx_XDECREF(__pyx_r);
4307   __pyx_t_5 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4308   __Pyx_GOTREF(__pyx_t_5);
4309   __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_bytes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4310   __Pyx_GOTREF(__pyx_t_4);
4311   __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4312   __Pyx_GOTREF(((PyObject *)__pyx_t_6));
4313   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
4314   __Pyx_GIVEREF(__pyx_t_5);
4315   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
4316   __Pyx_GIVEREF(__pyx_t_4);
4317   __pyx_t_5 = 0;
4318   __pyx_t_4 = 0;
4319   __pyx_r = ((PyObject *)__pyx_t_6);
4320   __pyx_t_6 = 0;
4321   goto __pyx_L0;
4322 
4323   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4324   goto __pyx_L0;
4325   __pyx_L1_error:;
4326   __Pyx_XDECREF(__pyx_t_4);
4327   __Pyx_XDECREF(__pyx_t_5);
4328   __Pyx_XDECREF(__pyx_t_6);
4329   __Pyx_AddTraceback("iocpsupport.recvfrom", __pyx_clineno, __pyx_lineno, __pyx_filename);
4330   __pyx_r = NULL;
4331   __pyx_L0:;
4332   __Pyx_XGIVEREF(__pyx_r);
4333   __Pyx_RefNannyFinishContext();
4334   return __pyx_r;
4335 }
4336 
4337 /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":5
4338  *
4339  *
4340  * def send(long s, object buff, object obj, unsigned long flags = 0):             # <<<<<<<<<<<<<<
4341  *     cdef int rc
4342  *     cdef myOVERLAPPED *ov
4343  */
4344 
4345 static PyObject *__pyx_pf_11iocpsupport_8send(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4346 static PyMethodDef __pyx_mdef_11iocpsupport_8send = {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_11iocpsupport_8send, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
__pyx_pf_11iocpsupport_8send(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4347 static PyObject *__pyx_pf_11iocpsupport_8send(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4348   long __pyx_v_s;
4349   PyObject *__pyx_v_buff = 0;
4350   PyObject *__pyx_v_obj = 0;
4351   unsigned long __pyx_v_flags;
4352   int __pyx_v_rc;
4353   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_v_ov;
4354   WSABUF __pyx_v_ws_buf;
4355   unsigned long __pyx_v_bytes;
4356   Py_ssize_t __pyx_v_size;
4357   PyObject *__pyx_r = NULL;
4358   __Pyx_RefNannyDeclarations
4359   int __pyx_t_1;
4360   struct __pyx_t_11iocpsupport_myOVERLAPPED *__pyx_t_2;
4361   int __pyx_t_3;
4362   PyObject *__pyx_t_4 = NULL;
4363   PyObject *__pyx_t_5 = NULL;
4364   PyObject *__pyx_t_6 = NULL;
4365   int __pyx_lineno = 0;
4366   const char *__pyx_filename = NULL;
4367   int __pyx_clineno = 0;
4368   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__buff,&__pyx_n_s__obj,&__pyx_n_s__flags,0};
4369   __Pyx_RefNannySetupContext("send");
4370   __pyx_self = __pyx_self;
4371   {
4372     PyObject* values[4] = {0,0,0,0};
4373     if (unlikely(__pyx_kwds)) {
4374       Py_ssize_t kw_args;
4375       switch (PyTuple_GET_SIZE(__pyx_args)) {
4376         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4377         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4378         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4379         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4380         case  0: break;
4381         default: goto __pyx_L5_argtuple_error;
4382       }
4383       kw_args = PyDict_Size(__pyx_kwds);
4384       switch (PyTuple_GET_SIZE(__pyx_args)) {
4385         case  0:
4386         values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
4387         if (likely(values[0])) kw_args--;
4388         else goto __pyx_L5_argtuple_error;
4389         case  1:
4390         values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buff);
4391         if (likely(values[1])) kw_args--;
4392         else {
4393           __Pyx_RaiseArgtupleInvalid("send", 0, 3, 4, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4394         }
4395         case  2:
4396         values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
4397         if (likely(values[2])) kw_args--;
4398         else {
4399           __Pyx_RaiseArgtupleInvalid("send", 0, 3, 4, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4400         }
4401         case  3:
4402         if (kw_args > 0) {
4403           PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
4404           if (value) { values[3] = value; kw_args--; }
4405         }
4406       }
4407       if (unlikely(kw_args > 0)) {
4408         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4409       }
4410     } else {
4411       switch (PyTuple_GET_SIZE(__pyx_args)) {
4412         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4413         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4414         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4415         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4416         break;
4417         default: goto __pyx_L5_argtuple_error;
4418       }
4419     }
4420     __pyx_v_s = __Pyx_PyInt_AsLong(values[0]); if (unlikely((__pyx_v_s == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4421     __pyx_v_buff = values[1];
4422     __pyx_v_obj = values[2];
4423     if (values[3]) {
4424       __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[3]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4425     } else {
4426       __pyx_v_flags = ((unsigned long)0);
4427     }
4428   }
4429   goto __pyx_L4_argument_unpacking_done;
4430   __pyx_L5_argtuple_error:;
4431   __Pyx_RaiseArgtupleInvalid("send", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4432   __pyx_L3_error:;
4433   __Pyx_AddTraceback("iocpsupport.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
4434   __Pyx_RefNannyFinishContext();
4435   return NULL;
4436   __pyx_L4_argument_unpacking_done:;
4437 
4438   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":12
4439  *     cdef Py_ssize_t size
4440  *
4441  *     PyObject_AsReadBuffer(buff, <void **>&ws_buf.buf, &size)             # <<<<<<<<<<<<<<
4442  *     ws_buf.len = <DWORD>size
4443  *
4444  */
4445   __pyx_t_1 = PyObject_AsReadBuffer(__pyx_v_buff, ((void **)(&__pyx_v_ws_buf.buf)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4446 
4447   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":13
4448  *
4449  *     PyObject_AsReadBuffer(buff, <void **>&ws_buf.buf, &size)
4450  *     ws_buf.len = <DWORD>size             # <<<<<<<<<<<<<<
4451  *
4452  *     ov = makeOV()
4453  */
4454   __pyx_v_ws_buf.len = ((__pyx_t_11iocpsupport_DWORD)__pyx_v_size);
4455 
4456   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":15
4457  *     ws_buf.len = <DWORD>size
4458  *
4459  *     ov = makeOV()             # <<<<<<<<<<<<<<
4460  *     if obj is not None:
4461  *         ov.obj = <PyObject *>obj
4462  */
4463   __pyx_t_2 = __pyx_f_11iocpsupport_makeOV(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4464   __pyx_v_ov = __pyx_t_2;
4465 
4466   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":16
4467  *
4468  *     ov = makeOV()
4469  *     if obj is not None:             # <<<<<<<<<<<<<<
4470  *         ov.obj = <PyObject *>obj
4471  *
4472  */
4473   __pyx_t_3 = (__pyx_v_obj != Py_None);
4474   if (__pyx_t_3) {
4475 
4476     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":17
4477  *     ov = makeOV()
4478  *     if obj is not None:
4479  *         ov.obj = <PyObject *>obj             # <<<<<<<<<<<<<<
4480  *
4481  *     rc = WSASend(s, &ws_buf, 1, &bytes, flags, <OVERLAPPED *>ov, NULL)
4482  */
4483     __pyx_v_ov->obj = ((struct PyObject *)__pyx_v_obj);
4484     goto __pyx_L6;
4485   }
4486   __pyx_L6:;
4487 
4488   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":19
4489  *         ov.obj = <PyObject *>obj
4490  *
4491  *     rc = WSASend(s, &ws_buf, 1, &bytes, flags, <OVERLAPPED *>ov, NULL)             # <<<<<<<<<<<<<<
4492  *
4493  *     if rc == SOCKET_ERROR:
4494  */
4495   __pyx_v_rc = WSASend(__pyx_v_s, (&__pyx_v_ws_buf), 1, (&__pyx_v_bytes), __pyx_v_flags, ((OVERLAPPED *)__pyx_v_ov), NULL);
4496 
4497   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":21
4498  *     rc = WSASend(s, &ws_buf, 1, &bytes, flags, <OVERLAPPED *>ov, NULL)
4499  *
4500  *     if rc == SOCKET_ERROR:             # <<<<<<<<<<<<<<
4501  *         rc = WSAGetLastError()
4502  *         if rc != ERROR_IO_PENDING:
4503  */
4504   __pyx_t_3 = (__pyx_v_rc == SOCKET_ERROR);
4505   if (__pyx_t_3) {
4506 
4507     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":22
4508  *
4509  *     if rc == SOCKET_ERROR:
4510  *         rc = WSAGetLastError()             # <<<<<<<<<<<<<<
4511  *         if rc != ERROR_IO_PENDING:
4512  *             PyMem_Free(ov)
4513  */
4514     __pyx_v_rc = WSAGetLastError();
4515 
4516     /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":23
4517  *     if rc == SOCKET_ERROR:
4518  *         rc = WSAGetLastError()
4519  *         if rc != ERROR_IO_PENDING:             # <<<<<<<<<<<<<<
4520  *             PyMem_Free(ov)
4521  *             return rc, bytes
4522  */
4523     __pyx_t_3 = (__pyx_v_rc != ERROR_IO_PENDING);
4524     if (__pyx_t_3) {
4525 
4526       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":24
4527  *         rc = WSAGetLastError()
4528  *         if rc != ERROR_IO_PENDING:
4529  *             PyMem_Free(ov)             # <<<<<<<<<<<<<<
4530  *             return rc, bytes
4531  *
4532  */
4533       PyMem_Free(__pyx_v_ov);
4534 
4535       /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":25
4536  *         if rc != ERROR_IO_PENDING:
4537  *             PyMem_Free(ov)
4538  *             return rc, bytes             # <<<<<<<<<<<<<<
4539  *
4540  *     Py_XINCREF(obj)
4541  */
4542       __Pyx_XDECREF(__pyx_r);
4543       __pyx_t_4 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4544       __Pyx_GOTREF(__pyx_t_4);
4545       __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_bytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4546       __Pyx_GOTREF(__pyx_t_5);
4547       __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4548       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
4549       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
4550       __Pyx_GIVEREF(__pyx_t_4);
4551       PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
4552       __Pyx_GIVEREF(__pyx_t_5);
4553       __pyx_t_4 = 0;
4554       __pyx_t_5 = 0;
4555       __pyx_r = ((PyObject *)__pyx_t_6);
4556       __pyx_t_6 = 0;
4557       goto __pyx_L0;
4558       goto __pyx_L8;
4559     }
4560     __pyx_L8:;
4561     goto __pyx_L7;
4562   }
4563   __pyx_L7:;
4564 
4565   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":27
4566  *             return rc, bytes
4567  *
4568  *     Py_XINCREF(obj)             # <<<<<<<<<<<<<<
4569  *     return rc, bytes
4570  *
4571  */
4572   Py_XINCREF(__pyx_v_obj);
4573 
4574   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":28
4575  *
4576  *     Py_XINCREF(obj)
4577  *     return rc, bytes             # <<<<<<<<<<<<<<
4578  *
4579  *
4580  */
4581   __Pyx_XDECREF(__pyx_r);
4582   __pyx_t_6 = PyInt_FromLong(__pyx_v_rc); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4583   __Pyx_GOTREF(__pyx_t_6);
4584   __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_bytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4585   __Pyx_GOTREF(__pyx_t_5);
4586   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4587   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
4588   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
4589   __Pyx_GIVEREF(__pyx_t_6);
4590   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
4591   __Pyx_GIVEREF(__pyx_t_5);
4592   __pyx_t_6 = 0;
4593   __pyx_t_5 = 0;
4594   __pyx_r = ((PyObject *)__pyx_t_4);
4595   __pyx_t_4 = 0;
4596   goto __pyx_L0;
4597 
4598   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4599   goto __pyx_L0;
4600   __pyx_L1_error:;
4601   __Pyx_XDECREF(__pyx_t_4);
4602   __Pyx_XDECREF(__pyx_t_5);
4603   __Pyx_XDECREF(__pyx_t_6);
4604   __Pyx_AddTraceback("iocpsupport.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
4605   __pyx_r = NULL;
4606   __pyx_L0:;
4607   __Pyx_XGIVEREF(__pyx_r);
4608   __Pyx_RefNannyFinishContext();
4609   return __pyx_r;
4610 }
4611 
__pyx_tp_new_11iocpsupport_CompletionPort(PyTypeObject * t,PyObject * a,PyObject * k)4612 static PyObject *__pyx_tp_new_11iocpsupport_CompletionPort(PyTypeObject *t, PyObject *a, PyObject *k) {
4613   PyObject *o = (*t->tp_alloc)(t, 0);
4614   if (!o) return 0;
4615   return o;
4616 }
4617 
__pyx_tp_dealloc_11iocpsupport_CompletionPort(PyObject * o)4618 static void __pyx_tp_dealloc_11iocpsupport_CompletionPort(PyObject *o) {
4619   (*Py_TYPE(o)->tp_free)(o);
4620 }
4621 
4622 static PyMethodDef __pyx_methods_11iocpsupport_CompletionPort[] = {
4623   {__Pyx_NAMESTR("addHandle"), (PyCFunction)__pyx_pf_11iocpsupport_14CompletionPort_1addHandle, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
4624   {__Pyx_NAMESTR("getEvent"), (PyCFunction)__pyx_pf_11iocpsupport_14CompletionPort_2getEvent, METH_O, __Pyx_DOCSTR(0)},
4625   {__Pyx_NAMESTR("postEvent"), (PyCFunction)__pyx_pf_11iocpsupport_14CompletionPort_3postEvent, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
4626   {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_11iocpsupport_14CompletionPort_4__del__, METH_NOARGS, __Pyx_DOCSTR(0)},
4627   {0, 0, 0, 0}
4628 };
4629 
4630 static PyNumberMethods __pyx_tp_as_number_CompletionPort = {
4631   0, /*nb_add*/
4632   0, /*nb_subtract*/
4633   0, /*nb_multiply*/
4634   #if PY_MAJOR_VERSION < 3
4635   0, /*nb_divide*/
4636   #endif
4637   0, /*nb_remainder*/
4638   0, /*nb_divmod*/
4639   0, /*nb_power*/
4640   0, /*nb_negative*/
4641   0, /*nb_positive*/
4642   0, /*nb_absolute*/
4643   0, /*nb_nonzero*/
4644   0, /*nb_invert*/
4645   0, /*nb_lshift*/
4646   0, /*nb_rshift*/
4647   0, /*nb_and*/
4648   0, /*nb_xor*/
4649   0, /*nb_or*/
4650   #if PY_MAJOR_VERSION < 3
4651   0, /*nb_coerce*/
4652   #endif
4653   0, /*nb_int*/
4654   #if PY_MAJOR_VERSION < 3
4655   0, /*nb_long*/
4656   #else
4657   0, /*reserved*/
4658   #endif
4659   0, /*nb_float*/
4660   #if PY_MAJOR_VERSION < 3
4661   0, /*nb_oct*/
4662   #endif
4663   #if PY_MAJOR_VERSION < 3
4664   0, /*nb_hex*/
4665   #endif
4666   0, /*nb_inplace_add*/
4667   0, /*nb_inplace_subtract*/
4668   0, /*nb_inplace_multiply*/
4669   #if PY_MAJOR_VERSION < 3
4670   0, /*nb_inplace_divide*/
4671   #endif
4672   0, /*nb_inplace_remainder*/
4673   0, /*nb_inplace_power*/
4674   0, /*nb_inplace_lshift*/
4675   0, /*nb_inplace_rshift*/
4676   0, /*nb_inplace_and*/
4677   0, /*nb_inplace_xor*/
4678   0, /*nb_inplace_or*/
4679   0, /*nb_floor_divide*/
4680   0, /*nb_true_divide*/
4681   0, /*nb_inplace_floor_divide*/
4682   0, /*nb_inplace_true_divide*/
4683   #if PY_VERSION_HEX >= 0x02050000
4684   0, /*nb_index*/
4685   #endif
4686 };
4687 
4688 static PySequenceMethods __pyx_tp_as_sequence_CompletionPort = {
4689   0, /*sq_length*/
4690   0, /*sq_concat*/
4691   0, /*sq_repeat*/
4692   0, /*sq_item*/
4693   0, /*sq_slice*/
4694   0, /*sq_ass_item*/
4695   0, /*sq_ass_slice*/
4696   0, /*sq_contains*/
4697   0, /*sq_inplace_concat*/
4698   0, /*sq_inplace_repeat*/
4699 };
4700 
4701 static PyMappingMethods __pyx_tp_as_mapping_CompletionPort = {
4702   0, /*mp_length*/
4703   0, /*mp_subscript*/
4704   0, /*mp_ass_subscript*/
4705 };
4706 
4707 static PyBufferProcs __pyx_tp_as_buffer_CompletionPort = {
4708   #if PY_MAJOR_VERSION < 3
4709   0, /*bf_getreadbuffer*/
4710   #endif
4711   #if PY_MAJOR_VERSION < 3
4712   0, /*bf_getwritebuffer*/
4713   #endif
4714   #if PY_MAJOR_VERSION < 3
4715   0, /*bf_getsegcount*/
4716   #endif
4717   #if PY_MAJOR_VERSION < 3
4718   0, /*bf_getcharbuffer*/
4719   #endif
4720   #if PY_VERSION_HEX >= 0x02060000
4721   0, /*bf_getbuffer*/
4722   #endif
4723   #if PY_VERSION_HEX >= 0x02060000
4724   0, /*bf_releasebuffer*/
4725   #endif
4726 };
4727 
4728 static PyTypeObject __pyx_type_11iocpsupport_CompletionPort = {
4729   PyVarObject_HEAD_INIT(0, 0)
4730   __Pyx_NAMESTR("iocpsupport.CompletionPort"), /*tp_name*/
4731   sizeof(struct __pyx_obj_11iocpsupport_CompletionPort), /*tp_basicsize*/
4732   0, /*tp_itemsize*/
4733   __pyx_tp_dealloc_11iocpsupport_CompletionPort, /*tp_dealloc*/
4734   0, /*tp_print*/
4735   0, /*tp_getattr*/
4736   0, /*tp_setattr*/
4737   #if PY_MAJOR_VERSION < 3
4738   0, /*tp_compare*/
4739   #else
4740   0, /*reserved*/
4741   #endif
4742   0, /*tp_repr*/
4743   &__pyx_tp_as_number_CompletionPort, /*tp_as_number*/
4744   &__pyx_tp_as_sequence_CompletionPort, /*tp_as_sequence*/
4745   &__pyx_tp_as_mapping_CompletionPort, /*tp_as_mapping*/
4746   0, /*tp_hash*/
4747   0, /*tp_call*/
4748   0, /*tp_str*/
4749   0, /*tp_getattro*/
4750   0, /*tp_setattro*/
4751   &__pyx_tp_as_buffer_CompletionPort, /*tp_as_buffer*/
4752   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
4753   0, /*tp_doc*/
4754   0, /*tp_traverse*/
4755   0, /*tp_clear*/
4756   0, /*tp_richcompare*/
4757   0, /*tp_weaklistoffset*/
4758   0, /*tp_iter*/
4759   0, /*tp_iternext*/
4760   __pyx_methods_11iocpsupport_CompletionPort, /*tp_methods*/
4761   0, /*tp_members*/
4762   0, /*tp_getset*/
4763   0, /*tp_base*/
4764   0, /*tp_dict*/
4765   0, /*tp_descr_get*/
4766   0, /*tp_descr_set*/
4767   0, /*tp_dictoffset*/
4768   __pyx_pf_11iocpsupport_14CompletionPort___init__, /*tp_init*/
4769   0, /*tp_alloc*/
4770   __pyx_tp_new_11iocpsupport_CompletionPort, /*tp_new*/
4771   0, /*tp_free*/
4772   0, /*tp_is_gc*/
4773   0, /*tp_bases*/
4774   0, /*tp_mro*/
4775   0, /*tp_cache*/
4776   0, /*tp_subclasses*/
4777   0, /*tp_weaklist*/
4778   0, /*tp_del*/
4779   #if PY_VERSION_HEX >= 0x02060000
4780   0, /*tp_version_tag*/
4781   #endif
4782 };
4783 
4784 static PyMethodDef __pyx_methods[] = {
4785   {0, 0, 0, 0}
4786 };
4787 
4788 #if PY_MAJOR_VERSION >= 3
4789 static struct PyModuleDef __pyx_moduledef = {
4790     PyModuleDef_HEAD_INIT,
4791     __Pyx_NAMESTR("iocpsupport"),
4792     0, /* m_doc */
4793     -1, /* m_size */
4794     __pyx_methods /* m_methods */,
4795     NULL, /* m_reload */
4796     NULL, /* m_traverse */
4797     NULL, /* m_clear */
4798     NULL /* m_free */
4799 };
4800 #endif
4801 
4802 static __Pyx_StringTabEntry __pyx_string_tab[] = {
4803   {&__pyx_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
4804   {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
4805   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
4806   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
4807   {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
4808   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
4809   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
4810   {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
4811   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
4812   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
4813   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
4814   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
4815   {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
4816   {&__pyx_n_s__AllocateReadBuffer, __pyx_k__AllocateReadBuffer, sizeof(__pyx_k__AllocateReadBuffer), 0, 0, 1, 1},
4817   {&__pyx_n_s__Event, __pyx_k__Event, sizeof(__pyx_k__Event), 0, 0, 1, 1},
4818   {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
4819   {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
4820   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
4821   {&__pyx_n_s__WSAAddressToString, __pyx_k__WSAAddressToString, sizeof(__pyx_k__WSAAddressToString), 0, 0, 1, 1},
4822   {&__pyx_n_s__WindowsError, __pyx_k__WindowsError, sizeof(__pyx_k__WindowsError), 0, 0, 1, 1},
4823   {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
4824   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
4825   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
4826   {&__pyx_n_s__accept, __pyx_k__accept, sizeof(__pyx_k__accept), 0, 0, 1, 1},
4827   {&__pyx_n_s__accepting, __pyx_k__accepting, sizeof(__pyx_k__accepting), 0, 0, 1, 1},
4828   {&__pyx_n_s__addr, __pyx_k__addr, sizeof(__pyx_k__addr), 0, 0, 1, 1},
4829   {&__pyx_n_s__addr_buff, __pyx_k__addr_buff, sizeof(__pyx_k__addr_buff), 0, 0, 1, 1},
4830   {&__pyx_n_s__addr_len_buff, __pyx_k__addr_len_buff, sizeof(__pyx_k__addr_len_buff), 0, 0, 1, 1},
4831   {&__pyx_n_s__buff, __pyx_k__buff, sizeof(__pyx_k__buff), 0, 0, 1, 1},
4832   {&__pyx_n_s__bufflist, __pyx_k__bufflist, sizeof(__pyx_k__bufflist), 0, 0, 1, 1},
4833   {&__pyx_n_s__bytes, __pyx_k__bytes, sizeof(__pyx_k__bytes), 0, 0, 1, 1},
4834   {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1},
4835   {&__pyx_n_s__connect, __pyx_k__connect, sizeof(__pyx_k__connect), 0, 0, 1, 1},
4836   {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
4837   {&__pyx_n_s__get_accept_addrs, __pyx_k__get_accept_addrs, sizeof(__pyx_k__get_accept_addrs), 0, 0, 1, 1},
4838   {&__pyx_n_s__getsockopt, __pyx_k__getsockopt, sizeof(__pyx_k__getsockopt), 0, 0, 1, 1},
4839   {&__pyx_n_s__handle, __pyx_k__handle, sizeof(__pyx_k__handle), 0, 0, 1, 1},
4840   {&__pyx_n_s__have_connectex, __pyx_k__have_connectex, sizeof(__pyx_k__have_connectex), 0, 0, 1, 1},
4841   {&__pyx_n_s__iocpsupport, __pyx_k__iocpsupport, sizeof(__pyx_k__iocpsupport), 0, 0, 1, 1},
4842   {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
4843   {&__pyx_n_s__listening, __pyx_k__listening, sizeof(__pyx_k__listening), 0, 0, 1, 1},
4844   {&__pyx_n_s__makesockaddr, __pyx_k__makesockaddr, sizeof(__pyx_k__makesockaddr), 0, 0, 1, 1},
4845   {&__pyx_n_s__maxAddrLen, __pyx_k__maxAddrLen, sizeof(__pyx_k__maxAddrLen), 0, 0, 1, 1},
4846   {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
4847   {&__pyx_n_s__owner, __pyx_k__owner, sizeof(__pyx_k__owner), 0, 0, 1, 1},
4848   {&__pyx_n_s__recv, __pyx_k__recv, sizeof(__pyx_k__recv), 0, 0, 1, 1},
4849   {&__pyx_n_s__recvfrom, __pyx_k__recvfrom, sizeof(__pyx_k__recvfrom), 0, 0, 1, 1},
4850   {&__pyx_n_s__rsplit, __pyx_k__rsplit, sizeof(__pyx_k__rsplit), 0, 0, 1, 1},
4851   {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
4852   {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
4853   {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1},
4854   {&__pyx_n_s__socket, __pyx_k__socket, sizeof(__pyx_k__socket), 0, 0, 1, 1},
4855   {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
4856   {0, 0, 0, 0, 0, 0, 0}
4857 };
__Pyx_InitCachedBuiltins(void)4858 static int __Pyx_InitCachedBuiltins(void) {
4859   __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4860   __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4861   __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4862   return 0;
4863   __pyx_L1_error:;
4864   return -1;
4865 }
4866 
__Pyx_InitCachedConstants(void)4867 static int __Pyx_InitCachedConstants(void) {
4868   __Pyx_RefNannyDeclarations
4869   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
4870 
4871   /* "iocpsupport.pyx":233
4872  *             raise_error(0, 'WSAAddressToString')
4873  *         host, sa_port = PyString_FromString(buff), ntohs(sin6.sin6_port)
4874  *         host, port = host.rsplit(':', 1)             # <<<<<<<<<<<<<<
4875  *         port = int(port)
4876  *         assert host[0] == '['
4877  */
4878   __pyx_k_tuple_4 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4879   __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
4880   __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
4881   PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
4882   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
4883   __Pyx_INCREF(__pyx_int_1);
4884   PyTuple_SET_ITEM(__pyx_k_tuple_4, 1, __pyx_int_1);
4885   __Pyx_GIVEREF(__pyx_int_1);
4886   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
4887 
4888   /* "iocpsupport.pyx":264
4889  *     cdef int addrlen = sizeof(sockaddr_in6)
4890  *     host, port, flow, scope = addr
4891  *     host = host.split("%")[0] # remove scope ID, if any             # <<<<<<<<<<<<<<
4892  *
4893  *     hoststr = PyString_AsString(host)
4894  */
4895   __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4896   __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
4897   __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
4898   PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
4899   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
4900   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));
4901   __Pyx_RefNannyFinishContext();
4902   return 0;
4903   __pyx_L1_error:;
4904   __Pyx_RefNannyFinishContext();
4905   return -1;
4906 }
4907 
__Pyx_InitGlobals(void)4908 static int __Pyx_InitGlobals(void) {
4909   if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
4910   __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;};
4911   __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;};
4912   return 0;
4913   __pyx_L1_error:;
4914   return -1;
4915 }
4916 
4917 #if PY_MAJOR_VERSION < 3
4918 PyMODINIT_FUNC initiocpsupport(void); /*proto*/
initiocpsupport(void)4919 PyMODINIT_FUNC initiocpsupport(void)
4920 #else
4921 PyMODINIT_FUNC PyInit_iocpsupport(void); /*proto*/
4922 PyMODINIT_FUNC PyInit_iocpsupport(void)
4923 #endif
4924 {
4925   PyObject *__pyx_t_1 = NULL;
4926   PyObject *__pyx_t_2 = NULL;
4927   int __pyx_t_3;
4928   __Pyx_RefNannyDeclarations
4929   #if CYTHON_REFNANNY
4930   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
4931   if (!__Pyx_RefNanny) {
4932       PyErr_Clear();
4933       __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
4934       if (!__Pyx_RefNanny)
4935           Py_FatalError("failed to import 'refnanny' module");
4936   }
4937   #endif
4938   __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_iocpsupport(void)");
4939   if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4940   __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;}
4941   __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;}
4942   #ifdef __pyx_binding_PyCFunctionType_USED
4943   if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4944   #endif
4945   /*--- Library function declarations ---*/
4946   /*--- Threads initialization code ---*/
4947   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
4948   #ifdef WITH_THREAD /* Python build with threading support? */
4949   PyEval_InitThreads();
4950   #endif
4951   #endif
4952   /*--- Module creation code ---*/
4953   #if PY_MAJOR_VERSION < 3
4954   __pyx_m = Py_InitModule4(__Pyx_NAMESTR("iocpsupport"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
4955   #else
4956   __pyx_m = PyModule_Create(&__pyx_moduledef);
4957   #endif
4958   if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
4959   #if PY_MAJOR_VERSION < 3
4960   Py_INCREF(__pyx_m);
4961   #endif
4962   __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
4963   if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
4964   if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
4965   /*--- Initialize various global constants etc. ---*/
4966   if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4967   if (__pyx_module_is_main_iocpsupport) {
4968     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;};
4969   }
4970   /*--- Builtin init code ---*/
4971   if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4972   /*--- Constants init code ---*/
4973   if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4974   /*--- Global init code ---*/
4975   /*--- Variable export code ---*/
4976   /*--- Function export code ---*/
4977   /*--- Type init code ---*/
4978   if (PyType_Ready(&__pyx_type_11iocpsupport_CompletionPort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4979   if (__Pyx_SetAttrString(__pyx_m, "CompletionPort", (PyObject *)&__pyx_type_11iocpsupport_CompletionPort) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4980   __pyx_ptype_11iocpsupport_CompletionPort = &__pyx_type_11iocpsupport_CompletionPort;
4981   /*--- Type import code ---*/
4982   /*--- Variable import code ---*/
4983   /*--- Function import code ---*/
4984   /*--- Execution code ---*/
4985 
4986   /* "iocpsupport.pyx":141
4987  *     raise WindowsError(message, err)
4988  *
4989  * class Event:             # <<<<<<<<<<<<<<
4990  *     def __init__(self, callback, owner, **kw):
4991  *         self.callback = callback
4992  */
4993   __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4994   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4995 
4996   /* "iocpsupport.pyx":142
4997  *
4998  * class Event:
4999  *     def __init__(self, callback, owner, **kw):             # <<<<<<<<<<<<<<
5000  *         self.callback = callback
5001  *         self.owner = owner
5002  */
5003   __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_11iocpsupport_5Event___init__, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5004   __Pyx_GOTREF(__pyx_t_2);
5005   if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5006   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5007 
5008   /* "iocpsupport.pyx":141
5009  *     raise WindowsError(message, err)
5010  *
5011  * class Event:             # <<<<<<<<<<<<<<
5012  *     def __init__(self, callback, owner, **kw):
5013  *         self.callback = callback
5014  */
5015   __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__Event, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5016   __Pyx_GOTREF(__pyx_t_2);
5017   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Event, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5018   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5019   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
5020 
5021   /* "iocpsupport.pyx":208
5022  *         CloseHandle(self.port)
5023  *
5024  * def makesockaddr(object buff):             # <<<<<<<<<<<<<<
5025  *     cdef void *mem_buffer
5026  *     cdef Py_ssize_t size
5027  */
5028   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_makesockaddr, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5029   __Pyx_GOTREF(__pyx_t_1);
5030   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__makesockaddr, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5031   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5032 
5033   /* "iocpsupport.pyx":279
5034  *
5035  *
5036  * def AllocateReadBuffer(int size):             # <<<<<<<<<<<<<<
5037  *     return PyBuffer_New(size)
5038  *
5039  */
5040   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_1AllocateReadBuffer, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5041   __Pyx_GOTREF(__pyx_t_1);
5042   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AllocateReadBuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5043   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5044 
5045   /* "iocpsupport.pyx":282
5046  *     return PyBuffer_New(size)
5047  *
5048  * def maxAddrLen(long s):             # <<<<<<<<<<<<<<
5049  *     cdef WSAPROTOCOL_INFO wsa_pi
5050  *     cdef int size, rc
5051  */
5052   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_2maxAddrLen, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5053   __Pyx_GOTREF(__pyx_t_1);
5054   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__maxAddrLen, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5055   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5056 
5057   /* "iocpsupport.pyx":302
5058  *     return wsa_pi.iAddressFamily
5059  *
5060  * import socket # for WSAStartup             # <<<<<<<<<<<<<<
5061  * if not initWinsockPointers():
5062  *     raise ValueError, 'Failed to initialize Winsock function vectors'
5063  */
5064   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__socket), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5065   __Pyx_GOTREF(__pyx_t_1);
5066   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__socket, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5067   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5068 
5069   /* "iocpsupport.pyx":303
5070  *
5071  * import socket # for WSAStartup
5072  * if not initWinsockPointers():             # <<<<<<<<<<<<<<
5073  *     raise ValueError, 'Failed to initialize Winsock function vectors'
5074  *
5075  */
5076   __pyx_t_3 = (!initWinsockPointers());
5077   if (__pyx_t_3) {
5078 
5079     /* "iocpsupport.pyx":304
5080  * import socket # for WSAStartup
5081  * if not initWinsockPointers():
5082  *     raise ValueError, 'Failed to initialize Winsock function vectors'             # <<<<<<<<<<<<<<
5083  *
5084  * have_connectex = (lpConnectEx != NULL)
5085  */
5086     __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_16), 0, 0);
5087     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5088     goto __pyx_L2;
5089   }
5090   __pyx_L2:;
5091 
5092   /* "iocpsupport.pyx":306
5093  *     raise ValueError, 'Failed to initialize Winsock function vectors'
5094  *
5095  * have_connectex = (lpConnectEx != NULL)             # <<<<<<<<<<<<<<
5096  *
5097  * include 'acceptex.pxi'
5098  */
5099   __pyx_t_1 = __Pyx_PyBool_FromLong((lpConnectEx != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5100   __Pyx_GOTREF(__pyx_t_1);
5101   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__have_connectex, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5102   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5103 
5104   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":5
5105  *
5106  *
5107  * def accept(long listening, long accepting, object buff, object obj):             # <<<<<<<<<<<<<<
5108  *     """
5109  *     CAUTION: unlike system AcceptEx(), this function returns 0 on success
5110  */
5111   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_3accept, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5112   __Pyx_GOTREF(__pyx_t_1);
5113   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__accept, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5114   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5115 
5116   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\acceptex.pxi":34
5117  *     return 0
5118  *
5119  * def get_accept_addrs(long s, object buff):             # <<<<<<<<<<<<<<
5120  *     cdef WSAPROTOCOL_INFO wsa_pi
5121  *     cdef int locallen, remotelen
5122  */
5123   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_4get_accept_addrs, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5124   __Pyx_GOTREF(__pyx_t_1);
5125   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__get_accept_addrs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5126   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5127 
5128   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\connectex.pxi":5
5129  *
5130  *
5131  * def connect(long s, object addr, object obj):             # <<<<<<<<<<<<<<
5132  *     """
5133  *     CAUTION: unlike system ConnectEx(), this function returns 0 on success
5134  */
5135   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_5connect, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5136   __Pyx_GOTREF(__pyx_t_1);
5137   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__connect, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5138   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5139   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_6recv, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5140   __Pyx_GOTREF(__pyx_t_1);
5141   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__recv, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5142   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5143 
5144   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsarecv.pxi":41
5145  *         PyMem_Free(ws_buf)
5146  *
5147  * def recvfrom(long s, object buff, object addr_buff, object addr_len_buff, object obj, unsigned long flags = 0):             # <<<<<<<<<<<<<<
5148  *     cdef int rc, c_addr_buff_len, c_addr_len_buff_len
5149  *     cdef myOVERLAPPED *ov
5150  */
5151   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_7recvfrom, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5152   __Pyx_GOTREF(__pyx_t_1);
5153   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__recvfrom, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5154   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5155 
5156   /* "C:\t\twisted\twisted\internet\iocpreactor\iocpsupport\wsasend.pxi":5
5157  *
5158  *
5159  * def send(long s, object buff, object obj, unsigned long flags = 0):             # <<<<<<<<<<<<<<
5160  *     cdef int rc
5161  *     cdef myOVERLAPPED *ov
5162  */
5163   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11iocpsupport_8send, NULL, __pyx_n_s__iocpsupport); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5164   __Pyx_GOTREF(__pyx_t_1);
5165   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__send, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5166   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5167 
5168   /* "iocpsupport.pyx":1
5169  * # Copyright (c) Twisted Matrix Laboratories.             # <<<<<<<<<<<<<<
5170  * # See LICENSE for details.
5171  *
5172  */
5173   __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;}
5174   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
5175   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;}
5176   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
5177   goto __pyx_L0;
5178   __pyx_L1_error:;
5179   __Pyx_XDECREF(__pyx_t_1);
5180   __Pyx_XDECREF(__pyx_t_2);
5181   if (__pyx_m) {
5182     __Pyx_AddTraceback("init iocpsupport", __pyx_clineno, __pyx_lineno, __pyx_filename);
5183     Py_DECREF(__pyx_m); __pyx_m = 0;
5184   } else if (!PyErr_Occurred()) {
5185     PyErr_SetString(PyExc_ImportError, "init iocpsupport");
5186   }
5187   __pyx_L0:;
5188   __Pyx_RefNannyFinishContext();
5189   #if PY_MAJOR_VERSION < 3
5190   return;
5191   #else
5192   return __pyx_m;
5193   #endif
5194 }
5195 
5196 /* Runtime support code */
5197 
5198 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)5199 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
5200     PyObject *m = NULL, *p = NULL;
5201     void *r = NULL;
5202     m = PyImport_ImportModule((char *)modname);
5203     if (!m) goto end;
5204     p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
5205     if (!p) goto end;
5206     r = PyLong_AsVoidPtr(p);
5207 end:
5208     Py_XDECREF(p);
5209     Py_XDECREF(m);
5210     return (__Pyx_RefNannyAPIStruct *)r;
5211 }
5212 #endif /* CYTHON_REFNANNY */
5213 
__Pyx_GetName(PyObject * dict,PyObject * name)5214 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
5215     PyObject *result;
5216     result = PyObject_GetAttr(dict, name);
5217     if (!result) {
5218         if (dict != __pyx_b) {
5219             PyErr_Clear();
5220             result = PyObject_GetAttr(__pyx_b, name);
5221         }
5222         if (!result) {
5223             PyErr_SetObject(PyExc_NameError, name);
5224         }
5225     }
5226     return result;
5227 }
5228 
__Pyx_ErrRestore(PyObject * type,PyObject * value,PyObject * tb)5229 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
5230     PyObject *tmp_type, *tmp_value, *tmp_tb;
5231     PyThreadState *tstate = PyThreadState_GET();
5232 
5233     tmp_type = tstate->curexc_type;
5234     tmp_value = tstate->curexc_value;
5235     tmp_tb = tstate->curexc_traceback;
5236     tstate->curexc_type = type;
5237     tstate->curexc_value = value;
5238     tstate->curexc_traceback = tb;
5239     Py_XDECREF(tmp_type);
5240     Py_XDECREF(tmp_value);
5241     Py_XDECREF(tmp_tb);
5242 }
5243 
__Pyx_ErrFetch(PyObject ** type,PyObject ** value,PyObject ** tb)5244 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
5245     PyThreadState *tstate = PyThreadState_GET();
5246     *type = tstate->curexc_type;
5247     *value = tstate->curexc_value;
5248     *tb = tstate->curexc_traceback;
5249 
5250     tstate->curexc_type = 0;
5251     tstate->curexc_value = 0;
5252     tstate->curexc_traceback = 0;
5253 }
5254 
5255 
5256 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)5257 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
5258     /* cause is unused */
5259     Py_XINCREF(type);
5260     Py_XINCREF(value);
5261     Py_XINCREF(tb);
5262     /* First, check the traceback argument, replacing None with NULL. */
5263     if (tb == Py_None) {
5264         Py_DECREF(tb);
5265         tb = 0;
5266     }
5267     else if (tb != NULL && !PyTraceBack_Check(tb)) {
5268         PyErr_SetString(PyExc_TypeError,
5269             "raise: arg 3 must be a traceback or None");
5270         goto raise_error;
5271     }
5272     /* Next, replace a missing value with None */
5273     if (value == NULL) {
5274         value = Py_None;
5275         Py_INCREF(value);
5276     }
5277     #if PY_VERSION_HEX < 0x02050000
5278     if (!PyClass_Check(type))
5279     #else
5280     if (!PyType_Check(type))
5281     #endif
5282     {
5283         /* Raising an instance.  The value should be a dummy. */
5284         if (value != Py_None) {
5285             PyErr_SetString(PyExc_TypeError,
5286                 "instance exception may not have a separate value");
5287             goto raise_error;
5288         }
5289         /* Normalize to raise <class>, <instance> */
5290         Py_DECREF(value);
5291         value = type;
5292         #if PY_VERSION_HEX < 0x02050000
5293             if (PyInstance_Check(type)) {
5294                 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
5295                 Py_INCREF(type);
5296             }
5297             else {
5298                 type = 0;
5299                 PyErr_SetString(PyExc_TypeError,
5300                     "raise: exception must be an old-style class or instance");
5301                 goto raise_error;
5302             }
5303         #else
5304             type = (PyObject*) Py_TYPE(type);
5305             Py_INCREF(type);
5306             if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
5307                 PyErr_SetString(PyExc_TypeError,
5308                     "raise: exception class must be a subclass of BaseException");
5309                 goto raise_error;
5310             }
5311         #endif
5312     }
5313 
5314     __Pyx_ErrRestore(type, value, tb);
5315     return;
5316 raise_error:
5317     Py_XDECREF(value);
5318     Py_XDECREF(type);
5319     Py_XDECREF(tb);
5320     return;
5321 }
5322 
5323 #else /* Python 3+ */
5324 
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)5325 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
5326     if (tb == Py_None) {
5327         tb = 0;
5328     } else if (tb && !PyTraceBack_Check(tb)) {
5329         PyErr_SetString(PyExc_TypeError,
5330             "raise: arg 3 must be a traceback or None");
5331         goto bad;
5332     }
5333     if (value == Py_None)
5334         value = 0;
5335 
5336     if (PyExceptionInstance_Check(type)) {
5337         if (value) {
5338             PyErr_SetString(PyExc_TypeError,
5339                 "instance exception may not have a separate value");
5340             goto bad;
5341         }
5342         value = type;
5343         type = (PyObject*) Py_TYPE(value);
5344     } else if (!PyExceptionClass_Check(type)) {
5345         PyErr_SetString(PyExc_TypeError,
5346             "raise: exception class must be a subclass of BaseException");
5347         goto bad;
5348     }
5349 
5350     if (cause) {
5351         PyObject *fixed_cause;
5352         if (PyExceptionClass_Check(cause)) {
5353             fixed_cause = PyObject_CallObject(cause, NULL);
5354             if (fixed_cause == NULL)
5355                 goto bad;
5356         }
5357         else if (PyExceptionInstance_Check(cause)) {
5358             fixed_cause = cause;
5359             Py_INCREF(fixed_cause);
5360         }
5361         else {
5362             PyErr_SetString(PyExc_TypeError,
5363                             "exception causes must derive from "
5364                             "BaseException");
5365             goto bad;
5366         }
5367         if (!value) {
5368             value = PyObject_CallObject(type, NULL);
5369         }
5370         PyException_SetCause(value, fixed_cause);
5371     }
5372 
5373     PyErr_SetObject(type, value);
5374 
5375     if (tb) {
5376         PyThreadState *tstate = PyThreadState_GET();
5377         PyObject* tmp_tb = tstate->curexc_traceback;
5378         if (tb != tmp_tb) {
5379             Py_INCREF(tb);
5380             tstate->curexc_traceback = tb;
5381             Py_XDECREF(tmp_tb);
5382         }
5383     }
5384 
5385 bad:
5386     return;
5387 }
5388 #endif
5389 
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)5390 static void __Pyx_RaiseArgtupleInvalid(
5391     const char* func_name,
5392     int exact,
5393     Py_ssize_t num_min,
5394     Py_ssize_t num_max,
5395     Py_ssize_t num_found)
5396 {
5397     Py_ssize_t num_expected;
5398     const char *more_or_less;
5399 
5400     if (num_found < num_min) {
5401         num_expected = num_min;
5402         more_or_less = "at least";
5403     } else {
5404         num_expected = num_max;
5405         more_or_less = "at most";
5406     }
5407     if (exact) {
5408         more_or_less = "exactly";
5409     }
5410     PyErr_Format(PyExc_TypeError,
5411                  "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
5412                  func_name, more_or_less, num_expected,
5413                  (num_expected == 1) ? "" : "s", num_found);
5414 }
5415 
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)5416 static void __Pyx_RaiseDoubleKeywordsError(
5417     const char* func_name,
5418     PyObject* kw_name)
5419 {
5420     PyErr_Format(PyExc_TypeError,
5421         #if PY_MAJOR_VERSION >= 3
5422         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
5423         #else
5424         "%s() got multiple values for keyword argument '%s'", func_name,
5425         PyString_AS_STRING(kw_name));
5426         #endif
5427 }
5428 
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)5429 static int __Pyx_ParseOptionalKeywords(
5430     PyObject *kwds,
5431     PyObject **argnames[],
5432     PyObject *kwds2,
5433     PyObject *values[],
5434     Py_ssize_t num_pos_args,
5435     const char* function_name)
5436 {
5437     PyObject *key = 0, *value = 0;
5438     Py_ssize_t pos = 0;
5439     PyObject*** name;
5440     PyObject*** first_kw_arg = argnames + num_pos_args;
5441 
5442     while (PyDict_Next(kwds, &pos, &key, &value)) {
5443         name = first_kw_arg;
5444         while (*name && (**name != key)) name++;
5445         if (*name) {
5446             values[name-argnames] = value;
5447         } else {
5448             #if PY_MAJOR_VERSION < 3
5449             if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
5450             #else
5451             if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
5452             #endif
5453                 goto invalid_keyword_type;
5454             } else {
5455                 for (name = first_kw_arg; *name; name++) {
5456                     #if PY_MAJOR_VERSION >= 3
5457                     if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
5458                         PyUnicode_Compare(**name, key) == 0) break;
5459                     #else
5460                     if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
5461                         _PyString_Eq(**name, key)) break;
5462                     #endif
5463                 }
5464                 if (*name) {
5465                     values[name-argnames] = value;
5466                 } else {
5467                     /* unexpected keyword found */
5468                     for (name=argnames; name != first_kw_arg; name++) {
5469                         if (**name == key) goto arg_passed_twice;
5470                         #if PY_MAJOR_VERSION >= 3
5471                         if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
5472                             PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
5473                         #else
5474                         if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
5475                             _PyString_Eq(**name, key)) goto arg_passed_twice;
5476                         #endif
5477                     }
5478                     if (kwds2) {
5479                         if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
5480                     } else {
5481                         goto invalid_keyword;
5482                     }
5483                 }
5484             }
5485         }
5486     }
5487     return 0;
5488 arg_passed_twice:
5489     __Pyx_RaiseDoubleKeywordsError(function_name, **name);
5490     goto bad;
5491 invalid_keyword_type:
5492     PyErr_Format(PyExc_TypeError,
5493         "%s() keywords must be strings", function_name);
5494     goto bad;
5495 invalid_keyword:
5496     PyErr_Format(PyExc_TypeError,
5497     #if PY_MAJOR_VERSION < 3
5498         "%s() got an unexpected keyword argument '%s'",
5499         function_name, PyString_AsString(key));
5500     #else
5501         "%s() got an unexpected keyword argument '%U'",
5502         function_name, key);
5503     #endif
5504 bad:
5505     return -1;
5506 }
5507 
5508 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
5509     PyErr_Format(PyExc_ValueError,
5510                  "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
5511                  index, (index == 1) ? "" : "s");
5512 }
5513 
5514 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
5515     PyErr_Format(PyExc_ValueError,
5516                  "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
5517 }
5518 
5519 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
5520     if (unlikely(retval)) {
5521         Py_DECREF(retval);
5522         __Pyx_RaiseTooManyValuesError(expected);
5523         return -1;
5524     } else if (PyErr_Occurred()) {
5525         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
5526             PyErr_Clear();
5527             return 0;
5528         } else {
5529             return -1;
5530         }
5531     }
5532     return 0;
5533 }
5534 
5535 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
5536     PyObject *kwdict,
5537     const char* function_name,
5538     int kw_allowed)
5539 {
5540     PyObject* key = 0;
5541     Py_ssize_t pos = 0;
5542     while (PyDict_Next(kwdict, &pos, &key, 0)) {
5543         #if PY_MAJOR_VERSION < 3
5544         if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
5545         #else
5546         if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
5547         #endif
5548             goto invalid_keyword_type;
5549     }
5550     if ((!kw_allowed) && unlikely(key))
5551         goto invalid_keyword;
5552     return 1;
5553 invalid_keyword_type:
5554     PyErr_Format(PyExc_TypeError,
5555         "%s() keywords must be strings", function_name);
5556     return 0;
5557 invalid_keyword:
5558     PyErr_Format(PyExc_TypeError,
5559     #if PY_MAJOR_VERSION < 3
5560         "%s() got an unexpected keyword argument '%s'",
5561         function_name, PyString_AsString(key));
5562     #else
5563         "%s() got an unexpected keyword argument '%U'",
5564         function_name, key);
5565     #endif
5566     return 0;
5567 }
5568 
5569 
5570 static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
5571     PyObject *metaclass;
5572     /* Default metaclass */
5573 #if PY_MAJOR_VERSION < 3
5574     if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
5575         PyObject *base = PyTuple_GET_ITEM(bases, 0);
5576         metaclass = PyObject_GetAttrString(base, (char *)"__class__");
5577         if (!metaclass) {
5578             PyErr_Clear();
5579             metaclass = (PyObject*) Py_TYPE(base);
5580         }
5581     } else {
5582         metaclass = (PyObject *) &PyClass_Type;
5583     }
5584 #else
5585     if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
5586         PyObject *base = PyTuple_GET_ITEM(bases, 0);
5587         metaclass = (PyObject*) Py_TYPE(base);
5588     } else {
5589         metaclass = (PyObject *) &PyType_Type;
5590     }
5591 #endif
5592     Py_INCREF(metaclass);
5593     return metaclass;
5594 }
5595 
5596 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
5597                                    PyObject *modname) {
5598     PyObject *result;
5599     PyObject *metaclass;
5600 
5601     if (PyDict_SetItemString(dict, "__module__", modname) < 0)
5602         return NULL;
5603 
5604     /* Python2 __metaclass__ */
5605     metaclass = PyDict_GetItemString(dict, "__metaclass__");
5606     if (metaclass) {
5607         Py_INCREF(metaclass);
5608     } else {
5609         metaclass = __Pyx_FindPy2Metaclass(bases);
5610     }
5611     result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
5612     Py_DECREF(metaclass);
5613     return result;
5614 }
5615 
5616 
5617 static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
5618     __pyx_binding_PyCFunctionType_object *op = PyObject_GC_New(__pyx_binding_PyCFunctionType_object, __pyx_binding_PyCFunctionType);
5619     if (op == NULL)
5620         return NULL;
5621     op->func.m_ml = ml;
5622     Py_XINCREF(self);
5623     op->func.m_self = self;
5624     Py_XINCREF(module);
5625     op->func.m_module = module;
5626     PyObject_GC_Track(op);
5627     return (PyObject *)op;
5628 }
5629 
5630 static void __pyx_binding_PyCFunctionType_dealloc(__pyx_binding_PyCFunctionType_object *m) {
5631     PyObject_GC_UnTrack(m);
5632     Py_XDECREF(m->func.m_self);
5633     Py_XDECREF(m->func.m_module);
5634     PyObject_GC_Del(m);
5635 }
5636 
5637 static PyObject *__pyx_binding_PyCFunctionType_descr_get(PyObject *func, PyObject *obj, PyObject *type) {
5638     if (obj == Py_None)
5639             obj = NULL;
5640     return PyMethod_New(func, obj, type);
5641 }
5642 
5643 static int __pyx_binding_PyCFunctionType_init(void) {
5644     __pyx_binding_PyCFunctionType_type = PyCFunction_Type;
5645     __pyx_binding_PyCFunctionType_type.tp_name = __Pyx_NAMESTR("cython_binding_builtin_function_or_method");
5646     __pyx_binding_PyCFunctionType_type.tp_dealloc = (destructor)__pyx_binding_PyCFunctionType_dealloc;
5647     __pyx_binding_PyCFunctionType_type.tp_descr_get = __pyx_binding_PyCFunctionType_descr_get;
5648     if (PyType_Ready(&__pyx_binding_PyCFunctionType_type) < 0) {
5649         return -1;
5650     }
5651     __pyx_binding_PyCFunctionType = &__pyx_binding_PyCFunctionType_type;
5652     return 0;
5653 
5654 }
5655 
5656 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
5657     PyObject *py_import = 0;
5658     PyObject *empty_list = 0;
5659     PyObject *module = 0;
5660     PyObject *global_dict = 0;
5661     PyObject *empty_dict = 0;
5662     PyObject *list;
5663     py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
5664     if (!py_import)
5665         goto bad;
5666     if (from_list)
5667         list = from_list;
5668     else {
5669         empty_list = PyList_New(0);
5670         if (!empty_list)
5671             goto bad;
5672         list = empty_list;
5673     }
5674     global_dict = PyModule_GetDict(__pyx_m);
5675     if (!global_dict)
5676         goto bad;
5677     empty_dict = PyDict_New();
5678     if (!empty_dict)
5679         goto bad;
5680     #if PY_VERSION_HEX >= 0x02050000
5681     {
5682         PyObject *py_level = PyInt_FromLong(level);
5683         if (!py_level)
5684             goto bad;
5685         module = PyObject_CallFunctionObjArgs(py_import,
5686             name, global_dict, empty_dict, list, py_level, NULL);
5687         Py_DECREF(py_level);
5688     }
5689     #else
5690     if (level>0) {
5691         PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
5692         goto bad;
5693     }
5694     module = PyObject_CallFunctionObjArgs(py_import,
5695         name, global_dict, empty_dict, list, NULL);
5696     #endif
5697 bad:
5698     Py_XDECREF(empty_list);
5699     Py_XDECREF(py_import);
5700     Py_XDECREF(empty_dict);
5701     return module;
5702 }
5703 
5704 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
5705     if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
5706         return (equals == Py_EQ);
5707     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
5708         if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
5709             return (equals == Py_NE);
5710         } else if (PyBytes_GET_SIZE(s1) == 1) {
5711             if (equals == Py_EQ)
5712                 return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
5713             else
5714                 return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
5715         } else {
5716             int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
5717             return (equals == Py_EQ) ? (result == 0) : (result != 0);
5718         }
5719     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
5720         return (equals == Py_NE);
5721     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
5722         return (equals == Py_NE);
5723     } else {
5724         int result;
5725         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
5726         if (!py_result)
5727             return -1;
5728         result = __Pyx_PyObject_IsTrue(py_result);
5729         Py_DECREF(py_result);
5730         return result;
5731     }
5732 }
5733 
5734 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
5735     if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
5736         return (equals == Py_EQ);
5737     } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
5738         if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
5739             return (equals == Py_NE);
5740         } else if (PyUnicode_GET_SIZE(s1) == 1) {
5741             if (equals == Py_EQ)
5742                 return (PyUnicode_AS_UNICODE(s1)[0] == PyUnicode_AS_UNICODE(s2)[0]);
5743             else
5744                 return (PyUnicode_AS_UNICODE(s1)[0] != PyUnicode_AS_UNICODE(s2)[0]);
5745         } else {
5746             int result = PyUnicode_Compare(s1, s2);
5747             if ((result == -1) && unlikely(PyErr_Occurred()))
5748                 return -1;
5749             return (equals == Py_EQ) ? (result == 0) : (result != 0);
5750         }
5751     } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
5752         return (equals == Py_NE);
5753     } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
5754         return (equals == Py_NE);
5755     } else {
5756         int result;
5757         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
5758         if (!py_result)
5759             return -1;
5760         result = __Pyx_PyObject_IsTrue(py_result);
5761         Py_DECREF(py_result);
5762         return result;
5763     }
5764 }
5765 
5766 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
5767     const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
5768     const int is_unsigned = neg_one > const_zero;
5769     if (sizeof(unsigned char) < sizeof(long)) {
5770         long val = __Pyx_PyInt_AsLong(x);
5771         if (unlikely(val != (long)(unsigned char)val)) {
5772             if (!unlikely(val == -1 && PyErr_Occurred())) {
5773                 PyErr_SetString(PyExc_OverflowError,
5774                     (is_unsigned && unlikely(val < 0)) ?
5775                     "can't convert negative value to unsigned char" :
5776                     "value too large to convert to unsigned char");
5777             }
5778             return (unsigned char)-1;
5779         }
5780         return (unsigned char)val;
5781     }
5782     return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
5783 }
5784 
5785 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
5786     const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
5787     const int is_unsigned = neg_one > const_zero;
5788     if (sizeof(unsigned short) < sizeof(long)) {
5789         long val = __Pyx_PyInt_AsLong(x);
5790         if (unlikely(val != (long)(unsigned short)val)) {
5791             if (!unlikely(val == -1 && PyErr_Occurred())) {
5792                 PyErr_SetString(PyExc_OverflowError,
5793                     (is_unsigned && unlikely(val < 0)) ?
5794                     "can't convert negative value to unsigned short" :
5795                     "value too large to convert to unsigned short");
5796             }
5797             return (unsigned short)-1;
5798         }
5799         return (unsigned short)val;
5800     }
5801     return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
5802 }
5803 
5804 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
5805     const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
5806     const int is_unsigned = neg_one > const_zero;
5807     if (sizeof(unsigned int) < sizeof(long)) {
5808         long val = __Pyx_PyInt_AsLong(x);
5809         if (unlikely(val != (long)(unsigned int)val)) {
5810             if (!unlikely(val == -1 && PyErr_Occurred())) {
5811                 PyErr_SetString(PyExc_OverflowError,
5812                     (is_unsigned && unlikely(val < 0)) ?
5813                     "can't convert negative value to unsigned int" :
5814                     "value too large to convert to unsigned int");
5815             }
5816             return (unsigned int)-1;
5817         }
5818         return (unsigned int)val;
5819     }
5820     return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
5821 }
5822 
5823 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
5824     const char neg_one = (char)-1, const_zero = 0;
5825     const int is_unsigned = neg_one > const_zero;
5826     if (sizeof(char) < sizeof(long)) {
5827         long val = __Pyx_PyInt_AsLong(x);
5828         if (unlikely(val != (long)(char)val)) {
5829             if (!unlikely(val == -1 && PyErr_Occurred())) {
5830                 PyErr_SetString(PyExc_OverflowError,
5831                     (is_unsigned && unlikely(val < 0)) ?
5832                     "can't convert negative value to char" :
5833                     "value too large to convert to char");
5834             }
5835             return (char)-1;
5836         }
5837         return (char)val;
5838     }
5839     return (char)__Pyx_PyInt_AsLong(x);
5840 }
5841 
5842 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
5843     const short neg_one = (short)-1, const_zero = 0;
5844     const int is_unsigned = neg_one > const_zero;
5845     if (sizeof(short) < sizeof(long)) {
5846         long val = __Pyx_PyInt_AsLong(x);
5847         if (unlikely(val != (long)(short)val)) {
5848             if (!unlikely(val == -1 && PyErr_Occurred())) {
5849                 PyErr_SetString(PyExc_OverflowError,
5850                     (is_unsigned && unlikely(val < 0)) ?
5851                     "can't convert negative value to short" :
5852                     "value too large to convert to short");
5853             }
5854             return (short)-1;
5855         }
5856         return (short)val;
5857     }
5858     return (short)__Pyx_PyInt_AsLong(x);
5859 }
5860 
5861 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
5862     const int neg_one = (int)-1, const_zero = 0;
5863     const int is_unsigned = neg_one > const_zero;
5864     if (sizeof(int) < sizeof(long)) {
5865         long val = __Pyx_PyInt_AsLong(x);
5866         if (unlikely(val != (long)(int)val)) {
5867             if (!unlikely(val == -1 && PyErr_Occurred())) {
5868                 PyErr_SetString(PyExc_OverflowError,
5869                     (is_unsigned && unlikely(val < 0)) ?
5870                     "can't convert negative value to int" :
5871                     "value too large to convert to int");
5872             }
5873             return (int)-1;
5874         }
5875         return (int)val;
5876     }
5877     return (int)__Pyx_PyInt_AsLong(x);
5878 }
5879 
5880 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
5881     const signed char neg_one = (signed char)-1, const_zero = 0;
5882     const int is_unsigned = neg_one > const_zero;
5883     if (sizeof(signed char) < sizeof(long)) {
5884         long val = __Pyx_PyInt_AsLong(x);
5885         if (unlikely(val != (long)(signed char)val)) {
5886             if (!unlikely(val == -1 && PyErr_Occurred())) {
5887                 PyErr_SetString(PyExc_OverflowError,
5888                     (is_unsigned && unlikely(val < 0)) ?
5889                     "can't convert negative value to signed char" :
5890                     "value too large to convert to signed char");
5891             }
5892             return (signed char)-1;
5893         }
5894         return (signed char)val;
5895     }
5896     return (signed char)__Pyx_PyInt_AsSignedLong(x);
5897 }
5898 
5899 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
5900     const signed short neg_one = (signed short)-1, const_zero = 0;
5901     const int is_unsigned = neg_one > const_zero;
5902     if (sizeof(signed short) < sizeof(long)) {
5903         long val = __Pyx_PyInt_AsLong(x);
5904         if (unlikely(val != (long)(signed short)val)) {
5905             if (!unlikely(val == -1 && PyErr_Occurred())) {
5906                 PyErr_SetString(PyExc_OverflowError,
5907                     (is_unsigned && unlikely(val < 0)) ?
5908                     "can't convert negative value to signed short" :
5909                     "value too large to convert to signed short");
5910             }
5911             return (signed short)-1;
5912         }
5913         return (signed short)val;
5914     }
5915     return (signed short)__Pyx_PyInt_AsSignedLong(x);
5916 }
5917 
5918 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
5919     const signed int neg_one = (signed int)-1, const_zero = 0;
5920     const int is_unsigned = neg_one > const_zero;
5921     if (sizeof(signed int) < sizeof(long)) {
5922         long val = __Pyx_PyInt_AsLong(x);
5923         if (unlikely(val != (long)(signed int)val)) {
5924             if (!unlikely(val == -1 && PyErr_Occurred())) {
5925                 PyErr_SetString(PyExc_OverflowError,
5926                     (is_unsigned && unlikely(val < 0)) ?
5927                     "can't convert negative value to signed int" :
5928                     "value too large to convert to signed int");
5929             }
5930             return (signed int)-1;
5931         }
5932         return (signed int)val;
5933     }
5934     return (signed int)__Pyx_PyInt_AsSignedLong(x);
5935 }
5936 
5937 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
5938     const int neg_one = (int)-1, const_zero = 0;
5939     const int is_unsigned = neg_one > const_zero;
5940     if (sizeof(int) < sizeof(long)) {
5941         long val = __Pyx_PyInt_AsLong(x);
5942         if (unlikely(val != (long)(int)val)) {
5943             if (!unlikely(val == -1 && PyErr_Occurred())) {
5944                 PyErr_SetString(PyExc_OverflowError,
5945                     (is_unsigned && unlikely(val < 0)) ?
5946                     "can't convert negative value to int" :
5947                     "value too large to convert to int");
5948             }
5949             return (int)-1;
5950         }
5951         return (int)val;
5952     }
5953     return (int)__Pyx_PyInt_AsLong(x);
5954 }
5955 
5956 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
5957     const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
5958     const int is_unsigned = neg_one > const_zero;
5959 #if PY_VERSION_HEX < 0x03000000
5960     if (likely(PyInt_Check(x))) {
5961         long val = PyInt_AS_LONG(x);
5962         if (is_unsigned && unlikely(val < 0)) {
5963             PyErr_SetString(PyExc_OverflowError,
5964                             "can't convert negative value to unsigned long");
5965             return (unsigned long)-1;
5966         }
5967         return (unsigned long)val;
5968     } else
5969 #endif
5970     if (likely(PyLong_Check(x))) {
5971         if (is_unsigned) {
5972             if (unlikely(Py_SIZE(x) < 0)) {
5973                 PyErr_SetString(PyExc_OverflowError,
5974                                 "can't convert negative value to unsigned long");
5975                 return (unsigned long)-1;
5976             }
5977             return (unsigned long)PyLong_AsUnsignedLong(x);
5978         } else {
5979             return (unsigned long)PyLong_AsLong(x);
5980         }
5981     } else {
5982         unsigned long val;
5983         PyObject *tmp = __Pyx_PyNumber_Int(x);
5984         if (!tmp) return (unsigned long)-1;
5985         val = __Pyx_PyInt_AsUnsignedLong(tmp);
5986         Py_DECREF(tmp);
5987         return val;
5988     }
5989 }
5990 
5991 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
5992     const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
5993     const int is_unsigned = neg_one > const_zero;
5994 #if PY_VERSION_HEX < 0x03000000
5995     if (likely(PyInt_Check(x))) {
5996         long val = PyInt_AS_LONG(x);
5997         if (is_unsigned && unlikely(val < 0)) {
5998             PyErr_SetString(PyExc_OverflowError,
5999                             "can't convert negative value to unsigned PY_LONG_LONG");
6000             return (unsigned PY_LONG_LONG)-1;
6001         }
6002         return (unsigned PY_LONG_LONG)val;
6003     } else
6004 #endif
6005     if (likely(PyLong_Check(x))) {
6006         if (is_unsigned) {
6007             if (unlikely(Py_SIZE(x) < 0)) {
6008                 PyErr_SetString(PyExc_OverflowError,
6009                                 "can't convert negative value to unsigned PY_LONG_LONG");
6010                 return (unsigned PY_LONG_LONG)-1;
6011             }
6012             return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
6013         } else {
6014             return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
6015         }
6016     } else {
6017         unsigned PY_LONG_LONG val;
6018         PyObject *tmp = __Pyx_PyNumber_Int(x);
6019         if (!tmp) return (unsigned PY_LONG_LONG)-1;
6020         val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
6021         Py_DECREF(tmp);
6022         return val;
6023     }
6024 }
6025 
6026 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
6027     const long neg_one = (long)-1, const_zero = 0;
6028     const int is_unsigned = neg_one > const_zero;
6029 #if PY_VERSION_HEX < 0x03000000
6030     if (likely(PyInt_Check(x))) {
6031         long val = PyInt_AS_LONG(x);
6032         if (is_unsigned && unlikely(val < 0)) {
6033             PyErr_SetString(PyExc_OverflowError,
6034                             "can't convert negative value to long");
6035             return (long)-1;
6036         }
6037         return (long)val;
6038     } else
6039 #endif
6040     if (likely(PyLong_Check(x))) {
6041         if (is_unsigned) {
6042             if (unlikely(Py_SIZE(x) < 0)) {
6043                 PyErr_SetString(PyExc_OverflowError,
6044                                 "can't convert negative value to long");
6045                 return (long)-1;
6046             }
6047             return (long)PyLong_AsUnsignedLong(x);
6048         } else {
6049             return (long)PyLong_AsLong(x);
6050         }
6051     } else {
6052         long val;
6053         PyObject *tmp = __Pyx_PyNumber_Int(x);
6054         if (!tmp) return (long)-1;
6055         val = __Pyx_PyInt_AsLong(tmp);
6056         Py_DECREF(tmp);
6057         return val;
6058     }
6059 }
6060 
6061 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
6062     const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
6063     const int is_unsigned = neg_one > const_zero;
6064 #if PY_VERSION_HEX < 0x03000000
6065     if (likely(PyInt_Check(x))) {
6066         long val = PyInt_AS_LONG(x);
6067         if (is_unsigned && unlikely(val < 0)) {
6068             PyErr_SetString(PyExc_OverflowError,
6069                             "can't convert negative value to PY_LONG_LONG");
6070             return (PY_LONG_LONG)-1;
6071         }
6072         return (PY_LONG_LONG)val;
6073     } else
6074 #endif
6075     if (likely(PyLong_Check(x))) {
6076         if (is_unsigned) {
6077             if (unlikely(Py_SIZE(x) < 0)) {
6078                 PyErr_SetString(PyExc_OverflowError,
6079                                 "can't convert negative value to PY_LONG_LONG");
6080                 return (PY_LONG_LONG)-1;
6081             }
6082             return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
6083         } else {
6084             return (PY_LONG_LONG)PyLong_AsLongLong(x);
6085         }
6086     } else {
6087         PY_LONG_LONG val;
6088         PyObject *tmp = __Pyx_PyNumber_Int(x);
6089         if (!tmp) return (PY_LONG_LONG)-1;
6090         val = __Pyx_PyInt_AsLongLong(tmp);
6091         Py_DECREF(tmp);
6092         return val;
6093     }
6094 }
6095 
6096 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
6097     const signed long neg_one = (signed long)-1, const_zero = 0;
6098     const int is_unsigned = neg_one > const_zero;
6099 #if PY_VERSION_HEX < 0x03000000
6100     if (likely(PyInt_Check(x))) {
6101         long val = PyInt_AS_LONG(x);
6102         if (is_unsigned && unlikely(val < 0)) {
6103             PyErr_SetString(PyExc_OverflowError,
6104                             "can't convert negative value to signed long");
6105             return (signed long)-1;
6106         }
6107         return (signed long)val;
6108     } else
6109 #endif
6110     if (likely(PyLong_Check(x))) {
6111         if (is_unsigned) {
6112             if (unlikely(Py_SIZE(x) < 0)) {
6113                 PyErr_SetString(PyExc_OverflowError,
6114                                 "can't convert negative value to signed long");
6115                 return (signed long)-1;
6116             }
6117             return (signed long)PyLong_AsUnsignedLong(x);
6118         } else {
6119             return (signed long)PyLong_AsLong(x);
6120         }
6121     } else {
6122         signed long val;
6123         PyObject *tmp = __Pyx_PyNumber_Int(x);
6124         if (!tmp) return (signed long)-1;
6125         val = __Pyx_PyInt_AsSignedLong(tmp);
6126         Py_DECREF(tmp);
6127         return val;
6128     }
6129 }
6130 
6131 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
6132     const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
6133     const int is_unsigned = neg_one > const_zero;
6134 #if PY_VERSION_HEX < 0x03000000
6135     if (likely(PyInt_Check(x))) {
6136         long val = PyInt_AS_LONG(x);
6137         if (is_unsigned && unlikely(val < 0)) {
6138             PyErr_SetString(PyExc_OverflowError,
6139                             "can't convert negative value to signed PY_LONG_LONG");
6140             return (signed PY_LONG_LONG)-1;
6141         }
6142         return (signed PY_LONG_LONG)val;
6143     } else
6144 #endif
6145     if (likely(PyLong_Check(x))) {
6146         if (is_unsigned) {
6147             if (unlikely(Py_SIZE(x) < 0)) {
6148                 PyErr_SetString(PyExc_OverflowError,
6149                                 "can't convert negative value to signed PY_LONG_LONG");
6150                 return (signed PY_LONG_LONG)-1;
6151             }
6152             return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
6153         } else {
6154             return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
6155         }
6156     } else {
6157         signed PY_LONG_LONG val;
6158         PyObject *tmp = __Pyx_PyNumber_Int(x);
6159         if (!tmp) return (signed PY_LONG_LONG)-1;
6160         val = __Pyx_PyInt_AsSignedLongLong(tmp);
6161         Py_DECREF(tmp);
6162         return val;
6163     }
6164 }
6165 
6166 static int __Pyx_check_binary_version(void) {
6167     char ctversion[4], rtversion[4];
6168     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
6169     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
6170     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
6171         char message[200];
6172         PyOS_snprintf(message, sizeof(message),
6173                       "compiletime version %s of module '%.100s' "
6174                       "does not match runtime version %s",
6175                       ctversion, __Pyx_MODULE_NAME, rtversion);
6176         #if PY_VERSION_HEX < 0x02050000
6177         return PyErr_Warn(NULL, message);
6178         #else
6179         return PyErr_WarnEx(NULL, message, 1);
6180         #endif
6181     }
6182     return 0;
6183 }
6184 
6185 #include "compile.h"
6186 #include "frameobject.h"
6187 #include "traceback.h"
6188 
6189 static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
6190                                int __pyx_lineno, const char *__pyx_filename) {
6191     PyObject *py_srcfile = 0;
6192     PyObject *py_funcname = 0;
6193     PyObject *py_globals = 0;
6194     PyCodeObject *py_code = 0;
6195     PyFrameObject *py_frame = 0;
6196 
6197     #if PY_MAJOR_VERSION < 3
6198     py_srcfile = PyString_FromString(__pyx_filename);
6199     #else
6200     py_srcfile = PyUnicode_FromString(__pyx_filename);
6201     #endif
6202     if (!py_srcfile) goto bad;
6203     if (__pyx_clineno) {
6204         #if PY_MAJOR_VERSION < 3
6205         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
6206         #else
6207         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
6208         #endif
6209     }
6210     else {
6211         #if PY_MAJOR_VERSION < 3
6212         py_funcname = PyString_FromString(funcname);
6213         #else
6214         py_funcname = PyUnicode_FromString(funcname);
6215         #endif
6216     }
6217     if (!py_funcname) goto bad;
6218     py_globals = PyModule_GetDict(__pyx_m);
6219     if (!py_globals) goto bad;
6220     py_code = PyCode_New(
6221         0,            /*int argcount,*/
6222         #if PY_MAJOR_VERSION >= 3
6223         0,            /*int kwonlyargcount,*/
6224         #endif
6225         0,            /*int nlocals,*/
6226         0,            /*int stacksize,*/
6227         0,            /*int flags,*/
6228         __pyx_empty_bytes, /*PyObject *code,*/
6229         __pyx_empty_tuple,  /*PyObject *consts,*/
6230         __pyx_empty_tuple,  /*PyObject *names,*/
6231         __pyx_empty_tuple,  /*PyObject *varnames,*/
6232         __pyx_empty_tuple,  /*PyObject *freevars,*/
6233         __pyx_empty_tuple,  /*PyObject *cellvars,*/
6234         py_srcfile,   /*PyObject *filename,*/
6235         py_funcname,  /*PyObject *name,*/
6236         __pyx_lineno,   /*int firstlineno,*/
6237         __pyx_empty_bytes  /*PyObject *lnotab*/
6238     );
6239     if (!py_code) goto bad;
6240     py_frame = PyFrame_New(
6241         PyThreadState_GET(), /*PyThreadState *tstate,*/
6242         py_code,             /*PyCodeObject *code,*/
6243         py_globals,          /*PyObject *globals,*/
6244         0                    /*PyObject *locals*/
6245     );
6246     if (!py_frame) goto bad;
6247     py_frame->f_lineno = __pyx_lineno;
6248     PyTraceBack_Here(py_frame);
6249 bad:
6250     Py_XDECREF(py_srcfile);
6251     Py_XDECREF(py_funcname);
6252     Py_XDECREF(py_code);
6253     Py_XDECREF(py_frame);
6254 }
6255 
6256 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
6257     while (t->p) {
6258         #if PY_MAJOR_VERSION < 3
6259         if (t->is_unicode) {
6260             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
6261         } else if (t->intern) {
6262             *t->p = PyString_InternFromString(t->s);
6263         } else {
6264             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
6265         }
6266         #else  /* Python 3+ has unicode identifiers */
6267         if (t->is_unicode | t->is_str) {
6268             if (t->intern) {
6269                 *t->p = PyUnicode_InternFromString(t->s);
6270             } else if (t->encoding) {
6271                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
6272             } else {
6273                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
6274             }
6275         } else {
6276             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
6277         }
6278         #endif
6279         if (!*t->p)
6280             return -1;
6281         ++t;
6282     }
6283     return 0;
6284 }
6285 
6286 /* Type Conversion Functions */
6287 
6288 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
6289    int is_true = x == Py_True;
6290    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
6291    else return PyObject_IsTrue(x);
6292 }
6293 
6294 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
6295   PyNumberMethods *m;
6296   const char *name = NULL;
6297   PyObject *res = NULL;
6298 #if PY_VERSION_HEX < 0x03000000
6299   if (PyInt_Check(x) || PyLong_Check(x))
6300 #else
6301   if (PyLong_Check(x))
6302 #endif
6303     return Py_INCREF(x), x;
6304   m = Py_TYPE(x)->tp_as_number;
6305 #if PY_VERSION_HEX < 0x03000000
6306   if (m && m->nb_int) {
6307     name = "int";
6308     res = PyNumber_Int(x);
6309   }
6310   else if (m && m->nb_long) {
6311     name = "long";
6312     res = PyNumber_Long(x);
6313   }
6314 #else
6315   if (m && m->nb_int) {
6316     name = "int";
6317     res = PyNumber_Long(x);
6318   }
6319 #endif
6320   if (res) {
6321 #if PY_VERSION_HEX < 0x03000000
6322     if (!PyInt_Check(res) && !PyLong_Check(res)) {
6323 #else
6324     if (!PyLong_Check(res)) {
6325 #endif
6326       PyErr_Format(PyExc_TypeError,
6327                    "__%s__ returned non-%s (type %.200s)",
6328                    name, name, Py_TYPE(res)->tp_name);
6329       Py_DECREF(res);
6330       return NULL;
6331     }
6332   }
6333   else if (!PyErr_Occurred()) {
6334     PyErr_SetString(PyExc_TypeError,
6335                     "an integer is required");
6336   }
6337   return res;
6338 }
6339 
6340 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
6341   Py_ssize_t ival;
6342   PyObject* x = PyNumber_Index(b);
6343   if (!x) return -1;
6344   ival = PyInt_AsSsize_t(x);
6345   Py_DECREF(x);
6346   return ival;
6347 }
6348 
6349 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
6350 #if PY_VERSION_HEX < 0x02050000
6351    if (ival <= LONG_MAX)
6352        return PyInt_FromLong((long)ival);
6353    else {
6354        unsigned char *bytes = (unsigned char *) &ival;
6355        int one = 1; int little = (int)*(unsigned char*)&one;
6356        return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
6357    }
6358 #else
6359    return PyInt_FromSize_t(ival);
6360 #endif
6361 }
6362 
6363 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
6364    unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
6365    if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
6366        return (size_t)-1;
6367    } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
6368        PyErr_SetString(PyExc_OverflowError,
6369                        "value too large to convert to size_t");
6370        return (size_t)-1;
6371    }
6372    return (size_t)val;
6373 }
6374 
6375 
6376 #endif /* Py_PYTHON_H */
6377