Spaces:
Runtime error
Runtime error
Download cmsgpt/lib/python3.8/site-packages/fontTools/cu2qu/cu2qu.c from AnshulKapoor/ChatCMS: direct link, hf CLI and curl.
- Browser
- Download file 449 kB
-
https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fontTools/cu2qu/cu2qu.c
- Command line
-
hf download hf://spaces/AnshulKapoor/ChatCMS/cmsgpt/lib/python3.8/site-packages/fontTools/cu2qu/cu2qu.c
-
curl -L -o cu2qu.c https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fontTools/cu2qu/cu2qu.c
449 kB
| /* Generated by Cython 0.29.35 */ | |
| /* BEGIN: Cython Metadata | |
| { | |
| "distutils": { | |
| "define_macros": [ | |
| [ | |
| "CYTHON_TRACE_NOGIL", | |
| "1" | |
| ] | |
| ], | |
| "name": "fontTools.cu2qu.cu2qu", | |
| "sources": [ | |
| "Lib/fontTools/cu2qu/cu2qu.py" | |
| ] | |
| }, | |
| "module_name": "fontTools.cu2qu.cu2qu" | |
| } | |
| 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; | |
| static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, | |
| PyObject *code, PyObject *c, PyObject* n, PyObject *v, | |
| PyObject *fv, PyObject *cell, PyObject* fn, | |
| PyObject *name, int fline, PyObject *lnos) { | |
| PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; | |
| PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; | |
| const char *fn_cstr=NULL; | |
| const char *name_cstr=NULL; | |
| PyCodeObject* co=NULL; | |
| PyObject *type, *value, *traceback; | |
| PyErr_Fetch(&type, &value, &traceback); | |
| if (!(kwds=PyDict_New())) goto end; | |
| if (!(argcount=PyLong_FromLong(a))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; | |
| if (!(posonlyargcount=PyLong_FromLong(0))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; | |
| if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; | |
| if (!(nlocals=PyLong_FromLong(l))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; | |
| if (!(stacksize=PyLong_FromLong(s))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; | |
| if (!(flags=PyLong_FromLong(f))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; | |
| if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; | |
| if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; | |
| if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; | |
| if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; | |
| if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here | |
| if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; | |
| Py_XDECREF((PyObject*)co); | |
| co = (PyCodeObject*)call_result; | |
| call_result = NULL; | |
| if (0) { | |
| cleanup_code_too: | |
| Py_XDECREF((PyObject*)co); | |
| co = NULL; | |
| } | |
| end: | |
| Py_XDECREF(kwds); | |
| Py_XDECREF(argcount); | |
| Py_XDECREF(posonlyargcount); | |
| Py_XDECREF(kwonlyargcount); | |
| Py_XDECREF(nlocals); | |
| Py_XDECREF(stacksize); | |
| Py_XDECREF(replace); | |
| Py_XDECREF(call_result); | |
| Py_XDECREF(empty); | |
| if (type) { | |
| PyErr_Restore(type, value, traceback); | |
| } | |
| return co; | |
| } | |
| 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 CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); | |
| 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; | |
| /* Header.proto */ | |
| static const char *__pyx_f[] = { | |
| "Lib/fontTools/cu2qu/cu2qu.py", | |
| }; | |
| /* Declarations.proto */ | |
| typedef ::std::complex< double > __pyx_t_double_complex; | |
| typedef double _Complex __pyx_t_double_complex; | |
| typedef struct { double real, imag; } __pyx_t_double_complex; | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); | |
| /*--- Type declarations ---*/ | |
| struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; | |
| /* "fontTools/cu2qu/cu2qu.py":141 | |
| * a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| */ | |
| struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen { | |
| PyObject_HEAD | |
| __pyx_t_double_complex __pyx_v_a; | |
| __pyx_t_double_complex __pyx_v_a1; | |
| __pyx_t_double_complex __pyx_v_b; | |
| __pyx_t_double_complex __pyx_v_b1; | |
| __pyx_t_double_complex __pyx_v_c; | |
| __pyx_t_double_complex __pyx_v_c1; | |
| __pyx_t_double_complex __pyx_v_d; | |
| __pyx_t_double_complex __pyx_v_d1; | |
| double __pyx_v_delta_2; | |
| double __pyx_v_delta_3; | |
| double __pyx_v_dt; | |
| int __pyx_v_i; | |
| int __pyx_v_n; | |
| __pyx_t_double_complex __pyx_v_p0; | |
| __pyx_t_double_complex __pyx_v_p1; | |
| __pyx_t_double_complex __pyx_v_p2; | |
| __pyx_t_double_complex __pyx_v_p3; | |
| double __pyx_v_t1; | |
| double __pyx_v_t1_2; | |
| int __pyx_t_0; | |
| int __pyx_t_1; | |
| int __pyx_t_2; | |
| }; | |
| /* --- 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); | |
| /* GetBuiltinName.proto */ | |
| static PyObject *__Pyx_GetBuiltinName(PyObject *name); | |
| /* PyIntCompare.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); | |
| /* RaiseTooManyValuesToUnpack.proto */ | |
| static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); | |
| /* RaiseNeedMoreValuesToUnpack.proto */ | |
| static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); | |
| /* IterFinish.proto */ | |
| static CYTHON_INLINE int __Pyx_IterFinish(void); | |
| /* UnpackItemEndCheck.proto */ | |
| static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); | |
| /* GetItemInt.proto */ | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, | |
| int wraparound, int boundscheck); | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, | |
| int wraparound, int boundscheck); | |
| static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, | |
| int is_list, int wraparound, int boundscheck); | |
| /* 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); | |
| /* GetModuleGlobalName.proto */ | |
| static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); | |
| static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); | |
| /* PyFunctionFastCall.proto */ | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); | |
| static size_t __pyx_pyframe_localsplus_offset = 0; | |
| /* PyCFunctionFastCall.proto */ | |
| static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); | |
| /* PyObjectCall.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); | |
| /* RaiseArgTupleInvalid.proto */ | |
| static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, | |
| Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); | |
| /* RaiseDoubleKeywords.proto */ | |
| static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); | |
| /* ParseKeywords.proto */ | |
| static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ | |
| PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ | |
| const char* function_name); | |
| /* GetTopmostException.proto */ | |
| static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); | |
| /* PyThreadStateGet.proto */ | |
| /* SaveResetException.proto */ | |
| static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); | |
| /* PyErrExceptionMatches.proto */ | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); | |
| /* GetException.proto */ | |
| static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); | |
| /* 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); | |
| /* WriteUnraisableException.proto */ | |
| static void __Pyx_WriteUnraisable(const char *name, int clineno, | |
| int lineno, const char *filename, | |
| int full_traceback, int nogil); | |
| /* PyObjectCall2Args.proto */ | |
| static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); | |
| /* PyObjectCallMethO.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); | |
| /* PyObjectCallOneArg.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); | |
| /* IterNext.proto */ | |
| static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); | |
| /* ListAppend.proto */ | |
| static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { | |
| PyListObject* L = (PyListObject*) list; | |
| Py_ssize_t len = Py_SIZE(list); | |
| if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { | |
| Py_INCREF(x); | |
| PyList_SET_ITEM(list, len, x); | |
| __Pyx_SET_SIZE(list, len + 1); | |
| return 0; | |
| } | |
| return PyList_Append(list, x); | |
| } | |
| /* ListCompAppend.proto */ | |
| static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { | |
| PyListObject* L = (PyListObject*) list; | |
| Py_ssize_t len = Py_SIZE(list); | |
| if (likely(L->allocated > len)) { | |
| Py_INCREF(x); | |
| PyList_SET_ITEM(list, len, x); | |
| __Pyx_SET_SIZE(list, len + 1); | |
| return 0; | |
| } | |
| return PyList_Append(list, x); | |
| } | |
| /* PyIntBinop.proto */ | |
| static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); | |
| /* RaiseException.proto */ | |
| static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); | |
| /* SetItemInt.proto */ | |
| static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); | |
| static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, | |
| int is_list, int wraparound, int boundscheck); | |
| /* ModInt[long].proto */ | |
| static CYTHON_INLINE long __Pyx_mod_long(long, long); | |
| /* IncludeStringH.proto */ | |
| /* PyObject_GenericGetAttrNoDict.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); | |
| /* Import.proto */ | |
| static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); | |
| /* ImportFrom.proto */ | |
| static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); | |
| /* FetchCommonType.proto */ | |
| static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); | |
| /* CythonFunctionShared.proto */ | |
| typedef struct { | |
| PyCFunctionObject func; | |
| PyObject *func_weakreflist; | |
| PyObject *func_dict; | |
| PyObject *func_name; | |
| PyObject *func_qualname; | |
| PyObject *func_doc; | |
| PyObject *func_globals; | |
| PyObject *func_code; | |
| PyObject *func_closure; | |
| PyObject *func_classobj; | |
| void *defaults; | |
| int defaults_pyobjects; | |
| size_t defaults_size; // used by FusedFunction for copying defaults | |
| int flags; | |
| PyObject *defaults_tuple; | |
| PyObject *defaults_kwdict; | |
| PyObject *(*defaults_getter)(PyObject *); | |
| PyObject *func_annotations; | |
| } __pyx_CyFunctionObject; | |
| static PyTypeObject *__pyx_CyFunctionType = 0; | |
| static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, | |
| int flags, PyObject* qualname, | |
| PyObject *self, | |
| PyObject *module, PyObject *globals, | |
| PyObject* code); | |
| static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, | |
| size_t size, | |
| int pyobjects); | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, | |
| PyObject *tuple); | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, | |
| PyObject *dict); | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, | |
| PyObject *dict); | |
| static int __pyx_CyFunction_init(void); | |
| /* CythonFunction.proto */ | |
| static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, | |
| int flags, PyObject* qualname, | |
| PyObject *closure, | |
| PyObject *module, PyObject *globals, | |
| PyObject* code); | |
| /* 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); | |
| /* FromPy.proto */ | |
| static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*); | |
| /* GCCDiagnostics.proto */ | |
| /* RealImag.proto */ | |
| /* Arithmetic.proto */ | |
| static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); | |
| static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); | |
| static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); | |
| /* ToPy.proto */ | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); | |
| /* CIntToPy.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); | |
| /* CIntToPy.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE long __Pyx_PyInt_As_long(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); | |
| /* SwapException.proto */ | |
| static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); | |
| /* PyObjectGetMethod.proto */ | |
| static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); | |
| /* PyObjectCallMethod1.proto */ | |
| static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); | |
| /* CoroutineBase.proto */ | |
| typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *); | |
| typedef struct { | |
| PyObject *exc_type; | |
| PyObject *exc_value; | |
| PyObject *exc_traceback; | |
| } __Pyx_ExcInfoStruct; | |
| typedef struct { | |
| PyObject_HEAD | |
| __pyx_coroutine_body_t body; | |
| PyObject *closure; | |
| __Pyx_ExcInfoStruct gi_exc_state; | |
| PyObject *gi_weakreflist; | |
| PyObject *classobj; | |
| PyObject *yieldfrom; | |
| PyObject *gi_name; | |
| PyObject *gi_qualname; | |
| PyObject *gi_modulename; | |
| PyObject *gi_code; | |
| PyObject *gi_frame; | |
| int resume_label; | |
| char is_running; | |
| } __pyx_CoroutineObject; | |
| static __pyx_CoroutineObject *__Pyx__Coroutine_New( | |
| PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, | |
| PyObject *name, PyObject *qualname, PyObject *module_name); | |
| static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( | |
| __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, | |
| PyObject *name, PyObject *qualname, PyObject *module_name); | |
| static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); | |
| static int __Pyx_Coroutine_clear(PyObject *self); | |
| static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); | |
| static PyObject *__Pyx_Coroutine_Close(PyObject *self); | |
| static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); | |
| static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); | |
| static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); | |
| /* PatchModuleWithCoroutine.proto */ | |
| static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); | |
| /* PatchGeneratorABC.proto */ | |
| static int __Pyx_patch_abc(void); | |
| /* Generator.proto */ | |
| static PyTypeObject *__pyx_GeneratorType = 0; | |
| static PyObject *__Pyx_Generator_Next(PyObject *self); | |
| static int __pyx_Generator_init(void); | |
| /* CheckBinaryVersion.proto */ | |
| static int __Pyx_check_binary_version(void); | |
| /* InitStrings.proto */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); | |
| /* Module declarations from 'cython' */ | |
| /* Module declarations from 'fontTools.cu2qu.cu2qu' */ | |
| static PyTypeObject *__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = 0; | |
| static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, PyObject *); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/ | |
| static int __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, double); /*proto*/ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *, double); /*proto*/ | |
| static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *, int, double, int); /*proto*/ | |
| extern int __pyx_module_is_main_fontTools__cu2qu__cu2qu; | |
| int __pyx_module_is_main_fontTools__cu2qu__cu2qu = 0; | |
| /* Implementation of 'fontTools.cu2qu.cu2qu' */ | |
| static PyObject *__pyx_builtin_AttributeError; | |
| static PyObject *__pyx_builtin_ImportError; | |
| static PyObject *__pyx_builtin_range; | |
| static PyObject *__pyx_builtin_ZeroDivisionError; | |
| static const char __pyx_k_a[] = "a"; | |
| static const char __pyx_k_b[] = "b"; | |
| static const char __pyx_k_c[] = "c"; | |
| static const char __pyx_k_d[] = "d"; | |
| static const char __pyx_k_i[] = "i"; | |
| static const char __pyx_k_l[] = "l"; | |
| static const char __pyx_k_n[] = "n"; | |
| static const char __pyx_k_p[] = "p"; | |
| static const char __pyx_k_s[] = "s"; | |
| static const char __pyx_k_a1[] = "a1"; | |
| static const char __pyx_k_b1[] = "b1"; | |
| static const char __pyx_k_c1[] = "c1"; | |
| static const char __pyx_k_d1[] = "d1"; | |
| static const char __pyx_k_dt[] = "dt"; | |
| static const char __pyx_k_p0[] = "p0"; | |
| static const char __pyx_k_p1[] = "p1"; | |
| static const char __pyx_k_p2[] = "p2"; | |
| static const char __pyx_k_p3[] = "p3"; | |
| static const char __pyx_k_t1[] = "t1"; | |
| static const char __pyx_k_NAN[] = "NAN"; | |
| static const char __pyx_k_NaN[] = "NaN"; | |
| static const char __pyx_k_all[] = "__all__"; | |
| static const char __pyx_k_args[] = "args"; | |
| static const char __pyx_k_imag[] = "imag"; | |
| static const char __pyx_k_main[] = "__main__"; | |
| static const char __pyx_k_math[] = "math"; | |
| static const char __pyx_k_name[] = "__name__"; | |
| static const char __pyx_k_real[] = "real"; | |
| static const char __pyx_k_send[] = "send"; | |
| static const char __pyx_k_t1_2[] = "t1_2"; | |
| static const char __pyx_k_test[] = "__test__"; | |
| static const char __pyx_k_Error[] = "Error"; | |
| static const char __pyx_k_MAX_N[] = "MAX_N"; | |
| static const char __pyx_k_close[] = "close"; | |
| static const char __pyx_k_curve[] = "curve"; | |
| static const char __pyx_k_isnan[] = "isnan"; | |
| static const char __pyx_k_range[] = "range"; | |
| static const char __pyx_k_throw[] = "throw"; | |
| static const char __pyx_k_curves[] = "curves"; | |
| static const char __pyx_k_cython[] = "cython"; | |
| static const char __pyx_k_errors[] = "errors"; | |
| static const char __pyx_k_import[] = "__import__"; | |
| static const char __pyx_k_last_i[] = "last_i"; | |
| static const char __pyx_k_spline[] = "spline"; | |
| static const char __pyx_k_delta_2[] = "delta_2"; | |
| static const char __pyx_k_delta_3[] = "delta_3"; | |
| static const char __pyx_k_max_err[] = "max_err"; | |
| static const char __pyx_k_splines[] = "splines"; | |
| static const char __pyx_k_COMPILED[] = "COMPILED"; | |
| static const char __pyx_k_Cu2QuError[] = "Cu2QuError"; | |
| static const char __pyx_k_max_errors[] = "max_errors"; | |
| static const char __pyx_k_ImportError[] = "ImportError"; | |
| static const char __pyx_k_all_quadratic[] = "all_quadratic"; | |
| static const char __pyx_k_AttributeError[] = "AttributeError"; | |
| static const char __pyx_k_fontTools_misc[] = "fontTools.misc"; | |
| static const char __pyx_k_ZeroDivisionError[] = "ZeroDivisionError"; | |
| static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; | |
| static const char __pyx_k_curve_to_quadratic[] = "curve_to_quadratic"; | |
| static const char __pyx_k_ApproxNotFoundError[] = "ApproxNotFoundError"; | |
| static const char __pyx_k_curves_to_quadratic[] = "curves_to_quadratic"; | |
| static const char __pyx_k_fontTools_cu2qu_cu2qu[] = "fontTools.cu2qu.cu2qu"; | |
| static const char __pyx_k_split_cubic_into_n_gen[] = "_split_cubic_into_n_gen"; | |
| static const char __pyx_k_Lib_fontTools_cu2qu_cu2qu_py[] = "Lib/fontTools/cu2qu/cu2qu.py"; | |
| static const char __pyx_k_curves_to_quadratic_line_476[] = "curves_to_quadratic (line 476)"; | |
| static const char __pyx_k_Return_quadratic_Bezier_splines[] = "Return quadratic Bezier splines approximating the input cubic Beziers.\n\n Args:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\n Example::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\n The returned splines have \"implied oncurve points\" suitable for use in\n TrueType ``glif`` outlines - i.e. in the first spline returned above,\n the first quadratic segment runs from (50,50) to\n ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\n Returns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\n Raises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.\n "; | |
| static PyObject *__pyx_n_s_ApproxNotFoundError; | |
| static PyObject *__pyx_n_s_AttributeError; | |
| static PyObject *__pyx_n_s_COMPILED; | |
| static PyObject *__pyx_n_s_Cu2QuError; | |
| static PyObject *__pyx_n_s_Error; | |
| static PyObject *__pyx_n_s_ImportError; | |
| static PyObject *__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py; | |
| static PyObject *__pyx_n_s_MAX_N; | |
| static PyObject *__pyx_n_s_NAN; | |
| static PyObject *__pyx_n_u_NaN; | |
| static PyObject *__pyx_kp_u_Return_quadratic_Bezier_splines; | |
| static PyObject *__pyx_n_s_ZeroDivisionError; | |
| static PyObject *__pyx_n_s_a; | |
| static PyObject *__pyx_n_s_a1; | |
| static PyObject *__pyx_n_s_all; | |
| static PyObject *__pyx_n_s_all_quadratic; | |
| static PyObject *__pyx_n_s_args; | |
| static PyObject *__pyx_n_s_b; | |
| static PyObject *__pyx_n_s_b1; | |
| static PyObject *__pyx_n_s_c; | |
| static PyObject *__pyx_n_s_c1; | |
| static PyObject *__pyx_n_s_cline_in_traceback; | |
| static PyObject *__pyx_n_s_close; | |
| static PyObject *__pyx_n_s_curve; | |
| static PyObject *__pyx_n_s_curve_to_quadratic; | |
| static PyObject *__pyx_n_u_curve_to_quadratic; | |
| static PyObject *__pyx_n_s_curves; | |
| static PyObject *__pyx_n_s_curves_to_quadratic; | |
| static PyObject *__pyx_n_u_curves_to_quadratic; | |
| static PyObject *__pyx_kp_u_curves_to_quadratic_line_476; | |
| static PyObject *__pyx_n_s_cython; | |
| static PyObject *__pyx_n_s_d; | |
| static PyObject *__pyx_n_s_d1; | |
| static PyObject *__pyx_n_s_delta_2; | |
| static PyObject *__pyx_n_s_delta_3; | |
| static PyObject *__pyx_n_s_dt; | |
| static PyObject *__pyx_n_s_errors; | |
| static PyObject *__pyx_n_s_fontTools_cu2qu_cu2qu; | |
| static PyObject *__pyx_n_s_fontTools_misc; | |
| static PyObject *__pyx_n_s_i; | |
| static PyObject *__pyx_n_s_imag; | |
| static PyObject *__pyx_n_s_import; | |
| static PyObject *__pyx_n_s_isnan; | |
| static PyObject *__pyx_n_s_l; | |
| static PyObject *__pyx_n_s_last_i; | |
| static PyObject *__pyx_n_s_main; | |
| static PyObject *__pyx_n_s_math; | |
| static PyObject *__pyx_n_s_max_err; | |
| static PyObject *__pyx_n_s_max_errors; | |
| static PyObject *__pyx_n_s_n; | |
| static PyObject *__pyx_n_s_name; | |
| static PyObject *__pyx_n_s_p; | |
| static PyObject *__pyx_n_s_p0; | |
| static PyObject *__pyx_n_s_p1; | |
| static PyObject *__pyx_n_s_p2; | |
| static PyObject *__pyx_n_s_p3; | |
| static PyObject *__pyx_n_s_range; | |
| static PyObject *__pyx_n_s_real; | |
| static PyObject *__pyx_n_s_s; | |
| static PyObject *__pyx_n_s_send; | |
| static PyObject *__pyx_n_s_spline; | |
| static PyObject *__pyx_n_s_splines; | |
| static PyObject *__pyx_n_s_split_cubic_into_n_gen; | |
| static PyObject *__pyx_n_s_t1; | |
| static PyObject *__pyx_n_s_t1_2; | |
| static PyObject *__pyx_n_s_test; | |
| static PyObject *__pyx_n_s_throw; | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n); /* proto */ | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic); /* proto */ | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic); /* proto */ | |
| static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ | |
| static PyObject *__pyx_int_1; | |
| static PyObject *__pyx_int_2; | |
| static PyObject *__pyx_int_3; | |
| static PyObject *__pyx_int_4; | |
| static PyObject *__pyx_int_6; | |
| static PyObject *__pyx_int_100; | |
| static PyObject *__pyx_codeobj_; | |
| static PyObject *__pyx_tuple__2; | |
| static PyObject *__pyx_tuple__3; | |
| static PyObject *__pyx_tuple__5; | |
| static PyObject *__pyx_codeobj__4; | |
| static PyObject *__pyx_codeobj__6; | |
| /* Late includes */ | |
| /* "fontTools/cu2qu/cu2qu.py":44 | |
| * @cython.returns(cython.double) | |
| * @cython.locals(v1=cython.complex, v2=cython.complex) | |
| * def dot(v1, v2): # <<<<<<<<<<<<<< | |
| * """Return the dot product of two vectors. | |
| * | |
| */ | |
| static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex __pyx_v_v1, __pyx_t_double_complex __pyx_v_v2) { | |
| double __pyx_r; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("dot", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":54 | |
| * double: Dot product. | |
| * """ | |
| * return (v1 * v2.conjugate()).real # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_r = __Pyx_CREAL(__Pyx_c_prod_double(__pyx_v_v1, __Pyx_c_conj_double(__pyx_v_v2))); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":44 | |
| * @cython.returns(cython.double) | |
| * @cython.locals(v1=cython.complex, v2=cython.complex) | |
| * def dot(v1, v2): # <<<<<<<<<<<<<< | |
| * """Return the dot product of two vectors. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":63 | |
| * _1=cython.complex, _2=cython.complex, _3=cython.complex, _4=cython.complex | |
| * ) | |
| * def calc_cubic_points(a, b, c, d): # <<<<<<<<<<<<<< | |
| * _1 = d | |
| * _2 = (c / 3.0) + d | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) { | |
| __pyx_t_double_complex __pyx_v__1; | |
| __pyx_t_double_complex __pyx_v__2; | |
| __pyx_t_double_complex __pyx_v__3; | |
| __pyx_t_double_complex __pyx_v__4; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| __pyx_t_double_complex __pyx_t_1; | |
| __pyx_t_double_complex __pyx_t_2; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *__pyx_t_7 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("calc_cubic_points", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":64 | |
| * ) | |
| * def calc_cubic_points(a, b, c, d): | |
| * _1 = d # <<<<<<<<<<<<<< | |
| * _2 = (c / 3.0) + d | |
| * _3 = (b + c) / 3.0 + _2 | |
| */ | |
| __pyx_v__1 = __pyx_v_d; | |
| /* "fontTools/cu2qu/cu2qu.py":65 | |
| * def calc_cubic_points(a, b, c, d): | |
| * _1 = d | |
| * _2 = (c / 3.0) + d # <<<<<<<<<<<<<< | |
| * _3 = (b + c) / 3.0 + _2 | |
| * _4 = a + d + c + b | |
| */ | |
| __pyx_t_1 = __pyx_t_double_complex_from_parts(3.0, 0); | |
| if (unlikely(__Pyx_c_is_zero_double(__pyx_t_1))) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 65, __pyx_L1_error) | |
| } | |
| __pyx_v__2 = __Pyx_c_sum_double(__Pyx_c_quot_double(__pyx_v_c, __pyx_t_1), __pyx_v_d); | |
| /* "fontTools/cu2qu/cu2qu.py":66 | |
| * _1 = d | |
| * _2 = (c / 3.0) + d | |
| * _3 = (b + c) / 3.0 + _2 # <<<<<<<<<<<<<< | |
| * _4 = a + d + c + b | |
| * return _1, _2, _3, _4 | |
| */ | |
| __pyx_t_1 = __Pyx_c_sum_double(__pyx_v_b, __pyx_v_c); | |
| __pyx_t_2 = __pyx_t_double_complex_from_parts(3.0, 0); | |
| if (unlikely(__Pyx_c_is_zero_double(__pyx_t_2))) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 66, __pyx_L1_error) | |
| } | |
| __pyx_v__3 = __Pyx_c_sum_double(__Pyx_c_quot_double(__pyx_t_1, __pyx_t_2), __pyx_v__2); | |
| /* "fontTools/cu2qu/cu2qu.py":67 | |
| * _2 = (c / 3.0) + d | |
| * _3 = (b + c) / 3.0 + _2 | |
| * _4 = a + d + c + b # <<<<<<<<<<<<<< | |
| * return _1, _2, _3, _4 | |
| * | |
| */ | |
| __pyx_v__4 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_a, __pyx_v_d), __pyx_v_c), __pyx_v_b); | |
| /* "fontTools/cu2qu/cu2qu.py":68 | |
| * _3 = (b + c) / 3.0 + _2 | |
| * _4 = a + d + c + b | |
| * return _1, _2, _3, _4 # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v__1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v__3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_v__4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); | |
| __Pyx_GIVEREF(__pyx_t_4); | |
| PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6); | |
| __pyx_t_3 = 0; | |
| __pyx_t_4 = 0; | |
| __pyx_t_5 = 0; | |
| __pyx_t_6 = 0; | |
| __pyx_r = __pyx_t_7; | |
| __pyx_t_7 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":63 | |
| * _1=cython.complex, _2=cython.complex, _3=cython.complex, _4=cython.complex | |
| * ) | |
| * def calc_cubic_points(a, b, c, d): # <<<<<<<<<<<<<< | |
| * _1 = d | |
| * _2 = (c / 3.0) + d | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_points", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":77 | |
| * ) | |
| * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) | |
| * def calc_cubic_parameters(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * c = (p1 - p0) * 3.0 | |
| * b = (p2 - p1) * 3.0 - c | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { | |
| __pyx_t_double_complex __pyx_v_a; | |
| __pyx_t_double_complex __pyx_v_b; | |
| __pyx_t_double_complex __pyx_v_c; | |
| __pyx_t_double_complex __pyx_v_d; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("calc_cubic_parameters", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":78 | |
| * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) | |
| * def calc_cubic_parameters(p0, p1, p2, p3): | |
| * c = (p1 - p0) * 3.0 # <<<<<<<<<<<<<< | |
| * b = (p2 - p1) * 3.0 - c | |
| * d = p0 | |
| */ | |
| __pyx_v_c = __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(3.0, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":79 | |
| * def calc_cubic_parameters(p0, p1, p2, p3): | |
| * c = (p1 - p0) * 3.0 | |
| * b = (p2 - p1) * 3.0 - c # <<<<<<<<<<<<<< | |
| * d = p0 | |
| * a = p3 - d - c - b | |
| */ | |
| __pyx_v_b = __Pyx_c_diff_double(__Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p1), __pyx_t_double_complex_from_parts(3.0, 0)), __pyx_v_c); | |
| /* "fontTools/cu2qu/cu2qu.py":80 | |
| * c = (p1 - p0) * 3.0 | |
| * b = (p2 - p1) * 3.0 - c | |
| * d = p0 # <<<<<<<<<<<<<< | |
| * a = p3 - d - c - b | |
| * return a, b, c, d | |
| */ | |
| __pyx_v_d = __pyx_v_p0; | |
| /* "fontTools/cu2qu/cu2qu.py":81 | |
| * b = (p2 - p1) * 3.0 - c | |
| * d = p0 | |
| * a = p3 - d - c - b # <<<<<<<<<<<<<< | |
| * return a, b, c, d | |
| * | |
| */ | |
| __pyx_v_a = __Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__pyx_v_p3, __pyx_v_d), __pyx_v_c), __pyx_v_b); | |
| /* "fontTools/cu2qu/cu2qu.py":82 | |
| * d = p0 | |
| * a = p3 - d - c - b | |
| * return a, b, c, d # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v_c); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_2); | |
| PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); | |
| __Pyx_GIVEREF(__pyx_t_4); | |
| PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); | |
| __pyx_t_1 = 0; | |
| __pyx_t_2 = 0; | |
| __pyx_t_3 = 0; | |
| __pyx_t_4 = 0; | |
| __pyx_r = __pyx_t_5; | |
| __pyx_t_5 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":77 | |
| * ) | |
| * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) | |
| * def calc_cubic_parameters(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * c = (p1 - p0) * 3.0 | |
| * b = (p2 - p1) * 3.0 - c | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":90 | |
| * p0=cython.complex, p1=cython.complex, p2=cython.complex, p3=cython.complex | |
| * ) | |
| * def split_cubic_into_n_iter(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into n equal parts. | |
| * | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, PyObject *__pyx_v_n) { | |
| PyObject *__pyx_v_a = NULL; | |
| PyObject *__pyx_v_b = NULL; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| int __pyx_t_2; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *(*__pyx_t_6)(PyObject *); | |
| __pyx_t_double_complex __pyx_t_7; | |
| __pyx_t_double_complex __pyx_t_8; | |
| __pyx_t_double_complex __pyx_t_9; | |
| __pyx_t_double_complex __pyx_t_10; | |
| PyObject *__pyx_t_11 = NULL; | |
| PyObject *__pyx_t_12 = NULL; | |
| PyObject *__pyx_t_13 = NULL; | |
| int __pyx_t_14; | |
| PyObject *__pyx_t_15 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("split_cubic_into_n_iter", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":107 | |
| * """ | |
| * # Hand-coded special-cases | |
| * if n == 2: # <<<<<<<<<<<<<< | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) | |
| * if n == 3: | |
| */ | |
| __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_n, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| if (__pyx_t_2) { | |
| /* "fontTools/cu2qu/cu2qu.py":108 | |
| * # Hand-coded special-cases | |
| * if n == 2: | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) # <<<<<<<<<<<<<< | |
| * if n == 3: | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_r = __pyx_t_3; | |
| __pyx_t_3 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":107 | |
| * """ | |
| * # Hand-coded special-cases | |
| * if n == 2: # <<<<<<<<<<<<<< | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) | |
| * if n == 3: | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":109 | |
| * if n == 2: | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) | |
| * if n == 3: # <<<<<<<<<<<<<< | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| * if n == 4: | |
| */ | |
| __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_n, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 109, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| if (__pyx_t_2) { | |
| /* "fontTools/cu2qu/cu2qu.py":110 | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) | |
| * if n == 3: | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) # <<<<<<<<<<<<<< | |
| * if n == 4: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_3 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":109 | |
| * if n == 2: | |
| * return iter(split_cubic_into_two(p0, p1, p2, p3)) | |
| * if n == 3: # <<<<<<<<<<<<<< | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| * if n == 4: | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":111 | |
| * if n == 3: | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| * if n == 4: # <<<<<<<<<<<<<< | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| */ | |
| __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_n, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| if (__pyx_t_2) { | |
| /* "fontTools/cu2qu/cu2qu.py":112 | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| * if n == 4: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<< | |
| * return iter( | |
| * split_cubic_into_two(a[0], a[1], a[2], a[3]) | |
| */ | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { | |
| PyObject* sequence = __pyx_t_1; | |
| Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); | |
| if (unlikely(size != 2)) { | |
| if (size > 2) __Pyx_RaiseTooManyValuesError(2); | |
| else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); | |
| __PYX_ERR(0, 112, __pyx_L1_error) | |
| } | |
| if (likely(PyTuple_CheckExact(sequence))) { | |
| __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); | |
| __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); | |
| } else { | |
| __pyx_t_3 = PyList_GET_ITEM(sequence, 0); | |
| __pyx_t_4 = PyList_GET_ITEM(sequence, 1); | |
| } | |
| __Pyx_INCREF(__pyx_t_3); | |
| __Pyx_INCREF(__pyx_t_4); | |
| __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| } else { | |
| Py_ssize_t index = -1; | |
| __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; | |
| index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed; | |
| __Pyx_GOTREF(__pyx_t_3); | |
| index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed; | |
| __Pyx_GOTREF(__pyx_t_4); | |
| if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 112, __pyx_L1_error) | |
| __pyx_t_6 = NULL; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| goto __pyx_L7_unpacking_done; | |
| __pyx_L6_unpacking_failed:; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __pyx_t_6 = NULL; | |
| if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); | |
| __PYX_ERR(0, 112, __pyx_L1_error) | |
| __pyx_L7_unpacking_done:; | |
| } | |
| __pyx_v_a = __pyx_t_3; | |
| __pyx_t_3 = 0; | |
| __pyx_v_b = __pyx_t_4; | |
| __pyx_t_4 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":113 | |
| * if n == 4: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( # <<<<<<<<<<<<<< | |
| * split_cubic_into_two(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| /* "fontTools/cu2qu/cu2qu.py":114 | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| * split_cubic_into_two(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<< | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) | |
| * ) | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| /* "fontTools/cu2qu/cu2qu.py":115 | |
| * return iter( | |
| * split_cubic_into_two(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<< | |
| * ) | |
| * if n == 6: | |
| */ | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":113 | |
| * if n == 4: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( # <<<<<<<<<<<<<< | |
| * split_cubic_into_two(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) | |
| */ | |
| __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| __pyx_r = __pyx_t_4; | |
| __pyx_t_4 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":111 | |
| * if n == 3: | |
| * return iter(split_cubic_into_three(p0, p1, p2, p3)) | |
| * if n == 4: # <<<<<<<<<<<<<< | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":117 | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) | |
| * ) | |
| * if n == 6: # <<<<<<<<<<<<<< | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| */ | |
| __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_n, __pyx_int_6, 6, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 117, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| if (__pyx_t_2) { | |
| /* "fontTools/cu2qu/cu2qu.py":118 | |
| * ) | |
| * if n == 6: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<< | |
| * return iter( | |
| * split_cubic_into_three(a[0], a[1], a[2], a[3]) | |
| */ | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { | |
| PyObject* sequence = __pyx_t_4; | |
| Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); | |
| if (unlikely(size != 2)) { | |
| if (size > 2) __Pyx_RaiseTooManyValuesError(2); | |
| else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); | |
| __PYX_ERR(0, 118, __pyx_L1_error) | |
| } | |
| if (likely(PyTuple_CheckExact(sequence))) { | |
| __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); | |
| __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); | |
| } else { | |
| __pyx_t_3 = PyList_GET_ITEM(sequence, 0); | |
| __pyx_t_1 = PyList_GET_ITEM(sequence, 1); | |
| } | |
| __Pyx_INCREF(__pyx_t_3); | |
| __Pyx_INCREF(__pyx_t_1); | |
| __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| } else { | |
| Py_ssize_t index = -1; | |
| __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; | |
| index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed; | |
| __Pyx_GOTREF(__pyx_t_3); | |
| index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed; | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 118, __pyx_L1_error) | |
| __pyx_t_6 = NULL; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| goto __pyx_L10_unpacking_done; | |
| __pyx_L9_unpacking_failed:; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __pyx_t_6 = NULL; | |
| if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); | |
| __PYX_ERR(0, 118, __pyx_L1_error) | |
| __pyx_L10_unpacking_done:; | |
| } | |
| __pyx_v_a = __pyx_t_3; | |
| __pyx_t_3 = 0; | |
| __pyx_v_b = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":119 | |
| * if n == 6: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( # <<<<<<<<<<<<<< | |
| * split_cubic_into_three(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_three(b[0], b[1], b[2], b[3]) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| /* "fontTools/cu2qu/cu2qu.py":120 | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| * split_cubic_into_three(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<< | |
| * + split_cubic_into_three(b[0], b[1], b[2], b[3]) | |
| * ) | |
| */ | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| /* "fontTools/cu2qu/cu2qu.py":121 | |
| * return iter( | |
| * split_cubic_into_three(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_three(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<< | |
| * ) | |
| * | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":119 | |
| * if n == 6: | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( # <<<<<<<<<<<<<< | |
| * split_cubic_into_three(a[0], a[1], a[2], a[3]) | |
| * + split_cubic_into_three(b[0], b[1], b[2], b[3]) | |
| */ | |
| __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":117 | |
| * + split_cubic_into_two(b[0], b[1], b[2], b[3]) | |
| * ) | |
| * if n == 6: # <<<<<<<<<<<<<< | |
| * a, b = split_cubic_into_two(p0, p1, p2, p3) | |
| * return iter( | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":124 | |
| * ) | |
| * | |
| * return _split_cubic_into_n_gen(p0, p1, p2, p3, n) # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_split_cubic_into_n_gen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_11 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_11); | |
| __pyx_t_12 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_12); | |
| __pyx_t_13 = NULL; | |
| __pyx_t_14 = 0; | |
| if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { | |
| __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3); | |
| if (likely(__pyx_t_13)) { | |
| PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); | |
| __Pyx_INCREF(__pyx_t_13); | |
| __Pyx_INCREF(function); | |
| __Pyx_DECREF_SET(__pyx_t_3, function); | |
| __pyx_t_14 = 1; | |
| } | |
| } | |
| if (PyFunction_Check(__pyx_t_3)) { | |
| PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_t_4, __pyx_t_5, __pyx_t_11, __pyx_t_12, __pyx_v_n}; | |
| __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_14, 5+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; | |
| __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; | |
| } else | |
| if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { | |
| PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_t_4, __pyx_t_5, __pyx_t_11, __pyx_t_12, __pyx_v_n}; | |
| __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_14, 5+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; | |
| __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; | |
| } else | |
| { | |
| __pyx_t_15 = PyTuple_New(5+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_15); | |
| if (__pyx_t_13) { | |
| __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL; | |
| } | |
| __Pyx_GIVEREF(__pyx_t_4); | |
| PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_4); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_11); | |
| PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_t_11); | |
| __Pyx_GIVEREF(__pyx_t_12); | |
| PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_14, __pyx_t_12); | |
| __Pyx_INCREF(__pyx_v_n); | |
| __Pyx_GIVEREF(__pyx_v_n); | |
| PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_14, __pyx_v_n); | |
| __pyx_t_4 = 0; | |
| __pyx_t_5 = 0; | |
| __pyx_t_11 = 0; | |
| __pyx_t_12 = 0; | |
| __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":90 | |
| * p0=cython.complex, p1=cython.complex, p2=cython.complex, p3=cython.complex | |
| * ) | |
| * def split_cubic_into_n_iter(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into n equal parts. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_11); | |
| __Pyx_XDECREF(__pyx_t_12); | |
| __Pyx_XDECREF(__pyx_t_13); | |
| __Pyx_XDECREF(__pyx_t_15); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_n_iter", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XDECREF(__pyx_v_a); | |
| __Pyx_XDECREF(__pyx_v_b); | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ | |
| /* "fontTools/cu2qu/cu2qu.py":141 | |
| * a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| */ | |
| /* Python wrapper */ | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ | |
| static char __pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen[] = "_split_cubic_into_n_gen(double complex p0, double complex p1, double complex p2, double complex p3, int n)"; | |
| static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen = {"_split_cubic_into_n_gen", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen}; | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { | |
| __pyx_t_double_complex __pyx_v_p0; | |
| __pyx_t_double_complex __pyx_v_p1; | |
| __pyx_t_double_complex __pyx_v_p2; | |
| __pyx_t_double_complex __pyx_v_p3; | |
| int __pyx_v_n; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| PyObject *__pyx_r = 0; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("_split_cubic_into_n_gen (wrapper)", 0); | |
| { | |
| static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_p0,&__pyx_n_s_p1,&__pyx_n_s_p2,&__pyx_n_s_p3,&__pyx_n_s_n,0}; | |
| PyObject* values[5] = {0,0,0,0,0}; | |
| if (unlikely(__pyx_kwds)) { | |
| Py_ssize_t kw_args; | |
| const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); | |
| switch (pos_args) { | |
| case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); | |
| CYTHON_FALLTHROUGH; | |
| case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); | |
| CYTHON_FALLTHROUGH; | |
| case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| CYTHON_FALLTHROUGH; | |
| case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| CYTHON_FALLTHROUGH; | |
| case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| CYTHON_FALLTHROUGH; | |
| case 0: break; | |
| default: goto __pyx_L5_argtuple_error; | |
| } | |
| kw_args = PyDict_Size(__pyx_kwds); | |
| switch (pos_args) { | |
| case 0: | |
| if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p0)) != 0)) kw_args--; | |
| else goto __pyx_L5_argtuple_error; | |
| CYTHON_FALLTHROUGH; | |
| case 1: | |
| if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p1)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 1); __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 2: | |
| if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p2)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 2); __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 3: | |
| if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_p3)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 3); __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 4: | |
| if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, 4); __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| } | |
| if (unlikely(kw_args > 0)) { | |
| if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_split_cubic_into_n_gen") < 0)) __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { | |
| goto __pyx_L5_argtuple_error; | |
| } else { | |
| values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| values[3] = PyTuple_GET_ITEM(__pyx_args, 3); | |
| values[4] = PyTuple_GET_ITEM(__pyx_args, 4); | |
| } | |
| __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) | |
| __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) | |
| __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) | |
| __pyx_v_p3 = __Pyx_PyComplex_As___pyx_t_double_complex(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) | |
| __pyx_v_n = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error) | |
| } | |
| goto __pyx_L4_argument_unpacking_done; | |
| __pyx_L5_argtuple_error:; | |
| __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 141, __pyx_L3_error) | |
| __pyx_L3_error:; | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __Pyx_RefNannyFinishContext(); | |
| return NULL; | |
| __pyx_L4_argument_unpacking_done:; | |
| __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(__pyx_self, __pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3, __pyx_v_n); | |
| /* function exit code */ | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n) { | |
| struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0); | |
| __pyx_cur_scope = (struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, __pyx_empty_tuple, NULL); | |
| if (unlikely(!__pyx_cur_scope)) { | |
| __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)Py_None); | |
| __Pyx_INCREF(Py_None); | |
| __PYX_ERR(0, 141, __pyx_L1_error) | |
| } else { | |
| __Pyx_GOTREF(__pyx_cur_scope); | |
| } | |
| __pyx_cur_scope->__pyx_v_p0 = __pyx_v_p0; | |
| __pyx_cur_scope->__pyx_v_p1 = __pyx_v_p1; | |
| __pyx_cur_scope->__pyx_v_p2 = __pyx_v_p2; | |
| __pyx_cur_scope->__pyx_v_p3 = __pyx_v_p3; | |
| __pyx_cur_scope->__pyx_v_n = __pyx_v_n; | |
| { | |
| __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator, __pyx_codeobj_, (PyObject *) __pyx_cur_scope, __pyx_n_s_split_cubic_into_n_gen, __pyx_n_s_split_cubic_into_n_gen, __pyx_n_s_fontTools_cu2qu_cu2qu); if (unlikely(!gen)) __PYX_ERR(0, 141, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_cur_scope); | |
| __Pyx_RefNannyFinishContext(); | |
| return (PyObject *) gen; | |
| } | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = NULL; | |
| __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ | |
| { | |
| struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_generator->closure); | |
| PyObject *__pyx_r = NULL; | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *(*__pyx_t_7)(PyObject *); | |
| __pyx_t_double_complex __pyx_t_8; | |
| __pyx_t_double_complex __pyx_t_9; | |
| __pyx_t_double_complex __pyx_t_10; | |
| __pyx_t_double_complex __pyx_t_11; | |
| int __pyx_t_12; | |
| int __pyx_t_13; | |
| int __pyx_t_14; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0); | |
| switch (__pyx_generator->resume_label) { | |
| case 0: goto __pyx_L3_first_run; | |
| case 1: goto __pyx_L8_resume_from_yield; | |
| default: /* CPython raises the right error here */ | |
| __Pyx_RefNannyFinishContext(); | |
| return NULL; | |
| } | |
| __pyx_L3_first_run:; | |
| if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 141, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":142 | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) # <<<<<<<<<<<<<< | |
| * dt = 1 / n | |
| * delta_2 = dt * dt | |
| */ | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_cur_scope->__pyx_v_p0, __pyx_cur_scope->__pyx_v_p1, __pyx_cur_scope->__pyx_v_p2, __pyx_cur_scope->__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { | |
| PyObject* sequence = __pyx_t_1; | |
| Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); | |
| if (unlikely(size != 4)) { | |
| if (size > 4) __Pyx_RaiseTooManyValuesError(4); | |
| else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); | |
| __PYX_ERR(0, 142, __pyx_L1_error) | |
| } | |
| if (likely(PyTuple_CheckExact(sequence))) { | |
| __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); | |
| __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); | |
| __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); | |
| __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); | |
| } else { | |
| __pyx_t_2 = PyList_GET_ITEM(sequence, 0); | |
| __pyx_t_3 = PyList_GET_ITEM(sequence, 1); | |
| __pyx_t_4 = PyList_GET_ITEM(sequence, 2); | |
| __pyx_t_5 = PyList_GET_ITEM(sequence, 3); | |
| } | |
| __Pyx_INCREF(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_t_3); | |
| __Pyx_INCREF(__pyx_t_4); | |
| __Pyx_INCREF(__pyx_t_5); | |
| { | |
| Py_ssize_t i; | |
| PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5}; | |
| for (i=0; i < 4; i++) { | |
| PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_GOTREF(item); | |
| *(temps[i]) = item; | |
| } | |
| } | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| } else { | |
| Py_ssize_t index = -1; | |
| PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5}; | |
| __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; | |
| for (index=0; index < 4; index++) { | |
| PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L4_unpacking_failed; | |
| __Pyx_GOTREF(item); | |
| *(temps[index]) = item; | |
| } | |
| if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __pyx_t_7 = NULL; | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| goto __pyx_L5_unpacking_done; | |
| __pyx_L4_unpacking_failed:; | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __pyx_t_7 = NULL; | |
| if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); | |
| __PYX_ERR(0, 142, __pyx_L1_error) | |
| __pyx_L5_unpacking_done:; | |
| } | |
| __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_11 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __pyx_cur_scope->__pyx_v_a = __pyx_t_8; | |
| __pyx_cur_scope->__pyx_v_b = __pyx_t_9; | |
| __pyx_cur_scope->__pyx_v_c = __pyx_t_10; | |
| __pyx_cur_scope->__pyx_v_d = __pyx_t_11; | |
| /* "fontTools/cu2qu/cu2qu.py":143 | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n # <<<<<<<<<<<<<< | |
| * delta_2 = dt * dt | |
| * delta_3 = dt * delta_2 | |
| */ | |
| if (unlikely(__pyx_cur_scope->__pyx_v_n == 0)) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 143, __pyx_L1_error) | |
| } | |
| __pyx_cur_scope->__pyx_v_dt = (1.0 / ((double)__pyx_cur_scope->__pyx_v_n)); | |
| /* "fontTools/cu2qu/cu2qu.py":144 | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| * delta_2 = dt * dt # <<<<<<<<<<<<<< | |
| * delta_3 = dt * delta_2 | |
| * for i in range(n): | |
| */ | |
| __pyx_cur_scope->__pyx_v_delta_2 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_dt); | |
| /* "fontTools/cu2qu/cu2qu.py":145 | |
| * dt = 1 / n | |
| * delta_2 = dt * dt | |
| * delta_3 = dt * delta_2 # <<<<<<<<<<<<<< | |
| * for i in range(n): | |
| * t1 = i * dt | |
| */ | |
| __pyx_cur_scope->__pyx_v_delta_3 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_delta_2); | |
| /* "fontTools/cu2qu/cu2qu.py":146 | |
| * delta_2 = dt * dt | |
| * delta_3 = dt * delta_2 | |
| * for i in range(n): # <<<<<<<<<<<<<< | |
| * t1 = i * dt | |
| * t1_2 = t1 * t1 | |
| */ | |
| __pyx_t_12 = __pyx_cur_scope->__pyx_v_n; | |
| __pyx_t_13 = __pyx_t_12; | |
| for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { | |
| __pyx_cur_scope->__pyx_v_i = __pyx_t_14; | |
| /* "fontTools/cu2qu/cu2qu.py":147 | |
| * delta_3 = dt * delta_2 | |
| * for i in range(n): | |
| * t1 = i * dt # <<<<<<<<<<<<<< | |
| * t1_2 = t1 * t1 | |
| * # calc new a, b, c and d | |
| */ | |
| __pyx_cur_scope->__pyx_v_t1 = (__pyx_cur_scope->__pyx_v_i * __pyx_cur_scope->__pyx_v_dt); | |
| /* "fontTools/cu2qu/cu2qu.py":148 | |
| * for i in range(n): | |
| * t1 = i * dt | |
| * t1_2 = t1 * t1 # <<<<<<<<<<<<<< | |
| * # calc new a, b, c and d | |
| * a1 = a * delta_3 | |
| */ | |
| __pyx_cur_scope->__pyx_v_t1_2 = (__pyx_cur_scope->__pyx_v_t1 * __pyx_cur_scope->__pyx_v_t1); | |
| /* "fontTools/cu2qu/cu2qu.py":150 | |
| * t1_2 = t1 * t1 | |
| * # calc new a, b, c and d | |
| * a1 = a * delta_3 # <<<<<<<<<<<<<< | |
| * b1 = (3 * a * t1 + b) * delta_2 | |
| * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt | |
| */ | |
| __pyx_cur_scope->__pyx_v_a1 = __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_3, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":151 | |
| * # calc new a, b, c and d | |
| * a1 = a * delta_3 | |
| * b1 = (3 * a * t1 + b) * delta_2 # <<<<<<<<<<<<<< | |
| * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt | |
| * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d | |
| */ | |
| __pyx_cur_scope->__pyx_v_b1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_2, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":152 | |
| * a1 = a * delta_3 | |
| * b1 = (3 * a * t1 + b) * delta_2 | |
| * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt # <<<<<<<<<<<<<< | |
| * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d | |
| * yield calc_cubic_points(a1, b1, c1, d1) | |
| */ | |
| __pyx_cur_scope->__pyx_v_c1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_c), __Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_dt, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":153 | |
| * b1 = (3 * a * t1 + b) * delta_2 | |
| * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt | |
| * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d # <<<<<<<<<<<<<< | |
| * yield calc_cubic_points(a1, b1, c1, d1) | |
| * | |
| */ | |
| __pyx_cur_scope->__pyx_v_d1 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0)), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_b, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_c, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0))), __pyx_cur_scope->__pyx_v_d); | |
| /* "fontTools/cu2qu/cu2qu.py":154 | |
| * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt | |
| * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d | |
| * yield calc_cubic_points(a1, b1, c1, d1) # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_cur_scope->__pyx_v_a1, __pyx_cur_scope->__pyx_v_b1, __pyx_cur_scope->__pyx_v_c1, __pyx_cur_scope->__pyx_v_d1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| __pyx_cur_scope->__pyx_t_0 = __pyx_t_12; | |
| __pyx_cur_scope->__pyx_t_1 = __pyx_t_13; | |
| __pyx_cur_scope->__pyx_t_2 = __pyx_t_14; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| __Pyx_Coroutine_ResetAndClearException(__pyx_generator); | |
| /* return from generator, yielding value */ | |
| __pyx_generator->resume_label = 1; | |
| return __pyx_r; | |
| __pyx_L8_resume_from_yield:; | |
| __pyx_t_12 = __pyx_cur_scope->__pyx_t_0; | |
| __pyx_t_13 = __pyx_cur_scope->__pyx_t_1; | |
| __pyx_t_14 = __pyx_cur_scope->__pyx_t_2; | |
| if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 154, __pyx_L1_error) | |
| } | |
| CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); | |
| /* "fontTools/cu2qu/cu2qu.py":141 | |
| * a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| */ | |
| /* function exit code */ | |
| PyErr_SetNone(PyExc_StopIteration); | |
| goto __pyx_L0; | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_AddTraceback("_split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_L0:; | |
| __Pyx_XDECREF(__pyx_r); __pyx_r = 0; | |
| __Pyx_Coroutine_ResetAndClearException(__pyx_generator); | |
| __pyx_generator->resume_label = -1; | |
| __Pyx_Coroutine_clear((PyObject*)__pyx_generator); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":163 | |
| * ) | |
| * @cython.locals(mid=cython.complex, deriv3=cython.complex) | |
| * def split_cubic_into_two(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into two equal parts. | |
| * | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { | |
| __pyx_t_double_complex __pyx_v_mid; | |
| __pyx_t_double_complex __pyx_v_deriv3; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| __pyx_t_double_complex __pyx_t_2; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *__pyx_t_7 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("split_cubic_into_two", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":178 | |
| * values). | |
| * """ | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<< | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return ( | |
| */ | |
| __pyx_v_mid = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __Pyx_c_sum_double(__pyx_v_p1, __pyx_v_p2))), __pyx_v_p3), __pyx_t_double_complex_from_parts(0.125, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":179 | |
| * """ | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<< | |
| * return ( | |
| * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), | |
| */ | |
| __pyx_v_deriv3 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __pyx_v_p2), __pyx_v_p1), __pyx_v_p0), __pyx_t_double_complex_from_parts(0.125, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":180 | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return ( # <<<<<<<<<<<<<< | |
| * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), | |
| * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| /* "fontTools/cu2qu/cu2qu.py":181 | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return ( | |
| * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<< | |
| * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), | |
| * ) | |
| */ | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0)); | |
| __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_2 = __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3); | |
| __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); | |
| __Pyx_GIVEREF(__pyx_t_4); | |
| PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5); | |
| __pyx_t_1 = 0; | |
| __pyx_t_3 = 0; | |
| __pyx_t_4 = 0; | |
| __pyx_t_5 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":182 | |
| * return ( | |
| * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), | |
| * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), # <<<<<<<<<<<<<< | |
| * ) | |
| * | |
| */ | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 182, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_2 = __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3); | |
| __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 182, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0)); | |
| __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_4); | |
| PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1); | |
| __pyx_t_5 = 0; | |
| __pyx_t_4 = 0; | |
| __pyx_t_3 = 0; | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":181 | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return ( | |
| * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<< | |
| * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), | |
| * ) | |
| */ | |
| __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_7); | |
| PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7); | |
| __pyx_t_6 = 0; | |
| __pyx_t_7 = 0; | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":163 | |
| * ) | |
| * @cython.locals(mid=cython.complex, deriv3=cython.complex) | |
| * def split_cubic_into_two(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into two equal parts. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_two", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":200 | |
| * deriv2=cython.complex, | |
| * ) | |
| * def split_cubic_into_three(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into three equal parts. | |
| * | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { | |
| __pyx_t_double_complex __pyx_v_mid1; | |
| __pyx_t_double_complex __pyx_v_deriv1; | |
| __pyx_t_double_complex __pyx_v_mid2; | |
| __pyx_t_double_complex __pyx_v_deriv2; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| __pyx_t_double_complex __pyx_t_2; | |
| __pyx_t_double_complex __pyx_t_3; | |
| __pyx_t_double_complex __pyx_t_4; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *__pyx_t_7 = NULL; | |
| PyObject *__pyx_t_8 = NULL; | |
| PyObject *__pyx_t_9 = NULL; | |
| PyObject *__pyx_t_10 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("split_cubic_into_three", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":215 | |
| * values). | |
| * """ | |
| * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) # <<<<<<<<<<<<<< | |
| * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) | |
| * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) | |
| */ | |
| __pyx_v_mid1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p0), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p2)), __pyx_v_p3), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":216 | |
| * """ | |
| * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) | |
| * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) # <<<<<<<<<<<<<< | |
| * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) | |
| */ | |
| __pyx_v_deriv1 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p0)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":217 | |
| * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) | |
| * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) | |
| * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) # <<<<<<<<<<<<<< | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) | |
| * return ( | |
| */ | |
| __pyx_v_mid2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p3)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":218 | |
| * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) | |
| * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) # <<<<<<<<<<<<<< | |
| * return ( | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), | |
| */ | |
| __pyx_v_deriv2 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p3), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p1)), __pyx_v_p0), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":219 | |
| * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) | |
| * return ( # <<<<<<<<<<<<<< | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), | |
| * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| /* "fontTools/cu2qu/cu2qu.py":220 | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) | |
| * return ( | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<< | |
| * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), | |
| * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), | |
| */ | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p0), __pyx_v_p1); | |
| __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0); | |
| if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 220, __pyx_L1_error) | |
| } | |
| __pyx_t_4 = __Pyx_c_quot_double(__pyx_t_2, __pyx_t_3); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid1, __pyx_v_deriv1); | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_7); | |
| PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7); | |
| __pyx_t_1 = 0; | |
| __pyx_t_5 = 0; | |
| __pyx_t_6 = 0; | |
| __pyx_t_7 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":221 | |
| * return ( | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), | |
| * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), # <<<<<<<<<<<<<< | |
| * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), | |
| * ) | |
| */ | |
| __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 221, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid1, __pyx_v_deriv1); | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid2, __pyx_v_deriv2); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 221, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| __Pyx_GIVEREF(__pyx_t_7); | |
| PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1); | |
| __pyx_t_7 = 0; | |
| __pyx_t_6 = 0; | |
| __pyx_t_5 = 0; | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":222 | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), | |
| * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), | |
| * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), # <<<<<<<<<<<<<< | |
| * ) | |
| * | |
| */ | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid2, __pyx_v_deriv2); | |
| __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 222, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_p2, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p3)); | |
| __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0); | |
| if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 222, __pyx_L1_error) | |
| } | |
| __pyx_t_2 = __Pyx_c_quot_double(__pyx_t_4, __pyx_t_3); | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 222, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_7); | |
| PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_7); | |
| __pyx_t_1 = 0; | |
| __pyx_t_5 = 0; | |
| __pyx_t_6 = 0; | |
| __pyx_t_7 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":220 | |
| * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) | |
| * return ( | |
| * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<< | |
| * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), | |
| * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), | |
| */ | |
| __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_8); | |
| PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); | |
| __Pyx_GIVEREF(__pyx_t_9); | |
| PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9); | |
| __Pyx_GIVEREF(__pyx_t_10); | |
| PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10); | |
| __pyx_t_8 = 0; | |
| __pyx_t_9 = 0; | |
| __pyx_t_10 = 0; | |
| __pyx_r = __pyx_t_7; | |
| __pyx_t_7 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":200 | |
| * deriv2=cython.complex, | |
| * ) | |
| * def split_cubic_into_three(p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Split a cubic Bezier into three equal parts. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_XDECREF(__pyx_t_8); | |
| __Pyx_XDECREF(__pyx_t_9); | |
| __Pyx_XDECREF(__pyx_t_10); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_three", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":237 | |
| * ) | |
| * @cython.locals(_p1=cython.complex, _p2=cython.complex) | |
| * def cubic_approx_control(t, p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier using a quadratic one. | |
| * | |
| */ | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double __pyx_v_t, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3) { | |
| __pyx_t_double_complex __pyx_v__p1; | |
| __pyx_t_double_complex __pyx_v__p2; | |
| __pyx_t_double_complex __pyx_r; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("cubic_approx_control", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":250 | |
| * complex: Location of candidate control point on quadratic curve. | |
| * """ | |
| * _p1 = p0 + (p1 - p0) * 1.5 # <<<<<<<<<<<<<< | |
| * _p2 = p3 + (p2 - p3) * 1.5 | |
| * return _p1 + (_p2 - _p1) * t | |
| */ | |
| __pyx_v__p1 = __Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(1.5, 0))); | |
| /* "fontTools/cu2qu/cu2qu.py":251 | |
| * """ | |
| * _p1 = p0 + (p1 - p0) * 1.5 | |
| * _p2 = p3 + (p2 - p3) * 1.5 # <<<<<<<<<<<<<< | |
| * return _p1 + (_p2 - _p1) * t | |
| * | |
| */ | |
| __pyx_v__p2 = __Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(1.5, 0))); | |
| /* "fontTools/cu2qu/cu2qu.py":252 | |
| * _p1 = p0 + (p1 - p0) * 1.5 | |
| * _p2 = p3 + (p2 - p3) * 1.5 | |
| * return _p1 + (_p2 - _p1) * t # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_r = __Pyx_c_sum_double(__pyx_v__p1, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v__p2, __pyx_v__p1), __pyx_t_double_complex_from_parts(__pyx_v_t, 0))); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":237 | |
| * ) | |
| * @cython.locals(_p1=cython.complex, _p2=cython.complex) | |
| * def cubic_approx_control(t, p0, p1, p2, p3): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier using a quadratic one. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":260 | |
| * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) | |
| * @cython.locals(ab=cython.complex, cd=cython.complex, p=cython.complex, h=cython.double) | |
| * def calc_intersect(a, b, c, d): # <<<<<<<<<<<<<< | |
| * """Calculate the intersection of two lines. | |
| * | |
| */ | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) { | |
| __pyx_t_double_complex __pyx_v_ab; | |
| __pyx_t_double_complex __pyx_v_cd; | |
| __pyx_t_double_complex __pyx_v_p; | |
| double __pyx_v_h; | |
| __pyx_t_double_complex __pyx_r; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| PyObject *__pyx_t_3 = NULL; | |
| double __pyx_t_4; | |
| double __pyx_t_5; | |
| int __pyx_t_6; | |
| PyObject *__pyx_t_7 = NULL; | |
| PyObject *__pyx_t_8 = NULL; | |
| PyObject *__pyx_t_9 = NULL; | |
| PyObject *__pyx_t_10 = NULL; | |
| PyObject *__pyx_t_11 = NULL; | |
| PyObject *__pyx_t_12 = NULL; | |
| __pyx_t_double_complex __pyx_t_13; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("calc_intersect", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":273 | |
| * if no intersection was found. | |
| * """ | |
| * ab = b - a # <<<<<<<<<<<<<< | |
| * cd = d - c | |
| * p = ab * 1j | |
| */ | |
| __pyx_v_ab = __Pyx_c_diff_double(__pyx_v_b, __pyx_v_a); | |
| /* "fontTools/cu2qu/cu2qu.py":274 | |
| * """ | |
| * ab = b - a | |
| * cd = d - c # <<<<<<<<<<<<<< | |
| * p = ab * 1j | |
| * try: | |
| */ | |
| __pyx_v_cd = __Pyx_c_diff_double(__pyx_v_d, __pyx_v_c); | |
| /* "fontTools/cu2qu/cu2qu.py":275 | |
| * ab = b - a | |
| * cd = d - c | |
| * p = ab * 1j # <<<<<<<<<<<<<< | |
| * try: | |
| * h = dot(p, a - c) / dot(p, cd) | |
| */ | |
| __pyx_v_p = __Pyx_c_prod_double(__pyx_v_ab, __pyx_t_double_complex_from_parts(0, 1.0)); | |
| /* "fontTools/cu2qu/cu2qu.py":276 | |
| * cd = d - c | |
| * p = ab * 1j | |
| * try: # <<<<<<<<<<<<<< | |
| * h = dot(p, a - c) / dot(p, cd) | |
| * except ZeroDivisionError: | |
| */ | |
| { | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); | |
| __Pyx_XGOTREF(__pyx_t_1); | |
| __Pyx_XGOTREF(__pyx_t_2); | |
| __Pyx_XGOTREF(__pyx_t_3); | |
| /*try:*/ { | |
| /* "fontTools/cu2qu/cu2qu.py":277 | |
| * p = ab * 1j | |
| * try: | |
| * h = dot(p, a - c) / dot(p, cd) # <<<<<<<<<<<<<< | |
| * except ZeroDivisionError: | |
| * return complex(NAN, NAN) | |
| */ | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __Pyx_c_diff_double(__pyx_v_a, __pyx_v_c)); | |
| __pyx_t_5 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __pyx_v_cd); | |
| if (unlikely(__pyx_t_5 == 0)) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 277, __pyx_L3_error) | |
| } | |
| __pyx_v_h = (__pyx_t_4 / __pyx_t_5); | |
| /* "fontTools/cu2qu/cu2qu.py":276 | |
| * cd = d - c | |
| * p = ab * 1j | |
| * try: # <<<<<<<<<<<<<< | |
| * h = dot(p, a - c) / dot(p, cd) | |
| * except ZeroDivisionError: | |
| */ | |
| } | |
| __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| goto __pyx_L8_try_end; | |
| __pyx_L3_error:; | |
| /* "fontTools/cu2qu/cu2qu.py":278 | |
| * try: | |
| * h = dot(p, a - c) / dot(p, cd) | |
| * except ZeroDivisionError: # <<<<<<<<<<<<<< | |
| * return complex(NAN, NAN) | |
| * return c + cd * h | |
| */ | |
| __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ZeroDivisionError); | |
| if (__pyx_t_6) { | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 278, __pyx_L5_except_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __Pyx_GOTREF(__pyx_t_9); | |
| /* "fontTools/cu2qu/cu2qu.py":279 | |
| * h = dot(p, a - c) / dot(p, cd) | |
| * except ZeroDivisionError: | |
| * return complex(NAN, NAN) # <<<<<<<<<<<<<< | |
| * return c + cd * h | |
| * | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_NAN); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 279, __pyx_L5_except_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_NAN); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L5_except_error) | |
| __Pyx_GOTREF(__pyx_t_11); | |
| __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L5_except_error) | |
| __Pyx_GOTREF(__pyx_t_12); | |
| __Pyx_GIVEREF(__pyx_t_10); | |
| PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); | |
| __Pyx_GIVEREF(__pyx_t_11); | |
| PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11); | |
| __pyx_t_10 = 0; | |
| __pyx_t_11 = 0; | |
| __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L5_except_error) | |
| __Pyx_GOTREF(__pyx_t_11); | |
| __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; | |
| __pyx_t_13 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_11); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L5_except_error) | |
| __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; | |
| __pyx_r = __pyx_t_13; | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; | |
| goto __pyx_L6_except_return; | |
| } | |
| goto __pyx_L5_except_error; | |
| __pyx_L5_except_error:; | |
| /* "fontTools/cu2qu/cu2qu.py":276 | |
| * cd = d - c | |
| * p = ab * 1j | |
| * try: # <<<<<<<<<<<<<< | |
| * h = dot(p, a - c) / dot(p, cd) | |
| * except ZeroDivisionError: | |
| */ | |
| __Pyx_XGIVEREF(__pyx_t_1); | |
| __Pyx_XGIVEREF(__pyx_t_2); | |
| __Pyx_XGIVEREF(__pyx_t_3); | |
| __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); | |
| goto __pyx_L1_error; | |
| __pyx_L6_except_return:; | |
| __Pyx_XGIVEREF(__pyx_t_1); | |
| __Pyx_XGIVEREF(__pyx_t_2); | |
| __Pyx_XGIVEREF(__pyx_t_3); | |
| __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); | |
| goto __pyx_L0; | |
| __pyx_L8_try_end:; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":280 | |
| * except ZeroDivisionError: | |
| * return complex(NAN, NAN) | |
| * return c + cd * h # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_r = __Pyx_c_sum_double(__pyx_v_c, __Pyx_c_prod_double(__pyx_v_cd, __pyx_t_double_complex_from_parts(__pyx_v_h, 0))); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":260 | |
| * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex) | |
| * @cython.locals(ab=cython.complex, cd=cython.complex, p=cython.complex, h=cython.double) | |
| * def calc_intersect(a, b, c, d): # <<<<<<<<<<<<<< | |
| * """Calculate the intersection of two lines. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_XDECREF(__pyx_t_8); | |
| __Pyx_XDECREF(__pyx_t_9); | |
| __Pyx_XDECREF(__pyx_t_10); | |
| __Pyx_XDECREF(__pyx_t_11); | |
| __Pyx_XDECREF(__pyx_t_12); | |
| __Pyx_WriteUnraisable("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); | |
| __pyx_r = __pyx_t_double_complex_from_parts(0, 0); | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":293 | |
| * ) | |
| * @cython.locals(mid=cython.complex, deriv3=cython.complex) | |
| * def cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<< | |
| * """Check if a cubic Bezier lies within a given distance of the origin. | |
| * | |
| */ | |
| static int __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, double __pyx_v_tolerance) { | |
| __pyx_t_double_complex __pyx_v_mid; | |
| __pyx_t_double_complex __pyx_v_deriv3; | |
| int __pyx_r; | |
| __Pyx_RefNannyDeclarations | |
| int __pyx_t_1; | |
| int __pyx_t_2; | |
| int __pyx_t_3; | |
| int __pyx_t_4; | |
| __Pyx_RefNannySetupContext("cubic_farthest_fit_inside", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":312 | |
| * """ | |
| * # First check p2 then p1, as p2 has higher error early on. | |
| * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<< | |
| * return True | |
| * | |
| */ | |
| __pyx_t_2 = ((__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance) != 0); | |
| if (__pyx_t_2) { | |
| } else { | |
| __pyx_t_1 = __pyx_t_2; | |
| goto __pyx_L4_bool_binop_done; | |
| } | |
| __pyx_t_2 = ((__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance) != 0); | |
| __pyx_t_1 = __pyx_t_2; | |
| __pyx_L4_bool_binop_done:; | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":313 | |
| * # First check p2 then p1, as p2 has higher error early on. | |
| * if abs(p2) <= tolerance and abs(p1) <= tolerance: | |
| * return True # <<<<<<<<<<<<<< | |
| * | |
| * # Split. | |
| */ | |
| __pyx_r = 1; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":312 | |
| * """ | |
| * # First check p2 then p1, as p2 has higher error early on. | |
| * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<< | |
| * return True | |
| * | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":316 | |
| * | |
| * # Split. | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<< | |
| * if abs(mid) > tolerance: | |
| * return False | |
| */ | |
| __pyx_v_mid = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __Pyx_c_sum_double(__pyx_v_p1, __pyx_v_p2))), __pyx_v_p3), __pyx_t_double_complex_from_parts(0.125, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":317 | |
| * # Split. | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 | |
| * if abs(mid) > tolerance: # <<<<<<<<<<<<<< | |
| * return False | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| */ | |
| __pyx_t_1 = ((__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance) != 0); | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":318 | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 | |
| * if abs(mid) > tolerance: | |
| * return False # <<<<<<<<<<<<<< | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return cubic_farthest_fit_inside( | |
| */ | |
| __pyx_r = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":317 | |
| * # Split. | |
| * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 | |
| * if abs(mid) > tolerance: # <<<<<<<<<<<<<< | |
| * return False | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":319 | |
| * if abs(mid) > tolerance: | |
| * return False | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<< | |
| * return cubic_farthest_fit_inside( | |
| * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance | |
| */ | |
| __pyx_v_deriv3 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __pyx_v_p2), __pyx_v_p1), __pyx_v_p0), __pyx_t_double_complex_from_parts(0.125, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":320 | |
| * return False | |
| * deriv3 = (p3 + p2 - p1 - p0) * 0.125 | |
| * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<< | |
| * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance | |
| * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) | |
| */ | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0)), __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3), __pyx_v_mid, __pyx_v_tolerance); | |
| if (__pyx_t_4) { | |
| } else { | |
| __pyx_t_3 = __pyx_t_4; | |
| goto __pyx_L7_bool_binop_done; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":322 | |
| * return cubic_farthest_fit_inside( | |
| * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance | |
| * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_mid, __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3), __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0)), __pyx_v_p3, __pyx_v_tolerance); | |
| __pyx_t_3 = __pyx_t_4; | |
| __pyx_L7_bool_binop_done:; | |
| __pyx_r = __pyx_t_3; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":293 | |
| * ) | |
| * @cython.locals(mid=cython.complex, deriv3=cython.complex) | |
| * def cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<< | |
| * """Check if a cubic Bezier lies within a given distance of the origin. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":335 | |
| * c3=cython.complex, | |
| * ) | |
| * def cubic_approx_quadratic(cubic, tolerance): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier with a single quadratic within a given tolerance. | |
| * | |
| */ | |
| static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *__pyx_v_cubic, double __pyx_v_tolerance) { | |
| __pyx_t_double_complex __pyx_v_q1; | |
| __pyx_t_double_complex __pyx_v_c0; | |
| __pyx_t_double_complex __pyx_v_c1; | |
| __pyx_t_double_complex __pyx_v_c2; | |
| __pyx_t_double_complex __pyx_v_c3; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| __pyx_t_double_complex __pyx_t_2; | |
| __pyx_t_double_complex __pyx_t_3; | |
| __pyx_t_double_complex __pyx_t_4; | |
| __pyx_t_double_complex __pyx_t_5; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *__pyx_t_7 = NULL; | |
| PyObject *__pyx_t_8 = NULL; | |
| int __pyx_t_9; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("cubic_approx_quadratic", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":349 | |
| * """ | |
| * | |
| * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) # <<<<<<<<<<<<<< | |
| * if math.isnan(q1.imag): | |
| * return None | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_3 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_v_q1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_t_5); | |
| /* "fontTools/cu2qu/cu2qu.py":350 | |
| * | |
| * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) | |
| * if math.isnan(q1.imag): # <<<<<<<<<<<<<< | |
| * return None | |
| * c0 = cubic[0] | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_math); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isnan); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __pyx_t_6 = PyFloat_FromDouble(__Pyx_CIMAG(__pyx_v_q1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_8 = NULL; | |
| if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { | |
| __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); | |
| if (likely(__pyx_t_8)) { | |
| PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); | |
| __Pyx_INCREF(__pyx_t_8); | |
| __Pyx_INCREF(function); | |
| __Pyx_DECREF_SET(__pyx_t_7, function); | |
| } | |
| } | |
| __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 350, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| if (__pyx_t_9) { | |
| /* "fontTools/cu2qu/cu2qu.py":351 | |
| * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) | |
| * if math.isnan(q1.imag): | |
| * return None # <<<<<<<<<<<<<< | |
| * c0 = cubic[0] | |
| * c3 = cubic[3] | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_r = Py_None; __Pyx_INCREF(Py_None); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":350 | |
| * | |
| * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) | |
| * if math.isnan(q1.imag): # <<<<<<<<<<<<<< | |
| * return None | |
| * c0 = cubic[0] | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":352 | |
| * if math.isnan(q1.imag): | |
| * return None | |
| * c0 = cubic[0] # <<<<<<<<<<<<<< | |
| * c3 = cubic[3] | |
| * c1 = c0 + (q1 - c0) * (2 / 3) | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 352, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_v_c0 = __pyx_t_5; | |
| /* "fontTools/cu2qu/cu2qu.py":353 | |
| * return None | |
| * c0 = cubic[0] | |
| * c3 = cubic[3] # <<<<<<<<<<<<<< | |
| * c1 = c0 + (q1 - c0) * (2 / 3) | |
| * c2 = c3 + (q1 - c3) * (2 / 3) | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 353, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_v_c3 = __pyx_t_5; | |
| /* "fontTools/cu2qu/cu2qu.py":354 | |
| * c0 = cubic[0] | |
| * c3 = cubic[3] | |
| * c1 = c0 + (q1 - c0) * (2 / 3) # <<<<<<<<<<<<<< | |
| * c2 = c3 + (q1 - c3) * (2 / 3) | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): | |
| */ | |
| __pyx_v_c1 = __Pyx_c_sum_double(__pyx_v_c0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))); | |
| /* "fontTools/cu2qu/cu2qu.py":355 | |
| * c3 = cubic[3] | |
| * c1 = c0 + (q1 - c0) * (2 / 3) | |
| * c2 = c3 + (q1 - c3) * (2 / 3) # <<<<<<<<<<<<<< | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): | |
| * return None | |
| */ | |
| __pyx_v_c2 = __Pyx_c_sum_double(__pyx_v_c3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c3), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))); | |
| /* "fontTools/cu2qu/cu2qu.py":356 | |
| * c1 = c0 + (q1 - c0) * (2 / 3) | |
| * c2 = c3 + (q1 - c3) * (2 / 3) | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<< | |
| * return None | |
| * return c0, q1, c3 | |
| */ | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_6 = PyNumber_Subtract(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_v_c2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_1 = PyNumber_Subtract(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_9 = ((!(__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex_from_parts(0, 0), __pyx_t_5, __pyx_t_4, __pyx_t_double_complex_from_parts(0, 0), __pyx_v_tolerance) != 0)) != 0); | |
| if (__pyx_t_9) { | |
| /* "fontTools/cu2qu/cu2qu.py":357 | |
| * c2 = c3 + (q1 - c3) * (2 / 3) | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): | |
| * return None # <<<<<<<<<<<<<< | |
| * return c0, q1, c3 | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_r = Py_None; __Pyx_INCREF(Py_None); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":356 | |
| * c1 = c0 + (q1 - c0) * (2 / 3) | |
| * c2 = c3 + (q1 - c3) * (2 / 3) | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<< | |
| * return None | |
| * return c0, q1, c3 | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":358 | |
| * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): | |
| * return None | |
| * return c0, q1, c3 # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_q1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 358, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_v_c3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 358, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __Pyx_GIVEREF(__pyx_t_1); | |
| PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); | |
| __Pyx_GIVEREF(__pyx_t_7); | |
| PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6); | |
| __pyx_t_1 = 0; | |
| __pyx_t_7 = 0; | |
| __pyx_t_6 = 0; | |
| __pyx_r = __pyx_t_8; | |
| __pyx_t_8 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":335 | |
| * c3=cython.complex, | |
| * ) | |
| * def cubic_approx_quadratic(cubic, tolerance): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier with a single quadratic within a given tolerance. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_XDECREF(__pyx_t_8); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":375 | |
| * d1=cython.complex, | |
| * ) | |
| * def cubic_approx_spline(cubic, n, tolerance, all_quadratic): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *__pyx_v_cubic, int __pyx_v_n, double __pyx_v_tolerance, int __pyx_v_all_quadratic) { | |
| __pyx_t_double_complex __pyx_v_q0; | |
| __pyx_t_double_complex __pyx_v_q1; | |
| __pyx_t_double_complex __pyx_v_next_q1; | |
| __pyx_t_double_complex __pyx_v_q2; | |
| __pyx_t_double_complex __pyx_v_d1; | |
| CYTHON_UNUSED __pyx_t_double_complex __pyx_v_c0; | |
| __pyx_t_double_complex __pyx_v_c1; | |
| __pyx_t_double_complex __pyx_v_c2; | |
| __pyx_t_double_complex __pyx_v_c3; | |
| int __pyx_v_i; | |
| PyObject *__pyx_v_cubics = NULL; | |
| PyObject *__pyx_v_next_cubic = NULL; | |
| PyObject *__pyx_v_spline = NULL; | |
| PyObject *__pyx_v_d0 = NULL; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| int __pyx_t_1; | |
| PyObject *__pyx_t_2 = NULL; | |
| int __pyx_t_3; | |
| __pyx_t_double_complex __pyx_t_4; | |
| __pyx_t_double_complex __pyx_t_5; | |
| __pyx_t_double_complex __pyx_t_6; | |
| __pyx_t_double_complex __pyx_t_7; | |
| PyObject *__pyx_t_8 = NULL; | |
| PyObject *__pyx_t_9 = NULL; | |
| long __pyx_t_10; | |
| long __pyx_t_11; | |
| int __pyx_t_12; | |
| PyObject *__pyx_t_13 = NULL; | |
| PyObject *__pyx_t_14 = NULL; | |
| PyObject *(*__pyx_t_15)(PyObject *); | |
| long __pyx_t_16; | |
| int __pyx_t_17; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("cubic_approx_spline", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":390 | |
| * """ | |
| * | |
| * if n == 1: # <<<<<<<<<<<<<< | |
| * return cubic_approx_quadratic(cubic, tolerance) | |
| * if n == 2 and all_quadratic == False: | |
| */ | |
| __pyx_t_1 = ((__pyx_v_n == 1) != 0); | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":391 | |
| * | |
| * if n == 1: | |
| * return cubic_approx_quadratic(cubic, tolerance) # <<<<<<<<<<<<<< | |
| * if n == 2 and all_quadratic == False: | |
| * return cubic | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(__pyx_v_cubic, __pyx_v_tolerance); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_r = __pyx_t_2; | |
| __pyx_t_2 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":390 | |
| * """ | |
| * | |
| * if n == 1: # <<<<<<<<<<<<<< | |
| * return cubic_approx_quadratic(cubic, tolerance) | |
| * if n == 2 and all_quadratic == False: | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":392 | |
| * if n == 1: | |
| * return cubic_approx_quadratic(cubic, tolerance) | |
| * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<< | |
| * return cubic | |
| * | |
| */ | |
| __pyx_t_3 = ((__pyx_v_n == 2) != 0); | |
| if (__pyx_t_3) { | |
| } else { | |
| __pyx_t_1 = __pyx_t_3; | |
| goto __pyx_L5_bool_binop_done; | |
| } | |
| __pyx_t_3 = ((__pyx_v_all_quadratic == 0) != 0); | |
| __pyx_t_1 = __pyx_t_3; | |
| __pyx_L5_bool_binop_done:; | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":393 | |
| * return cubic_approx_quadratic(cubic, tolerance) | |
| * if n == 2 and all_quadratic == False: | |
| * return cubic # <<<<<<<<<<<<<< | |
| * | |
| * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __Pyx_INCREF(__pyx_v_cubic); | |
| __pyx_r = __pyx_v_cubic; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":392 | |
| * if n == 1: | |
| * return cubic_approx_quadratic(cubic, tolerance) | |
| * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<< | |
| * return cubic | |
| * | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":395 | |
| * return cubic | |
| * | |
| * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) # <<<<<<<<<<<<<< | |
| * | |
| * # calculate the spline of quadratics and check errors at the same time. | |
| */ | |
| __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_8 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 395, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_v_cubics = __pyx_t_8; | |
| __pyx_t_8 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":398 | |
| * | |
| * # calculate the spline of quadratics and check errors at the same time. | |
| * next_cubic = next(cubics) # <<<<<<<<<<<<<< | |
| * next_q1 = cubic_approx_control( | |
| * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| */ | |
| __pyx_t_8 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 398, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_v_next_cubic = __pyx_t_8; | |
| __pyx_t_8 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":400 | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( | |
| * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<< | |
| * ) | |
| * q2 = cubic[0] | |
| */ | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":399 | |
| * # calculate the spline of quadratics and check errors at the same time. | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<< | |
| * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| * ) | |
| */ | |
| __pyx_v_next_q1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(0.0, __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_t_4); | |
| /* "fontTools/cu2qu/cu2qu.py":402 | |
| * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| * ) | |
| * q2 = cubic[0] # <<<<<<<<<<<<<< | |
| * d1 = 0j | |
| * spline = [cubic[0], next_q1] | |
| */ | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 402, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_v_q2 = __pyx_t_4; | |
| /* "fontTools/cu2qu/cu2qu.py":403 | |
| * ) | |
| * q2 = cubic[0] | |
| * d1 = 0j # <<<<<<<<<<<<<< | |
| * spline = [cubic[0], next_q1] | |
| * for i in range(1, n + 1): | |
| */ | |
| __pyx_v_d1 = __pyx_t_double_complex_from_parts(0, 0.0); | |
| /* "fontTools/cu2qu/cu2qu.py":404 | |
| * q2 = cubic[0] | |
| * d1 = 0j | |
| * spline = [cubic[0], next_q1] # <<<<<<<<<<<<<< | |
| * for i in range(1, n + 1): | |
| * # Current cubic to convert | |
| */ | |
| __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 404, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 404, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| __Pyx_GIVEREF(__pyx_t_8); | |
| PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); | |
| __Pyx_GIVEREF(__pyx_t_2); | |
| PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_2); | |
| __pyx_t_8 = 0; | |
| __pyx_t_2 = 0; | |
| __pyx_v_spline = ((PyObject*)__pyx_t_9); | |
| __pyx_t_9 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":405 | |
| * d1 = 0j | |
| * spline = [cubic[0], next_q1] | |
| * for i in range(1, n + 1): # <<<<<<<<<<<<<< | |
| * # Current cubic to convert | |
| * c0, c1, c2, c3 = next_cubic | |
| */ | |
| __pyx_t_10 = (__pyx_v_n + 1); | |
| __pyx_t_11 = __pyx_t_10; | |
| for (__pyx_t_12 = 1; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { | |
| __pyx_v_i = __pyx_t_12; | |
| /* "fontTools/cu2qu/cu2qu.py":407 | |
| * for i in range(1, n + 1): | |
| * # Current cubic to convert | |
| * c0, c1, c2, c3 = next_cubic # <<<<<<<<<<<<<< | |
| * | |
| * # Current quadratic approximation of current cubic | |
| */ | |
| if ((likely(PyTuple_CheckExact(__pyx_v_next_cubic))) || (PyList_CheckExact(__pyx_v_next_cubic))) { | |
| PyObject* sequence = __pyx_v_next_cubic; | |
| Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); | |
| if (unlikely(size != 4)) { | |
| if (size > 4) __Pyx_RaiseTooManyValuesError(4); | |
| else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); | |
| __PYX_ERR(0, 407, __pyx_L1_error) | |
| } | |
| if (likely(PyTuple_CheckExact(sequence))) { | |
| __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); | |
| __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); | |
| __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2); | |
| __pyx_t_13 = PyTuple_GET_ITEM(sequence, 3); | |
| } else { | |
| __pyx_t_9 = PyList_GET_ITEM(sequence, 0); | |
| __pyx_t_2 = PyList_GET_ITEM(sequence, 1); | |
| __pyx_t_8 = PyList_GET_ITEM(sequence, 2); | |
| __pyx_t_13 = PyList_GET_ITEM(sequence, 3); | |
| } | |
| __Pyx_INCREF(__pyx_t_9); | |
| __Pyx_INCREF(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_t_8); | |
| __Pyx_INCREF(__pyx_t_13); | |
| { | |
| Py_ssize_t i; | |
| PyObject** temps[4] = {&__pyx_t_9,&__pyx_t_2,&__pyx_t_8,&__pyx_t_13}; | |
| for (i=0; i < 4; i++) { | |
| PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_GOTREF(item); | |
| *(temps[i]) = item; | |
| } | |
| } | |
| } else { | |
| Py_ssize_t index = -1; | |
| PyObject** temps[4] = {&__pyx_t_9,&__pyx_t_2,&__pyx_t_8,&__pyx_t_13}; | |
| __pyx_t_14 = PyObject_GetIter(__pyx_v_next_cubic); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_14); | |
| __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext; | |
| for (index=0; index < 4; index++) { | |
| PyObject* item = __pyx_t_15(__pyx_t_14); if (unlikely(!item)) goto __pyx_L9_unpacking_failed; | |
| __Pyx_GOTREF(item); | |
| *(temps[index]) = item; | |
| } | |
| if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 4) < 0) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __pyx_t_15 = NULL; | |
| __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; | |
| goto __pyx_L10_unpacking_done; | |
| __pyx_L9_unpacking_failed:; | |
| __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; | |
| __pyx_t_15 = NULL; | |
| if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); | |
| __PYX_ERR(0, 407, __pyx_L1_error) | |
| __pyx_L10_unpacking_done:; | |
| } | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_9); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __pyx_v_c0 = __pyx_t_4; | |
| __pyx_v_c1 = __pyx_t_5; | |
| __pyx_v_c2 = __pyx_t_6; | |
| __pyx_v_c3 = __pyx_t_7; | |
| /* "fontTools/cu2qu/cu2qu.py":410 | |
| * | |
| * # Current quadratic approximation of current cubic | |
| * q0 = q2 # <<<<<<<<<<<<<< | |
| * q1 = next_q1 | |
| * if i < n: | |
| */ | |
| __pyx_v_q0 = __pyx_v_q2; | |
| /* "fontTools/cu2qu/cu2qu.py":411 | |
| * # Current quadratic approximation of current cubic | |
| * q0 = q2 | |
| * q1 = next_q1 # <<<<<<<<<<<<<< | |
| * if i < n: | |
| * next_cubic = next(cubics) | |
| */ | |
| __pyx_v_q1 = __pyx_v_next_q1; | |
| /* "fontTools/cu2qu/cu2qu.py":412 | |
| * q0 = q2 | |
| * q1 = next_q1 | |
| * if i < n: # <<<<<<<<<<<<<< | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( | |
| */ | |
| __pyx_t_1 = ((__pyx_v_i < __pyx_v_n) != 0); | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":413 | |
| * q1 = next_q1 | |
| * if i < n: | |
| * next_cubic = next(cubics) # <<<<<<<<<<<<<< | |
| * next_q1 = cubic_approx_control( | |
| * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| */ | |
| __pyx_t_13 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 413, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __Pyx_DECREF_SET(__pyx_v_next_cubic, __pyx_t_13); | |
| __pyx_t_13 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":415 | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( | |
| * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<< | |
| * ) | |
| * spline.append(next_q1) | |
| */ | |
| __pyx_t_16 = (__pyx_v_n - 1); | |
| if (unlikely(__pyx_t_16 == 0)) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "float division"); | |
| __PYX_ERR(0, 415, __pyx_L1_error) | |
| } | |
| __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_13); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":414 | |
| * if i < n: | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<< | |
| * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| * ) | |
| */ | |
| __pyx_v_next_q1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control((((double)__pyx_v_i) / ((double)__pyx_t_16)), __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_t_4); | |
| /* "fontTools/cu2qu/cu2qu.py":417 | |
| * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] | |
| * ) | |
| * spline.append(next_q1) # <<<<<<<<<<<<<< | |
| * q2 = (q1 + next_q1) * 0.5 | |
| * else: | |
| */ | |
| __pyx_t_13 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 417, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_13); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 417, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":418 | |
| * ) | |
| * spline.append(next_q1) | |
| * q2 = (q1 + next_q1) * 0.5 # <<<<<<<<<<<<<< | |
| * else: | |
| * q2 = c3 | |
| */ | |
| __pyx_v_q2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_q1, __pyx_v_next_q1), __pyx_t_double_complex_from_parts(0.5, 0)); | |
| /* "fontTools/cu2qu/cu2qu.py":412 | |
| * q0 = q2 | |
| * q1 = next_q1 | |
| * if i < n: # <<<<<<<<<<<<<< | |
| * next_cubic = next(cubics) | |
| * next_q1 = cubic_approx_control( | |
| */ | |
| goto __pyx_L11; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":420 | |
| * q2 = (q1 + next_q1) * 0.5 | |
| * else: | |
| * q2 = c3 # <<<<<<<<<<<<<< | |
| * | |
| * # End-point deltas | |
| */ | |
| /*else*/ { | |
| __pyx_v_q2 = __pyx_v_c3; | |
| } | |
| __pyx_L11:; | |
| /* "fontTools/cu2qu/cu2qu.py":423 | |
| * | |
| * # End-point deltas | |
| * d0 = d1 # <<<<<<<<<<<<<< | |
| * d1 = q2 - c3 | |
| * | |
| */ | |
| __pyx_t_13 = __pyx_PyComplex_FromComplex(__pyx_v_d1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 423, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __Pyx_XDECREF_SET(__pyx_v_d0, __pyx_t_13); | |
| __pyx_t_13 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":424 | |
| * # End-point deltas | |
| * d0 = d1 | |
| * d1 = q2 - c3 # <<<<<<<<<<<<<< | |
| * | |
| * if abs(d1) > tolerance or not cubic_farthest_fit_inside( | |
| */ | |
| __pyx_v_d1 = __Pyx_c_diff_double(__pyx_v_q2, __pyx_v_c3); | |
| /* "fontTools/cu2qu/cu2qu.py":426 | |
| * d1 = q2 - c3 | |
| * | |
| * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< | |
| * d0, | |
| * q0 + (q1 - q0) * (2 / 3) - c1, | |
| */ | |
| __pyx_t_3 = ((__Pyx_c_abs_double(__pyx_v_d1) > __pyx_v_tolerance) != 0); | |
| if (!__pyx_t_3) { | |
| } else { | |
| __pyx_t_1 = __pyx_t_3; | |
| goto __pyx_L13_bool_binop_done; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":427 | |
| * | |
| * if abs(d1) > tolerance or not cubic_farthest_fit_inside( | |
| * d0, # <<<<<<<<<<<<<< | |
| * q0 + (q1 - q0) * (2 / 3) - c1, | |
| * q2 + (q1 - q2) * (2 / 3) - c2, | |
| */ | |
| __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_v_d0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":426 | |
| * d1 = q2 - c3 | |
| * | |
| * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< | |
| * d0, | |
| * q0 + (q1 - q0) * (2 / 3) - c1, | |
| */ | |
| __pyx_t_3 = ((!(__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_4, __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c1), __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q2, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q2), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c2), __pyx_v_d1, __pyx_v_tolerance) != 0)) != 0); | |
| __pyx_t_1 = __pyx_t_3; | |
| __pyx_L13_bool_binop_done:; | |
| if (__pyx_t_1) { | |
| /* "fontTools/cu2qu/cu2qu.py":433 | |
| * tolerance, | |
| * ): | |
| * return None # <<<<<<<<<<<<<< | |
| * spline.append(cubic[3]) | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __pyx_r = Py_None; __Pyx_INCREF(Py_None); | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":426 | |
| * d1 = q2 - c3 | |
| * | |
| * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<< | |
| * d0, | |
| * q0 + (q1 - q0) * (2 / 3) - c1, | |
| */ | |
| } | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":434 | |
| * ): | |
| * return None | |
| * spline.append(cubic[3]) # <<<<<<<<<<<<<< | |
| * | |
| * return spline | |
| */ | |
| __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 434, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_13); | |
| __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_13); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 434, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":436 | |
| * spline.append(cubic[3]) | |
| * | |
| * return spline # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| __Pyx_INCREF(__pyx_v_spline); | |
| __pyx_r = __pyx_v_spline; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":375 | |
| * d1=cython.complex, | |
| * ) | |
| * def cubic_approx_spline(cubic, n, tolerance, all_quadratic): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_8); | |
| __Pyx_XDECREF(__pyx_t_9); | |
| __Pyx_XDECREF(__pyx_t_13); | |
| __Pyx_XDECREF(__pyx_t_14); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_spline", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = 0; | |
| __pyx_L0:; | |
| __Pyx_XDECREF(__pyx_v_cubics); | |
| __Pyx_XDECREF(__pyx_v_next_cubic); | |
| __Pyx_XDECREF(__pyx_v_spline); | |
| __Pyx_XDECREF(__pyx_v_d0); | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":442 | |
| * @cython.locals(n=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| /* Python wrapper */ | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ | |
| static char __pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic[] = "curve_to_quadratic(curve, double max_err, int all_quadratic=True)\nApproximate a cubic Bezier curve with a spline of n quadratics.\n\n Args:\n cubic (sequence): Four 2D tuples representing control points of\n the cubic Bezier curve.\n max_err (double): Permitted deviation from the original curve.\n all_quadratic (bool): If True (default) returned value is a\n quadratic spline. If False, it's either a single quadratic\n curve or a single cubic curve.\n\n Returns:\n If all_quadratic is True: A list of 2D tuples, representing\n control points of the quadratic spline if it fits within the\n given tolerance, or ``None`` if no suitable spline could be\n calculated.\n\n If all_quadratic is False: Either a quadratic curve (if length\n of output is 3), or a cubic curve (if length of output is 4).\n "; | |
| static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic = {"curve_to_quadratic", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic}; | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { | |
| PyObject *__pyx_v_curve = 0; | |
| double __pyx_v_max_err; | |
| int __pyx_v_all_quadratic; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| PyObject *__pyx_r = 0; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("curve_to_quadratic (wrapper)", 0); | |
| { | |
| static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_curve,&__pyx_n_s_max_err,&__pyx_n_s_all_quadratic,0}; | |
| PyObject* values[3] = {0,0,0}; | |
| if (unlikely(__pyx_kwds)) { | |
| Py_ssize_t kw_args; | |
| const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); | |
| switch (pos_args) { | |
| case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| CYTHON_FALLTHROUGH; | |
| case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| CYTHON_FALLTHROUGH; | |
| case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| CYTHON_FALLTHROUGH; | |
| case 0: break; | |
| default: goto __pyx_L5_argtuple_error; | |
| } | |
| kw_args = PyDict_Size(__pyx_kwds); | |
| switch (pos_args) { | |
| case 0: | |
| if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_curve)) != 0)) kw_args--; | |
| else goto __pyx_L5_argtuple_error; | |
| CYTHON_FALLTHROUGH; | |
| case 1: | |
| if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_err)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, 1); __PYX_ERR(0, 442, __pyx_L3_error) | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 2: | |
| if (kw_args > 0) { | |
| PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_all_quadratic); | |
| if (value) { values[2] = value; kw_args--; } | |
| } | |
| } | |
| if (unlikely(kw_args > 0)) { | |
| if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "curve_to_quadratic") < 0)) __PYX_ERR(0, 442, __pyx_L3_error) | |
| } | |
| } else { | |
| switch (PyTuple_GET_SIZE(__pyx_args)) { | |
| case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| CYTHON_FALLTHROUGH; | |
| case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| break; | |
| default: goto __pyx_L5_argtuple_error; | |
| } | |
| } | |
| __pyx_v_curve = values[0]; | |
| __pyx_v_max_err = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_err == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L3_error) | |
| if (values[2]) { | |
| __pyx_v_all_quadratic = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L3_error) | |
| } else { | |
| __pyx_v_all_quadratic = ((int)((int)1)); | |
| } | |
| } | |
| goto __pyx_L4_argument_unpacking_done; | |
| __pyx_L5_argtuple_error:; | |
| __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 442, __pyx_L3_error) | |
| __pyx_L3_error:; | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __Pyx_RefNannyFinishContext(); | |
| return NULL; | |
| __pyx_L4_argument_unpacking_done:; | |
| __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(__pyx_self, __pyx_v_curve, __pyx_v_max_err, __pyx_v_all_quadratic); | |
| /* function exit code */ | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic) { | |
| int __pyx_v_n; | |
| PyObject *__pyx_v_spline = NULL; | |
| PyObject *__pyx_7genexpr__pyx_v_p = NULL; | |
| PyObject *__pyx_8genexpr1__pyx_v_s = NULL; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| Py_ssize_t __pyx_t_3; | |
| PyObject *(*__pyx_t_4)(PyObject *); | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| long __pyx_t_7; | |
| long __pyx_t_8; | |
| int __pyx_t_9; | |
| int __pyx_t_10; | |
| int __pyx_t_11; | |
| PyObject *__pyx_t_12 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("curve_to_quadratic", 0); | |
| __Pyx_INCREF(__pyx_v_curve); | |
| /* "fontTools/cu2qu/cu2qu.py":463 | |
| * """ | |
| * | |
| * curve = [complex(*p) for p in curve] # <<<<<<<<<<<<<< | |
| * | |
| * for n in range(1, MAX_N + 1): | |
| */ | |
| { /* enter inner scope */ | |
| __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (likely(PyList_CheckExact(__pyx_v_curve)) || PyTuple_CheckExact(__pyx_v_curve)) { | |
| __pyx_t_2 = __pyx_v_curve; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; | |
| __pyx_t_4 = NULL; | |
| } else { | |
| __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| } | |
| for (;;) { | |
| if (likely(!__pyx_t_4)) { | |
| if (likely(PyList_CheckExact(__pyx_t_2))) { | |
| if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; | |
| __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } else { | |
| if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; | |
| __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } | |
| } else { | |
| __pyx_t_5 = __pyx_t_4(__pyx_t_2); | |
| if (unlikely(!__pyx_t_5)) { | |
| PyObject* exc_type = PyErr_Occurred(); | |
| if (exc_type) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); | |
| else __PYX_ERR(0, 463, __pyx_L5_error) | |
| } | |
| break; | |
| } | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } | |
| __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_p, __pyx_t_5); | |
| __pyx_t_5 = 0; | |
| __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_7genexpr__pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 463, __pyx_L5_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0; | |
| goto __pyx_L8_exit_scope; | |
| __pyx_L5_error:; | |
| __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0; | |
| goto __pyx_L1_error; | |
| __pyx_L8_exit_scope:; | |
| } /* exit inner scope */ | |
| __Pyx_DECREF_SET(__pyx_v_curve, __pyx_t_1); | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":465 | |
| * curve = [complex(*p) for p in curve] | |
| * | |
| * for n in range(1, MAX_N + 1): # <<<<<<<<<<<<<< | |
| * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) | |
| * if spline is not None: | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MAX_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 465, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_8 = __pyx_t_7; | |
| for (__pyx_t_9 = 1; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { | |
| __pyx_v_n = __pyx_t_9; | |
| /* "fontTools/cu2qu/cu2qu.py":466 | |
| * | |
| * for n in range(1, MAX_N + 1): | |
| * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) # <<<<<<<<<<<<<< | |
| * if spline is not None: | |
| * # done. go home | |
| */ | |
| __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_v_curve, __pyx_v_n, __pyx_v_max_err, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2); | |
| __pyx_t_2 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":467 | |
| * for n in range(1, MAX_N + 1): | |
| * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) | |
| * if spline is not None: # <<<<<<<<<<<<<< | |
| * # done. go home | |
| * return [(s.real, s.imag) for s in spline] | |
| */ | |
| __pyx_t_10 = (__pyx_v_spline != Py_None); | |
| __pyx_t_11 = (__pyx_t_10 != 0); | |
| if (__pyx_t_11) { | |
| /* "fontTools/cu2qu/cu2qu.py":469 | |
| * if spline is not None: | |
| * # done. go home | |
| * return [(s.real, s.imag) for s in spline] # <<<<<<<<<<<<<< | |
| * | |
| * raise ApproxNotFoundError(curve) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| { /* enter inner scope */ | |
| __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (likely(PyList_CheckExact(__pyx_v_spline)) || PyTuple_CheckExact(__pyx_v_spline)) { | |
| __pyx_t_1 = __pyx_v_spline; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; | |
| __pyx_t_4 = NULL; | |
| } else { | |
| __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_spline); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| } | |
| for (;;) { | |
| if (likely(!__pyx_t_4)) { | |
| if (likely(PyList_CheckExact(__pyx_t_1))) { | |
| if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; | |
| __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| } else { | |
| if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; | |
| __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| } | |
| } else { | |
| __pyx_t_6 = __pyx_t_4(__pyx_t_1); | |
| if (unlikely(!__pyx_t_6)) { | |
| PyObject* exc_type = PyErr_Occurred(); | |
| if (exc_type) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); | |
| else __PYX_ERR(0, 469, __pyx_L14_error) | |
| } | |
| break; | |
| } | |
| __Pyx_GOTREF(__pyx_t_6); | |
| } | |
| __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_s, __pyx_t_6); | |
| __pyx_t_6 = 0; | |
| __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_n_s_real); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_n_s_imag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_GOTREF(__pyx_t_12); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); | |
| __Pyx_GIVEREF(__pyx_t_5); | |
| PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_5); | |
| __pyx_t_6 = 0; | |
| __pyx_t_5 = 0; | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 469, __pyx_L14_error) | |
| __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0; | |
| goto __pyx_L17_exit_scope; | |
| __pyx_L14_error:; | |
| __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0; | |
| goto __pyx_L1_error; | |
| __pyx_L17_exit_scope:; | |
| } /* exit inner scope */ | |
| __pyx_r = __pyx_t_2; | |
| __pyx_t_2 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":467 | |
| * for n in range(1, MAX_N + 1): | |
| * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) | |
| * if spline is not None: # <<<<<<<<<<<<<< | |
| * # done. go home | |
| * return [(s.real, s.imag) for s in spline] | |
| */ | |
| } | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":471 | |
| * return [(s.real, s.imag) for s in spline] | |
| * | |
| * raise ApproxNotFoundError(curve) # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_12 = NULL; | |
| if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { | |
| __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); | |
| if (likely(__pyx_t_12)) { | |
| PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); | |
| __Pyx_INCREF(__pyx_t_12); | |
| __Pyx_INCREF(function); | |
| __Pyx_DECREF_SET(__pyx_t_1, function); | |
| } | |
| } | |
| __pyx_t_2 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_v_curve) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_curve); | |
| __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; | |
| if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_Raise(__pyx_t_2, 0, 0, 0); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __PYX_ERR(0, 471, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":442 | |
| * @cython.locals(n=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_12); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = NULL; | |
| __pyx_L0:; | |
| __Pyx_XDECREF(__pyx_v_spline); | |
| __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); | |
| __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); | |
| __Pyx_XDECREF(__pyx_v_curve); | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":476 | |
| * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Return quadratic Bezier splines approximating the input cubic Beziers. | |
| * | |
| */ | |
| /* Python wrapper */ | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ | |
| static char __pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic[] = "curves_to_quadratic(curves, max_errors, int all_quadratic=True)\nReturn quadratic Bezier splines approximating the input cubic Beziers.\n\n Args:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\n Example::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\n The returned splines have \"implied oncurve points\" suitable for use in\n TrueType ``glif`` outlines - i.e. in the first spline returned above,\n the first quadratic segment runs from (50,50) to\n ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\n Returns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\n Raises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.\n "; | |
| static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic = {"curves_to_quadratic", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic}; | |
| static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { | |
| PyObject *__pyx_v_curves = 0; | |
| PyObject *__pyx_v_max_errors = 0; | |
| int __pyx_v_all_quadratic; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| PyObject *__pyx_r = 0; | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("curves_to_quadratic (wrapper)", 0); | |
| { | |
| static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_curves,&__pyx_n_s_max_errors,&__pyx_n_s_all_quadratic,0}; | |
| PyObject* values[3] = {0,0,0}; | |
| if (unlikely(__pyx_kwds)) { | |
| Py_ssize_t kw_args; | |
| const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); | |
| switch (pos_args) { | |
| case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| CYTHON_FALLTHROUGH; | |
| case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| CYTHON_FALLTHROUGH; | |
| case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| CYTHON_FALLTHROUGH; | |
| case 0: break; | |
| default: goto __pyx_L5_argtuple_error; | |
| } | |
| kw_args = PyDict_Size(__pyx_kwds); | |
| switch (pos_args) { | |
| case 0: | |
| if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_curves)) != 0)) kw_args--; | |
| else goto __pyx_L5_argtuple_error; | |
| CYTHON_FALLTHROUGH; | |
| case 1: | |
| if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_errors)) != 0)) kw_args--; | |
| else { | |
| __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, 1); __PYX_ERR(0, 476, __pyx_L3_error) | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 2: | |
| if (kw_args > 0) { | |
| PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_all_quadratic); | |
| if (value) { values[2] = value; kw_args--; } | |
| } | |
| } | |
| if (unlikely(kw_args > 0)) { | |
| if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "curves_to_quadratic") < 0)) __PYX_ERR(0, 476, __pyx_L3_error) | |
| } | |
| } else { | |
| switch (PyTuple_GET_SIZE(__pyx_args)) { | |
| case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); | |
| CYTHON_FALLTHROUGH; | |
| case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); | |
| values[0] = PyTuple_GET_ITEM(__pyx_args, 0); | |
| break; | |
| default: goto __pyx_L5_argtuple_error; | |
| } | |
| } | |
| __pyx_v_curves = values[0]; | |
| __pyx_v_max_errors = values[1]; | |
| if (values[2]) { | |
| __pyx_v_all_quadratic = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 476, __pyx_L3_error) | |
| } else { | |
| __pyx_v_all_quadratic = ((int)((int)1)); | |
| } | |
| } | |
| goto __pyx_L4_argument_unpacking_done; | |
| __pyx_L5_argtuple_error:; | |
| __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 476, __pyx_L3_error) | |
| __pyx_L3_error:; | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __Pyx_RefNannyFinishContext(); | |
| return NULL; | |
| __pyx_L4_argument_unpacking_done:; | |
| __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(__pyx_self, __pyx_v_curves, __pyx_v_max_errors, __pyx_v_all_quadratic); | |
| /* function exit code */ | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic) { | |
| int __pyx_v_l; | |
| int __pyx_v_last_i; | |
| int __pyx_v_i; | |
| PyObject *__pyx_v_splines = NULL; | |
| PyObject *__pyx_v_n = NULL; | |
| PyObject *__pyx_v_spline = NULL; | |
| PyObject *__pyx_8genexpr2__pyx_v_curve = NULL; | |
| PyObject *__pyx_8genexpr3__pyx_v_p = NULL; | |
| PyObject *__pyx_8genexpr4__pyx_v_spline = NULL; | |
| PyObject *__pyx_8genexpr5__pyx_v_s = NULL; | |
| PyObject *__pyx_r = NULL; | |
| __Pyx_RefNannyDeclarations | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| Py_ssize_t __pyx_t_3; | |
| PyObject *(*__pyx_t_4)(PyObject *); | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| Py_ssize_t __pyx_t_7; | |
| PyObject *(*__pyx_t_8)(PyObject *); | |
| PyObject *__pyx_t_9 = NULL; | |
| PyObject *__pyx_t_10 = NULL; | |
| int __pyx_t_11; | |
| double __pyx_t_12; | |
| int __pyx_t_13; | |
| int __pyx_t_14; | |
| long __pyx_t_15; | |
| PyObject *__pyx_t_16 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("curves_to_quadratic", 0); | |
| __Pyx_INCREF(__pyx_v_curves); | |
| /* "fontTools/cu2qu/cu2qu.py":513 | |
| * """ | |
| * | |
| * curves = [[complex(*p) for p in curve] for curve in curves] # <<<<<<<<<<<<<< | |
| * assert len(max_errors) == len(curves) | |
| * | |
| */ | |
| { /* enter inner scope */ | |
| __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) { | |
| __pyx_t_2 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; | |
| __pyx_t_4 = NULL; | |
| } else { | |
| __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| } | |
| for (;;) { | |
| if (likely(!__pyx_t_4)) { | |
| if (likely(PyList_CheckExact(__pyx_t_2))) { | |
| if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; | |
| __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } else { | |
| if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; | |
| __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } | |
| } else { | |
| __pyx_t_5 = __pyx_t_4(__pyx_t_2); | |
| if (unlikely(!__pyx_t_5)) { | |
| PyObject* exc_type = PyErr_Occurred(); | |
| if (exc_type) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); | |
| else __PYX_ERR(0, 513, __pyx_L5_error) | |
| } | |
| break; | |
| } | |
| __Pyx_GOTREF(__pyx_t_5); | |
| } | |
| __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_curve, __pyx_t_5); | |
| __pyx_t_5 = 0; | |
| { /* enter inner scope */ | |
| __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (likely(PyList_CheckExact(__pyx_8genexpr2__pyx_v_curve)) || PyTuple_CheckExact(__pyx_8genexpr2__pyx_v_curve)) { | |
| __pyx_t_6 = __pyx_8genexpr2__pyx_v_curve; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; | |
| __pyx_t_8 = NULL; | |
| } else { | |
| __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr2__pyx_v_curve); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| } | |
| for (;;) { | |
| if (likely(!__pyx_t_8)) { | |
| if (likely(PyList_CheckExact(__pyx_t_6))) { | |
| if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break; | |
| __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| } else { | |
| if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break; | |
| __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| } | |
| } else { | |
| __pyx_t_9 = __pyx_t_8(__pyx_t_6); | |
| if (unlikely(!__pyx_t_9)) { | |
| PyObject* exc_type = PyErr_Occurred(); | |
| if (exc_type) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); | |
| else __PYX_ERR(0, 513, __pyx_L10_error) | |
| } | |
| break; | |
| } | |
| __Pyx_GOTREF(__pyx_t_9); | |
| } | |
| __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_p, __pyx_t_9); | |
| __pyx_t_9 = 0; | |
| __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_8genexpr3__pyx_v_p); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 513, __pyx_L10_error) | |
| __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0; | |
| goto __pyx_L13_exit_scope; | |
| __pyx_L10_error:; | |
| __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0; | |
| goto __pyx_L5_error; | |
| __pyx_L13_exit_scope:; | |
| } /* exit inner scope */ | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 513, __pyx_L5_error) | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0; | |
| goto __pyx_L14_exit_scope; | |
| __pyx_L5_error:; | |
| __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0; | |
| goto __pyx_L1_error; | |
| __pyx_L14_exit_scope:; | |
| } /* exit inner scope */ | |
| __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_1); | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":514 | |
| * | |
| * curves = [[complex(*p) for p in curve] for curve in curves] | |
| * assert len(max_errors) == len(curves) # <<<<<<<<<<<<<< | |
| * | |
| * l = len(curves) | |
| */ | |
| if (unlikely(!Py_OptimizeFlag)) { | |
| __pyx_t_3 = PyObject_Length(__pyx_v_max_errors); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 514, __pyx_L1_error) | |
| __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 514, __pyx_L1_error) | |
| if (unlikely(!((__pyx_t_3 == __pyx_t_7) != 0))) { | |
| PyErr_SetNone(PyExc_AssertionError); | |
| __PYX_ERR(0, 514, __pyx_L1_error) | |
| } | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":516 | |
| * assert len(max_errors) == len(curves) | |
| * | |
| * l = len(curves) # <<<<<<<<<<<<<< | |
| * splines = [None] * l | |
| * last_i = i = 0 | |
| */ | |
| __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 516, __pyx_L1_error) | |
| __pyx_v_l = __pyx_t_7; | |
| /* "fontTools/cu2qu/cu2qu.py":517 | |
| * | |
| * l = len(curves) | |
| * splines = [None] * l # <<<<<<<<<<<<<< | |
| * last_i = i = 0 | |
| * n = 1 | |
| */ | |
| __pyx_t_1 = PyList_New(1 * ((__pyx_v_l<0) ? 0:__pyx_v_l)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| { Py_ssize_t __pyx_temp; | |
| for (__pyx_temp=0; __pyx_temp < __pyx_v_l; __pyx_temp++) { | |
| __Pyx_INCREF(Py_None); | |
| __Pyx_GIVEREF(Py_None); | |
| PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None); | |
| } | |
| } | |
| __pyx_v_splines = ((PyObject*)__pyx_t_1); | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":518 | |
| * l = len(curves) | |
| * splines = [None] * l | |
| * last_i = i = 0 # <<<<<<<<<<<<<< | |
| * n = 1 | |
| * while True: | |
| */ | |
| __pyx_v_last_i = 0; | |
| __pyx_v_i = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":519 | |
| * splines = [None] * l | |
| * last_i = i = 0 | |
| * n = 1 # <<<<<<<<<<<<<< | |
| * while True: | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| */ | |
| __Pyx_INCREF(__pyx_int_1); | |
| __pyx_v_n = __pyx_int_1; | |
| /* "fontTools/cu2qu/cu2qu.py":520 | |
| * last_i = i = 0 | |
| * n = 1 | |
| * while True: # <<<<<<<<<<<<<< | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| * if spline is None: | |
| */ | |
| while (1) { | |
| /* "fontTools/cu2qu/cu2qu.py":521 | |
| * n = 1 | |
| * while True: | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) # <<<<<<<<<<<<<< | |
| * if spline is None: | |
| * if n == MAX_N: | |
| */ | |
| __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 521, __pyx_L1_error) | |
| __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_max_errors, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 521, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_t_1, __pyx_t_11, __pyx_t_12, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2); | |
| __pyx_t_2 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":522 | |
| * while True: | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| * if spline is None: # <<<<<<<<<<<<<< | |
| * if n == MAX_N: | |
| * break | |
| */ | |
| __pyx_t_13 = (__pyx_v_spline == Py_None); | |
| __pyx_t_14 = (__pyx_t_13 != 0); | |
| if (__pyx_t_14) { | |
| /* "fontTools/cu2qu/cu2qu.py":523 | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| * if spline is None: | |
| * if n == MAX_N: # <<<<<<<<<<<<<< | |
| * break | |
| * n += 1 | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MAX_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_1 = PyObject_RichCompare(__pyx_v_n, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 523, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| if (__pyx_t_14) { | |
| /* "fontTools/cu2qu/cu2qu.py":524 | |
| * if spline is None: | |
| * if n == MAX_N: | |
| * break # <<<<<<<<<<<<<< | |
| * n += 1 | |
| * last_i = i | |
| */ | |
| goto __pyx_L16_break; | |
| /* "fontTools/cu2qu/cu2qu.py":523 | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| * if spline is None: | |
| * if n == MAX_N: # <<<<<<<<<<<<<< | |
| * break | |
| * n += 1 | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":525 | |
| * if n == MAX_N: | |
| * break | |
| * n += 1 # <<<<<<<<<<<<<< | |
| * last_i = i | |
| * continue | |
| */ | |
| __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_n, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_1); | |
| __pyx_t_1 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":526 | |
| * break | |
| * n += 1 | |
| * last_i = i # <<<<<<<<<<<<<< | |
| * continue | |
| * splines[i] = spline | |
| */ | |
| __pyx_v_last_i = __pyx_v_i; | |
| /* "fontTools/cu2qu/cu2qu.py":527 | |
| * n += 1 | |
| * last_i = i | |
| * continue # <<<<<<<<<<<<<< | |
| * splines[i] = spline | |
| * i = (i + 1) % l | |
| */ | |
| goto __pyx_L15_continue; | |
| /* "fontTools/cu2qu/cu2qu.py":522 | |
| * while True: | |
| * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) | |
| * if spline is None: # <<<<<<<<<<<<<< | |
| * if n == MAX_N: | |
| * break | |
| */ | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":528 | |
| * last_i = i | |
| * continue | |
| * splines[i] = spline # <<<<<<<<<<<<<< | |
| * i = (i + 1) % l | |
| * if i == last_i: | |
| */ | |
| if (unlikely(__Pyx_SetItemInt(__pyx_v_splines, __pyx_v_i, __pyx_v_spline, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 528, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":529 | |
| * continue | |
| * splines[i] = spline | |
| * i = (i + 1) % l # <<<<<<<<<<<<<< | |
| * if i == last_i: | |
| * # done. go home | |
| */ | |
| __pyx_t_15 = (__pyx_v_i + 1); | |
| if (unlikely(__pyx_v_l == 0)) { | |
| PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); | |
| __PYX_ERR(0, 529, __pyx_L1_error) | |
| } | |
| __pyx_v_i = __Pyx_mod_long(__pyx_t_15, __pyx_v_l); | |
| /* "fontTools/cu2qu/cu2qu.py":530 | |
| * splines[i] = spline | |
| * i = (i + 1) % l | |
| * if i == last_i: # <<<<<<<<<<<<<< | |
| * # done. go home | |
| * return [[(s.real, s.imag) for s in spline] for spline in splines] | |
| */ | |
| __pyx_t_14 = ((__pyx_v_i == __pyx_v_last_i) != 0); | |
| if (__pyx_t_14) { | |
| /* "fontTools/cu2qu/cu2qu.py":532 | |
| * if i == last_i: | |
| * # done. go home | |
| * return [[(s.real, s.imag) for s in spline] for spline in splines] # <<<<<<<<<<<<<< | |
| * | |
| * raise ApproxNotFoundError(curves) | |
| */ | |
| __Pyx_XDECREF(__pyx_r); | |
| { /* enter inner scope */ | |
| __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L22_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __pyx_t_2 = __pyx_v_splines; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; | |
| for (;;) { | |
| if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break; | |
| __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 532, __pyx_L22_error) | |
| __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L22_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_spline, __pyx_t_5); | |
| __pyx_t_5 = 0; | |
| { /* enter inner scope */ | |
| __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (likely(PyList_CheckExact(__pyx_8genexpr4__pyx_v_spline)) || PyTuple_CheckExact(__pyx_8genexpr4__pyx_v_spline)) { | |
| __pyx_t_6 = __pyx_8genexpr4__pyx_v_spline; __Pyx_INCREF(__pyx_t_6); __pyx_t_3 = 0; | |
| __pyx_t_4 = NULL; | |
| } else { | |
| __pyx_t_3 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr4__pyx_v_spline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_4 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| } | |
| for (;;) { | |
| if (likely(!__pyx_t_4)) { | |
| if (likely(PyList_CheckExact(__pyx_t_6))) { | |
| if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_6)) break; | |
| __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_10); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| } else { | |
| if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_6)) break; | |
| __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_10); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| } | |
| } else { | |
| __pyx_t_10 = __pyx_t_4(__pyx_t_6); | |
| if (unlikely(!__pyx_t_10)) { | |
| PyObject* exc_type = PyErr_Occurred(); | |
| if (exc_type) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); | |
| else __PYX_ERR(0, 532, __pyx_L27_error) | |
| } | |
| break; | |
| } | |
| __Pyx_GOTREF(__pyx_t_10); | |
| } | |
| __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_s, __pyx_t_10); | |
| __pyx_t_10 = 0; | |
| __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_n_s_real); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_10); | |
| __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_n_s_imag); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_GOTREF(__pyx_t_16); | |
| __Pyx_GIVEREF(__pyx_t_10); | |
| PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_10); | |
| __Pyx_GIVEREF(__pyx_t_9); | |
| PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_9); | |
| __pyx_t_10 = 0; | |
| __pyx_t_9 = 0; | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_16))) __PYX_ERR(0, 532, __pyx_L27_error) | |
| __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0; | |
| goto __pyx_L30_exit_scope; | |
| __pyx_L27_error:; | |
| __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0; | |
| goto __pyx_L22_error; | |
| __pyx_L30_exit_scope:; | |
| } /* exit inner scope */ | |
| if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 532, __pyx_L22_error) | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| } | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0; | |
| goto __pyx_L31_exit_scope; | |
| __pyx_L22_error:; | |
| __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0; | |
| goto __pyx_L1_error; | |
| __pyx_L31_exit_scope:; | |
| } /* exit inner scope */ | |
| __pyx_r = __pyx_t_1; | |
| __pyx_t_1 = 0; | |
| goto __pyx_L0; | |
| /* "fontTools/cu2qu/cu2qu.py":530 | |
| * splines[i] = spline | |
| * i = (i + 1) % l | |
| * if i == last_i: # <<<<<<<<<<<<<< | |
| * # done. go home | |
| * return [[(s.real, s.imag) for s in spline] for spline in splines] | |
| */ | |
| } | |
| __pyx_L15_continue:; | |
| } | |
| __pyx_L16_break:; | |
| /* "fontTools/cu2qu/cu2qu.py":534 | |
| * return [[(s.real, s.imag) for s in spline] for spline in splines] | |
| * | |
| * raise ApproxNotFoundError(curves) # <<<<<<<<<<<<<< | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_5 = NULL; | |
| if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { | |
| __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); | |
| if (likely(__pyx_t_5)) { | |
| PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); | |
| __Pyx_INCREF(__pyx_t_5); | |
| __Pyx_INCREF(function); | |
| __Pyx_DECREF_SET(__pyx_t_2, function); | |
| } | |
| } | |
| __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_v_curves) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_curves); | |
| __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_1); | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_Raise(__pyx_t_1, 0, 0, 0); | |
| __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __PYX_ERR(0, 534, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":476 | |
| * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Return quadratic Bezier splines approximating the input cubic Beziers. | |
| * | |
| */ | |
| /* function exit code */ | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_1); | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_9); | |
| __Pyx_XDECREF(__pyx_t_10); | |
| __Pyx_XDECREF(__pyx_t_16); | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| __pyx_r = NULL; | |
| __pyx_L0:; | |
| __Pyx_XDECREF(__pyx_v_splines); | |
| __Pyx_XDECREF(__pyx_v_n); | |
| __Pyx_XDECREF(__pyx_v_spline); | |
| __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); | |
| __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); | |
| __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); | |
| __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); | |
| __Pyx_XDECREF(__pyx_v_curves); | |
| __Pyx_XGIVEREF(__pyx_r); | |
| __Pyx_RefNannyFinishContext(); | |
| return __pyx_r; | |
| } | |
| static struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[8]; | |
| static int __pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = 0; | |
| static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { | |
| PyObject *o; | |
| if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)))) { | |
| o = (PyObject*)__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[--__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen]; | |
| memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)); | |
| (void) PyObject_INIT(o, t); | |
| } else { | |
| o = (*t->tp_alloc)(t, 0); | |
| if (unlikely(!o)) return 0; | |
| } | |
| return o; | |
| } | |
| static void __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyObject *o) { | |
| if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)))) { | |
| __pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen++] = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)o); | |
| } else { | |
| (*Py_TYPE(o)->tp_free)(o); | |
| } | |
| } | |
| static PyTypeObject __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = { | |
| PyVarObject_HEAD_INIT(0, 0) | |
| "fontTools.cu2qu.cu2qu.__pyx_scope_struct___split_cubic_into_n_gen", /*tp_name*/ | |
| sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen), /*tp_basicsize*/ | |
| 0, /*tp_itemsize*/ | |
| __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_dealloc*/ | |
| 0, /*tp_print*/ | |
| 0, /*tp_vectorcall_offset*/ | |
| 0, /*tp_getattr*/ | |
| 0, /*tp_setattr*/ | |
| 0, /*tp_compare*/ | |
| 0, /*tp_as_async*/ | |
| 0, /*tp_repr*/ | |
| 0, /*tp_as_number*/ | |
| 0, /*tp_as_sequence*/ | |
| 0, /*tp_as_mapping*/ | |
| 0, /*tp_hash*/ | |
| 0, /*tp_call*/ | |
| 0, /*tp_str*/ | |
| 0, /*tp_getattro*/ | |
| 0, /*tp_setattro*/ | |
| 0, /*tp_as_buffer*/ | |
| Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ | |
| 0, /*tp_doc*/ | |
| 0, /*tp_traverse*/ | |
| 0, /*tp_clear*/ | |
| 0, /*tp_richcompare*/ | |
| 0, /*tp_weaklistoffset*/ | |
| 0, /*tp_iter*/ | |
| 0, /*tp_iternext*/ | |
| 0, /*tp_methods*/ | |
| 0, /*tp_members*/ | |
| 0, /*tp_getset*/ | |
| 0, /*tp_base*/ | |
| 0, /*tp_dict*/ | |
| 0, /*tp_descr_get*/ | |
| 0, /*tp_descr_set*/ | |
| 0, /*tp_dictoffset*/ | |
| 0, /*tp_init*/ | |
| 0, /*tp_alloc*/ | |
| __pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_new*/ | |
| 0, /*tp_free*/ | |
| 0, /*tp_is_gc*/ | |
| 0, /*tp_bases*/ | |
| 0, /*tp_mro*/ | |
| 0, /*tp_cache*/ | |
| 0, /*tp_subclasses*/ | |
| 0, /*tp_weaklist*/ | |
| 0, /*tp_del*/ | |
| 0, /*tp_version_tag*/ | |
| 0, /*tp_finalize*/ | |
| 0, /*tp_vectorcall*/ | |
| 0, /*tp_print*/ | |
| 0, /*tp_pypy_flags*/ | |
| }; | |
| static PyMethodDef __pyx_methods[] = { | |
| {0, 0, 0, 0} | |
| }; | |
| static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ | |
| static int __pyx_pymod_exec_cu2qu(PyObject* module); /*proto*/ | |
| static PyModuleDef_Slot __pyx_moduledef_slots[] = { | |
| {Py_mod_create, (void*)__pyx_pymod_create}, | |
| {Py_mod_exec, (void*)__pyx_pymod_exec_cu2qu}, | |
| {0, NULL} | |
| }; | |
| static struct PyModuleDef __pyx_moduledef = { | |
| PyModuleDef_HEAD_INIT, | |
| "cu2qu", | |
| 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_ApproxNotFoundError, __pyx_k_ApproxNotFoundError, sizeof(__pyx_k_ApproxNotFoundError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_COMPILED, __pyx_k_COMPILED, sizeof(__pyx_k_COMPILED), 0, 0, 1, 1}, | |
| {&__pyx_n_s_Cu2QuError, __pyx_k_Cu2QuError, sizeof(__pyx_k_Cu2QuError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_Error, __pyx_k_Error, sizeof(__pyx_k_Error), 0, 0, 1, 1}, | |
| {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, | |
| {&__pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_k_Lib_fontTools_cu2qu_cu2qu_py, sizeof(__pyx_k_Lib_fontTools_cu2qu_cu2qu_py), 0, 0, 1, 0}, | |
| {&__pyx_n_s_MAX_N, __pyx_k_MAX_N, sizeof(__pyx_k_MAX_N), 0, 0, 1, 1}, | |
| {&__pyx_n_s_NAN, __pyx_k_NAN, sizeof(__pyx_k_NAN), 0, 0, 1, 1}, | |
| {&__pyx_n_u_NaN, __pyx_k_NaN, sizeof(__pyx_k_NaN), 0, 1, 0, 1}, | |
| {&__pyx_kp_u_Return_quadratic_Bezier_splines, __pyx_k_Return_quadratic_Bezier_splines, sizeof(__pyx_k_Return_quadratic_Bezier_splines), 0, 1, 0, 0}, | |
| {&__pyx_n_s_ZeroDivisionError, __pyx_k_ZeroDivisionError, sizeof(__pyx_k_ZeroDivisionError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, | |
| {&__pyx_n_s_a1, __pyx_k_a1, sizeof(__pyx_k_a1), 0, 0, 1, 1}, | |
| {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, | |
| {&__pyx_n_s_all_quadratic, __pyx_k_all_quadratic, sizeof(__pyx_k_all_quadratic), 0, 0, 1, 1}, | |
| {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, | |
| {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1}, | |
| {&__pyx_n_s_b1, __pyx_k_b1, sizeof(__pyx_k_b1), 0, 0, 1, 1}, | |
| {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, | |
| {&__pyx_n_s_c1, __pyx_k_c1, sizeof(__pyx_k_c1), 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_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, | |
| {&__pyx_n_s_curve, __pyx_k_curve, sizeof(__pyx_k_curve), 0, 0, 1, 1}, | |
| {&__pyx_n_s_curve_to_quadratic, __pyx_k_curve_to_quadratic, sizeof(__pyx_k_curve_to_quadratic), 0, 0, 1, 1}, | |
| {&__pyx_n_u_curve_to_quadratic, __pyx_k_curve_to_quadratic, sizeof(__pyx_k_curve_to_quadratic), 0, 1, 0, 1}, | |
| {&__pyx_n_s_curves, __pyx_k_curves, sizeof(__pyx_k_curves), 0, 0, 1, 1}, | |
| {&__pyx_n_s_curves_to_quadratic, __pyx_k_curves_to_quadratic, sizeof(__pyx_k_curves_to_quadratic), 0, 0, 1, 1}, | |
| {&__pyx_n_u_curves_to_quadratic, __pyx_k_curves_to_quadratic, sizeof(__pyx_k_curves_to_quadratic), 0, 1, 0, 1}, | |
| {&__pyx_kp_u_curves_to_quadratic_line_476, __pyx_k_curves_to_quadratic_line_476, sizeof(__pyx_k_curves_to_quadratic_line_476), 0, 1, 0, 0}, | |
| {&__pyx_n_s_cython, __pyx_k_cython, sizeof(__pyx_k_cython), 0, 0, 1, 1}, | |
| {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, | |
| {&__pyx_n_s_d1, __pyx_k_d1, sizeof(__pyx_k_d1), 0, 0, 1, 1}, | |
| {&__pyx_n_s_delta_2, __pyx_k_delta_2, sizeof(__pyx_k_delta_2), 0, 0, 1, 1}, | |
| {&__pyx_n_s_delta_3, __pyx_k_delta_3, sizeof(__pyx_k_delta_3), 0, 0, 1, 1}, | |
| {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, | |
| {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1}, | |
| {&__pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_k_fontTools_cu2qu_cu2qu, sizeof(__pyx_k_fontTools_cu2qu_cu2qu), 0, 0, 1, 1}, | |
| {&__pyx_n_s_fontTools_misc, __pyx_k_fontTools_misc, sizeof(__pyx_k_fontTools_misc), 0, 0, 1, 1}, | |
| {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, | |
| {&__pyx_n_s_imag, __pyx_k_imag, sizeof(__pyx_k_imag), 0, 0, 1, 1}, | |
| {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, | |
| {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1}, | |
| {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1}, | |
| {&__pyx_n_s_last_i, __pyx_k_last_i, sizeof(__pyx_k_last_i), 0, 0, 1, 1}, | |
| {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, | |
| {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1}, | |
| {&__pyx_n_s_max_err, __pyx_k_max_err, sizeof(__pyx_k_max_err), 0, 0, 1, 1}, | |
| {&__pyx_n_s_max_errors, __pyx_k_max_errors, sizeof(__pyx_k_max_errors), 0, 0, 1, 1}, | |
| {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, | |
| {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, | |
| {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1}, | |
| {&__pyx_n_s_p0, __pyx_k_p0, sizeof(__pyx_k_p0), 0, 0, 1, 1}, | |
| {&__pyx_n_s_p1, __pyx_k_p1, sizeof(__pyx_k_p1), 0, 0, 1, 1}, | |
| {&__pyx_n_s_p2, __pyx_k_p2, sizeof(__pyx_k_p2), 0, 0, 1, 1}, | |
| {&__pyx_n_s_p3, __pyx_k_p3, sizeof(__pyx_k_p3), 0, 0, 1, 1}, | |
| {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, | |
| {&__pyx_n_s_real, __pyx_k_real, sizeof(__pyx_k_real), 0, 0, 1, 1}, | |
| {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, | |
| {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, | |
| {&__pyx_n_s_spline, __pyx_k_spline, sizeof(__pyx_k_spline), 0, 0, 1, 1}, | |
| {&__pyx_n_s_splines, __pyx_k_splines, sizeof(__pyx_k_splines), 0, 0, 1, 1}, | |
| {&__pyx_n_s_split_cubic_into_n_gen, __pyx_k_split_cubic_into_n_gen, sizeof(__pyx_k_split_cubic_into_n_gen), 0, 0, 1, 1}, | |
| {&__pyx_n_s_t1, __pyx_k_t1, sizeof(__pyx_k_t1), 0, 0, 1, 1}, | |
| {&__pyx_n_s_t1_2, __pyx_k_t1_2, sizeof(__pyx_k_t1_2), 0, 0, 1, 1}, | |
| {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, | |
| {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, | |
| {0, 0, 0, 0, 0, 0, 0} | |
| }; | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { | |
| __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 22, __pyx_L1_error) | |
| __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 22, __pyx_L1_error) | |
| __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 146, __pyx_L1_error) | |
| __pyx_builtin_ZeroDivisionError = __Pyx_GetBuiltinName(__pyx_n_s_ZeroDivisionError); if (!__pyx_builtin_ZeroDivisionError) __PYX_ERR(0, 278, __pyx_L1_error) | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); | |
| /* "fontTools/cu2qu/cu2qu.py":141 | |
| * a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| */ | |
| __pyx_tuple__2 = PyTuple_Pack(19, __pyx_n_s_p0, __pyx_n_s_p1, __pyx_n_s_p2, __pyx_n_s_p3, __pyx_n_s_n, __pyx_n_s_a1, __pyx_n_s_b1, __pyx_n_s_c1, __pyx_n_s_d1, __pyx_n_s_dt, __pyx_n_s_delta_2, __pyx_n_s_delta_3, __pyx_n_s_i, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_c, __pyx_n_s_d, __pyx_n_s_t1, __pyx_n_s_t1_2); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 141, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_tuple__2); | |
| __Pyx_GIVEREF(__pyx_tuple__2); | |
| __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(5, 0, 19, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_split_cubic_into_n_gen, 141, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 141, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":442 | |
| * @cython.locals(n=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| __pyx_tuple__3 = PyTuple_Pack(7, __pyx_n_s_curve, __pyx_n_s_max_err, __pyx_n_s_all_quadratic, __pyx_n_s_n, __pyx_n_s_spline, __pyx_n_s_p, __pyx_n_s_s); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 442, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_tuple__3); | |
| __Pyx_GIVEREF(__pyx_tuple__3); | |
| __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_curve_to_quadratic, 442, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 442, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":476 | |
| * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Return quadratic Bezier splines approximating the input cubic Beziers. | |
| * | |
| */ | |
| __pyx_tuple__5 = PyTuple_Pack(13, __pyx_n_s_curves, __pyx_n_s_max_errors, __pyx_n_s_all_quadratic, __pyx_n_s_l, __pyx_n_s_last_i, __pyx_n_s_i, __pyx_n_s_splines, __pyx_n_s_n, __pyx_n_s_spline, __pyx_n_s_curve, __pyx_n_s_p, __pyx_n_s_spline, __pyx_n_s_s); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_tuple__5); | |
| __Pyx_GIVEREF(__pyx_tuple__5); | |
| __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_cu2qu_cu2qu_py, __pyx_n_s_curves_to_quadratic, 476, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| __pyx_L1_error:; | |
| __Pyx_RefNannyFinishContext(); | |
| return -1; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { | |
| if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __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 | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); | |
| /*--- Type init code ---*/ | |
| if (PyType_Ready(&__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) < 0) __PYX_ERR(0, 141, __pyx_L1_error) | |
| __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen.tp_print = 0; | |
| if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen.tp_dictoffset && __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen.tp_getattro == PyObject_GenericGetAttr)) { | |
| __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; | |
| } | |
| __pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = &__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen; | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| __pyx_L1_error:; | |
| __Pyx_RefNannyFinishContext(); | |
| return -1; | |
| } | |
| 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 initcu2qu(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC initcu2qu(void) | |
| __Pyx_PyMODINIT_FUNC PyInit_cu2qu(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC PyInit_cu2qu(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_cu2qu(PyObject *__pyx_pyinit_module) | |
| { | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| PyObject *__pyx_t_3 = NULL; | |
| int __pyx_t_4; | |
| PyObject *__pyx_t_5 = NULL; | |
| PyObject *__pyx_t_6 = NULL; | |
| PyObject *__pyx_t_7 = NULL; | |
| PyObject *__pyx_t_8 = NULL; | |
| PyObject *__pyx_t_9 = 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 'cu2qu' 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_cu2qu(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("cu2qu", __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_fontTools__cu2qu__cu2qu) { | |
| if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 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, "fontTools.cu2qu.cu2qu")) { | |
| if (unlikely(PyDict_SetItemString(modules, "fontTools.cu2qu.cu2qu", __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(); | |
| if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| (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) | |
| /* "fontTools/cu2qu/cu2qu.py":18 | |
| * # limitations under the License. | |
| * | |
| * try: # <<<<<<<<<<<<<< | |
| * import cython | |
| * | |
| */ | |
| { | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); | |
| __Pyx_XGOTREF(__pyx_t_1); | |
| __Pyx_XGOTREF(__pyx_t_2); | |
| __Pyx_XGOTREF(__pyx_t_3); | |
| /*try:*/ { | |
| /* "fontTools/cu2qu/cu2qu.py":21 | |
| * import cython | |
| * | |
| * COMPILED = cython.compiled # <<<<<<<<<<<<<< | |
| * except (AttributeError, ImportError): | |
| * # if cython not installed, use mock module with no-op decorators and types | |
| */ | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPILED, Py_True) < 0) __PYX_ERR(0, 21, __pyx_L2_error) | |
| /* "fontTools/cu2qu/cu2qu.py":18 | |
| * # limitations under the License. | |
| * | |
| * try: # <<<<<<<<<<<<<< | |
| * import cython | |
| * | |
| */ | |
| } | |
| __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; | |
| __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| goto __pyx_L7_try_end; | |
| __pyx_L2_error:; | |
| /* "fontTools/cu2qu/cu2qu.py":22 | |
| * | |
| * COMPILED = cython.compiled | |
| * except (AttributeError, ImportError): # <<<<<<<<<<<<<< | |
| * # if cython not installed, use mock module with no-op decorators and types | |
| * from fontTools.misc import cython | |
| */ | |
| __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); | |
| if (__pyx_t_4) { | |
| __Pyx_AddTraceback("fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 22, __pyx_L4_except_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_GOTREF(__pyx_t_7); | |
| /* "fontTools/cu2qu/cu2qu.py":24 | |
| * except (AttributeError, ImportError): | |
| * # if cython not installed, use mock module with no-op decorators and types | |
| * from fontTools.misc import cython # <<<<<<<<<<<<<< | |
| * | |
| * COMPILED = False | |
| */ | |
| __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L4_except_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| __Pyx_INCREF(__pyx_n_s_cython); | |
| __Pyx_GIVEREF(__pyx_n_s_cython); | |
| PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_cython); | |
| __pyx_t_9 = __Pyx_Import(__pyx_n_s_fontTools_misc, __pyx_t_8, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 24, __pyx_L4_except_error) | |
| __Pyx_GOTREF(__pyx_t_9); | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_cython); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L4_except_error) | |
| __Pyx_GOTREF(__pyx_t_8); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_cython, __pyx_t_8) < 0) __PYX_ERR(0, 24, __pyx_L4_except_error) | |
| __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; | |
| __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":26 | |
| * from fontTools.misc import cython | |
| * | |
| * COMPILED = False # <<<<<<<<<<<<<< | |
| * | |
| * import math | |
| */ | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPILED, Py_False) < 0) __PYX_ERR(0, 26, __pyx_L4_except_error) | |
| __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| goto __pyx_L3_exception_handled; | |
| } | |
| goto __pyx_L4_except_error; | |
| __pyx_L4_except_error:; | |
| /* "fontTools/cu2qu/cu2qu.py":18 | |
| * # limitations under the License. | |
| * | |
| * try: # <<<<<<<<<<<<<< | |
| * import cython | |
| * | |
| */ | |
| __Pyx_XGIVEREF(__pyx_t_1); | |
| __Pyx_XGIVEREF(__pyx_t_2); | |
| __Pyx_XGIVEREF(__pyx_t_3); | |
| __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); | |
| goto __pyx_L1_error; | |
| __pyx_L3_exception_handled:; | |
| __Pyx_XGIVEREF(__pyx_t_1); | |
| __Pyx_XGIVEREF(__pyx_t_2); | |
| __Pyx_XGIVEREF(__pyx_t_3); | |
| __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); | |
| __pyx_L7_try_end:; | |
| } | |
| /* "fontTools/cu2qu/cu2qu.py":28 | |
| * COMPILED = False | |
| * | |
| * import math # <<<<<<<<<<<<<< | |
| * | |
| * from .errors import Error as Cu2QuError, ApproxNotFoundError | |
| */ | |
| __pyx_t_7 = __Pyx_Import(__pyx_n_s_math, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_7) < 0) __PYX_ERR(0, 28, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":30 | |
| * import math | |
| * | |
| * from .errors import Error as Cu2QuError, ApproxNotFoundError # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_INCREF(__pyx_n_s_Error); | |
| __Pyx_GIVEREF(__pyx_n_s_Error); | |
| PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_Error); | |
| __Pyx_INCREF(__pyx_n_s_ApproxNotFoundError); | |
| __Pyx_GIVEREF(__pyx_n_s_ApproxNotFoundError); | |
| PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ApproxNotFoundError); | |
| __pyx_t_6 = __Pyx_Import(__pyx_n_s_errors, __pyx_t_7, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_Error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_Cu2QuError, __pyx_t_7) < 0) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_ApproxNotFoundError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_ApproxNotFoundError, __pyx_t_7) < 0) __PYX_ERR(0, 30, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":33 | |
| * | |
| * | |
| * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] # <<<<<<<<<<<<<< | |
| * | |
| * MAX_N = 100 | |
| */ | |
| __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 33, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_INCREF(__pyx_n_u_curve_to_quadratic); | |
| __Pyx_GIVEREF(__pyx_n_u_curve_to_quadratic); | |
| PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_curve_to_quadratic); | |
| __Pyx_INCREF(__pyx_n_u_curves_to_quadratic); | |
| __Pyx_GIVEREF(__pyx_n_u_curves_to_quadratic); | |
| PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_curves_to_quadratic); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_6) < 0) __PYX_ERR(0, 33, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":35 | |
| * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] | |
| * | |
| * MAX_N = 100 # <<<<<<<<<<<<<< | |
| * | |
| * NAN = float("NaN") | |
| */ | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_N, __pyx_int_100) < 0) __PYX_ERR(0, 35, __pyx_L1_error) | |
| /* "fontTools/cu2qu/cu2qu.py":37 | |
| * MAX_N = 100 | |
| * | |
| * NAN = float("NaN") # <<<<<<<<<<<<<< | |
| * | |
| * | |
| */ | |
| __pyx_t_6 = __Pyx_PyNumber_Float(__pyx_n_u_NaN); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_NAN, __pyx_t_6) < 0) __PYX_ERR(0, 37, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":141 | |
| * a1=cython.complex, b1=cython.complex, c1=cython.complex, d1=cython.complex | |
| * ) | |
| * def _split_cubic_into_n_gen(p0, p1, p2, p3, n): # <<<<<<<<<<<<<< | |
| * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) | |
| * dt = 1 / n | |
| */ | |
| __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, 0, __pyx_n_s_split_cubic_into_n_gen, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 141, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_cubic_into_n_gen, __pyx_t_6) < 0) __PYX_ERR(0, 141, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":442 | |
| * @cython.locals(n=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Approximate a cubic Bezier curve with a spline of n quadratics. | |
| * | |
| */ | |
| __pyx_t_6 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 442, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 442, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); | |
| __pyx_t_6 = 0; | |
| __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, 0, __pyx_n_s_curve_to_quadratic, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 442, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_t_7); | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_curve_to_quadratic, __pyx_t_6) < 0) __PYX_ERR(0, 442, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":476 | |
| * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) | |
| * @cython.locals(all_quadratic=cython.int) | |
| * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<< | |
| * """Return quadratic Bezier splines approximating the input cubic Beziers. | |
| * | |
| */ | |
| __pyx_t_6 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_7); | |
| __Pyx_GIVEREF(__pyx_t_6); | |
| PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); | |
| __pyx_t_6 = 0; | |
| __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, 0, __pyx_n_s_curves_to_quadratic, NULL, __pyx_n_s_fontTools_cu2qu_cu2qu, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_t_7); | |
| __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_curves_to_quadratic, __pyx_t_6) < 0) __PYX_ERR(0, 476, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /* "fontTools/cu2qu/cu2qu.py":1 | |
| * # cython: language_level=3 # <<<<<<<<<<<<<< | |
| * # distutils: define_macros=CYTHON_TRACE_NOGIL=1 | |
| * | |
| */ | |
| __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_6); | |
| if (PyDict_SetItem(__pyx_t_6, __pyx_kp_u_curves_to_quadratic_line_476, __pyx_kp_u_Return_quadratic_Bezier_splines) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_6) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; | |
| /*--- Wrapped vars code ---*/ | |
| goto __pyx_L0; | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_5); | |
| __Pyx_XDECREF(__pyx_t_6); | |
| __Pyx_XDECREF(__pyx_t_7); | |
| __Pyx_XDECREF(__pyx_t_8); | |
| __Pyx_XDECREF(__pyx_t_9); | |
| if (__pyx_m) { | |
| if (__pyx_d) { | |
| __Pyx_AddTraceback("init fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| } | |
| Py_CLEAR(__pyx_m); | |
| } else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_ImportError, "init fontTools.cu2qu.cu2qu"); | |
| } | |
| __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); | |
| } | |
| /* GetBuiltinName */ | |
| static PyObject *__Pyx_GetBuiltinName(PyObject *name) { | |
| PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); | |
| if (unlikely(!result)) { | |
| PyErr_Format(PyExc_NameError, | |
| "name '%U' is not defined", name); | |
| "name '%.200s' is not defined", PyString_AS_STRING(name)); | |
| } | |
| return result; | |
| } | |
| /* PyIntCompare */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) { | |
| if (op1 == op2) { | |
| Py_RETURN_TRUE; | |
| } | |
| if (likely(PyInt_CheckExact(op1))) { | |
| const long b = intval; | |
| long a = PyInt_AS_LONG(op1); | |
| if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE; | |
| } | |
| if (likely(PyLong_CheckExact(op1))) { | |
| int unequal; | |
| unsigned long uintval; | |
| Py_ssize_t size = Py_SIZE(op1); | |
| const digit* digits = ((PyLongObject*)op1)->ob_digit; | |
| if (intval == 0) { | |
| if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; | |
| } else if (intval < 0) { | |
| if (size >= 0) | |
| Py_RETURN_FALSE; | |
| intval = -intval; | |
| size = -size; | |
| } else { | |
| if (size <= 0) | |
| Py_RETURN_FALSE; | |
| } | |
| uintval = (unsigned long) intval; | |
| if (uintval >> (PyLong_SHIFT * 4)) { | |
| unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | |
| | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); | |
| } else | |
| if (uintval >> (PyLong_SHIFT * 3)) { | |
| unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | |
| | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); | |
| } else | |
| if (uintval >> (PyLong_SHIFT * 2)) { | |
| unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | |
| | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); | |
| } else | |
| if (uintval >> (PyLong_SHIFT * 1)) { | |
| unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | |
| | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); | |
| } else | |
| unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); | |
| if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; | |
| } | |
| if (PyFloat_CheckExact(op1)) { | |
| const long b = intval; | |
| double a = PyFloat_AS_DOUBLE(op1); | |
| if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE; | |
| } | |
| return ( | |
| PyObject_RichCompare(op1, op2, Py_EQ)); | |
| } | |
| /* RaiseTooManyValuesToUnpack */ | |
| static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { | |
| PyErr_Format(PyExc_ValueError, | |
| "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); | |
| } | |
| /* RaiseNeedMoreValuesToUnpack */ | |
| static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { | |
| PyErr_Format(PyExc_ValueError, | |
| "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", | |
| index, (index == 1) ? "" : "s"); | |
| } | |
| /* IterFinish */ | |
| static CYTHON_INLINE int __Pyx_IterFinish(void) { | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject* exc_type = tstate->curexc_type; | |
| if (unlikely(exc_type)) { | |
| if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { | |
| PyObject *exc_value, *exc_tb; | |
| exc_value = tstate->curexc_value; | |
| exc_tb = tstate->curexc_traceback; | |
| tstate->curexc_type = 0; | |
| tstate->curexc_value = 0; | |
| tstate->curexc_traceback = 0; | |
| Py_DECREF(exc_type); | |
| Py_XDECREF(exc_value); | |
| Py_XDECREF(exc_tb); | |
| return 0; | |
| } else { | |
| return -1; | |
| } | |
| } | |
| return 0; | |
| if (unlikely(PyErr_Occurred())) { | |
| if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { | |
| PyErr_Clear(); | |
| return 0; | |
| } else { | |
| return -1; | |
| } | |
| } | |
| return 0; | |
| } | |
| /* UnpackItemEndCheck */ | |
| static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { | |
| if (unlikely(retval)) { | |
| Py_DECREF(retval); | |
| __Pyx_RaiseTooManyValuesError(expected); | |
| return -1; | |
| } | |
| return __Pyx_IterFinish(); | |
| } | |
| /* GetItemInt */ | |
| static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { | |
| PyObject *r; | |
| if (!j) return NULL; | |
| r = PyObject_GetItem(o, j); | |
| Py_DECREF(j); | |
| return r; | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, | |
| CYTHON_NCP_UNUSED int wraparound, | |
| CYTHON_NCP_UNUSED int boundscheck) { | |
| Py_ssize_t wrapped_i = i; | |
| if (wraparound & unlikely(i < 0)) { | |
| wrapped_i += PyList_GET_SIZE(o); | |
| } | |
| if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { | |
| PyObject *r = PyList_GET_ITEM(o, wrapped_i); | |
| Py_INCREF(r); | |
| return r; | |
| } | |
| return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); | |
| return PySequence_GetItem(o, i); | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, | |
| CYTHON_NCP_UNUSED int wraparound, | |
| CYTHON_NCP_UNUSED int boundscheck) { | |
| Py_ssize_t wrapped_i = i; | |
| if (wraparound & unlikely(i < 0)) { | |
| wrapped_i += PyTuple_GET_SIZE(o); | |
| } | |
| if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { | |
| PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); | |
| Py_INCREF(r); | |
| return r; | |
| } | |
| return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); | |
| return PySequence_GetItem(o, i); | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, | |
| CYTHON_NCP_UNUSED int wraparound, | |
| CYTHON_NCP_UNUSED int boundscheck) { | |
| if (is_list || PyList_CheckExact(o)) { | |
| Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); | |
| if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { | |
| PyObject *r = PyList_GET_ITEM(o, n); | |
| Py_INCREF(r); | |
| return r; | |
| } | |
| } | |
| else if (PyTuple_CheckExact(o)) { | |
| Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); | |
| if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { | |
| PyObject *r = PyTuple_GET_ITEM(o, n); | |
| Py_INCREF(r); | |
| return r; | |
| } | |
| } else { | |
| PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; | |
| if (likely(m && m->sq_item)) { | |
| if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { | |
| Py_ssize_t l = m->sq_length(o); | |
| if (likely(l >= 0)) { | |
| i += l; | |
| } else { | |
| if (!PyErr_ExceptionMatches(PyExc_OverflowError)) | |
| return NULL; | |
| PyErr_Clear(); | |
| } | |
| } | |
| return m->sq_item(o, i); | |
| } | |
| } | |
| if (is_list || PySequence_Check(o)) { | |
| return PySequence_GetItem(o, i); | |
| } | |
| return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); | |
| } | |
| /* 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); | |
| } | |
| /* GetModuleGlobalName */ | |
| static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) | |
| static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) | |
| { | |
| PyObject *result; | |
| result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } else if (unlikely(PyErr_Occurred())) { | |
| return NULL; | |
| } | |
| result = PyDict_GetItem(__pyx_d, name); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } | |
| result = PyObject_GetItem(__pyx_d, name); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } | |
| PyErr_Clear(); | |
| return __Pyx_GetBuiltinName(name); | |
| } | |
| /* PyFunctionFastCall */ | |
| static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, | |
| PyObject *globals) { | |
| PyFrameObject *f; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject **fastlocals; | |
| Py_ssize_t i; | |
| PyObject *result; | |
| assert(globals != NULL); | |
| /* XXX Perhaps we should create a specialized | |
| PyFrame_New() that doesn't take locals, but does | |
| take builtins without sanity checking them. | |
| */ | |
| assert(tstate != NULL); | |
| f = PyFrame_New(tstate, co, globals, NULL); | |
| if (f == NULL) { | |
| return NULL; | |
| } | |
| fastlocals = __Pyx_PyFrame_GetLocalsplus(f); | |
| for (i = 0; i < na; i++) { | |
| Py_INCREF(*args); | |
| fastlocals[i] = *args++; | |
| } | |
| result = PyEval_EvalFrameEx(f,0); | |
| ++tstate->recursion_depth; | |
| Py_DECREF(f); | |
| --tstate->recursion_depth; | |
| return result; | |
| } | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { | |
| PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); | |
| PyObject *globals = PyFunction_GET_GLOBALS(func); | |
| PyObject *argdefs = PyFunction_GET_DEFAULTS(func); | |
| PyObject *closure; | |
| PyObject *kwdefs; | |
| PyObject *kwtuple, **k; | |
| PyObject **d; | |
| Py_ssize_t nd; | |
| Py_ssize_t nk; | |
| PyObject *result; | |
| assert(kwargs == NULL || PyDict_Check(kwargs)); | |
| nk = kwargs ? PyDict_Size(kwargs) : 0; | |
| if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { | |
| return NULL; | |
| } | |
| if ( | |
| co->co_kwonlyargcount == 0 && | |
| likely(kwargs == NULL || nk == 0) && | |
| co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { | |
| if (argdefs == NULL && co->co_argcount == nargs) { | |
| result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); | |
| goto done; | |
| } | |
| else if (nargs == 0 && argdefs != NULL | |
| && co->co_argcount == Py_SIZE(argdefs)) { | |
| /* function called with no arguments, but all parameters have | |
| a default value: use default values as arguments .*/ | |
| args = &PyTuple_GET_ITEM(argdefs, 0); | |
| result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); | |
| goto done; | |
| } | |
| } | |
| if (kwargs != NULL) { | |
| Py_ssize_t pos, i; | |
| kwtuple = PyTuple_New(2 * nk); | |
| if (kwtuple == NULL) { | |
| result = NULL; | |
| goto done; | |
| } | |
| k = &PyTuple_GET_ITEM(kwtuple, 0); | |
| pos = i = 0; | |
| while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { | |
| Py_INCREF(k[i]); | |
| Py_INCREF(k[i+1]); | |
| i += 2; | |
| } | |
| nk = i / 2; | |
| } | |
| else { | |
| kwtuple = NULL; | |
| k = NULL; | |
| } | |
| closure = PyFunction_GET_CLOSURE(func); | |
| kwdefs = PyFunction_GET_KW_DEFAULTS(func); | |
| if (argdefs != NULL) { | |
| d = &PyTuple_GET_ITEM(argdefs, 0); | |
| nd = Py_SIZE(argdefs); | |
| } | |
| else { | |
| d = NULL; | |
| nd = 0; | |
| } | |
| result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, | |
| args, (int)nargs, | |
| k, (int)nk, | |
| d, (int)nd, kwdefs, closure); | |
| result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, | |
| args, (int)nargs, | |
| k, (int)nk, | |
| d, (int)nd, closure); | |
| Py_XDECREF(kwtuple); | |
| done: | |
| Py_LeaveRecursiveCall(); | |
| return result; | |
| } | |
| /* PyCFunctionFastCall */ | |
| static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { | |
| PyCFunctionObject *func = (PyCFunctionObject*)func_obj; | |
| PyCFunction meth = PyCFunction_GET_FUNCTION(func); | |
| PyObject *self = PyCFunction_GET_SELF(func); | |
| int flags = PyCFunction_GET_FLAGS(func); | |
| assert(PyCFunction_Check(func)); | |
| assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); | |
| assert(nargs >= 0); | |
| assert(nargs == 0 || args != NULL); | |
| /* _PyCFunction_FastCallDict() must not be called with an exception set, | |
| because it may clear it (directly or indirectly) and so the | |
| caller loses its exception */ | |
| assert(!PyErr_Occurred()); | |
| if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { | |
| return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); | |
| } else { | |
| return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); | |
| } | |
| } | |
| /* PyObjectCall */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { | |
| PyObject *result; | |
| ternaryfunc call = Py_TYPE(func)->tp_call; | |
| if (unlikely(!call)) | |
| return PyObject_Call(func, arg, kw); | |
| if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) | |
| return NULL; | |
| result = (*call)(func, arg, kw); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* RaiseArgTupleInvalid */ | |
| static void __Pyx_RaiseArgtupleInvalid( | |
| const char* func_name, | |
| int exact, | |
| Py_ssize_t num_min, | |
| Py_ssize_t num_max, | |
| Py_ssize_t num_found) | |
| { | |
| Py_ssize_t num_expected; | |
| const char *more_or_less; | |
| if (num_found < num_min) { | |
| num_expected = num_min; | |
| more_or_less = "at least"; | |
| } else { | |
| num_expected = num_max; | |
| more_or_less = "at most"; | |
| } | |
| if (exact) { | |
| more_or_less = "exactly"; | |
| } | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", | |
| func_name, more_or_less, num_expected, | |
| (num_expected == 1) ? "" : "s", num_found); | |
| } | |
| /* RaiseDoubleKeywords */ | |
| static void __Pyx_RaiseDoubleKeywordsError( | |
| const char* func_name, | |
| PyObject* kw_name) | |
| { | |
| PyErr_Format(PyExc_TypeError, | |
| "%s() got multiple values for keyword argument '%U'", func_name, kw_name); | |
| "%s() got multiple values for keyword argument '%s'", func_name, | |
| PyString_AsString(kw_name)); | |
| } | |
| /* ParseKeywords */ | |
| static int __Pyx_ParseOptionalKeywords( | |
| PyObject *kwds, | |
| PyObject **argnames[], | |
| PyObject *kwds2, | |
| PyObject *values[], | |
| Py_ssize_t num_pos_args, | |
| const char* function_name) | |
| { | |
| PyObject *key = 0, *value = 0; | |
| Py_ssize_t pos = 0; | |
| PyObject*** name; | |
| PyObject*** first_kw_arg = argnames + num_pos_args; | |
| while (PyDict_Next(kwds, &pos, &key, &value)) { | |
| name = first_kw_arg; | |
| while (*name && (**name != key)) name++; | |
| if (*name) { | |
| values[name-argnames] = value; | |
| continue; | |
| } | |
| name = first_kw_arg; | |
| if (likely(PyString_Check(key))) { | |
| while (*name) { | |
| if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) | |
| && _PyString_Eq(**name, key)) { | |
| values[name-argnames] = value; | |
| break; | |
| } | |
| name++; | |
| } | |
| if (*name) continue; | |
| else { | |
| PyObject*** argname = argnames; | |
| while (argname != first_kw_arg) { | |
| if ((**argname == key) || ( | |
| (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) | |
| && _PyString_Eq(**argname, key))) { | |
| goto arg_passed_twice; | |
| } | |
| argname++; | |
| } | |
| } | |
| } else | |
| if (likely(PyUnicode_Check(key))) { | |
| while (*name) { | |
| int cmp = (**name == key) ? 0 : | |
| (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : | |
| PyUnicode_Compare(**name, key); | |
| if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; | |
| if (cmp == 0) { | |
| values[name-argnames] = value; | |
| break; | |
| } | |
| name++; | |
| } | |
| if (*name) continue; | |
| else { | |
| PyObject*** argname = argnames; | |
| while (argname != first_kw_arg) { | |
| int cmp = (**argname == key) ? 0 : | |
| (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : | |
| PyUnicode_Compare(**argname, key); | |
| if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; | |
| if (cmp == 0) goto arg_passed_twice; | |
| argname++; | |
| } | |
| } | |
| } else | |
| goto invalid_keyword_type; | |
| if (kwds2) { | |
| if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; | |
| } else { | |
| goto invalid_keyword; | |
| } | |
| } | |
| return 0; | |
| arg_passed_twice: | |
| __Pyx_RaiseDoubleKeywordsError(function_name, key); | |
| goto bad; | |
| invalid_keyword_type: | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s() keywords must be strings", function_name); | |
| goto bad; | |
| invalid_keyword: | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s() got an unexpected keyword argument '%.200s'", | |
| function_name, PyString_AsString(key)); | |
| "%s() got an unexpected keyword argument '%U'", | |
| function_name, key); | |
| bad: | |
| return -1; | |
| } | |
| /* GetTopmostException */ | |
| static _PyErr_StackItem * | |
| __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) | |
| { | |
| _PyErr_StackItem *exc_info = tstate->exc_info; | |
| while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && | |
| exc_info->previous_item != NULL) | |
| { | |
| exc_info = exc_info->previous_item; | |
| } | |
| return exc_info; | |
| } | |
| /* SaveResetException */ | |
| static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { | |
| _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); | |
| *type = exc_info->exc_type; | |
| *value = exc_info->exc_value; | |
| *tb = exc_info->exc_traceback; | |
| *type = tstate->exc_type; | |
| *value = tstate->exc_value; | |
| *tb = tstate->exc_traceback; | |
| Py_XINCREF(*type); | |
| Py_XINCREF(*value); | |
| Py_XINCREF(*tb); | |
| } | |
| static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| _PyErr_StackItem *exc_info = tstate->exc_info; | |
| tmp_type = exc_info->exc_type; | |
| tmp_value = exc_info->exc_value; | |
| tmp_tb = exc_info->exc_traceback; | |
| exc_info->exc_type = type; | |
| exc_info->exc_value = value; | |
| exc_info->exc_traceback = tb; | |
| tmp_type = tstate->exc_type; | |
| tmp_value = tstate->exc_value; | |
| tmp_tb = tstate->exc_traceback; | |
| tstate->exc_type = type; | |
| tstate->exc_value = value; | |
| tstate->exc_traceback = tb; | |
| Py_XDECREF(tmp_type); | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(tmp_tb); | |
| } | |
| /* PyErrExceptionMatches */ | |
| static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| 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++) { | |
| if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { | |
| PyObject *exc_type = tstate->curexc_type; | |
| if (exc_type == err) return 1; | |
| if (unlikely(!exc_type)) return 0; | |
| if (unlikely(PyTuple_Check(err))) | |
| return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); | |
| return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); | |
| } | |
| /* GetException */ | |
| static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) | |
| static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) | |
| { | |
| PyObject *local_type, *local_value, *local_tb; | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| local_type = tstate->curexc_type; | |
| local_value = tstate->curexc_value; | |
| local_tb = tstate->curexc_traceback; | |
| tstate->curexc_type = 0; | |
| tstate->curexc_value = 0; | |
| tstate->curexc_traceback = 0; | |
| PyErr_Fetch(&local_type, &local_value, &local_tb); | |
| PyErr_NormalizeException(&local_type, &local_value, &local_tb); | |
| if (unlikely(tstate->curexc_type)) | |
| if (unlikely(PyErr_Occurred())) | |
| goto bad; | |
| if (local_tb) { | |
| if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) | |
| goto bad; | |
| } | |
| Py_XINCREF(local_tb); | |
| Py_XINCREF(local_type); | |
| Py_XINCREF(local_value); | |
| *type = local_type; | |
| *value = local_value; | |
| *tb = local_tb; | |
| { | |
| _PyErr_StackItem *exc_info = tstate->exc_info; | |
| tmp_type = exc_info->exc_type; | |
| tmp_value = exc_info->exc_value; | |
| tmp_tb = exc_info->exc_traceback; | |
| exc_info->exc_type = local_type; | |
| exc_info->exc_value = local_value; | |
| exc_info->exc_traceback = local_tb; | |
| } | |
| tmp_type = tstate->exc_type; | |
| tmp_value = tstate->exc_value; | |
| tmp_tb = tstate->exc_traceback; | |
| tstate->exc_type = local_type; | |
| tstate->exc_value = local_value; | |
| tstate->exc_traceback = local_tb; | |
| Py_XDECREF(tmp_type); | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(tmp_tb); | |
| PyErr_SetExcInfo(local_type, local_value, local_tb); | |
| return 0; | |
| bad: | |
| *type = 0; | |
| *value = 0; | |
| *tb = 0; | |
| Py_XDECREF(local_type); | |
| Py_XDECREF(local_value); | |
| Py_XDECREF(local_tb); | |
| return -1; | |
| } | |
| /* 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; | |
| } | |
| /* WriteUnraisableException */ | |
| static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, | |
| CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, | |
| int full_traceback, CYTHON_UNUSED int nogil) { | |
| PyObject *old_exc, *old_val, *old_tb; | |
| PyObject *ctx; | |
| __Pyx_PyThreadState_declare | |
| PyGILState_STATE state; | |
| if (nogil) | |
| state = PyGILState_Ensure(); | |
| else state = (PyGILState_STATE)0; | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); | |
| if (full_traceback) { | |
| Py_XINCREF(old_exc); | |
| Py_XINCREF(old_val); | |
| Py_XINCREF(old_tb); | |
| __Pyx_ErrRestore(old_exc, old_val, old_tb); | |
| PyErr_PrintEx(1); | |
| } | |
| ctx = PyString_FromString(name); | |
| ctx = PyUnicode_FromString(name); | |
| __Pyx_ErrRestore(old_exc, old_val, old_tb); | |
| if (!ctx) { | |
| PyErr_WriteUnraisable(Py_None); | |
| } else { | |
| PyErr_WriteUnraisable(ctx); | |
| Py_DECREF(ctx); | |
| } | |
| if (nogil) | |
| PyGILState_Release(state); | |
| } | |
| /* PyObjectCall2Args */ | |
| static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { | |
| PyObject *args, *result = NULL; | |
| if (PyFunction_Check(function)) { | |
| PyObject *args[2] = {arg1, arg2}; | |
| return __Pyx_PyFunction_FastCall(function, args, 2); | |
| } | |
| if (__Pyx_PyFastCFunction_Check(function)) { | |
| PyObject *args[2] = {arg1, arg2}; | |
| return __Pyx_PyCFunction_FastCall(function, args, 2); | |
| } | |
| args = PyTuple_New(2); | |
| if (unlikely(!args)) goto done; | |
| Py_INCREF(arg1); | |
| PyTuple_SET_ITEM(args, 0, arg1); | |
| Py_INCREF(arg2); | |
| PyTuple_SET_ITEM(args, 1, arg2); | |
| Py_INCREF(function); | |
| result = __Pyx_PyObject_Call(function, args, NULL); | |
| Py_DECREF(args); | |
| Py_DECREF(function); | |
| done: | |
| return result; | |
| } | |
| /* PyObjectCallMethO */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { | |
| PyObject *self, *result; | |
| PyCFunction cfunc; | |
| cfunc = PyCFunction_GET_FUNCTION(func); | |
| self = PyCFunction_GET_SELF(func); | |
| if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) | |
| return NULL; | |
| result = cfunc(self, arg); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* PyObjectCallOneArg */ | |
| static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { | |
| PyObject *result; | |
| PyObject *args = PyTuple_New(1); | |
| if (unlikely(!args)) return NULL; | |
| Py_INCREF(arg); | |
| PyTuple_SET_ITEM(args, 0, arg); | |
| result = __Pyx_PyObject_Call(func, args, NULL); | |
| Py_DECREF(args); | |
| return result; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { | |
| if (PyFunction_Check(func)) { | |
| return __Pyx_PyFunction_FastCall(func, &arg, 1); | |
| } | |
| if (likely(PyCFunction_Check(func))) { | |
| if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { | |
| return __Pyx_PyObject_CallMethO(func, arg); | |
| } else if (__Pyx_PyFastCFunction_Check(func)) { | |
| return __Pyx_PyCFunction_FastCall(func, &arg, 1); | |
| } | |
| } | |
| return __Pyx__PyObject_CallOneArg(func, arg); | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { | |
| PyObject *result; | |
| PyObject *args = PyTuple_Pack(1, arg); | |
| if (unlikely(!args)) return NULL; | |
| result = __Pyx_PyObject_Call(func, args, NULL); | |
| Py_DECREF(args); | |
| return result; | |
| } | |
| /* IterNext */ | |
| static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { | |
| PyObject* exc_type; | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| exc_type = __Pyx_PyErr_Occurred(); | |
| if (unlikely(exc_type)) { | |
| if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) | |
| return NULL; | |
| __Pyx_PyErr_Clear(); | |
| Py_INCREF(defval); | |
| return defval; | |
| } | |
| if (defval) { | |
| Py_INCREF(defval); | |
| return defval; | |
| } | |
| __Pyx_PyErr_SetNone(PyExc_StopIteration); | |
| return NULL; | |
| } | |
| static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name); | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) { | |
| PyObject* next; | |
| iternextfunc iternext = Py_TYPE(iterator)->tp_iternext; | |
| if (likely(iternext)) { | |
| next = iternext(iterator); | |
| if (likely(next)) | |
| return next; | |
| if (unlikely(iternext == &_PyObject_NextNotImplemented)) | |
| return NULL; | |
| next = PyIter_Next(iterator); | |
| if (likely(next)) | |
| return next; | |
| } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) { | |
| __Pyx_PyIter_Next_ErrorNoIterator(iterator); | |
| return NULL; | |
| } | |
| else { | |
| next = PyIter_Next(iterator); | |
| if (likely(next)) | |
| return next; | |
| } | |
| return __Pyx_PyIter_Next2Default(defval); | |
| } | |
| /* PyIntBinop */ | |
| static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { | |
| (void)inplace; | |
| (void)zerodivision_check; | |
| if (likely(PyInt_CheckExact(op1))) { | |
| const long b = intval; | |
| long x; | |
| long a = PyInt_AS_LONG(op1); | |
| x = (long)((unsigned long)a + b); | |
| if (likely((x^a) >= 0 || (x^b) >= 0)) | |
| return PyInt_FromLong(x); | |
| return PyLong_Type.tp_as_number->nb_add(op1, op2); | |
| } | |
| if (likely(PyLong_CheckExact(op1))) { | |
| const long b = intval; | |
| long a, x; | |
| const PY_LONG_LONG llb = intval; | |
| PY_LONG_LONG lla, llx; | |
| const digit* digits = ((PyLongObject*)op1)->ob_digit; | |
| const Py_ssize_t size = Py_SIZE(op1); | |
| if (likely(__Pyx_sst_abs(size) <= 1)) { | |
| a = likely(size) ? digits[0] : 0; | |
| if (size == -1) a = -a; | |
| } else { | |
| switch (size) { | |
| case -2: | |
| if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { | |
| a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { | |
| lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 2: | |
| if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { | |
| a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { | |
| lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case -3: | |
| if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { | |
| a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { | |
| lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 3: | |
| if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { | |
| a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { | |
| lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case -4: | |
| if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { | |
| a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { | |
| lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| case 4: | |
| if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { | |
| a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); | |
| break; | |
| } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { | |
| lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); | |
| goto long_long; | |
| } | |
| CYTHON_FALLTHROUGH; | |
| default: return PyLong_Type.tp_as_number->nb_add(op1, op2); | |
| } | |
| } | |
| x = a + b; | |
| return PyLong_FromLong(x); | |
| long_long: | |
| llx = lla + llb; | |
| return PyLong_FromLongLong(llx); | |
| } | |
| if (PyFloat_CheckExact(op1)) { | |
| const long b = intval; | |
| double a = PyFloat_AS_DOUBLE(op1); | |
| double result; | |
| PyFPE_START_PROTECT("add", return NULL) | |
| result = ((double)a) + (double)b; | |
| PyFPE_END_PROTECT(result) | |
| return PyFloat_FromDouble(result); | |
| } | |
| return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); | |
| } | |
| /* RaiseException */ | |
| static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, | |
| CYTHON_UNUSED PyObject *cause) { | |
| __Pyx_PyThreadState_declare | |
| Py_XINCREF(type); | |
| if (!value || value == Py_None) | |
| value = NULL; | |
| else | |
| Py_INCREF(value); | |
| if (!tb || tb == Py_None) | |
| tb = NULL; | |
| else { | |
| Py_INCREF(tb); | |
| if (!PyTraceBack_Check(tb)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "raise: arg 3 must be a traceback or None"); | |
| goto raise_error; | |
| } | |
| } | |
| if (PyType_Check(type)) { | |
| if (!value) { | |
| Py_INCREF(Py_None); | |
| value = Py_None; | |
| } | |
| PyErr_NormalizeException(&type, &value, &tb); | |
| } else { | |
| if (value) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "instance exception may not have a separate value"); | |
| goto raise_error; | |
| } | |
| value = type; | |
| type = (PyObject*) Py_TYPE(type); | |
| Py_INCREF(type); | |
| if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "raise: exception class must be a subclass of BaseException"); | |
| goto raise_error; | |
| } | |
| } | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ErrRestore(type, value, tb); | |
| return; | |
| raise_error: | |
| Py_XDECREF(value); | |
| Py_XDECREF(type); | |
| Py_XDECREF(tb); | |
| return; | |
| } | |
| static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { | |
| PyObject* owned_instance = NULL; | |
| if (tb == Py_None) { | |
| tb = 0; | |
| } else if (tb && !PyTraceBack_Check(tb)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "raise: arg 3 must be a traceback or None"); | |
| goto bad; | |
| } | |
| if (value == Py_None) | |
| value = 0; | |
| if (PyExceptionInstance_Check(type)) { | |
| if (value) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "instance exception may not have a separate value"); | |
| goto bad; | |
| } | |
| value = type; | |
| type = (PyObject*) Py_TYPE(value); | |
| } else if (PyExceptionClass_Check(type)) { | |
| PyObject *instance_class = NULL; | |
| if (value && PyExceptionInstance_Check(value)) { | |
| instance_class = (PyObject*) Py_TYPE(value); | |
| if (instance_class != type) { | |
| int is_subclass = PyObject_IsSubclass(instance_class, type); | |
| if (!is_subclass) { | |
| instance_class = NULL; | |
| } else if (unlikely(is_subclass == -1)) { | |
| goto bad; | |
| } else { | |
| type = instance_class; | |
| } | |
| } | |
| } | |
| if (!instance_class) { | |
| PyObject *args; | |
| if (!value) | |
| args = PyTuple_New(0); | |
| else if (PyTuple_Check(value)) { | |
| Py_INCREF(value); | |
| args = value; | |
| } else | |
| args = PyTuple_Pack(1, value); | |
| if (!args) | |
| goto bad; | |
| owned_instance = PyObject_Call(type, args, NULL); | |
| Py_DECREF(args); | |
| if (!owned_instance) | |
| goto bad; | |
| value = owned_instance; | |
| if (!PyExceptionInstance_Check(value)) { | |
| PyErr_Format(PyExc_TypeError, | |
| "calling %R should have returned an instance of " | |
| "BaseException, not %R", | |
| type, Py_TYPE(value)); | |
| goto bad; | |
| } | |
| } | |
| } else { | |
| PyErr_SetString(PyExc_TypeError, | |
| "raise: exception class must be a subclass of BaseException"); | |
| goto bad; | |
| } | |
| if (cause) { | |
| PyObject *fixed_cause; | |
| if (cause == Py_None) { | |
| fixed_cause = NULL; | |
| } else if (PyExceptionClass_Check(cause)) { | |
| fixed_cause = PyObject_CallObject(cause, NULL); | |
| if (fixed_cause == NULL) | |
| goto bad; | |
| } else if (PyExceptionInstance_Check(cause)) { | |
| fixed_cause = cause; | |
| Py_INCREF(fixed_cause); | |
| } else { | |
| PyErr_SetString(PyExc_TypeError, | |
| "exception causes must derive from " | |
| "BaseException"); | |
| goto bad; | |
| } | |
| PyException_SetCause(value, fixed_cause); | |
| } | |
| PyErr_SetObject(type, value); | |
| if (tb) { | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject* tmp_tb = tstate->curexc_traceback; | |
| if (tb != tmp_tb) { | |
| Py_INCREF(tb); | |
| tstate->curexc_traceback = tb; | |
| Py_XDECREF(tmp_tb); | |
| } | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); | |
| Py_INCREF(tb); | |
| PyErr_Restore(tmp_type, tmp_value, tb); | |
| Py_XDECREF(tmp_tb); | |
| } | |
| bad: | |
| Py_XDECREF(owned_instance); | |
| return; | |
| } | |
| /* SetItemInt */ | |
| static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { | |
| int r; | |
| if (!j) return -1; | |
| r = PyObject_SetItem(o, j, v); | |
| Py_DECREF(j); | |
| return r; | |
| } | |
| static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, | |
| CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { | |
| if (is_list || PyList_CheckExact(o)) { | |
| Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); | |
| if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { | |
| PyObject* old = PyList_GET_ITEM(o, n); | |
| Py_INCREF(v); | |
| PyList_SET_ITEM(o, n, v); | |
| Py_DECREF(old); | |
| return 1; | |
| } | |
| } else { | |
| PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; | |
| if (likely(m && m->sq_ass_item)) { | |
| if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { | |
| Py_ssize_t l = m->sq_length(o); | |
| if (likely(l >= 0)) { | |
| i += l; | |
| } else { | |
| if (!PyErr_ExceptionMatches(PyExc_OverflowError)) | |
| return -1; | |
| PyErr_Clear(); | |
| } | |
| } | |
| return m->sq_ass_item(o, i, v); | |
| } | |
| } | |
| if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) | |
| if (is_list || PySequence_Check(o)) | |
| { | |
| return PySequence_SetItem(o, i, v); | |
| } | |
| return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); | |
| } | |
| /* ModInt[long] */ | |
| static CYTHON_INLINE long __Pyx_mod_long(long a, long b) { | |
| long r = a % b; | |
| r += ((r != 0) & ((r ^ b) < 0)) * b; | |
| return r; | |
| } | |
| /* PyObject_GenericGetAttrNoDict */ | |
| static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { | |
| PyErr_Format(PyExc_AttributeError, | |
| "'%.50s' object has no attribute '%U'", | |
| tp->tp_name, attr_name); | |
| "'%.50s' object has no attribute '%.400s'", | |
| tp->tp_name, PyString_AS_STRING(attr_name)); | |
| return NULL; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { | |
| PyObject *descr; | |
| PyTypeObject *tp = Py_TYPE(obj); | |
| if (unlikely(!PyString_Check(attr_name))) { | |
| return PyObject_GenericGetAttr(obj, attr_name); | |
| } | |
| assert(!tp->tp_dictoffset); | |
| descr = _PyType_Lookup(tp, attr_name); | |
| if (unlikely(!descr)) { | |
| return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); | |
| } | |
| Py_INCREF(descr); | |
| if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) | |
| { | |
| descrgetfunc f = Py_TYPE(descr)->tp_descr_get; | |
| if (unlikely(f)) { | |
| PyObject *res = f(descr, obj, (PyObject *)tp); | |
| Py_DECREF(descr); | |
| return res; | |
| } | |
| } | |
| return descr; | |
| } | |
| /* 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; | |
| } | |
| /* FetchCommonType */ | |
| static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { | |
| PyObject* fake_module; | |
| PyTypeObject* cached_type = NULL; | |
| fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); | |
| if (!fake_module) return NULL; | |
| Py_INCREF(fake_module); | |
| cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); | |
| if (cached_type) { | |
| if (!PyType_Check((PyObject*)cached_type)) { | |
| PyErr_Format(PyExc_TypeError, | |
| "Shared Cython type %.200s is not a type object", | |
| type->tp_name); | |
| goto bad; | |
| } | |
| if (cached_type->tp_basicsize != type->tp_basicsize) { | |
| PyErr_Format(PyExc_TypeError, | |
| "Shared Cython type %.200s has the wrong size, try recompiling", | |
| type->tp_name); | |
| goto bad; | |
| } | |
| } else { | |
| if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; | |
| PyErr_Clear(); | |
| if (PyType_Ready(type) < 0) goto bad; | |
| if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) | |
| goto bad; | |
| Py_INCREF(type); | |
| cached_type = type; | |
| } | |
| done: | |
| Py_DECREF(fake_module); | |
| return cached_type; | |
| bad: | |
| Py_XDECREF(cached_type); | |
| cached_type = NULL; | |
| goto done; | |
| } | |
| /* CythonFunctionShared */ | |
| static PyObject * | |
| __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) | |
| { | |
| if (unlikely(op->func_doc == NULL)) { | |
| if (op->func.m_ml->ml_doc) { | |
| op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); | |
| op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); | |
| if (unlikely(op->func_doc == NULL)) | |
| return NULL; | |
| } else { | |
| Py_INCREF(Py_None); | |
| return Py_None; | |
| } | |
| } | |
| Py_INCREF(op->func_doc); | |
| return op->func_doc; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp = op->func_doc; | |
| if (value == NULL) { | |
| value = Py_None; | |
| } | |
| Py_INCREF(value); | |
| op->func_doc = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| if (unlikely(op->func_name == NULL)) { | |
| op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); | |
| op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); | |
| if (unlikely(op->func_name == NULL)) | |
| return NULL; | |
| } | |
| Py_INCREF(op->func_name); | |
| return op->func_name; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp; | |
| if (unlikely(value == NULL || !PyUnicode_Check(value))) | |
| if (unlikely(value == NULL || !PyString_Check(value))) | |
| { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__name__ must be set to a string object"); | |
| return -1; | |
| } | |
| tmp = op->func_name; | |
| Py_INCREF(value); | |
| op->func_name = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| Py_INCREF(op->func_qualname); | |
| return op->func_qualname; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp; | |
| if (unlikely(value == NULL || !PyUnicode_Check(value))) | |
| if (unlikely(value == NULL || !PyString_Check(value))) | |
| { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__qualname__ must be set to a string object"); | |
| return -1; | |
| } | |
| tmp = op->func_qualname; | |
| Py_INCREF(value); | |
| op->func_qualname = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) | |
| { | |
| PyObject *self; | |
| self = m->func_closure; | |
| if (self == NULL) | |
| self = Py_None; | |
| Py_INCREF(self); | |
| return self; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| if (unlikely(op->func_dict == NULL)) { | |
| op->func_dict = PyDict_New(); | |
| if (unlikely(op->func_dict == NULL)) | |
| return NULL; | |
| } | |
| Py_INCREF(op->func_dict); | |
| return op->func_dict; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp; | |
| if (unlikely(value == NULL)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "function's dictionary may not be deleted"); | |
| return -1; | |
| } | |
| if (unlikely(!PyDict_Check(value))) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "setting function's dictionary to a non-dict"); | |
| return -1; | |
| } | |
| tmp = op->func_dict; | |
| Py_INCREF(value); | |
| op->func_dict = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| Py_INCREF(op->func_globals); | |
| return op->func_globals; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| Py_INCREF(Py_None); | |
| return Py_None; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) | |
| { | |
| PyObject* result = (op->func_code) ? op->func_code : Py_None; | |
| Py_INCREF(result); | |
| return result; | |
| } | |
| static int | |
| __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { | |
| int result = 0; | |
| PyObject *res = op->defaults_getter((PyObject *) op); | |
| if (unlikely(!res)) | |
| return -1; | |
| op->defaults_tuple = PyTuple_GET_ITEM(res, 0); | |
| Py_INCREF(op->defaults_tuple); | |
| op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); | |
| Py_INCREF(op->defaults_kwdict); | |
| op->defaults_tuple = PySequence_ITEM(res, 0); | |
| if (unlikely(!op->defaults_tuple)) result = -1; | |
| else { | |
| op->defaults_kwdict = PySequence_ITEM(res, 1); | |
| if (unlikely(!op->defaults_kwdict)) result = -1; | |
| } | |
| Py_DECREF(res); | |
| return result; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { | |
| PyObject* tmp; | |
| if (!value) { | |
| value = Py_None; | |
| } else if (value != Py_None && !PyTuple_Check(value)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__defaults__ must be set to a tuple object"); | |
| return -1; | |
| } | |
| Py_INCREF(value); | |
| tmp = op->defaults_tuple; | |
| op->defaults_tuple = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { | |
| PyObject* result = op->defaults_tuple; | |
| if (unlikely(!result)) { | |
| if (op->defaults_getter) { | |
| if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; | |
| result = op->defaults_tuple; | |
| } else { | |
| result = Py_None; | |
| } | |
| } | |
| Py_INCREF(result); | |
| return result; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { | |
| PyObject* tmp; | |
| if (!value) { | |
| value = Py_None; | |
| } else if (value != Py_None && !PyDict_Check(value)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__kwdefaults__ must be set to a dict object"); | |
| return -1; | |
| } | |
| Py_INCREF(value); | |
| tmp = op->defaults_kwdict; | |
| op->defaults_kwdict = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { | |
| PyObject* result = op->defaults_kwdict; | |
| if (unlikely(!result)) { | |
| if (op->defaults_getter) { | |
| if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; | |
| result = op->defaults_kwdict; | |
| } else { | |
| result = Py_None; | |
| } | |
| } | |
| Py_INCREF(result); | |
| return result; | |
| } | |
| static int | |
| __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { | |
| PyObject* tmp; | |
| if (!value || value == Py_None) { | |
| value = NULL; | |
| } else if (!PyDict_Check(value)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__annotations__ must be set to a dict object"); | |
| return -1; | |
| } | |
| Py_XINCREF(value); | |
| tmp = op->func_annotations; | |
| op->func_annotations = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { | |
| PyObject* result = op->func_annotations; | |
| if (unlikely(!result)) { | |
| result = PyDict_New(); | |
| if (unlikely(!result)) return NULL; | |
| op->func_annotations = result; | |
| } | |
| Py_INCREF(result); | |
| return result; | |
| } | |
| static PyGetSetDef __pyx_CyFunction_getsets[] = { | |
| {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, | |
| {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, | |
| {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, | |
| {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, | |
| {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, | |
| {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, | |
| {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, | |
| {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, | |
| {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, | |
| {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, | |
| {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, | |
| {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, | |
| {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, | |
| {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, | |
| {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, | |
| {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, | |
| {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, | |
| {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, | |
| {0, 0, 0, 0, 0} | |
| }; | |
| static PyMemberDef __pyx_CyFunction_members[] = { | |
| {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, | |
| {0, 0, 0, 0, 0} | |
| }; | |
| static PyObject * | |
| __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) | |
| { | |
| Py_INCREF(m->func_qualname); | |
| return m->func_qualname; | |
| return PyString_FromString(m->func.m_ml->ml_name); | |
| } | |
| static PyMethodDef __pyx_CyFunction_methods[] = { | |
| {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, | |
| {0, 0, 0, 0} | |
| }; | |
| static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, | |
| PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { | |
| if (unlikely(op == NULL)) | |
| return NULL; | |
| op->flags = flags; | |
| __Pyx_CyFunction_weakreflist(op) = NULL; | |
| op->func.m_ml = ml; | |
| op->func.m_self = (PyObject *) op; | |
| Py_XINCREF(closure); | |
| op->func_closure = closure; | |
| Py_XINCREF(module); | |
| op->func.m_module = module; | |
| op->func_dict = NULL; | |
| op->func_name = NULL; | |
| Py_INCREF(qualname); | |
| op->func_qualname = qualname; | |
| op->func_doc = NULL; | |
| op->func_classobj = NULL; | |
| op->func_globals = globals; | |
| Py_INCREF(op->func_globals); | |
| Py_XINCREF(code); | |
| op->func_code = code; | |
| op->defaults_pyobjects = 0; | |
| op->defaults_size = 0; | |
| op->defaults = NULL; | |
| op->defaults_tuple = NULL; | |
| op->defaults_kwdict = NULL; | |
| op->defaults_getter = NULL; | |
| op->func_annotations = NULL; | |
| return (PyObject *) op; | |
| } | |
| static int | |
| __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) | |
| { | |
| Py_CLEAR(m->func_closure); | |
| Py_CLEAR(m->func.m_module); | |
| Py_CLEAR(m->func_dict); | |
| Py_CLEAR(m->func_name); | |
| Py_CLEAR(m->func_qualname); | |
| Py_CLEAR(m->func_doc); | |
| Py_CLEAR(m->func_globals); | |
| Py_CLEAR(m->func_code); | |
| Py_CLEAR(m->func_classobj); | |
| Py_CLEAR(m->defaults_tuple); | |
| Py_CLEAR(m->defaults_kwdict); | |
| Py_CLEAR(m->func_annotations); | |
| if (m->defaults) { | |
| PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); | |
| int i; | |
| for (i = 0; i < m->defaults_pyobjects; i++) | |
| Py_XDECREF(pydefaults[i]); | |
| PyObject_Free(m->defaults); | |
| m->defaults = NULL; | |
| } | |
| return 0; | |
| } | |
| static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) | |
| { | |
| if (__Pyx_CyFunction_weakreflist(m) != NULL) | |
| PyObject_ClearWeakRefs((PyObject *) m); | |
| __Pyx_CyFunction_clear(m); | |
| PyObject_GC_Del(m); | |
| } | |
| static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) | |
| { | |
| PyObject_GC_UnTrack(m); | |
| __Pyx__CyFunction_dealloc(m); | |
| } | |
| static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) | |
| { | |
| Py_VISIT(m->func_closure); | |
| Py_VISIT(m->func.m_module); | |
| Py_VISIT(m->func_dict); | |
| Py_VISIT(m->func_name); | |
| Py_VISIT(m->func_qualname); | |
| Py_VISIT(m->func_doc); | |
| Py_VISIT(m->func_globals); | |
| Py_VISIT(m->func_code); | |
| Py_VISIT(m->func_classobj); | |
| Py_VISIT(m->defaults_tuple); | |
| Py_VISIT(m->defaults_kwdict); | |
| if (m->defaults) { | |
| PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); | |
| int i; | |
| for (i = 0; i < m->defaults_pyobjects; i++) | |
| Py_VISIT(pydefaults[i]); | |
| } | |
| return 0; | |
| } | |
| static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) | |
| { | |
| __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; | |
| if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { | |
| Py_INCREF(func); | |
| return func; | |
| } | |
| if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { | |
| if (type == NULL) | |
| type = (PyObject *)(Py_TYPE(obj)); | |
| return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); | |
| } | |
| if (obj == Py_None) | |
| obj = NULL; | |
| return __Pyx_PyMethod_New(func, obj, type); | |
| } | |
| static PyObject* | |
| __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) | |
| { | |
| return PyUnicode_FromFormat("<cyfunction %U at %p>", | |
| op->func_qualname, (void *)op); | |
| return PyString_FromFormat("<cyfunction %s at %p>", | |
| PyString_AsString(op->func_qualname), (void *)op); | |
| } | |
| static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { | |
| PyCFunctionObject* f = (PyCFunctionObject*)func; | |
| PyCFunction meth = f->m_ml->ml_meth; | |
| Py_ssize_t size; | |
| switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { | |
| case METH_VARARGS: | |
| if (likely(kw == NULL || PyDict_Size(kw) == 0)) | |
| return (*meth)(self, arg); | |
| break; | |
| case METH_VARARGS | METH_KEYWORDS: | |
| return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); | |
| case METH_NOARGS: | |
| if (likely(kw == NULL || PyDict_Size(kw) == 0)) { | |
| size = PyTuple_GET_SIZE(arg); | |
| if (likely(size == 0)) | |
| return (*meth)(self, NULL); | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", | |
| f->m_ml->ml_name, size); | |
| return NULL; | |
| } | |
| break; | |
| case METH_O: | |
| if (likely(kw == NULL || PyDict_Size(kw) == 0)) { | |
| size = PyTuple_GET_SIZE(arg); | |
| if (likely(size == 1)) { | |
| PyObject *result, *arg0; | |
| arg0 = PyTuple_GET_ITEM(arg, 0); | |
| arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; | |
| result = (*meth)(self, arg0); | |
| Py_DECREF(arg0); | |
| return result; | |
| } | |
| PyErr_Format(PyExc_TypeError, | |
| "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", | |
| f->m_ml->ml_name, size); | |
| return NULL; | |
| } | |
| break; | |
| default: | |
| PyErr_SetString(PyExc_SystemError, "Bad call flags in " | |
| "__Pyx_CyFunction_Call. METH_OLDARGS is no " | |
| "longer supported!"); | |
| return NULL; | |
| } | |
| PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", | |
| f->m_ml->ml_name); | |
| return NULL; | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { | |
| return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); | |
| } | |
| static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { | |
| PyObject *result; | |
| __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; | |
| if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { | |
| Py_ssize_t argc; | |
| PyObject *new_args; | |
| PyObject *self; | |
| argc = PyTuple_GET_SIZE(args); | |
| new_args = PyTuple_GetSlice(args, 1, argc); | |
| if (unlikely(!new_args)) | |
| return NULL; | |
| self = PyTuple_GetItem(args, 0); | |
| if (unlikely(!self)) { | |
| Py_DECREF(new_args); | |
| PyErr_Format(PyExc_TypeError, | |
| "unbound method %.200S() needs an argument", | |
| cyfunc->func_qualname); | |
| PyErr_SetString(PyExc_TypeError, | |
| "unbound method needs an argument"); | |
| return NULL; | |
| } | |
| result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); | |
| Py_DECREF(new_args); | |
| } else { | |
| result = __Pyx_CyFunction_Call(func, args, kw); | |
| } | |
| return result; | |
| } | |
| static PyTypeObject __pyx_CyFunctionType_type = { | |
| PyVarObject_HEAD_INIT(0, 0) | |
| "cython_function_or_method", | |
| sizeof(__pyx_CyFunctionObject), | |
| 0, | |
| (destructor) __Pyx_CyFunction_dealloc, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| (reprfunc) __Pyx_CyFunction_repr, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| __Pyx_CyFunction_CallAsMethod, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, | |
| 0, | |
| (traverseproc) __Pyx_CyFunction_traverse, | |
| (inquiry) __Pyx_CyFunction_clear, | |
| 0, | |
| offsetof(__pyx_CyFunctionObject, func_weakreflist), | |
| offsetof(PyCFunctionObject, m_weakreflist), | |
| 0, | |
| 0, | |
| __pyx_CyFunction_methods, | |
| __pyx_CyFunction_members, | |
| __pyx_CyFunction_getsets, | |
| 0, | |
| 0, | |
| __Pyx_CyFunction_descr_get, | |
| 0, | |
| offsetof(__pyx_CyFunctionObject, func_dict), | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| }; | |
| static int __pyx_CyFunction_init(void) { | |
| __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); | |
| if (unlikely(__pyx_CyFunctionType == NULL)) { | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { | |
| __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; | |
| m->defaults = PyObject_Malloc(size); | |
| if (unlikely(!m->defaults)) | |
| return PyErr_NoMemory(); | |
| memset(m->defaults, 0, size); | |
| m->defaults_pyobjects = pyobjects; | |
| m->defaults_size = size; | |
| return m->defaults; | |
| } | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { | |
| __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; | |
| m->defaults_tuple = tuple; | |
| Py_INCREF(tuple); | |
| } | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { | |
| __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; | |
| m->defaults_kwdict = dict; | |
| Py_INCREF(dict); | |
| } | |
| static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { | |
| __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; | |
| m->func_annotations = dict; | |
| Py_INCREF(dict); | |
| } | |
| /* CythonFunction */ | |
| static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, | |
| PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { | |
| PyObject *op = __Pyx_CyFunction_Init( | |
| PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), | |
| ml, flags, qualname, closure, module, globals, code | |
| ); | |
| if (likely(op)) { | |
| PyObject_GC_Track(op); | |
| } | |
| return op; | |
| } | |
| /* CLineInTraceback */ | |
| static int __Pyx_CLineForTraceback(CYTHON_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; | |
| (void) 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 = NULL; | |
| PyObject *py_funcname = NULL; | |
| PyObject *py_srcfile = NULL; | |
| py_srcfile = PyString_FromString(filename); | |
| if (!py_srcfile) goto bad; | |
| if (c_line) { | |
| py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| if (!py_funcname) goto bad; | |
| py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| if (!py_funcname) goto bad; | |
| funcname = PyUnicode_AsUTF8(py_funcname); | |
| if (!funcname) goto bad; | |
| } | |
| else { | |
| py_funcname = PyString_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_code = PyCode_NewEmpty(filename, funcname, py_line); | |
| Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline | |
| return py_code; | |
| bad: | |
| Py_XDECREF(py_funcname); | |
| Py_XDECREF(py_srcfile); | |
| 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; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| 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) { | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| py_code = __Pyx_CreateCodeObjectForTraceback( | |
| funcname, c_line, py_line, filename); | |
| if (!py_code) { | |
| /* If the code object creation fails, then we should clear the | |
| fetched exception references and propagate the new exception */ | |
| Py_XDECREF(ptype); | |
| Py_XDECREF(pvalue); | |
| Py_XDECREF(ptraceback); | |
| goto bad; | |
| } | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| __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); | |
| } | |
| /* FromPy */ | |
| static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) { | |
| Py_complex cval; | |
| if (PyComplex_CheckExact(o)) | |
| cval = ((PyComplexObject *)o)->cval; | |
| else | |
| cval = PyComplex_AsCComplex(o); | |
| return __pyx_t_double_complex_from_parts( | |
| (double)cval.real, | |
| (double)cval.imag); | |
| } | |
| /* CIntFromPyVerify */ | |
| /* Declarations */ | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { | |
| return ::std::complex< double >(x, y); | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { | |
| return x + y*(__pyx_t_double_complex)_Complex_I; | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { | |
| __pyx_t_double_complex z; | |
| z.real = x; | |
| z.imag = y; | |
| return z; | |
| } | |
| /* Arithmetic */ | |
| static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| return (a.real == b.real) && (a.imag == b.imag); | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| __pyx_t_double_complex z; | |
| z.real = a.real + b.real; | |
| z.imag = a.imag + b.imag; | |
| return z; | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| __pyx_t_double_complex z; | |
| z.real = a.real - b.real; | |
| z.imag = a.imag - b.imag; | |
| return z; | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| __pyx_t_double_complex z; | |
| z.real = a.real * b.real - a.imag * b.imag; | |
| z.imag = a.real * b.imag + a.imag * b.real; | |
| return z; | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| if (b.imag == 0) { | |
| return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); | |
| } else if (fabs(b.real) >= fabs(b.imag)) { | |
| if (b.real == 0 && b.imag == 0) { | |
| return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); | |
| } else { | |
| double r = b.imag / b.real; | |
| double s = (double)(1.0) / (b.real + b.imag * r); | |
| return __pyx_t_double_complex_from_parts( | |
| (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); | |
| } | |
| } else { | |
| double r = b.real / b.imag; | |
| double s = (double)(1.0) / (b.imag + b.real * r); | |
| return __pyx_t_double_complex_from_parts( | |
| (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); | |
| } | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| if (b.imag == 0) { | |
| return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); | |
| } else { | |
| double denom = b.real * b.real + b.imag * b.imag; | |
| return __pyx_t_double_complex_from_parts( | |
| (a.real * b.real + a.imag * b.imag) / denom, | |
| (a.imag * b.real - a.real * b.imag) / denom); | |
| } | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { | |
| __pyx_t_double_complex z; | |
| z.real = -a.real; | |
| z.imag = -a.imag; | |
| return z; | |
| } | |
| static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { | |
| return (a.real == 0) && (a.imag == 0); | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { | |
| __pyx_t_double_complex z; | |
| z.real = a.real; | |
| z.imag = -a.imag; | |
| return z; | |
| } | |
| static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { | |
| return sqrt(z.real*z.real + z.imag*z.imag); | |
| return hypot(z.real, z.imag); | |
| } | |
| static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { | |
| __pyx_t_double_complex z; | |
| double r, lnr, theta, z_r, z_theta; | |
| if (b.imag == 0 && b.real == (int)b.real) { | |
| if (b.real < 0) { | |
| double denom = a.real * a.real + a.imag * a.imag; | |
| a.real = a.real / denom; | |
| a.imag = -a.imag / denom; | |
| b.real = -b.real; | |
| } | |
| switch ((int)b.real) { | |
| case 0: | |
| z.real = 1; | |
| z.imag = 0; | |
| return z; | |
| case 1: | |
| return a; | |
| case 2: | |
| return __Pyx_c_prod_double(a, a); | |
| case 3: | |
| z = __Pyx_c_prod_double(a, a); | |
| return __Pyx_c_prod_double(z, a); | |
| case 4: | |
| z = __Pyx_c_prod_double(a, a); | |
| return __Pyx_c_prod_double(z, z); | |
| } | |
| } | |
| if (a.imag == 0) { | |
| if (a.real == 0) { | |
| return a; | |
| } else if ((b.imag == 0) && (a.real >= 0)) { | |
| z.real = pow(a.real, b.real); | |
| z.imag = 0; | |
| return z; | |
| } else if (a.real > 0) { | |
| r = a.real; | |
| theta = 0; | |
| } else { | |
| r = -a.real; | |
| theta = atan2(0.0, -1.0); | |
| } | |
| } else { | |
| r = __Pyx_c_abs_double(a); | |
| theta = atan2(a.imag, a.real); | |
| } | |
| lnr = log(r); | |
| z_r = exp(lnr * b.real - theta * b.imag); | |
| z_theta = theta * b.real + lnr * b.imag; | |
| z.real = z_r * cos(z_theta); | |
| z.imag = z_r * sin(z_theta); | |
| return z; | |
| } | |
| /* 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; | |
| } | |
| /* 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); | |
| } | |
| } | |
| /* CIntToPy */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { | |
| const int neg_one = (int) -1, const_zero = (int) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (is_unsigned) { | |
| if (sizeof(int) < sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(int) <= sizeof(unsigned long)) { | |
| return PyLong_FromUnsignedLong((unsigned long) value); | |
| } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { | |
| return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); | |
| } | |
| } else { | |
| if (sizeof(int) <= sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(int) <= 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(int), | |
| little, !is_unsigned); | |
| } | |
| } | |
| /* 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; | |
| } | |
| /* 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)); | |
| } | |
| /* SwapException */ | |
| static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| _PyErr_StackItem *exc_info = tstate->exc_info; | |
| tmp_type = exc_info->exc_type; | |
| tmp_value = exc_info->exc_value; | |
| tmp_tb = exc_info->exc_traceback; | |
| exc_info->exc_type = *type; | |
| exc_info->exc_value = *value; | |
| exc_info->exc_traceback = *tb; | |
| tmp_type = tstate->exc_type; | |
| tmp_value = tstate->exc_value; | |
| tmp_tb = tstate->exc_traceback; | |
| tstate->exc_type = *type; | |
| tstate->exc_value = *value; | |
| tstate->exc_traceback = *tb; | |
| *type = tmp_type; | |
| *value = tmp_value; | |
| *tb = tmp_tb; | |
| } | |
| static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); | |
| PyErr_SetExcInfo(*type, *value, *tb); | |
| *type = tmp_type; | |
| *value = tmp_value; | |
| *tb = tmp_tb; | |
| } | |
| /* PyObjectGetMethod */ | |
| static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { | |
| PyObject *attr; | |
| PyTypeObject *tp = Py_TYPE(obj); | |
| PyObject *descr; | |
| descrgetfunc f = NULL; | |
| PyObject **dictptr, *dict; | |
| int meth_found = 0; | |
| assert (*method == NULL); | |
| if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { | |
| attr = __Pyx_PyObject_GetAttrStr(obj, name); | |
| goto try_unpack; | |
| } | |
| if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { | |
| return 0; | |
| } | |
| descr = _PyType_Lookup(tp, name); | |
| if (likely(descr != NULL)) { | |
| Py_INCREF(descr); | |
| if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) | |
| if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) | |
| if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) | |
| if (likely(PyFunction_Check(descr))) | |
| { | |
| meth_found = 1; | |
| } else { | |
| f = Py_TYPE(descr)->tp_descr_get; | |
| if (f != NULL && PyDescr_IsData(descr)) { | |
| attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); | |
| Py_DECREF(descr); | |
| goto try_unpack; | |
| } | |
| } | |
| } | |
| dictptr = _PyObject_GetDictPtr(obj); | |
| if (dictptr != NULL && (dict = *dictptr) != NULL) { | |
| Py_INCREF(dict); | |
| attr = __Pyx_PyDict_GetItemStr(dict, name); | |
| if (attr != NULL) { | |
| Py_INCREF(attr); | |
| Py_DECREF(dict); | |
| Py_XDECREF(descr); | |
| goto try_unpack; | |
| } | |
| Py_DECREF(dict); | |
| } | |
| if (meth_found) { | |
| *method = descr; | |
| return 1; | |
| } | |
| if (f != NULL) { | |
| attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); | |
| Py_DECREF(descr); | |
| goto try_unpack; | |
| } | |
| if (descr != NULL) { | |
| *method = descr; | |
| return 0; | |
| } | |
| PyErr_Format(PyExc_AttributeError, | |
| "'%.50s' object has no attribute '%U'", | |
| tp->tp_name, name); | |
| "'%.50s' object has no attribute '%.400s'", | |
| tp->tp_name, PyString_AS_STRING(name)); | |
| return 0; | |
| attr = __Pyx_PyObject_GetAttrStr(obj, name); | |
| goto try_unpack; | |
| try_unpack: | |
| if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { | |
| PyObject *function = PyMethod_GET_FUNCTION(attr); | |
| Py_INCREF(function); | |
| Py_DECREF(attr); | |
| *method = function; | |
| return 1; | |
| } | |
| *method = attr; | |
| return 0; | |
| } | |
| /* PyObjectCallMethod1 */ | |
| static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { | |
| PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); | |
| Py_DECREF(method); | |
| return result; | |
| } | |
| static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { | |
| PyObject *method = NULL, *result; | |
| int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); | |
| if (likely(is_method)) { | |
| result = __Pyx_PyObject_Call2Args(method, obj, arg); | |
| Py_DECREF(method); | |
| return result; | |
| } | |
| if (unlikely(!method)) return NULL; | |
| return __Pyx__PyObject_CallMethod1(method, arg); | |
| } | |
| /* CoroutineBase */ | |
| static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) { | |
| PyObject *et, *ev, *tb; | |
| PyObject *value = NULL; | |
| __Pyx_ErrFetch(&et, &ev, &tb); | |
| if (!et) { | |
| Py_XDECREF(tb); | |
| Py_XDECREF(ev); | |
| Py_INCREF(Py_None); | |
| *pvalue = Py_None; | |
| return 0; | |
| } | |
| if (likely(et == PyExc_StopIteration)) { | |
| if (!ev) { | |
| Py_INCREF(Py_None); | |
| value = Py_None; | |
| } | |
| else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { | |
| value = ((PyStopIterationObject *)ev)->value; | |
| Py_INCREF(value); | |
| Py_DECREF(ev); | |
| } | |
| else if (unlikely(PyTuple_Check(ev))) { | |
| if (PyTuple_GET_SIZE(ev) >= 1) { | |
| value = PyTuple_GET_ITEM(ev, 0); | |
| Py_INCREF(value); | |
| value = PySequence_ITEM(ev, 0); | |
| } else { | |
| Py_INCREF(Py_None); | |
| value = Py_None; | |
| } | |
| Py_DECREF(ev); | |
| } | |
| else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { | |
| value = ev; | |
| } | |
| if (likely(value)) { | |
| Py_XDECREF(tb); | |
| Py_DECREF(et); | |
| *pvalue = value; | |
| return 0; | |
| } | |
| } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { | |
| __Pyx_ErrRestore(et, ev, tb); | |
| return -1; | |
| } | |
| PyErr_NormalizeException(&et, &ev, &tb); | |
| if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { | |
| __Pyx_ErrRestore(et, ev, tb); | |
| return -1; | |
| } | |
| Py_XDECREF(tb); | |
| Py_DECREF(et); | |
| value = ((PyStopIterationObject *)ev)->value; | |
| Py_INCREF(value); | |
| Py_DECREF(ev); | |
| { | |
| PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); | |
| Py_DECREF(ev); | |
| if (likely(args)) { | |
| value = PySequence_GetItem(args, 0); | |
| Py_DECREF(args); | |
| } | |
| if (unlikely(!value)) { | |
| __Pyx_ErrRestore(NULL, NULL, NULL); | |
| Py_INCREF(Py_None); | |
| value = Py_None; | |
| } | |
| } | |
| *pvalue = value; | |
| return 0; | |
| } | |
| static CYTHON_INLINE | |
| void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { | |
| PyObject *t, *v, *tb; | |
| t = exc_state->exc_type; | |
| v = exc_state->exc_value; | |
| tb = exc_state->exc_traceback; | |
| exc_state->exc_type = NULL; | |
| exc_state->exc_value = NULL; | |
| exc_state->exc_traceback = NULL; | |
| Py_XDECREF(t); | |
| Py_XDECREF(v); | |
| Py_XDECREF(tb); | |
| } | |
| static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) { | |
| const char *msg; | |
| if ((0)) { | |
| } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { | |
| msg = "coroutine already executing"; | |
| } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { | |
| msg = "async generator already executing"; | |
| } else { | |
| msg = "generator already executing"; | |
| } | |
| PyErr_SetString(PyExc_ValueError, msg); | |
| } | |
| static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) { | |
| const char *msg; | |
| if ((0)) { | |
| } else if (__Pyx_Coroutine_Check(gen)) { | |
| msg = "can't send non-None value to a just-started coroutine"; | |
| } else if (__Pyx_AsyncGen_CheckExact(gen)) { | |
| msg = "can't send non-None value to a just-started async generator"; | |
| } else { | |
| msg = "can't send non-None value to a just-started generator"; | |
| } | |
| PyErr_SetString(PyExc_TypeError, msg); | |
| } | |
| static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) { | |
| if (!closing && __Pyx_Coroutine_Check(gen)) { | |
| PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); | |
| } else | |
| if (value) { | |
| if (__Pyx_AsyncGen_CheckExact(gen)) | |
| PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); | |
| else | |
| PyErr_SetNone(PyExc_StopIteration); | |
| } | |
| } | |
| static | |
| PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { | |
| __Pyx_PyThreadState_declare | |
| PyThreadState *tstate; | |
| __Pyx_ExcInfoStruct *exc_state; | |
| PyObject *retval; | |
| assert(!self->is_running); | |
| if (unlikely(self->resume_label == 0)) { | |
| if (unlikely(value && value != Py_None)) { | |
| return __Pyx_Coroutine_NotStartedError((PyObject*)self); | |
| } | |
| } | |
| if (unlikely(self->resume_label == -1)) { | |
| return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); | |
| } | |
| __Pyx_PyThreadState_assign | |
| tstate = __pyx_tstate; | |
| tstate = __Pyx_PyThreadState_Current; | |
| exc_state = &self->gi_exc_state; | |
| if (exc_state->exc_type) { | |
| if (exc_state->exc_traceback) { | |
| PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback; | |
| PyFrameObject *f = tb->tb_frame; | |
| assert(f->f_back == NULL); | |
| f->f_back = PyThreadState_GetFrame(tstate); | |
| Py_XINCREF(tstate->frame); | |
| f->f_back = tstate->frame; | |
| } | |
| } | |
| exc_state->previous_item = tstate->exc_info; | |
| tstate->exc_info = exc_state; | |
| if (exc_state->exc_type) { | |
| __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); | |
| } else { | |
| __Pyx_Coroutine_ExceptionClear(exc_state); | |
| __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); | |
| } | |
| self->is_running = 1; | |
| retval = self->body((PyObject *) self, tstate, value); | |
| self->is_running = 0; | |
| exc_state = &self->gi_exc_state; | |
| tstate->exc_info = exc_state->previous_item; | |
| exc_state->previous_item = NULL; | |
| __Pyx_Coroutine_ResetFrameBackpointer(exc_state); | |
| return retval; | |
| } | |
| static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { | |
| PyObject *exc_tb = exc_state->exc_traceback; | |
| if (likely(exc_tb)) { | |
| PyTracebackObject *tb = (PyTracebackObject *) exc_tb; | |
| PyFrameObject *f = tb->tb_frame; | |
| Py_CLEAR(f->f_back); | |
| } | |
| } | |
| static CYTHON_INLINE | |
| PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) { | |
| if (unlikely(!retval)) { | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| if (!__Pyx_PyErr_Occurred()) { | |
| PyObject *exc = PyExc_StopIteration; | |
| if (__Pyx_AsyncGen_CheckExact(gen)) | |
| exc = __Pyx_PyExc_StopAsyncIteration; | |
| __Pyx_PyErr_SetNone(exc); | |
| } | |
| } | |
| return retval; | |
| } | |
| static CYTHON_INLINE | |
| PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { | |
| return _PyGen_Send(gen, arg); | |
| PyObject *result; | |
| if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { | |
| if (PyAsyncGen_CheckExact(gen)) { | |
| assert(result == Py_None); | |
| PyErr_SetNone(PyExc_StopAsyncIteration); | |
| } | |
| else if (result == Py_None) { | |
| PyErr_SetNone(PyExc_StopIteration); | |
| } | |
| else { | |
| _PyGen_SetStopIterationValue(result); | |
| } | |
| Py_CLEAR(result); | |
| } | |
| return result; | |
| } | |
| static CYTHON_INLINE | |
| PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { | |
| PyObject *ret; | |
| PyObject *val = NULL; | |
| __Pyx_Coroutine_Undelegate(gen); | |
| __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); | |
| ret = __Pyx_Coroutine_SendEx(gen, val, 0); | |
| Py_XDECREF(val); | |
| return ret; | |
| } | |
| static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { | |
| PyObject *retval; | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; | |
| PyObject *yf = gen->yieldfrom; | |
| if (unlikely(gen->is_running)) | |
| return __Pyx_Coroutine_AlreadyRunningError(gen); | |
| if (yf) { | |
| PyObject *ret; | |
| gen->is_running = 1; | |
| if (__Pyx_Generator_CheckExact(yf)) { | |
| ret = __Pyx_Coroutine_Send(yf, value); | |
| } else | |
| if (__Pyx_Coroutine_Check(yf)) { | |
| ret = __Pyx_Coroutine_Send(yf, value); | |
| } else | |
| if (__pyx_PyAsyncGenASend_CheckExact(yf)) { | |
| ret = __Pyx_async_gen_asend_send(yf, value); | |
| } else | |
| if (PyGen_CheckExact(yf)) { | |
| ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); | |
| } else | |
| if (PyCoro_CheckExact(yf)) { | |
| ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); | |
| } else | |
| { | |
| if (value == Py_None) | |
| ret = Py_TYPE(yf)->tp_iternext(yf); | |
| else | |
| ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); | |
| } | |
| gen->is_running = 0; | |
| if (likely(ret)) { | |
| return ret; | |
| } | |
| retval = __Pyx_Coroutine_FinishDelegation(gen); | |
| } else { | |
| retval = __Pyx_Coroutine_SendEx(gen, value, 0); | |
| } | |
| return __Pyx_Coroutine_MethodReturn(self, retval); | |
| } | |
| static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { | |
| PyObject *retval = NULL; | |
| int err = 0; | |
| if (__Pyx_Generator_CheckExact(yf)) { | |
| retval = __Pyx_Coroutine_Close(yf); | |
| if (!retval) | |
| return -1; | |
| } else | |
| if (__Pyx_Coroutine_Check(yf)) { | |
| retval = __Pyx_Coroutine_Close(yf); | |
| if (!retval) | |
| return -1; | |
| } else | |
| if (__Pyx_CoroutineAwait_CheckExact(yf)) { | |
| retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); | |
| if (!retval) | |
| return -1; | |
| } else | |
| if (__pyx_PyAsyncGenASend_CheckExact(yf)) { | |
| retval = __Pyx_async_gen_asend_close(yf, NULL); | |
| } else | |
| if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { | |
| retval = __Pyx_async_gen_athrow_close(yf, NULL); | |
| } else | |
| { | |
| PyObject *meth; | |
| gen->is_running = 1; | |
| meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close); | |
| if (unlikely(!meth)) { | |
| if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| PyErr_WriteUnraisable(yf); | |
| } | |
| PyErr_Clear(); | |
| } else { | |
| retval = PyObject_CallFunction(meth, NULL); | |
| Py_DECREF(meth); | |
| if (!retval) | |
| err = -1; | |
| } | |
| gen->is_running = 0; | |
| } | |
| Py_XDECREF(retval); | |
| return err; | |
| } | |
| static PyObject *__Pyx_Generator_Next(PyObject *self) { | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; | |
| PyObject *yf = gen->yieldfrom; | |
| if (unlikely(gen->is_running)) | |
| return __Pyx_Coroutine_AlreadyRunningError(gen); | |
| if (yf) { | |
| PyObject *ret; | |
| gen->is_running = 1; | |
| if (__Pyx_Generator_CheckExact(yf)) { | |
| ret = __Pyx_Generator_Next(yf); | |
| } else | |
| if (PyGen_CheckExact(yf)) { | |
| ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); | |
| } else | |
| if (__Pyx_Coroutine_Check(yf)) { | |
| ret = __Pyx_Coroutine_Send(yf, Py_None); | |
| } else | |
| ret = Py_TYPE(yf)->tp_iternext(yf); | |
| gen->is_running = 0; | |
| if (likely(ret)) { | |
| return ret; | |
| } | |
| return __Pyx_Coroutine_FinishDelegation(gen); | |
| } | |
| return __Pyx_Coroutine_SendEx(gen, Py_None, 0); | |
| } | |
| static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) { | |
| return __Pyx_Coroutine_Close(self); | |
| } | |
| static PyObject *__Pyx_Coroutine_Close(PyObject *self) { | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; | |
| PyObject *retval, *raised_exception; | |
| PyObject *yf = gen->yieldfrom; | |
| int err = 0; | |
| if (unlikely(gen->is_running)) | |
| return __Pyx_Coroutine_AlreadyRunningError(gen); | |
| if (yf) { | |
| Py_INCREF(yf); | |
| err = __Pyx_Coroutine_CloseIter(gen, yf); | |
| __Pyx_Coroutine_Undelegate(gen); | |
| Py_DECREF(yf); | |
| } | |
| if (err == 0) | |
| PyErr_SetNone(PyExc_GeneratorExit); | |
| retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); | |
| if (unlikely(retval)) { | |
| const char *msg; | |
| Py_DECREF(retval); | |
| if ((0)) { | |
| } else if (__Pyx_Coroutine_Check(self)) { | |
| msg = "coroutine ignored GeneratorExit"; | |
| } else if (__Pyx_AsyncGen_CheckExact(self)) { | |
| msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; | |
| msg = "async generator ignored GeneratorExit"; | |
| } else { | |
| msg = "generator ignored GeneratorExit"; | |
| } | |
| PyErr_SetString(PyExc_RuntimeError, msg); | |
| return NULL; | |
| } | |
| raised_exception = PyErr_Occurred(); | |
| if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { | |
| if (raised_exception) PyErr_Clear(); | |
| Py_INCREF(Py_None); | |
| return Py_None; | |
| } | |
| return NULL; | |
| } | |
| static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, | |
| PyObject *args, int close_on_genexit) { | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; | |
| PyObject *yf = gen->yieldfrom; | |
| if (unlikely(gen->is_running)) | |
| return __Pyx_Coroutine_AlreadyRunningError(gen); | |
| if (yf) { | |
| PyObject *ret; | |
| Py_INCREF(yf); | |
| if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { | |
| int err = __Pyx_Coroutine_CloseIter(gen, yf); | |
| Py_DECREF(yf); | |
| __Pyx_Coroutine_Undelegate(gen); | |
| if (err < 0) | |
| return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); | |
| goto throw_here; | |
| } | |
| gen->is_running = 1; | |
| if (0 | |
| || __Pyx_Generator_CheckExact(yf) | |
| || __Pyx_Coroutine_Check(yf) | |
| ) { | |
| ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); | |
| } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { | |
| ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); | |
| } else { | |
| PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); | |
| if (unlikely(!meth)) { | |
| Py_DECREF(yf); | |
| if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| gen->is_running = 0; | |
| return NULL; | |
| } | |
| PyErr_Clear(); | |
| __Pyx_Coroutine_Undelegate(gen); | |
| gen->is_running = 0; | |
| goto throw_here; | |
| } | |
| if (likely(args)) { | |
| ret = PyObject_CallObject(meth, args); | |
| } else { | |
| ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL); | |
| } | |
| Py_DECREF(meth); | |
| } | |
| gen->is_running = 0; | |
| Py_DECREF(yf); | |
| if (!ret) { | |
| ret = __Pyx_Coroutine_FinishDelegation(gen); | |
| } | |
| return __Pyx_Coroutine_MethodReturn(self, ret); | |
| } | |
| throw_here: | |
| __Pyx_Raise(typ, val, tb, NULL); | |
| return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); | |
| } | |
| static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { | |
| PyObject *typ; | |
| PyObject *val = NULL; | |
| PyObject *tb = NULL; | |
| if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) | |
| return NULL; | |
| return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); | |
| } | |
| static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { | |
| Py_VISIT(exc_state->exc_type); | |
| Py_VISIT(exc_state->exc_value); | |
| Py_VISIT(exc_state->exc_traceback); | |
| return 0; | |
| } | |
| static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { | |
| Py_VISIT(gen->closure); | |
| Py_VISIT(gen->classobj); | |
| Py_VISIT(gen->yieldfrom); | |
| return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); | |
| } | |
| static int __Pyx_Coroutine_clear(PyObject *self) { | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; | |
| Py_CLEAR(gen->closure); | |
| Py_CLEAR(gen->classobj); | |
| Py_CLEAR(gen->yieldfrom); | |
| __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); | |
| if (__Pyx_AsyncGen_CheckExact(self)) { | |
| Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); | |
| } | |
| Py_CLEAR(gen->gi_code); | |
| Py_CLEAR(gen->gi_frame); | |
| Py_CLEAR(gen->gi_name); | |
| Py_CLEAR(gen->gi_qualname); | |
| Py_CLEAR(gen->gi_modulename); | |
| return 0; | |
| } | |
| static void __Pyx_Coroutine_dealloc(PyObject *self) { | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; | |
| PyObject_GC_UnTrack(gen); | |
| if (gen->gi_weakreflist != NULL) | |
| PyObject_ClearWeakRefs(self); | |
| if (gen->resume_label >= 0) { | |
| PyObject_GC_Track(self); | |
| if (PyObject_CallFinalizerFromDealloc(self)) | |
| Py_TYPE(gen)->tp_del(self); | |
| if (Py_REFCNT(self) > 0) | |
| { | |
| return; | |
| } | |
| PyObject_GC_UnTrack(self); | |
| } | |
| if (__Pyx_AsyncGen_CheckExact(self)) { | |
| /* We have to handle this case for asynchronous generators | |
| right here, because this code has to be between UNTRACK | |
| and GC_Del. */ | |
| Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); | |
| } | |
| __Pyx_Coroutine_clear(self); | |
| PyObject_GC_Del(gen); | |
| } | |
| static void __Pyx_Coroutine_del(PyObject *self) { | |
| PyObject *error_type, *error_value, *error_traceback; | |
| __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; | |
| __Pyx_PyThreadState_declare | |
| if (gen->resume_label < 0) { | |
| return; | |
| } | |
| assert(self->ob_refcnt == 0); | |
| __Pyx_SET_REFCNT(self, 1); | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); | |
| if (__Pyx_AsyncGen_CheckExact(self)) { | |
| __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; | |
| PyObject *finalizer = agen->ag_finalizer; | |
| if (finalizer && !agen->ag_closed) { | |
| PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); | |
| if (unlikely(!res)) { | |
| PyErr_WriteUnraisable(self); | |
| } else { | |
| Py_DECREF(res); | |
| } | |
| __Pyx_ErrRestore(error_type, error_value, error_traceback); | |
| return; | |
| } | |
| } | |
| if (unlikely(gen->resume_label == 0 && !error_value)) { | |
| if (!__Pyx_Generator_CheckExact(self)) | |
| { | |
| PyObject_GC_UnTrack(self); | |
| if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) | |
| PyErr_WriteUnraisable(self); | |
| {PyObject *msg; | |
| char *cmsg; | |
| msg = NULL; | |
| cmsg = (char*) "coroutine was never awaited"; | |
| char *cname; | |
| PyObject *qualname; | |
| qualname = gen->gi_qualname; | |
| cname = PyString_AS_STRING(qualname); | |
| msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); | |
| if (unlikely(!msg)) { | |
| PyErr_Clear(); | |
| cmsg = (char*) "coroutine was never awaited"; | |
| } else { | |
| cmsg = PyString_AS_STRING(msg); | |
| } | |
| if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) | |
| PyErr_WriteUnraisable(self); | |
| Py_XDECREF(msg);} | |
| PyObject_GC_Track(self); | |
| } | |
| } else { | |
| PyObject *res = __Pyx_Coroutine_Close(self); | |
| if (unlikely(!res)) { | |
| if (PyErr_Occurred()) | |
| PyErr_WriteUnraisable(self); | |
| } else { | |
| Py_DECREF(res); | |
| } | |
| } | |
| __Pyx_ErrRestore(error_type, error_value, error_traceback); | |
| assert(Py_REFCNT(self) > 0); | |
| if (--self->ob_refcnt == 0) { | |
| return; | |
| } | |
| { | |
| Py_ssize_t refcnt = Py_REFCNT(self); | |
| _Py_NewReference(self); | |
| __Pyx_SET_REFCNT(self, refcnt); | |
| } | |
| assert(PyType_IS_GC(Py_TYPE(self)) && | |
| _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); | |
| _Py_DEC_REFTOTAL; | |
| --Py_TYPE(self)->tp_frees; | |
| --Py_TYPE(self)->tp_allocs; | |
| } | |
| static PyObject * | |
| __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *name = self->gi_name; | |
| if (unlikely(!name)) name = Py_None; | |
| Py_INCREF(name); | |
| return name; | |
| } | |
| static int | |
| __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp; | |
| if (unlikely(value == NULL || !PyUnicode_Check(value))) | |
| if (unlikely(value == NULL || !PyString_Check(value))) | |
| { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__name__ must be set to a string object"); | |
| return -1; | |
| } | |
| tmp = self->gi_name; | |
| Py_INCREF(value); | |
| self->gi_name = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *name = self->gi_qualname; | |
| if (unlikely(!name)) name = Py_None; | |
| Py_INCREF(name); | |
| return name; | |
| } | |
| static int | |
| __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *tmp; | |
| if (unlikely(value == NULL || !PyUnicode_Check(value))) | |
| if (unlikely(value == NULL || !PyString_Check(value))) | |
| { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__qualname__ must be set to a string object"); | |
| return -1; | |
| } | |
| tmp = self->gi_qualname; | |
| Py_INCREF(value); | |
| self->gi_qualname = value; | |
| Py_XDECREF(tmp); | |
| return 0; | |
| } | |
| static PyObject * | |
| __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) | |
| { | |
| PyObject *frame = self->gi_frame; | |
| if (!frame) { | |
| if (unlikely(!self->gi_code)) { | |
| Py_RETURN_NONE; | |
| } | |
| frame = (PyObject *) PyFrame_New( | |
| PyThreadState_Get(), /*PyThreadState *tstate,*/ | |
| (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ | |
| __pyx_d, /*PyObject *globals,*/ | |
| 0 /*PyObject *locals*/ | |
| ); | |
| if (unlikely(!frame)) | |
| return NULL; | |
| self->gi_frame = frame; | |
| } | |
| Py_INCREF(frame); | |
| return frame; | |
| } | |
| static __pyx_CoroutineObject *__Pyx__Coroutine_New( | |
| PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, | |
| PyObject *name, PyObject *qualname, PyObject *module_name) { | |
| __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); | |
| if (unlikely(!gen)) | |
| return NULL; | |
| return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); | |
| } | |
| static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( | |
| __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, | |
| PyObject *name, PyObject *qualname, PyObject *module_name) { | |
| gen->body = body; | |
| gen->closure = closure; | |
| Py_XINCREF(closure); | |
| gen->is_running = 0; | |
| gen->resume_label = 0; | |
| gen->classobj = NULL; | |
| gen->yieldfrom = NULL; | |
| gen->gi_exc_state.exc_type = NULL; | |
| gen->gi_exc_state.exc_value = NULL; | |
| gen->gi_exc_state.exc_traceback = NULL; | |
| gen->gi_exc_state.previous_item = NULL; | |
| gen->gi_weakreflist = NULL; | |
| Py_XINCREF(qualname); | |
| gen->gi_qualname = qualname; | |
| Py_XINCREF(name); | |
| gen->gi_name = name; | |
| Py_XINCREF(module_name); | |
| gen->gi_modulename = module_name; | |
| Py_XINCREF(code); | |
| gen->gi_code = code; | |
| gen->gi_frame = NULL; | |
| PyObject_GC_Track(gen); | |
| return gen; | |
| } | |
| /* PatchModuleWithCoroutine */ | |
| static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { | |
| int result; | |
| PyObject *globals, *result_obj; | |
| globals = PyDict_New(); if (unlikely(!globals)) goto ignore; | |
| result = PyDict_SetItemString(globals, "_cython_coroutine_type", | |
| (PyObject*)__pyx_CoroutineType); | |
| Py_None); | |
| if (unlikely(result < 0)) goto ignore; | |
| result = PyDict_SetItemString(globals, "_cython_generator_type", | |
| (PyObject*)__pyx_GeneratorType); | |
| Py_None); | |
| if (unlikely(result < 0)) goto ignore; | |
| if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; | |
| if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; | |
| result_obj = PyRun_String(py_code, Py_file_input, globals, globals); | |
| if (unlikely(!result_obj)) goto ignore; | |
| Py_DECREF(result_obj); | |
| Py_DECREF(globals); | |
| return module; | |
| ignore: | |
| Py_XDECREF(globals); | |
| PyErr_WriteUnraisable(module); | |
| if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { | |
| Py_DECREF(module); | |
| module = NULL; | |
| } | |
| py_code++; | |
| return module; | |
| } | |
| /* PatchGeneratorABC */ | |
| static PyObject* __Pyx_patch_abc_module(PyObject *module); | |
| static PyObject* __Pyx_patch_abc_module(PyObject *module) { | |
| module = __Pyx_Coroutine_patch_module( | |
| module, "" | |
| "if _cython_generator_type is not None:\n" | |
| " try: Generator = _module.Generator\n" | |
| " except AttributeError: pass\n" | |
| " else: Generator.register(_cython_generator_type)\n" | |
| "if _cython_coroutine_type is not None:\n" | |
| " try: Coroutine = _module.Coroutine\n" | |
| " except AttributeError: pass\n" | |
| " else: Coroutine.register(_cython_coroutine_type)\n" | |
| ); | |
| return module; | |
| } | |
| static int __Pyx_patch_abc(void) { | |
| static int abc_patched = 0; | |
| if (CYTHON_REGISTER_ABCS && !abc_patched) { | |
| PyObject *module; | |
| module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); | |
| if (!module) { | |
| PyErr_WriteUnraisable(NULL); | |
| if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, | |
| ((PY_MAJOR_VERSION >= 3) ? | |
| "Cython module failed to register with collections.abc module" : | |
| "Cython module failed to register with collections module"), 1) < 0)) { | |
| return -1; | |
| } | |
| } else { | |
| module = __Pyx_patch_abc_module(module); | |
| abc_patched = 1; | |
| if (unlikely(!module)) | |
| return -1; | |
| Py_DECREF(module); | |
| } | |
| module = PyImport_ImportModule("backports_abc"); | |
| if (module) { | |
| module = __Pyx_patch_abc_module(module); | |
| Py_XDECREF(module); | |
| } | |
| if (!module) { | |
| PyErr_Clear(); | |
| } | |
| } | |
| if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); | |
| return 0; | |
| } | |
| /* Generator */ | |
| static PyMethodDef __pyx_Generator_methods[] = { | |
| {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, | |
| (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, | |
| {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, | |
| (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, | |
| {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, | |
| (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, | |
| {0, 0, 0, 0} | |
| }; | |
| static PyMemberDef __pyx_Generator_memberlist[] = { | |
| {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, | |
| {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, | |
| (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, | |
| {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, | |
| {0, 0, 0, 0, 0} | |
| }; | |
| static PyGetSetDef __pyx_Generator_getsets[] = { | |
| {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, | |
| (char*) PyDoc_STR("name of the generator"), 0}, | |
| {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, | |
| (char*) PyDoc_STR("qualified name of the generator"), 0}, | |
| {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, | |
| (char*) PyDoc_STR("Frame of the generator"), 0}, | |
| {0, 0, 0, 0, 0} | |
| }; | |
| static PyTypeObject __pyx_GeneratorType_type = { | |
| PyVarObject_HEAD_INIT(0, 0) | |
| "generator", | |
| sizeof(__pyx_CoroutineObject), | |
| 0, | |
| (destructor) __Pyx_Coroutine_dealloc, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, | |
| 0, | |
| (traverseproc) __Pyx_Coroutine_traverse, | |
| 0, | |
| 0, | |
| offsetof(__pyx_CoroutineObject, gi_weakreflist), | |
| 0, | |
| (iternextfunc) __Pyx_Generator_Next, | |
| __pyx_Generator_methods, | |
| __pyx_Generator_memberlist, | |
| __pyx_Generator_getsets, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| __Pyx_Coroutine_del, | |
| 0, | |
| __Pyx_Coroutine_del, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| }; | |
| static int __pyx_Generator_init(void) { | |
| __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; | |
| __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; | |
| __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); | |
| if (unlikely(!__pyx_GeneratorType)) { | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| /* CheckBinaryVersion */ | |
| static int __Pyx_check_binary_version(void) { | |
| char ctversion[5]; | |
| int same=1, i, found_dot; | |
| const char* rt_from_call = Py_GetVersion(); | |
| PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); | |
| found_dot = 0; | |
| for (i = 0; i < 4; i++) { | |
| if (!ctversion[i]) { | |
| same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); | |
| break; | |
| } | |
| if (rt_from_call[i] != ctversion[i]) { | |
| same = 0; | |
| break; | |
| } | |
| } | |
| if (!same) { | |
| char rtversion[5] = {'\0'}; | |
| char message[200]; | |
| for (i=0; i<4; ++i) { | |
| if (rt_from_call[i] == '.') { | |
| if (found_dot) break; | |
| found_dot = 1; | |
| } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { | |
| break; | |
| } | |
| rtversion[i] = rt_from_call[i]; | |
| } | |
| 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 Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { | |
| if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { | |
| return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); | |
| } else if (likely(PyInt_CheckExact(o))) { | |
| return PyInt_AS_LONG(o); | |
| } else { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| x = PyNumber_Index(o); | |
| if (!x) return -1; | |
| ival = PyInt_AsLong(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); | |
| } | |