cy_cxxtest.cc (109260B)
1 /* Generated by Cython 0.29 */ 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 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) 8 #error Cython requires Python 2.6+ or Python 3.3+. 9 #else 10 #define CYTHON_ABI "0_29" 11 #define CYTHON_HEX_VERSION 0x001D00F0 12 #define CYTHON_FUTURE_DIVISION 0 13 #include <stddef.h> 14 #ifndef offsetof 15 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) 16 #endif 17 #if !defined(WIN32) && !defined(MS_WINDOWS) 18 #ifndef __stdcall 19 #define __stdcall 20 #endif 21 #ifndef __cdecl 22 #define __cdecl 23 #endif 24 #ifndef __fastcall 25 #define __fastcall 26 #endif 27 #endif 28 #ifndef DL_IMPORT 29 #define DL_IMPORT(t) t 30 #endif 31 #ifndef DL_EXPORT 32 #define DL_EXPORT(t) t 33 #endif 34 #define __PYX_COMMA , 35 #ifndef HAVE_LONG_LONG 36 #if PY_VERSION_HEX >= 0x02070000 37 #define HAVE_LONG_LONG 38 #endif 39 #endif 40 #ifndef PY_LONG_LONG 41 #define PY_LONG_LONG LONG_LONG 42 #endif 43 #ifndef Py_HUGE_VAL 44 #define Py_HUGE_VAL HUGE_VAL 45 #endif 46 #ifdef PYPY_VERSION 47 #define CYTHON_COMPILING_IN_PYPY 1 48 #define CYTHON_COMPILING_IN_PYSTON 0 49 #define CYTHON_COMPILING_IN_CPYTHON 0 50 #undef CYTHON_USE_TYPE_SLOTS 51 #define CYTHON_USE_TYPE_SLOTS 0 52 #undef CYTHON_USE_PYTYPE_LOOKUP 53 #define CYTHON_USE_PYTYPE_LOOKUP 0 54 #if PY_VERSION_HEX < 0x03050000 55 #undef CYTHON_USE_ASYNC_SLOTS 56 #define CYTHON_USE_ASYNC_SLOTS 0 57 #elif !defined(CYTHON_USE_ASYNC_SLOTS) 58 #define CYTHON_USE_ASYNC_SLOTS 1 59 #endif 60 #undef CYTHON_USE_PYLIST_INTERNALS 61 #define CYTHON_USE_PYLIST_INTERNALS 0 62 #undef CYTHON_USE_UNICODE_INTERNALS 63 #define CYTHON_USE_UNICODE_INTERNALS 0 64 #undef CYTHON_USE_UNICODE_WRITER 65 #define CYTHON_USE_UNICODE_WRITER 0 66 #undef CYTHON_USE_PYLONG_INTERNALS 67 #define CYTHON_USE_PYLONG_INTERNALS 0 68 #undef CYTHON_AVOID_BORROWED_REFS 69 #define CYTHON_AVOID_BORROWED_REFS 1 70 #undef CYTHON_ASSUME_SAFE_MACROS 71 #define CYTHON_ASSUME_SAFE_MACROS 0 72 #undef CYTHON_UNPACK_METHODS 73 #define CYTHON_UNPACK_METHODS 0 74 #undef CYTHON_FAST_THREAD_STATE 75 #define CYTHON_FAST_THREAD_STATE 0 76 #undef CYTHON_FAST_PYCALL 77 #define CYTHON_FAST_PYCALL 0 78 #undef CYTHON_PEP489_MULTI_PHASE_INIT 79 #define CYTHON_PEP489_MULTI_PHASE_INIT 0 80 #undef CYTHON_USE_TP_FINALIZE 81 #define CYTHON_USE_TP_FINALIZE 0 82 #undef CYTHON_USE_DICT_VERSIONS 83 #define CYTHON_USE_DICT_VERSIONS 0 84 #undef CYTHON_USE_EXC_INFO_STACK 85 #define CYTHON_USE_EXC_INFO_STACK 0 86 #elif defined(PYSTON_VERSION) 87 #define CYTHON_COMPILING_IN_PYPY 0 88 #define CYTHON_COMPILING_IN_PYSTON 1 89 #define CYTHON_COMPILING_IN_CPYTHON 0 90 #ifndef CYTHON_USE_TYPE_SLOTS 91 #define CYTHON_USE_TYPE_SLOTS 1 92 #endif 93 #undef CYTHON_USE_PYTYPE_LOOKUP 94 #define CYTHON_USE_PYTYPE_LOOKUP 0 95 #undef CYTHON_USE_ASYNC_SLOTS 96 #define CYTHON_USE_ASYNC_SLOTS 0 97 #undef CYTHON_USE_PYLIST_INTERNALS 98 #define CYTHON_USE_PYLIST_INTERNALS 0 99 #ifndef CYTHON_USE_UNICODE_INTERNALS 100 #define CYTHON_USE_UNICODE_INTERNALS 1 101 #endif 102 #undef CYTHON_USE_UNICODE_WRITER 103 #define CYTHON_USE_UNICODE_WRITER 0 104 #undef CYTHON_USE_PYLONG_INTERNALS 105 #define CYTHON_USE_PYLONG_INTERNALS 0 106 #ifndef CYTHON_AVOID_BORROWED_REFS 107 #define CYTHON_AVOID_BORROWED_REFS 0 108 #endif 109 #ifndef CYTHON_ASSUME_SAFE_MACROS 110 #define CYTHON_ASSUME_SAFE_MACROS 1 111 #endif 112 #ifndef CYTHON_UNPACK_METHODS 113 #define CYTHON_UNPACK_METHODS 1 114 #endif 115 #undef CYTHON_FAST_THREAD_STATE 116 #define CYTHON_FAST_THREAD_STATE 0 117 #undef CYTHON_FAST_PYCALL 118 #define CYTHON_FAST_PYCALL 0 119 #undef CYTHON_PEP489_MULTI_PHASE_INIT 120 #define CYTHON_PEP489_MULTI_PHASE_INIT 0 121 #undef CYTHON_USE_TP_FINALIZE 122 #define CYTHON_USE_TP_FINALIZE 0 123 #undef CYTHON_USE_DICT_VERSIONS 124 #define CYTHON_USE_DICT_VERSIONS 0 125 #undef CYTHON_USE_EXC_INFO_STACK 126 #define CYTHON_USE_EXC_INFO_STACK 0 127 #else 128 #define CYTHON_COMPILING_IN_PYPY 0 129 #define CYTHON_COMPILING_IN_PYSTON 0 130 #define CYTHON_COMPILING_IN_CPYTHON 1 131 #ifndef CYTHON_USE_TYPE_SLOTS 132 #define CYTHON_USE_TYPE_SLOTS 1 133 #endif 134 #if PY_VERSION_HEX < 0x02070000 135 #undef CYTHON_USE_PYTYPE_LOOKUP 136 #define CYTHON_USE_PYTYPE_LOOKUP 0 137 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) 138 #define CYTHON_USE_PYTYPE_LOOKUP 1 139 #endif 140 #if PY_MAJOR_VERSION < 3 141 #undef CYTHON_USE_ASYNC_SLOTS 142 #define CYTHON_USE_ASYNC_SLOTS 0 143 #elif !defined(CYTHON_USE_ASYNC_SLOTS) 144 #define CYTHON_USE_ASYNC_SLOTS 1 145 #endif 146 #if PY_VERSION_HEX < 0x02070000 147 #undef CYTHON_USE_PYLONG_INTERNALS 148 #define CYTHON_USE_PYLONG_INTERNALS 0 149 #elif !defined(CYTHON_USE_PYLONG_INTERNALS) 150 #define CYTHON_USE_PYLONG_INTERNALS 1 151 #endif 152 #ifndef CYTHON_USE_PYLIST_INTERNALS 153 #define CYTHON_USE_PYLIST_INTERNALS 1 154 #endif 155 #ifndef CYTHON_USE_UNICODE_INTERNALS 156 #define CYTHON_USE_UNICODE_INTERNALS 1 157 #endif 158 #if PY_VERSION_HEX < 0x030300F0 159 #undef CYTHON_USE_UNICODE_WRITER 160 #define CYTHON_USE_UNICODE_WRITER 0 161 #elif !defined(CYTHON_USE_UNICODE_WRITER) 162 #define CYTHON_USE_UNICODE_WRITER 1 163 #endif 164 #ifndef CYTHON_AVOID_BORROWED_REFS 165 #define CYTHON_AVOID_BORROWED_REFS 0 166 #endif 167 #ifndef CYTHON_ASSUME_SAFE_MACROS 168 #define CYTHON_ASSUME_SAFE_MACROS 1 169 #endif 170 #ifndef CYTHON_UNPACK_METHODS 171 #define CYTHON_UNPACK_METHODS 1 172 #endif 173 #ifndef CYTHON_FAST_THREAD_STATE 174 #define CYTHON_FAST_THREAD_STATE 1 175 #endif 176 #ifndef CYTHON_FAST_PYCALL 177 #define CYTHON_FAST_PYCALL 1 178 #endif 179 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT 180 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) 181 #endif 182 #ifndef CYTHON_USE_TP_FINALIZE 183 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) 184 #endif 185 #ifndef CYTHON_USE_DICT_VERSIONS 186 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) 187 #endif 188 #ifndef CYTHON_USE_EXC_INFO_STACK 189 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) 190 #endif 191 #endif 192 #if !defined(CYTHON_FAST_PYCCALL) 193 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) 194 #endif 195 #if CYTHON_USE_PYLONG_INTERNALS 196 #include "longintrepr.h" 197 #undef SHIFT 198 #undef BASE 199 #undef MASK 200 #endif 201 #ifndef __has_attribute 202 #define __has_attribute(x) 0 203 #endif 204 #ifndef __has_cpp_attribute 205 #define __has_cpp_attribute(x) 0 206 #endif 207 #ifndef CYTHON_RESTRICT 208 #if defined(__GNUC__) 209 #define CYTHON_RESTRICT __restrict__ 210 #elif defined(_MSC_VER) && _MSC_VER >= 1400 211 #define CYTHON_RESTRICT __restrict 212 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 213 #define CYTHON_RESTRICT restrict 214 #else 215 #define CYTHON_RESTRICT 216 #endif 217 #endif 218 #ifndef CYTHON_UNUSED 219 # if defined(__GNUC__) 220 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 221 # define CYTHON_UNUSED __attribute__ ((__unused__)) 222 # else 223 # define CYTHON_UNUSED 224 # endif 225 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) 226 # define CYTHON_UNUSED __attribute__ ((__unused__)) 227 # else 228 # define CYTHON_UNUSED 229 # endif 230 #endif 231 #ifndef CYTHON_MAYBE_UNUSED_VAR 232 # if defined(__cplusplus) 233 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } 234 # else 235 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) 236 # endif 237 #endif 238 #ifndef CYTHON_NCP_UNUSED 239 # if CYTHON_COMPILING_IN_CPYTHON 240 # define CYTHON_NCP_UNUSED 241 # else 242 # define CYTHON_NCP_UNUSED CYTHON_UNUSED 243 # endif 244 #endif 245 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) 246 #ifdef _MSC_VER 247 #ifndef _MSC_STDINT_H_ 248 #if _MSC_VER < 1300 249 typedef unsigned char uint8_t; 250 typedef unsigned int uint32_t; 251 #else 252 typedef unsigned __int8 uint8_t; 253 typedef unsigned __int32 uint32_t; 254 #endif 255 #endif 256 #else 257 #include <stdint.h> 258 #endif 259 #ifndef CYTHON_FALLTHROUGH 260 #if defined(__cplusplus) && __cplusplus >= 201103L 261 #if __has_cpp_attribute(fallthrough) 262 #define CYTHON_FALLTHROUGH [[fallthrough]] 263 #elif __has_cpp_attribute(clang::fallthrough) 264 #define CYTHON_FALLTHROUGH [[clang::fallthrough]] 265 #elif __has_cpp_attribute(gnu::fallthrough) 266 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] 267 #endif 268 #endif 269 #ifndef CYTHON_FALLTHROUGH 270 #if __has_attribute(fallthrough) 271 #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) 272 #else 273 #define CYTHON_FALLTHROUGH 274 #endif 275 #endif 276 #if defined(__clang__ ) && defined(__apple_build_version__) 277 #if __apple_build_version__ < 7000000 278 #undef CYTHON_FALLTHROUGH 279 #define CYTHON_FALLTHROUGH 280 #endif 281 #endif 282 #endif 283 284 #ifndef __cplusplus 285 #error "Cython files generated with the C++ option must be compiled with a C++ compiler." 286 #endif 287 #ifndef CYTHON_INLINE 288 #if defined(__clang__) 289 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) 290 #else 291 #define CYTHON_INLINE inline 292 #endif 293 #endif 294 template<typename T> 295 void __Pyx_call_destructor(T& x) { 296 x.~T(); 297 } 298 template<typename T> 299 class __Pyx_FakeReference { 300 public: 301 __Pyx_FakeReference() : ptr(NULL) { } 302 __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { } 303 T *operator->() { return ptr; } 304 T *operator&() { return ptr; } 305 operator T&() { return *ptr; } 306 template<typename U> bool operator ==(U other) { return *ptr == other; } 307 template<typename U> bool operator !=(U other) { return *ptr != other; } 308 private: 309 T *ptr; 310 }; 311 312 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) 313 #define Py_OptimizeFlag 0 314 #endif 315 #define __PYX_BUILD_PY_SSIZE_T "n" 316 #define CYTHON_FORMAT_SSIZE_T "z" 317 #if PY_MAJOR_VERSION < 3 318 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" 319 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ 320 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) 321 #define __Pyx_DefaultClassType PyClass_Type 322 #else 323 #define __Pyx_BUILTIN_MODULE_NAME "builtins" 324 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ 325 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) 326 #define __Pyx_DefaultClassType PyType_Type 327 #endif 328 #ifndef Py_TPFLAGS_CHECKTYPES 329 #define Py_TPFLAGS_CHECKTYPES 0 330 #endif 331 #ifndef Py_TPFLAGS_HAVE_INDEX 332 #define Py_TPFLAGS_HAVE_INDEX 0 333 #endif 334 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER 335 #define Py_TPFLAGS_HAVE_NEWBUFFER 0 336 #endif 337 #ifndef Py_TPFLAGS_HAVE_FINALIZE 338 #define Py_TPFLAGS_HAVE_FINALIZE 0 339 #endif 340 #ifndef METH_STACKLESS 341 #define METH_STACKLESS 0 342 #endif 343 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) 344 #ifndef METH_FASTCALL 345 #define METH_FASTCALL 0x80 346 #endif 347 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); 348 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, 349 Py_ssize_t nargs, PyObject *kwnames); 350 #else 351 #define __Pyx_PyCFunctionFast _PyCFunctionFast 352 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords 353 #endif 354 #if CYTHON_FAST_PYCCALL 355 #define __Pyx_PyFastCFunction_Check(func)\ 356 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) 357 #else 358 #define __Pyx_PyFastCFunction_Check(func) 0 359 #endif 360 #if CYTHON_USE_DICT_VERSIONS 361 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) 362 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ 363 (version_var) = __PYX_GET_DICT_VERSION(dict);\ 364 (cache_var) = (value); 365 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ 366 static PY_UINT64_T __pyx_dict_version = 0;\ 367 static PyObject *__pyx_dict_cached_value = NULL;\ 368 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ 369 (VAR) = __pyx_dict_cached_value;\ 370 } else {\ 371 (VAR) = __pyx_dict_cached_value = (LOOKUP);\ 372 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ 373 }\ 374 } 375 #else 376 #define __PYX_GET_DICT_VERSION(dict) (0) 377 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) 378 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); 379 #endif 380 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) 381 #define PyObject_Malloc(s) PyMem_Malloc(s) 382 #define PyObject_Free(p) PyMem_Free(p) 383 #define PyObject_Realloc(p) PyMem_Realloc(p) 384 #endif 385 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 386 #define PyMem_RawMalloc(n) PyMem_Malloc(n) 387 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) 388 #define PyMem_RawFree(p) PyMem_Free(p) 389 #endif 390 #if CYTHON_COMPILING_IN_PYSTON 391 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) 392 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) 393 #else 394 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) 395 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) 396 #endif 397 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 398 #define __Pyx_PyThreadState_Current PyThreadState_GET() 399 #elif PY_VERSION_HEX >= 0x03060000 400 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() 401 #elif PY_VERSION_HEX >= 0x03000000 402 #define __Pyx_PyThreadState_Current PyThreadState_GET() 403 #else 404 #define __Pyx_PyThreadState_Current _PyThreadState_Current 405 #endif 406 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) 407 #include "pythread.h" 408 #define Py_tss_NEEDS_INIT 0 409 typedef int Py_tss_t; 410 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { 411 *key = PyThread_create_key(); 412 return 0; // PyThread_create_key reports success always 413 } 414 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { 415 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); 416 *key = Py_tss_NEEDS_INIT; 417 return key; 418 } 419 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { 420 PyObject_Free(key); 421 } 422 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { 423 return *key != Py_tss_NEEDS_INIT; 424 } 425 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { 426 PyThread_delete_key(*key); 427 *key = Py_tss_NEEDS_INIT; 428 } 429 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { 430 return PyThread_set_key_value(*key, value); 431 } 432 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { 433 return PyThread_get_key_value(*key); 434 } 435 #endif // TSS (Thread Specific Storage) API 436 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) 437 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) 438 #else 439 #define __Pyx_PyDict_NewPresized(n) PyDict_New() 440 #endif 441 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION 442 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) 443 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) 444 #else 445 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) 446 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) 447 #endif 448 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS 449 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) 450 #else 451 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) 452 #endif 453 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) 454 #define CYTHON_PEP393_ENABLED 1 455 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 456 0 : _PyUnicode_Ready((PyObject *)(op))) 457 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) 458 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) 459 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) 460 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) 461 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) 462 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) 463 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) 464 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) 465 #else 466 #define CYTHON_PEP393_ENABLED 0 467 #define PyUnicode_1BYTE_KIND 1 468 #define PyUnicode_2BYTE_KIND 2 469 #define PyUnicode_4BYTE_KIND 4 470 #define __Pyx_PyUnicode_READY(op) (0) 471 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) 472 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) 473 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) 474 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) 475 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) 476 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) 477 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) 478 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) 479 #endif 480 #if CYTHON_COMPILING_IN_PYPY 481 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) 482 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) 483 #else 484 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) 485 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ 486 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) 487 #endif 488 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) 489 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) 490 #endif 491 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) 492 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) 493 #endif 494 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) 495 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) 496 #endif 497 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) 498 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) 499 #if PY_MAJOR_VERSION >= 3 500 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) 501 #else 502 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) 503 #endif 504 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) 505 #define PyObject_ASCII(o) PyObject_Repr(o) 506 #endif 507 #if PY_MAJOR_VERSION >= 3 508 #define PyBaseString_Type PyUnicode_Type 509 #define PyStringObject PyUnicodeObject 510 #define PyString_Type PyUnicode_Type 511 #define PyString_Check PyUnicode_Check 512 #define PyString_CheckExact PyUnicode_CheckExact 513 #define PyObject_Unicode PyObject_Str 514 #endif 515 #if PY_MAJOR_VERSION >= 3 516 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) 517 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) 518 #else 519 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) 520 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) 521 #endif 522 #ifndef PySet_CheckExact 523 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) 524 #endif 525 #if CYTHON_ASSUME_SAFE_MACROS 526 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) 527 #else 528 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) 529 #endif 530 #if PY_MAJOR_VERSION >= 3 531 #define PyIntObject PyLongObject 532 #define PyInt_Type PyLong_Type 533 #define PyInt_Check(op) PyLong_Check(op) 534 #define PyInt_CheckExact(op) PyLong_CheckExact(op) 535 #define PyInt_FromString PyLong_FromString 536 #define PyInt_FromUnicode PyLong_FromUnicode 537 #define PyInt_FromLong PyLong_FromLong 538 #define PyInt_FromSize_t PyLong_FromSize_t 539 #define PyInt_FromSsize_t PyLong_FromSsize_t 540 #define PyInt_AsLong PyLong_AsLong 541 #define PyInt_AS_LONG PyLong_AS_LONG 542 #define PyInt_AsSsize_t PyLong_AsSsize_t 543 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask 544 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask 545 #define PyNumber_Int PyNumber_Long 546 #endif 547 #if PY_MAJOR_VERSION >= 3 548 #define PyBoolObject PyLongObject 549 #endif 550 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY 551 #ifndef PyUnicode_InternFromString 552 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) 553 #endif 554 #endif 555 #if PY_VERSION_HEX < 0x030200A4 556 typedef long Py_hash_t; 557 #define __Pyx_PyInt_FromHash_t PyInt_FromLong 558 #define __Pyx_PyInt_AsHash_t PyInt_AsLong 559 #else 560 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t 561 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t 562 #endif 563 #if PY_MAJOR_VERSION >= 3 564 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) 565 #else 566 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) 567 #endif 568 #if CYTHON_USE_ASYNC_SLOTS 569 #if PY_VERSION_HEX >= 0x030500B1 570 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods 571 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) 572 #else 573 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) 574 #endif 575 #else 576 #define __Pyx_PyType_AsAsync(obj) NULL 577 #endif 578 #ifndef __Pyx_PyAsyncMethodsStruct 579 typedef struct { 580 unaryfunc am_await; 581 unaryfunc am_aiter; 582 unaryfunc am_anext; 583 } __Pyx_PyAsyncMethodsStruct; 584 #endif 585 586 #if defined(WIN32) || defined(MS_WINDOWS) 587 #define _USE_MATH_DEFINES 588 #endif 589 #include <math.h> 590 #ifdef NAN 591 #define __PYX_NAN() ((float) NAN) 592 #else 593 static CYTHON_INLINE float __PYX_NAN() { 594 float value; 595 memset(&value, 0xFF, sizeof(value)); 596 return value; 597 } 598 #endif 599 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) 600 #define __Pyx_truncl trunc 601 #else 602 #define __Pyx_truncl truncl 603 #endif 604 605 606 #define __PYX_ERR(f_index, lineno, Ln_error) \ 607 { \ 608 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ 609 } 610 611 #ifndef __PYX_EXTERN_C 612 #ifdef __cplusplus 613 #define __PYX_EXTERN_C extern "C" 614 #else 615 #define __PYX_EXTERN_C extern 616 #endif 617 #endif 618 619 #define __PYX_HAVE__cy_cxxtest 620 #define __PYX_HAVE_API__cy_cxxtest 621 /* Early includes */ 622 #include "lib.h" 623 #ifdef _OPENMP 624 #include <omp.h> 625 #endif /* _OPENMP */ 626 627 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) 628 #define CYTHON_WITHOUT_ASSERTIONS 629 #endif 630 631 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; 632 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; 633 634 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 635 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 636 #define __PYX_DEFAULT_STRING_ENCODING "" 637 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString 638 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize 639 #define __Pyx_uchar_cast(c) ((unsigned char)c) 640 #define __Pyx_long_cast(x) ((long)x) 641 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ 642 (sizeof(type) < sizeof(Py_ssize_t)) ||\ 643 (sizeof(type) > sizeof(Py_ssize_t) &&\ 644 likely(v < (type)PY_SSIZE_T_MAX ||\ 645 v == (type)PY_SSIZE_T_MAX) &&\ 646 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ 647 v == (type)PY_SSIZE_T_MIN))) ||\ 648 (sizeof(type) == sizeof(Py_ssize_t) &&\ 649 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ 650 v == (type)PY_SSIZE_T_MAX))) ) 651 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { 652 return (size_t) i < (size_t) limit; 653 } 654 #if defined (__cplusplus) && __cplusplus >= 201103L 655 #include <cstdlib> 656 #define __Pyx_sst_abs(value) std::abs(value) 657 #elif SIZEOF_INT >= SIZEOF_SIZE_T 658 #define __Pyx_sst_abs(value) abs(value) 659 #elif SIZEOF_LONG >= SIZEOF_SIZE_T 660 #define __Pyx_sst_abs(value) labs(value) 661 #elif defined (_MSC_VER) 662 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) 663 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 664 #define __Pyx_sst_abs(value) llabs(value) 665 #elif defined (__GNUC__) 666 #define __Pyx_sst_abs(value) __builtin_llabs(value) 667 #else 668 #define __Pyx_sst_abs(value) ((value<0) ? -value : value) 669 #endif 670 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); 671 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); 672 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) 673 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) 674 #define __Pyx_PyBytes_FromString PyBytes_FromString 675 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize 676 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); 677 #if PY_MAJOR_VERSION < 3 678 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString 679 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize 680 #else 681 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString 682 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize 683 #endif 684 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) 685 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) 686 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) 687 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) 688 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) 689 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) 690 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) 691 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) 692 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) 693 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) 694 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) 695 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) 696 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) 697 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) 698 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) 699 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) 700 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { 701 const Py_UNICODE *u_end = u; 702 while (*u_end++) ; 703 return (size_t)(u_end - u - 1); 704 } 705 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) 706 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode 707 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode 708 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) 709 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) 710 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); 711 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); 712 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); 713 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); 714 #define __Pyx_PySequence_Tuple(obj)\ 715 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) 716 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); 717 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); 718 #if CYTHON_ASSUME_SAFE_MACROS 719 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) 720 #else 721 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) 722 #endif 723 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) 724 #if PY_MAJOR_VERSION >= 3 725 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) 726 #else 727 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) 728 #endif 729 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) 730 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 731 static int __Pyx_sys_getdefaultencoding_not_ascii; 732 static int __Pyx_init_sys_getdefaultencoding_params(void) { 733 PyObject* sys; 734 PyObject* default_encoding = NULL; 735 PyObject* ascii_chars_u = NULL; 736 PyObject* ascii_chars_b = NULL; 737 const char* default_encoding_c; 738 sys = PyImport_ImportModule("sys"); 739 if (!sys) goto bad; 740 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); 741 Py_DECREF(sys); 742 if (!default_encoding) goto bad; 743 default_encoding_c = PyBytes_AsString(default_encoding); 744 if (!default_encoding_c) goto bad; 745 if (strcmp(default_encoding_c, "ascii") == 0) { 746 __Pyx_sys_getdefaultencoding_not_ascii = 0; 747 } else { 748 char ascii_chars[128]; 749 int c; 750 for (c = 0; c < 128; c++) { 751 ascii_chars[c] = c; 752 } 753 __Pyx_sys_getdefaultencoding_not_ascii = 1; 754 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); 755 if (!ascii_chars_u) goto bad; 756 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); 757 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { 758 PyErr_Format( 759 PyExc_ValueError, 760 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", 761 default_encoding_c); 762 goto bad; 763 } 764 Py_DECREF(ascii_chars_u); 765 Py_DECREF(ascii_chars_b); 766 } 767 Py_DECREF(default_encoding); 768 return 0; 769 bad: 770 Py_XDECREF(default_encoding); 771 Py_XDECREF(ascii_chars_u); 772 Py_XDECREF(ascii_chars_b); 773 return -1; 774 } 775 #endif 776 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 777 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) 778 #else 779 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) 780 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 781 static char* __PYX_DEFAULT_STRING_ENCODING; 782 static int __Pyx_init_sys_getdefaultencoding_params(void) { 783 PyObject* sys; 784 PyObject* default_encoding = NULL; 785 char* default_encoding_c; 786 sys = PyImport_ImportModule("sys"); 787 if (!sys) goto bad; 788 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); 789 Py_DECREF(sys); 790 if (!default_encoding) goto bad; 791 default_encoding_c = PyBytes_AsString(default_encoding); 792 if (!default_encoding_c) goto bad; 793 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); 794 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; 795 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); 796 Py_DECREF(default_encoding); 797 return 0; 798 bad: 799 Py_XDECREF(default_encoding); 800 return -1; 801 } 802 #endif 803 #endif 804 805 806 /* Test for GCC > 2.95 */ 807 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) 808 #define likely(x) __builtin_expect(!!(x), 1) 809 #define unlikely(x) __builtin_expect(!!(x), 0) 810 #else /* !__GNUC__ or GCC < 2.95 */ 811 #define likely(x) (x) 812 #define unlikely(x) (x) 813 #endif /* __GNUC__ */ 814 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } 815 816 static PyObject *__pyx_m = NULL; 817 static PyObject *__pyx_d; 818 static PyObject *__pyx_b; 819 static PyObject *__pyx_cython_runtime = NULL; 820 static PyObject *__pyx_empty_tuple; 821 static PyObject *__pyx_empty_bytes; 822 static PyObject *__pyx_empty_unicode; 823 static int __pyx_lineno; 824 static int __pyx_clineno = 0; 825 static const char * __pyx_cfilenm= __FILE__; 826 static const char *__pyx_filename; 827 828 829 static const char *__pyx_f[] = { 830 "cy_cxxtest.pyx", 831 }; 832 833 /*--- Type declarations ---*/ 834 835 /* --- Runtime support code (head) --- */ 836 /* Refnanny.proto */ 837 #ifndef CYTHON_REFNANNY 838 #define CYTHON_REFNANNY 0 839 #endif 840 #if CYTHON_REFNANNY 841 typedef struct { 842 void (*INCREF)(void*, PyObject*, int); 843 void (*DECREF)(void*, PyObject*, int); 844 void (*GOTREF)(void*, PyObject*, int); 845 void (*GIVEREF)(void*, PyObject*, int); 846 void* (*SetupContext)(const char*, int, const char*); 847 void (*FinishContext)(void**); 848 } __Pyx_RefNannyAPIStruct; 849 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; 850 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); 851 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; 852 #ifdef WITH_THREAD 853 #define __Pyx_RefNannySetupContext(name, acquire_gil)\ 854 if (acquire_gil) {\ 855 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ 856 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ 857 PyGILState_Release(__pyx_gilstate_save);\ 858 } else {\ 859 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ 860 } 861 #else 862 #define __Pyx_RefNannySetupContext(name, acquire_gil)\ 863 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) 864 #endif 865 #define __Pyx_RefNannyFinishContext()\ 866 __Pyx_RefNanny->FinishContext(&__pyx_refnanny) 867 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 868 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 869 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 870 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 871 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) 872 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) 873 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) 874 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) 875 #else 876 #define __Pyx_RefNannyDeclarations 877 #define __Pyx_RefNannySetupContext(name, acquire_gil) 878 #define __Pyx_RefNannyFinishContext() 879 #define __Pyx_INCREF(r) Py_INCREF(r) 880 #define __Pyx_DECREF(r) Py_DECREF(r) 881 #define __Pyx_GOTREF(r) 882 #define __Pyx_GIVEREF(r) 883 #define __Pyx_XINCREF(r) Py_XINCREF(r) 884 #define __Pyx_XDECREF(r) Py_XDECREF(r) 885 #define __Pyx_XGOTREF(r) 886 #define __Pyx_XGIVEREF(r) 887 #endif 888 #define __Pyx_XDECREF_SET(r, v) do {\ 889 PyObject *tmp = (PyObject *) r;\ 890 r = v; __Pyx_XDECREF(tmp);\ 891 } while (0) 892 #define __Pyx_DECREF_SET(r, v) do {\ 893 PyObject *tmp = (PyObject *) r;\ 894 r = v; __Pyx_DECREF(tmp);\ 895 } while (0) 896 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) 897 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) 898 899 /* PyThreadStateGet.proto */ 900 #if CYTHON_FAST_THREAD_STATE 901 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; 902 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; 903 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type 904 #else 905 #define __Pyx_PyThreadState_declare 906 #define __Pyx_PyThreadState_assign 907 #define __Pyx_PyErr_Occurred() PyErr_Occurred() 908 #endif 909 910 /* PyErrFetchRestore.proto */ 911 #if CYTHON_FAST_THREAD_STATE 912 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) 913 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) 914 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) 915 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) 916 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) 917 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); 918 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); 919 #if CYTHON_COMPILING_IN_CPYTHON 920 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) 921 #else 922 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) 923 #endif 924 #else 925 #define __Pyx_PyErr_Clear() PyErr_Clear() 926 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) 927 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) 928 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) 929 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) 930 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) 931 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) 932 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) 933 #endif 934 935 /* WriteUnraisableException.proto */ 936 static void __Pyx_WriteUnraisable(const char *name, int clineno, 937 int lineno, const char *filename, 938 int full_traceback, int nogil); 939 940 /* PyObjectGetAttrStr.proto */ 941 #if CYTHON_USE_TYPE_SLOTS 942 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); 943 #else 944 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) 945 #endif 946 947 /* CLineInTraceback.proto */ 948 #ifdef CYTHON_CLINE_IN_TRACEBACK 949 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) 950 #else 951 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); 952 #endif 953 954 /* CodeObjectCache.proto */ 955 typedef struct { 956 PyCodeObject* code_object; 957 int code_line; 958 } __Pyx_CodeObjectCacheEntry; 959 struct __Pyx_CodeObjectCache { 960 int count; 961 int max_count; 962 __Pyx_CodeObjectCacheEntry* entries; 963 }; 964 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; 965 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); 966 static PyCodeObject *__pyx_find_code_object(int code_line); 967 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); 968 969 /* AddTraceback.proto */ 970 static void __Pyx_AddTraceback(const char *funcname, int c_line, 971 int py_line, const char *filename); 972 973 /* Print.proto */ 974 static int __Pyx_Print(PyObject*, PyObject *, int); 975 #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 976 static PyObject* __pyx_print = 0; 977 static PyObject* __pyx_print_kwargs = 0; 978 #endif 979 980 /* PrintOne.proto */ 981 static int __Pyx_PrintOne(PyObject* stream, PyObject *o); 982 983 /* CIntToPy.proto */ 984 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); 985 986 /* CIntFromPy.proto */ 987 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); 988 989 /* CIntFromPy.proto */ 990 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); 991 992 /* FastTypeChecks.proto */ 993 #if CYTHON_COMPILING_IN_CPYTHON 994 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) 995 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); 996 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); 997 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); 998 #else 999 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) 1000 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) 1001 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) 1002 #endif 1003 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) 1004 1005 /* CheckBinaryVersion.proto */ 1006 static int __Pyx_check_binary_version(void); 1007 1008 /* FunctionExport.proto */ 1009 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); 1010 1011 /* InitStrings.proto */ 1012 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); 1013 1014 1015 /* Module declarations from 'cpython.version' */ 1016 1017 /* Module declarations from 'cy_cxxtest' */ 1018 __PYX_EXTERN_C void cy_hello(void); /*proto*/ 1019 #define __Pyx_MODULE_NAME "cy_cxxtest" 1020 extern int __pyx_module_is_main_cy_cxxtest; 1021 int __pyx_module_is_main_cy_cxxtest = 0; 1022 1023 /* Implementation of 'cy_cxxtest' */ 1024 static const char __pyx_k_end[] = "end"; 1025 static const char __pyx_k_file[] = "file"; 1026 static const char __pyx_k_main[] = "__main__"; 1027 static const char __pyx_k_name[] = "__name__"; 1028 static const char __pyx_k_test[] = "__test__"; 1029 static const char __pyx_k_print[] = "print"; 1030 static const char __pyx_k_pyhello[] = "pyhello"; 1031 static const char __pyx_k_cy_cxxtest[] = "cy_cxxtest"; 1032 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; 1033 static const char __pyx_k_hello_cython_world[] = "hello cython-world!"; 1034 static const char __pyx_k_Compiled_with_python_version_s[] = "Compiled with python version %s"; 1035 static const char __pyx_k_home_romain_dev_waf_wrapper_waf[] = "/home/romain/dev/waf-wrapper/waf/playground/cython/src/cy_cxxtest.pyx"; 1036 static PyObject *__pyx_kp_s_Compiled_with_python_version_s; 1037 static PyObject *__pyx_n_s_cline_in_traceback; 1038 static PyObject *__pyx_n_s_cy_cxxtest; 1039 static PyObject *__pyx_n_s_end; 1040 static PyObject *__pyx_n_s_file; 1041 static PyObject *__pyx_kp_s_hello_cython_world; 1042 static PyObject *__pyx_kp_s_home_romain_dev_waf_wrapper_waf; 1043 static PyObject *__pyx_n_s_main; 1044 static PyObject *__pyx_n_s_name; 1045 static PyObject *__pyx_n_s_print; 1046 static PyObject *__pyx_n_s_pyhello; 1047 static PyObject *__pyx_n_s_test; 1048 static PyObject *__pyx_pf_10cy_cxxtest_pyhello(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ 1049 static PyObject *__pyx_codeobj_; 1050 /* Late includes */ 1051 1052 /* "cy_cxxtest.pyx":4 1053 * cimport cy_cxxtest 1054 * 1055 * def pyhello(): # <<<<<<<<<<<<<< 1056 * cy_cxxtest.hello() 1057 * print("Compiled with python version %s" % PY_VERSION) 1058 */ 1059 1060 /* Python wrapper */ 1061 static PyObject *__pyx_pw_10cy_cxxtest_1pyhello(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 1062 static PyMethodDef __pyx_mdef_10cy_cxxtest_1pyhello = {"pyhello", (PyCFunction)__pyx_pw_10cy_cxxtest_1pyhello, METH_NOARGS, 0}; 1063 static PyObject *__pyx_pw_10cy_cxxtest_1pyhello(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { 1064 PyObject *__pyx_r = 0; 1065 __Pyx_RefNannyDeclarations 1066 __Pyx_RefNannySetupContext("pyhello (wrapper)", 0); 1067 __pyx_r = __pyx_pf_10cy_cxxtest_pyhello(__pyx_self); 1068 1069 /* function exit code */ 1070 __Pyx_RefNannyFinishContext(); 1071 return __pyx_r; 1072 } 1073 1074 static PyObject *__pyx_pf_10cy_cxxtest_pyhello(CYTHON_UNUSED PyObject *__pyx_self) { 1075 PyObject *__pyx_r = NULL; 1076 __Pyx_RefNannyDeclarations 1077 PyObject *__pyx_t_1 = NULL; 1078 PyObject *__pyx_t_2 = NULL; 1079 __Pyx_RefNannySetupContext("pyhello", 0); 1080 1081 /* "cy_cxxtest.pyx":5 1082 * 1083 * def pyhello(): 1084 * cy_cxxtest.hello() # <<<<<<<<<<<<<< 1085 * print("Compiled with python version %s" % PY_VERSION) 1086 * 1087 */ 1088 hello(); 1089 1090 /* "cy_cxxtest.pyx":6 1091 * def pyhello(): 1092 * cy_cxxtest.hello() 1093 * print("Compiled with python version %s" % PY_VERSION) # <<<<<<<<<<<<<< 1094 * 1095 * cdef public api void cy_hello(): 1096 */ 1097 __pyx_t_1 = __Pyx_PyObject_FromString(PY_VERSION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) 1098 __Pyx_GOTREF(__pyx_t_1); 1099 __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Compiled_with_python_version_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) 1100 __Pyx_GOTREF(__pyx_t_2); 1101 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1102 if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error) 1103 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 1104 1105 /* "cy_cxxtest.pyx":4 1106 * cimport cy_cxxtest 1107 * 1108 * def pyhello(): # <<<<<<<<<<<<<< 1109 * cy_cxxtest.hello() 1110 * print("Compiled with python version %s" % PY_VERSION) 1111 */ 1112 1113 /* function exit code */ 1114 __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1115 goto __pyx_L0; 1116 __pyx_L1_error:; 1117 __Pyx_XDECREF(__pyx_t_1); 1118 __Pyx_XDECREF(__pyx_t_2); 1119 __Pyx_AddTraceback("cy_cxxtest.pyhello", __pyx_clineno, __pyx_lineno, __pyx_filename); 1120 __pyx_r = NULL; 1121 __pyx_L0:; 1122 __Pyx_XGIVEREF(__pyx_r); 1123 __Pyx_RefNannyFinishContext(); 1124 return __pyx_r; 1125 } 1126 1127 /* "cy_cxxtest.pyx":8 1128 * print("Compiled with python version %s" % PY_VERSION) 1129 * 1130 * cdef public api void cy_hello(): # <<<<<<<<<<<<<< 1131 * print("hello cython-world!") 1132 */ 1133 1134 void cy_hello(void) { 1135 __Pyx_RefNannyDeclarations 1136 __Pyx_RefNannySetupContext("cy_hello", 0); 1137 1138 /* "cy_cxxtest.pyx":9 1139 * 1140 * cdef public api void cy_hello(): 1141 * print("hello cython-world!") # <<<<<<<<<<<<<< 1142 */ 1143 if (__Pyx_PrintOne(0, __pyx_kp_s_hello_cython_world) < 0) __PYX_ERR(0, 9, __pyx_L1_error) 1144 1145 /* "cy_cxxtest.pyx":8 1146 * print("Compiled with python version %s" % PY_VERSION) 1147 * 1148 * cdef public api void cy_hello(): # <<<<<<<<<<<<<< 1149 * print("hello cython-world!") 1150 */ 1151 1152 /* function exit code */ 1153 goto __pyx_L0; 1154 __pyx_L1_error:; 1155 __Pyx_WriteUnraisable("cy_cxxtest.cy_hello", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); 1156 __pyx_L0:; 1157 __Pyx_RefNannyFinishContext(); 1158 } 1159 1160 static PyMethodDef __pyx_methods[] = { 1161 {0, 0, 0, 0} 1162 }; 1163 1164 #if PY_MAJOR_VERSION >= 3 1165 #if CYTHON_PEP489_MULTI_PHASE_INIT 1166 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ 1167 static int __pyx_pymod_exec_cy_cxxtest(PyObject* module); /*proto*/ 1168 static PyModuleDef_Slot __pyx_moduledef_slots[] = { 1169 {Py_mod_create, (void*)__pyx_pymod_create}, 1170 {Py_mod_exec, (void*)__pyx_pymod_exec_cy_cxxtest}, 1171 {0, NULL} 1172 }; 1173 #endif 1174 1175 static struct PyModuleDef __pyx_moduledef = { 1176 PyModuleDef_HEAD_INIT, 1177 "cy_cxxtest", 1178 0, /* m_doc */ 1179 #if CYTHON_PEP489_MULTI_PHASE_INIT 1180 0, /* m_size */ 1181 #else 1182 -1, /* m_size */ 1183 #endif 1184 __pyx_methods /* m_methods */, 1185 #if CYTHON_PEP489_MULTI_PHASE_INIT 1186 __pyx_moduledef_slots, /* m_slots */ 1187 #else 1188 NULL, /* m_reload */ 1189 #endif 1190 NULL, /* m_traverse */ 1191 NULL, /* m_clear */ 1192 NULL /* m_free */ 1193 }; 1194 #endif 1195 #ifndef CYTHON_SMALL_CODE 1196 #if defined(__clang__) 1197 #define CYTHON_SMALL_CODE 1198 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) 1199 #define CYTHON_SMALL_CODE __attribute__((cold)) 1200 #else 1201 #define CYTHON_SMALL_CODE 1202 #endif 1203 #endif 1204 1205 static __Pyx_StringTabEntry __pyx_string_tab[] = { 1206 {&__pyx_kp_s_Compiled_with_python_version_s, __pyx_k_Compiled_with_python_version_s, sizeof(__pyx_k_Compiled_with_python_version_s), 0, 0, 1, 0}, 1207 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, 1208 {&__pyx_n_s_cy_cxxtest, __pyx_k_cy_cxxtest, sizeof(__pyx_k_cy_cxxtest), 0, 0, 1, 1}, 1209 {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, 1210 {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, 1211 {&__pyx_kp_s_hello_cython_world, __pyx_k_hello_cython_world, sizeof(__pyx_k_hello_cython_world), 0, 0, 1, 0}, 1212 {&__pyx_kp_s_home_romain_dev_waf_wrapper_waf, __pyx_k_home_romain_dev_waf_wrapper_waf, sizeof(__pyx_k_home_romain_dev_waf_wrapper_waf), 0, 0, 1, 0}, 1213 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, 1214 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, 1215 {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, 1216 {&__pyx_n_s_pyhello, __pyx_k_pyhello, sizeof(__pyx_k_pyhello), 0, 0, 1, 1}, 1217 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, 1218 {0, 0, 0, 0, 0, 0, 0} 1219 }; 1220 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { 1221 return 0; 1222 } 1223 1224 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { 1225 __Pyx_RefNannyDeclarations 1226 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); 1227 1228 /* "cy_cxxtest.pyx":4 1229 * cimport cy_cxxtest 1230 * 1231 * def pyhello(): # <<<<<<<<<<<<<< 1232 * cy_cxxtest.hello() 1233 * print("Compiled with python version %s" % PY_VERSION) 1234 */ 1235 __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_romain_dev_waf_wrapper_waf, __pyx_n_s_pyhello, 4, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 4, __pyx_L1_error) 1236 __Pyx_RefNannyFinishContext(); 1237 return 0; 1238 __pyx_L1_error:; 1239 __Pyx_RefNannyFinishContext(); 1240 return -1; 1241 } 1242 1243 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { 1244 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); 1245 return 0; 1246 __pyx_L1_error:; 1247 return -1; 1248 } 1249 1250 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ 1251 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ 1252 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ 1253 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ 1254 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ 1255 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ 1256 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ 1257 1258 static int __Pyx_modinit_global_init_code(void) { 1259 __Pyx_RefNannyDeclarations 1260 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); 1261 /*--- Global init code ---*/ 1262 __Pyx_RefNannyFinishContext(); 1263 return 0; 1264 } 1265 1266 static int __Pyx_modinit_variable_export_code(void) { 1267 __Pyx_RefNannyDeclarations 1268 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); 1269 /*--- Variable export code ---*/ 1270 __Pyx_RefNannyFinishContext(); 1271 return 0; 1272 } 1273 1274 static int __Pyx_modinit_function_export_code(void) { 1275 __Pyx_RefNannyDeclarations 1276 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); 1277 /*--- Function export code ---*/ 1278 if (__Pyx_ExportFunction("cy_hello", (void (*)(void))cy_hello, "void (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1279 __Pyx_RefNannyFinishContext(); 1280 return 0; 1281 __pyx_L1_error:; 1282 __Pyx_RefNannyFinishContext(); 1283 return -1; 1284 } 1285 1286 static int __Pyx_modinit_type_init_code(void) { 1287 __Pyx_RefNannyDeclarations 1288 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); 1289 /*--- Type init code ---*/ 1290 __Pyx_RefNannyFinishContext(); 1291 return 0; 1292 } 1293 1294 static int __Pyx_modinit_type_import_code(void) { 1295 __Pyx_RefNannyDeclarations 1296 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); 1297 /*--- Type import code ---*/ 1298 __Pyx_RefNannyFinishContext(); 1299 return 0; 1300 } 1301 1302 static int __Pyx_modinit_variable_import_code(void) { 1303 __Pyx_RefNannyDeclarations 1304 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); 1305 /*--- Variable import code ---*/ 1306 __Pyx_RefNannyFinishContext(); 1307 return 0; 1308 } 1309 1310 static int __Pyx_modinit_function_import_code(void) { 1311 __Pyx_RefNannyDeclarations 1312 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); 1313 /*--- Function import code ---*/ 1314 __Pyx_RefNannyFinishContext(); 1315 return 0; 1316 } 1317 1318 1319 #if PY_MAJOR_VERSION < 3 1320 #ifdef CYTHON_NO_PYINIT_EXPORT 1321 #define __Pyx_PyMODINIT_FUNC void 1322 #else 1323 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC 1324 #endif 1325 #else 1326 #ifdef CYTHON_NO_PYINIT_EXPORT 1327 #define __Pyx_PyMODINIT_FUNC PyObject * 1328 #else 1329 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC 1330 #endif 1331 #endif 1332 1333 1334 #if PY_MAJOR_VERSION < 3 1335 __Pyx_PyMODINIT_FUNC initcy_cxxtest(void) CYTHON_SMALL_CODE; /*proto*/ 1336 __Pyx_PyMODINIT_FUNC initcy_cxxtest(void) 1337 #else 1338 __Pyx_PyMODINIT_FUNC PyInit_cy_cxxtest(void) CYTHON_SMALL_CODE; /*proto*/ 1339 __Pyx_PyMODINIT_FUNC PyInit_cy_cxxtest(void) 1340 #if CYTHON_PEP489_MULTI_PHASE_INIT 1341 { 1342 return PyModuleDef_Init(&__pyx_moduledef); 1343 } 1344 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { 1345 #if PY_VERSION_HEX >= 0x030700A1 1346 static PY_INT64_T main_interpreter_id = -1; 1347 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); 1348 if (main_interpreter_id == -1) { 1349 main_interpreter_id = current_id; 1350 return (unlikely(current_id == -1)) ? -1 : 0; 1351 } else if (unlikely(main_interpreter_id != current_id)) 1352 #else 1353 static PyInterpreterState *main_interpreter = NULL; 1354 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; 1355 if (!main_interpreter) { 1356 main_interpreter = current_interpreter; 1357 } else if (unlikely(main_interpreter != current_interpreter)) 1358 #endif 1359 { 1360 PyErr_SetString( 1361 PyExc_ImportError, 1362 "Interpreter change detected - this module can only be loaded into one interpreter per process."); 1363 return -1; 1364 } 1365 return 0; 1366 } 1367 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { 1368 PyObject *value = PyObject_GetAttrString(spec, from_name); 1369 int result = 0; 1370 if (likely(value)) { 1371 result = PyDict_SetItemString(moddict, to_name, value); 1372 Py_DECREF(value); 1373 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { 1374 PyErr_Clear(); 1375 } else { 1376 result = -1; 1377 } 1378 return result; 1379 } 1380 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { 1381 PyObject *module = NULL, *moddict, *modname; 1382 if (__Pyx_check_single_interpreter()) 1383 return NULL; 1384 if (__pyx_m) 1385 return __Pyx_NewRef(__pyx_m); 1386 modname = PyObject_GetAttrString(spec, "name"); 1387 if (unlikely(!modname)) goto bad; 1388 module = PyModule_NewObject(modname); 1389 Py_DECREF(modname); 1390 if (unlikely(!module)) goto bad; 1391 moddict = PyModule_GetDict(module); 1392 if (unlikely(!moddict)) goto bad; 1393 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; 1394 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; 1395 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; 1396 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; 1397 return module; 1398 bad: 1399 Py_XDECREF(module); 1400 return NULL; 1401 } 1402 1403 1404 static CYTHON_SMALL_CODE int __pyx_pymod_exec_cy_cxxtest(PyObject *__pyx_pyinit_module) 1405 #endif 1406 #endif 1407 { 1408 PyObject *__pyx_t_1 = NULL; 1409 __Pyx_RefNannyDeclarations 1410 #if CYTHON_PEP489_MULTI_PHASE_INIT 1411 if (__pyx_m) { 1412 if (__pyx_m == __pyx_pyinit_module) return 0; 1413 PyErr_SetString(PyExc_RuntimeError, "Module 'cy_cxxtest' has already been imported. Re-initialisation is not supported."); 1414 return -1; 1415 } 1416 #elif PY_MAJOR_VERSION >= 3 1417 if (__pyx_m) return __Pyx_NewRef(__pyx_m); 1418 #endif 1419 #if CYTHON_REFNANNY 1420 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); 1421 if (!__Pyx_RefNanny) { 1422 PyErr_Clear(); 1423 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); 1424 if (!__Pyx_RefNanny) 1425 Py_FatalError("failed to import 'refnanny' module"); 1426 } 1427 #endif 1428 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cy_cxxtest(void)", 0); 1429 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1430 #ifdef __Pxy_PyFrame_Initialize_Offsets 1431 __Pxy_PyFrame_Initialize_Offsets(); 1432 #endif 1433 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) 1434 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) 1435 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) 1436 #ifdef __Pyx_CyFunction_USED 1437 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1438 #endif 1439 #ifdef __Pyx_FusedFunction_USED 1440 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1441 #endif 1442 #ifdef __Pyx_Coroutine_USED 1443 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1444 #endif 1445 #ifdef __Pyx_Generator_USED 1446 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1447 #endif 1448 #ifdef __Pyx_AsyncGen_USED 1449 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1450 #endif 1451 #ifdef __Pyx_StopAsyncIteration_USED 1452 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1453 #endif 1454 /*--- Library function declarations ---*/ 1455 /*--- Threads initialization code ---*/ 1456 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS 1457 #ifdef WITH_THREAD /* Python build with threading support? */ 1458 PyEval_InitThreads(); 1459 #endif 1460 #endif 1461 /*--- Module creation code ---*/ 1462 #if CYTHON_PEP489_MULTI_PHASE_INIT 1463 __pyx_m = __pyx_pyinit_module; 1464 Py_INCREF(__pyx_m); 1465 #else 1466 #if PY_MAJOR_VERSION < 3 1467 __pyx_m = Py_InitModule4("cy_cxxtest", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); 1468 #else 1469 __pyx_m = PyModule_Create(&__pyx_moduledef); 1470 #endif 1471 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) 1472 #endif 1473 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) 1474 Py_INCREF(__pyx_d); 1475 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) 1476 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) 1477 #if CYTHON_COMPILING_IN_PYPY 1478 Py_INCREF(__pyx_b); 1479 #endif 1480 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); 1481 /*--- Initialize various global constants etc. ---*/ 1482 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1483 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) 1484 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1485 #endif 1486 if (__pyx_module_is_main_cy_cxxtest) { 1487 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1488 } 1489 #if PY_MAJOR_VERSION >= 3 1490 { 1491 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) 1492 if (!PyDict_GetItemString(modules, "cy_cxxtest")) { 1493 if (unlikely(PyDict_SetItemString(modules, "cy_cxxtest", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) 1494 } 1495 } 1496 #endif 1497 /*--- Builtin init code ---*/ 1498 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1499 /*--- Constants init code ---*/ 1500 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1501 /*--- Global type/function init code ---*/ 1502 (void)__Pyx_modinit_global_init_code(); 1503 (void)__Pyx_modinit_variable_export_code(); 1504 if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error; 1505 (void)__Pyx_modinit_type_init_code(); 1506 (void)__Pyx_modinit_type_import_code(); 1507 (void)__Pyx_modinit_variable_import_code(); 1508 (void)__Pyx_modinit_function_import_code(); 1509 /*--- Execution code ---*/ 1510 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) 1511 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1512 #endif 1513 1514 /* "cy_cxxtest.pyx":4 1515 * cimport cy_cxxtest 1516 * 1517 * def pyhello(): # <<<<<<<<<<<<<< 1518 * cy_cxxtest.hello() 1519 * print("Compiled with python version %s" % PY_VERSION) 1520 */ 1521 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10cy_cxxtest_1pyhello, NULL, __pyx_n_s_cy_cxxtest); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) 1522 __Pyx_GOTREF(__pyx_t_1); 1523 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyhello, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) 1524 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1525 1526 /* "cy_cxxtest.pyx":1 1527 * from cpython.version cimport PY_VERSION # <<<<<<<<<<<<<< 1528 * cimport cy_cxxtest 1529 * 1530 */ 1531 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) 1532 __Pyx_GOTREF(__pyx_t_1); 1533 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) 1534 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1535 1536 /*--- Wrapped vars code ---*/ 1537 1538 goto __pyx_L0; 1539 __pyx_L1_error:; 1540 __Pyx_XDECREF(__pyx_t_1); 1541 if (__pyx_m) { 1542 if (__pyx_d) { 1543 __Pyx_AddTraceback("init cy_cxxtest", __pyx_clineno, __pyx_lineno, __pyx_filename); 1544 } 1545 Py_CLEAR(__pyx_m); 1546 } else if (!PyErr_Occurred()) { 1547 PyErr_SetString(PyExc_ImportError, "init cy_cxxtest"); 1548 } 1549 __pyx_L0:; 1550 __Pyx_RefNannyFinishContext(); 1551 #if CYTHON_PEP489_MULTI_PHASE_INIT 1552 return (__pyx_m != NULL) ? 0 : -1; 1553 #elif PY_MAJOR_VERSION >= 3 1554 return __pyx_m; 1555 #else 1556 return; 1557 #endif 1558 } 1559 1560 /* --- Runtime support code --- */ 1561 /* Refnanny */ 1562 #if CYTHON_REFNANNY 1563 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { 1564 PyObject *m = NULL, *p = NULL; 1565 void *r = NULL; 1566 m = PyImport_ImportModule(modname); 1567 if (!m) goto end; 1568 p = PyObject_GetAttrString(m, "RefNannyAPI"); 1569 if (!p) goto end; 1570 r = PyLong_AsVoidPtr(p); 1571 end: 1572 Py_XDECREF(p); 1573 Py_XDECREF(m); 1574 return (__Pyx_RefNannyAPIStruct *)r; 1575 } 1576 #endif 1577 1578 /* PyErrFetchRestore */ 1579 #if CYTHON_FAST_THREAD_STATE 1580 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { 1581 PyObject *tmp_type, *tmp_value, *tmp_tb; 1582 tmp_type = tstate->curexc_type; 1583 tmp_value = tstate->curexc_value; 1584 tmp_tb = tstate->curexc_traceback; 1585 tstate->curexc_type = type; 1586 tstate->curexc_value = value; 1587 tstate->curexc_traceback = tb; 1588 Py_XDECREF(tmp_type); 1589 Py_XDECREF(tmp_value); 1590 Py_XDECREF(tmp_tb); 1591 } 1592 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { 1593 *type = tstate->curexc_type; 1594 *value = tstate->curexc_value; 1595 *tb = tstate->curexc_traceback; 1596 tstate->curexc_type = 0; 1597 tstate->curexc_value = 0; 1598 tstate->curexc_traceback = 0; 1599 } 1600 #endif 1601 1602 /* WriteUnraisableException */ 1603 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, 1604 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, 1605 int full_traceback, CYTHON_UNUSED int nogil) { 1606 PyObject *old_exc, *old_val, *old_tb; 1607 PyObject *ctx; 1608 __Pyx_PyThreadState_declare 1609 #ifdef WITH_THREAD 1610 PyGILState_STATE state; 1611 if (nogil) 1612 state = PyGILState_Ensure(); 1613 #ifdef _MSC_VER 1614 else state = (PyGILState_STATE)-1; 1615 #endif 1616 #endif 1617 __Pyx_PyThreadState_assign 1618 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); 1619 if (full_traceback) { 1620 Py_XINCREF(old_exc); 1621 Py_XINCREF(old_val); 1622 Py_XINCREF(old_tb); 1623 __Pyx_ErrRestore(old_exc, old_val, old_tb); 1624 PyErr_PrintEx(1); 1625 } 1626 #if PY_MAJOR_VERSION < 3 1627 ctx = PyString_FromString(name); 1628 #else 1629 ctx = PyUnicode_FromString(name); 1630 #endif 1631 __Pyx_ErrRestore(old_exc, old_val, old_tb); 1632 if (!ctx) { 1633 PyErr_WriteUnraisable(Py_None); 1634 } else { 1635 PyErr_WriteUnraisable(ctx); 1636 Py_DECREF(ctx); 1637 } 1638 #ifdef WITH_THREAD 1639 if (nogil) 1640 PyGILState_Release(state); 1641 #endif 1642 } 1643 1644 /* PyObjectGetAttrStr */ 1645 #if CYTHON_USE_TYPE_SLOTS 1646 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { 1647 PyTypeObject* tp = Py_TYPE(obj); 1648 if (likely(tp->tp_getattro)) 1649 return tp->tp_getattro(obj, attr_name); 1650 #if PY_MAJOR_VERSION < 3 1651 if (likely(tp->tp_getattr)) 1652 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); 1653 #endif 1654 return PyObject_GetAttr(obj, attr_name); 1655 } 1656 #endif 1657 1658 /* CLineInTraceback */ 1659 #ifndef CYTHON_CLINE_IN_TRACEBACK 1660 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { 1661 PyObject *use_cline; 1662 PyObject *ptype, *pvalue, *ptraceback; 1663 #if CYTHON_COMPILING_IN_CPYTHON 1664 PyObject **cython_runtime_dict; 1665 #endif 1666 if (unlikely(!__pyx_cython_runtime)) { 1667 return c_line; 1668 } 1669 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); 1670 #if CYTHON_COMPILING_IN_CPYTHON 1671 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); 1672 if (likely(cython_runtime_dict)) { 1673 __PYX_PY_DICT_LOOKUP_IF_MODIFIED( 1674 use_cline, *cython_runtime_dict, 1675 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) 1676 } else 1677 #endif 1678 { 1679 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); 1680 if (use_cline_obj) { 1681 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; 1682 Py_DECREF(use_cline_obj); 1683 } else { 1684 PyErr_Clear(); 1685 use_cline = NULL; 1686 } 1687 } 1688 if (!use_cline) { 1689 c_line = 0; 1690 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); 1691 } 1692 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { 1693 c_line = 0; 1694 } 1695 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); 1696 return c_line; 1697 } 1698 #endif 1699 1700 /* CodeObjectCache */ 1701 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { 1702 int start = 0, mid = 0, end = count - 1; 1703 if (end >= 0 && code_line > entries[end].code_line) { 1704 return count; 1705 } 1706 while (start < end) { 1707 mid = start + (end - start) / 2; 1708 if (code_line < entries[mid].code_line) { 1709 end = mid; 1710 } else if (code_line > entries[mid].code_line) { 1711 start = mid + 1; 1712 } else { 1713 return mid; 1714 } 1715 } 1716 if (code_line <= entries[mid].code_line) { 1717 return mid; 1718 } else { 1719 return mid + 1; 1720 } 1721 } 1722 static PyCodeObject *__pyx_find_code_object(int code_line) { 1723 PyCodeObject* code_object; 1724 int pos; 1725 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { 1726 return NULL; 1727 } 1728 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); 1729 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { 1730 return NULL; 1731 } 1732 code_object = __pyx_code_cache.entries[pos].code_object; 1733 Py_INCREF(code_object); 1734 return code_object; 1735 } 1736 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { 1737 int pos, i; 1738 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; 1739 if (unlikely(!code_line)) { 1740 return; 1741 } 1742 if (unlikely(!entries)) { 1743 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); 1744 if (likely(entries)) { 1745 __pyx_code_cache.entries = entries; 1746 __pyx_code_cache.max_count = 64; 1747 __pyx_code_cache.count = 1; 1748 entries[0].code_line = code_line; 1749 entries[0].code_object = code_object; 1750 Py_INCREF(code_object); 1751 } 1752 return; 1753 } 1754 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); 1755 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { 1756 PyCodeObject* tmp = entries[pos].code_object; 1757 entries[pos].code_object = code_object; 1758 Py_DECREF(tmp); 1759 return; 1760 } 1761 if (__pyx_code_cache.count == __pyx_code_cache.max_count) { 1762 int new_max = __pyx_code_cache.max_count + 64; 1763 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( 1764 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); 1765 if (unlikely(!entries)) { 1766 return; 1767 } 1768 __pyx_code_cache.entries = entries; 1769 __pyx_code_cache.max_count = new_max; 1770 } 1771 for (i=__pyx_code_cache.count; i>pos; i--) { 1772 entries[i] = entries[i-1]; 1773 } 1774 entries[pos].code_line = code_line; 1775 entries[pos].code_object = code_object; 1776 __pyx_code_cache.count++; 1777 Py_INCREF(code_object); 1778 } 1779 1780 /* AddTraceback */ 1781 #include "compile.h" 1782 #include "frameobject.h" 1783 #include "traceback.h" 1784 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( 1785 const char *funcname, int c_line, 1786 int py_line, const char *filename) { 1787 PyCodeObject *py_code = 0; 1788 PyObject *py_srcfile = 0; 1789 PyObject *py_funcname = 0; 1790 #if PY_MAJOR_VERSION < 3 1791 py_srcfile = PyString_FromString(filename); 1792 #else 1793 py_srcfile = PyUnicode_FromString(filename); 1794 #endif 1795 if (!py_srcfile) goto bad; 1796 if (c_line) { 1797 #if PY_MAJOR_VERSION < 3 1798 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); 1799 #else 1800 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); 1801 #endif 1802 } 1803 else { 1804 #if PY_MAJOR_VERSION < 3 1805 py_funcname = PyString_FromString(funcname); 1806 #else 1807 py_funcname = PyUnicode_FromString(funcname); 1808 #endif 1809 } 1810 if (!py_funcname) goto bad; 1811 py_code = __Pyx_PyCode_New( 1812 0, 1813 0, 1814 0, 1815 0, 1816 0, 1817 __pyx_empty_bytes, /*PyObject *code,*/ 1818 __pyx_empty_tuple, /*PyObject *consts,*/ 1819 __pyx_empty_tuple, /*PyObject *names,*/ 1820 __pyx_empty_tuple, /*PyObject *varnames,*/ 1821 __pyx_empty_tuple, /*PyObject *freevars,*/ 1822 __pyx_empty_tuple, /*PyObject *cellvars,*/ 1823 py_srcfile, /*PyObject *filename,*/ 1824 py_funcname, /*PyObject *name,*/ 1825 py_line, 1826 __pyx_empty_bytes /*PyObject *lnotab*/ 1827 ); 1828 Py_DECREF(py_srcfile); 1829 Py_DECREF(py_funcname); 1830 return py_code; 1831 bad: 1832 Py_XDECREF(py_srcfile); 1833 Py_XDECREF(py_funcname); 1834 return NULL; 1835 } 1836 static void __Pyx_AddTraceback(const char *funcname, int c_line, 1837 int py_line, const char *filename) { 1838 PyCodeObject *py_code = 0; 1839 PyFrameObject *py_frame = 0; 1840 PyThreadState *tstate = __Pyx_PyThreadState_Current; 1841 if (c_line) { 1842 c_line = __Pyx_CLineForTraceback(tstate, c_line); 1843 } 1844 py_code = __pyx_find_code_object(c_line ? -c_line : py_line); 1845 if (!py_code) { 1846 py_code = __Pyx_CreateCodeObjectForTraceback( 1847 funcname, c_line, py_line, filename); 1848 if (!py_code) goto bad; 1849 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); 1850 } 1851 py_frame = PyFrame_New( 1852 tstate, /*PyThreadState *tstate,*/ 1853 py_code, /*PyCodeObject *code,*/ 1854 __pyx_d, /*PyObject *globals,*/ 1855 0 /*PyObject *locals*/ 1856 ); 1857 if (!py_frame) goto bad; 1858 __Pyx_PyFrame_SetLineNumber(py_frame, py_line); 1859 PyTraceBack_Here(py_frame); 1860 bad: 1861 Py_XDECREF(py_code); 1862 Py_XDECREF(py_frame); 1863 } 1864 1865 /* Print */ 1866 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 1867 static PyObject *__Pyx_GetStdout(void) { 1868 PyObject *f = PySys_GetObject((char *)"stdout"); 1869 if (!f) { 1870 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); 1871 } 1872 return f; 1873 } 1874 static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { 1875 int i; 1876 if (!f) { 1877 if (!(f = __Pyx_GetStdout())) 1878 return -1; 1879 } 1880 Py_INCREF(f); 1881 for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { 1882 PyObject* v; 1883 if (PyFile_SoftSpace(f, 1)) { 1884 if (PyFile_WriteString(" ", f) < 0) 1885 goto error; 1886 } 1887 v = PyTuple_GET_ITEM(arg_tuple, i); 1888 if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) 1889 goto error; 1890 if (PyString_Check(v)) { 1891 char *s = PyString_AsString(v); 1892 Py_ssize_t len = PyString_Size(v); 1893 if (len > 0) { 1894 switch (s[len-1]) { 1895 case ' ': break; 1896 case '\f': case '\r': case '\n': case '\t': case '\v': 1897 PyFile_SoftSpace(f, 0); 1898 break; 1899 default: break; 1900 } 1901 } 1902 } 1903 } 1904 if (newline) { 1905 if (PyFile_WriteString("\n", f) < 0) 1906 goto error; 1907 PyFile_SoftSpace(f, 0); 1908 } 1909 Py_DECREF(f); 1910 return 0; 1911 error: 1912 Py_DECREF(f); 1913 return -1; 1914 } 1915 #else 1916 static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { 1917 PyObject* kwargs = 0; 1918 PyObject* result = 0; 1919 PyObject* end_string; 1920 if (unlikely(!__pyx_print)) { 1921 __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); 1922 if (!__pyx_print) 1923 return -1; 1924 } 1925 if (stream) { 1926 kwargs = PyDict_New(); 1927 if (unlikely(!kwargs)) 1928 return -1; 1929 if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) 1930 goto bad; 1931 if (!newline) { 1932 end_string = PyUnicode_FromStringAndSize(" ", 1); 1933 if (unlikely(!end_string)) 1934 goto bad; 1935 if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { 1936 Py_DECREF(end_string); 1937 goto bad; 1938 } 1939 Py_DECREF(end_string); 1940 } 1941 } else if (!newline) { 1942 if (unlikely(!__pyx_print_kwargs)) { 1943 __pyx_print_kwargs = PyDict_New(); 1944 if (unlikely(!__pyx_print_kwargs)) 1945 return -1; 1946 end_string = PyUnicode_FromStringAndSize(" ", 1); 1947 if (unlikely(!end_string)) 1948 return -1; 1949 if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { 1950 Py_DECREF(end_string); 1951 return -1; 1952 } 1953 Py_DECREF(end_string); 1954 } 1955 kwargs = __pyx_print_kwargs; 1956 } 1957 result = PyObject_Call(__pyx_print, arg_tuple, kwargs); 1958 if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) 1959 Py_DECREF(kwargs); 1960 if (!result) 1961 return -1; 1962 Py_DECREF(result); 1963 return 0; 1964 bad: 1965 if (kwargs != __pyx_print_kwargs) 1966 Py_XDECREF(kwargs); 1967 return -1; 1968 } 1969 #endif 1970 1971 /* PrintOne */ 1972 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 1973 static int __Pyx_PrintOne(PyObject* f, PyObject *o) { 1974 if (!f) { 1975 if (!(f = __Pyx_GetStdout())) 1976 return -1; 1977 } 1978 Py_INCREF(f); 1979 if (PyFile_SoftSpace(f, 0)) { 1980 if (PyFile_WriteString(" ", f) < 0) 1981 goto error; 1982 } 1983 if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) 1984 goto error; 1985 if (PyFile_WriteString("\n", f) < 0) 1986 goto error; 1987 Py_DECREF(f); 1988 return 0; 1989 error: 1990 Py_DECREF(f); 1991 return -1; 1992 /* the line below is just to avoid C compiler 1993 * warnings about unused functions */ 1994 return __Pyx_Print(f, NULL, 0); 1995 } 1996 #else 1997 static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { 1998 int res; 1999 PyObject* arg_tuple = PyTuple_Pack(1, o); 2000 if (unlikely(!arg_tuple)) 2001 return -1; 2002 res = __Pyx_Print(stream, arg_tuple, 1); 2003 Py_DECREF(arg_tuple); 2004 return res; 2005 } 2006 #endif 2007 2008 /* CIntToPy */ 2009 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { 2010 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; 2011 const int is_unsigned = neg_one > const_zero; 2012 if (is_unsigned) { 2013 if (sizeof(long) < sizeof(long)) { 2014 return PyInt_FromLong((long) value); 2015 } else if (sizeof(long) <= sizeof(unsigned long)) { 2016 return PyLong_FromUnsignedLong((unsigned long) value); 2017 #ifdef HAVE_LONG_LONG 2018 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { 2019 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); 2020 #endif 2021 } 2022 } else { 2023 if (sizeof(long) <= sizeof(long)) { 2024 return PyInt_FromLong((long) value); 2025 #ifdef HAVE_LONG_LONG 2026 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { 2027 return PyLong_FromLongLong((PY_LONG_LONG) value); 2028 #endif 2029 } 2030 } 2031 { 2032 int one = 1; int little = (int)*(unsigned char *)&one; 2033 unsigned char *bytes = (unsigned char *)&value; 2034 return _PyLong_FromByteArray(bytes, sizeof(long), 2035 little, !is_unsigned); 2036 } 2037 } 2038 2039 /* CIntFromPyVerify */ 2040 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ 2041 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) 2042 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ 2043 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) 2044 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ 2045 {\ 2046 func_type value = func_value;\ 2047 if (sizeof(target_type) < sizeof(func_type)) {\ 2048 if (unlikely(value != (func_type) (target_type) value)) {\ 2049 func_type zero = 0;\ 2050 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ 2051 return (target_type) -1;\ 2052 if (is_unsigned && unlikely(value < zero))\ 2053 goto raise_neg_overflow;\ 2054 else\ 2055 goto raise_overflow;\ 2056 }\ 2057 }\ 2058 return (target_type) value;\ 2059 } 2060 2061 /* CIntFromPy */ 2062 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { 2063 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; 2064 const int is_unsigned = neg_one > const_zero; 2065 #if PY_MAJOR_VERSION < 3 2066 if (likely(PyInt_Check(x))) { 2067 if (sizeof(long) < sizeof(long)) { 2068 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) 2069 } else { 2070 long val = PyInt_AS_LONG(x); 2071 if (is_unsigned && unlikely(val < 0)) { 2072 goto raise_neg_overflow; 2073 } 2074 return (long) val; 2075 } 2076 } else 2077 #endif 2078 if (likely(PyLong_Check(x))) { 2079 if (is_unsigned) { 2080 #if CYTHON_USE_PYLONG_INTERNALS 2081 const digit* digits = ((PyLongObject*)x)->ob_digit; 2082 switch (Py_SIZE(x)) { 2083 case 0: return (long) 0; 2084 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) 2085 case 2: 2086 if (8 * sizeof(long) > 1 * PyLong_SHIFT) { 2087 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2088 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2089 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { 2090 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); 2091 } 2092 } 2093 break; 2094 case 3: 2095 if (8 * sizeof(long) > 2 * PyLong_SHIFT) { 2096 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2097 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2098 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { 2099 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); 2100 } 2101 } 2102 break; 2103 case 4: 2104 if (8 * sizeof(long) > 3 * PyLong_SHIFT) { 2105 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2106 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2107 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { 2108 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); 2109 } 2110 } 2111 break; 2112 } 2113 #endif 2114 #if CYTHON_COMPILING_IN_CPYTHON 2115 if (unlikely(Py_SIZE(x) < 0)) { 2116 goto raise_neg_overflow; 2117 } 2118 #else 2119 { 2120 int result = PyObject_RichCompareBool(x, Py_False, Py_LT); 2121 if (unlikely(result < 0)) 2122 return (long) -1; 2123 if (unlikely(result == 1)) 2124 goto raise_neg_overflow; 2125 } 2126 #endif 2127 if (sizeof(long) <= sizeof(unsigned long)) { 2128 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) 2129 #ifdef HAVE_LONG_LONG 2130 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { 2131 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) 2132 #endif 2133 } 2134 } else { 2135 #if CYTHON_USE_PYLONG_INTERNALS 2136 const digit* digits = ((PyLongObject*)x)->ob_digit; 2137 switch (Py_SIZE(x)) { 2138 case 0: return (long) 0; 2139 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) 2140 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) 2141 case -2: 2142 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { 2143 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2144 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2145 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { 2146 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2147 } 2148 } 2149 break; 2150 case 2: 2151 if (8 * sizeof(long) > 1 * PyLong_SHIFT) { 2152 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2153 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2154 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { 2155 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2156 } 2157 } 2158 break; 2159 case -3: 2160 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { 2161 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2162 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2163 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { 2164 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2165 } 2166 } 2167 break; 2168 case 3: 2169 if (8 * sizeof(long) > 2 * PyLong_SHIFT) { 2170 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2171 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2172 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { 2173 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2174 } 2175 } 2176 break; 2177 case -4: 2178 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { 2179 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2180 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2181 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { 2182 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2183 } 2184 } 2185 break; 2186 case 4: 2187 if (8 * sizeof(long) > 3 * PyLong_SHIFT) { 2188 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2189 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2190 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { 2191 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); 2192 } 2193 } 2194 break; 2195 } 2196 #endif 2197 if (sizeof(long) <= sizeof(long)) { 2198 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) 2199 #ifdef HAVE_LONG_LONG 2200 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { 2201 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) 2202 #endif 2203 } 2204 } 2205 { 2206 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) 2207 PyErr_SetString(PyExc_RuntimeError, 2208 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); 2209 #else 2210 long val; 2211 PyObject *v = __Pyx_PyNumber_IntOrLong(x); 2212 #if PY_MAJOR_VERSION < 3 2213 if (likely(v) && !PyLong_Check(v)) { 2214 PyObject *tmp = v; 2215 v = PyNumber_Long(tmp); 2216 Py_DECREF(tmp); 2217 } 2218 #endif 2219 if (likely(v)) { 2220 int one = 1; int is_little = (int)*(unsigned char *)&one; 2221 unsigned char *bytes = (unsigned char *)&val; 2222 int ret = _PyLong_AsByteArray((PyLongObject *)v, 2223 bytes, sizeof(val), 2224 is_little, !is_unsigned); 2225 Py_DECREF(v); 2226 if (likely(!ret)) 2227 return val; 2228 } 2229 #endif 2230 return (long) -1; 2231 } 2232 } else { 2233 long val; 2234 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); 2235 if (!tmp) return (long) -1; 2236 val = __Pyx_PyInt_As_long(tmp); 2237 Py_DECREF(tmp); 2238 return val; 2239 } 2240 raise_overflow: 2241 PyErr_SetString(PyExc_OverflowError, 2242 "value too large to convert to long"); 2243 return (long) -1; 2244 raise_neg_overflow: 2245 PyErr_SetString(PyExc_OverflowError, 2246 "can't convert negative value to long"); 2247 return (long) -1; 2248 } 2249 2250 /* CIntFromPy */ 2251 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { 2252 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; 2253 const int is_unsigned = neg_one > const_zero; 2254 #if PY_MAJOR_VERSION < 3 2255 if (likely(PyInt_Check(x))) { 2256 if (sizeof(int) < sizeof(long)) { 2257 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) 2258 } else { 2259 long val = PyInt_AS_LONG(x); 2260 if (is_unsigned && unlikely(val < 0)) { 2261 goto raise_neg_overflow; 2262 } 2263 return (int) val; 2264 } 2265 } else 2266 #endif 2267 if (likely(PyLong_Check(x))) { 2268 if (is_unsigned) { 2269 #if CYTHON_USE_PYLONG_INTERNALS 2270 const digit* digits = ((PyLongObject*)x)->ob_digit; 2271 switch (Py_SIZE(x)) { 2272 case 0: return (int) 0; 2273 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) 2274 case 2: 2275 if (8 * sizeof(int) > 1 * PyLong_SHIFT) { 2276 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2277 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2278 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { 2279 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); 2280 } 2281 } 2282 break; 2283 case 3: 2284 if (8 * sizeof(int) > 2 * PyLong_SHIFT) { 2285 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2286 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2287 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { 2288 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); 2289 } 2290 } 2291 break; 2292 case 4: 2293 if (8 * sizeof(int) > 3 * PyLong_SHIFT) { 2294 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2295 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2296 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { 2297 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); 2298 } 2299 } 2300 break; 2301 } 2302 #endif 2303 #if CYTHON_COMPILING_IN_CPYTHON 2304 if (unlikely(Py_SIZE(x) < 0)) { 2305 goto raise_neg_overflow; 2306 } 2307 #else 2308 { 2309 int result = PyObject_RichCompareBool(x, Py_False, Py_LT); 2310 if (unlikely(result < 0)) 2311 return (int) -1; 2312 if (unlikely(result == 1)) 2313 goto raise_neg_overflow; 2314 } 2315 #endif 2316 if (sizeof(int) <= sizeof(unsigned long)) { 2317 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) 2318 #ifdef HAVE_LONG_LONG 2319 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { 2320 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) 2321 #endif 2322 } 2323 } else { 2324 #if CYTHON_USE_PYLONG_INTERNALS 2325 const digit* digits = ((PyLongObject*)x)->ob_digit; 2326 switch (Py_SIZE(x)) { 2327 case 0: return (int) 0; 2328 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) 2329 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) 2330 case -2: 2331 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { 2332 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2333 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2334 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { 2335 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2336 } 2337 } 2338 break; 2339 case 2: 2340 if (8 * sizeof(int) > 1 * PyLong_SHIFT) { 2341 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { 2342 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2343 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { 2344 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2345 } 2346 } 2347 break; 2348 case -3: 2349 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { 2350 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2351 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2352 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { 2353 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2354 } 2355 } 2356 break; 2357 case 3: 2358 if (8 * sizeof(int) > 2 * PyLong_SHIFT) { 2359 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { 2360 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2361 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { 2362 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2363 } 2364 } 2365 break; 2366 case -4: 2367 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { 2368 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2369 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2370 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { 2371 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2372 } 2373 } 2374 break; 2375 case 4: 2376 if (8 * sizeof(int) > 3 * PyLong_SHIFT) { 2377 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { 2378 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) 2379 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { 2380 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); 2381 } 2382 } 2383 break; 2384 } 2385 #endif 2386 if (sizeof(int) <= sizeof(long)) { 2387 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) 2388 #ifdef HAVE_LONG_LONG 2389 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { 2390 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) 2391 #endif 2392 } 2393 } 2394 { 2395 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) 2396 PyErr_SetString(PyExc_RuntimeError, 2397 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); 2398 #else 2399 int val; 2400 PyObject *v = __Pyx_PyNumber_IntOrLong(x); 2401 #if PY_MAJOR_VERSION < 3 2402 if (likely(v) && !PyLong_Check(v)) { 2403 PyObject *tmp = v; 2404 v = PyNumber_Long(tmp); 2405 Py_DECREF(tmp); 2406 } 2407 #endif 2408 if (likely(v)) { 2409 int one = 1; int is_little = (int)*(unsigned char *)&one; 2410 unsigned char *bytes = (unsigned char *)&val; 2411 int ret = _PyLong_AsByteArray((PyLongObject *)v, 2412 bytes, sizeof(val), 2413 is_little, !is_unsigned); 2414 Py_DECREF(v); 2415 if (likely(!ret)) 2416 return val; 2417 } 2418 #endif 2419 return (int) -1; 2420 } 2421 } else { 2422 int val; 2423 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); 2424 if (!tmp) return (int) -1; 2425 val = __Pyx_PyInt_As_int(tmp); 2426 Py_DECREF(tmp); 2427 return val; 2428 } 2429 raise_overflow: 2430 PyErr_SetString(PyExc_OverflowError, 2431 "value too large to convert to int"); 2432 return (int) -1; 2433 raise_neg_overflow: 2434 PyErr_SetString(PyExc_OverflowError, 2435 "can't convert negative value to int"); 2436 return (int) -1; 2437 } 2438 2439 /* FastTypeChecks */ 2440 #if CYTHON_COMPILING_IN_CPYTHON 2441 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { 2442 while (a) { 2443 a = a->tp_base; 2444 if (a == b) 2445 return 1; 2446 } 2447 return b == &PyBaseObject_Type; 2448 } 2449 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { 2450 PyObject *mro; 2451 if (a == b) return 1; 2452 mro = a->tp_mro; 2453 if (likely(mro)) { 2454 Py_ssize_t i, n; 2455 n = PyTuple_GET_SIZE(mro); 2456 for (i = 0; i < n; i++) { 2457 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) 2458 return 1; 2459 } 2460 return 0; 2461 } 2462 return __Pyx_InBases(a, b); 2463 } 2464 #if PY_MAJOR_VERSION == 2 2465 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { 2466 PyObject *exception, *value, *tb; 2467 int res; 2468 __Pyx_PyThreadState_declare 2469 __Pyx_PyThreadState_assign 2470 __Pyx_ErrFetch(&exception, &value, &tb); 2471 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; 2472 if (unlikely(res == -1)) { 2473 PyErr_WriteUnraisable(err); 2474 res = 0; 2475 } 2476 if (!res) { 2477 res = PyObject_IsSubclass(err, exc_type2); 2478 if (unlikely(res == -1)) { 2479 PyErr_WriteUnraisable(err); 2480 res = 0; 2481 } 2482 } 2483 __Pyx_ErrRestore(exception, value, tb); 2484 return res; 2485 } 2486 #else 2487 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { 2488 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; 2489 if (!res) { 2490 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); 2491 } 2492 return res; 2493 } 2494 #endif 2495 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { 2496 Py_ssize_t i, n; 2497 assert(PyExceptionClass_Check(exc_type)); 2498 n = PyTuple_GET_SIZE(tuple); 2499 #if PY_MAJOR_VERSION >= 3 2500 for (i=0; i<n; i++) { 2501 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; 2502 } 2503 #endif 2504 for (i=0; i<n; i++) { 2505 PyObject *t = PyTuple_GET_ITEM(tuple, i); 2506 #if PY_MAJOR_VERSION < 3 2507 if (likely(exc_type == t)) return 1; 2508 #endif 2509 if (likely(PyExceptionClass_Check(t))) { 2510 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; 2511 } else { 2512 } 2513 } 2514 return 0; 2515 } 2516 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { 2517 if (likely(err == exc_type)) return 1; 2518 if (likely(PyExceptionClass_Check(err))) { 2519 if (likely(PyExceptionClass_Check(exc_type))) { 2520 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); 2521 } else if (likely(PyTuple_Check(exc_type))) { 2522 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); 2523 } else { 2524 } 2525 } 2526 return PyErr_GivenExceptionMatches(err, exc_type); 2527 } 2528 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { 2529 assert(PyExceptionClass_Check(exc_type1)); 2530 assert(PyExceptionClass_Check(exc_type2)); 2531 if (likely(err == exc_type1 || err == exc_type2)) return 1; 2532 if (likely(PyExceptionClass_Check(err))) { 2533 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); 2534 } 2535 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); 2536 } 2537 #endif 2538 2539 /* CheckBinaryVersion */ 2540 static int __Pyx_check_binary_version(void) { 2541 char ctversion[4], rtversion[4]; 2542 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); 2543 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); 2544 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { 2545 char message[200]; 2546 PyOS_snprintf(message, sizeof(message), 2547 "compiletime version %s of module '%.100s' " 2548 "does not match runtime version %s", 2549 ctversion, __Pyx_MODULE_NAME, rtversion); 2550 return PyErr_WarnEx(NULL, message, 1); 2551 } 2552 return 0; 2553 } 2554 2555 /* FunctionExport */ 2556 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { 2557 PyObject *d = 0; 2558 PyObject *cobj = 0; 2559 union { 2560 void (*fp)(void); 2561 void *p; 2562 } tmp; 2563 d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__"); 2564 if (!d) { 2565 PyErr_Clear(); 2566 d = PyDict_New(); 2567 if (!d) 2568 goto bad; 2569 Py_INCREF(d); 2570 if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0) 2571 goto bad; 2572 } 2573 tmp.fp = f; 2574 #if PY_VERSION_HEX >= 0x02070000 2575 cobj = PyCapsule_New(tmp.p, sig, 0); 2576 #else 2577 cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0); 2578 #endif 2579 if (!cobj) 2580 goto bad; 2581 if (PyDict_SetItemString(d, name, cobj) < 0) 2582 goto bad; 2583 Py_DECREF(cobj); 2584 Py_DECREF(d); 2585 return 0; 2586 bad: 2587 Py_XDECREF(cobj); 2588 Py_XDECREF(d); 2589 return -1; 2590 } 2591 2592 /* InitStrings */ 2593 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 2594 while (t->p) { 2595 #if PY_MAJOR_VERSION < 3 2596 if (t->is_unicode) { 2597 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); 2598 } else if (t->intern) { 2599 *t->p = PyString_InternFromString(t->s); 2600 } else { 2601 *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 2602 } 2603 #else 2604 if (t->is_unicode | t->is_str) { 2605 if (t->intern) { 2606 *t->p = PyUnicode_InternFromString(t->s); 2607 } else if (t->encoding) { 2608 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); 2609 } else { 2610 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); 2611 } 2612 } else { 2613 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); 2614 } 2615 #endif 2616 if (!*t->p) 2617 return -1; 2618 if (PyObject_Hash(*t->p) == -1) 2619 return -1; 2620 ++t; 2621 } 2622 return 0; 2623 } 2624 2625 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { 2626 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); 2627 } 2628 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { 2629 Py_ssize_t ignore; 2630 return __Pyx_PyObject_AsStringAndSize(o, &ignore); 2631 } 2632 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 2633 #if !CYTHON_PEP393_ENABLED 2634 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { 2635 char* defenc_c; 2636 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); 2637 if (!defenc) return NULL; 2638 defenc_c = PyBytes_AS_STRING(defenc); 2639 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 2640 { 2641 char* end = defenc_c + PyBytes_GET_SIZE(defenc); 2642 char* c; 2643 for (c = defenc_c; c < end; c++) { 2644 if ((unsigned char) (*c) >= 128) { 2645 PyUnicode_AsASCIIString(o); 2646 return NULL; 2647 } 2648 } 2649 } 2650 #endif 2651 *length = PyBytes_GET_SIZE(defenc); 2652 return defenc_c; 2653 } 2654 #else 2655 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { 2656 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; 2657 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 2658 if (likely(PyUnicode_IS_ASCII(o))) { 2659 *length = PyUnicode_GET_LENGTH(o); 2660 return PyUnicode_AsUTF8(o); 2661 } else { 2662 PyUnicode_AsASCIIString(o); 2663 return NULL; 2664 } 2665 #else 2666 return PyUnicode_AsUTF8AndSize(o, length); 2667 #endif 2668 } 2669 #endif 2670 #endif 2671 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { 2672 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 2673 if ( 2674 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 2675 __Pyx_sys_getdefaultencoding_not_ascii && 2676 #endif 2677 PyUnicode_Check(o)) { 2678 return __Pyx_PyUnicode_AsStringAndSize(o, length); 2679 } else 2680 #endif 2681 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) 2682 if (PyByteArray_Check(o)) { 2683 *length = PyByteArray_GET_SIZE(o); 2684 return PyByteArray_AS_STRING(o); 2685 } else 2686 #endif 2687 { 2688 char* result; 2689 int r = PyBytes_AsStringAndSize(o, &result, length); 2690 if (unlikely(r < 0)) { 2691 return NULL; 2692 } else { 2693 return result; 2694 } 2695 } 2696 } 2697 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { 2698 int is_true = x == Py_True; 2699 if (is_true | (x == Py_False) | (x == Py_None)) return is_true; 2700 else return PyObject_IsTrue(x); 2701 } 2702 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { 2703 int retval; 2704 if (unlikely(!x)) return -1; 2705 retval = __Pyx_PyObject_IsTrue(x); 2706 Py_DECREF(x); 2707 return retval; 2708 } 2709 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { 2710 #if PY_MAJOR_VERSION >= 3 2711 if (PyLong_Check(result)) { 2712 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, 2713 "__int__ returned non-int (type %.200s). " 2714 "The ability to return an instance of a strict subclass of int " 2715 "is deprecated, and may be removed in a future version of Python.", 2716 Py_TYPE(result)->tp_name)) { 2717 Py_DECREF(result); 2718 return NULL; 2719 } 2720 return result; 2721 } 2722 #endif 2723 PyErr_Format(PyExc_TypeError, 2724 "__%.4s__ returned non-%.4s (type %.200s)", 2725 type_name, type_name, Py_TYPE(result)->tp_name); 2726 Py_DECREF(result); 2727 return NULL; 2728 } 2729 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { 2730 #if CYTHON_USE_TYPE_SLOTS 2731 PyNumberMethods *m; 2732 #endif 2733 const char *name = NULL; 2734 PyObject *res = NULL; 2735 #if PY_MAJOR_VERSION < 3 2736 if (likely(PyInt_Check(x) || PyLong_Check(x))) 2737 #else 2738 if (likely(PyLong_Check(x))) 2739 #endif 2740 return __Pyx_NewRef(x); 2741 #if CYTHON_USE_TYPE_SLOTS 2742 m = Py_TYPE(x)->tp_as_number; 2743 #if PY_MAJOR_VERSION < 3 2744 if (m && m->nb_int) { 2745 name = "int"; 2746 res = m->nb_int(x); 2747 } 2748 else if (m && m->nb_long) { 2749 name = "long"; 2750 res = m->nb_long(x); 2751 } 2752 #else 2753 if (likely(m && m->nb_int)) { 2754 name = "int"; 2755 res = m->nb_int(x); 2756 } 2757 #endif 2758 #else 2759 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { 2760 res = PyNumber_Int(x); 2761 } 2762 #endif 2763 if (likely(res)) { 2764 #if PY_MAJOR_VERSION < 3 2765 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { 2766 #else 2767 if (unlikely(!PyLong_CheckExact(res))) { 2768 #endif 2769 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); 2770 } 2771 } 2772 else if (!PyErr_Occurred()) { 2773 PyErr_SetString(PyExc_TypeError, 2774 "an integer is required"); 2775 } 2776 return res; 2777 } 2778 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { 2779 Py_ssize_t ival; 2780 PyObject *x; 2781 #if PY_MAJOR_VERSION < 3 2782 if (likely(PyInt_CheckExact(b))) { 2783 if (sizeof(Py_ssize_t) >= sizeof(long)) 2784 return PyInt_AS_LONG(b); 2785 else 2786 return PyInt_AsSsize_t(b); 2787 } 2788 #endif 2789 if (likely(PyLong_CheckExact(b))) { 2790 #if CYTHON_USE_PYLONG_INTERNALS 2791 const digit* digits = ((PyLongObject*)b)->ob_digit; 2792 const Py_ssize_t size = Py_SIZE(b); 2793 if (likely(__Pyx_sst_abs(size) <= 1)) { 2794 ival = likely(size) ? digits[0] : 0; 2795 if (size == -1) ival = -ival; 2796 return ival; 2797 } else { 2798 switch (size) { 2799 case 2: 2800 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { 2801 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2802 } 2803 break; 2804 case -2: 2805 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { 2806 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2807 } 2808 break; 2809 case 3: 2810 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { 2811 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2812 } 2813 break; 2814 case -3: 2815 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { 2816 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2817 } 2818 break; 2819 case 4: 2820 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { 2821 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2822 } 2823 break; 2824 case -4: 2825 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { 2826 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); 2827 } 2828 break; 2829 } 2830 } 2831 #endif 2832 return PyLong_AsSsize_t(b); 2833 } 2834 x = PyNumber_Index(b); 2835 if (!x) return -1; 2836 ival = PyInt_AsSsize_t(x); 2837 Py_DECREF(x); 2838 return ival; 2839 } 2840 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { 2841 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); 2842 } 2843 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { 2844 return PyInt_FromSize_t(ival); 2845 } 2846 2847 2848 #endif /* Py_PYTHON_H */