OLD | NEW |
(Empty) | |
| 1 /////////////// CModulePreamble /////////////// |
| 2 |
| 3 #include <stddef.h> /* For offsetof */ |
| 4 #ifndef offsetof |
| 5 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) |
| 6 #endif |
| 7 |
| 8 #if !defined(WIN32) && !defined(MS_WINDOWS) |
| 9 #ifndef __stdcall |
| 10 #define __stdcall |
| 11 #endif |
| 12 #ifndef __cdecl |
| 13 #define __cdecl |
| 14 #endif |
| 15 #ifndef __fastcall |
| 16 #define __fastcall |
| 17 #endif |
| 18 #endif |
| 19 |
| 20 #ifndef DL_IMPORT |
| 21 #define DL_IMPORT(t) t |
| 22 #endif |
| 23 #ifndef DL_EXPORT |
| 24 #define DL_EXPORT(t) t |
| 25 #endif |
| 26 |
| 27 #ifndef PY_LONG_LONG |
| 28 #define PY_LONG_LONG LONG_LONG |
| 29 #endif |
| 30 |
| 31 #ifndef Py_HUGE_VAL |
| 32 #define Py_HUGE_VAL HUGE_VAL |
| 33 #endif |
| 34 |
| 35 #ifdef PYPY_VERSION |
| 36 #define CYTHON_COMPILING_IN_PYPY 1 |
| 37 #define CYTHON_COMPILING_IN_CPYTHON 0 |
| 38 #else |
| 39 #define CYTHON_COMPILING_IN_PYPY 0 |
| 40 #define CYTHON_COMPILING_IN_CPYTHON 1 |
| 41 #endif |
| 42 |
| 43 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 |
| 44 #define Py_OptimizeFlag 0 |
| 45 #endif |
| 46 |
| 47 #if PY_VERSION_HEX < 0x02050000 |
| 48 typedef int Py_ssize_t; |
| 49 #define PY_SSIZE_T_MAX INT_MAX |
| 50 #define PY_SSIZE_T_MIN INT_MIN |
| 51 #define PY_FORMAT_SIZE_T "" |
| 52 #define CYTHON_FORMAT_SSIZE_T "" |
| 53 #define PyInt_FromSsize_t(z) PyInt_FromLong(z) |
| 54 #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) |
| 55 #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNum
ber_Int(o) : \ |
| 56 (PyErr_Format(PyExc_TypeError, \ |
| 57 "expected index value, got %.200s"
, Py_TYPE(o)->tp_name), \ |
| 58 (PyObject*)0)) |
| 59 #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ |
| 60 !PyComplex_Check(o)) |
| 61 #define PyIndex_Check __Pyx_PyIndex_Check |
| 62 #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, messa
ge) |
| 63 #define __PYX_BUILD_PY_SSIZE_T "i" |
| 64 #else |
| 65 #define __PYX_BUILD_PY_SSIZE_T "n" |
| 66 #define CYTHON_FORMAT_SSIZE_T "z" |
| 67 #define __Pyx_PyIndex_Check PyIndex_Check |
| 68 #endif |
| 69 |
| 70 #if PY_VERSION_HEX < 0x02060000 |
| 71 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) |
| 72 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) |
| 73 #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) |
| 74 #define PyVarObject_HEAD_INIT(type, size) \ |
| 75 PyObject_HEAD_INIT(type) size, |
| 76 #define PyType_Modified(t) |
| 77 |
| 78 typedef struct { |
| 79 void *buf; |
| 80 PyObject *obj; |
| 81 Py_ssize_t len; |
| 82 Py_ssize_t itemsize; |
| 83 int readonly; |
| 84 int ndim; |
| 85 char *format; |
| 86 Py_ssize_t *shape; |
| 87 Py_ssize_t *strides; |
| 88 Py_ssize_t *suboffsets; |
| 89 void *internal; |
| 90 } Py_buffer; |
| 91 |
| 92 #define PyBUF_SIMPLE 0 |
| 93 #define PyBUF_WRITABLE 0x0001 |
| 94 #define PyBUF_FORMAT 0x0004 |
| 95 #define PyBUF_ND 0x0008 |
| 96 #define PyBUF_STRIDES (0x0010 | PyBUF_ND) |
| 97 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) |
| 98 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) |
| 99 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) |
| 100 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) |
| 101 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) |
| 102 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) |
| 103 |
| 104 typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); |
| 105 typedef void (*releasebufferproc)(PyObject *, Py_buffer *); |
| 106 #endif |
| 107 |
| 108 #if PY_MAJOR_VERSION < 3 |
| 109 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" |
| 110 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fli
ne, lnos) \ |
| 111 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lno
s) |
| 112 #define __Pyx_DefaultClassType PyClass_Type |
| 113 #else |
| 114 #define __Pyx_BUILTIN_MODULE_NAME "builtins" |
| 115 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fli
ne, lnos) \ |
| 116 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, ln
os) |
| 117 #define __Pyx_DefaultClassType PyType_Type |
| 118 #endif |
| 119 |
| 120 #if PY_VERSION_HEX < 0x02060000 |
| 121 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "stric
t") |
| 122 #endif |
| 123 |
| 124 #if PY_MAJOR_VERSION >= 3 |
| 125 #define Py_TPFLAGS_CHECKTYPES 0 |
| 126 #define Py_TPFLAGS_HAVE_INDEX 0 |
| 127 #endif |
| 128 |
| 129 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) |
| 130 #define Py_TPFLAGS_HAVE_NEWBUFFER 0 |
| 131 #endif |
| 132 |
| 133 #if PY_VERSION_HEX < 0x02060000 |
| 134 #define Py_TPFLAGS_HAVE_VERSION_TAG 0 |
| 135 #endif |
| 136 #if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) |
| 137 #define Py_TPFLAGS_IS_ABSTRACT 0 |
| 138 #endif |
| 139 #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) |
| 140 #define Py_TPFLAGS_HAVE_FINALIZE 0 |
| 141 #endif |
| 142 |
| 143 /* new Py3.3 unicode type (PEP 393) */ |
| 144 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) |
| 145 #define CYTHON_PEP393_ENABLED 1 |
| 146 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ |
| 147 0 : _PyUnicode_Ready((PyObject *)(
op))) |
| 148 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) |
| 149 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) |
| 150 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) |
| 151 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) |
| 152 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) |
| 153 #else |
| 154 #define CYTHON_PEP393_ENABLED 0 |
| 155 #define __Pyx_PyUnicode_READY(op) (0) |
| 156 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) |
| 157 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])
) |
| 158 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) |
| 159 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) |
| 160 /* (void)(k) => avoid unused variable warning due to macro: */ |
| 161 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)
[i])) |
| 162 #endif |
| 163 |
| 164 #if CYTHON_COMPILING_IN_PYPY |
| 165 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) |
| 166 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) |
| 167 #else |
| 168 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) |
| 169 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlike
ly((b) == Py_None)) ? \ |
| 170 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) |
| 171 #endif |
| 172 |
| 173 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_
Remainder(a, b) : __Pyx_PyString_Format(a, b)) |
| 174 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber
_Remainder(a, b) : PyUnicode_Format(a, b)) |
| 175 |
| 176 #if PY_MAJOR_VERSION >= 3 |
| 177 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) |
| 178 #else |
| 179 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) |
| 180 #endif |
| 181 |
| 182 #if PY_MAJOR_VERSION >= 3 |
| 183 #define PyBaseString_Type PyUnicode_Type |
| 184 #define PyStringObject PyUnicodeObject |
| 185 #define PyString_Type PyUnicode_Type |
| 186 #define PyString_Check PyUnicode_Check |
| 187 #define PyString_CheckExact PyUnicode_CheckExact |
| 188 #endif |
| 189 |
| 190 #if PY_VERSION_HEX < 0x02060000 |
| 191 #define PyBytesObject PyStringObject |
| 192 #define PyBytes_Type PyString_Type |
| 193 #define PyBytes_Check PyString_Check |
| 194 #define PyBytes_CheckExact PyString_CheckExact |
| 195 #define PyBytes_FromString PyString_FromString |
| 196 #define PyBytes_FromStringAndSize PyString_FromStringAndSize |
| 197 #define PyBytes_FromFormat PyString_FromFormat |
| 198 #define PyBytes_DecodeEscape PyString_DecodeEscape |
| 199 #define PyBytes_AsString PyString_AsString |
| 200 #define PyBytes_AsStringAndSize PyString_AsStringAndSize |
| 201 #define PyBytes_Size PyString_Size |
| 202 #define PyBytes_AS_STRING PyString_AS_STRING |
| 203 #define PyBytes_GET_SIZE PyString_GET_SIZE |
| 204 #define PyBytes_Repr PyString_Repr |
| 205 #define PyBytes_Concat PyString_Concat |
| 206 #define PyBytes_ConcatAndDel PyString_ConcatAndDel |
| 207 #endif |
| 208 |
| 209 #if PY_MAJOR_VERSION >= 3 |
| 210 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) |
| 211 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) |
| 212 #else |
| 213 #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_C
heckExact(obj) || \ |
| 214 PyString_Check(obj) || PyUnicode_Check(
obj)) |
| 215 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnic
ode_CheckExact(obj)) |
| 216 #endif |
| 217 |
| 218 #if PY_VERSION_HEX < 0x02060000 |
| 219 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) |
| 220 #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type
) |
| 221 #endif |
| 222 #ifndef PySet_CheckExact |
| 223 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) |
| 224 #endif |
| 225 |
| 226 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) |
| 227 |
| 228 #if PY_MAJOR_VERSION >= 3 |
| 229 #define PyIntObject PyLongObject |
| 230 #define PyInt_Type PyLong_Type |
| 231 #define PyInt_Check(op) PyLong_Check(op) |
| 232 #define PyInt_CheckExact(op) PyLong_CheckExact(op) |
| 233 #define PyInt_FromString PyLong_FromString |
| 234 #define PyInt_FromUnicode PyLong_FromUnicode |
| 235 #define PyInt_FromLong PyLong_FromLong |
| 236 #define PyInt_FromSize_t PyLong_FromSize_t |
| 237 #define PyInt_FromSsize_t PyLong_FromSsize_t |
| 238 #define PyInt_AsLong PyLong_AsLong |
| 239 #define PyInt_AS_LONG PyLong_AS_LONG |
| 240 #define PyInt_AsSsize_t PyLong_AsSsize_t |
| 241 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask |
| 242 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask |
| 243 #define PyNumber_Int PyNumber_Long |
| 244 #endif |
| 245 |
| 246 #if PY_MAJOR_VERSION >= 3 |
| 247 #define PyBoolObject PyLongObject |
| 248 #endif |
| 249 |
| 250 #if PY_VERSION_HEX < 0x030200A4 |
| 251 typedef long Py_hash_t; |
| 252 #define __Pyx_PyInt_FromHash_t PyInt_FromLong |
| 253 #define __Pyx_PyInt_AsHash_t PyInt_AsLong |
| 254 #else |
| 255 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t |
| 256 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t |
| 257 #endif |
| 258 |
| 259 #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) |
| 260 #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) |
| 261 #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a
, b, value) |
| 262 #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) |
| 263 #else |
| 264 #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ |
| 265 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine")
, (PyObject*)0) : \ |
| 266 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)
) : \ |
| 267 (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (ob
j)->ob_type->tp_name), (PyObject*)0))) |
| 268 #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ |
| 269 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine")
, -1) : \ |
| 270 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b,
value)) : \ |
| 271 (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slic
e assignment", (obj)->ob_type->tp_name), -1))) |
| 272 #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ |
| 273 (PyErr_SetString(PyExc_SystemError, "null argument to internal routine")
, -1) : \ |
| 274 (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)
) : \ |
| 275 (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slic
e deletion", (obj)->ob_type->tp_name), -1))) |
| 276 #endif |
| 277 |
| 278 #if PY_MAJOR_VERSION >= 3 |
| 279 #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : P
yInstanceMethod_New(func)) |
| 280 #endif |
| 281 |
| 282 #if PY_VERSION_HEX < 0x02050000 |
| 283 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) |
| 284 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a
)) |
| 285 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) |
| 286 #else |
| 287 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) |
| 288 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) |
| 289 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) |
| 290 #endif |
| 291 |
| 292 #if PY_VERSION_HEX < 0x02050000 |
| 293 #define __Pyx_NAMESTR(n) ((char *)(n)) |
| 294 #define __Pyx_DOCSTR(n) ((char *)(n)) |
| 295 #else |
| 296 #define __Pyx_NAMESTR(n) (n) |
| 297 #define __Pyx_DOCSTR(n) (n) |
| 298 #endif |
| 299 |
| 300 /* inline attribute */ |
| 301 #ifndef CYTHON_INLINE |
| 302 #if defined(__GNUC__) |
| 303 #define CYTHON_INLINE __inline__ |
| 304 #elif defined(_MSC_VER) |
| 305 #define CYTHON_INLINE __inline |
| 306 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 307 #define CYTHON_INLINE inline |
| 308 #else |
| 309 #define CYTHON_INLINE |
| 310 #endif |
| 311 #endif |
| 312 |
| 313 /* restrict */ |
| 314 #ifndef CYTHON_RESTRICT |
| 315 #if defined(__GNUC__) |
| 316 #define CYTHON_RESTRICT __restrict__ |
| 317 #elif defined(_MSC_VER) && _MSC_VER >= 1400 |
| 318 #define CYTHON_RESTRICT __restrict |
| 319 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 320 #define CYTHON_RESTRICT restrict |
| 321 #else |
| 322 #define CYTHON_RESTRICT |
| 323 #endif |
| 324 #endif |
| 325 |
| 326 #ifdef NAN |
| 327 #define __PYX_NAN() ((float) NAN) |
| 328 #else |
| 329 static CYTHON_INLINE float __PYX_NAN() { |
| 330 /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and |
| 331 a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is |
| 332 a quiet NaN. */ |
| 333 float value; |
| 334 memset(&value, 0xFF, sizeof(value)); |
| 335 return value; |
| 336 } |
| 337 #endif |
| 338 |
| 339 // Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-ne
sted-template-class-destructor |
| 340 #ifdef __cplusplus |
| 341 template<typename T> |
| 342 void __Pyx_call_destructor(T* x) { |
| 343 x->~T(); |
| 344 } |
| 345 #endif |
| 346 |
| 347 /////////////// UtilityFunctionPredeclarations.proto /////////////// |
| 348 |
| 349 /* unused attribute */ |
| 350 #ifndef CYTHON_UNUSED |
| 351 # if defined(__GNUC__) |
| 352 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINO
R__ >= 4)) |
| 353 # define CYTHON_UNUSED __attribute__ ((__unused__)) |
| 354 # else |
| 355 # define CYTHON_UNUSED |
| 356 # endif |
| 357 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) |
| 358 # define CYTHON_UNUSED __attribute__ ((__unused__)) |
| 359 # else |
| 360 # define CYTHON_UNUSED |
| 361 # endif |
| 362 #endif |
| 363 |
| 364 typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; |
| 365 const char is_unicode; const char is_str; const char intern; } _
_Pyx_StringTabEntry; /*proto*/ |
| 366 |
| 367 /////////////// ForceInitThreads.proto /////////////// |
| 368 |
| 369 #ifndef __PYX_FORCE_INIT_THREADS |
| 370 #define __PYX_FORCE_INIT_THREADS 0 |
| 371 #endif |
| 372 |
| 373 /////////////// InitThreads.init /////////////// |
| 374 |
| 375 #ifdef WITH_THREAD |
| 376 PyEval_InitThreads(); |
| 377 #endif |
| 378 |
| 379 /////////////// CodeObjectCache.proto /////////////// |
| 380 |
| 381 typedef struct { |
| 382 int code_line; |
| 383 PyCodeObject* code_object; |
| 384 } __Pyx_CodeObjectCacheEntry; |
| 385 |
| 386 struct __Pyx_CodeObjectCache { |
| 387 int count; |
| 388 int max_count; |
| 389 __Pyx_CodeObjectCacheEntry* entries; |
| 390 }; |
| 391 |
| 392 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; |
| 393 |
| 394 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int co
unt, int code_line); |
| 395 static PyCodeObject *__pyx_find_code_object(int code_line); |
| 396 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); |
| 397 |
| 398 /////////////// CodeObjectCache /////////////// |
| 399 // Note that errors are simply ignored in the code below. |
| 400 // This is just a cache, if a lookup or insertion fails - so what? |
| 401 |
| 402 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int co
unt, int code_line) { |
| 403 int start = 0, mid = 0, end = count - 1; |
| 404 if (end >= 0 && code_line > entries[end].code_line) { |
| 405 return count; |
| 406 } |
| 407 while (start < end) { |
| 408 mid = (start + end) / 2; |
| 409 if (code_line < entries[mid].code_line) { |
| 410 end = mid; |
| 411 } else if (code_line > entries[mid].code_line) { |
| 412 start = mid + 1; |
| 413 } else { |
| 414 return mid; |
| 415 } |
| 416 } |
| 417 if (code_line <= entries[mid].code_line) { |
| 418 return mid; |
| 419 } else { |
| 420 return mid + 1; |
| 421 } |
| 422 } |
| 423 |
| 424 static PyCodeObject *__pyx_find_code_object(int code_line) { |
| 425 PyCodeObject* code_object; |
| 426 int pos; |
| 427 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { |
| 428 return NULL; |
| 429 } |
| 430 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.c
ount, code_line); |
| 431 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.ent
ries[pos].code_line != code_line)) { |
| 432 return NULL; |
| 433 } |
| 434 code_object = __pyx_code_cache.entries[pos].code_object; |
| 435 Py_INCREF(code_object); |
| 436 return code_object; |
| 437 } |
| 438 |
| 439 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { |
| 440 int pos, i; |
| 441 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; |
| 442 if (unlikely(!code_line)) { |
| 443 return; |
| 444 } |
| 445 if (unlikely(!entries)) { |
| 446 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_Code
ObjectCacheEntry)); |
| 447 if (likely(entries)) { |
| 448 __pyx_code_cache.entries = entries; |
| 449 __pyx_code_cache.max_count = 64; |
| 450 __pyx_code_cache.count = 1; |
| 451 entries[0].code_line = code_line; |
| 452 entries[0].code_object = code_object; |
| 453 Py_INCREF(code_object); |
| 454 } |
| 455 return; |
| 456 } |
| 457 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.c
ount, code_line); |
| 458 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos]
.code_line == code_line)) { |
| 459 PyCodeObject* tmp = entries[pos].code_object; |
| 460 entries[pos].code_object = code_object; |
| 461 Py_DECREF(tmp); |
| 462 return; |
| 463 } |
| 464 if (__pyx_code_cache.count == __pyx_code_cache.max_count) { |
| 465 int new_max = __pyx_code_cache.max_count + 64; |
| 466 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( |
| 467 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCac
heEntry)); |
| 468 if (unlikely(!entries)) { |
| 469 return; |
| 470 } |
| 471 __pyx_code_cache.entries = entries; |
| 472 __pyx_code_cache.max_count = new_max; |
| 473 } |
| 474 for (i=__pyx_code_cache.count; i>pos; i--) { |
| 475 entries[i] = entries[i-1]; |
| 476 } |
| 477 entries[pos].code_line = code_line; |
| 478 entries[pos].code_object = code_object; |
| 479 __pyx_code_cache.count++; |
| 480 Py_INCREF(code_object); |
| 481 } |
| 482 |
| 483 /////////////// CodeObjectCache.cleanup /////////////// |
| 484 |
| 485 if (__pyx_code_cache.entries) { |
| 486 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; |
| 487 int i, count = __pyx_code_cache.count; |
| 488 __pyx_code_cache.count = 0; |
| 489 __pyx_code_cache.max_count = 0; |
| 490 __pyx_code_cache.entries = NULL; |
| 491 for (i=0; i<count; i++) { |
| 492 Py_DECREF(entries[i].code_object); |
| 493 } |
| 494 PyMem_Free(entries); |
| 495 } |
| 496 |
| 497 /////////////// CheckBinaryVersion.proto /////////////// |
| 498 |
| 499 static int __Pyx_check_binary_version(void); |
| 500 |
| 501 /////////////// CheckBinaryVersion /////////////// |
| 502 |
| 503 static int __Pyx_check_binary_version(void) { |
| 504 char ctversion[4], rtversion[4]; |
| 505 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); |
| 506 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); |
| 507 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { |
| 508 char message[200]; |
| 509 PyOS_snprintf(message, sizeof(message), |
| 510 "compiletime version %s of module '%.100s' " |
| 511 "does not match runtime version %s", |
| 512 ctversion, __Pyx_MODULE_NAME, rtversion); |
| 513 #if PY_VERSION_HEX < 0x02050000 |
| 514 return PyErr_Warn(NULL, message); |
| 515 #else |
| 516 return PyErr_WarnEx(NULL, message, 1); |
| 517 #endif |
| 518 } |
| 519 return 0; |
| 520 } |
| 521 |
| 522 /////////////// Refnanny.proto /////////////// |
| 523 |
| 524 #ifndef CYTHON_REFNANNY |
| 525 #define CYTHON_REFNANNY 0 |
| 526 #endif |
| 527 |
| 528 #if CYTHON_REFNANNY |
| 529 typedef struct { |
| 530 void (*INCREF)(void*, PyObject*, int); |
| 531 void (*DECREF)(void*, PyObject*, int); |
| 532 void (*GOTREF)(void*, PyObject*, int); |
| 533 void (*GIVEREF)(void*, PyObject*, int); |
| 534 void* (*SetupContext)(const char*, int, const char*); |
| 535 void (*FinishContext)(void**); |
| 536 } __Pyx_RefNannyAPIStruct; |
| 537 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; |
| 538 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
/*proto*/ |
| 539 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; |
| 540 #ifdef WITH_THREAD |
| 541 #define __Pyx_RefNannySetupContext(name, acquire_gil) \ |
| 542 if (acquire_gil) { \ |
| 543 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ |
| 544 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __
FILE__); \ |
| 545 PyGILState_Release(__pyx_gilstate_save); \ |
| 546 } else { \ |
| 547 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __
FILE__); \ |
| 548 } |
| 549 #else |
| 550 #define __Pyx_RefNannySetupContext(name, acquire_gil) \ |
| 551 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE
__) |
| 552 #endif |
| 553 #define __Pyx_RefNannyFinishContext() \ |
| 554 __Pyx_RefNanny->FinishContext(&__pyx_refnanny) |
| 555 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r
), __LINE__) |
| 556 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r
), __LINE__) |
| 557 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r
), __LINE__) |
| 558 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(
r), __LINE__) |
| 559 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) |
| 560 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) |
| 561 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) |
| 562 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) |
| 563 #else |
| 564 #define __Pyx_RefNannyDeclarations |
| 565 #define __Pyx_RefNannySetupContext(name, acquire_gil) |
| 566 #define __Pyx_RefNannyFinishContext() |
| 567 #define __Pyx_INCREF(r) Py_INCREF(r) |
| 568 #define __Pyx_DECREF(r) Py_DECREF(r) |
| 569 #define __Pyx_GOTREF(r) |
| 570 #define __Pyx_GIVEREF(r) |
| 571 #define __Pyx_XINCREF(r) Py_XINCREF(r) |
| 572 #define __Pyx_XDECREF(r) Py_XDECREF(r) |
| 573 #define __Pyx_XGOTREF(r) |
| 574 #define __Pyx_XGIVEREF(r) |
| 575 #endif /* CYTHON_REFNANNY */ |
| 576 |
| 577 #define __Pyx_XDECREF_SET(r, v) do { \ |
| 578 PyObject *tmp = (PyObject *) r; \ |
| 579 r = v; __Pyx_XDECREF(tmp); \ |
| 580 } while (0) |
| 581 #define __Pyx_DECREF_SET(r, v) do { \ |
| 582 PyObject *tmp = (PyObject *) r; \ |
| 583 r = v; __Pyx_DECREF(tmp); \ |
| 584 } while (0) |
| 585 |
| 586 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx
_DECREF(tmp);} while(0) |
| 587 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r))
; r = NULL; __Pyx_DECREF(tmp);}} while(0) |
| 588 |
| 589 /////////////// Refnanny /////////////// |
| 590 |
| 591 #if CYTHON_REFNANNY |
| 592 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { |
| 593 PyObject *m = NULL, *p = NULL; |
| 594 void *r = NULL; |
| 595 m = PyImport_ImportModule((char *)modname); |
| 596 if (!m) goto end; |
| 597 p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); |
| 598 if (!p) goto end; |
| 599 r = PyLong_AsVoidPtr(p); |
| 600 end: |
| 601 Py_XDECREF(p); |
| 602 Py_XDECREF(m); |
| 603 return (__Pyx_RefNannyAPIStruct *)r; |
| 604 } |
| 605 #endif /* CYTHON_REFNANNY */ |
| 606 |
| 607 /////////////// RegisterModuleCleanup.proto /////////////// |
| 608 //@substitute: naming |
| 609 |
| 610 static void ${cleanup_cname}(PyObject *self); /*proto*/ |
| 611 static int __Pyx_RegisterCleanup(void); /*proto*/ |
| 612 |
| 613 /////////////// RegisterModuleCleanup /////////////// |
| 614 //@substitute: naming |
| 615 //@requires: ImportExport.c::ModuleImport |
| 616 |
| 617 #if PY_MAJOR_VERSION < 3 |
| 618 static PyObject* ${cleanup_cname}_atexit(PyObject *module, CYTHON_UNUSED PyObjec
t *unused) { |
| 619 ${cleanup_cname}(module); |
| 620 Py_INCREF(Py_None); return Py_None; |
| 621 } |
| 622 |
| 623 static int __Pyx_RegisterCleanup(void) { |
| 624 // Don't use Py_AtExit because that has a 32-call limit and is called |
| 625 // after python finalization. |
| 626 // Also, we try to prepend the cleanup function to "atexit._exithandlers" |
| 627 // in Py2 because CPython runs them last-to-first. Being run last allows |
| 628 // user exit code to run before us that may depend on the globals |
| 629 // and cached objects that we are about to clean up. |
| 630 |
| 631 static PyMethodDef cleanup_def = { |
| 632 __Pyx_NAMESTR("__cleanup"), (PyCFunction)${cleanup_cname}_atexit, METH_N
OARGS, 0}; |
| 633 |
| 634 PyObject *cleanup_func = 0; |
| 635 PyObject *atexit = 0; |
| 636 PyObject *reg = 0; |
| 637 PyObject *args = 0; |
| 638 PyObject *res = 0; |
| 639 int ret = -1; |
| 640 |
| 641 cleanup_func = PyCFunction_New(&cleanup_def, 0); |
| 642 if (!cleanup_func) |
| 643 goto bad; |
| 644 |
| 645 atexit = __Pyx_ImportModule("atexit"); |
| 646 if (!atexit) |
| 647 goto bad; |
| 648 reg = __Pyx_GetAttrString(atexit, "_exithandlers"); |
| 649 if (reg && PyList_Check(reg)) { |
| 650 PyObject *a, *kw; |
| 651 a = PyTuple_New(0); |
| 652 kw = PyDict_New(); |
| 653 if (!a || !kw) { |
| 654 Py_XDECREF(a); |
| 655 Py_XDECREF(kw); |
| 656 goto bad; |
| 657 } |
| 658 args = PyTuple_Pack(3, cleanup_func, a, kw); |
| 659 Py_DECREF(a); |
| 660 Py_DECREF(kw); |
| 661 if (!args) |
| 662 goto bad; |
| 663 ret = PyList_Insert(reg, 0, args); |
| 664 } else { |
| 665 if (!reg) |
| 666 PyErr_Clear(); |
| 667 Py_XDECREF(reg); |
| 668 reg = __Pyx_GetAttrString(atexit, "register"); |
| 669 if (!reg) |
| 670 goto bad; |
| 671 args = PyTuple_Pack(1, cleanup_func); |
| 672 if (!args) |
| 673 goto bad; |
| 674 res = PyObject_CallObject(reg, args); |
| 675 if (!res) |
| 676 goto bad; |
| 677 ret = 0; |
| 678 } |
| 679 bad: |
| 680 Py_XDECREF(cleanup_func); |
| 681 Py_XDECREF(atexit); |
| 682 Py_XDECREF(reg); |
| 683 Py_XDECREF(args); |
| 684 Py_XDECREF(res); |
| 685 return ret; |
| 686 } |
| 687 #else |
| 688 // fake call purely to work around "unused function" warning for __Pyx_ImportMod
ule() |
| 689 static int __Pyx_RegisterCleanup(void) { |
| 690 if (0) __Pyx_ImportModule(NULL); |
| 691 return 0; |
| 692 } |
| 693 #endif |
OLD | NEW |