~djfroofy/twisted/5013-txAfterResponse

« back to all changes in this revision

Viewing changes to twisted/internet/iocpreactor/iocpsupport/iocpsupport.c

  • Committer: pahan
  • Date: 2011-03-17 02:34:22 UTC
  • Revision ID: svn-v4:bbbe8e31-12d6-0310-92fd-ac37d47ddeeb:trunk:31217
Merge iocp-tcp-large-write-3233-2

Author: PenguinOfDoom
Reviewer: exarkun
Fixes: #3233

Remove immediate successful completion handling for all overlapped operations.

Show diffs side-by-side

added added

removed removed

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