Download insightface/thirdparty/face3d/mesh/__init__.cpp from AXERA-TECH/Insightface: direct link, hf CLI and curl.
- Browser
- Download file 113 kB
-
https://huggingface.co/AXERA-TECH/Insightface/resolve/main/insightface/thirdparty/face3d/mesh/__init__.cpp
- Command line
-
hf download hf://AXERA-TECH/Insightface/insightface/thirdparty/face3d/mesh/__init__.cpp
-
curl -L -o __init__.cpp https://huggingface.co/AXERA-TECH/Insightface/resolve/main/insightface/thirdparty/face3d/mesh/__init__.cpp
113 kB
| /* Generated by Cython 0.29.23 */ | |
| /* BEGIN: Cython Metadata | |
| { | |
| "distutils": { | |
| "language": "c++", | |
| "name": "insightface.thirdparty.face3d.mesh.cython.mesh_core_cython", | |
| "sources": [ | |
| "insightface/thirdparty/face3d/morphable_model/__init__.py", | |
| "insightface/thirdparty/face3d/morphable_model/morphabel_model.py", | |
| "insightface/thirdparty/face3d/morphable_model/load.py", | |
| "insightface/thirdparty/face3d/morphable_model/fit.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/vis.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/__init__.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/transform.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/io.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/render.py", | |
| "insightface/thirdparty/face3d/mesh_numpy/light.py", | |
| "insightface/thirdparty/face3d/mesh/vis.py", | |
| "insightface/thirdparty/face3d/mesh/__init__.py", | |
| "insightface/thirdparty/face3d/mesh/transform.py", | |
| "insightface/thirdparty/face3d/mesh/io.py", | |
| "insightface/thirdparty/face3d/mesh/render.py", | |
| "insightface/thirdparty/face3d/mesh/light.py" | |
| ] | |
| }, | |
| "module_name": "insightface.thirdparty.face3d.mesh.cython.mesh_core_cython" | |
| } | |
| END: Cython Metadata */ | |
| enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; | |
| template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } | |
| typedef unsigned char uint8_t; | |
| typedef unsigned int uint32_t; | |
| typedef unsigned __int8 uint8_t; | |
| typedef unsigned __int32 uint32_t; | |
| template<typename T> | |
| void __Pyx_call_destructor(T& x) { | |
| x.~T(); | |
| } | |
| template<typename T> | |
| class __Pyx_FakeReference { | |
| public: | |
| __Pyx_FakeReference() : ptr(NULL) { } | |
| __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { } | |
| T *operator->() { return ptr; } | |
| T *operator&() { return ptr; } | |
| operator T&() { return *ptr; } | |
| template<typename U> bool operator ==(U other) { return *ptr == other; } | |
| template<typename U> bool operator !=(U other) { return *ptr != other; } | |
| private: | |
| T *ptr; | |
| }; | |
| typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); | |
| typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, | |
| Py_ssize_t nargs, PyObject *kwnames); | |
| typedef int Py_tss_t; | |
| static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { | |
| *key = PyThread_create_key(); | |
| return 0; | |
| } | |
| static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { | |
| Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); | |
| *key = Py_tss_NEEDS_INIT; | |
| return key; | |
| } | |
| static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { | |
| PyObject_Free(key); | |
| } | |
| static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { | |
| return *key != Py_tss_NEEDS_INIT; | |
| } | |
| static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { | |
| PyThread_delete_key(*key); | |
| *key = Py_tss_NEEDS_INIT; | |
| } | |
| static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { | |
| return PyThread_set_key_value(*key, value); | |
| } | |
| static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { | |
| return PyThread_get_key_value(*key); | |
| } | |
| typedef long Py_hash_t; | |
| typedef struct { | |
| unaryfunc am_await; | |
| unaryfunc am_aiter; | |
| unaryfunc am_anext; | |
| } __Pyx_PyAsyncMethodsStruct; | |
| static CYTHON_INLINE float __PYX_NAN() { | |
| float value; | |
| memset(&value, 0xFF, sizeof(value)); | |
| return value; | |
| } | |
| /* Early includes */ | |
| typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; | |
| const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; | |
| static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { | |
| return (size_t) i < (size_t) limit; | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); | |
| static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { | |
| const Py_UNICODE *u_end = u; | |
| while (*u_end++) ; | |
| return (size_t)(u_end - u - 1); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); | |
| static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); | |
| static int __Pyx_sys_getdefaultencoding_not_ascii; | |
| static int __Pyx_init_sys_getdefaultencoding_params(void) { | |
| PyObject* sys; | |
| PyObject* default_encoding = NULL; | |
| PyObject* ascii_chars_u = NULL; | |
| PyObject* ascii_chars_b = NULL; | |
| const char* default_encoding_c; | |
| sys = PyImport_ImportModule("sys"); | |
| if (!sys) goto bad; | |
| default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); | |
| Py_DECREF(sys); | |
| if (!default_encoding) goto bad; | |
| default_encoding_c = PyBytes_AsString(default_encoding); | |
| if (!default_encoding_c) goto bad; | |
| if (strcmp(default_encoding_c, "ascii") == 0) { | |
| __Pyx_sys_getdefaultencoding_not_ascii = 0; | |
| } else { | |
| char ascii_chars[128]; | |
| int c; | |
| for (c = 0; c < 128; c++) { | |
| ascii_chars[c] = c; | |
| } | |
| __Pyx_sys_getdefaultencoding_not_ascii = 1; | |
| ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); | |
| if (!ascii_chars_u) goto bad; | |
| ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); | |
| if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { | |
| PyErr_Format( | |
| PyExc_ValueError, | |
| "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", | |
| default_encoding_c); | |
| goto bad; | |
| } | |
| Py_DECREF(ascii_chars_u); | |
| Py_DECREF(ascii_chars_b); | |
| } | |
| Py_DECREF(default_encoding); | |
| return 0; | |
| bad: | |
| Py_XDECREF(default_encoding); | |
| Py_XDECREF(ascii_chars_u); | |
| Py_XDECREF(ascii_chars_b); | |
| return -1; | |
| } | |
| static char* __PYX_DEFAULT_STRING_ENCODING; | |
| static int __Pyx_init_sys_getdefaultencoding_params(void) { | |
| PyObject* sys; | |
| PyObject* default_encoding = NULL; | |
| char* default_encoding_c; | |
| sys = PyImport_ImportModule("sys"); | |
| if (!sys) goto bad; | |
| default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); | |
| Py_DECREF(sys); | |
| if (!default_encoding) goto bad; | |
| default_encoding_c = PyBytes_AsString(default_encoding); | |
| if (!default_encoding_c) goto bad; | |
| __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); | |
| if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; | |
| strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); | |
| Py_DECREF(default_encoding); | |
| return 0; | |
| bad: | |
| Py_XDECREF(default_encoding); | |
| return -1; | |
| } | |
| /* Test for GCC > 2.95 */ | |
| static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } | |
| static PyObject *__pyx_m = NULL; | |
| static PyObject *__pyx_d; | |
| static PyObject *__pyx_b; | |
| static PyObject *__pyx_cython_runtime = NULL; | |
| static PyObject *__pyx_empty_tuple; | |
| static PyObject *__pyx_empty_bytes; | |
| static PyObject *__pyx_empty_unicode; | |
| static int __pyx_lineno; | |
| static int __pyx_clineno = 0; | |
| static const char * __pyx_cfilenm= __FILE__; | |
| static const char *__pyx_filename; | |
| static const char *__pyx_f[] = { | |
| "insightface/thirdparty/face3d/mesh/__init__.py", | |
| }; | |
| /*--- Type declarations ---*/ | |
| /* --- Runtime support code (head) --- */ | |
| /* Refnanny.proto */ | |
| typedef struct { | |
| void (*INCREF)(void*, PyObject*, int); | |
| void (*DECREF)(void*, PyObject*, int); | |
| void (*GOTREF)(void*, PyObject*, int); | |
| void (*GIVEREF)(void*, PyObject*, int); | |
| void* (*SetupContext)(const char*, int, const char*); | |
| void (*FinishContext)(void**); | |
| } __Pyx_RefNannyAPIStruct; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); | |
| /* PyObjectGetAttrStr.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); | |
| /* SetPackagePathFromImportLib.proto */ | |
| static int __Pyx_SetPackagePathFromImportLib(const char* parent_package_name, PyObject *module_name); | |
| /* Import.proto */ | |
| static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); | |
| /* ImportFrom.proto */ | |
| static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); | |
| /* PyDictVersioning.proto */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); | |
| /* PyThreadStateGet.proto */ | |
| /* PyErrFetchRestore.proto */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| /* CLineInTraceback.proto */ | |
| static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); | |
| /* CodeObjectCache.proto */ | |
| typedef struct { | |
| PyCodeObject* code_object; | |
| int code_line; | |
| } __Pyx_CodeObjectCacheEntry; | |
| struct __Pyx_CodeObjectCache { | |
| int count; | |
| int max_count; | |
| __Pyx_CodeObjectCacheEntry* entries; | |
| }; | |
| static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); | |
| static PyCodeObject *__pyx_find_code_object(int code_line); | |
| static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); | |
| /* AddTraceback.proto */ | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename); | |
| /* GCCDiagnostics.proto */ | |
| /* CIntToPy.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); | |
| /* FastTypeChecks.proto */ | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); | |
| /* CheckBinaryVersion.proto */ | |
| static int __Pyx_check_binary_version(void); | |
| /* InitStrings.proto */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); | |
| /* Module declarations from 'face3d.mesh.__init__' */ | |
| extern int __pyx_module_is_main_face3d__mesh____init__; | |
| int __pyx_module_is_main_face3d__mesh____init__ = 0; | |
| /* Implementation of 'face3d.mesh.__init__' */ | |
| static const char __pyx_k_[] = ""; | |
| static const char __pyx_k_io[] = "io"; | |
| static const char __pyx_k_vis[] = "vis"; | |
| static const char __pyx_k_main[] = "__main__"; | |
| static const char __pyx_k_mesh[] = "mesh"; | |
| static const char __pyx_k_name[] = "__name__"; | |
| static const char __pyx_k_test[] = "__test__"; | |
| static const char __pyx_k_light[] = "light"; | |
| static const char __pyx_k_cython[] = "cython"; | |
| static const char __pyx_k_import[] = "__import__"; | |
| static const char __pyx_k_render[] = "render"; | |
| static const char __pyx_k_transform[] = "transform"; | |
| static const char __pyx_k_mesh_core_cython[] = "mesh_core_cython"; | |
| static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; | |
| static PyObject *__pyx_n_s_; | |
| static PyObject *__pyx_n_s_cline_in_traceback; | |
| static PyObject *__pyx_n_s_cython; | |
| static PyObject *__pyx_n_s_import; | |
| static PyObject *__pyx_n_s_io; | |
| static PyObject *__pyx_n_s_light; | |
| static PyObject *__pyx_n_s_main; | |
| static PyObject *__pyx_n_u_mesh; | |
| static PyObject *__pyx_n_s_mesh_core_cython; | |
| static PyObject *__pyx_n_s_name; | |
| static PyObject *__pyx_n_s_render; | |
| static PyObject *__pyx_n_s_test; | |
| static PyObject *__pyx_n_s_transform; | |
| static PyObject *__pyx_n_s_vis; | |
| /* Late includes */ | |
| static PyMethodDef __pyx_methods[] = { | |
| {0, 0, 0, 0} | |
| }; | |
| static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ | |
| static int __pyx_pymod_exec_mesh(PyObject* module); /*proto*/ | |
| static PyModuleDef_Slot __pyx_moduledef_slots[] = { | |
| {Py_mod_create, (void*)__pyx_pymod_create}, | |
| {Py_mod_exec, (void*)__pyx_pymod_exec_mesh}, | |
| {0, NULL} | |
| }; | |
| static struct PyModuleDef __pyx_moduledef = { | |
| PyModuleDef_HEAD_INIT, | |
| "mesh", | |
| 0, /* m_doc */ | |
| 0, /* m_size */ | |
| -1, /* m_size */ | |
| __pyx_methods /* m_methods */, | |
| __pyx_moduledef_slots, /* m_slots */ | |
| NULL, /* m_reload */ | |
| NULL, /* m_traverse */ | |
| NULL, /* m_clear */ | |
| NULL /* m_free */ | |
| }; | |
| static __Pyx_StringTabEntry __pyx_string_tab[] = { | |
| {&__pyx_n_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 1}, | |
| {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, | |
| {&__pyx_n_s_cython, __pyx_k_cython, sizeof(__pyx_k_cython), 0, 0, 1, 1}, | |
| {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, | |
| {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1}, | |
| {&__pyx_n_s_light, __pyx_k_light, sizeof(__pyx_k_light), 0, 0, 1, 1}, | |
| {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, | |
| {&__pyx_n_u_mesh, __pyx_k_mesh, sizeof(__pyx_k_mesh), 0, 1, 0, 1}, | |
| {&__pyx_n_s_mesh_core_cython, __pyx_k_mesh_core_cython, sizeof(__pyx_k_mesh_core_cython), 0, 0, 1, 1}, | |
| {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, | |
| {&__pyx_n_s_render, __pyx_k_render, sizeof(__pyx_k_render), 0, 0, 1, 1}, | |
| {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, | |
| {&__pyx_n_s_transform, __pyx_k_transform, sizeof(__pyx_k_transform), 0, 0, 1, 1}, | |
| {&__pyx_n_s_vis, __pyx_k_vis, sizeof(__pyx_k_vis), 0, 0, 1, 1}, | |
| {0, 0, 0, 0, 0, 0, 0} | |
| }; | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { | |
| return 0; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { | |
| if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ | |
| static int __Pyx_modinit_global_init_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); | |
| /*--- Global init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_export_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); | |
| /*--- Variable export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_export_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); | |
| /*--- Function export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_init_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); | |
| /*--- Type init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); | |
| /*--- Type import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); | |
| /*--- Variable import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); | |
| /*--- Function import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| __Pyx_PyMODINIT_FUNC initmesh(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC initmesh(void) | |
| __Pyx_PyMODINIT_FUNC PyInit_mesh(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC PyInit_mesh(void) | |
| { | |
| return PyModuleDef_Init(&__pyx_moduledef); | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { | |
| static PY_INT64_T main_interpreter_id = -1; | |
| PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); | |
| if (main_interpreter_id == -1) { | |
| main_interpreter_id = current_id; | |
| return (unlikely(current_id == -1)) ? -1 : 0; | |
| } else if (unlikely(main_interpreter_id != current_id)) | |
| static PyInterpreterState *main_interpreter = NULL; | |
| PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; | |
| if (!main_interpreter) { | |
| main_interpreter = current_interpreter; | |
| } else if (unlikely(main_interpreter != current_interpreter)) | |
| { | |
| PyErr_SetString( | |
| PyExc_ImportError, | |
| "Interpreter change detected - this module can only be loaded into one interpreter per process."); | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { | |
| PyObject *value = PyObject_GetAttrString(spec, from_name); | |
| int result = 0; | |
| if (likely(value)) { | |
| if (allow_none || value != Py_None) { | |
| result = PyDict_SetItemString(moddict, to_name, value); | |
| } | |
| Py_DECREF(value); | |
| } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| PyErr_Clear(); | |
| } else { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { | |
| PyObject *module = NULL, *moddict, *modname; | |
| if (__Pyx_check_single_interpreter()) | |
| return NULL; | |
| if (__pyx_m) | |
| return __Pyx_NewRef(__pyx_m); | |
| modname = PyObject_GetAttrString(spec, "name"); | |
| if (unlikely(!modname)) goto bad; | |
| module = PyModule_NewObject(modname); | |
| Py_DECREF(modname); | |
| if (unlikely(!module)) goto bad; | |
| moddict = PyModule_GetDict(module); | |
| if (unlikely(!moddict)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; | |
| return module; | |
| bad: | |
| Py_XDECREF(module); | |
| return NULL; | |
| } | |
| static CYTHON_SMALL_CODE int __pyx_pymod_exec_mesh(PyObject *__pyx_pyinit_module) | |
| { | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannyDeclarations | |
| if (__pyx_m) { | |
| if (__pyx_m == __pyx_pyinit_module) return 0; | |
| PyErr_SetString(PyExc_RuntimeError, "Module 'mesh' has already been imported. Re-initialisation is not supported."); | |
| return -1; | |
| } | |
| if (__pyx_m) return __Pyx_NewRef(__pyx_m); | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); | |
| if (!__Pyx_RefNanny) { | |
| PyErr_Clear(); | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); | |
| if (!__Pyx_RefNanny) | |
| Py_FatalError("failed to import 'refnanny' module"); | |
| } | |
| __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_mesh(void)", 0); | |
| if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pxy_PyFrame_Initialize_Offsets(); | |
| __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Library function declarations ---*/ | |
| /*--- Threads initialization code ---*/ | |
| PyEval_InitThreads(); | |
| /*--- Module creation code ---*/ | |
| __pyx_m = __pyx_pyinit_module; | |
| Py_INCREF(__pyx_m); | |
| __pyx_m = Py_InitModule4("mesh", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); | |
| __pyx_m = PyModule_Create(&__pyx_moduledef); | |
| if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_d); | |
| __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_b); | |
| __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_cython_runtime); | |
| if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); | |
| /*--- Initialize various global constants etc. ---*/ | |
| if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_module_is_main_face3d__mesh____init__) { | |
| if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| if (!CYTHON_PEP489_MULTI_PHASE_INIT) { | |
| if (unlikely(__Pyx_SetPackagePathFromImportLib("face3d", __pyx_n_u_mesh) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| { | |
| PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (!PyDict_GetItemString(modules, "face3d.mesh")) { | |
| if (unlikely(PyDict_SetItemString(modules, "face3d.mesh", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| } | |
| /*--- Builtin init code ---*/ | |
| if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Constants init code ---*/ | |
| if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Global type/function init code ---*/ | |
| (void)__Pyx_modinit_global_init_code(); | |
| (void)__Pyx_modinit_variable_export_code(); | |
| (void)__Pyx_modinit_function_export_code(); | |
| (void)__Pyx_modinit_type_init_code(); | |
| (void)__Pyx_modinit_type_import_code(); | |
| (void)__Pyx_modinit_variable_import_code(); | |
| (void)__Pyx_modinit_function_import_code(); | |
| /*--- Execution code ---*/ | |
| if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /* "face3d/mesh/__init__.py":9 | |
| * #import render | |
| * | |
| * from .cython import mesh_core_cython # <<<<<<<<<<<<<< | |
| * from . import io | |
| * from . import vis | |
| */ | |
| __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_INCREF(__pyx_n_s_mesh_core_cython); | |
| __Pyx_GIVEREF(__pyx_n_s_mesh_core_cython); | |
| PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_mesh_core_cython); | |
| __pyx_t_2 = __Pyx_Import(__pyx_n_s_cython, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_mesh_core_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_mesh_core_cython, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| /* "face3d/mesh/__init__.py":10 | |
| * | |
| * from .cython import mesh_core_cython | |
| * from . import io # <<<<<<<<<<<<<< | |
| * from . import vis | |
| * from . import transform | |
| */ | |
| __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_n_s_io); | |
| __Pyx_GIVEREF(__pyx_n_s_io); | |
| PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_io); | |
| __pyx_t_1 = __Pyx_Import(__pyx_n_s_, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_io, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| /* "face3d/mesh/__init__.py":11 | |
| * from .cython import mesh_core_cython | |
| * from . import io | |
| * from . import vis # <<<<<<<<<<<<<< | |
| * from . import transform | |
| * from . import light | |
| */ | |
| __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_INCREF(__pyx_n_s_vis); | |
| __Pyx_GIVEREF(__pyx_n_s_vis); | |
| PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_vis); | |
| __pyx_t_2 = __Pyx_Import(__pyx_n_s_, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_vis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_vis, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| /* "face3d/mesh/__init__.py":12 | |
| * from . import io | |
| * from . import vis | |
| * from . import transform # <<<<<<<<<<<<<< | |
| * from . import light | |
| * from . import render | |
| */ | |
| __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_n_s_transform); | |
| __Pyx_GIVEREF(__pyx_n_s_transform); | |
| PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_transform); | |
| __pyx_t_1 = __Pyx_Import(__pyx_n_s_, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_transform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_transform, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| /* "face3d/mesh/__init__.py":13 | |
| * from . import vis | |
| * from . import transform | |
| * from . import light # <<<<<<<<<<<<<< | |
| * from . import render | |
| * | |
| */ | |
| __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_INCREF(__pyx_n_s_light); | |
| __Pyx_GIVEREF(__pyx_n_s_light); | |
| PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_light); | |
| __pyx_t_2 = __Pyx_Import(__pyx_n_s_, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_light); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_light, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| /* "face3d/mesh/__init__.py":14 | |
| * from . import transform | |
| * from . import light | |
| * from . import render # <<<<<<<<<<<<<< | |
| * | |
| */ | |
| __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_n_s_render); | |
| __Pyx_GIVEREF(__pyx_n_s_render); | |
| PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_render); | |
| __pyx_t_1 = __Pyx_Import(__pyx_n_s_, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_render); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_render, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| /* "face3d/mesh/__init__.py":1 | |
| * #from __future__ import absolute_import # <<<<<<<<<<<<<< | |
| * #from cython import mesh_core_cython | |
| * #import io | |
| */ | |
| __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| /*--- Wrapped vars code ---*/ | |
| goto __pyx_L0; | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_2); | |
| if (__pyx_m) { | |
| if (__pyx_d) { | |
| __Pyx_AddTraceback("init face3d.mesh.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| } | |
| Py_CLEAR(__pyx_m); | |
| } else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_ImportError, "init face3d.mesh.__init__"); | |
| } | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return (__pyx_m != NULL) ? 0 : -1; | |
| return __pyx_m; | |
| return; | |
| } | |
| /* --- Runtime support code --- */ | |
| /* Refnanny */ | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { | |
| PyObject *m = NULL, *p = NULL; | |
| void *r = NULL; | |
| m = PyImport_ImportModule(modname); | |
| if (!m) goto end; | |
| p = PyObject_GetAttrString(m, "RefNannyAPI"); | |
| if (!p) goto end; | |
| r = PyLong_AsVoidPtr(p); | |
| end: | |
| Py_XDECREF(p); | |
| Py_XDECREF(m); | |
| return (__Pyx_RefNannyAPIStruct *)r; | |
| } | |
| /* PyObjectGetAttrStr */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { | |
| PyTypeObject* tp = Py_TYPE(obj); | |
| if (likely(tp->tp_getattro)) | |
| return tp->tp_getattro(obj, attr_name); | |
| if (likely(tp->tp_getattr)) | |
| return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); | |
| return PyObject_GetAttr(obj, attr_name); | |
| } | |
| /* SetPackagePathFromImportLib */ | |
| static int __Pyx_SetPackagePathFromImportLib(const char* parent_package_name, PyObject *module_name) { | |
| PyObject *importlib, *loader, *osmod, *ossep, *parts, *package_path; | |
| PyObject *path = NULL, *file_path = NULL; | |
| int result; | |
| if (parent_package_name) { | |
| PyObject *package = PyImport_ImportModule(parent_package_name); | |
| if (unlikely(!package)) | |
| goto bad; | |
| path = PyObject_GetAttrString(package, "__path__"); | |
| Py_DECREF(package); | |
| if (unlikely(!path) || unlikely(path == Py_None)) | |
| goto bad; | |
| } else { | |
| path = Py_None; Py_INCREF(Py_None); | |
| } | |
| importlib = PyImport_ImportModule("importlib"); | |
| if (unlikely(!importlib)) | |
| goto bad; | |
| loader = PyObject_CallMethod(importlib, "find_loader", "(OO)", module_name, path); | |
| Py_DECREF(importlib); | |
| Py_DECREF(path); path = NULL; | |
| if (unlikely(!loader)) | |
| goto bad; | |
| file_path = PyObject_GetAttrString(loader, "path"); | |
| Py_DECREF(loader); | |
| if (unlikely(!file_path)) | |
| goto bad; | |
| if (unlikely(PyObject_SetAttrString(__pyx_m, "__file__", file_path) < 0)) | |
| goto bad; | |
| osmod = PyImport_ImportModule("os"); | |
| if (unlikely(!osmod)) | |
| goto bad; | |
| ossep = PyObject_GetAttrString(osmod, "sep"); | |
| Py_DECREF(osmod); | |
| if (unlikely(!ossep)) | |
| goto bad; | |
| parts = PyObject_CallMethod(file_path, "rsplit", "(Oi)", ossep, 1); | |
| Py_DECREF(file_path); file_path = NULL; | |
| Py_DECREF(ossep); | |
| if (unlikely(!parts)) | |
| goto bad; | |
| package_path = Py_BuildValue("[O]", PyList_GET_ITEM(parts, 0)); | |
| Py_DECREF(parts); | |
| if (unlikely(!package_path)) | |
| goto bad; | |
| goto set_path; | |
| bad: | |
| PyErr_WriteUnraisable(module_name); | |
| Py_XDECREF(path); | |
| Py_XDECREF(file_path); | |
| PyErr_Clear(); | |
| package_path = PyList_New(0); | |
| if (unlikely(!package_path)) | |
| return -1; | |
| set_path: | |
| result = PyObject_SetAttrString(__pyx_m, "__path__", package_path); | |
| Py_DECREF(package_path); | |
| return result; | |
| } | |
| /* Import */ | |
| static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { | |
| PyObject *empty_list = 0; | |
| PyObject *module = 0; | |
| PyObject *global_dict = 0; | |
| PyObject *empty_dict = 0; | |
| PyObject *list; | |
| PyObject *py_import; | |
| py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); | |
| if (!py_import) | |
| goto bad; | |
| if (from_list) | |
| list = from_list; | |
| else { | |
| empty_list = PyList_New(0); | |
| if (!empty_list) | |
| goto bad; | |
| list = empty_list; | |
| } | |
| global_dict = PyModule_GetDict(__pyx_m); | |
| if (!global_dict) | |
| goto bad; | |
| empty_dict = PyDict_New(); | |
| if (!empty_dict) | |
| goto bad; | |
| { | |
| if (level == -1) { | |
| if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { | |
| module = PyImport_ImportModuleLevelObject( | |
| name, global_dict, empty_dict, list, 1); | |
| if (!module) { | |
| if (!PyErr_ExceptionMatches(PyExc_ImportError)) | |
| goto bad; | |
| PyErr_Clear(); | |
| } | |
| } | |
| level = 0; | |
| } | |
| if (!module) { | |
| PyObject *py_level = PyInt_FromLong(level); | |
| if (!py_level) | |
| goto bad; | |
| module = PyObject_CallFunctionObjArgs(py_import, | |
| name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); | |
| Py_DECREF(py_level); | |
| module = PyImport_ImportModuleLevelObject( | |
| name, global_dict, empty_dict, list, level); | |
| } | |
| } | |
| bad: | |
| Py_XDECREF(py_import); | |
| Py_XDECREF(empty_list); | |
| Py_XDECREF(empty_dict); | |
| return module; | |
| } | |
| /* ImportFrom */ | |
| static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { | |
| PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); | |
| if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| PyErr_Format(PyExc_ImportError, | |
| "cannot import name %.230s", PyString_AS_STRING(name)); | |
| "cannot import name %S", name); | |
| } | |
| return value; | |
| } | |
| /* PyDictVersioning */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; | |
| } | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { | |
| PyObject **dictptr = NULL; | |
| Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; | |
| if (offset) { | |
| dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); | |
| dictptr = _PyObject_GetDictPtr(obj); | |
| } | |
| return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) | |
| return 0; | |
| return obj_dict_version == __Pyx_get_object_dict_version(obj); | |
| } | |
| /* PyErrFetchRestore */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| tmp_type = tstate->curexc_type; | |
| tmp_value = tstate->curexc_value; | |
| tmp_tb = tstate->curexc_traceback; | |
| tstate->curexc_type = type; | |
| tstate->curexc_value = value; | |
| tstate->curexc_traceback = tb; | |
| Py_XDECREF(tmp_type); | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(tmp_tb); | |
| } | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { | |
| *type = tstate->curexc_type; | |
| *value = tstate->curexc_value; | |
| *tb = tstate->curexc_traceback; | |
| tstate->curexc_type = 0; | |
| tstate->curexc_value = 0; | |
| tstate->curexc_traceback = 0; | |
| } | |
| /* CLineInTraceback */ | |
| static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { | |
| PyObject *use_cline; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| PyObject **cython_runtime_dict; | |
| if (unlikely(!__pyx_cython_runtime)) { | |
| return c_line; | |
| } | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); | |
| if (likely(cython_runtime_dict)) { | |
| __PYX_PY_DICT_LOOKUP_IF_MODIFIED( | |
| use_cline, *cython_runtime_dict, | |
| __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) | |
| } else | |
| { | |
| PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); | |
| if (use_cline_obj) { | |
| use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; | |
| Py_DECREF(use_cline_obj); | |
| } else { | |
| PyErr_Clear(); | |
| use_cline = NULL; | |
| } | |
| } | |
| if (!use_cline) { | |
| c_line = 0; | |
| PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); | |
| } | |
| else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { | |
| c_line = 0; | |
| } | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| return c_line; | |
| } | |
| /* CodeObjectCache */ | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { | |
| int start = 0, mid = 0, end = count - 1; | |
| if (end >= 0 && code_line > entries[end].code_line) { | |
| return count; | |
| } | |
| while (start < end) { | |
| mid = start + (end - start) / 2; | |
| if (code_line < entries[mid].code_line) { | |
| end = mid; | |
| } else if (code_line > entries[mid].code_line) { | |
| start = mid + 1; | |
| } else { | |
| return mid; | |
| } | |
| } | |
| if (code_line <= entries[mid].code_line) { | |
| return mid; | |
| } else { | |
| return mid + 1; | |
| } | |
| } | |
| static PyCodeObject *__pyx_find_code_object(int code_line) { | |
| PyCodeObject* code_object; | |
| int pos; | |
| if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { | |
| return NULL; | |
| } | |
| pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); | |
| if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { | |
| return NULL; | |
| } | |
| code_object = __pyx_code_cache.entries[pos].code_object; | |
| Py_INCREF(code_object); | |
| return code_object; | |
| } | |
| static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { | |
| int pos, i; | |
| __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; | |
| if (unlikely(!code_line)) { | |
| return; | |
| } | |
| if (unlikely(!entries)) { | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (likely(entries)) { | |
| __pyx_code_cache.entries = entries; | |
| __pyx_code_cache.max_count = 64; | |
| __pyx_code_cache.count = 1; | |
| entries[0].code_line = code_line; | |
| entries[0].code_object = code_object; | |
| Py_INCREF(code_object); | |
| } | |
| return; | |
| } | |
| pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); | |
| if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { | |
| PyCodeObject* tmp = entries[pos].code_object; | |
| entries[pos].code_object = code_object; | |
| Py_DECREF(tmp); | |
| return; | |
| } | |
| if (__pyx_code_cache.count == __pyx_code_cache.max_count) { | |
| int new_max = __pyx_code_cache.max_count + 64; | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( | |
| __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (unlikely(!entries)) { | |
| return; | |
| } | |
| __pyx_code_cache.entries = entries; | |
| __pyx_code_cache.max_count = new_max; | |
| } | |
| for (i=__pyx_code_cache.count; i>pos; i--) { | |
| entries[i] = entries[i-1]; | |
| } | |
| entries[pos].code_line = code_line; | |
| entries[pos].code_object = code_object; | |
| __pyx_code_cache.count++; | |
| Py_INCREF(code_object); | |
| } | |
| /* AddTraceback */ | |
| static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( | |
| const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = 0; | |
| PyObject *py_srcfile = 0; | |
| PyObject *py_funcname = 0; | |
| py_srcfile = PyString_FromString(filename); | |
| py_srcfile = PyUnicode_FromString(filename); | |
| if (!py_srcfile) goto bad; | |
| if (c_line) { | |
| py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| } | |
| else { | |
| py_funcname = PyString_FromString(funcname); | |
| py_funcname = PyUnicode_FromString(funcname); | |
| } | |
| if (!py_funcname) goto bad; | |
| py_code = __Pyx_PyCode_New( | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| __pyx_empty_bytes, /*PyObject *code,*/ | |
| __pyx_empty_tuple, /*PyObject *consts,*/ | |
| __pyx_empty_tuple, /*PyObject *names,*/ | |
| __pyx_empty_tuple, /*PyObject *varnames,*/ | |
| __pyx_empty_tuple, /*PyObject *freevars,*/ | |
| __pyx_empty_tuple, /*PyObject *cellvars,*/ | |
| py_srcfile, /*PyObject *filename,*/ | |
| py_funcname, /*PyObject *name,*/ | |
| py_line, | |
| __pyx_empty_bytes /*PyObject *lnotab*/ | |
| ); | |
| Py_DECREF(py_srcfile); | |
| Py_DECREF(py_funcname); | |
| return py_code; | |
| bad: | |
| Py_XDECREF(py_srcfile); | |
| Py_XDECREF(py_funcname); | |
| return NULL; | |
| } | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = 0; | |
| PyFrameObject *py_frame = 0; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| if (c_line) { | |
| c_line = __Pyx_CLineForTraceback(tstate, c_line); | |
| } | |
| py_code = __pyx_find_code_object(c_line ? -c_line : py_line); | |
| if (!py_code) { | |
| py_code = __Pyx_CreateCodeObjectForTraceback( | |
| funcname, c_line, py_line, filename); | |
| if (!py_code) goto bad; | |
| __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); | |
| } | |
| py_frame = PyFrame_New( | |
| tstate, /*PyThreadState *tstate,*/ | |
| py_code, /*PyCodeObject *code,*/ | |
| __pyx_d, /*PyObject *globals,*/ | |
| 0 /*PyObject *locals*/ | |
| ); | |
| if (!py_frame) goto bad; | |
| __Pyx_PyFrame_SetLineNumber(py_frame, py_line); | |
| PyTraceBack_Here(py_frame); | |
| bad: | |
| Py_XDECREF(py_code); | |
| Py_XDECREF(py_frame); | |
| } | |
| /* CIntToPy */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (is_unsigned) { | |
| if (sizeof(long) < sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned long)) { | |
| return PyLong_FromUnsignedLong((unsigned long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { | |
| return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); | |
| } | |
| } else { | |
| if (sizeof(long) <= sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { | |
| return PyLong_FromLongLong((PY_LONG_LONG) value); | |
| } | |
| } | |
| { | |
| int one = 1; int little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&value; | |
| return _PyLong_FromByteArray(bytes, sizeof(long), | |
| little, !is_unsigned); | |
| } | |
| } | |
| /* CIntFromPyVerify */ | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (likely(PyInt_Check(x))) { | |
| if (sizeof(long) < sizeof(long)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) | |
| } else { | |
| long val = PyInt_AS_LONG(x); | |
| if (is_unsigned && unlikely(val < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| return (long) val; | |
| } | |
| } else | |
| if (likely(PyLong_Check(x))) { | |
| if (is_unsigned) { | |
| const digit* digits = ((PyLongObject*)x)->ob_digit; | |
| switch (Py_SIZE(x)) { | |
| case 0: return (long) 0; | |
| case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) | |
| case 2: | |
| if (8 * sizeof(long) > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { | |
| return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(long) > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { | |
| return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(long) > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { | |
| return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (long) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if (sizeof(long) <= sizeof(unsigned long)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| const digit* digits = ((PyLongObject*)x)->ob_digit; | |
| switch (Py_SIZE(x)) { | |
| case 0: return (long) 0; | |
| case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) | |
| case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) | |
| case -2: | |
| if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { | |
| return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if (8 * sizeof(long) > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { | |
| return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { | |
| return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(long) > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { | |
| return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { | |
| return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(long) > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { | |
| return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| if (sizeof(long) <= sizeof(long)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) | |
| } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| PyErr_SetString(PyExc_RuntimeError, | |
| "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); | |
| long val; | |
| PyObject *v = __Pyx_PyNumber_IntOrLong(x); | |
| if (likely(v) && !PyLong_Check(v)) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(tmp); | |
| Py_DECREF(tmp); | |
| } | |
| if (likely(v)) { | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| int ret = _PyLong_AsByteArray((PyLongObject *)v, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| Py_DECREF(v); | |
| if (likely(!ret)) | |
| return val; | |
| } | |
| return (long) -1; | |
| } | |
| } else { | |
| long val; | |
| PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); | |
| if (!tmp) return (long) -1; | |
| val = __Pyx_PyInt_As_long(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to long"); | |
| return (long) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to long"); | |
| return (long) -1; | |
| } | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { | |
| const int neg_one = (int) -1, const_zero = (int) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (likely(PyInt_Check(x))) { | |
| if (sizeof(int) < sizeof(long)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) | |
| } else { | |
| long val = PyInt_AS_LONG(x); | |
| if (is_unsigned && unlikely(val < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| return (int) val; | |
| } | |
| } else | |
| if (likely(PyLong_Check(x))) { | |
| if (is_unsigned) { | |
| const digit* digits = ((PyLongObject*)x)->ob_digit; | |
| switch (Py_SIZE(x)) { | |
| case 0: return (int) 0; | |
| case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) | |
| case 2: | |
| if (8 * sizeof(int) > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { | |
| return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(int) > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { | |
| return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(int) > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { | |
| return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (int) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if (sizeof(int) <= sizeof(unsigned long)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| const digit* digits = ((PyLongObject*)x)->ob_digit; | |
| switch (Py_SIZE(x)) { | |
| case 0: return (int) 0; | |
| case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) | |
| case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) | |
| case -2: | |
| if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { | |
| return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if (8 * sizeof(int) > 1 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { | |
| return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { | |
| return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(int) > 2 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { | |
| return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { | |
| return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(int) > 3 * PyLong_SHIFT) { | |
| if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { | |
| __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]))) | |
| } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { | |
| return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| if (sizeof(int) <= sizeof(long)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) | |
| } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| PyErr_SetString(PyExc_RuntimeError, | |
| "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); | |
| int val; | |
| PyObject *v = __Pyx_PyNumber_IntOrLong(x); | |
| if (likely(v) && !PyLong_Check(v)) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(tmp); | |
| Py_DECREF(tmp); | |
| } | |
| if (likely(v)) { | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| int ret = _PyLong_AsByteArray((PyLongObject *)v, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| Py_DECREF(v); | |
| if (likely(!ret)) | |
| return val; | |
| } | |
| return (int) -1; | |
| } | |
| } else { | |
| int val; | |
| PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); | |
| if (!tmp) return (int) -1; | |
| val = __Pyx_PyInt_As_int(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to int"); | |
| return (int) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to int"); | |
| return (int) -1; | |
| } | |
| /* FastTypeChecks */ | |
| static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { | |
| while (a) { | |
| a = a->tp_base; | |
| if (a == b) | |
| return 1; | |
| } | |
| return b == &PyBaseObject_Type; | |
| } | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { | |
| PyObject *mro; | |
| if (a == b) return 1; | |
| mro = a->tp_mro; | |
| if (likely(mro)) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(mro); | |
| for (i = 0; i < n; i++) { | |
| if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| return __Pyx_InBases(a, b); | |
| } | |
| static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { | |
| PyObject *exception, *value, *tb; | |
| int res; | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ErrFetch(&exception, &value, &tb); | |
| res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; | |
| if (unlikely(res == -1)) { | |
| PyErr_WriteUnraisable(err); | |
| res = 0; | |
| } | |
| if (!res) { | |
| res = PyObject_IsSubclass(err, exc_type2); | |
| if (unlikely(res == -1)) { | |
| PyErr_WriteUnraisable(err); | |
| res = 0; | |
| } | |
| } | |
| __Pyx_ErrRestore(exception, value, tb); | |
| return res; | |
| } | |
| static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { | |
| int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; | |
| if (!res) { | |
| res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); | |
| } | |
| return res; | |
| } | |
| static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| assert(PyExceptionClass_Check(exc_type)); | |
| n = PyTuple_GET_SIZE(tuple); | |
| for (i=0; i<n; i++) { | |
| if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; | |
| } | |
| for (i=0; i<n; i++) { | |
| PyObject *t = PyTuple_GET_ITEM(tuple, i); | |
| if (likely(exc_type == t)) return 1; | |
| if (likely(PyExceptionClass_Check(t))) { | |
| if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; | |
| } else { | |
| } | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { | |
| if (likely(err == exc_type)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| if (likely(PyExceptionClass_Check(exc_type))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); | |
| } else if (likely(PyTuple_Check(exc_type))) { | |
| return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); | |
| } else { | |
| } | |
| } | |
| return PyErr_GivenExceptionMatches(err, exc_type); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { | |
| assert(PyExceptionClass_Check(exc_type1)); | |
| assert(PyExceptionClass_Check(exc_type2)); | |
| if (likely(err == exc_type1 || err == exc_type2)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); | |
| } | |
| return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); | |
| } | |
| /* CheckBinaryVersion */ | |
| static int __Pyx_check_binary_version(void) { | |
| char ctversion[4], rtversion[4]; | |
| PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); | |
| PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); | |
| if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { | |
| char message[200]; | |
| PyOS_snprintf(message, sizeof(message), | |
| "compiletime version %s of module '%.100s' " | |
| "does not match runtime version %s", | |
| ctversion, __Pyx_MODULE_NAME, rtversion); | |
| return PyErr_WarnEx(NULL, message, 1); | |
| } | |
| return 0; | |
| } | |
| /* InitStrings */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { | |
| while (t->p) { | |
| if (t->is_unicode) { | |
| *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); | |
| } else if (t->intern) { | |
| *t->p = PyString_InternFromString(t->s); | |
| } else { | |
| *t->p = PyString_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| if (t->is_unicode | t->is_str) { | |
| if (t->intern) { | |
| *t->p = PyUnicode_InternFromString(t->s); | |
| } else if (t->encoding) { | |
| *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); | |
| } else { | |
| *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| } else { | |
| *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| if (!*t->p) | |
| return -1; | |
| if (PyObject_Hash(*t->p) == -1) | |
| return -1; | |
| ++t; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { | |
| return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { | |
| Py_ssize_t ignore; | |
| return __Pyx_PyObject_AsStringAndSize(o, &ignore); | |
| } | |
| static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| char* defenc_c; | |
| PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); | |
| if (!defenc) return NULL; | |
| defenc_c = PyBytes_AS_STRING(defenc); | |
| { | |
| char* end = defenc_c + PyBytes_GET_SIZE(defenc); | |
| char* c; | |
| for (c = defenc_c; c < end; c++) { | |
| if ((unsigned char) (*c) >= 128) { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| } | |
| } | |
| *length = PyBytes_GET_SIZE(defenc); | |
| return defenc_c; | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; | |
| if (likely(PyUnicode_IS_ASCII(o))) { | |
| *length = PyUnicode_GET_LENGTH(o); | |
| return PyUnicode_AsUTF8(o); | |
| } else { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| return PyUnicode_AsUTF8AndSize(o, length); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if ( | |
| __Pyx_sys_getdefaultencoding_not_ascii && | |
| PyUnicode_Check(o)) { | |
| return __Pyx_PyUnicode_AsStringAndSize(o, length); | |
| } else | |
| if (PyByteArray_Check(o)) { | |
| *length = PyByteArray_GET_SIZE(o); | |
| return PyByteArray_AS_STRING(o); | |
| } else | |
| { | |
| char* result; | |
| int r = PyBytes_AsStringAndSize(o, &result, length); | |
| if (unlikely(r < 0)) { | |
| return NULL; | |
| } else { | |
| return result; | |
| } | |
| } | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { | |
| int is_true = x == Py_True; | |
| if (is_true | (x == Py_False) | (x == Py_None)) return is_true; | |
| else return PyObject_IsTrue(x); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { | |
| int retval; | |
| if (unlikely(!x)) return -1; | |
| retval = __Pyx_PyObject_IsTrue(x); | |
| Py_DECREF(x); | |
| return retval; | |
| } | |
| static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { | |
| if (PyLong_Check(result)) { | |
| if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, | |
| "__int__ returned non-int (type %.200s). " | |
| "The ability to return an instance of a strict subclass of int " | |
| "is deprecated, and may be removed in a future version of Python.", | |
| Py_TYPE(result)->tp_name)) { | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| return result; | |
| } | |
| PyErr_Format(PyExc_TypeError, | |
| "__%.4s__ returned non-%.4s (type %.200s)", | |
| type_name, type_name, Py_TYPE(result)->tp_name); | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { | |
| PyNumberMethods *m; | |
| const char *name = NULL; | |
| PyObject *res = NULL; | |
| if (likely(PyInt_Check(x) || PyLong_Check(x))) | |
| if (likely(PyLong_Check(x))) | |
| return __Pyx_NewRef(x); | |
| m = Py_TYPE(x)->tp_as_number; | |
| if (m && m->nb_int) { | |
| name = "int"; | |
| res = m->nb_int(x); | |
| } | |
| else if (m && m->nb_long) { | |
| name = "long"; | |
| res = m->nb_long(x); | |
| } | |
| if (likely(m && m->nb_int)) { | |
| name = "int"; | |
| res = m->nb_int(x); | |
| } | |
| if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { | |
| res = PyNumber_Int(x); | |
| } | |
| if (likely(res)) { | |
| if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { | |
| if (unlikely(!PyLong_CheckExact(res))) { | |
| return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); | |
| } | |
| } | |
| else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "an integer is required"); | |
| } | |
| return res; | |
| } | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| if (likely(PyInt_CheckExact(b))) { | |
| if (sizeof(Py_ssize_t) >= sizeof(long)) | |
| return PyInt_AS_LONG(b); | |
| else | |
| return PyInt_AsSsize_t(b); | |
| } | |
| if (likely(PyLong_CheckExact(b))) { | |
| const digit* digits = ((PyLongObject*)b)->ob_digit; | |
| const Py_ssize_t size = Py_SIZE(b); | |
| if (likely(__Pyx_sst_abs(size) <= 1)) { | |
| ival = likely(size) ? digits[0] : 0; | |
| if (size == -1) ival = -ival; | |
| return ival; | |
| } else { | |
| switch (size) { | |
| case 2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| 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])); | |
| } | |
| break; | |
| case -4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| 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])); | |
| } | |
| break; | |
| } | |
| } | |
| return PyLong_AsSsize_t(b); | |
| } | |
| x = PyNumber_Index(b); | |
| if (!x) return -1; | |
| ival = PyInt_AsSsize_t(x); | |
| Py_DECREF(x); | |
| return ival; | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { | |
| return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { | |
| return PyInt_FromSize_t(ival); | |
| } | |