diff options
| author | nik-bes <[email protected]> | 2025-05-19 07:20:13 +0300 |
|---|---|---|
| committer | nik-bes <[email protected]> | 2025-05-19 07:36:02 +0300 |
| commit | 317b7368e24941ff76499f500579fd9b10f6656e (patch) | |
| tree | abbcbaea595e7d2e9f23cf59a408b3082fe4340d /contrib/tools/cython/Cython/Includes | |
| parent | 6b666a52d40308ab9b3532cd8d3008b9f37cfffb (diff) | |
Update Cython to 3.0.10.
commit_hash:b43c96b868cd36d636192fd2c6024d9f0d2fb6f8
Diffstat (limited to 'contrib/tools/cython/Cython/Includes')
108 files changed, 3807 insertions, 867 deletions
diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd deleted file mode 100644 index 56236e925ca..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd deleted file mode 100644 index 9a6d253f45e..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.bool cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd deleted file mode 100644 index 2baeaae00ca..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.buffer cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd deleted file mode 100644 index 87af662de0f..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.bytes cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd deleted file mode 100644 index ed32c6b8781..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.cobject cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd deleted file mode 100644 index 0a780b3b2dd..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.complex cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd deleted file mode 100644 index 05b5f4796a6..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.dict cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd deleted file mode 100644 index 6eb236bccb4..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.exc cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd deleted file mode 100644 index 7e133ef9bb8..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.float cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd deleted file mode 100644 index 1461c4e6353..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.function cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd deleted file mode 100644 index 3852d6a6a15..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.getargs cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd deleted file mode 100644 index 99cb5a9091c..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.instance cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd deleted file mode 100644 index c1fd5178d64..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.int cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd deleted file mode 100644 index e09aad27901..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.iterator cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd deleted file mode 100644 index 64febcf9693..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.list cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd deleted file mode 100644 index 1a24380c4cf..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.long cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd deleted file mode 100644 index cd01bee015f..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.mapping cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd deleted file mode 100644 index d74429ea367..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.mem cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd deleted file mode 100644 index e7da5154e43..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.method cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd deleted file mode 100644 index 6310c0247dd..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.module cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd deleted file mode 100644 index ae67da1c38f..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.number cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd deleted file mode 100644 index 3981bfa44e1..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.object cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd deleted file mode 100644 index e03e66a2e23..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.oldbuffer cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd deleted file mode 100644 index fe9cf8f8d9d..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.pycapsule cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd deleted file mode 100644 index 94474181989..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.ref cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd deleted file mode 100644 index fdef5b63ebb..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.sequence cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd deleted file mode 100644 index a2feb937122..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.set cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd deleted file mode 100644 index 24c818338e8..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.string cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd deleted file mode 100644 index 190713b0204..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.tuple cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd deleted file mode 100644 index 3ac47d1b3f2..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.type cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd deleted file mode 100644 index 2b488b2dc89..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.unicode cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd deleted file mode 100644 index c27ca4df956..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.version cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd deleted file mode 100644 index 1f84f1a1795..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from cpython.weakref cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd deleted file mode 100644 index 41a4aebf1d7..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from libc.stdio cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd deleted file mode 100644 index 499511cde99..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd +++ /dev/null @@ -1,2 +0,0 @@ -# Present for backwards compatibility -from libc.stdlib cimport * diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd deleted file mode 100644 index 22248d2655e..00000000000 --- a/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd +++ /dev/null @@ -1,91 +0,0 @@ -cdef extern from "<vector>" namespace std: - - cdef cppclass vector[TYPE]: - #constructors - __init__() - __init__(vector&) - __init__(int) - __init__(int, TYPE&) - __init__(iterator, iterator) - #operators - TYPE& __getitem__(int) - TYPE& __setitem__(int, TYPE&) - vector __new__(vector&) - bool __eq__(vector&, vector&) - bool __ne__(vector&, vector&) - bool __lt__(vector&, vector&) - bool __gt__(vector&, vector&) - bool __le__(vector&, vector&) - bool __ge__(vector&, vector&) - #others - void assign(int, TYPE) - #void assign(iterator, iterator) - TYPE& at(int) - TYPE& back() - iterator begin() - int capacity() - void clear() - bool empty() - iterator end() - iterator erase(iterator) - iterator erase(iterator, iterator) - TYPE& front() - iterator insert(iterator, TYPE&) - void insert(iterator, int, TYPE&) - void insert(iterator, iterator) - int max_size() - void pop_back() - void push_back(TYPE&) - iterator rbegin() - iterator rend() - void reserve(int) - void resize(int) - void resize(int, TYPE&) #void resize(size_type num, const TYPE& = TYPE()) - int size() - void swap(container&) - -cdef extern from "<deque>" namespace std: - - cdef cppclass deque[TYPE]: - #constructors - __init__() - __init__(deque&) - __init__(int) - __init__(int, TYPE&) - __init__(iterator, iterator) - #operators - TYPE& operator[]( size_type index ); - const TYPE& operator[]( size_type index ) const; - deque __new__(deque&); - bool __eq__(deque&, deque&); - bool __ne__(deque&, deque&); - bool __lt__(deque&, deque&); - bool __gt__(deque&, deque&); - bool __le__(deque&, deque&); - bool __ge__(deque&, deque&); - #others - void assign(int, TYPE&) - void assign(iterator, iterator) - TYPE& at(int) - TYPE& back() - iterator begin() - void clear() - bool empty() - iterator end() - iterator erase(iterator) - iterator erase(iterator, iterator) - TYPE& front() - iterator insert(iterator, TYPE&) - void insert(iterator, int, TYPE&) - void insert(iterator, iterator, iterator) - int max_size() - void pop_back() - void pop_front() - void push_back(TYPE&) - void push_front(TYPE&) - iterator rbegin() - iterator rend() - void resize(int) - void resize(int, TYPE&) - int size() - void swap(container&) diff --git a/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd b/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd index c81f4e66558..7ad2684aa79 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd @@ -179,6 +179,9 @@ from cpython.bytes cimport * # Python >= 3.0 from cpython.pycapsule cimport * +# Python >= 3.7 +from cpython.contextvars cimport * + ################################################################# # END OF DEPRECATED SECTION ################################################################# diff --git a/contrib/tools/cython/Cython/Includes/cpython/array.pxd b/contrib/tools/cython/Cython/Includes/cpython/array.pxd index 19230a0a827..c64e972775b 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/array.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/array.pxd @@ -46,8 +46,19 @@ : 2012-05-02 andreasvc : (see revision control) """ -from libc.string cimport strcat, strncat, \ - memset, memchr, memcmp, memcpy, memmove + +cdef extern from *: + """ + #if CYTHON_COMPILING_IN_PYPY + #ifdef _MSC_VER + #pragma message ("This module uses CPython specific internals of 'array.array', which are not available in PyPy.") + #else + #warning This module uses CPython specific internals of 'array.array', which are not available in PyPy. + #endif + #endif + """ + +from libc.string cimport memset, memcpy from cpython.object cimport Py_SIZE from cpython.ref cimport PyTypeObject, Py_TYPE @@ -158,6 +169,6 @@ cdef inline int extend(array self, array other) except -1: PyErr_BadArgument() return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) -cdef inline void zero(array self): +cdef inline void zero(array self) noexcept: """ set all elements of array to zero. """ memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) diff --git a/contrib/tools/cython/Cython/Includes/cpython/bool.pxd b/contrib/tools/cython/Cython/Includes/cpython/bool.pxd index c775088ce64..3359214523b 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/bool.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/bool.pxd @@ -35,4 +35,3 @@ cdef extern from "Python.h": object PyBool_FromLong(long v) # Return value: New reference. # Return a new reference to Py_True or Py_False depending on the truth value of v. - diff --git a/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd index ea72c6aae77..8998770d8df 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd @@ -68,6 +68,10 @@ cdef extern from "Python.h": # Return value: New reference. # Identical to PyBytes_FromFormat() except that it takes exactly two arguments. + bytes PyBytes_FromObject(object o) + # Return value: New reference. + # Return the bytes representation of object o that implements the buffer protocol. + Py_ssize_t PyBytes_Size(object string) except -1 # Return the length of the string in string object string. @@ -194,5 +198,3 @@ cdef extern from "Python.h": # string encode() method. The codec to be used is looked up using # the Python codec registry. Return NULL if an exception was # raised by the codec. - - diff --git a/contrib/tools/cython/Cython/Includes/cpython/complex.pxd b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd index f5ba339575a..c0147547ce3 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/complex.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd @@ -14,9 +14,14 @@ cdef extern from "Python.h": ctypedef class __builtin__.complex [object PyComplexObject]: cdef Py_complex cval - # not making these available to keep them read-only: - #cdef double imag "cval.imag" - #cdef double real "cval.real" + + @property + cdef inline double real(self) noexcept: + return self.cval.real + + @property + cdef inline double imag(self) noexcept: + return self.cval.imag # PyTypeObject PyComplex_Type # This instance of PyTypeObject represents the Python complex diff --git a/contrib/tools/cython/Cython/Includes/cpython/contextvars.pxd b/contrib/tools/cython/Cython/Includes/cpython/contextvars.pxd new file mode 100644 index 00000000000..aa80026642f --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/contextvars.pxd @@ -0,0 +1,140 @@ +from cpython.object cimport PyObject +from cpython.ref cimport Py_XDECREF + +cdef extern from "Python.h": + # Defining PyContextVar_Get() below to always return the default value for Py<3.7 and PyPy<7.3.6 + # to make the inline functions sort-of work. + """ + #if (PY_VERSION_HEX < 0x030700b1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600)) && !defined(PyContextVar_Get) + #define PyContextVar_Get(var, d, v) \ + ((d) ? \ + ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : \ + ((v)[0] = NULL, 0) \ + ) + #endif + """ + + ############################################################################ + # Context Variables Objects + ############################################################################ + + # PyContext + # The C structure used to represent a `contextvars.Context` object. + + # PyContextVar + # The C structure used to represent a `contextvars.ContextVar` object. + + # PyContextToken + # The C structure used to represent a `contextvars.Token` object. + + # PyTypeObject PyContext_Type + # Type object representing the `contextvars.Context` type. + + # PyTypeObject PyContextVar_Type + # Type object representing the `contextvars.ContextVar` type. + + # PyTypeObject PyContextToken_Type + # Type object representing the `contextvars.Token` type. + + bint PyContext_CheckExact(object obj) + # Return `true` if `obj` is of type `PyContext_Type`. + # `obj` must not be NULL. This function always succeeds. + + bint PyContextVar_CheckExact(object obj) + # Return `true` if `obj` is of type `PyContextVar_Type`. + # `obj` must not be NULL. This function always succeeds. + + bint PyContextToken_CheckExact(object obj) + # Return `true` if `obj` is of type `PyContextToken_Type`. + # `obj` must not be NULL. This function always succeeds. + + object PyContext_New() + # Return value: New reference. + # Create a new empty context object. + # Returns NULL if an error has occurred. + + object PyContext_Copy(object ctx) + # Return value: New reference. + # Create a shallow copy of the passed `ctx` context object. + # Returns NULL if an error has occurred. + + object PyContext_CopyCurrent() + # Return value: New reference. + # Create a shallow copy of the current thread context. + # Returns NULL if an error has occurred. + + int PyContext_Enter(object ctx) except -1 + # Set `ctx` as the current context for the current thread. + # Returns 0 on success, and -1 on error. + + int PyContext_Exit(object ctx) except -1 + # Deactivate the `ctx` context and restore the previous context + # as the current context for the current thread. + # Returns 0 on success, and -1 on error. + + object PyContextVar_New(const char* name, PyObject* default_value) + # Return value: New reference. + # Create a new ContextVar object. The `name` parameter is used + # for introspection and debug purposes. The `default_value` parameter + # may optionally specify the default value for the context variable. + # If an error has occurred, this function returns NULL. + + object PyContextVar_New_with_default "PyContextVar_New" (const char* name, object default_value) + # A different declaration of PyContextVar_New that requires a default value + # to be passed on call. + + int PyContextVar_Get(object var, PyObject* default_value, PyObject** value) except -1 + # Get the value of a context variable. + # Returns -1 if an error has occurred during lookup, and 0 if no error + # occurred, whether or not a value was found. + # + # If the context variable was found, `value` will be a pointer to it. + # If the context variable was not found, `value` will point to: + # + # • `default_value`, if not NULL; + # • the default value of `var`, if not NULL; + # • NULL + int PyContextVar_Get_with_default "PyContextVar_Get" (object var, object default_value, PyObject** value) except -1 + # A different declaration of PyContextVar_Get that requires a default value + # to be passed on call. + + object PyContextVar_Set(object var, object value) + # Return value: New reference. + # Set the value of `var` to `value` in the current context. + # Returns a token object for this value change, or NULL if an error has occurred. + + int PyContextVar_Reset(object var, object token) except -1 + # Reset the state of the `var` context variable to that it was in + # before `PyContextVar_Set()` that returned `token` was called. + # This function returns 0 on success and -1 on error. + + +cdef inline object get_value(var, default_value=None): + """Return a new reference to the value of the context variable, + or the default value of the context variable, + or None if no such value or default was found. + """ + cdef PyObject *value = NULL + PyContextVar_Get(var, NULL, &value) + if value is NULL: + # context variable does not have a default + pyvalue = default_value + else: + # value or default value of context variable + pyvalue = <object>value + Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' + return pyvalue + + +cdef inline object get_value_no_default(var, default_value=None): + """Return a new reference to the value of the context variable, + or the provided default value if no such value was found. + + Ignores the default value of the context variable, if any. + """ + cdef PyObject *value = NULL + PyContextVar_Get(var, <PyObject*>default_value, &value) + # value of context variable or 'default_value' + pyvalue = <object>value + Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' + return pyvalue diff --git a/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd index cd0f90719bd..3dce3958882 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd @@ -1,22 +1,161 @@ from cpython.object cimport PyObject +from cpython.version cimport PY_VERSION_HEX cdef extern from "Python.h": ctypedef struct PyTypeObject: pass cdef extern from "datetime.h": + """ + /* Backport for Python 2.x */ + #if PY_MAJOR_VERSION < 3 + #ifndef PyDateTime_DELTA_GET_DAYS + #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days) + #endif + #ifndef PyDateTime_DELTA_GET_SECONDS + #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds) + #endif + #ifndef PyDateTime_DELTA_GET_MICROSECONDS + #define PyDateTime_DELTA_GET_MICROSECONDS(o) (((PyDateTime_Delta*)o)->microseconds) + #endif + #endif + + /* Backport for Python < 3.6 */ + #if PY_VERSION_HEX < 0x030600a4 + #ifndef PyDateTime_TIME_GET_FOLD + #define PyDateTime_TIME_GET_FOLD(o) ((void)(o), 0) + #endif + #ifndef PyDateTime_DATE_GET_FOLD + #define PyDateTime_DATE_GET_FOLD(o) ((void)(o), 0) + #endif + #endif + + /* Backport for Python < 3.6 */ + #if PY_VERSION_HEX < 0x030600a4 + #define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) \ + ((void)(fold), PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, minute, second, \ + microsecond, tz, PyDateTimeAPI->DateTimeType)) + #define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) \ + ((void)(fold), PyDateTimeAPI->Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI->TimeType)) + #else /* For Python 3.6+ so that we can pass tz */ + #define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) \ + PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, minute, second, \ + microsecond, tz, fold, PyDateTimeAPI->DateTimeType) + #define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) \ + PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, microsecond, tz, fold, PyDateTimeAPI->TimeType) + #endif + + /* Backport for Python < 3.7 */ + #if PY_VERSION_HEX < 0x030700b1 + #define __Pyx_TimeZone_UTC NULL + #define __Pyx_TimeZone_FromOffsetAndName(offset, name) ((void)(offset), (void)(name), (PyObject*)NULL) + #else + #define __Pyx_TimeZone_UTC PyDateTime_TimeZone_UTC + #define __Pyx_TimeZone_FromOffsetAndName(offset, name) PyTimeZone_FromOffsetAndName(offset, name) + #endif + + /* Backport for Python < 3.10 */ + #if PY_VERSION_HEX < 0x030a00a1 + #ifndef PyDateTime_TIME_GET_TZINFO + #define PyDateTime_TIME_GET_TZINFO(o) \ + ((((PyDateTime_Time*)o)->hastzinfo) ? ((PyDateTime_Time*)o)->tzinfo : Py_None) + #endif + #ifndef PyDateTime_DATE_GET_TZINFO + #define PyDateTime_DATE_GET_TZINFO(o) \ + ((((PyDateTime_DateTime*)o)->hastzinfo) ? ((PyDateTime_DateTime*)o)->tzinfo : Py_None) + #endif + #endif + """ ctypedef extern class datetime.date[object PyDateTime_Date]: - pass + @property + cdef inline int year(self) noexcept: + return PyDateTime_GET_YEAR(self) + + @property + cdef inline int month(self) noexcept: + return PyDateTime_GET_MONTH(self) + + @property + cdef inline int day(self) noexcept: + return PyDateTime_GET_DAY(self) ctypedef extern class datetime.time[object PyDateTime_Time]: - pass + @property + cdef inline int hour(self) noexcept: + return PyDateTime_TIME_GET_HOUR(self) + + @property + cdef inline int minute(self) noexcept: + return PyDateTime_TIME_GET_MINUTE(self) + + @property + cdef inline int second(self) noexcept: + return PyDateTime_TIME_GET_SECOND(self) + + @property + cdef inline int microsecond(self) noexcept: + return PyDateTime_TIME_GET_MICROSECOND(self) + + @property + cdef inline object tzinfo(self): + return <object>PyDateTime_TIME_GET_TZINFO(self) + + @property + cdef inline int fold(self) noexcept: + # For Python < 3.6 this returns 0 no matter what + return PyDateTime_TIME_GET_FOLD(self) ctypedef extern class datetime.datetime[object PyDateTime_DateTime]: - pass + @property + cdef inline int year(self) noexcept: + return PyDateTime_GET_YEAR(self) + + @property + cdef inline int month(self) noexcept: + return PyDateTime_GET_MONTH(self) + + @property + cdef inline int day(self) noexcept: + return PyDateTime_GET_DAY(self) + + @property + cdef inline int hour(self) noexcept: + return PyDateTime_DATE_GET_HOUR(self) + + @property + cdef inline int minute(self) noexcept: + return PyDateTime_DATE_GET_MINUTE(self) + + @property + cdef inline int second(self) noexcept: + return PyDateTime_DATE_GET_SECOND(self) + + @property + cdef inline int microsecond(self) noexcept: + return PyDateTime_DATE_GET_MICROSECOND(self) + + @property + cdef inline object tzinfo(self): + return <object>PyDateTime_DATE_GET_TZINFO(self) + + @property + cdef inline int fold(self) noexcept: + # For Python < 3.6 this returns 0 no matter what + return PyDateTime_DATE_GET_FOLD(self) ctypedef extern class datetime.timedelta[object PyDateTime_Delta]: - pass + @property + cdef inline int day(self) noexcept: + return PyDateTime_DELTA_GET_DAYS(self) + + @property + cdef inline int second(self) noexcept: + return PyDateTime_DELTA_GET_SECONDS(self) + + @property + cdef inline int microsecond(self) noexcept: + return PyDateTime_DELTA_GET_MICROSECONDS(self) ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]: pass @@ -25,10 +164,12 @@ cdef extern from "datetime.h": pass ctypedef struct PyDateTime_Time: + unsigned char fold char hastzinfo PyObject *tzinfo ctypedef struct PyDateTime_DateTime: + unsigned char fold char hastzinfo PyObject *tzinfo @@ -47,14 +188,27 @@ cdef extern from "datetime.h": PyTypeObject *TZInfoType # constructors - object (*Date_FromDate)(int, int, int, PyTypeObject*) - object (*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, object, PyTypeObject*) - object (*Time_FromTime)(int, int, int, int, object, PyTypeObject*) - object (*Delta_FromDelta)(int, int, int, int, PyTypeObject*) + date (*Date_FromDate)(int, int, int, PyTypeObject*) + datetime (*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, object, PyTypeObject*) + time (*Time_FromTime)(int, int, int, int, object, PyTypeObject*) + timedelta (*Delta_FromDelta)(int, int, int, int, PyTypeObject*) # constructors for the DB API - object (*DateTime_FromTimestamp)(object, object, object) - object (*Date_FromTimestamp)(object, object) + datetime (*DateTime_FromTimestamp)(PyObject*, object, PyObject*) + date (*Date_FromTimestamp)(PyObject*, object) + + # We cannot use the following because they do not compile in older Python versions. + # Instead, we use datetime.h's macros here that we can backport in C. + + # Python 3.7+ constructors + object (*TimeZone_FromTimeZone)(object offset, PyObject *name) + + # Python 3.7+ singletons + PyObject *TimeZone_UTC + + # Python 3.6+ PEP 495 constructors + datetime (*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int, object, int, PyTypeObject*) + time (*Time_FromTimeAndFold)(int, int, int ,int, object, int, PyTypeObject*) # Check type of the object. bint PyDate_Check(object op) @@ -82,131 +236,191 @@ cdef extern from "datetime.h": int PyDateTime_DATE_GET_MINUTE(object o) int PyDateTime_DATE_GET_SECOND(object o) int PyDateTime_DATE_GET_MICROSECOND(object o) + int PyDateTime_DATE_GET_FOLD(object o) + PyObject* PyDateTime_DATE_GET_TZINFO(object o) # returns a borrowed reference # Getters for time (C macros). int PyDateTime_TIME_GET_HOUR(object o) int PyDateTime_TIME_GET_MINUTE(object o) int PyDateTime_TIME_GET_SECOND(object o) int PyDateTime_TIME_GET_MICROSECOND(object o) + int PyDateTime_TIME_GET_FOLD(object o) + PyObject* PyDateTime_TIME_GET_TZINFO(object o) # returns a borrowed reference # Getters for timedelta (C macros). int PyDateTime_DELTA_GET_DAYS(object o) int PyDateTime_DELTA_GET_SECONDS(object o) int PyDateTime_DELTA_GET_MICROSECONDS(object o) + # Constructors + object PyTimeZone_FromOffset(object offset) + object PyTimeZone_FromOffsetAndName(object offset, object name) + + # The above macros is Python 3.7+ so we use these instead + object __Pyx_TimeZone_FromOffsetAndName(object offset, PyObject* name) + + # Constructors for the DB API + datetime PyDateTime_FromTimeStamp(object args) + date PyDate_FromTimeStamp(object args) + + # PEP 495 constructors but patched above to allow passing tz + datetime __Pyx_DateTime_DateTimeWithFold(int, int, int, int, int, int, int, object, int) + datetime __Pyx_DateTime_TimeWithFold(int, int, int ,int, object, int) + # PyDateTime CAPI object. PyDateTime_CAPI *PyDateTimeAPI + PyObject* PyDateTime_TimeZone_UTC + + # PyDateTime_TimeZone_UTC is Python 3.7+ so instead we use the following macro + PyObject* __Pyx_TimeZone_UTC + void PyDateTime_IMPORT() # Datetime C API initialization function. # You have to call it before any usage of DateTime CAPI functions. -cdef inline void import_datetime(): +cdef inline void import_datetime() noexcept: PyDateTime_IMPORT # Create date object using DateTime CAPI factory function. # Note, there are no range checks for any of the arguments. -cdef inline object date_new(int year, int month, int day): +cdef inline date date_new(int year, int month, int day): return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType) # Create time object using DateTime CAPI factory function # Note, there are no range checks for any of the arguments. -cdef inline object time_new(int hour, int minute, int second, int microsecond, object tz): - return PyDateTimeAPI.Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI.TimeType) +cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0): + return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) # Create datetime object using DateTime CAPI factory function. # Note, there are no range checks for any of the arguments. -cdef inline object datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz): - return PyDateTimeAPI.DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI.DateTimeType) +cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0): + return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) # Create timedelta object using DateTime CAPI factory function. # Note, there are no range checks for any of the arguments. -cdef inline object timedelta_new(int days, int seconds, int useconds): +cdef inline timedelta timedelta_new(int days, int seconds, int useconds): return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType) +# Create timedelta object using DateTime CAPI factory function. +cdef inline object timezone_new(object offset, object name=None): + if PY_VERSION_HEX < 0x030700b1: + raise RuntimeError('Time zones are not available from the C-API.') + return __Pyx_TimeZone_FromOffsetAndName(offset, <PyObject*>name if name is not None else NULL) + +# Create datetime object using DB API constructor. +cdef inline datetime datetime_from_timestamp(timestamp, tz=None): + return PyDateTimeAPI.DateTime_FromTimestamp( + <PyObject*>PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) + +# Create date object using DB API constructor. +cdef inline date date_from_timestamp(timestamp): + return PyDateTimeAPI.Date_FromTimestamp(<PyObject*>PyDateTimeAPI.DateType, (timestamp,)) + # More recognizable getters for date/time/datetime/timedelta. # There are no setters because datetime.h hasn't them. # This is because of immutable nature of these objects by design. # If you would change time/date/datetime/timedelta object you need to recreate. +# Get UTC singleton +cdef inline object get_utc(): + if PY_VERSION_HEX < 0x030700b1: + raise RuntimeError('Time zones are not available from the C-API.') + return <object>__Pyx_TimeZone_UTC + # Get tzinfo of time cdef inline object time_tzinfo(object o): - if (<PyDateTime_Time*>o).hastzinfo: - return <object>(<PyDateTime_Time*>o).tzinfo - else: - return None + return <object>PyDateTime_TIME_GET_TZINFO(o) # Get tzinfo of datetime cdef inline object datetime_tzinfo(object o): - if (<PyDateTime_DateTime*>o).hastzinfo: - return <object>(<PyDateTime_DateTime*>o).tzinfo - else: - return None + return <object>PyDateTime_DATE_GET_TZINFO(o) # Get year of date -cdef inline int date_year(object o): +cdef inline int date_year(object o) noexcept: return PyDateTime_GET_YEAR(o) # Get month of date -cdef inline int date_month(object o): +cdef inline int date_month(object o) noexcept: return PyDateTime_GET_MONTH(o) # Get day of date -cdef inline int date_day(object o): +cdef inline int date_day(object o) noexcept: return PyDateTime_GET_DAY(o) # Get year of datetime -cdef inline int datetime_year(object o): +cdef inline int datetime_year(object o) noexcept: return PyDateTime_GET_YEAR(o) # Get month of datetime -cdef inline int datetime_month(object o): +cdef inline int datetime_month(object o) noexcept: return PyDateTime_GET_MONTH(o) # Get day of datetime -cdef inline int datetime_day(object o): +cdef inline int datetime_day(object o) noexcept: return PyDateTime_GET_DAY(o) # Get hour of time -cdef inline int time_hour(object o): +cdef inline int time_hour(object o) noexcept: return PyDateTime_TIME_GET_HOUR(o) # Get minute of time -cdef inline int time_minute(object o): +cdef inline int time_minute(object o) noexcept: return PyDateTime_TIME_GET_MINUTE(o) # Get second of time -cdef inline int time_second(object o): +cdef inline int time_second(object o) noexcept: return PyDateTime_TIME_GET_SECOND(o) # Get microsecond of time -cdef inline int time_microsecond(object o): +cdef inline int time_microsecond(object o) noexcept: return PyDateTime_TIME_GET_MICROSECOND(o) +# Get fold of time +cdef inline int time_fold(object o) noexcept: + # For Python < 3.6 this returns 0 no matter what + return PyDateTime_TIME_GET_FOLD(o) + # Get hour of datetime -cdef inline int datetime_hour(object o): +cdef inline int datetime_hour(object o) noexcept: return PyDateTime_DATE_GET_HOUR(o) # Get minute of datetime -cdef inline int datetime_minute(object o): +cdef inline int datetime_minute(object o) noexcept: return PyDateTime_DATE_GET_MINUTE(o) # Get second of datetime -cdef inline int datetime_second(object o): +cdef inline int datetime_second(object o) noexcept: return PyDateTime_DATE_GET_SECOND(o) # Get microsecond of datetime -cdef inline int datetime_microsecond(object o): +cdef inline int datetime_microsecond(object o) noexcept: return PyDateTime_DATE_GET_MICROSECOND(o) +# Get fold of datetime +cdef inline int datetime_fold(object o) noexcept: + # For Python < 3.6 this returns 0 no matter what + return PyDateTime_DATE_GET_FOLD(o) + # Get days of timedelta -cdef inline int timedelta_days(object o): +cdef inline int timedelta_days(object o) noexcept: return (<PyDateTime_Delta*>o).days # Get seconds of timedelta -cdef inline int timedelta_seconds(object o): +cdef inline int timedelta_seconds(object o) noexcept: return (<PyDateTime_Delta*>o).seconds # Get microseconds of timedelta -cdef inline int timedelta_microseconds(object o): +cdef inline int timedelta_microseconds(object o) noexcept: return (<PyDateTime_Delta*>o).microseconds + +cdef inline double total_seconds(timedelta obj) noexcept: + # Mirrors the "timedelta.total_seconds()" method. + # Note that this implementation is not guaranteed to give *exactly* the same + # result as the original method, due to potential differences in floating point rounding. + cdef: + double days, seconds, micros + days = <double>PyDateTime_DELTA_GET_DAYS(obj) + seconds = <double>PyDateTime_DELTA_GET_SECONDS(obj) + micros = <double>PyDateTime_DELTA_GET_MICROSECONDS(obj) + return days * 24 * 3600 + seconds + micros / 1_000_000 diff --git a/contrib/tools/cython/Cython/Includes/cpython/descr.pxd b/contrib/tools/cython/Cython/Includes/cpython/descr.pxd new file mode 100644 index 00000000000..5075f0bbdf9 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/descr.pxd @@ -0,0 +1,26 @@ +from .object cimport PyObject, PyTypeObject + +cdef extern from "Python.h": + ctypedef object (*wrapperfunc)(self, args, void* wrapped) + ctypedef object (*wrapperfunc_kwds)(self, args, void* wrapped, kwds) + + struct wrapperbase: + char* name + int offset + void* function + wrapperfunc wrapper + char* doc + int flags + PyObject* name_strobj + + int PyWrapperFlag_KEYWORDS + + ctypedef class __builtin__.wrapper_descriptor [object PyWrapperDescrObject]: + cdef type d_type + cdef d_name + cdef wrapperbase* d_base + cdef void* d_wrapped + + object PyDescr_NewWrapper(PyTypeObject* cls, wrapperbase* wrapper, void* wrapped) + + int PyDescr_IsData(descr) diff --git a/contrib/tools/cython/Cython/Includes/cpython/dict.pxd b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd index 16dd5e14581..979dd392a07 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/dict.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd @@ -1,6 +1,13 @@ from .object cimport PyObject +from .pyport cimport uint64_t cdef extern from "Python.h": + # On Python 2, PyDict_GetItemWithError is called _PyDict_GetItemWithError + """ + #if PY_MAJOR_VERSION <= 2 + #define PyDict_GetItemWithError _PyDict_GetItemWithError + #endif + """ ############################################################################ # 7.4.1 Dictionary Objects @@ -72,11 +79,25 @@ cdef extern from "Python.h": # NULL if the key key is not present, but without setting an # exception. + PyObject* PyDict_GetItemWithError(object p, object key) except? NULL + # Return value: Borrowed reference. + # Variant of PyDict_GetItem() that does not suppress exceptions. Return + # NULL with an exception set if an exception occurred. Return NULL + # without an exception set if the key wasn’t present. + PyObject* PyDict_GetItemString(object p, const char *key) # Return value: Borrowed reference. # This is the same as PyDict_GetItem(), but key is specified as a # char*, rather than a PyObject*. + PyObject* PyDict_SetDefault(object p, object key, object default) except NULL + # Return value: Borrowed reference. + # This is the same as the Python-level dict.setdefault(). If present, it + # returns the value corresponding to key from the dictionary p. If the key + # is not in the dict, it is inserted with value defaultobj and defaultobj + # is returned. This function evaluates the hash function of key only once, + # instead of evaluating it independently for the lookup and the insertion. + list PyDict_Items(object p) # Return value: New reference. # Return a PyListObject containing all the items from the diff --git a/contrib/tools/cython/Cython/Includes/cpython/exc.pxd b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd index bc57c0e571b..756342ad3af 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/exc.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd @@ -88,6 +88,11 @@ cdef extern from "Python.h": # needs to handle exceptions or by code that needs to save and # restore the error indicator temporarily. + PyObject* PyErr_GetHandledException() + void PyErr_SetHandledException(PyObject* exc) + PyObject* PyErr_GetRaisedException() + void PyErr_SetRaisedException(PyObject* exc) + void PyErr_Restore(PyObject* type, PyObject* value, PyObject* traceback) # Set the error indicator from the three objects. If the error # indicator is already set, it is cleared first. If the objects @@ -236,6 +241,8 @@ cdef extern from "Python.h": # KeyboardInterrupt will be raised. It may be called without # holding the interpreter lock. + int PyErr_SetInterruptEx(int signum) + object PyErr_NewException(char *name, object base, object dict) # Return value: New reference. # This utility function creates and returns a new exception @@ -254,4 +261,3 @@ cdef extern from "Python.h": # identifies the context in which the unraisable exception # occurred. The repr of obj will be printed in the warning # message. - diff --git a/contrib/tools/cython/Cython/Includes/cpython/fileobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/fileobject.pxd new file mode 100644 index 00000000000..e52cd33f577 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/fileobject.pxd @@ -0,0 +1,57 @@ +""" +From https://docs.python.org/3.9/c-api/file.html + +These APIs are a minimal emulation of the Python 2 C API for built-in file objects, +which used to rely on the buffered I/O (FILE*) support from the C standard library. +In Python 3, files and streams use the new io module, which defines several layers +over the low-level unbuffered I/O of the operating system. The functions described +below are convenience C wrappers over these new APIs, and meant mostly for internal +error reporting in the interpreter; + +third-party code is advised to access the io APIs instead. +""" + +cdef extern from "Python.h": + + ########################################################################### + # File Objects + ########################################################################### + + object PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, + const char *encoding, const char *errors, const char *newline, int closefd) + # Return value: New reference. + # Create a Python file object from the file descriptor of an already + # opened file fd. The arguments name, encoding, errors and newline can be + # NULL to use the defaults; buffering can be -1 to use the default. name + # is ignored and kept for backward compatibility. Return NULL on failure. + # For a more comprehensive description of the arguments, please refer to + # the io.open() function documentation. + + # Warning: Since Python streams have their own buffering layer, mixing + # them with OS-level file descriptors can produce various issues (such as + # unexpected ordering of data). + + # Changed in version 3.2: Ignore name attribute. + + object PyFile_GetLine(object p, int n) + # Return value: New reference. + # Equivalent to p.readline([n]), this function reads one line from the + # object p. p may be a file object or any object with a readline() + # method. If n is 0, exactly one line is read, regardless of the length of + # the line. If n is greater than 0, no more than n bytes will be read from + # the file; a partial line can be returned. In both cases, an empty string + # is returned if the end of the file is reached immediately. If n is less + # than 0, however, one line is read regardless of length, but EOFError is + # raised if the end of the file is reached immediately. + + int PyFile_WriteObject(object obj, object p, int flags) except? -1 + # Write object obj to file object p. The only supported flag for flags + # is Py_PRINT_RAW; if given, the str() of the object is written instead of + # the repr(). Return 0 on success or -1 on failure; the appropriate + # exception will be set. + + int PyFile_WriteString(const char *s, object p) except? -1 + # Write string s to file object p. Return 0 on success or -1 on failure; + # the appropriate exception will be set. + + enum: Py_PRINT_RAW diff --git a/contrib/tools/cython/Cython/Includes/cpython/float.pxd b/contrib/tools/cython/Cython/Includes/cpython/float.pxd index 65328f31ea4..7c567a80fcc 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/float.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/float.pxd @@ -1,4 +1,11 @@ cdef extern from "Python.h": + """ + #if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj) + #else + #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL) + #endif + """ ############################################################################ # 7.2.3 @@ -21,7 +28,7 @@ cdef extern from "Python.h": # Return true if its argument is a PyFloatObject, but not a # subtype of PyFloatObject. - object PyFloat_FromString(object str, char **pend) + object PyFloat_FromString "__Pyx_PyFloat_FromString" (object str) # Return value: New reference. # Create a PyFloatObject object based on the string value in str, # or NULL on failure. The pend argument is ignored. It remains diff --git a/contrib/tools/cython/Cython/Includes/cpython/list.pxd b/contrib/tools/cython/Cython/Includes/cpython/list.pxd index c6a29535c9a..1d0503c2c1a 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/list.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/list.pxd @@ -42,17 +42,19 @@ cdef extern from "Python.h": int PyList_SetItem(object list, Py_ssize_t index, object item) except -1 # Set the item at index index in list to item. Return 0 on success - # or -1 on failure. Note: This function ``steals'' a reference to - # item and discards a reference to an item already in the list at - # the affected position. + # or -1 on failure. + # + # WARNING: This function _steals_ a reference to item and discards a + # reference to an item already in the list at the affected position. void PyList_SET_ITEM(object list, Py_ssize_t i, object o) # Macro form of PyList_SetItem() without error checking. This is # normally only used to fill in new lists where there is no - # previous content. Note: This function ``steals'' a reference to - # item, and, unlike PyList_SetItem(), does not discard a reference - # to any item that it being replaced; any reference in list at - # position i will be *leaked*. + # previous content. + # + # WARNING: This function _steals_ a reference to item, and, unlike + # PyList_SetItem(), does not discard a reference to any item that + # it being replaced; any reference in list at position i will be *leaked*. int PyList_Insert(object list, Py_ssize_t index, object item) except -1 # Insert the item item into list list in front of index @@ -88,5 +90,3 @@ cdef extern from "Python.h": # Return value: New reference. # Return a new tuple object containing the contents of list; # equivalent to "tuple(list)". - - diff --git a/contrib/tools/cython/Cython/Includes/cpython/long.pxd b/contrib/tools/cython/Cython/Includes/cpython/long.pxd index eb8140d417a..f65cd0073ac 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/long.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/long.pxd @@ -89,7 +89,7 @@ cdef extern from "Python.h": # Return a C long representation of the contents of pylong. If # pylong is greater than LONG_MAX, an OverflowError is raised. - # long PyLong_AsLongAndOverflow(object pylong, int *overflow) except? -1 + long PyLong_AsLongAndOverflow(object pylong, int *overflow) except? -1 # Return a C long representation of the contents of pylong. If pylong is # greater than LONG_MAX or less than LONG_MIN, set *overflow to 1 or -1, # respectively, and return -1; otherwise, set *overflow to 0. If any other @@ -97,7 +97,7 @@ cdef extern from "Python.h": # be returned and *overflow will be 0. # New in version 2.7. - # PY_LONG_LONG PyLong_AsLongLongAndOverflow(object pylong, int *overflow) except? -1 + PY_LONG_LONG PyLong_AsLongLongAndOverflow(object pylong, int *overflow) except? -1 # Return a C long long representation of the contents of pylong. If pylong # is greater than PY_LLONG_MAX or less than PY_LLONG_MIN, set *overflow to # 1 or -1, respectively, and return -1; otherwise, set *overflow to 0. If diff --git a/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd index 3d235b65e20..5e54af531ea 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd @@ -61,4 +61,3 @@ cdef extern from "Python.h": # Map the object key to the value v in object o. Returns -1 on # failure. This is the equivalent of the Python statement "o[key] # = v". - diff --git a/contrib/tools/cython/Cython/Includes/cpython/marshal.pxd b/contrib/tools/cython/Cython/Includes/cpython/marshal.pxd new file mode 100644 index 00000000000..1d8a54c86a0 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/marshal.pxd @@ -0,0 +1,66 @@ +from libc.stdio cimport FILE + +cdef extern from "Python.h": + + ########################################################################### + # Data marshalling support + ########################################################################### + + const int Py_MARSHAL_VERSION + + void PyMarshal_WriteLongToFile(long value, FILE *file, int version) + # Marshal a long integer, value, to file. This will only write the + # least-significant 32 bits of value, regardless of the size of the native + # long type. version indicates the file format. + + void PyMarshal_WriteObjectToFile(object value, FILE *file, int version) + # Marshal a Python object, value, to file. version indicates the file + # format. + + bytes PyMarshal_WriteObjectToString(object value, int version) + # Return value: New reference. + # Return a bytes object containing the marshalled representation of value. + # version indicates the file format. + + long PyMarshal_ReadLongFromFile(FILE *file) except? -1 + # Return a C long from the data stream in a FILE* opened for reading. Only + # a 32-bit value can be read in using this function, regardless of the + # native size of long. + + # On error, sets the appropriate exception (EOFError) and returns -1. + + int PyMarshal_ReadShortFromFile(FILE *file) except? -1 + # Return a C short from the data stream in a FILE* opened for reading. Only + # a 16-bit value can be read in using this function, regardless of the + # native size of short. + + # On error, sets the appropriate exception (EOFError) and returns -1. + + object PyMarshal_ReadObjectFromFile(FILE *file) + # Return value: New reference. + # Return a Python object from the data stream in a FILE* opened for + # reading. + + # On error, sets the appropriate exception (EOFError, ValueError or + # TypeError) and returns NULL. + + object PyMarshal_ReadLastObjectFromFile(FILE *file) + # Return value: New reference. + # Return a Python object from the data stream in a FILE* opened for + # reading. Unlike PyMarshal_ReadObjectFromFile(), this function assumes + # that no further objects will be read from the file, allowing it to + # aggressively load file data into memory so that the de-serialization can + # operate from data in memory, rather than reading a byte at a time from the + # file. Only use these variant if you are certain that you won’t be reading + # anything else from the file. + + # On error, sets the appropriate exception (EOFError, ValueError or + # TypeError) and returns NULL. + + object PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len) + # Return value: New reference. + # Return a Python object from the data stream in a byte buffer containing + # len bytes pointed to by data. + + # On error, sets the appropriate exception (EOFError, ValueError or + # TypeError) and returns NULL. diff --git a/contrib/tools/cython/Cython/Includes/cpython/mem.pxd b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd index af820f2ee01..236d111f6ff 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/mem.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd @@ -35,6 +35,15 @@ cdef extern from "Python.h": # PyMem_Malloc(1) had been called instead. The memory will not # have been initialized in any way. + void* PyMem_RawCalloc(size_t nelem, size_t elsize) nogil + void* PyMem_Calloc(size_t nelem, size_t elsize) + # Allocates nelem elements each whose size in bytes is elsize and + # returns a pointer of type void* to the allocated memory, or NULL if + # the request fails. The memory is initialized to zeros. Requesting + # zero elements or elements of size zero bytes returns a distinct + # non-NULL pointer if possible, as if PyMem_Calloc(1, 1) had been + # called instead. + void* PyMem_RawRealloc(void *p, size_t n) nogil void* PyMem_Realloc(void *p, size_t n) # Resizes the memory block pointed to by p to n bytes. The @@ -43,13 +52,13 @@ cdef extern from "Python.h": # else if n is equal to zero, the memory block is resized but is # not freed, and the returned pointer is non-NULL. Unless p is # NULL, it must have been returned by a previous call to - # PyMem_Malloc() or PyMem_Realloc(). + # PyMem_Malloc(), PyMem_Realloc(), or PyMem_Calloc(). void PyMem_RawFree(void *p) nogil void PyMem_Free(void *p) # Frees the memory block pointed to by p, which must have been - # returned by a previous call to PyMem_Malloc() or - # PyMem_Realloc(). Otherwise, or if PyMem_Free(p) has been called + # returned by a previous call to PyMem_Malloc(), PyMem_Realloc(), or + # PyMem_Calloc(). Otherwise, or if PyMem_Free(p) has been called # before, undefined behavior occurs. If p is NULL, no operation is # performed. diff --git a/contrib/tools/cython/Cython/Includes/cpython/module.pxd b/contrib/tools/cython/Cython/Includes/cpython/module.pxd index 8eb323b010b..ea4c3817ed5 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/module.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/module.pxd @@ -145,6 +145,12 @@ cdef extern from "Python.h": bint PyModule_CheckExact(object p) # Return true if p is a module object, but not a subtype of PyModule_Type. + object PyModule_NewObject(object name) + # Return a new module object with the __name__ attribute set to name. + # The module’s __name__, __doc__, __package__, and __loader__ + # attributes are filled in (all but __name__ are set to None); the caller + # is responsible for providing a __file__ attribute. + object PyModule_New(const char *name) # Return value: New reference. # Return a new module object with the __name__ attribute set to @@ -160,21 +166,35 @@ cdef extern from "Python.h": # use other PyModule_*() and PyObject_*() functions rather than # directly manipulate a module's __dict__. + object PyModule_GetNameObject(object module) + # Return module’s __name__ value. If the module does not provide one, or if + # it is not a string, SystemError is raised and NULL is returned. + char* PyModule_GetName(object module) except NULL - # Return module's __name__ value. If the module does not provide - # one, or if it is not a string, SystemError is raised and NULL is - # returned. + # Similar to PyModule_GetNameObject() but return the name encoded + # to 'utf-8'. + + void* PyModule_GetState(object module) + # Return the “state” of the module, that is, a pointer to the block of + # memory allocated at module creation time, or NULL. + # See PyModuleDef.m_size. + + object PyModule_GetFilenameObject(object module) + # Return the name of the file from which module was loaded using module’s + # __file__ attribute. If this is not defined, or if it is not a unicode + # string, raise SystemError and return NULL; otherwise return a reference + # to a Unicode object. char* PyModule_GetFilename(object module) except NULL - # Return the name of the file from which module was loaded using - # module's __file__ attribute. If this is not defined, or if it is - # not a string, raise SystemError and return NULL. + # Similar to PyModule_GetFilenameObject() but return the filename encoded + # to ‘utf-8’. int PyModule_AddObject(object module, const char *name, object value) except -1 # Add an object to module as name. This is a convenience function - # which can be used from the module's initialization - # function. This steals a reference to value. Return -1 on error, - # 0 on success. + # which can be used from the module's initialization function. + # Return -1 on error, 0 on success. + # + # WARNING: This _steals_ a reference to value. int PyModule_AddIntConstant(object module, const char *name, long value) except -1 # Add an integer constant to module as name. This convenience diff --git a/contrib/tools/cython/Cython/Includes/cpython/object.pxd b/contrib/tools/cython/Cython/Includes/cpython/object.pxd index 5a81166393f..41874159ce7 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/object.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/object.pxd @@ -5,7 +5,7 @@ cdef extern from "Python.h": ctypedef struct PyObject # forward declaration - ctypedef object (*newfunc)(cpython.type.type, object, object) # (type, args, kwargs) + ctypedef object (*newfunc)(cpython.type.type, PyObject*, PyObject*) # (type, args|NULL, kwargs|NULL) ctypedef object (*unaryfunc)(object) ctypedef object (*binaryfunc)(object, object) @@ -35,6 +35,14 @@ cdef extern from "Python.h": ctypedef object (*descrgetfunc)(object, object, object) ctypedef int (*descrsetfunc)(object, object, object) except -1 + ctypedef object (*PyCFunction)(object, object) + + ctypedef struct PyMethodDef: + const char* ml_name + PyCFunction ml_meth + int ml_flags + const char* ml_doc + ctypedef struct PyTypeObject: const char* tp_name const char* tp_doc @@ -45,6 +53,8 @@ cdef extern from "Python.h": newfunc tp_new destructor tp_dealloc + destructor tp_del + destructor tp_finalize traverseproc tp_traverse inquiry tp_clear freefunc tp_free @@ -57,12 +67,16 @@ cdef extern from "Python.h": cmpfunc tp_compare richcmpfunc tp_richcompare + PyMethodDef* tp_methods + PyTypeObject* tp_base PyObject* tp_dict descrgetfunc tp_descr_get descrsetfunc tp_descr_set + unsigned int tp_version_tag + ctypedef struct PyObject: Py_ssize_t ob_refcnt PyTypeObject *ob_type @@ -128,6 +142,17 @@ cdef extern from "Python.h": # failure. This is the equivalent of the Python statement "del # o.attr_name". + object PyObject_GenericGetDict(object o, void *context) + # Return value: New reference. + # A generic implementation for the getter of a __dict__ descriptor. It + # creates the dictionary if necessary. + # New in version 3.3. + + int PyObject_GenericSetDict(object o, object value, void *context) except -1 + # A generic implementation for the setter of a __dict__ descriptor. This + # implementation does not allow the dictionary to be deleted. + # New in version 3.3. + int Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE object PyObject_RichCompare(object o1, object o2, int opid) @@ -177,6 +202,14 @@ cdef extern from "Python.h": # equivalent of the Python expression "str(o)". Called by the # str() built-in function and by the print statement. + object PyObject_Bytes(object o) + # Return value: New reference. + # Compute a bytes representation of object o. Return NULL on + # failure and a bytes object on success. This is equivalent to + # the Python expression bytes(o), when o is not an integer. + # Unlike bytes(o), a TypeError is raised when o is an integer + # instead of a zero-initialized bytes object. + object PyObject_Unicode(object o) # Return value: New reference. # Compute a Unicode string representation of object o. Returns the @@ -320,6 +353,13 @@ cdef extern from "Python.h": # returned. On error, -1 is returned. This is the equivalent to # the Python expression "len(o)". + Py_ssize_t PyObject_LengthHint(object o, Py_ssize_t default) except -1 + # Return an estimated length for the object o. First try to return its + # actual length, then an estimate using __length_hint__(), and finally + # return the default value. On error, return -1. This is the equivalent to + # the Python expression "operator.length_hint(o, default)". + # New in version 3.4. + object PyObject_GetItem(object o, object key) # Return value: New reference. # Return element of o corresponding to the object key or NULL on @@ -397,3 +437,4 @@ cdef extern from "Python.h": long Py_TPFLAGS_DEFAULT_EXTERNAL long Py_TPFLAGS_DEFAULT_CORE long Py_TPFLAGS_DEFAULT + long Py_TPFLAGS_HAVE_FINALIZE diff --git a/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd index 08062da850f..1c21b370b3c 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd @@ -1,5 +1,5 @@ -# available since Python 3.1! +# available since Python 2.7! cdef extern from "Python.h": @@ -141,4 +141,3 @@ cdef extern from "Python.h": # set an exception and return NULL. However, if PyCapsule_Import() # failed to import the module, and no_block was true, no exception # is set. - diff --git a/contrib/tools/cython/Cython/Includes/cpython/pyport.pxd b/contrib/tools/cython/Cython/Includes/cpython/pyport.pxd new file mode 100644 index 00000000000..fec59c9c8c4 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/pyport.pxd @@ -0,0 +1,8 @@ +cdef extern from "Python.h": + ctypedef int int32_t + ctypedef int int64_t + ctypedef unsigned int uint32_t + ctypedef unsigned int uint64_t + + const Py_ssize_t PY_SSIZE_T_MIN + const Py_ssize_t PY_SSIZE_T_MAX diff --git a/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd index 1af63079313..ee8856b20ab 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd @@ -84,6 +84,9 @@ cdef extern from "Python.h": # PyGILState_Release on the same thread. void PyGILState_Release(PyGILState_STATE) + # Return 1 if the current thread holds the GIL and 0 otherwise. + int PyGILState_Check() + # Routines for advanced debuggers, requested by David Beazley. # Don't use unless you know what you are doing! PyInterpreterState * PyInterpreterState_Head() diff --git a/contrib/tools/cython/Cython/Includes/cpython/ref.pxd b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd index 4bc9a7d7c88..44f870006a9 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/ref.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd @@ -48,4 +48,3 @@ cdef extern from "Python.h": # It is a good idea to use this macro whenever decrementing the # value of a variable that might be traversed during garbage # collection. - diff --git a/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd b/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd index eb279968d20..e50e4c495ea 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd @@ -132,5 +132,3 @@ cdef extern from "Python.h": # gotten by calling PySequence_Size() on o, but # PySequence_Fast_GET_SIZE() is faster because it can assume o is # a list or tuple. - - diff --git a/contrib/tools/cython/Cython/Includes/cpython/string.pxd b/contrib/tools/cython/Cython/Includes/cpython/string.pxd index 8af78f3dde6..3ba25515fe8 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/string.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/string.pxd @@ -194,5 +194,3 @@ cdef extern from "Python.h": # string encode() method. The codec to be used is looked up using # the Python codec registry. Return NULL if an exception was # raised by the codec. - - diff --git a/contrib/tools/cython/Cython/Includes/cpython/time.pxd b/contrib/tools/cython/Cython/Includes/cpython/time.pxd new file mode 100644 index 00000000000..3f333a72a9d --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/cpython/time.pxd @@ -0,0 +1,51 @@ +""" +Cython implementation of (parts of) the standard library time module. +""" + +from libc.stdint cimport int64_t +from cpython.exc cimport PyErr_SetFromErrno + +cdef extern from "Python.h": + ctypedef int64_t _PyTime_t + _PyTime_t _PyTime_GetSystemClock() nogil + double _PyTime_AsSecondsDouble(_PyTime_t t) nogil + +from libc.time cimport ( + tm, + time_t, + localtime as libc_localtime, +) + + +cdef inline double time() noexcept nogil: + cdef: + _PyTime_t tic + + tic = _PyTime_GetSystemClock() + return _PyTime_AsSecondsDouble(tic) + + +cdef inline int _raise_from_errno() except -1 with gil: + PyErr_SetFromErrno(RuntimeError) + return <int> -1 # Let the C compiler know that this function always raises. + + +cdef inline tm localtime() except * nogil: + """ + Analogue to the stdlib time.localtime. The returned struct + has some entries that the stdlib version does not: tm_gmtoff, tm_zone + """ + cdef: + time_t tic = <time_t>time() + tm* result + + result = libc_localtime(&tic) + if result is NULL: + _raise_from_errno() + # Fix 0-based date values (and the 1900-based year). + # See tmtotuple() in https://github.com/python/cpython/blob/master/Modules/timemodule.c + result.tm_year += 1900 + result.tm_mon += 1 + result.tm_wday = (result.tm_wday + 6) % 7 + result.tm_yday += 1 + return result[0] diff --git a/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd index 09c46e0b4bc..907033fe453 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd @@ -47,13 +47,15 @@ cdef extern from "Python.h": int PyTuple_SetItem(object p, Py_ssize_t pos, object o) except -1 # Insert a reference to object o at position pos of the tuple - # pointed to by p. Return 0 on success. Note: This function - # ``steals'' a reference to o. + # pointed to by p. Return 0 on success. + # + # WARNING: This function _steals_ a reference to o. void PyTuple_SET_ITEM(object p, Py_ssize_t pos, object o) # Like PyTuple_SetItem(), but does no error checking, and should - # only be used to fill in brand new tuples. Note: This function - # ``steals'' a reference to o. + # only be used to fill in brand new tuples. + # + # WARNING: This function _steals_ a reference to o. int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1 # Can be used to resize a tuple. newsize will be the new length of @@ -68,4 +70,3 @@ cdef extern from "Python.h": # the object referenced by *p is replaced, the original *p is # destroyed. On failure, returns -1 and sets *p to NULL, and # raises MemoryError or SystemError. - diff --git a/contrib/tools/cython/Cython/Includes/cpython/type.pxd b/contrib/tools/cython/Cython/Includes/cpython/type.pxd index a1d094e37c7..928a748cd3e 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/type.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/type.pxd @@ -23,6 +23,11 @@ cdef extern from "Python.h": # of the standard type object. Return false in all other # cases. + void PyType_Modified(type type) + # Invalidate the internal lookup cache for the type and all of its + # subtypes. This function must be called after any manual modification + # of the attributes or base classes of the type. + bint PyType_HasFeature(object o, int feature) # Return true if the type object o sets the feature feature. Type # features are denoted by single bit flags. diff --git a/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd index 81260f2adcf..c798ae2b644 100644 --- a/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd +++ b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd @@ -1,4 +1,9 @@ +from libc.stddef cimport wchar_t + cdef extern from *: + ctypedef unsigned char Py_UCS1 # uint8_t + ctypedef unsigned short Py_UCS2 # uint16_t + # Return true if the object o is a Unicode object or an instance # of a Unicode subtype. Changed in version 2.2: Allowed subtypes # to be accepted. @@ -23,6 +28,21 @@ cdef extern from *: # New in version 3.3. Py_ssize_t PyUnicode_GET_LENGTH(object o) + Py_UCS1 *PyUnicode_1BYTE_DATA(object o) + Py_UCS2 *PyUnicode_2BYTE_DATA(object o) + Py_UCS4 *PyUnicode_4BYTE_DATA(object o) + + int PyUnicode_WCHAR_KIND # Deprecated since Python 3.10, removed in 3.12. + int PyUnicode_1BYTE_KIND + int PyUnicode_2BYTE_KIND + int PyUnicode_4BYTE_KIND + void PyUnicode_WRITE(int kind, void *data, Py_ssize_t index, Py_UCS4 value) + Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index) + Py_UCS4 PyUnicode_READ_CHAR(object o, Py_ssize_t index) + + unsigned int PyUnicode_KIND(object o) + void *PyUnicode_DATA(object o) + # Return the size of the object's internal buffer in bytes. o has # to be a PyUnicodeObject (not checked). Py_ssize_t PyUnicode_GET_DATA_SIZE(object o) @@ -35,6 +55,8 @@ cdef extern from *: # be a PyUnicodeObject (not checked). char* PyUnicode_AS_DATA(object o) + bint PyUnicode_IsIdentifier(object o) + # Return 1 or 0 depending on whether ch is a whitespace character. bint Py_UNICODE_ISSPACE(Py_UCS4 ch) @@ -65,6 +87,8 @@ cdef extern from *: # Return 1 or 0 depending on whether ch is an alphanumeric character. bint Py_UNICODE_ISALNUM(Py_UCS4 ch) + bint Py_UNICODE_ISPRINTABLE(Py_UCS4 ch) + # Return the character ch converted to lower case. # Used to return a Py_UNICODE value before Py3.3. Py_UCS4 Py_UNICODE_TOLOWER(Py_UCS4 ch) @@ -103,6 +127,26 @@ cdef extern from *: # when u is NULL. unicode PyUnicode_FromUnicode(Py_UNICODE *u, Py_ssize_t size) + # Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded + # bytes + unicode PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) + + # Similar to PyUnicode_FromUnicode(), but u points to null-terminated + # UTF-8 encoded bytes. The size is determined with strlen(). + unicode PyUnicode_FromString(const char *u) + + unicode PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar) + unicode PyUnicode_FromKindAndData(int kind, const void *buffer, Py_ssize_t size) + unicode PyUnicode_FromFormat(const char *format, ...) + Py_ssize_t PyUnicode_GetLength(object unicode) except -1 + Py_ssize_t PyUnicode_CopyCharacters(object to, Py_ssize_t to_start, object from_, Py_ssize_t from_start, Py_ssize_t how_many) except -1 + Py_ssize_t PyUnicode_Fill(object unicode, Py_ssize_t start, Py_ssize_t length, Py_UCS4 fill_char) except -1 + int PyUnicode_WriteChar(object unicode, Py_ssize_t index, Py_UCS4 character) except -1 + Py_UCS4 PyUnicode_ReadChar(object unicode, Py_ssize_t index) except -1 + unicode PyUnicode_Substring(object str, Py_ssize_t start, Py_ssize_t end) + Py_UCS4 *PyUnicode_AsUCS4(object u, Py_UCS4 *buffer, Py_ssize_t buflen, int copy_null) except NULL + Py_UCS4 *PyUnicode_AsUCS4Copy(object u) except NULL + # Create a Unicode Object from the given Unicode code point ordinal. # # The ordinal must be in range(0x10000) on narrow Python builds @@ -137,14 +181,33 @@ cdef extern from *: # following functions. Support is optimized if Python's own # Py_UNICODE type is identical to the system's wchar_t. - #ctypedef int wchar_t - # Create a Unicode object from the wchar_t buffer w of the given # size. Return NULL on failure. - #PyObject* PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size) - - #Py_ssize_t PyUnicode_AsWideChar(object o, wchar_t *w, Py_ssize_t size) - + object PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size) + + # Copy the Unicode object contents into the wchar_t buffer w. + # At most size wchar_t characters are copied (excluding a possibly + # trailing null termination character). Return the number of wchar_t + # characters copied or -1 in case of an error. Note that the + # esulting wchar_t* string may or may not be null-terminated. + # It is the responsibility of the caller to make sure that the wchar_t* + # string is null-terminated in case this is required by the application. + # Also, note that the wchar_t* string might contain null characters, + # which would cause the string to be truncated when used with most C functions. + Py_ssize_t PyUnicode_AsWideChar(object o, wchar_t *w, Py_ssize_t size) except -1 + + # Convert the Unicode object to a wide character string. The output + # string always ends with a null character. If size is not NULL, + # write the number of wide characters (excluding the trailing null + # termination character) into *size. Note that the resulting wchar_t + # string might contain null characters, which would cause the string + # to be truncated when used with most C functions. If size is NULL and + # the wchar_t* string contains null characters a ValueError is raised. + + # Returns a buffer allocated by PyMem_New (use PyMem_Free() to free it) + # on success. On error, returns NULL and *size is undefined. Raises a + # MemoryError if memory allocation is failed. + wchar_t *PyUnicode_AsWideCharString(object o, Py_ssize_t *size) except NULL # Unicode Methods @@ -331,7 +394,11 @@ cdef extern from *: # This caches the UTF-8 representation of the string in the Unicode # object, and subsequent calls will return a pointer to the same buffer. # The caller is not responsible for deallocating the buffer - const char* PyUnicode_AsUTF8AndSize(object unicode, Py_ssize_t *size) + const char* PyUnicode_AsUTF8AndSize(object unicode, Py_ssize_t *size) except NULL + + + # As PyUnicode_AsUTF8AndSize(), but does not store the size. + const char *PyUnicode_AsUTF8(object unicode) except NULL # These are the UTF-16 codec APIs: @@ -570,8 +637,3 @@ cdef extern from *: int Py_UCS4_strncmp(const Py_UCS4 *s1, const Py_UCS4 *s2, size_t n) Py_UCS4* Py_UCS4_strchr(const Py_UCS4 *s, Py_UCS4 c) Py_UCS4* Py_UCS4_strrchr(const Py_UCS4 *s, Py_UCS4 c) - -# Backport from Cython 3 - Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index) - unsigned int PyUnicode_KIND(object o) - void *PyUnicode_DATA(object o) diff --git a/contrib/tools/cython/Cython/Includes/libc/complex.pxd b/contrib/tools/cython/Cython/Includes/libc/complex.pxd new file mode 100644 index 00000000000..7cd740cb8ec --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libc/complex.pxd @@ -0,0 +1,35 @@ +cdef extern from "<complex.h>" nogil: + # Trigonometric functions. + double complex cacos(double complex z) + double complex casin(double complex z) + double complex catan(double complex z) + double complex ccos(double complex z) + double complex csin(double complex z) + double complex ctan(double complex z) + + # Hyperbolic functions. + double complex cacosh(double complex z) + double complex casinh(double complex z) + double complex catanh(double complex z) + double complex ccosh(double complex z) + double complex csinh(double complex z) + double complex ctanh(double complex z) + + # Exponential and logarithmic functions. + double complex cexp(double complex z) + double complex clog(double complex z) + double complex clog10(double complex z) + + # Power functions. + double complex cpow(double complex x, double complex y) + double complex csqrt(double complex z) + + # Absolute value, conjugates, and projection. + double cabs(double complex z) + double carg(double complex z) + double complex conj(double complex z) + double complex cproj(double complex z) + + # Decomposing complex values. + double cimag(double complex z) + double creal(double complex z) diff --git a/contrib/tools/cython/Cython/Includes/libc/errno.pxd b/contrib/tools/cython/Cython/Includes/libc/errno.pxd index 191d47b3dc1..9803a25fe3d 100644 --- a/contrib/tools/cython/Cython/Includes/libc/errno.pxd +++ b/contrib/tools/cython/Cython/Includes/libc/errno.pxd @@ -125,4 +125,3 @@ cdef extern from "<errno.h>" nogil: EDQUOT int errno - diff --git a/contrib/tools/cython/Cython/Includes/libc/math.pxd b/contrib/tools/cython/Cython/Includes/libc/math.pxd index b002670b224..4a9858c2af4 100644 --- a/contrib/tools/cython/Cython/Includes/libc/math.pxd +++ b/contrib/tools/cython/Cython/Includes/libc/math.pxd @@ -23,81 +23,178 @@ cdef extern from "<math.h>" nogil: const float HUGE_VALF const long double HUGE_VALL + # All C99 functions in alphabetical order double acos(double x) + float acosf(float) + double acosh(double x) + float acoshf(float) + long double acoshl(long double) + long double acosl(long double) double asin(double x) + float asinf(float) + double asinh(double x) + float asinhf(float) + long double asinhl(long double) + long double asinl(long double) double atan(double x) double atan2(double y, double x) - double cos(double x) - double sin(double x) - double tan(double x) - - double cosh(double x) - double sinh(double x) - double tanh(double x) - double acosh(double x) - double asinh(double x) + float atan2f(float, float) + long double atan2l(long double, long double) + float atanf(float) double atanh(double x) - - double hypot(double x, double y) - - double exp(double x) - double exp2(double x) - double expm1(double x) - double log(double x) - double logb(double x) - double log2(double x) - double log10(double x) - double log1p(double x) - int ilogb(double x) - - double lgamma(double x) - double tgamma(double x) - - double frexp(double x, int* exponent) - double ldexp(double x, int exponent) - - double modf(double x, double* iptr) - double fmod(double x, double y) - double remainder(double x, double y) - double remquo(double x, double y, int *quot) - double pow(double x, double y) - double sqrt(double x) + float atanhf(float) + long double atanhl(long double) + long double atanl(long double) double cbrt(double x) - - double fabs(double x) + float cbrtf(float) + long double cbrtl(long double) double ceil(double x) - double floor(double x) - double trunc(double x) - double rint(double x) - double round(double x) - double nearbyint(double x) - double nextafter(double, double) - double nexttoward(double, long double) - - long long llrint(double) - long lrint(double) - long long llround(double) - long lround(double) - + float ceilf(float) + long double ceill(long double) double copysign(double, double) float copysignf(float, float) long double copysignl(long double, long double) - + double cos(double x) + float cosf(float) + double cosh(double x) + float coshf(float) + long double coshl(long double) + long double cosl(long double) double erf(double) - float erff(float) - long double erfl(long double) double erfc(double) float erfcf(float) long double erfcl(long double) - + float erff(float) + long double erfl(long double) + double exp(double x) + double exp2(double x) + float exp2f(float) + long double exp2l(long double) + float expf(float) + long double expl(long double) + double expm1(double x) + float expm1f(float) + long double expm1l(long double) + double fabs(double x) + float fabsf(float) + long double fabsl(long double) double fdim(double x, double y) + float fdimf(float, float) + long double fdiml(long double, long double) + double floor(double x) + float floorf(float) + long double floorl(long double) double fma(double x, double y, double z) + float fmaf(float, float, float) + long double fmal(long double, long double, long double) double fmax(double x, double y) + float fmaxf(float, float) + long double fmaxl(long double, long double) double fmin(double x, double y) + float fminf(float, float) + long double fminl(long double, long double) + double fmod(double x, double y) + float fmodf(float, float) + long double fmodl(long double, long double) + double frexp(double x, int* exponent) + float frexpf(float, int* exponent) + long double frexpl(long double, int*) + double hypot(double x, double y) + float hypotf(float, float) + long double hypotl(long double, long double) + int ilogb(double x) + int ilogbf(float) + int ilogbl(long double) + double ldexp(double x, int exponent) + float ldexpf(float, int exponent) + long double ldexpl(long double, int exponent) + double lgamma(double x) + float lgammaf(float) + long double lgammal(long double) + long long llrint(double) + long long llrintf(float) + long long llrintl(long double) + long long llround(double) + long long llroundf(float) + long long llroundl(long double) + double log(double x) + double log10(double x) + float log10f(float) + long double log10l(long double) + double log1p(double x) + float log1pf(float) + long double log1pl(long double) + double log2(double x) + float log2f(float) + long double log2l(long double) + double logb(double x) + float logbf(float) + long double logbl(long double) + float logf(float) + long double logl(long double) + long lrint(double) + long lrintf(float) + long lrintl(long double) + long lround(double) + long lroundf(float) + long lroundl(long double) + double modf(double x, double* iptr) + float modff(float, float* iptr) + long double modfl(long double, long double* iptr) + double nan(const char*) + float nanf(const char*) + long double nanl(const char*) + double nearbyint(double x) + float nearbyintf(float) + long double nearbyintl(long double) + double nextafter(double, double) + float nextafterf(float, float) + long double nextafterl(long double, long double) + double nexttoward(double, long double) + float nexttowardf(float, long double) + long double nexttowardl(long double, long double) + double pow(double x, double y) + float powf(float, float) + long double powl(long double, long double) + double remainder(double x, double y) + float remainderf(float, float) + long double remainderl(long double, long double) + double remquo(double x, double y, int* quot) + float remquof(float, float, int* quot) + long double remquol(long double, long double, int* quot) + double rint(double x) + float rintf(float) + long double rintl(long double) + double round(double x) + float roundf(float) + long double roundl(long double) double scalbln(double x, long n) + float scalblnf(float, long) + long double scalblnl(long double, long) double scalbn(double x, int n) - - double nan(const char*) + float scalbnf(float, int) + long double scalbnl(long double, int) + double sin(double x) + float sinf(float) + double sinh(double x) + float sinhf(float) + long double sinhl(long double) + long double sinl(long double) + double sqrt(double x) + float sqrtf(float) + long double sqrtl(long double) + double tan(double x) + float tanf(float) + double tanh(double x) + float tanhf(float) + long double tanhl(long double) + long double tanl(long double) + double tgamma(double x) + float tgammaf(float) + long double tgammal(long double) + double trunc(double x) + float truncf(float) + long double truncl(long double) int isinf(long double) # -1 / 0 / 1 bint isfinite(long double) diff --git a/contrib/tools/cython/Cython/Includes/libc/signal.pxd b/contrib/tools/cython/Cython/Includes/libc/signal.pxd index 5d34935543b..fd392adea94 100644 --- a/contrib/tools/cython/Cython/Includes/libc/signal.pxd +++ b/contrib/tools/cython/Cython/Includes/libc/signal.pxd @@ -1,6 +1,6 @@ # 7.14 Signal handling <signal.h> -ctypedef void (*sighandler_t)(int SIGNUM) nogil +ctypedef void (*sighandler_t)(int SIGNUM) noexcept nogil cdef extern from "<signal.h>" nogil: diff --git a/contrib/tools/cython/Cython/Includes/libc/time.pxd b/contrib/tools/cython/Cython/Includes/libc/time.pxd index 3aa15a2eee3..318212eea91 100644 --- a/contrib/tools/cython/Cython/Includes/libc/time.pxd +++ b/contrib/tools/cython/Cython/Includes/libc/time.pxd @@ -1,4 +1,4 @@ -# http://en.wikipedia.org/wiki/C_date_and_time_functions +# https://en.wikipedia.org/wiki/C_date_and_time_functions from libc.stddef cimport wchar_t @@ -20,8 +20,9 @@ cdef extern from "<time.h>" nogil: int tm_wday int tm_yday int tm_isdst - char *tm_zone - long tm_gmtoff + # GNU specific extensions + #char *tm_zone + #long tm_gmtoff int daylight # global state long timezone diff --git a/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd index ec7c3835b40..b800c569ccf 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd @@ -1,43 +1,320 @@ from libcpp cimport bool +from libcpp.utility cimport pair +from libc.stddef import ptrdiff_t cdef extern from "<algorithm>" namespace "std" nogil: - # Sorting and searching - bool binary_search[Iter, T](Iter first, Iter last, const T& value) - bool binary_search[Iter, T, Compare](Iter first, Iter last, const T& value, - Compare comp) + # Non-modifying sequence operations + bool all_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool all_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + bool any_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool any_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + bool none_of[Iter, Pred](Iter first, Iter last, Pred pred) except + + bool none_of[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - Iter lower_bound[Iter, T](Iter first, Iter last, const T& value) - Iter lower_bound[Iter, T, Compare](Iter first, Iter last, const T& value, - Compare comp) + void for_each[Iter, UnaryFunction](Iter first, Iter last, UnaryFunction f) except + # actually returns f + void for_each[ExecutionPolicy, Iter, UnaryFunction](ExecutionPolicy&& policy, Iter first, Iter last, UnaryFunction f) except + # actually returns f - Iter upper_bound[Iter, T](Iter first, Iter last, const T& value) - Iter upper_bound[Iter, T, Compare](Iter first, Iter last, const T& value, - Compare comp) + ptrdiff_t count[Iter, T](Iter first, Iter last, const T& value) except + + ptrdiff_t count[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + ptrdiff_t count_if[Iter, Pred](Iter first, Iter last, Pred pred) except + + ptrdiff_t count_if[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - void partial_sort[Iter](Iter first, Iter middle, Iter last) - void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last, - Compare comp) + pair[Iter1, Iter2] mismatch[Iter1, Iter2]( + Iter1 first1, Iter1 last1, Iter2 first2) except + # other overloads are tricky + pair[Iter1, Iter2] mismatch[ExecutionPolicy, Iter1, Iter2]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2) except + - void sort[Iter](Iter first, Iter last) - void sort[Iter, Compare](Iter first, Iter last, Compare comp) + Iter find[Iter, T](Iter first, Iter last, const T& value) except + + Iter find[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + - # Removing duplicates - Iter unique[Iter](Iter first, Iter last) - Iter unique[Iter, BinaryPredicate](Iter first, Iter last, BinaryPredicate p) + Iter find_if[Iter, Pred](Iter first, Iter last, Pred pred) except + + Iter find_if[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + + Iter find_if_not[Iter, Pred](Iter first, Iter last, Pred pred) except + + Iter find_if_not[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred pred) except + - # Binary heaps (priority queues) - void make_heap[Iter](Iter first, Iter last) - void make_heap[Iter, Compare](Iter first, Iter last, Compare comp) + Iter1 find_end[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_end[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_end[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 find_end[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + - void pop_heap[Iter](Iter first, Iter last) - void pop_heap[Iter, Compare](Iter first, Iter last, Compare comp) - void push_heap[Iter](Iter first, Iter last) - void push_heap[Iter, Compare](Iter first, Iter last, Compare comp) + Iter1 find_first_of[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_first_of[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 find_first_of[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 find_first_of[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + - void sort_heap[Iter](Iter first, Iter last) - void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp) + Iter adjacent_find[Iter](Iter first, Iter last) except + + Iter adjacent_find[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter adjacent_find[Iter, BinaryPred](Iter first, Iter last, BinaryPred pred) except + + Iter adjacent_find[ExecutionPolicy, Iter, BinaryPred](ExecutionPolicy&& policy, Iter first, Iter last, BinaryPred pred) except + - # Copy - OutputIter copy[InputIter,OutputIter](InputIter,InputIter,OutputIter) + Iter1 search[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 search[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2) except + + Iter1 search[Iter1, Iter2, BinaryPred]( + Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter1 search[ExecutionPolicy, Iter1, Iter2, BinaryPred]( + ExecutionPolicy&& policy, Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, BinaryPred pred) except + + Iter search_n[Iter, Size, T](Iter first1, Iter last1, Size count, const T& value) except + + Iter search_n[ExecutionPolicy, Iter, Size, T](ExecutionPolicy&& policy, Iter first1, Iter last1, Size count, const T& value) except + + Iter search_n[Iter, Size, T, BinaryPred]( + Iter first1, Iter last1, Size count, const T& value, BinaryPred pred) except + + Iter search_n[ExecutionPolicy, Iter, Size, T, BinaryPred]( + ExecutionPolicy&& policy, Iter first1, Iter last1, Size count, const T& value, BinaryPred pred) except + + + # Modifying sequence operations + OutputIt copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + OutputIt copy_if[InputIt, OutputIt, Pred](InputIt first, InputIt last, OutputIt d_first, Pred pred) except + + OutputIt copy_if[ExecutionPolicy, InputIt, OutputIt, Pred](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, Pred pred) except + + OutputIt copy_n[InputIt, Size, OutputIt](InputIt first, Size count, OutputIt result) except + + OutputIt copy_n[ExecutionPolicy, InputIt, Size, OutputIt](ExecutionPolicy&& policy, InputIt first, Size count, OutputIt result) except + + Iter2 copy_backward[Iter1, Iter2](Iter1 first, Iter1 last, Iter2 d_last) except + + Iter2 copy_backward[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first, Iter1 last, Iter2 d_last) except + + + OutputIt move[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt move[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + Iter2 move_backward[Iter1, Iter2](Iter1 first, Iter1 last, Iter2 d_last) except + + Iter2 move_backward[ExecutionPolicy, Iter1, Iter2](ExecutionPolicy&& policy, Iter1 first, Iter1 last, Iter2 d_last) except + + + void fill[Iter, T](Iter first, Iter last, const T& value) except + + void fill[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter fill_n[Iter, Size, T](Iter first, Size count, const T& value) except + + Iter fill_n[ExecutionPolicy, Iter, Size, T](ExecutionPolicy&& policy, Iter first, Size count, const T& value) except + + + OutputIt transform[InputIt, OutputIt, UnaryOp]( + InputIt first1, InputIt last1, OutputIt d_first, UnaryOp unary_op) except + + + # This overload is ambiguous with the next one. We just let C++ disambiguate from the arguments + # OutputIt transform[ExecutionPolicy, InputIt, OutputIt, UnaryOp]( + # ExecutionPolicy&& policy, InputIt first1, InputIt last1, OutputIt d_first, UnaryOp unary_op) except + + + OutputIt transform[InputIt1, InputIt2, OutputIt, BinaryOp]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt d_first, BinaryOp binary_op) except + + + OutputIt transform[ExecutionPolicy, InputIt1, InputIt2, OutputIt, BinaryOp]( + ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt d_first, BinaryOp binary_op) except + + + void generate[Iter, Generator](Iter first, Iter last, Generator g) except + + void generate[ExecutionPolicy, Iter, Generator](ExecutionPolicy&& policy, Iter first, Iter last, Generator g) except + + void generate_n[Iter, Size, Generator](Iter first, Size count, Generator g) except + + void generate_n[ExecutionPolicy, Iter, Size, Generator](ExecutionPolicy&& policy, Iter first, Size count, Generator g) except + + + Iter remove[Iter, T](Iter first, Iter last, const T& value) except + + Iter remove[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter remove_if[Iter, UnaryPred](Iter first, Iter last, UnaryPred pred) except + + Iter remove_if[ExecutionPolicy, Iter, UnaryPred](ExecutionPolicy&& policy, Iter first, Iter last, UnaryPred pred) except + + OutputIt remove_copy[InputIt, OutputIt, T](InputIt first, InputIt last, OutputIt d_first, const T& value) except + + OutputIt remove_copy[ExecutionPolicy, InputIt, OutputIt, T](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, const T& value) except + + OutputIt remove_copy_if[InputIt, OutputIt, UnaryPred]( + InputIt first, InputIt last, OutputIt d_first, UnaryPred pred) except + + OutputIt remove_copy_if[ExecutionPolicy, InputIt, OutputIt, UnaryPred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, UnaryPred pred) except + + + void replace[Iter, T](Iter first, Iter last, const T& old_value, const T& new_value) except + + void replace[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& old_value, const T& new_value) except + + void replace_if[Iter, UnaryPred, T](Iter first, Iter last, UnaryPred pred, const T& new_value) except + + OutputIt replace_copy[InputIt, OutputIt, T]( + InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value) except + + void replace_if[ExecutionPolicy, Iter, UnaryPred, T](ExecutionPolicy&& policy, Iter first, Iter last, UnaryPred pred, const T& new_value) except + + + OutputIt replace_copy[ExecutionPolicy, InputIt, OutputIt, T]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value) except + + OutputIt replace_copy_if[InputIt, OutputIt, UnaryPred, T]( + InputIt first, InputIt last, OutputIt d_first, UnaryPred pred, const T& new_value) except + + OutputIt replace_copy_if[ExecutionPolicy, InputIt, OutputIt, UnaryPred, T]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, UnaryPred pred, const T& new_value) except + + + void swap[T](T& a, T& b) except + # array overload also works + Iter2 swap_ranges[Iter1, Iter2](Iter1 first1, Iter1 last1, Iter2 first2) except + + void iter_swap[Iter](Iter a, Iter b) except + + + void reverse[Iter](Iter first, Iter last) except + + void reverse[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + OutputIt reverse_copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt reverse_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + + Iter rotate[Iter](Iter first, Iter n_first, Iter last) except + + Iter rotate[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter n_first, Iter last) except + + OutputIt rotate_copy[InputIt, OutputIt](InputIt first, InputIt n_first, InputIt last, OutputIt d_first) except + + OutputIt rotate_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt n_first, InputIt last, OutputIt d_first) except + + + Iter unique[Iter](Iter first, Iter last) except + + Iter unique[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter unique[Iter, BinaryPred](Iter first, Iter last, BinaryPred p) except + + Iter unique[ExecutionPolicy, Iter, BinaryPred](ExecutionPolicy&& policy, Iter first, Iter last, BinaryPred p) except + + OutputIt unique_copy[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) except + + OutputIt unique_copy[ExecutionPolicy, InputIt, OutputIt](ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first) except + + OutputIt unique_copy[InputIt, OutputIt, BinaryPred]( + InputIt first, InputIt last, OutputIt d_first, BinaryPred pred) except + + OutputIt unique_copy[ExecutionPolicy, InputIt, OutputIt, BinaryPred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, BinaryPred pred) except + + + SampleIt sample[PopulationIt, SampleIt, Distance, URBG](PopulationIt first, PopulationIt last, SampleIt out, Distance n, URBG&& g) except + + + # Partitioning operations + bool is_partitioned[Iter, Pred](Iter first, Iter last, Pred p) except + + bool is_partitioned[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + Iter partition[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter partition[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + pair[OutputIt1, OutputIt2] partition_copy[InputIt, OutputIt1, OutputIt2, Pred]( + InputIt first, InputIt last, OutputIt1 d_first_true, OutputIt2 d_first_false, Pred p) except + + pair[OutputIt1, OutputIt2] partition_copy[ExecutionPolicy, InputIt, OutputIt1, OutputIt2, Pred]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt1 d_first_true, OutputIt2 d_first_false, Pred p) except + + + Iter stable_partition[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter stable_partition[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + Iter partition_point[Iter, Pred](Iter first, Iter last, Pred p) except + + Iter partition_point[ExecutionPolicy, Iter, Pred](ExecutionPolicy&& policy, Iter first, Iter last, Pred p) except + + + # Sorting operations + bool is_sorted[Iter](Iter first, Iter last) except + + bool is_sorted[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + bool is_sorted[Iter, Compare](Iter first, Iter last, Compare comp) except + + bool is_sorted[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + Iter is_sorted_until[Iter](Iter first, Iter last) except + + Iter is_sorted_until[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter is_sorted_until[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter is_sorted_until[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void sort[Iter](Iter first, Iter last) except + + void sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + void sort[Iter, Compare](Iter first, Iter last, Compare comp) except + + void sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void partial_sort[Iter](Iter first, Iter middle, Iter last) except + + void partial_sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter middle, Iter last) except + + void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last, Compare comp) except + + void partial_sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter middle, Iter last, Compare comp) except + + + OutputIt partial_sort_copy[InputIt, OutputIt]( + InputIt first, InputIt last, OutputIt d_first, OutputIt d_last) except + + OutputIt partial_sort_copy[ExecutionPolicy, InputIt, OutputIt]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, OutputIt d_last) except + + OutputIt partial_sort_copy[InputIt, OutputIt, Compare]( + InputIt first, InputIt last, OutputIt d_first, OutputIt d_last, Compare comp) except + + OutputIt partial_sort_copy[ExecutionPolicy, InputIt, OutputIt, Compare]( + ExecutionPolicy&& policy, InputIt first, InputIt last, OutputIt d_first, OutputIt d_last, Compare comp) except + + + void stable_sort[Iter](Iter first, Iter last) except + + void stable_sort[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + void stable_sort[Iter, Compare](Iter first, Iter last, Compare comp) except + + void stable_sort[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter last, Compare comp) except + + + void nth_element[Iter](Iter first, Iter nth, Iter last) except + + void nth_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter nth, Iter last) except + + void nth_element[Iter, Compare](Iter first, Iter nth, Iter last, Compare comp) except + + void nth_element[ExecutionPolicy, Iter, Compare](ExecutionPolicy&& policy, Iter first, Iter nth, Iter last, Compare comp) except + + + # Binary search operations (on sorted ranges) + Iter lower_bound[Iter, T](Iter first, Iter last, const T& value) except + + Iter lower_bound[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter lower_bound[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + Iter lower_bound[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + Iter upper_bound[Iter, T](Iter first, Iter last, const T& value) except + + Iter upper_bound[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + Iter upper_bound[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + Iter upper_bound[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + bool binary_search[Iter, T](Iter first, Iter last, const T& value) except + + bool binary_search[ExecutionPolicy, Iter, T](ExecutionPolicy&& policy, Iter first, Iter last, const T& value) except + + bool binary_search[Iter, T, Compare](Iter first, Iter last, const T& value, Compare comp) except + + bool binary_search[ExecutionPolicy, Iter, T, Compare](ExecutionPolicy&& policy, Iter first, Iter last, const T& value, Compare comp) except + + + # Other operations on sorted ranges + OutputIt merge[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + OutputIt merge[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + void inplace_merge[BidirIt](BidirIt first, BidirIt middle, BidirIt last) except + + void inplace_merge[BidirIt, Compare](BidirIt first, BidirIt middle, BidirIt last, Compare comp) except + + + # Set operations (on sorted ranges) + bool includes[InputIt1, InputIt2]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + + bool includes[InputIt1, InputIt2, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) except + + + OutputIt set_difference[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_difference[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, + OutputIt out, Compare comp) except + + + OutputIt set_intersection[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_intersection[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + OutputIt set_symmetric_difference[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_symmetric_difference[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + OutputIt set_union[InputIt1, InputIt2, OutputIt]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out) except + + + OutputIt set_union[InputIt1, InputIt2, OutputIt, Compare]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt out, Compare comp) except + + + # Heap operations + void make_heap[Iter](Iter first, Iter last) except + + void make_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void push_heap[Iter](Iter first, Iter last) except + + void push_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void pop_heap[Iter](Iter first, Iter last) except + + void pop_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + void sort_heap[Iter](Iter first, Iter last) except + + void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp) except + + + # Minimum/maximum operations + Iter min_element[Iter](Iter first, Iter last) except + + Iter min_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter min_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + Iter max_element[Iter](Iter first, Iter last) except + + Iter max_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + Iter max_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + pair[T, T] minmax[T](const T& a, const T& b) except + + pair[T, T] minmax[T, Compare](const T& a, const T& b, Compare comp) except + + pair[Iter, Iter] minmax_element[Iter](Iter first, Iter last) except + + pair[Iter, Iter] minmax_element[Iter, Compare](Iter first, Iter last, Compare comp) except + + pair[Iter, Iter] minmax_element[ExecutionPolicy, Iter](ExecutionPolicy&& policy, Iter first, Iter last) except + + const T& clamp[T](const T& v, const T& lo, const T& hi) except + + const T& clamp[T, Compare](const T& v, const T& lo, const T& hi, Compare comp) except + + + # Comparison operations + bool equal[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2) except + + bool equal[InputIt1, InputIt2, BinPred](InputIt1 first1, InputIt1 last1, InputIt2 first2, BinPred pred) except + + # ambiguous with previous overload + #bool equal[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + bool equal[InputIt1, InputIt2, BinPred](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinPred pred) except + + + bool lexicographical_compare[InputIt1, InputIt2](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + # ambiguous with next overload + #bool lexicographical_compare[InputIt1, InputIt2, ExecutionPolicy](ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) except + + bool lexicographical_compare[InputIt1, InputIt2, Compare](InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) except + + + # Permutation operations + bool is_permutation[ForwardIt1, ForwardIt2](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) except + + bool is_permutation[ForwardIt1, ForwardIt2, BinaryPred](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPred p) except + + # ambiguous with previous overload + #bool is_permutation[ForwardIt1, ForwardIt2](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2) except + + bool is_permutation[ForwardIt1, ForwardIt2, BinaryPred](ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPred p) except + + bool next_permutation[BidirIt](BidirIt first, BidirIt last) except + + bool next_permutation[BidirIt, Compare](BidirIt first, BidirIt last, Compare comp) except + + bool prev_permutation[BidirIt](BidirIt first, BidirIt last) except + + bool prev_permutation[BidirIt, Compare](BidirIt first, BidirIt last, Compare comp) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/any.pxd b/contrib/tools/cython/Cython/Includes/libcpp/any.pxd new file mode 100644 index 00000000000..7c0d000cdbb --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/any.pxd @@ -0,0 +1,16 @@ +from libcpp cimport bool +from libcpp.typeinfo cimport type_info + +cdef extern from "<any>" namespace "std" nogil: + cdef cppclass any: + any() + any(any&) except + + void reset() + bool has_value() + type_info& type() + T& emplace[T](...) except + + void swap(any&) + any& operator=(any&) except + + any& operator=[U](U&) except + + + cdef T any_cast[T](any&) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/atomic.pxd b/contrib/tools/cython/Cython/Includes/libcpp/atomic.pxd new file mode 100644 index 00000000000..89a8e6ffc2e --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/atomic.pxd @@ -0,0 +1,59 @@ + +cdef extern from "<atomic>" namespace "std" nogil: + + cdef enum memory_order: + memory_order_relaxed + memory_order_consume + memory_order_acquire + memory_order_release + memory_order_acq_rel + memory_order_seq_cst + + cdef cppclass atomic[T]: + atomic() + atomic(T) + + bint is_lock_free() + void store(T) + void store(T, memory_order) + T load() + T load(memory_order) + T exchange(T) + T exchange(T, memory_order) + + bint compare_exchange_weak(T&, T, memory_order, memory_order) + bint compare_exchange_weak(T&, T, memory_order) + bint compare_exchange_weak(T&, T) + bint compare_exchange_strong(T&, T, memory_order, memory_order) + bint compare_exchange_strong(T&, T, memory_order) + bint compare_exchange_strong(T&, T) + + T fetch_add(T, memory_order) + T fetch_add(T) + T fetch_sub(T, memory_order) + T fetch_sub(T) + T fetch_and(T, memory_order) + T fetch_and(T) + T fetch_or(T, memory_order) + T fetch_or(T) + T fetch_xor(T, memory_order) + T fetch_xor(T) + + T operator++() + T operator++(int) + T operator--() + T operator--(int) + + # modify-in-place operators not yet supported by Cython: + # T operator+=(T) + # T operator-=(T) + # T operator&=(T) + # T operator|=(T) + # T operator^=(T) + + bint operator==(atomic[T]&, atomic[T]&) + bint operator==(atomic[T]&, T&) + bint operator==(T&, atomic[T]&) + bint operator!=(atomic[T]&, atomic[T]&) + bint operator!=(atomic[T]&, T&) + bint operator!=(T&, atomic[T]&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/bit.pxd b/contrib/tools/cython/Cython/Includes/libcpp/bit.pxd new file mode 100644 index 00000000000..3b6ffed0553 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/bit.pxd @@ -0,0 +1,29 @@ +cdef extern from "<bit>" namespace "std" nogil: + # bit_cast (gcc >= 11.0, clang >= 14.0) + cdef To bit_cast[To, From](From&) + + # byteswap (C++23) + #cdef T byteswap[T](T) + + # integral powers of 2 (gcc >= 10.0, clang >= 12.0) + cdef bint has_single_bit[T](T) + cdef T bit_ceil[T](T) + cdef T bit_floor[T](T) + cdef int bit_width[T](T) + + # rotating (gcc >= 9.0, clang >= 9.0) + cdef T rotl[T](T, int shift) + cdef T rotr[T](T, int shift) + + # counting (gcc >= 9.0, clang >= 9.0) + cdef int countl_zero[T](T) + cdef int countl_one[T](T) + cdef int countr_zero[T](T) + cdef int countr_one[T](T) + cdef int popcount[T](T) + + # endian + cpdef enum class endian(int): + little, + big, + native diff --git a/contrib/tools/cython/Cython/Includes/libcpp/cmath.pxd b/contrib/tools/cython/Cython/Includes/libcpp/cmath.pxd new file mode 100644 index 00000000000..edc19838307 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/cmath.pxd @@ -0,0 +1,518 @@ + +cdef extern from "<cmath>" namespace "std" nogil: + # all C99 functions + float acos(float x) except + + double acos(double x) except + + long double acos(long double x) except + + float acosf(float x) except + + long double acosl(long double x) except + + + float asin(float x) except + + double asin(double x) except + + long double asin(long double x) except + + float asinf(float x) except + + long double asinl(long double x) except + + + float atan(float x) except + + double atan(double x) except + + long double atan(long double x) except + + float atanf(float x) except + + long double atanl(long double x) except + + + float atan2(float y, float x) except + + double atan2(double y, double x) except + + long double atan2(long double y, long double x) except + + float atan2f(float y, float x) except + + long double atan2l(long double y, long double x) except + + + float cos(float x) except + + double cos(double x) except + + long double cos(long double x) except + + float cosf(float x) except + + long double cosl(long double x) except + + + float sin(float x) except + + double sin(double x) except + + long double sin(long double x) except + + float sinf(float x) except + + long double sinl(long double x) except + + + float tan(float x) except + + double tan(double x) except + + long double tan(long double x) except + + float tanf(float x) except + + long double tanl(long double x) except + + + float acosh(float x) except + + double acosh(double x) except + + long double acosh(long double x) except + + float acoshf(float x) except + + long double acoshl(long double x) except + + + float asinh(float x) except + + double asinh(double x) except + + long double asinh(long double x) except + + float asinhf(float x) except + + long double asinhl(long double x) except + + + float atanh(float x) except + + double atanh(double x) except + + long double atanh(long double x) except + + float atanhf(float x) except + + long double atanhl(long double x) except + + + float cosh(float x) except + + double cosh(double x) except + + long double cosh(long double x) except + + float coshf(float x) except + + long double coshl(long double x) except + + + float sinh(float x) except + + double sinh(double x) except + + long double sinh(long double x) except + + float sinhf(float x) except + + long double sinhl(long double x) except + + + float tanh(float x) except + + double tanh(double x) except + + long double tanh(long double x) except + + float tanhf(float x) except + + long double tanhl(long double x) except + + + float exp(float x) except + + double exp(double x) except + + long double exp(long double x) except + + float expf(float x) except + + long double expl(long double x) except + + + float exp2(float x) except + + double exp2(double x) except + + long double exp2(long double x) except + + float exp2f(float x) except + + long double exp2l(long double x) except + + + float expm1(float x) except + + double expm1(double x) except + + long double expm1(long double x) except + + float expm1f(float x) except + + long double expm1l(long double x) except + + + float frexp(float value, int* exp) except + + double frexp(double value, int* exp) except + + long double frexp(long double value, int* exp) except + + float frexpf(float value, int* exp) except + + long double frexpl(long double value, int* exp) except + + + int ilogb(float x) except + + int ilogb(double x) except + + int ilogb(long double x) except + + int ilogbf(float x) except + + int ilogbl(long double x) except + + + float ldexp(float x, int exp) except + + double ldexp(double x, int exp) except + + long double ldexp(long double x, int exp) except + + float ldexpf(float x, int exp) except + + long double ldexpl(long double x, int exp) except + + + float log(float x) except + + double log(double x) except + + long double log(long double x) except + + float logf(float x) except + + long double logl(long double x) except + + + float log10(float x) except + + double log10(double x) except + + long double log10(long double x) except + + float log10f(float x) except + + long double log10l(long double x) except + + + float log1p(float x) except + + double log1p(double x) except + + long double log1p(long double x) except + + float log1pf(float x) except + + long double log1pl(long double x) except + + + float log2(float x) except + + double log2(double x) except + + long double log2(long double x) except + + float log2f(float x) except + + long double log2l(long double x) except + + + float logb(float x) except + + double logb(double x) except + + long double logb(long double x) except + + float logbf(float x) except + + long double logbl(long double x) except + + + float modf(float value, float* iptr) except + + double modf(double value, double* iptr) except + + long double modf(long double value, long double* iptr) except + + float modff(float value, float* iptr) except + + long double modfl(long double value, long double* iptr) except + + + float scalbn(float x, int n) except + + double scalbn(double x, int n) except + + long double scalbn(long double x, int n) except + + float scalbnf(float x, int n) except + + long double scalbnl(long double x, int n) except + + + float scalbln(float x, long int n) except + + double scalbln(double x, long int n) except + + long double scalbln(long double x, long int n) except + + float scalblnf(float x, long int n) except + + long double scalblnl(long double x, long int n) except + + + float cbrt(float x) except + + double cbrt(double x) except + + long double cbrt(long double x) except + + float cbrtf(float x) except + + long double cbrtl(long double x) except + + + # absolute values + int abs(int j) except + + long int abs(long int j) except + + long long int abs(long long int j) except + + float abs(float j) except + + double abs(double j) except + + long double abs(long double j) except + + + float fabs(float x) except + + double fabs(double x) except + + long double fabs(long double x) except + + float fabsf(float x) except + + long double fabsl(long double x) except + + + float hypot(float x, float y) except + + double hypot(double x, double y) except + + long double hypot(long double x, long double y) except + + float hypotf(float x, float y) except + + long double hypotl(long double x, long double y) except + + + # C++17 three-dimensional hypotenuse + float hypot(float x, float y, float z) except + + double hypot(double x, double y, double z) except + + long double hypot(long double x, long double y, long double z) except + + + float pow(float x, float y) except + + double pow(double x, double y) except + + long double pow(long double x, long double y) except + + float powf(float x, float y) except + + long double powl(long double x, long double y) except + + + float sqrt(float x) except + + double sqrt(double x) except + + long double sqrt(long double x) except + + float sqrtf(float x) except + + long double sqrtl(long double x) except + + + float erf(float x) except + + double erf(double x) except + + long double erf(long double x) except + + float erff(float x) except + + long double erfl(long double x) except + + + float erfc(float x) except + + double erfc(double x) except + + long double erfc(long double x) except + + float erfcf(float x) except + + long double erfcl(long double x) except + + + float lgamma(float x) except + + double lgamma(double x) except + + long double lgamma(long double x) except + + float lgammaf(float x) except + + long double lgammal(long double x) except + + + float tgamma(float x) except + + double tgamma(double x) except + + long double tgamma(long double x) except + + float tgammaf(float x) except + + long double tgammal(long double x) except + + + float ceil(float x) except + + double ceil(double x) except + + long double ceil(long double x) except + + float ceilf(float x) except + + long double ceill(long double x) except + + + float floor(float x) except + + double floor(double x) except + + long double floor(long double x) except + + float floorf(float x) except + + long double floorl(long double x) except + + + float nearbyint(float x) except + + double nearbyint(double x) except + + long double nearbyint(long double x) except + + float nearbyintf(float x) except + + long double nearbyintl(long double x) except + + + float rint(float x) except + + double rint(double x) except + + long double rint(long double x) except + + float rintf(float x) except + + long double rintl(long double x) except + + + long int lrint(float x) except + + long int lrint(double x) except + + long int lrint(long double x) except + + long int lrintf(float x) except + + long int lrintl(long double x) except + + + long long int llrint(float x) except + + long long int llrint(double x) except + + long long int llrint(long double x) except + + long long int llrintf(float x) except + + long long int llrintl(long double x) except + + + float round(float x) except + + double round(double x) except + + long double round(long double x) except + + float roundf(float x) except + + long double roundl(long double x) except + + + long int lround(float x) except + + long int lround(double x) except + + long int lround(long double x) except + + long int lroundf(float x) except + + long int lroundl(long double x) except + + + long long int llround(float x) except + + long long int llround(double x) except + + long long int llround(long double x) except + + long long int llroundf(float x) except + + long long int llroundl(long double x) except + + + float trunc(float x) except + + double trunc(double x) except + + long double trunc(long double x) except + + float truncf(float x) except + + long double truncl(long double x) except + + + float fmod(float x, float y) except + + double fmod(double x, double y) except + + long double fmod(long double x, long double y) except + + float fmodf(float x, float y) except + + long double fmodl(long double x, long double y) except + + + float remainder(float x, float y) except + + double remainder(double x, double y) except + + long double remainder(long double x, long double y) except + + float remainderf(float x, float y) except + + long double remainderl(long double x, long double y) except + + + float remquo(float x, float y, int* quo) except + + double remquo(double x, double y, int* quo) except + + long double remquo(long double x, long double y, int* quo) except + + float remquof(float x, float y, int* quo) except + + long double remquol(long double x, long double y, int* quo) except + + + float copysign(float x, float y) except + + double copysign(double x, double y) except + + long double copysign(long double x, long double y) except + + float copysignf(float x, float y) except + + long double copysignl(long double x, long double y) except + + + double nan(const char* tagp) except + + float nanf(const char* tagp) except + + long double nanl(const char* tagp) except + + + float nextafter(float x, float y) except + + double nextafter(double x, double y) except + + long double nextafter(long double x, long double y) except + + float nextafterf(float x, float y) except + + long double nextafterl(long double x, long double y) except + + + float nexttoward(float x, long double y) except + + double nexttoward(double x, long double y) except + + long double nexttoward(long double x, long double y) except + + float nexttowardf(float x, long double y) except + + long double nexttowardl(long double x, long double y) except + + + float fdim(float x, float y) except + + double fdim(double x, double y) except + + long double fdim(long double x, long double y) except + + float fdimf(float x, float y) except + + long double fdiml(long double x, long double y) except + + + float fmax(float x, float y) except + + double fmax(double x, double y) except + + long double fmax(long double x, long double y) except + + float fmaxf(float x, float y) except + + long double fmaxl(long double x, long double y) except + + + float fmin(float x, float y) except + + double fmin(double x, double y) except + + long double fmin(long double x, long double y) except + + float fminf(float x, float y) except + + long double fminl(long double x, long double y) except + + + float fma(float x, float y, float z) except + + double fma(double x, double y, double z) except + + long double fma(long double x, long double y, long double z) except + + float fmaf(float x, float y, float z) except + + long double fmal(long double x, long double y, long double z) except + + + # C++20 linear interpolation + float lerp(float a, float b, float t) + double lerp(double a, double b, double t) + long double lerp(long double a, long double b, long double t) + + # classification / comparison functions + int fpclassify(float x) except + + int fpclassify(double x) except + + int fpclassify(long double x) except + + + bint isfinite(float x) except + + bint isfinite(double x) except + + bint isfinite(long double x) except + + + bint isinf(float x) except + + bint isinf(double x) except + + bint isinf(long double x) except + + + bint isnan(float x) except + + bint isnan(double x) except + + bint isnan(long double x) except + + + bint isnormal(float x) except + + bint isnormal(double x) except + + bint isnormal(long double x) except + + + bint signbit(float x) except + + bint signbit(double x) except + + bint signbit(long double x) except + + + bint isgreater(float x, float y) except + + bint isgreater(double x, double y) except + + bint isgreater(long double x, long double y) except + + + bint isgreaterequal(float x, float y) except + + bint isgreaterequal(double x, double y) except + + bint isgreaterequal(long double x, long double y) except + + + bint isless(float x, float y) except + + bint isless(double x, double y) except + + bint isless(long double x, long double y) except + + + bint islessequal(float x, float y) except + + bint islessequal(double x, double y) except + + bint islessequal(long double x, long double y) except + + + bint islessgreater(float x, float y) except + + bint islessgreater(double x, double y) except + + bint islessgreater(long double x, long double y) except + + + bint isunordered(float x, float y) except + + bint isunordered(double x, double y) except + + bint isunordered(long double x, long double y) except + + + # C++17 mathematical special functions + + # associated Laguerre polynomials + double assoc_laguerre(unsigned int n, unsigned int m, double x) except + + float assoc_laguerref(unsigned int n, unsigned int m, float x) except + + long double assoc_laguerrel(unsigned int n, unsigned int m, long double x) except + + + # associated Legendre functions + double assoc_legendre(unsigned int l, unsigned int m, double x) except + + float assoc_legendref(unsigned int l, unsigned int m, float x) except + + long double assoc_legendrel(unsigned int l, unsigned int m, long double x) except + + + # beta function + double beta(double x, double y) except + + float betaf(float x, float y) except + + long double betal(long double x, long double y) except + + + # complete elliptic integral of the first kind + double comp_ellint_1(double k) except + + float comp_ellint_1f(float k) except + + long double comp_ellint_1l(long double k) except + + + # complete elliptic integral of the second kind + double comp_ellint_2(double k) except + + float comp_ellint_2f(float k) except + + long double comp_ellint_2l(long double k) except + + + # complete elliptic integral of the third kind + double comp_ellint_3(double k, double nu) except + + float comp_ellint_3f(float k, float nu) except + + long double comp_ellint_3l(long double k, long double nu) except + + + # regular modified cylindrical Bessel functions + double cyl_bessel_i(double nu, double x) except + + float cyl_bessel_if(float nu, float x) except + + long double cyl_bessel_il(long double nu, long double x) except + + + # cylindrical Bessel functions of the first kind + double cyl_bessel_j(double nu, double x) except + + float cyl_bessel_jf(float nu, float x) except + + long double cyl_bessel_jl(long double nu, long double x) except + + + # irregular modified cylindrical Bessel functions + double cyl_bessel_k(double nu, double x) except + + float cyl_bessel_kf(float nu, float x) except + + long double cyl_bessel_kl(long double nu, long double x) except + + + # cylindrical Neumann functions + # cylindrical Bessel functions of the second kind + double cyl_neumann(double nu, double x) except + + float cyl_neumannf(float nu, float x) except + + long double cyl_neumannl(long double nu, long double x) except + + + # incomplete elliptic integral of the first kind + double ellint_1(double k, double phi) except + + float ellint_1f(float k, float phi) except + + long double ellint_1l(long double k, long double phi) except + + + # incomplete elliptic integral of the second kind + double ellint_2(double k, double phi) except + + float ellint_2f(float k, float phi) except + + long double ellint_2l(long double k, long double phi) except + + + # incomplete elliptic integral of the third kind + double ellint_3(double k, double nu, double phi) except + + float ellint_3f(float k, float nu, float phi) except + + long double ellint_3l(long double k, long double nu, long double phi) except + + + # exponential integral + double expint(double x) except + + float expintf(float x) except + + long double expintl(long double x) except + + + # Hermite polynomials + double hermite(unsigned int n, double x) except + + float hermitef(unsigned int n, float x) except + + long double hermitel(unsigned int n, long double x) except + + + # Laguerre polynomials + double laguerre(unsigned int n, double x) except + + float laguerref(unsigned int n, float x) except + + long double laguerrel(unsigned int n, long double x) except + + + # Legendre polynomials + double legendre(unsigned int l, double x) except + + float legendref(unsigned int l, float x) except + + long double legendrel(unsigned int l, long double x) except + + + # Riemann zeta function + double riemann_zeta(double x) except + + float riemann_zetaf(float x) except + + long double riemann_zetal(long double x) except + + + # spherical Bessel functions of the first kind + double sph_bessel(unsigned int n, double x) except + + float sph_besself(unsigned int n, float x) except + + long double sph_bessell(unsigned int n, long double x) except + + + # spherical associated Legendre functions + double sph_legendre(unsigned int l, unsigned int m, double theta) except + + float sph_legendref(unsigned int l, unsigned int m, float theta) except + + long double sph_legendrel(unsigned int l, unsigned int m, long double theta) except + + + # spherical Neumann functions + # spherical Bessel functions of the second kind + double sph_neumann(unsigned int n, double x) except + + float sph_neumannf(unsigned int n, float x) except + + long double sph_neumannl(unsigned int n, long double x) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd index c875d5e5bd9..9d8a700ea00 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd @@ -8,21 +8,25 @@ cdef extern from "<complex>" namespace "std" nogil: # How to make the converting constructor, i.e. convert complex[double] # to complex[float]? - complex[T] operator+(complex[T]&) - complex[T] operator-(complex[T]&) complex[T] operator+(complex[T]&, complex[T]&) complex[T] operator+(complex[T]&, T&) complex[T] operator+(T&, complex[T]&) + complex[T] operator-(complex[T]&, complex[T]&) complex[T] operator-(complex[T]&, T&) complex[T] operator-(T&, complex[T]&) + complex[T] operator*(complex[T]&, complex[T]&) complex[T] operator*(complex[T]&, T&) complex[T] operator*(T&, complex[T]&) + complex[T] operator/(complex[T]&, complex[T]&) complex[T] operator/(complex[T]&, T&) complex[T] operator/(T&, complex[T]&) + complex[T] operator+() + complex[T] operator-() + bint operator==(complex[T]&, complex[T]&) bint operator==(complex[T]&, T&) bint operator==(T&, complex[T]&) @@ -51,6 +55,7 @@ cdef extern from "<complex>" namespace "std" nogil: float imag(float) T abs[T](complex[T]&) + T arg[T](complex[T]&) long double arg(long double) double arg(double) @@ -72,7 +77,7 @@ cdef extern from "<complex>" namespace "std" nogil: complex[float] proj(float) complex[T] polar[T](T&, T&) - complex[T] ploar[T](T&) + complex[T] polar[T](T&) complex[T] exp[T](complex[T]&) complex[T] log[T](complex[T]&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd index 9e2b2291d0c..5f189ffd1c1 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd @@ -9,41 +9,114 @@ cdef extern from "<deque>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) iterator operator+(size_type) iterator operator-(size_type) difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) bint operator<(iterator) + bint operator<(const_iterator) bint operator>(iterator) + bint operator>(const_iterator) bint operator<=(iterator) + bint operator<=(const_iterator) bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - T& operator*() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) reverse_iterator operator+(size_type) reverse_iterator operator-(size_type) - difference_type operator-(reverse_iterator) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) + deque() except + deque(deque&) except + deque(size_t) except + deque(size_t, T&) except + - #deque[input_iterator](input_iterator, input_iterator) + #deque[InputIt](InputIt, InputIt) T& operator[](size_t) #deque& operator=(deque&) bint operator==(deque&, deque&) @@ -52,35 +125,39 @@ cdef extern from "<deque>" namespace "std" nogil: bint operator>(deque&, deque&) bint operator<=(deque&, deque&) bint operator>=(deque&, deque&) - void assign(size_t, T&) - void assign(input_iterator, input_iterator) - T& at(size_t) + void assign(size_t, T&) except + + void assign[InputIt](InputIt, InputIt) except + + T& at(size_t) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() bint empty() iterator end() const_iterator const_end "end"() - iterator erase(iterator) - iterator erase(iterator, iterator) + const_iterator cend() + iterator erase(iterator) except + + iterator erase(iterator, iterator) except + T& front() - iterator insert(iterator, T&) - void insert(iterator, size_t, T&) - void insert(iterator, input_iterator, input_iterator) + iterator insert(iterator, T&) except + + void insert(iterator, size_t, T&) except + + void insert[InputIt](iterator, InputIt, InputIt) except + size_t max_size() void pop_back() void pop_front() - void push_back(T&) - void push_front(T&) + void push_back(T&) except + + void push_front(T&) except + reverse_iterator rbegin() #const_reverse_iterator rbegin() + const_reverse_iterator crbegin() reverse_iterator rend() #const_reverse_iterator rend() - void resize(size_t) - void resize(size_t, T&) + const_reverse_iterator crend() + void resize(size_t) except + + void resize(size_t, T&) except + size_t size() void swap(deque&) # C++11 methods - void shrink_to_fit() + void shrink_to_fit() except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/execution.pxd b/contrib/tools/cython/Cython/Includes/libcpp/execution.pxd new file mode 100644 index 00000000000..eb92e3404f6 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/execution.pxd @@ -0,0 +1,15 @@ + +cdef extern from "<execution>" namespace "std::execution" nogil: + cdef cppclass sequenced_policy: + pass + cdef cppclass parallel_policy: + pass + cdef cppclass parallel_unsequenced_policy: + pass + cdef cppclass unsequenced_policy: + pass + + const sequenced_policy seq "std::execution::seq" + const parallel_policy par "std::execution::par" + const parallel_unsequenced_policy par_unseq "std::execution::par_unseq" + const unsequenced_policy unseq "std::execution::unseq" diff --git a/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd index 8c3b240d041..3e04ce87553 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd @@ -14,6 +14,7 @@ cdef extern from "<forward_list>" namespace "std" nogil: iterator(iterator &) T& operator*() iterator operator++() + iterator operator++(int) bint operator==(iterator) bint operator!=(iterator) cppclass const_iterator(iterator): diff --git a/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd index 94cbd9e1dd8..596ea90da01 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd @@ -1,3 +1,5 @@ +from libcpp cimport bool + cdef extern from "<functional>" namespace "std" nogil: cdef cppclass function[T]: function() except + @@ -10,4 +12,15 @@ cdef extern from "<functional>" namespace "std" nogil: function operator=(void*) function operator=[U](U) - bint operator bool() + bool operator bool() + + # Comparisons + cdef cppclass greater[T=*]: + # https://github.com/cython/cython/issues/3193 + greater() except + + bool operator()(const T& lhs, const T& rhs) except + + + cdef cppclass reference_wrapper[T]: + reference_wrapper() + reference_wrapper(T) + T& get() const diff --git a/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd index e0f8bd8d6e4..0b50c586d36 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd @@ -1,6 +1,8 @@ #Basic reference: http://www.cplusplus.com/reference/iterator/ #Most of these classes are in fact empty structs +from libc.stddef import ptrdiff_t + cdef extern from "<iterator>" namespace "std" nogil: cdef cppclass iterator[Category,T,Distance,Pointer,Reference]: pass @@ -29,4 +31,4 @@ cdef extern from "<iterator>" namespace "std" nogil: ##insert_iterator<Container> inserter (Container& x, typename Container::iterator it) insert_iterator[CONTAINER] inserter[CONTAINER,ITERATOR](CONTAINER &, ITERATOR) - + ptrdiff_t distance[It](It first, It last) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd index c325263b727..11f5e23eab4 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd @@ -1,61 +1,61 @@ cdef extern from "<limits>" namespace "std" nogil: - enum float_round_style: + enum float_round_style: round_indeterminate = -1 round_toward_zero = 0 round_to_nearest = 1 round_toward_infinity = 2 round_toward_neg_infinity = 3 - enum float_denorm_style: + enum float_denorm_style: denorm_indeterminate = -1 denorm_absent = 0 denorm_present = 1 - #The static methods can be called as, e.g. numeric_limits[int].round_error(), etc. - #The const data members should be declared as static. Cython currently doesn't allow that - #and/or I can't figure it out, so you must instantiate an object to access, e.g. - #cdef numeric_limits[double] lm - #print lm.round_style - cdef cppclass numeric_limits[T]: - const bint is_specialized - @staticmethod - T min() - @staticmethod - T max() - const int digits - const int digits10 - const bint is_signed - const bint is_integer - const bint is_exact - const int radix - @staticmethod - T epsilon() - @staticmethod - T round_error() + #The static methods can be called as, e.g. numeric_limits[int].round_error(), etc. + #The const data members should be declared as static. Cython currently doesn't allow that + #and/or I can't figure it out, so you must instantiate an object to access, e.g. + #cdef numeric_limits[double] lm + #print lm.round_style + cdef cppclass numeric_limits[T]: + const bint is_specialized + @staticmethod + T min() + @staticmethod + T max() + const int digits + const int digits10 + const bint is_signed + const bint is_integer + const bint is_exact + const int radix + @staticmethod + T epsilon() + @staticmethod + T round_error() - const int min_exponent - const int min_exponent10 - const int max_exponent - const int max_exponent10 + const int min_exponent + const int min_exponent10 + const int max_exponent + const int max_exponent10 - const bint has_infinity - const bint has_quiet_NaN - const bint has_signaling_NaN - const float_denorm_style has_denorm - const bint has_denorm_loss - @staticmethod - T infinity() - @staticmethod - T quiet_NaN() - @staticmethod - T signaling_NaN() - @staticmethod - T denorm_min() + const bint has_infinity + const bint has_quiet_NaN + const bint has_signaling_NaN + const float_denorm_style has_denorm + const bint has_denorm_loss + @staticmethod + T infinity() + @staticmethod + T quiet_NaN() + @staticmethod + T signaling_NaN() + @staticmethod + T denorm_min() - const bint is_iec559 - const bint is_bounded - const bint is_modulo + const bint is_iec559 + const bint is_bounded + const bint is_modulo - const bint traps - const bint tinyness_before - const float_round_style round_style + const bint traps + const bint tinyness_before + const float_round_style round_style diff --git a/contrib/tools/cython/Cython/Includes/libcpp/list.pxd b/contrib/tools/cython/Cython/Includes/libcpp/list.pxd index b5b0410ad81..b69cd573e53 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/list.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/list.pxd @@ -9,26 +9,61 @@ cdef extern from "<list>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: - iterator() - iterator(iterator &) - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - reverse_iterator() - reverse_iterator(iterator &) - T& operator*() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + list() except + list(list&) except + list(size_t, T&) except + @@ -39,36 +74,40 @@ cdef extern from "<list>" namespace "std" nogil: bint operator>(list&, list&) bint operator<=(list&, list&) bint operator>=(list&, list&) - void assign(size_t, T&) + void assign(size_t, T&) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() iterator erase(iterator) iterator erase(iterator, iterator) T& front() iterator insert(iterator, T&) void insert(iterator, size_t, T&) size_t max_size() - void merge(list&) + void merge(list&) except + #void merge(list&, BinPred) void pop_back() void pop_front() - void push_back(T&) - void push_front(T&) + void push_back(T&) except + + void push_front(T&) except + reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() - void remove(T&) + const_reverse_iterator crbegin() + void remove(T&) except + #void remove_if(UnPred) reverse_iterator rend() const_reverse_iterator const_rend "rend"() - void resize(size_t, T&) + const_reverse_iterator crend() + void resize(size_t, T&) except + void reverse() size_t size() - void sort() + void sort() except + #void sort(BinPred) void splice(iterator, list&) void splice(iterator, list&, iterator) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd index 624a7ac026f..eb739509ac1 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/map.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd @@ -7,26 +7,80 @@ cdef extern from "<map>" namespace "std" nogil: ctypedef pair[const T, U] value_type ctypedef COMPARE key_compare ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen pair[T, U]& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen pair[T, U]& operator*() - iterator operator++() - iterator operator--() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + map() except + map(map&) except + #map(key_compare&) - U& operator[](T&) + U& operator[](const T&) #map& operator=(map&) bint operator==(map&, map&) bint operator!=(map&, map&) @@ -38,31 +92,161 @@ cdef extern from "<map>" namespace "std" nogil: const U& const_at "at"(const T&) except + iterator begin() const_iterator const_begin "begin" () + const_iterator cbegin() void clear() size_t count(const T&) bint empty() iterator end() const_iterator const_end "end" () + const_iterator cend() pair[iterator, iterator] equal_range(const T&) - #pair[const_iterator, const_iterator] equal_range(key_type&) - void erase(iterator) - void erase(iterator, iterator) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) size_t erase(const T&) iterator find(const T&) const_iterator const_find "find" (const T&) - pair[iterator, bint] insert(pair[T, U]) except + # XXX pair[T,U]& - iterator insert(iterator, pair[T, U]) except + # XXX pair[T,U]& - #void insert(input_iterator, input_iterator) + pair[iterator, bint] insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + #key_compare key_comp() iterator lower_bound(const T&) const_iterator const_lower_bound "lower_bound"(const T&) size_t max_size() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() size_t size() void swap(map&) iterator upper_bound(const T&) const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() + # C++20 + bint contains(const T&) + + cdef cppclass multimap[T, U, COMPARE=*, ALLOCATOR=*]: + ctypedef T key_type + ctypedef U mapped_type + ctypedef pair[const T, U] value_type + ctypedef COMPARE key_compare + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator + cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen + pair[T, U]& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + + multimap() except + + multimap(const multimap&) except + + #multimap(key_compare&) + #multimap& operator=(multimap&) + bint operator==(const multimap&, const multimap&) + bint operator!=(const multimap&, const multimap&) + bint operator<(const multimap&, const multimap&) + bint operator>(const multimap&, const multimap&) + bint operator<=(const multimap&, const multimap&) + bint operator>=(const multimap&, const multimap&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + + #key_compare key_comp() + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + size_t size() + void swap(multimap&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() + bint contains(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd index 2151c1ec7f2..0b2070f429a 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd @@ -59,6 +59,7 @@ cdef extern from "<memory>" namespace "std" nogil: shared_ptr(shared_ptr[T]&, T*) shared_ptr(unique_ptr[T]&) #shared_ptr(weak_ptr[T]&) # Not Supported + shared_ptr[T]& operator=[Y](const shared_ptr[Y]& ptr) # Modifiers void reset() @@ -105,8 +106,7 @@ cdef extern from "<memory>" namespace "std" nogil: # Smart pointer non-member operations shared_ptr[T] make_shared[T](...) except + - # Temporaries used for exception handling break generated code - unique_ptr[T] make_unique[T](...) # except + + unique_ptr[T] make_unique[T](...) except + # No checking on the compatibility of T and U. cdef shared_ptr[T] static_pointer_cast[T, U](const shared_ptr[U]&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/numbers.pxd b/contrib/tools/cython/Cython/Includes/libcpp/numbers.pxd new file mode 100644 index 00000000000..abd3069a134 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/numbers.pxd @@ -0,0 +1,15 @@ +cdef extern from "<numbers>" namespace "std::numbers" nogil: + # C++20 mathematical constants + const double e + const double log2e + const double log10e + const double pi + const double inv_pi + const double inv_sqrtpi + const double ln2 + const double ln10 + const double sqrt2 + const double sqrt3 + const double inv_sqrt3 + const double egamma + const double phi diff --git a/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd b/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd new file mode 100644 index 00000000000..a9fb37205a5 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd @@ -0,0 +1,131 @@ +cdef extern from "<numeric>" namespace "std" nogil: + T inner_product[InputIt1, InputIt2, T](InputIt1 first1, InputIt1 last1, InputIt2 first2, T init) + + T inner_product[InputIt1, InputIt2, T, BinaryOperation1, BinaryOperation2](InputIt1 first1, InputIt1 last1, + InputIt2 first2, T init, + BinaryOperation1 op1, + BinaryOperation2 op2) + + void iota[ForwardIt, T](ForwardIt first, ForwardIt last, T value) + + T accumulate[InputIt, T](InputIt first, InputIt last, T init) + + T accumulate[InputIt, T, BinaryOperation](InputIt first, InputIt last, T init, BinaryOperation op) + + void adjacent_difference[InputIt, OutputIt](InputIt in_first, InputIt in_last, OutputIt out_first) + + void adjacent_difference[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, + BinaryOperation op) + + void partial_sum[InputIt, OutputIt](InputIt in_first, OutputIt in_last, OutputIt out_first) + + void partial_sum[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, + BinaryOperation op) + + + T reduce[InputIt, T](InputIt first, InputIt last, T init) + + # ambiguous with next overload + #T reduce[ExecutionPolicy, ForwardIt, T](ExecutionPolicy&& policy, + # ForwardIt first, ForwardIt last, T init) + + T reduce[InputIt, T, BinaryOp](InputIt first, InputIt last, T init, BinaryOp binary_op) + + T reduce[ExecutionPolicy, ForwardIt, T, BinaryOp](ExecutionPolicy&& policy, + ForwardIt first, ForwardIt last, T init, BinaryOp binary_op) + + T transform_reduce[InputIt1, InputIt2, T](InputIt1 first1, InputIt1 last1, + InputIt2 first2, T init) + + T transform_reduce[InputIt1, InputIt2, T, BinaryReductionOp, BinaryTransformOp]( + InputIt1 first1, InputIt1 last1, InputIt2 first2, T init, + BinaryReductionOp reduce, BinaryTransformOp transform) + + T transform_reduce[InputIt, T, BinaryReductionOp, UnaryTransformOp]( + InputIt first, InputIt last, T init, BinaryReductionOp reduce, + UnaryTransformOp transform) + + # ambiguous with previous overload + #T transform_reduce[ExecutionPolicy, ForwardIt1, ForwardIt2, T]( + # ExecutionPolicy&& policy, ForwardIt1 first1, ForwardIt1 last1, + # ForwardIt2 first2, T init) + + T transform_reduce[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryReductionOp, BinaryTransformOp]( + ExecutionPolicy&& policy, ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, T init, + BinaryReductionOp reduce, BinaryTransformOp transform) + + # ambiguous with second overload + #T transform_reduce[ExecutionPolicy, ForwardIt, T, BinaryReductionOp, UnaryTransformOp]( + # ExecutionPolicy&& policy, ForwardIt first, ForwardIt last, T init, BinaryReductionOp reduce, + # UnaryTransformOp transform) + + OutputIt inclusive_scan[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first) + + # ambiguous with next overload + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, + # ForwardIt2 d_first) + + OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op) + + # ambiguous with next overload + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op) + + OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation, T]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + T init) + + # + # ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, T]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op, T init) + + OutputIt exclusive_scan[InputIt, OutputIt, T](InputIt first, InputIt last, + OutputIt d_first, T init) + + # ambiguous with next overload + #ForwardIt2 exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, + # ForwardIt2 d_first, T init) + + OutputIt exclusive_scan[InputIt, OutputIt, T, BinaryOperation]( + InputIt first, InputIt last, OutputIt d_first, T init, BinaryOperation binary_op) + + ForwardIt2 exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryOperation]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + T init, BinaryOperation binary_op) + + OutputIt transform_inclusive_scan[InputIt, OutputIt, BinaryOperation, UnaryOperation]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + UnaryOperation unary_op) + + # ambiguous with next overload + # ForwardIt2 transform_inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, UnaryOperation]( + # ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + # BinaryOperation binary_op, UnaryOperation unary_op) + + OutputIt transform_inclusive_scan[InputIt, OutputIt, BinaryOperation, UnaryOperation, T]( + InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, + UnaryOperation unary_op, T init) + + ForwardIt2 transform_inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, UnaryOperation, T]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + BinaryOperation binary_op, UnaryOperation unary_op, T init) + + OutputIt transform_exclusive_scan[InputIt, OutputIt, T, BinaryOperation, UnaryOperation]( + InputIt first, InputIt last, OutputIt d_first, T init, BinaryOperation binary_op, + UnaryOperation unary_op) + + ForwardIt2 transform_exclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, T, BinaryOperation, UnaryOperation]( + ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, + T init, BinaryOperation binary_op, UnaryOperation unary_op) + + # C++17 + T gcd[T](T a, T b) + T lcm[T](T a, T b) + + # C++20 + T midpoint[T](T a, T b) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/optional.pxd b/contrib/tools/cython/Cython/Includes/libcpp/optional.pxd new file mode 100644 index 00000000000..284dfcd6e50 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/optional.pxd @@ -0,0 +1,34 @@ +from libcpp cimport bool + +cdef extern from "<optional>" namespace "std" nogil: + cdef cppclass nullopt_t: + nullopt_t() + + cdef nullopt_t nullopt + + cdef cppclass optional[T]: + ctypedef T value_type + optional() + optional(nullopt_t) + optional(optional&) except + + optional(T&) except + + bool has_value() + T& value() + T& value_or[U](U& default_value) + void swap(optional&) + void reset() + T& emplace(...) + T& operator*() + #T* operator->() # Not Supported + optional& operator=(optional&) + optional& operator=[U](U&) + bool operator bool() + bool operator!() + bool operator==[U](optional&, U&) + bool operator!=[U](optional&, U&) + bool operator<[U](optional&, U&) + bool operator>[U](optional&, U&) + bool operator<=[U](optional&, U&) + bool operator>=[U](optional&, U&) + + optional[T] make_optional[T](...) except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/random.pxd b/contrib/tools/cython/Cython/Includes/libcpp/random.pxd new file mode 100644 index 00000000000..9e48bb27f77 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/libcpp/random.pxd @@ -0,0 +1,166 @@ +from libc.stdint cimport uint_fast32_t, uint_fast64_t + + +cdef extern from "<random>" namespace "std" nogil: + cdef cppclass random_device: + ctypedef uint_fast32_t result_type + random_device() except + + result_type operator()() except + + + cdef cppclass mt19937: + ctypedef uint_fast32_t result_type + mt19937() except + + mt19937(result_type seed) except + + result_type operator()() except + + result_type min() except + + result_type max() except + + void discard(size_t z) except + + void seed(result_type seed) except + + + cdef cppclass mt19937_64: + ctypedef uint_fast64_t result_type + + mt19937_64() except + + mt19937_64(result_type seed) except + + result_type operator()() except + + result_type min() except + + result_type max() except + + void discard(size_t z) except + + void seed(result_type seed) except + + + cdef cppclass uniform_int_distribution[T]: + ctypedef T result_type + uniform_int_distribution() except + + uniform_int_distribution(T, T) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass uniform_real_distribution[T]: + ctypedef T result_type + uniform_real_distribution() except + + uniform_real_distribution(T, T) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass bernoulli_distribution: + ctypedef bint result_type + bernoulli_distribution() except + + bernoulli_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass binomial_distribution[T]: + ctypedef T result_type + binomial_distribution() except + + binomial_distribution(T, double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass geometric_distribution[T]: + ctypedef T result_type + geometric_distribution() except + + geometric_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + + cdef cppclass negative_binomial_distribution[T]: + ctypedef T result_type + negative_binomial_distribution() except + + negative_binomial_distribution(T, double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass poisson_distribution[T]: + ctypedef T result_type + poisson_distribution() except + + poisson_distribution(double) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass exponential_distribution[T]: + ctypedef T result_type + exponential_distribution() except + + exponential_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass gamma_distribution[T]: + ctypedef T result_type + gamma_distribution() except + + gamma_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass weibull_distribution[T]: + ctypedef T result_type + weibull_distribution() except + + weibull_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass extreme_value_distribution[T]: + ctypedef T result_type + extreme_value_distribution() except + + extreme_value_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass normal_distribution[T]: + ctypedef T result_type + normal_distribution() except + + normal_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass lognormal_distribution[T]: + ctypedef T result_type + lognormal_distribution() except + + lognormal_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass chi_squared_distribution[T]: + ctypedef T result_type + chi_squared_distribution() except + + chi_squared_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass cauchy_distribution[T]: + ctypedef T result_type + cauchy_distribution() except + + cauchy_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass fisher_f_distribution[T]: + ctypedef T result_type + fisher_f_distribution() except + + fisher_f_distribution(result_type, result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + + + cdef cppclass student_t_distribution[T]: + ctypedef T result_type + student_t_distribution() except + + student_t_distribution(result_type) except + + result_type operator()[Generator](Generator&) except + + result_type min() except + + result_type max() except + diff --git a/contrib/tools/cython/Cython/Includes/libcpp/set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd index 1069be7466a..444b1ce9f38 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/set.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd @@ -3,22 +3,68 @@ from .utility cimport pair cdef extern from "<set>" namespace "std" nogil: cdef cppclass set[T]: ctypedef T value_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - T& operator*() - iterator operator++() - iterator operator--() + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_reverse_iterator) + set() except + set(set&) except + #set(key_compare&) @@ -31,31 +77,152 @@ cdef extern from "<set>" namespace "std" nogil: bint operator>=(set&, set&) iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() size_t count(const T&) bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() pair[iterator, iterator] equal_range(const T&) - #pair[const_iterator, const_iterator] equal_range(T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) iterator erase(iterator) - iterator erase(iterator, iterator) - size_t erase(T&) - iterator find(T&) - const_iterator const_find "find"(T&) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) pair[iterator, bint] insert(const T&) except + iterator insert(iterator, const T&) except + - void insert(iterator, iterator) except + + iterator insert(const_iterator, const T&) except + + iterator const_insert "insert"(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + #key_compare key_comp() - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) size_t max_size() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() size_t size() void swap(set&) iterator upper_bound(const T&) const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() + # C++20 + bint contains(const T&) + + cdef cppclass multiset[T]: + ctypedef T value_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + value_type& operator*() + iterator operator++() + iterator operator--() + iterator operator++(int) + iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + cppclass const_reverse_iterator + cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + + multiset() except + + multiset(multiset&) except + + #multiset(key_compare&) + #multiset& operator=(multiset&) + bint operator==(multiset&, multiset&) + bint operator!=(multiset&, multiset&) + bint operator<(multiset&, multiset&) + bint operator>(multiset&, multiset&) + bint operator<=(multiset&, multiset&) + bint operator>=(multiset&, multiset&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const T&) except + + iterator insert(iterator, const T&) except + + iterator const_insert "insert"(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + + #key_compare key_comp() + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) + size_t max_size() + reverse_iterator rbegin() + const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() + reverse_iterator rend() + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + size_t size() + void swap(multiset&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + # C++20 + bint contains(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd index 2dc80992b76..f92240f6669 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd @@ -6,6 +6,6 @@ cdef extern from "<stack>" namespace "std" nogil: #stack(Container&) bint empty() void pop() - void push(T&) + void push(T&) except + size_t size() T& top() diff --git a/contrib/tools/cython/Cython/Includes/libcpp/string.pxd b/contrib/tools/cython/Cython/Includes/libcpp/string.pxd index a894144f1f6..566c748f5f6 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/string.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/string.pxd @@ -7,34 +7,116 @@ cdef extern from "<string>" namespace "std::string" nogil: cdef extern from "<string>" namespace "std" nogil: cdef cppclass string: + ctypedef char value_type + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator cppclass iterator: - iterator() - char& operator*() - iterator(iterator&) + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) + iterator operator+(size_type) + iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) - + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: - char& operator*() - iterator operator++() - iterator operator--() - iterator operator+(size_t) - iterator operator-(size_t) + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + + value_type& operator*() + reverse_iterator operator++() + reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) + reverse_iterator operator+(size_type) + reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - - cppclass const_iterator(iterator): - pass - - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const value_type& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) string() except + string(const string& s) except + @@ -47,12 +129,16 @@ cdef extern from "<string>" namespace "std" nogil: iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() iterator end() const_iterator const_end "end"() + const_iterator cend() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() const char* c_str() const char* data() @@ -62,6 +148,7 @@ cdef extern from "<string>" namespace "std" nogil: void resize(size_t) except + void resize(size_t, char) except + void shrink_to_fit() except + + void swap(string& other) size_t capacity() void reserve(size_t) except + void clear() @@ -109,6 +196,16 @@ cdef extern from "<string>" namespace "std" nogil: void insert(iterator p, size_t n, char c) except + iterator insert(iterator p, char c) except + + string& replace(size_t pos, size_t len, const string& str) except + + string& replace(iterator i1, iterator i2, const string& str) except + + string& replace(size_t pos, size_t len, const string& str, size_t subpos, size_t sublen) except + + string& replace(size_t pos, size_t len, const char* s) except + + string& replace(iterator i1, iterator i2, const char* s) except + + string& replace(size_t pos, size_t len, const char* s, size_t n) except + + string& replace(iterator i1, iterator i2, const char* s, size_t n) except + + string& replace(size_t pos, size_t len, size_t n, char c) except + + string& replace(iterator i1, iterator i2, size_t n, char c) except + + size_t copy(char* s, size_t len, size_t pos) except + size_t copy(char* s, size_t len) except + @@ -164,6 +261,15 @@ cdef extern from "<string>" namespace "std" nogil: string substr(size_t pos) except + string substr() + # C++20 + bint starts_with(char c) except + + bint starts_with(const char* s) + bint ends_with(char c) except + + bint ends_with(const char* s) + # C++23 + bint contains(char c) except + + bint contains(const char* s) + #string& operator= (const string&) #string& operator= (const char*) #string& operator= (char) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd index a00fbbed280..90f5a2d06b3 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd @@ -5,26 +5,49 @@ cdef extern from "<unordered_map>" namespace "std" nogil: ctypedef T key_type ctypedef U mapped_type ctypedef pair[const T, U] value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass iterator cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen pair[T, U]& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) - cppclass reverse_iterator: - pair[T, U]& operator*() - iterator operator++() - iterator operator--() - bint operator==(reverse_iterator) - bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + unordered_map() except + unordered_map(unordered_map&) except + #unordered_map(key_compare&) - U& operator[](T&) + U& operator[](const T&) #unordered_map& operator=(unordered_map&) bint operator==(unordered_map&, unordered_map&) bint operator!=(unordered_map&, unordered_map&) @@ -32,43 +55,139 @@ cdef extern from "<unordered_map>" namespace "std" nogil: bint operator>(unordered_map&, unordered_map&) bint operator<=(unordered_map&, unordered_map&) bint operator>=(unordered_map&, unordered_map&) - U& at(const T&) - const U& const_at "at"(const T&) + U& at(const T&) except + + const U& const_at "at"(const T&) except + iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() - size_t count(T&) + size_t count(const T&) bint empty() iterator end() const_iterator const_end "end"() - pair[iterator, iterator] equal_range(T&) + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) iterator erase(iterator) - iterator erase(iterator, iterator) - size_t erase(T&) - iterator find(T&) - const_iterator const_find "find"(T&) - pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& - iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& - iterator insert(iterator, iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + pair[iterator, bint] insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + #key_compare key_comp() - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) size_t max_size() - reverse_iterator rbegin() - const_reverse_iterator const_rbegin "rbegin"() - reverse_iterator rend() - const_reverse_iterator const_rend "rend"() size_t size() void swap(unordered_map&) - iterator upper_bound(T&) - const_iterator const_upper_bound "upper_bound"(T&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + float load_factor() + void rehash(size_t) + void reserve(size_t) + size_t bucket_count() + size_t max_bucket_count() + size_t bucket_size(size_t) + size_t bucket(const T&) + # C++20 + bint contains(const T&) + + cdef cppclass unordered_multimap[T, U, HASH=*, PRED=*, ALLOCATOR=*]: + ctypedef T key_type + ctypedef U mapped_type + ctypedef pair[const T, U] value_type + ctypedef ALLOCATOR allocator_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + # correct would be value_type& but this does not work + # well with cython's code gen + pair[T, U]& operator*() + iterator operator++() + iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + # correct would be const value_type& but this does not work + # well with cython's code gen + const pair[T, U]& operator*() + const_iterator operator++() + const_iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + unordered_multimap() except + + unordered_multimap(const unordered_multimap&) except + + #unordered_multimap(key_compare&) + #unordered_map& operator=(unordered_multimap&) + bint operator==(const unordered_multimap&, const unordered_multimap&) + bint operator!=(const unordered_multimap&, const unordered_multimap&) + bint operator<(const unordered_multimap&, const unordered_multimap&) + bint operator>(const unordered_multimap&, const unordered_multimap&) + bint operator<=(const unordered_multimap&, const unordered_multimap&) + bint operator>=(const unordered_multimap&, const unordered_multimap&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + #local_iterator begin(size_t) + #const_local_iterator const_begin "begin"(size_t) + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + #local_iterator end(size_t) + #const_local_iterator const_end "end"(size_t) + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const pair[T, U]&) except + + iterator insert(const_iterator, const pair[T, U]&) except + + void insert[InputIt](InputIt, InputIt) except + + #key_compare key_comp() + iterator lower_bound(const T&) + const_iterator const_lower_bound "lower_bound"(const T&) + size_t max_size() + size_t size() + void swap(unordered_multimap&) + iterator upper_bound(const T&) + const_iterator const_upper_bound "upper_bound"(const T&) #value_compare value_comp() void max_load_factor(float) float max_load_factor() + float load_factor() void rehash(size_t) void reserve(size_t) size_t bucket_count() size_t max_bucket_count() size_t bucket_size(size_t) size_t bucket(const T&) + # C++20 + bint contains(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd index 5aa24175285..6aae890d930 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd @@ -3,67 +3,150 @@ from .utility cimport pair cdef extern from "<unordered_set>" namespace "std" nogil: cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]: ctypedef T value_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator cppclass iterator: - T& operator*() + iterator() except + + iterator(iterator&) except + + value_type& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) - cppclass reverse_iterator: - T& operator*() - iterator operator++() - iterator operator--() - bint operator==(reverse_iterator) - bint operator!=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + unordered_set() except + unordered_set(unordered_set&) except + - #unordered_set(key_compare&) #unordered_set& operator=(unordered_set&) bint operator==(unordered_set&, unordered_set&) bint operator!=(unordered_set&, unordered_set&) - bint operator<(unordered_set&, unordered_set&) - bint operator>(unordered_set&, unordered_set&) - bint operator<=(unordered_set&, unordered_set&) - bint operator>=(unordered_set&, unordered_set&) iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() void clear() - size_t count(T&) + size_t count(const T&) bint empty() iterator end() const_iterator const_end "end"() - pair[iterator, iterator] equal_range(T&) - pair[const_iterator, const_iterator] const_equal_range "equal_range"(T&) + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) iterator erase(iterator) - iterator erase(iterator, iterator) - size_t erase(T&) - iterator find(T&) - const_iterator const_find "find"(T&) - pair[iterator, bint] insert(T&) - iterator insert(iterator, T&) - #key_compare key_comp() - iterator insert(iterator, iterator) - iterator lower_bound(T&) - const_iterator const_lower_bound "lower_bound"(T&) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + pair[iterator, bint] insert(const T&) except + + iterator insert(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + size_t max_size() - reverse_iterator rbegin() - const_reverse_iterator const_rbegin "rbegin"() - reverse_iterator rend() - const_reverse_iterator const_rend "rend"() size_t size() void swap(unordered_set&) - iterator upper_bound(T&) - const_iterator const_upper_bound "upper_bound"(T&) #value_compare value_comp() void max_load_factor(float) float max_load_factor() + float load_factor() + void rehash(size_t) + void reserve(size_t) + size_t bucket_count() + size_t max_bucket_count() + size_t bucket_size(size_t) + size_t bucket(const T&) + # C++20 + bint contains(const T&) + + cdef cppclass unordered_multiset[T,HASH=*,PRED=*,ALLOCATOR=*]: + ctypedef T value_type + + # these should really be allocator_type.size_type and + # allocator_type.difference_type to be true to the C++ definition + # but cython doesn't support deferred access on template arguments + ctypedef size_t size_type + ctypedef ptrdiff_t difference_type + + cppclass const_iterator + cppclass iterator: + iterator() except + + iterator(iterator&) except + + value_type& operator*() + iterator operator++() + iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + operator=(iterator&) except + + const value_type& operator*() + const_iterator operator++() + const_iterator operator++(int) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + + unordered_multiset() except + + unordered_multiset(unordered_multiset&) except + + #unordered_multiset& operator=(unordered_multiset&) + bint operator==(unordered_multiset&, unordered_multiset&) + bint operator!=(unordered_multiset&, unordered_multiset&) + iterator begin() + const_iterator const_begin "begin"() + const_iterator cbegin() + void clear() + size_t count(const T&) + bint empty() + iterator end() + const_iterator const_end "end"() + const_iterator cend() + pair[iterator, iterator] equal_range(const T&) + pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&) + iterator erase(iterator) + iterator const_erase "erase"(const_iterator) + iterator erase(const_iterator, const_iterator) + size_t erase(const T&) + iterator find(const T&) + const_iterator const_find "find"(const T&) + iterator insert(const T&) except + + iterator insert(const_iterator, const T&) except + + void insert[InputIt](InputIt, InputIt) except + + size_t max_size() + size_t size() + void swap(unordered_multiset&) + #value_compare value_comp() + void max_load_factor(float) + float max_load_factor() + float load_factor() void rehash(size_t) void reserve(size_t) size_t bucket_count() size_t max_bucket_count() size_t bucket_size(size_t) size_t bucket(const T&) + # C++20 + bint contains(const T&) diff --git a/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd index 9b007dd0c79..3def8a568b1 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd @@ -9,41 +9,114 @@ cdef extern from "<vector>" namespace "std" nogil: ctypedef size_t size_type ctypedef ptrdiff_t difference_type + cppclass const_iterator cppclass iterator: + iterator() except + + iterator(iterator&) except + T& operator*() iterator operator++() iterator operator--() + iterator operator++(int) + iterator operator--(int) iterator operator+(size_type) iterator operator-(size_type) difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(iterator) + bint operator==(const_iterator) bint operator!=(iterator) + bint operator!=(const_iterator) bint operator<(iterator) + bint operator<(const_iterator) bint operator>(iterator) + bint operator>(const_iterator) bint operator<=(iterator) + bint operator<=(const_iterator) bint operator>=(iterator) + bint operator>=(const_iterator) + cppclass const_iterator: + const_iterator() except + + const_iterator(iterator&) except + + const_iterator(const_iterator&) except + + operator=(iterator&) except + + const T& operator*() + const_iterator operator++() + const_iterator operator--() + const_iterator operator++(int) + const_iterator operator--(int) + const_iterator operator+(size_type) + const_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(iterator) + bint operator==(const_iterator) + bint operator!=(iterator) + bint operator!=(const_iterator) + bint operator<(iterator) + bint operator<(const_iterator) + bint operator>(iterator) + bint operator>(const_iterator) + bint operator<=(iterator) + bint operator<=(const_iterator) + bint operator>=(iterator) + bint operator>=(const_iterator) + + cppclass const_reverse_iterator cppclass reverse_iterator: + reverse_iterator() except + + reverse_iterator(reverse_iterator&) except + T& operator*() reverse_iterator operator++() reverse_iterator operator--() + reverse_iterator operator++(int) + reverse_iterator operator--(int) reverse_iterator operator+(size_type) reverse_iterator operator-(size_type) - difference_type operator-(reverse_iterator) + difference_type operator-(iterator) + difference_type operator-(const_iterator) bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) bint operator>=(reverse_iterator) - cppclass const_iterator(iterator): - pass - cppclass const_reverse_iterator(reverse_iterator): - pass + bint operator>=(const_reverse_iterator) + cppclass const_reverse_iterator: + const_reverse_iterator() except + + const_reverse_iterator(reverse_iterator&) except + + operator=(reverse_iterator&) except + + const T& operator*() + const_reverse_iterator operator++() + const_reverse_iterator operator--() + const_reverse_iterator operator++(int) + const_reverse_iterator operator--(int) + const_reverse_iterator operator+(size_type) + const_reverse_iterator operator-(size_type) + difference_type operator-(iterator) + difference_type operator-(const_iterator) + bint operator==(reverse_iterator) + bint operator==(const_reverse_iterator) + bint operator!=(reverse_iterator) + bint operator!=(const_reverse_iterator) + bint operator<(reverse_iterator) + bint operator<(const_reverse_iterator) + bint operator>(reverse_iterator) + bint operator>(const_reverse_iterator) + bint operator<=(reverse_iterator) + bint operator<=(const_reverse_iterator) + bint operator>=(reverse_iterator) + bint operator>=(const_reverse_iterator) + vector() except + vector(vector&) except + vector(size_type) except + vector(size_type, T&) except + - #vector[input_iterator](input_iterator, input_iterator) + #vector[InputIt](InputIt, InputIt) T& operator[](size_type) #vector& operator=(vector&) bint operator==(vector&, vector&) @@ -53,30 +126,34 @@ cdef extern from "<vector>" namespace "std" nogil: bint operator<=(vector&, vector&) bint operator>=(vector&, vector&) void assign(size_type, const T&) - void assign[input_iterator](input_iterator, input_iterator) except + + void assign[InputIt](InputIt, InputIt) except + T& at(size_type) except + T& back() iterator begin() const_iterator const_begin "begin"() + const_iterator cbegin() size_type capacity() void clear() bint empty() iterator end() const_iterator const_end "end"() + const_iterator cend() iterator erase(iterator) iterator erase(iterator, iterator) T& front() iterator insert(iterator, const T&) except + iterator insert(iterator, size_type, const T&) except + - iterator insert[Iter](iterator, Iter, Iter) except + + iterator insert[InputIt](iterator, InputIt, InputIt) except + size_type max_size() void pop_back() void push_back(T&) except + reverse_iterator rbegin() - const_reverse_iterator const_rbegin "crbegin"() + const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator crbegin() reverse_iterator rend() - const_reverse_iterator const_rend "crend"() - void reserve(size_type) + const_reverse_iterator const_rend "rend"() + const_reverse_iterator crend() + void reserve(size_type) except + void resize(size_type) except + void resize(size_type, T&) except + size_type size() @@ -85,4 +162,6 @@ cdef extern from "<vector>" namespace "std" nogil: # C++11 methods T* data() const T* const_data "data"() - void shrink_to_fit() + void shrink_to_fit() except + + iterator emplace(const_iterator, ...) except + + T& emplace_back(...) except + diff --git a/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd index 15700c05efd..228aee4cff8 100644 --- a/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd +++ b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd @@ -1,30 +1,31 @@ # NumPy static imports for Cython # -# If any of the PyArray_* functions are called, import_array must be -# called first. -# -# This also defines backwards-compatibility buffer acquisition -# code for use in Python 2.x (or Python <= 2.5 when NumPy starts -# implementing PEP-3118 directly). +# NOTE: Do not make incompatible local changes to this file without contacting the NumPy project. +# This file is maintained by the NumPy project at +# https://github.com/numpy/numpy/tree/master/numpy # -# Because of laziness, the format string of the buffer is statically -# allocated. Increase the size if this is not enough, or submit a -# patch to do this properly. +# If any of the PyArray_* functions are called, import_array must be +# called first. This is done automatically by Cython 3.0+ if a call +# is not detected inside of the module. # # Author: Dag Sverre Seljebotn # -DEF _buffer_format_string_len = 255 - -cimport cpython.buffer as pybuf from cpython.ref cimport Py_INCREF -from cpython.mem cimport PyObject_Malloc, PyObject_Free -from cpython.object cimport PyObject, PyTypeObject -from cpython.type cimport type +from cpython.object cimport PyObject, PyTypeObject, PyObject_TypeCheck cimport libc.stdio as stdio + +cdef extern from *: + # Leave a marker that the NumPy declarations came from Cython and not from NumPy itself. + # See https://github.com/cython/cython/issues/3573 + """ + /* Using NumPy API declarations from "Cython/Includes/numpy/" */ + """ + + cdef extern from "Python.h": - ctypedef int Py_intptr_t + ctypedef Py_ssize_t Py_intptr_t cdef extern from "numpy/arrayobject.h": ctypedef Py_intptr_t npy_intp @@ -219,7 +220,7 @@ cdef extern from "numpy/arrayobject.h": cdef int type_num cdef int itemsize "elsize" cdef int alignment - cdef dict fields + cdef object fields cdef tuple names # Use PyDataType_HASSUBARRAY to test whether this field is # valid (the pointer can be NULL). Most users should access @@ -242,104 +243,56 @@ cdef extern from "numpy/arrayobject.h": ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]: cdef __cythonbufferdefaults__ = {"mode": "strided"} - cdef: - # Only taking a few of the most commonly used and stable fields. - # One should use PyArray_* macros instead to access the C fields. - char *data - int ndim "nd" - npy_intp *shape "dimensions" - npy_intp *strides - dtype descr # deprecated since NumPy 1.7 ! - PyObject* base - - # Note: This syntax (function definition in pxd files) is an - # experimental exception made for __getbuffer__ and __releasebuffer__ - # -- the details of this may change. - def __getbuffer__(ndarray self, Py_buffer* info, int flags): - # This implementation of getbuffer is geared towards Cython - # requirements, and does not yet fulfill the PEP. - # In particular strided access is always provided regardless - # of flags - - cdef int i, ndim - cdef int endian_detector = 1 - cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) - - ndim = PyArray_NDIM(self) - - if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): - raise ValueError(u"ndarray is not C contiguous") - - if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): - raise ValueError(u"ndarray is not Fortran contiguous") - - info.buf = PyArray_DATA(self) - info.ndim = ndim - if sizeof(npy_intp) != sizeof(Py_ssize_t): - # Allocate new buffer for strides and shape info. - # This is allocated as one block, strides first. - info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim) - info.shape = info.strides + ndim - for i in range(ndim): - info.strides[i] = PyArray_STRIDES(self)[i] - info.shape[i] = PyArray_DIMS(self)[i] - else: - info.strides = <Py_ssize_t*>PyArray_STRIDES(self) - info.shape = <Py_ssize_t*>PyArray_DIMS(self) - info.suboffsets = NULL - info.itemsize = PyArray_ITEMSIZE(self) - info.readonly = not PyArray_ISWRITEABLE(self) - - cdef int t - cdef char* f = NULL - cdef dtype descr = <dtype>PyArray_DESCR(self) - cdef int offset - - info.obj = self - - if not PyDataType_HASFIELDS(descr): - t = descr.type_num - if ((descr.byteorder == c'>' and little_endian) or - (descr.byteorder == c'<' and not little_endian)): - raise ValueError(u"Non-native byte order not supported") - if t == NPY_BYTE: f = "b" - elif t == NPY_UBYTE: f = "B" - elif t == NPY_SHORT: f = "h" - elif t == NPY_USHORT: f = "H" - elif t == NPY_INT: f = "i" - elif t == NPY_UINT: f = "I" - elif t == NPY_LONG: f = "l" - elif t == NPY_ULONG: f = "L" - elif t == NPY_LONGLONG: f = "q" - elif t == NPY_ULONGLONG: f = "Q" - elif t == NPY_FLOAT: f = "f" - elif t == NPY_DOUBLE: f = "d" - elif t == NPY_LONGDOUBLE: f = "g" - elif t == NPY_CFLOAT: f = "Zf" - elif t == NPY_CDOUBLE: f = "Zd" - elif t == NPY_CLONGDOUBLE: f = "Zg" - elif t == NPY_OBJECT: f = "O" - else: - raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - info.format = f - return - else: - info.format = <char*>PyObject_Malloc(_buffer_format_string_len) - info.format[0] = c'^' # Native data types, manual alignment - offset = 0 - f = _util_dtypestring(descr, info.format + 1, - info.format + _buffer_format_string_len, - &offset) - f[0] = c'\0' # Terminate format string - - def __releasebuffer__(ndarray self, Py_buffer* info): - if PyArray_HASFIELDS(self): - PyObject_Free(info.format) - if sizeof(npy_intp) != sizeof(Py_ssize_t): - PyObject_Free(info.strides) - # info.shape was stored after info.strides in the same block + # NOTE: no field declarations since direct access is deprecated since NumPy 1.7 + # Instead, we use properties that map to the corresponding C-API functions. + + @property + cdef inline PyObject* base(self) nogil: + """Returns a borrowed reference to the object owning the data/memory. + """ + return PyArray_BASE(self) + + @property + cdef inline dtype descr(self): + """Returns an owned reference to the dtype of the array. + """ + return <dtype>PyArray_DESCR(self) + + @property + cdef inline int ndim(self) nogil: + """Returns the number of dimensions in the array. + """ + return PyArray_NDIM(self) + + @property + cdef inline npy_intp *shape(self) nogil: + """Returns a pointer to the dimensions/shape of the array. + The number of elements matches the number of dimensions of the array (ndim). + Can return NULL for 0-dimensional arrays. + """ + return PyArray_DIMS(self) + + @property + cdef inline npy_intp *strides(self) nogil: + """Returns a pointer to the strides of the array. + The number of elements matches the number of dimensions of the array (ndim). + """ + return PyArray_STRIDES(self) + + @property + cdef inline npy_intp size(self) nogil: + """Returns the total size (in number of elements) of the array. + """ + return PyArray_SIZE(self) + + @property + cdef inline char* data(self) nogil: + """The pointer to the data buffer as a char*. + This is provided for legacy reasons to avoid direct struct field access. + For new code that needs this access, you probably want to cast the result + of `PyArray_DATA()` instead, which returns a 'void*'. + """ + return PyArray_BYTES(self) ctypedef unsigned char npy_bool @@ -416,103 +369,110 @@ cdef extern from "numpy/arrayobject.h": int len int _import_array() except -1 + # A second definition so _import_array isn't marked as used when we use it here. + # Do not use - subject to change any time. + int __pyx_import_array "_import_array"() except -1 # # Macros from ndarrayobject.h # - bint PyArray_CHKFLAGS(ndarray m, int flags) - bint PyArray_IS_C_CONTIGUOUS(ndarray arr) - bint PyArray_IS_F_CONTIGUOUS(ndarray arr) - bint PyArray_ISCONTIGUOUS(ndarray m) - bint PyArray_ISWRITEABLE(ndarray m) - bint PyArray_ISALIGNED(ndarray m) - - int PyArray_NDIM(ndarray) - bint PyArray_ISONESEGMENT(ndarray) - bint PyArray_ISFORTRAN(ndarray) - int PyArray_FORTRANIF(ndarray) - - void* PyArray_DATA(ndarray) - char* PyArray_BYTES(ndarray) - npy_intp* PyArray_DIMS(ndarray) - npy_intp* PyArray_STRIDES(ndarray) - npy_intp PyArray_DIM(ndarray, size_t) - npy_intp PyArray_STRIDE(ndarray, size_t) - - PyObject *PyArray_BASE(ndarray) # returns borrowed reference! - PyArray_Descr *PyArray_DESCR(ndarray) # returns borrowed reference to dtype! - int PyArray_FLAGS(ndarray) - npy_intp PyArray_ITEMSIZE(ndarray) - int PyArray_TYPE(ndarray arr) + bint PyArray_CHKFLAGS(ndarray m, int flags) nogil + bint PyArray_IS_C_CONTIGUOUS(ndarray arr) nogil + bint PyArray_IS_F_CONTIGUOUS(ndarray arr) nogil + bint PyArray_ISCONTIGUOUS(ndarray m) nogil + bint PyArray_ISWRITEABLE(ndarray m) nogil + bint PyArray_ISALIGNED(ndarray m) nogil + + int PyArray_NDIM(ndarray) nogil + bint PyArray_ISONESEGMENT(ndarray) nogil + bint PyArray_ISFORTRAN(ndarray) nogil + int PyArray_FORTRANIF(ndarray) nogil + + void* PyArray_DATA(ndarray) nogil + char* PyArray_BYTES(ndarray) nogil + + npy_intp* PyArray_DIMS(ndarray) nogil + npy_intp* PyArray_STRIDES(ndarray) nogil + npy_intp PyArray_DIM(ndarray, size_t) nogil + npy_intp PyArray_STRIDE(ndarray, size_t) nogil + + PyObject *PyArray_BASE(ndarray) nogil # returns borrowed reference! + PyArray_Descr *PyArray_DESCR(ndarray) nogil # returns borrowed reference to dtype! + PyArray_Descr *PyArray_DTYPE(ndarray) nogil # returns borrowed reference to dtype! NP 1.7+ alias for descr. + int PyArray_FLAGS(ndarray) nogil + void PyArray_CLEARFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7 + void PyArray_ENABLEFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7 + npy_intp PyArray_ITEMSIZE(ndarray) nogil + int PyArray_TYPE(ndarray arr) nogil object PyArray_GETITEM(ndarray arr, void *itemptr) int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) - bint PyTypeNum_ISBOOL(int) - bint PyTypeNum_ISUNSIGNED(int) - bint PyTypeNum_ISSIGNED(int) - bint PyTypeNum_ISINTEGER(int) - bint PyTypeNum_ISFLOAT(int) - bint PyTypeNum_ISNUMBER(int) - bint PyTypeNum_ISSTRING(int) - bint PyTypeNum_ISCOMPLEX(int) - bint PyTypeNum_ISPYTHON(int) - bint PyTypeNum_ISFLEXIBLE(int) - bint PyTypeNum_ISUSERDEF(int) - bint PyTypeNum_ISEXTENDED(int) - bint PyTypeNum_ISOBJECT(int) - - bint PyDataType_ISBOOL(dtype) - bint PyDataType_ISUNSIGNED(dtype) - bint PyDataType_ISSIGNED(dtype) - bint PyDataType_ISINTEGER(dtype) - bint PyDataType_ISFLOAT(dtype) - bint PyDataType_ISNUMBER(dtype) - bint PyDataType_ISSTRING(dtype) - bint PyDataType_ISCOMPLEX(dtype) - bint PyDataType_ISPYTHON(dtype) - bint PyDataType_ISFLEXIBLE(dtype) - bint PyDataType_ISUSERDEF(dtype) - bint PyDataType_ISEXTENDED(dtype) - bint PyDataType_ISOBJECT(dtype) - bint PyDataType_HASFIELDS(dtype) - bint PyDataType_HASSUBARRAY(dtype) - - bint PyArray_ISBOOL(ndarray) - bint PyArray_ISUNSIGNED(ndarray) - bint PyArray_ISSIGNED(ndarray) - bint PyArray_ISINTEGER(ndarray) - bint PyArray_ISFLOAT(ndarray) - bint PyArray_ISNUMBER(ndarray) - bint PyArray_ISSTRING(ndarray) - bint PyArray_ISCOMPLEX(ndarray) - bint PyArray_ISPYTHON(ndarray) - bint PyArray_ISFLEXIBLE(ndarray) - bint PyArray_ISUSERDEF(ndarray) - bint PyArray_ISEXTENDED(ndarray) - bint PyArray_ISOBJECT(ndarray) - bint PyArray_HASFIELDS(ndarray) - - bint PyArray_ISVARIABLE(ndarray) - - bint PyArray_SAFEALIGNEDCOPY(ndarray) - bint PyArray_ISNBO(char) # works on ndarray.byteorder - bint PyArray_IsNativeByteOrder(char) # works on ndarray.byteorder - bint PyArray_ISNOTSWAPPED(ndarray) - bint PyArray_ISBYTESWAPPED(ndarray) - - bint PyArray_FLAGSWAP(ndarray, int) - - bint PyArray_ISCARRAY(ndarray) - bint PyArray_ISCARRAY_RO(ndarray) - bint PyArray_ISFARRAY(ndarray) - bint PyArray_ISFARRAY_RO(ndarray) - bint PyArray_ISBEHAVED(ndarray) - bint PyArray_ISBEHAVED_RO(ndarray) - - - bint PyDataType_ISNOTSWAPPED(dtype) - bint PyDataType_ISBYTESWAPPED(dtype) + bint PyTypeNum_ISBOOL(int) nogil + bint PyTypeNum_ISUNSIGNED(int) nogil + bint PyTypeNum_ISSIGNED(int) nogil + bint PyTypeNum_ISINTEGER(int) nogil + bint PyTypeNum_ISFLOAT(int) nogil + bint PyTypeNum_ISNUMBER(int) nogil + bint PyTypeNum_ISSTRING(int) nogil + bint PyTypeNum_ISCOMPLEX(int) nogil + bint PyTypeNum_ISPYTHON(int) nogil + bint PyTypeNum_ISFLEXIBLE(int) nogil + bint PyTypeNum_ISUSERDEF(int) nogil + bint PyTypeNum_ISEXTENDED(int) nogil + bint PyTypeNum_ISOBJECT(int) nogil + + bint PyDataType_ISBOOL(dtype) nogil + bint PyDataType_ISUNSIGNED(dtype) nogil + bint PyDataType_ISSIGNED(dtype) nogil + bint PyDataType_ISINTEGER(dtype) nogil + bint PyDataType_ISFLOAT(dtype) nogil + bint PyDataType_ISNUMBER(dtype) nogil + bint PyDataType_ISSTRING(dtype) nogil + bint PyDataType_ISCOMPLEX(dtype) nogil + bint PyDataType_ISPYTHON(dtype) nogil + bint PyDataType_ISFLEXIBLE(dtype) nogil + bint PyDataType_ISUSERDEF(dtype) nogil + bint PyDataType_ISEXTENDED(dtype) nogil + bint PyDataType_ISOBJECT(dtype) nogil + bint PyDataType_HASFIELDS(dtype) nogil + bint PyDataType_HASSUBARRAY(dtype) nogil + + bint PyArray_ISBOOL(ndarray) nogil + bint PyArray_ISUNSIGNED(ndarray) nogil + bint PyArray_ISSIGNED(ndarray) nogil + bint PyArray_ISINTEGER(ndarray) nogil + bint PyArray_ISFLOAT(ndarray) nogil + bint PyArray_ISNUMBER(ndarray) nogil + bint PyArray_ISSTRING(ndarray) nogil + bint PyArray_ISCOMPLEX(ndarray) nogil + bint PyArray_ISPYTHON(ndarray) nogil + bint PyArray_ISFLEXIBLE(ndarray) nogil + bint PyArray_ISUSERDEF(ndarray) nogil + bint PyArray_ISEXTENDED(ndarray) nogil + bint PyArray_ISOBJECT(ndarray) nogil + bint PyArray_HASFIELDS(ndarray) nogil + + bint PyArray_ISVARIABLE(ndarray) nogil + + bint PyArray_SAFEALIGNEDCOPY(ndarray) nogil + bint PyArray_ISNBO(char) nogil # works on ndarray.byteorder + bint PyArray_IsNativeByteOrder(char) nogil # works on ndarray.byteorder + bint PyArray_ISNOTSWAPPED(ndarray) nogil + bint PyArray_ISBYTESWAPPED(ndarray) nogil + + bint PyArray_FLAGSWAP(ndarray, int) nogil + + bint PyArray_ISCARRAY(ndarray) nogil + bint PyArray_ISCARRAY_RO(ndarray) nogil + bint PyArray_ISFARRAY(ndarray) nogil + bint PyArray_ISFARRAY_RO(ndarray) nogil + bint PyArray_ISBEHAVED(ndarray) nogil + bint PyArray_ISBEHAVED_RO(ndarray) nogil + + + bint PyDataType_ISNOTSWAPPED(dtype) nogil + bint PyDataType_ISBYTESWAPPED(dtype) nogil bint PyArray_DescrCheck(object) @@ -532,10 +492,11 @@ cdef extern from "numpy/arrayobject.h": bint PyArray_IsPythonScalar(object) bint PyArray_IsAnyScalar(object) bint PyArray_CheckAnyScalar(object) + ndarray PyArray_GETCONTIGUOUS(ndarray) - bint PyArray_SAMESHAPE(ndarray, ndarray) - npy_intp PyArray_SIZE(ndarray) - npy_intp PyArray_NBYTES(ndarray) + bint PyArray_SAMESHAPE(ndarray, ndarray) nogil + npy_intp PyArray_SIZE(ndarray) nogil + npy_intp PyArray_NBYTES(ndarray) nogil object PyArray_FROM_O(object) object PyArray_FROM_OF(object m, int flags) @@ -548,16 +509,16 @@ cdef extern from "numpy/arrayobject.h": npy_intp PyArray_REFCOUNT(object) object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth) unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2) - bint PyArray_EquivByteorders(int b1, int b2) + bint PyArray_EquivByteorders(int b1, int b2) nogil object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum) object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data) #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr) object PyArray_ToScalar(void* data, ndarray arr) - void* PyArray_GETPTR1(ndarray m, npy_intp i) - void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) - void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) - void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) + void* PyArray_GETPTR1(ndarray m, npy_intp i) nogil + void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) nogil + void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) nogil + void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) nogil void PyArray_XDECREF_ERR(ndarray) # Cannot be supported due to out arg @@ -685,7 +646,7 @@ cdef extern from "numpy/arrayobject.h": object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE) int PyArray_Sort (ndarray, int, NPY_SORTKIND) object PyArray_ArgSort (ndarray, int, NPY_SORTKIND) - object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject*) + object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject *) object PyArray_ArgMax (ndarray, int, ndarray) object PyArray_ArgMin (ndarray, int, ndarray) object PyArray_Reshape (ndarray, object) @@ -797,11 +758,9 @@ ctypedef double complex complex128_t # The int types are mapped a bit surprising -- # numpy.int corresponds to 'l' and numpy.long to 'q' ctypedef npy_long int_t -ctypedef npy_longlong long_t ctypedef npy_longlong longlong_t ctypedef npy_ulong uint_t -ctypedef npy_ulonglong ulong_t ctypedef npy_ulonglong ulonglong_t ctypedef npy_intp intp_t @@ -838,72 +797,67 @@ cdef inline tuple PyDataType_SHAPE(dtype d): else: return () -cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: - # Recursive utility function used in __getbuffer__ to get format - # string. The new location in the format string is returned. - - cdef dtype child - cdef int endian_detector = 1 - cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) - cdef tuple fields - - for childname in descr.names: - fields = descr.fields[childname] - child, new_offset = fields - - if (end - f) - <int>(new_offset - offset[0]) < 15: - raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - - if ((child.byteorder == c'>' and little_endian) or - (child.byteorder == c'<' and not little_endian)): - raise ValueError(u"Non-native byte order not supported") - # One could encode it in the format string and have Cython - # complain instead, BUT: < and > in format strings also imply - # standardized sizes for datatypes, and we rely on native in - # order to avoid reencoding data types based on their size. - # - # A proper PEP 3118 exporter for other clients than Cython - # must deal properly with this! - - # Output padding bytes - while offset[0] < new_offset: - f[0] = 120 # "x"; pad byte - f += 1 - offset[0] += 1 - - offset[0] += child.itemsize - - if not PyDataType_HASFIELDS(child): - t = child.type_num - if end - f < 5: - raise RuntimeError(u"Format string allocated too short.") - - # Until ticket #99 is fixed, use integers to avoid warnings - if t == NPY_BYTE: f[0] = 98 #"b" - elif t == NPY_UBYTE: f[0] = 66 #"B" - elif t == NPY_SHORT: f[0] = 104 #"h" - elif t == NPY_USHORT: f[0] = 72 #"H" - elif t == NPY_INT: f[0] = 105 #"i" - elif t == NPY_UINT: f[0] = 73 #"I" - elif t == NPY_LONG: f[0] = 108 #"l" - elif t == NPY_ULONG: f[0] = 76 #"L" - elif t == NPY_LONGLONG: f[0] = 113 #"q" - elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - elif t == NPY_FLOAT: f[0] = 102 #"f" - elif t == NPY_DOUBLE: f[0] = 100 #"d" - elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - elif t == NPY_OBJECT: f[0] = 79 #"O" - else: - raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - f += 1 - else: - # Cython ignores struct boundary information ("T{...}"), - # so don't output it - f = _util_dtypestring(child, f, end, offset) - return f + +cdef extern from "numpy/ndarrayobject.h": + PyTypeObject PyTimedeltaArrType_Type + PyTypeObject PyDatetimeArrType_Type + ctypedef int64_t npy_timedelta + ctypedef int64_t npy_datetime + +cdef extern from "numpy/ndarraytypes.h": + ctypedef struct PyArray_DatetimeMetaData: + NPY_DATETIMEUNIT base + int64_t num + +cdef extern from "numpy/arrayscalars.h": + + # abstract types + ctypedef class numpy.generic [object PyObject]: + pass + ctypedef class numpy.number [object PyObject]: + pass + ctypedef class numpy.integer [object PyObject]: + pass + ctypedef class numpy.signedinteger [object PyObject]: + pass + ctypedef class numpy.unsignedinteger [object PyObject]: + pass + ctypedef class numpy.inexact [object PyObject]: + pass + ctypedef class numpy.floating [object PyObject]: + pass + ctypedef class numpy.complexfloating [object PyObject]: + pass + ctypedef class numpy.flexible [object PyObject]: + pass + ctypedef class numpy.character [object PyObject]: + pass + + ctypedef struct PyDatetimeScalarObject: + # PyObject_HEAD + npy_datetime obval + PyArray_DatetimeMetaData obmeta + + ctypedef struct PyTimedeltaScalarObject: + # PyObject_HEAD + npy_timedelta obval + PyArray_DatetimeMetaData obmeta + + ctypedef enum NPY_DATETIMEUNIT: + NPY_FR_Y + NPY_FR_M + NPY_FR_W + NPY_FR_D + NPY_FR_B + NPY_FR_h + NPY_FR_m + NPY_FR_s + NPY_FR_ms + NPY_FR_us + NPY_FR_ns + NPY_FR_ps + NPY_FR_fs + NPY_FR_as # @@ -1032,7 +986,7 @@ cdef inline object get_array_base(ndarray arr): # Cython code. cdef inline int import_array() except -1: try: - _import_array() + __pyx_import_array() except Exception: raise ImportError("numpy.core.multiarray failed to import") @@ -1047,3 +1001,57 @@ cdef inline int import_ufunc() except -1: _import_umath() except Exception: raise ImportError("numpy.core.umath failed to import") + + +cdef inline bint is_timedelta64_object(object obj): + """ + Cython equivalent of `isinstance(obj, np.timedelta64)` + + Parameters + ---------- + obj : object + + Returns + ------- + bool + """ + return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) + + +cdef inline bint is_datetime64_object(object obj): + """ + Cython equivalent of `isinstance(obj, np.datetime64)` + + Parameters + ---------- + obj : object + + Returns + ------- + bool + """ + return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) + + +cdef inline npy_datetime get_datetime64_value(object obj) nogil: + """ + returns the int64 value underlying scalar numpy datetime64 object + + Note that to interpret this as a datetime, the corresponding unit is + also needed. That can be found using `get_datetime64_unit`. + """ + return (<PyDatetimeScalarObject*>obj).obval + + +cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: + """ + returns the int64 value underlying scalar numpy timedelta64 object + """ + return (<PyTimedeltaScalarObject*>obj).obval + + +cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: + """ + returns the unit part of the dtype for a numpy datetime64 object. + """ + return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base diff --git a/contrib/tools/cython/Cython/Includes/openmp.pxd b/contrib/tools/cython/Cython/Includes/openmp.pxd index 30873a588bb..40f2f17a3c8 100644 --- a/contrib/tools/cython/Cython/Includes/openmp.pxd +++ b/contrib/tools/cython/Cython/Includes/openmp.pxd @@ -48,4 +48,3 @@ cdef extern from "<omp.h>": int omp_get_ancestor_thread_num(int) nogil int omp_get_team_size(int) nogil int omp_get_active_level() nogil - diff --git a/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd index cff5bea15a9..bf61997f341 100644 --- a/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd @@ -1,5 +1,5 @@ # POSIX dynamic linking/loading interface. -# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html cdef extern from "<dlfcn.h>" nogil: void *dlopen(const char *, int) diff --git a/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd index 9afc33a3688..f7bec9e3753 100644 --- a/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd @@ -1,8 +1,11 @@ -# http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html + +from posix.types cimport mode_t, off_t, pid_t cdef extern from "<fcntl.h>" nogil: enum: F_DUPFD + enum: F_DUPFD_CLOEXEC enum: F_GETFD enum: F_SETFD enum: F_GETFL @@ -23,11 +26,14 @@ cdef extern from "<fcntl.h>" nogil: enum: SEEK_CUR enum: SEEK_END + enum: O_CLOEXEC enum: O_CREAT enum: O_DIRECT + enum: O_DIRECTORY enum: O_EXCL enum: O_NOCTTY enum: O_TRUNC + enum: O_TTY_INIT enum: O_APPEND enum: O_DSYNC @@ -37,9 +43,17 @@ cdef extern from "<fcntl.h>" nogil: enum: O_ACCMODE # O_RDONLY|O_WRONLY|O_RDWR + enum: O_EXEC enum: O_RDONLY enum: O_WRONLY enum: O_RDWR + enum: O_SEARCH + + enum: AT_FDCWD + enum: AT_EACCESS + enum: AT_SYMLINK_NOFOLLOW + enum: AT_SYMLINK_FOLLOW + enum: AT_REMOVEDIR enum: S_IFMT enum: S_IFBLK @@ -50,9 +64,12 @@ cdef extern from "<fcntl.h>" nogil: enum: S_IFLNK enum: S_IFSOCK - ctypedef int mode_t - ctypedef signed pid_t - ctypedef signed off_t + enum: POSIX_FADV_DONTNEED + enum: POSIX_FADV_NOREUSE + enum: POSIX_FADV_NORMAL + enum: POSIX_FADV_RANDOM + enum: POSIX_FADV_SEQUENTIAL + enum: POSIX_FADV_WILLNEED struct flock: short l_type @@ -61,8 +78,9 @@ cdef extern from "<fcntl.h>" nogil: off_t l_len pid_t l_pid - int creat(char *, mode_t) + int creat(const char *, mode_t) int fcntl(int, int, ...) - int open(char *, int, ...) - #int open (char *, int, mode_t) - + int open(const char *, int, ...) + int openat(int, const char *, int, ...) + int posix_fadvise(int, off_t, off_t, int) + int posix_fallocate(int, off_t, off_t) diff --git a/contrib/tools/cython/Cython/Includes/posix/mman.pxd b/contrib/tools/cython/Cython/Includes/posix/mman.pxd index c810f431b3d..9f26f7615f7 100644 --- a/contrib/tools/cython/Cython/Includes/posix/mman.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/mman.pxd @@ -1,4 +1,6 @@ -# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/mman.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_mman.h.html +# https://man7.org/linux/man-pages/man2/mmap.2.html +# https://www.freebsd.org/cgi/man.cgi?query=mmap&sektion=2 from posix.types cimport off_t, mode_t diff --git a/contrib/tools/cython/Cython/Includes/posix/resource.pxd b/contrib/tools/cython/Cython/Includes/posix/resource.pxd index 9f55c6ab4ee..b9628c66bdf 100644 --- a/contrib/tools/cython/Cython/Includes/posix/resource.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/resource.pxd @@ -1,4 +1,5 @@ -# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html +# https://man7.org/linux/man-pages/man2/getrusage.2.html from posix.time cimport timeval from posix.types cimport id_t @@ -33,6 +34,7 @@ cdef extern from "<sys/resource.h>" nogil: cdef struct rusage: timeval ru_utime timeval ru_stime + # Linux-specific long ru_maxrss long ru_ixrss long ru_idrss diff --git a/contrib/tools/cython/Cython/Includes/posix/select.pxd b/contrib/tools/cython/Cython/Includes/posix/select.pxd index 46703df1043..803c492d40f 100644 --- a/contrib/tools/cython/Cython/Includes/posix/select.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/select.pxd @@ -1,3 +1,5 @@ +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html + from .types cimport sigset_t from .time cimport timeval, timespec @@ -12,7 +14,7 @@ cdef extern from "<sys/select.h>" nogil: void FD_ZERO(fd_set*) int select(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, const timeval *timeout) + fd_set *exceptfds, timeval *timeout) int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const timespec *timeout, diff --git a/contrib/tools/cython/Cython/Includes/posix/stat.pxd b/contrib/tools/cython/Cython/Includes/posix/stat.pxd index 69c2eca1667..9247423f84e 100644 --- a/contrib/tools/cython/Cython/Includes/posix/stat.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/stat.pxd @@ -1,5 +1,9 @@ +# https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html + from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t, nlink_t, off_t, time_t, uid_t) +from posix.time cimport timespec cdef extern from "<sys/stat.h>" nogil: @@ -14,9 +18,14 @@ cdef extern from "<sys/stat.h>" nogil: off_t st_size blksize_t st_blksize blkcnt_t st_blocks + # POSIX.1-2001 time_t st_atime time_t st_mtime time_t st_ctime + # POSIX.1-2008 + timespec st_atim + timespec st_mtim + timespec st_ctim # st_birthtime exists on *BSD and OS X. # Under Linux, defining it here does not hurt. Compilation under Linux @@ -25,12 +34,24 @@ cdef extern from "<sys/stat.h>" nogil: # POSIX prescribes including both <sys/stat.h> and <unistd.h> for these cdef extern from "<unistd.h>" nogil: - int fchmod(int, mode_t) int chmod(const char *, mode_t) + int fchmod(int, mode_t) + int fchmodat(int, const char *, mode_t, int flags) - int fstat(int, struct_stat *) - int lstat(const char *, struct_stat *) int stat(const char *, struct_stat *) + int lstat(const char *, struct_stat *) + int fstat(int, struct_stat *) + int fstatat(int, const char *, struct_stat *, int flags) + + int mkdir(const char *, mode_t) + int mkdirat(int, const char *, mode_t) + int mkfifo(const char *, mode_t) + int mkfifoat(int, const char *, mode_t) + int mknod(const char *, mode_t, dev_t) + int mknodat(int, const char *, mode_t, dev_t) + + int futimens(int, const timespec *) + int utimensat(int, const char *, const timespec *, int flags) # Macros for st_mode mode_t S_ISREG(mode_t) @@ -69,3 +90,9 @@ cdef extern from "<unistd.h>" nogil: mode_t S_IROTH mode_t S_IWOTH mode_t S_IXOTH + + # test file types + bint S_TYPEISMQ(struct_stat *buf) + bint S_TYPEISSEM(struct_stat *buf) + bint S_TYPEISSHM(struct_stat *buf) + bint S_TYPEISTMO(struct_stat *buf) diff --git a/contrib/tools/cython/Cython/Includes/posix/stdio.pxd b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd index 53913fdf457..38b81555932 100644 --- a/contrib/tools/cython/Cython/Includes/posix/stdio.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd @@ -1,5 +1,5 @@ # POSIX additions to <stdio.h>. -# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html from libc.stdio cimport FILE from libc.stddef cimport wchar_t diff --git a/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd index 513de938a88..188e2e50103 100644 --- a/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd @@ -1,5 +1,5 @@ # POSIX additions to <stdlib.h> -# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html cdef extern from "<stdlib.h>" nogil: void _Exit(int) diff --git a/contrib/tools/cython/Cython/Includes/posix/time.pxd b/contrib/tools/cython/Cython/Includes/posix/time.pxd index 6bc81bfea01..a90cab577a2 100644 --- a/contrib/tools/cython/Cython/Includes/posix/time.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/time.pxd @@ -1,4 +1,4 @@ -# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html +# https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html from posix.types cimport suseconds_t, time_t, clockid_t, timer_t from posix.signal cimport sigevent diff --git a/contrib/tools/cython/Cython/Includes/posix/uio.pxd b/contrib/tools/cython/Cython/Includes/posix/uio.pxd new file mode 100644 index 00000000000..d9971bd4a06 --- /dev/null +++ b/contrib/tools/cython/Cython/Includes/posix/uio.pxd @@ -0,0 +1,26 @@ +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_uio.h.html + +from posix.types cimport off_t + + +cdef extern from "<sys/uio.h>" nogil: + + cdef struct iovec: + void *iov_base + size_t iov_len + + ssize_t readv (int fd, const iovec *iov, int iovcnt) + ssize_t writev(int fd, const iovec *iov, int iovcnt) + + # Linux-specific, https://man7.org/linux/man-pages/man2/readv.2.html + ssize_t preadv (int fd, const iovec *iov, int iovcnt, off_t offset) + ssize_t pwritev(int fd, const iovec *iov, int iovcnt, off_t offset) + + enum: RWF_DSYNC + enum: RWF_HIPRI + enum: RWF_SYNC + enum: RWF_NOWAIT + enum: RWF_APPEND + + ssize_t preadv2 (int fd, const iovec *iov, int iovcnt, off_t offset, int flags) + ssize_t pwritev2(int fd, const iovec *iov, int iovcnt, off_t offset, int flags) diff --git a/contrib/tools/cython/Cython/Includes/posix/wait.pxd b/contrib/tools/cython/Cython/Includes/posix/wait.pxd index d18cff9cf84..f30be06df2c 100644 --- a/contrib/tools/cython/Cython/Includes/posix/wait.pxd +++ b/contrib/tools/cython/Cython/Includes/posix/wait.pxd @@ -1,4 +1,4 @@ -# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/wait.h.html +# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html from posix.types cimport pid_t, id_t from posix.signal cimport siginfo_t |
