aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Includes
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-03-15 19:59:12 +0300
committeralexv-smirnov <alex@ydb.tech>2023-03-15 19:59:12 +0300
commit056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch)
tree4740980126f32e3af7937ba0ca5f83e59baa4ab0 /contrib/tools/cython/Cython/Includes
parent269126dcced1cc8b53eb4398b4a33e5142f10290 (diff)
downloadydb-056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11.tar.gz
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'contrib/tools/cython/Cython/Includes')
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd2
-rw-r--r--contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd91
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/__init__.pxd184
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/array.pxd163
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/bool.pxd38
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/buffer.pxd112
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd33
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/bytes.pxd198
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd35
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/ceval.pxd8
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/cobject.pxd36
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/codecs.pxd121
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/complex.pxd50
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/conversion.pxd36
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/datetime.pxd212
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/dict.pxd165
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/exc.pxd257
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/float.pxd39
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/function.pxd65
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/genobject.pxd25
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/getargs.pxd12
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/instance.pxd25
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/int.pxd89
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/iterator.pxd36
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd24
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/list.pxd92
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/long.pxd149
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd19
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/mapping.pxd64
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/mem.pxd111
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd50
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/method.pxd49
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/module.pxd188
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/number.pxd265
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/object.pxd399
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd63
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd144
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd68
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/pystate.pxd92
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/pythread.pxd53
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/ref.pxd51
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/sequence.pxd136
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/set.pxd119
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/slice.pxd70
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/string.pxd198
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/tuple.pxd71
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/type.pxd48
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/unicode.pxd572
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/version.pxd32
-rw-r--r--contrib/tools/cython/Cython/Includes/cpython/weakref.pxd42
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/__init__.pxd1
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/errno.pxd128
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/float.pxd43
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/limits.pxd28
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/locale.pxd46
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/math.pxd112
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/setjmp.pxd10
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/signal.pxd64
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/stddef.pxd9
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/stdint.pxd105
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/stdio.pxd80
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/stdlib.pxd72
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/string.pxd50
-rw-r--r--contrib/tools/cython/Cython/Includes/libc/time.pxd46
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd4
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd43
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/cast.pxd12
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/complex.pxd101
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/deque.pxd86
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd62
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/functional.pxd13
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd32
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/limits.pxd61
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/list.pxd78
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/map.pxd68
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/memory.pxd115
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/pair.pxd1
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/queue.pxd25
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/set.pxd61
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/stack.pxd11
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/string.pxd227
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd15
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd10
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd74
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd69
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/utility.pxd30
-rw-r--r--contrib/tools/cython/Cython/Includes/libcpp/vector.pxd88
-rw-r--r--contrib/tools/cython/Cython/Includes/numpy.pxd1050
-rw-r--r--contrib/tools/cython/Cython/Includes/numpy/__init__.pxd1049
-rw-r--r--contrib/tools/cython/Cython/Includes/numpy/math.pxd133
-rw-r--r--contrib/tools/cython/Cython/Includes/openmp.pxd51
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/__init__.pxd1
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd14
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/fcntl.pxd68
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/ioctl.pxd4
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/mman.pxd99
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/resource.pxd55
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/select.pxd19
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/signal.pxd73
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/stat.pxd71
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/stdio.pxd37
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/stdlib.pxd29
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/strings.pxd9
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/time.pxd71
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/types.pxd30
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/unistd.pxd271
-rw-r--r--contrib/tools/cython/Cython/Includes/posix/wait.pxd38
141 files changed, 10521 insertions, 0 deletions
diff --git a/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd b/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd
new file mode 100644
index 0000000000..56236e925c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..9a6d253f45
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_bool.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..2baeaae00c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_buffer.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..87af662de0
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_bytes.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..ed32c6b878
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_cobject.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..0a780b3b2d
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_complex.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..05b5f4796a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_dict.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..6eb236bccb
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_exc.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..7e133ef9bb
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_float.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..1461c4e635
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_function.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..3852d6a6a1
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_getargs.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..99cb5a9091
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_instance.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..c1fd5178d6
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_int.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..e09aad2790
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_iterator.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..64febcf969
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_list.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..1a24380c4c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_long.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..cd01bee015
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_mapping.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..d74429ea36
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_mem.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..e7da5154e4
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_method.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..6310c0247d
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_module.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..ae67da1c38
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_number.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..3981bfa44e
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_object.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..e03e66a2e2
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_oldbuffer.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..fe9cf8f8d9
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_pycapsule.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..9447418198
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_ref.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..fdef5b63eb
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_sequence.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..a2feb93712
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_set.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..24c818338e
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_string.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..190713b020
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_tuple.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..3ac47d1b3f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_type.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..2b488b2dc8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_unicode.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..c27ca4df95
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_version.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..1f84f1a179
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/python_weakref.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..41a4aebf1d
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/stdio.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..499511cde9
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/stdlib.pxd
@@ -0,0 +1,2 @@
+# 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
new file mode 100644
index 0000000000..22248d2655
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/Deprecated/stl.pxd
@@ -0,0 +1,91 @@
+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
new file mode 100644
index 0000000000..c81f4e6655
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/__init__.pxd
@@ -0,0 +1,184 @@
+#####################################################################
+#
+# These are the Cython pxd files for (most of) the Python/C API.
+#
+# REFERENCE COUNTING:
+#
+# JUST TO SCARE YOU:
+# If you are going to use any of the Python/C API in your Cython
+# program, you might be responsible for doing reference counting.
+# Read http://docs.python.org/api/refcounts.html which is so
+# important I've copied it below.
+#
+# For all the declaration below, whenever the Py_ function returns
+# a *new reference* to a PyObject*, the return type is "object".
+# When the function returns a borrowed reference, the return
+# type is PyObject*. When Cython sees "object" as a return type
+# it doesn't increment the reference count. When it sees PyObject*
+# in order to use the result you must explicitly cast to <object>,
+# and when you do that Cython increments the reference count whether
+# you want it to or not, forcing you to an explicit DECREF (or leak memory).
+# To avoid this we make the above convention. Note, you can
+# always locally override this convention by putting something like
+#
+# cdef extern from "Python.h":
+# PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
+#
+# in your .pyx file or into a cimported .pxd file. You just have to
+# use the one from the right (pxd-)namespace then.
+#
+# Cython automatically takes care of reference counting for anything
+# of type object.
+#
+## More precisely, I think the correct convention for
+## using the Python/C API from Cython is as follows.
+##
+## (1) Declare all input arguments as type "object". This way no explicit
+## <PyObject*> casting is needed, and moreover Cython doesn't generate
+## any funny reference counting.
+## (2) Declare output as object if a new reference is returned.
+## (3) Declare output as PyObject* if a borrowed reference is returned.
+##
+## This way when you call objects, no cast is needed, and if the api
+## calls returns a new reference (which is about 95% of them), then
+## you can just assign to a variable of type object. With borrowed
+## references if you do an explicit typecast to <object>, Cython generates an
+## INCREF and DECREF so you have to be careful. However, you got a
+## borrowed reference in this case, so there's got to be another reference
+## to your object, so you're OK, as long as you relealize this
+## and use the result of an explicit cast to <object> as a borrowed
+## reference (and you can call Py_INCREF if you want to turn it
+## into another reference for some reason).
+#
+# "The reference count is important because today's computers have
+# a finite (and often severely limited) memory size; it counts how
+# many different places there are that have a reference to an
+# object. Such a place could be another object, or a global (or
+# static) C variable, or a local variable in some C function. When
+# an object's reference count becomes zero, the object is
+# deallocated. If it contains references to other objects, their
+# reference count is decremented. Those other objects may be
+# deallocated in turn, if this decrement makes their reference
+# count become zero, and so on. (There's an obvious problem with
+# objects that reference each other here; for now, the solution is
+# ``don't do that.'')
+#
+# Reference counts are always manipulated explicitly. The normal
+# way is to use the macro Py_INCREF() to increment an object's
+# reference count by one, and Py_DECREF() to decrement it by
+# one. The Py_DECREF() macro is considerably more complex than the
+# incref one, since it must check whether the reference count
+# becomes zero and then cause the object's deallocator to be
+# called. The deallocator is a function pointer contained in the
+# object's type structure. The type-specific deallocator takes
+# care of decrementing the reference counts for other objects
+# contained in the object if this is a compound object type, such
+# as a list, as well as performing any additional finalization
+# that's needed. There's no chance that the reference count can
+# overflow; at least as many bits are used to hold the reference
+# count as there are distinct memory locations in virtual memory
+# (assuming sizeof(long) >= sizeof(char*)). Thus, the reference
+# count increment is a simple operation.
+#
+# It is not necessary to increment an object's reference count for
+# every local variable that contains a pointer to an object. In
+# theory, the object's reference count goes up by one when the
+# variable is made to point to it and it goes down by one when the
+# variable goes out of scope. However, these two cancel each other
+# out, so at the end the reference count hasn't changed. The only
+# real reason to use the reference count is to prevent the object
+# from being deallocated as long as our variable is pointing to
+# it. If we know that there is at least one other reference to the
+# object that lives at least as long as our variable, there is no
+# need to increment the reference count temporarily. An important
+# situation where this arises is in objects that are passed as
+# arguments to C functions in an extension module that are called
+# from Python; the call mechanism guarantees to hold a reference
+# to every argument for the duration of the call.
+#
+# However, a common pitfall is to extract an object from a list
+# and hold on to it for a while without incrementing its reference
+# count. Some other operation might conceivably remove the object
+# from the list, decrementing its reference count and possible
+# deallocating it. The real danger is that innocent-looking
+# operations may invoke arbitrary Python code which could do this;
+# there is a code path which allows control to flow back to the
+# user from a Py_DECREF(), so almost any operation is potentially
+# dangerous.
+#
+# A safe approach is to always use the generic operations
+# (functions whose name begins with "PyObject_", "PyNumber_",
+# "PySequence_" or "PyMapping_"). These operations always
+# increment the reference count of the object they return. This
+# leaves the caller with the responsibility to call Py_DECREF()
+# when they are done with the result; this soon becomes second
+# nature.
+#
+# Now you should read http://docs.python.org/api/refcountDetails.html
+# just to be sure you understand what is going on.
+#
+#################################################################
+
+
+
+#################################################################
+# BIG FAT DEPRECATION WARNING
+#################################################################
+# Do NOT cimport any names directly from the cpython package,
+# despite of the star-imports below. They will be removed at
+# some point.
+# Instead, use the correct sub-module to draw your cimports from.
+#
+# A direct cimport from the package will make your code depend on
+# all of the existing declarations. This may have side-effects
+# and reduces the portability of your code.
+#################################################################
+# START OF DEPRECATED SECTION
+#################################################################
+
+from cpython.version cimport *
+from cpython.ref cimport *
+from cpython.exc cimport *
+from cpython.module cimport *
+from cpython.mem cimport *
+from cpython.tuple cimport *
+from cpython.list cimport *
+from cpython.object cimport *
+from cpython.sequence cimport *
+from cpython.mapping cimport *
+from cpython.iterator cimport *
+from cpython.type cimport *
+from cpython.number cimport *
+from cpython.int cimport *
+from cpython.bool cimport *
+from cpython.long cimport *
+from cpython.float cimport *
+from cpython.complex cimport *
+from cpython.string cimport *
+from cpython.unicode cimport *
+from cpython.dict cimport *
+from cpython.instance cimport *
+from cpython.function cimport *
+from cpython.method cimport *
+from cpython.weakref cimport *
+from cpython.getargs cimport *
+from cpython.pythread cimport *
+from cpython.pystate cimport *
+
+# Python <= 2.x
+from cpython.cobject cimport *
+from cpython.oldbuffer cimport *
+
+# Python >= 2.4
+from cpython.set cimport *
+
+# Python >= 2.6
+from cpython.buffer cimport *
+from cpython.bytes cimport *
+
+# Python >= 3.0
+from cpython.pycapsule 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
new file mode 100644
index 0000000000..19230a0a82
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/array.pxd
@@ -0,0 +1,163 @@
+"""
+ array.pxd
+
+ Cython interface to Python's array.array module.
+
+ * 1D contiguous data view
+ * tools for fast array creation, maximum C-speed and handiness
+ * suitable as allround light weight auto-array within Cython code too
+
+ Usage:
+
+ >>> cimport array
+
+ Usage through Cython buffer interface (Py2.3+):
+
+ >>> def f(arg1, unsigned i, double dx)
+ ... array.array[double] a = arg1
+ ... a[i] += dx
+
+ Fast C-level new_array(_zeros), resize_array, copy_array, Py_SIZE(obj),
+ zero_array
+
+ cdef array.array[double] k = array.copy(d)
+ cdef array.array[double] n = array.array(d, Py_SIZE(d) * 2 )
+ cdef array.array[double] m = array.zeros_like(FLOAT_TEMPLATE)
+ array.resize(f, 200000)
+
+ Zero overhead with naked data pointer views by union:
+ _f, _d, _i, _c, _u, ...
+ => Original C array speed + Python dynamic memory management
+
+ cdef array.array a = inarray
+ if
+ a._d[2] += 0.66 # use as double array without extra casting
+
+ float *subview = vector._f + 10 # starting from 10th element
+ unsigned char *subview_buffer = vector._B + 4
+
+ Suitable as lightweight arrays intra Cython without speed penalty.
+ Replacement for C stack/malloc arrays; no trouble with refcounting,
+ mem.leaks; seamless Python compatibility, buffer() optional
+
+
+ last changes: 2009-05-15 rk
+ : 2009-12-06 bp
+ : 2012-05-02 andreasvc
+ : (see revision control)
+"""
+from libc.string cimport strcat, strncat, \
+ memset, memchr, memcmp, memcpy, memmove
+
+from cpython.object cimport Py_SIZE
+from cpython.ref cimport PyTypeObject, Py_TYPE
+from cpython.exc cimport PyErr_BadArgument
+from cpython.mem cimport PyObject_Malloc, PyObject_Free
+
+cdef extern from *: # Hard-coded utility code hack.
+ ctypedef class array.array [object arrayobject]
+ ctypedef object GETF(array a, Py_ssize_t ix)
+ ctypedef object SETF(array a, Py_ssize_t ix, object o)
+ ctypedef struct arraydescr: # [object arraydescr]:
+ char typecode
+ int itemsize
+ GETF getitem # PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
+ SETF setitem # int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
+
+ ctypedef union __data_union:
+ # views of ob_item:
+ float* as_floats # direct float pointer access to buffer
+ double* as_doubles # double ...
+ int* as_ints
+ unsigned int *as_uints
+ unsigned char *as_uchars
+ signed char *as_schars
+ char *as_chars
+ unsigned long *as_ulongs
+ long *as_longs
+ unsigned long long *as_ulonglongs
+ long long *as_longlongs
+ short *as_shorts
+ unsigned short *as_ushorts
+ Py_UNICODE *as_pyunicodes
+ void *as_voidptr
+
+ ctypedef class array.array [object arrayobject]:
+ cdef __cythonbufferdefaults__ = {'ndim' : 1, 'mode':'c'}
+
+ cdef:
+ Py_ssize_t ob_size
+ arraydescr* ob_descr # struct arraydescr *ob_descr;
+ __data_union data
+
+ def __getbuffer__(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
+ item_count = Py_SIZE(self)
+
+ info.suboffsets = NULL
+ info.buf = self.data.as_chars
+ info.readonly = 0
+ info.ndim = 1
+ info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float)
+ info.len = info.itemsize * item_count
+
+ info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
+ if not info.shape:
+ raise MemoryError()
+ info.shape[0] = item_count # constant regardless of resizing
+ info.strides = &info.itemsize
+
+ info.format = <char*> (info.shape + 1)
+ info.format[0] = self.ob_descr.typecode
+ info.format[1] = 0
+ info.obj = self
+
+ def __releasebuffer__(self, Py_buffer* info):
+ PyObject_Free(info.shape)
+
+ array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr)
+
+ # fast resize/realloc
+ # not suitable for small increments; reallocation 'to the point'
+ int resize(array self, Py_ssize_t n) except -1
+ # efficient for small increments (not in Py2.3-)
+ int resize_smart(array self, Py_ssize_t n) except -1
+
+
+cdef inline array clone(array template, Py_ssize_t length, bint zero):
+ """ fast creation of a new array, given a template array.
+ type will be same as template.
+ if zero is true, new array will be initialized with zeroes."""
+ cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
+ if zero and op is not None:
+ memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
+ return op
+
+cdef inline array copy(array self):
+ """ make a copy of an array. """
+ cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
+ memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
+ return op
+
+cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:
+ """ efficient appending of new stuff of same type
+ (e.g. of same array type)
+ n: number of elements (not number of bytes!) """
+ cdef Py_ssize_t itemsize = self.ob_descr.itemsize
+ cdef Py_ssize_t origsize = Py_SIZE(self)
+ resize_smart(self, origsize + n)
+ memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
+ return 0
+
+cdef inline int extend(array self, array other) except -1:
+ """ extend array with data from another array; types must match. """
+ if self.ob_descr.typecode != other.ob_descr.typecode:
+ PyErr_BadArgument()
+ return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
+
+cdef inline void zero(array self):
+ """ 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
new file mode 100644
index 0000000000..c775088ce6
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/bool.pxd
@@ -0,0 +1,38 @@
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.2.2 Boolean Objects
+ ############################################################################
+
+ ctypedef class __builtin__.bool [object PyBoolObject]:
+ pass
+
+ # Booleans in Python are implemented as a subclass of
+ # integers. There are only two booleans, Py_False and Py_True. As
+ # such, the normal creation and deletion functions don't apply to
+ # booleans. The following macros are available, however.
+
+ bint PyBool_Check(object o)
+ # Return true if o is of type PyBool_Type.
+
+ #PyObject* Py_False
+ # The Python False object. This object has no methods. It needs to
+ # be treated just like any other object with respect to reference
+ # counts.
+
+ #PyObject* Py_True
+ # The Python True object. This object has no methods. It needs to
+ # be treated just like any other object with respect to reference
+ # counts.
+
+ # Py_RETURN_FALSE
+ # Return Py_False from a function, properly incrementing its reference count.
+
+ # Py_RETURN_TRUE
+ # Return Py_True from a function, properly incrementing its reference count.
+
+ 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/buffer.pxd b/contrib/tools/cython/Cython/Includes/cpython/buffer.pxd
new file mode 100644
index 0000000000..3f1ada774a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/buffer.pxd
@@ -0,0 +1,112 @@
+# Please see the Python header files (object.h/abstract.h) for docs
+
+cdef extern from "Python.h":
+
+ cdef enum:
+ PyBUF_MAX_NDIM
+
+ cdef enum:
+ PyBUF_SIMPLE,
+ PyBUF_WRITABLE,
+ PyBUF_WRITEABLE, # backwards compatibility
+ PyBUF_FORMAT,
+ PyBUF_ND,
+ PyBUF_STRIDES,
+ PyBUF_C_CONTIGUOUS,
+ PyBUF_F_CONTIGUOUS,
+ PyBUF_ANY_CONTIGUOUS,
+ PyBUF_INDIRECT,
+ PyBUF_CONTIG,
+ PyBUF_CONTIG_RO,
+ PyBUF_STRIDED,
+ PyBUF_STRIDED_RO,
+ PyBUF_RECORDS,
+ PyBUF_RECORDS_RO,
+ PyBUF_FULL,
+ PyBUF_FULL_RO,
+ PyBUF_READ,
+ PyBUF_WRITE,
+ PyBUF_SHADOW
+
+ bint PyObject_CheckBuffer(object obj)
+ # Return 1 if obj supports the buffer interface otherwise 0.
+
+ int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) except -1
+ # Export obj into a Py_buffer, view. These arguments must never be
+ # NULL. The flags argument is a bit field indicating what kind of
+ # buffer the caller is prepared to deal with and therefore what
+ # kind of buffer the exporter is allowed to return. The buffer
+ # interface allows for complicated memory sharing possibilities,
+ # but some caller may not be able to handle all the complexity but
+ # may want to see if the exporter will let them take a simpler
+ # view to its memory.
+
+ # Some exporters may not be able to share memory in every possible
+ # way and may need to raise errors to signal to some consumers
+ # that something is just not possible. These errors should be a
+ # BufferError unless there is another error that is actually
+ # causing the problem. The exporter can use flags information to
+ # simplify how much of the Py_buffer structure is filled in with
+ # non-default values and/or raise an error if the object can’t
+ # support a simpler view of its memory.
+
+ # 0 is returned on success and -1 on error.
+
+ void PyBuffer_Release(Py_buffer *view)
+ # Release the buffer view. This should be called when the buffer
+ # is no longer being used as it may free memory from it.
+
+ void* PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices)
+ # ??
+
+ Py_ssize_t PyBuffer_SizeFromFormat(char *) # actually const char
+ # Return the implied ~Py_buffer.itemsize from the struct-stype
+ # ~Py_buffer.format
+
+ int PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort)
+ # ??
+
+ int PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
+ # ??
+
+ int PyObject_CopyToObject(object obj, void *buf, Py_ssize_t len, char fortran) except -1
+ # Copy len bytes of data pointed to by the contiguous chunk of
+ # memory pointed to by buf into the buffer exported by obj. The
+ # buffer must of course be writable. Return 0 on success and
+ # return -1 and raise an error on failure. If the object does not
+ # have a writable buffer, then an error is raised. If fortran is
+ # 'F', then if the object is multi-dimensional, then the data will
+ # be copied into the array in Fortran-style (first dimension
+ # varies the fastest). If fortran is 'C', then the data will be
+ # copied into the array in C-style (last dimension varies the
+ # fastest). If fortran is 'A', then it does not matter and the
+ # copy will be made in whatever way is more efficient.
+
+ int PyObject_CopyData(object dest, object src) except -1
+ # Copy the data from the src buffer to the buffer of destination
+
+ bint PyBuffer_IsContiguous(Py_buffer *view, char fort)
+ # Return 1 if the memory defined by the view is C-style (fortran
+ # is 'C') or Fortran-style (fortran is 'F') contiguous or either
+ # one (fortran is 'A'). Return 0 otherwise.
+
+ void PyBuffer_FillContiguousStrides(int ndims,
+ Py_ssize_t *shape,
+ Py_ssize_t *strides,
+ Py_ssize_t itemsize,
+ char fort)
+ # Fill the strides array with byte-strides of a contiguous
+ # (Fortran-style if fort is 'F' or C-style otherwise) array of the
+ # given shape with the given number of bytes per element.
+
+ int PyBuffer_FillInfo(Py_buffer *view, object exporter, void *buf,
+ Py_ssize_t len, int readonly, int flags) except -1
+ # Fill in a buffer-info structure, view, correctly for an exporter
+ # that can only share a contiguous chunk of memory of “unsigned
+ # bytes” of the given length. Return 0 on success and -1 (with
+ # raising an error) on error.
+
+ # DEPRECATED HERE: do not cimport from here, cimport from cpython.object instead
+ object PyObject_Format(object obj, object format_spec)
+ # Takes an arbitrary object and returns the result of calling
+ # obj.__format__(format_spec).
diff --git a/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd b/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd
new file mode 100644
index 0000000000..1af4a6c427
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/bytearray.pxd
@@ -0,0 +1,33 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ bint PyByteArray_Check(object o)
+ # Return true if the object o is a bytearray object or an instance of a subtype of the bytearray type.
+
+ bint PyByteArray_CheckExact(object o)
+ # Return true if the object o is a bytearray object, but not an instance of a subtype of the bytearray type.
+
+ bytearray PyByteArray_FromObject(object o)
+ # Return a new bytearray object from any object, o, that implements the buffer protocol.
+
+ bytearray PyByteArray_FromStringAndSize(char *string, Py_ssize_t len)
+ # Create a new bytearray object from string and its length, len. On failure, NULL is returned.
+
+ bytearray PyByteArray_Concat(object a, object b)
+ # Concat bytearrays a and b and return a new bytearray with the result.
+
+ Py_ssize_t PyByteArray_Size(object bytearray)
+ # Return the size of bytearray after checking for a NULL pointer.
+
+ char* PyByteArray_AsString(object bytearray)
+ # Return the contents of bytearray as a char array after checking for a NULL pointer.
+ # The returned array always has an extra null byte appended.
+
+ int PyByteArray_Resize(object bytearray, Py_ssize_t len)
+ # Resize the internal buffer of bytearray to len.
+
+ char* PyByteArray_AS_STRING(object bytearray)
+ # Macro version of PyByteArray_AsString().
+
+ Py_ssize_t PyByteArray_GET_SIZE(object bytearray)
+ # Macro version of PyByteArray_Size().
diff --git a/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd
new file mode 100644
index 0000000000..ea72c6aae7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/bytes.pxd
@@ -0,0 +1,198 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ ctypedef struct va_list
+
+ ############################################################################
+ # 7.3.1 String Objects
+ ############################################################################
+
+ # These functions raise TypeError when expecting a string
+ # parameter and are called with a non-string parameter.
+ # PyStringObject
+ # This subtype of PyObject represents a Python bytes object.
+ # PyTypeObject PyBytes_Type
+ # This instance of PyTypeObject represents the Python bytes type;
+ # it is the same object as bytes and types.BytesType in the Python
+ # layer.
+
+ bint PyBytes_Check(object o)
+ # Return true if the object o is a string object or an instance of
+ # a subtype of the string type.
+
+ bint PyBytes_CheckExact(object o)
+ # Return true if the object o is a string object, but not an instance of a subtype of the string type.
+
+ bytes PyBytes_FromString(char *v)
+ # Return value: New reference.
+ # Return a new string object with the value v on success, and NULL
+ # on failure. The parameter v must not be NULL; it will not be
+ # checked.
+
+ bytes PyBytes_FromStringAndSize(char *v, Py_ssize_t len)
+ # Return value: New reference.
+ # Return a new string object with the value v and length len on
+ # success, and NULL on failure. If v is NULL, the contents of the
+ # string are uninitialized.
+
+ bytes PyBytes_FromFormat(char *format, ...)
+ # Return value: New reference.
+ # Take a C printf()-style format string and a variable number of
+ # arguments, calculate the size of the resulting Python string and
+ # return a string with the values formatted into it. The variable
+ # arguments must be C types and must correspond exactly to the
+ # format characters in the format string. The following format
+ # characters are allowed:
+ # Format Characters Type Comment
+ # %% n/a The literal % character.
+ # %c int A single character, represented as an C int.
+ # %d int Exactly equivalent to printf("%d").
+ # %u unsigned int Exactly equivalent to printf("%u").
+ # %ld long Exactly equivalent to printf("%ld").
+ # %lu unsigned long Exactly equivalent to printf("%lu").
+ # %zd Py_ssize_t Exactly equivalent to printf("%zd").
+ # %zu size_t Exactly equivalent to printf("%zu").
+ # %i int Exactly equivalent to printf("%i").
+ # %x int Exactly equivalent to printf("%x").
+ # %s char* A null-terminated C character array.
+
+ # %p void* The hex representation of a C pointer.
+ # Mostly equivalent to printf("%p") except that it is guaranteed to
+ # start with the literal 0x regardless of what the platform's printf
+ # yields.
+ # An unrecognized format character causes all the rest of the
+ # format string to be copied as-is to the result string, and any
+ # extra arguments discarded.
+
+ bytes PyBytes_FromFormatV(char *format, va_list vargs)
+ # Return value: New reference.
+ # Identical to PyBytes_FromFormat() except that it takes exactly two arguments.
+
+ Py_ssize_t PyBytes_Size(object string) except -1
+ # Return the length of the string in string object string.
+
+ Py_ssize_t PyBytes_GET_SIZE(object string)
+ # Macro form of PyBytes_Size() but without error checking.
+
+ char* PyBytes_AsString(object string) except NULL
+ # Return a NUL-terminated representation of the contents of
+ # string. The pointer refers to the internal buffer of string, not
+ # a copy. The data must not be modified in any way, unless the
+ # string was just created using PyBytes_FromStringAndSize(NULL,
+ # size). It must not be deallocated. If string is a Unicode
+ # object, this function computes the default encoding of string
+ # and operates on that. If string is not a string object at all,
+ # PyBytes_AsString() returns NULL and raises TypeError.
+
+ char* PyBytes_AS_STRING(object string)
+ # Macro form of PyBytes_AsString() but without error
+ # checking. Only string objects are supported; no Unicode objects
+ # should be passed.
+
+ int PyBytes_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
+ # Return a NULL-terminated representation of the contents of the
+ # object obj through the output variables buffer and length.
+ #
+ # The function accepts both string and Unicode objects as
+ # input. For Unicode objects it returns the default encoded
+ # version of the object. If length is NULL, the resulting buffer
+ # may not contain NUL characters; if it does, the function returns
+ # -1 and a TypeError is raised.
+
+ # The buffer refers to an internal string buffer of obj, not a
+ # copy. The data must not be modified in any way, unless the
+ # string was just created using PyBytes_FromStringAndSize(NULL,
+ # size). It must not be deallocated. If string is a Unicode
+ # object, this function computes the default encoding of string
+ # and operates on that. If string is not a string object at all,
+ # PyBytes_AsStringAndSize() returns -1 and raises TypeError.
+
+ void PyBytes_Concat(PyObject **string, object newpart)
+ # Create a new string object in *string containing the contents of
+ # newpart appended to string; the caller will own the new
+ # reference. The reference to the old value of string will be
+ # stolen. If the new string cannot be created, the old reference
+ # to string will still be discarded and the value of *string will
+ # be set to NULL; the appropriate exception will be set.
+
+ void PyBytes_ConcatAndDel(PyObject **string, object newpart)
+ # Create a new string object in *string containing the contents of
+ # newpart appended to string. This version decrements the
+ # reference count of newpart.
+
+ int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
+ # A way to resize a string object even though it is
+ # ``immutable''. Only use this to build up a brand new string
+ # object; don't use this if the string may already be known in
+ # other parts of the code. It is an error to call this function if
+ # the refcount on the input string object is not one. Pass the
+ # address of an existing string object as an lvalue (it may be
+ # written into), and the new size desired. On success, *string
+ # holds the resized string object and 0 is returned; the address
+ # in *string may differ from its input value. If the reallocation
+ # fails, the original string object at *string is deallocated,
+ # *string is set to NULL, a memory exception is set, and -1 is
+ # returned.
+
+ bytes PyBytes_Format(object format, object args)
+ # Return value: New reference. Return a new string object from
+ # format and args. Analogous to format % args. The args argument
+ # must be a tuple.
+
+ void PyBytes_InternInPlace(PyObject **string)
+ # Intern the argument *string in place. The argument must be the
+ # address of a pointer variable pointing to a Python string
+ # object. If there is an existing interned string that is the same
+ # as *string, it sets *string to it (decrementing the reference
+ # count of the old string object and incrementing the reference
+ # count of the interned string object), otherwise it leaves
+ # *string alone and interns it (incrementing its reference
+ # count). (Clarification: even though there is a lot of talk about
+ # reference counts, think of this function as
+ # reference-count-neutral; you own the object after the call if
+ # and only if you owned it before the call.)
+
+ bytes PyBytes_InternFromString(char *v)
+ # Return value: New reference.
+ # A combination of PyBytes_FromString() and
+ # PyBytes_InternInPlace(), returning either a new string object
+ # that has been interned, or a new (``owned'') reference to an
+ # earlier interned string object with the same value.
+
+ object PyBytes_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+ # Return value: New reference.
+ # Create an object by decoding size bytes of the encoded buffer s
+ # using the codec registered for encoding. encoding and errors
+ # have the same meaning as the parameters of the same name in the
+ # unicode() built-in function. The codec to be used is looked up
+ # using the Python codec registry. Return NULL if an exception was
+ # raised by the codec.
+
+ object PyBytes_AsDecodedObject(object str, char *encoding, char *errors)
+ # Return value: New reference.
+ # Decode a string object by passing it to the codec registered for
+ # encoding and return the result as Python object. encoding and
+ # errors have the same meaning as the parameters of the same name
+ # in the 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.
+
+ object PyBytes_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
+ # Return value: New reference.
+ # Encode the char buffer of the given size by passing it to the
+ # codec registered for encoding and return a Python
+ # object. encoding and errors have the same meaning as the
+ # parameters of the same name in the 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.
+
+ object PyBytes_AsEncodedObject(object str, char *encoding, char *errors)
+ # Return value: New reference.
+ # Encode a string object using the codec registered for encoding
+ # and return the result as Python object. encoding and errors have
+ # the same meaning as the parameters of the same name in the
+ # 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/cellobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd
new file mode 100644
index 0000000000..5e3dd3d63c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/cellobject.pxd
@@ -0,0 +1,35 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # Cell Objects
+ ############################################################################
+
+ bint PyCell_Check(object ob)
+ # Return true if ob is a cell object; ob must not be NULL.
+
+ object PyCell_New(PyObject* ob)
+ # Return value: New reference.
+ # Create and return a new cell object containing the value ob. The
+ # parameter may be NULL.
+
+ object PyCell_Get(object cell)
+ # Return value: New reference.
+ # Return the contents of the cell object cell.
+
+ object PyCell_GET(object cell)
+ # Return value: Borrowed reference.
+ # Return the contents of the cell object cell, but without checking that
+ # cell is non-NULL and is a cell object.
+
+ int PyCell_Set(object cell, PyObject* value) except? -1
+ # Set the contents of the cell object cell to value. This releases the
+ # reference to any current content of the cell. value may be NULL. cell
+ # must be non-NULL; if it is not a cell object, -1 will be returned. On
+ # success, 0 will be returned.
+
+ void PyCell_SET(object cell, PyObject* value)
+ # Sets the value of the cell object cell to value. No reference counts are
+ # adjusted, and no checks are made for safety; cell must be non-NULL and
+ # must be a cell object.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd b/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd
new file mode 100644
index 0000000000..f22191f9fe
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/ceval.pxd
@@ -0,0 +1,8 @@
+
+cdef extern from "Python.h":
+
+ void PyEval_InitThreads()
+ # Initialize and acquire the global interpreter lock.
+
+ int PyEval_ThreadsInitialized()
+ # Returns a non-zero value if PyEval_InitThreads() has been called.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd
new file mode 100644
index 0000000000..497d8a92e8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/cobject.pxd
@@ -0,0 +1,36 @@
+
+cdef extern from "Python.h":
+
+ ###########################################################################
+ # Warning:
+ #
+ # The CObject API is deprecated as of Python 3.1. Please switch to
+ # the new Capsules API.
+ ###########################################################################
+
+ int PyCObject_Check(object p)
+ # Return true if its argument is a PyCObject.
+
+ object PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
+ # Return value: New reference.
+ #
+ # Create a PyCObject from the void * cobj. The destr function will
+ # be called when the object is reclaimed, unless it is NULL.
+
+ object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
+ # Return value: New reference.
+ #
+ # Create a PyCObject from the void * cobj. The destr function will
+ # be called when the object is reclaimed. The desc argument can be
+ # used to pass extra callback data for the destructor function.
+
+ void* PyCObject_AsVoidPtr(object self) except? NULL
+ # Return the object void * that the PyCObject self was created with.
+
+ void* PyCObject_GetDesc(object self) except? NULL
+ # Return the description void * that the PyCObject self was created with.
+
+ int PyCObject_SetVoidPtr(object self, void* cobj) except 0
+ # Set the void pointer inside self to cobj. The PyCObject must not
+ # have an associated destructor. Return true on success, false on
+ # failure.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd b/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd
new file mode 100644
index 0000000000..f2ca7d2444
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/codecs.pxd
@@ -0,0 +1,121 @@
+cdef extern from "Python.h":
+
+ ###########################################################################
+ # Codec registry and support functions
+ ###########################################################################
+
+ int PyCodec_Register(object search_function)
+ # Register a new codec search function.
+
+ # As side effect, this tries to load the encodings package, if not yet
+ # done, to make sure that it is always first in the list of search
+ # functions.
+
+ int PyCodec_KnownEncoding(const char *encoding)
+ # Return 1 or 0 depending on whether there is a registered codec for the
+ # given encoding. This function always succeeds.
+
+ object PyCodec_Encode(object o, const char *encoding, const char *errors)
+ # Return value: New reference.
+ # Generic codec based encoding API.
+
+ # o is passed through the encoder function found for the given encoding
+ # using the error handling method defined by errors. errors may be NULL
+ # to use the default method defined for the codec. Raises a LookupError
+ # if no encoder can be found.
+
+ object PyCodec_Decode(object o, const char *encoding, const char *errors)
+ # Return value: New reference.
+ # Generic codec based decoding API.
+
+ # o is passed through the decoder function found for the given encoding
+ # using the error handling method defined by errors. errors may be NULL
+ # to use the default method defined for the codec. Raises a LookupError
+ # if no encoder can be found.
+
+
+ # Codec lookup API
+
+ # In the following functions, the encoding string is looked up converted
+ # to all lower-case characters, which makes encodings looked up through
+ # this mechanism effectively case-insensitive. If no codec is found, a
+ # KeyError is set and NULL returned.
+
+ object PyCodec_Encoder(const char *encoding)
+ # Return value: New reference.
+ # Get an encoder function for the given encoding.
+
+ object PyCodec_Decoder(const char *encoding)
+ # Return value: New reference.
+ # Get a decoder function for the given encoding.
+
+ object PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
+ # Return value: New reference.
+ # Get an IncrementalEncoder object for the given encoding.
+
+ object PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
+ # Return value: New reference.
+ # Get an IncrementalDecoder object for the given encoding.
+
+ object PyCodec_StreamReader(const char *encoding, object stream, const char *errors)
+ # Return value: New reference.
+ # Get a StreamReader factory function for the given encoding.
+
+ object PyCodec_StreamWriter(const char *encoding, object stream, const char *errors)
+ # Return value: New reference.
+ # Get a StreamWriter factory function for the given encoding.
+
+
+ # Registry API for Unicode encoding error handlers
+
+ int PyCodec_RegisterError(const char *name, object error) except? -1
+ # Register the error handling callback function error under the given
+ # name. This callback function will be called by a codec when it
+ # encounters unencodable characters/undecodable bytes and name is
+ # specified as the error parameter in the call to the encode/decode
+ # function.
+
+ # The callback gets a single argument, an instance of
+ # UnicodeEncodeError, UnicodeDecodeError or UnicodeTranslateError that
+ # holds information about the problematic sequence of characters or bytes
+ # and their offset in the original string (see Unicode Exception Objects
+ # for functions to extract this information). The callback must either
+ # raise the given exception, or return a two-item tuple containing the
+ # replacement for the problematic sequence, and an integer giving the
+ # offset in the original string at which encoding/decoding should be
+ # resumed.
+
+ # Return 0 on success, -1 on error.
+
+ object PyCodec_LookupError(const char *name)
+ # Return value: New reference.
+ # Lookup the error handling callback function registered under name. As a
+ # special case NULL can be passed, in which case the error handling
+ # callback for "strict" will be returned.
+
+ object PyCodec_StrictErrors(object exc)
+ # Return value: Always NULL.
+ # Raise exc as an exception.
+
+ object PyCodec_IgnoreErrors(object exc)
+ # Return value: New reference.
+ # Ignore the unicode error, skipping the faulty input.
+
+ object PyCodec_ReplaceErrors(object exc)
+ # Return value: New reference.
+ # Replace the unicode encode error with "?" or "U+FFFD".
+
+ object PyCodec_XMLCharRefReplaceErrors(object exc)
+ # Return value: New reference.
+ # Replace the unicode encode error with XML character references.
+
+ object PyCodec_BackslashReplaceErrors(object exc)
+ # Return value: New reference.
+ # Replace the unicode encode error with backslash escapes ("\x", "\u"
+ # and "\U").
+
+ object PyCodec_NameReplaceErrors(object exc)
+ # Return value: New reference.
+ # Replace the unicode encode error with "\N{...}" escapes.
+
+ # New in version 3.5.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/complex.pxd b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd
new file mode 100644
index 0000000000..f5ba339575
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/complex.pxd
@@ -0,0 +1,50 @@
+
+cdef extern from "Python.h":
+
+ ctypedef struct Py_complex:
+ double imag
+ double real
+
+ ############################################################################
+ # 7.2.5.2 Complex Numbers as Python Objects
+ ############################################################################
+
+ # PyComplexObject
+ # This subtype of PyObject represents a Python complex number object.
+
+ 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"
+
+ # PyTypeObject PyComplex_Type
+ # This instance of PyTypeObject represents the Python complex
+ # number type. It is the same object as complex and
+ # types.ComplexType.
+
+ bint PyComplex_Check(object p)
+ # Return true if its argument is a PyComplexObject or a subtype of
+ # PyComplexObject.
+
+ bint PyComplex_CheckExact(object p)
+ # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
+
+ object PyComplex_FromCComplex(Py_complex v)
+ # Return value: New reference.
+ # Create a new Python complex number object from a C Py_complex value.
+
+ object PyComplex_FromDoubles(double real, double imag)
+ # Return value: New reference.
+ # Return a new PyComplexObject object from real and imag.
+
+ double PyComplex_RealAsDouble(object op) except? -1
+ # Return the real part of op as a C double.
+
+ double PyComplex_ImagAsDouble(object op) except? -1
+ # Return the imaginary part of op as a C double.
+
+ Py_complex PyComplex_AsCComplex(object op)
+ # Return the Py_complex value of the complex number op.
+ #
+ # Returns (-1+0i) in case of an error
diff --git a/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd b/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd
new file mode 100644
index 0000000000..18e2c3d1a6
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/conversion.pxd
@@ -0,0 +1,36 @@
+# From https://docs.python.org/3/c-api/conversion.html
+
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ ctypedef struct va_list
+
+ int PyOS_snprintf(char *str, size_t size, const char *format, ...)
+ # Output not more than size bytes to str according to the format
+ # string format and the extra arguments. See the Unix man page snprintf(2).
+
+ int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
+ # Output not more than size bytes to str according to the format
+ # string format and the variable argument list va. Unix man page vsnprintf(2).
+
+ double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) except? -1.0
+ # Convert a string s to a double, raising a Python exception on failure. The set of
+ # accepted strings corresponds to the set of strings accepted by Python’s float()
+ # constructor, except that s must not have leading or trailing whitespace.
+ # The conversion is independent of the current locale.
+
+ enum:
+ Py_DTSF_SIGN
+ Py_DTSF_ADD_DOT_0
+ Py_DTSF_ALT
+
+ char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) except NULL
+ # Convert a double val to a string using supplied format_code, precision, and flags.
+
+ int PyOS_stricmp(const char *s1, const char *s2)
+ # Case insensitive comparison of strings. The function works almost identically
+ # to strcmp() except that it ignores the case.
+
+ int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size)
+ # Case insensitive comparison of strings. The function works almost identically
+ # to strncmp() except that it ignores the case.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd
new file mode 100644
index 0000000000..cd0f90719b
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/datetime.pxd
@@ -0,0 +1,212 @@
+from cpython.object cimport PyObject
+
+cdef extern from "Python.h":
+ ctypedef struct PyTypeObject:
+ pass
+
+cdef extern from "datetime.h":
+
+ ctypedef extern class datetime.date[object PyDateTime_Date]:
+ pass
+
+ ctypedef extern class datetime.time[object PyDateTime_Time]:
+ pass
+
+ ctypedef extern class datetime.datetime[object PyDateTime_DateTime]:
+ pass
+
+ ctypedef extern class datetime.timedelta[object PyDateTime_Delta]:
+ pass
+
+ ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]:
+ pass
+
+ ctypedef struct PyDateTime_Date:
+ pass
+
+ ctypedef struct PyDateTime_Time:
+ char hastzinfo
+ PyObject *tzinfo
+
+ ctypedef struct PyDateTime_DateTime:
+ char hastzinfo
+ PyObject *tzinfo
+
+ ctypedef struct PyDateTime_Delta:
+ int days
+ int seconds
+ int microseconds
+
+ # Define structure for C API.
+ ctypedef struct PyDateTime_CAPI:
+ # type objects
+ PyTypeObject *DateType
+ PyTypeObject *DateTimeType
+ PyTypeObject *TimeType
+ PyTypeObject *DeltaType
+ 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*)
+
+ # constructors for the DB API
+ object (*DateTime_FromTimestamp)(object, object, object)
+ object (*Date_FromTimestamp)(object, object)
+
+ # Check type of the object.
+ bint PyDate_Check(object op)
+ bint PyDate_CheckExact(object op)
+
+ bint PyDateTime_Check(object op)
+ bint PyDateTime_CheckExact(object op)
+
+ bint PyTime_Check(object op)
+ bint PyTime_CheckExact(object op)
+
+ bint PyDelta_Check(object op)
+ bint PyDelta_CheckExact(object op)
+
+ bint PyTZInfo_Check(object op)
+ bint PyTZInfo_CheckExact(object op)
+
+ # Getters for date and datetime (C macros).
+ int PyDateTime_GET_YEAR(object o)
+ int PyDateTime_GET_MONTH(object o)
+ int PyDateTime_GET_DAY(object o)
+
+ # Getters for datetime (C macros).
+ int PyDateTime_DATE_GET_HOUR(object o)
+ int PyDateTime_DATE_GET_MINUTE(object o)
+ int PyDateTime_DATE_GET_SECOND(object o)
+ int PyDateTime_DATE_GET_MICROSECOND(object o)
+
+ # 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)
+
+ # 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)
+
+ # PyDateTime CAPI object.
+ PyDateTime_CAPI *PyDateTimeAPI
+
+ 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():
+ 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):
+ 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)
+
+# 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)
+
+# 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):
+ return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)
+
+# 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 tzinfo of time
+cdef inline object time_tzinfo(object o):
+ if (<PyDateTime_Time*>o).hastzinfo:
+ return <object>(<PyDateTime_Time*>o).tzinfo
+ else:
+ return None
+
+# 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
+
+# Get year of date
+cdef inline int date_year(object o):
+ return PyDateTime_GET_YEAR(o)
+
+# Get month of date
+cdef inline int date_month(object o):
+ return PyDateTime_GET_MONTH(o)
+
+# Get day of date
+cdef inline int date_day(object o):
+ return PyDateTime_GET_DAY(o)
+
+# Get year of datetime
+cdef inline int datetime_year(object o):
+ return PyDateTime_GET_YEAR(o)
+
+# Get month of datetime
+cdef inline int datetime_month(object o):
+ return PyDateTime_GET_MONTH(o)
+
+# Get day of datetime
+cdef inline int datetime_day(object o):
+ return PyDateTime_GET_DAY(o)
+
+# Get hour of time
+cdef inline int time_hour(object o):
+ return PyDateTime_TIME_GET_HOUR(o)
+
+# Get minute of time
+cdef inline int time_minute(object o):
+ return PyDateTime_TIME_GET_MINUTE(o)
+
+# Get second of time
+cdef inline int time_second(object o):
+ return PyDateTime_TIME_GET_SECOND(o)
+
+# Get microsecond of time
+cdef inline int time_microsecond(object o):
+ return PyDateTime_TIME_GET_MICROSECOND(o)
+
+# Get hour of datetime
+cdef inline int datetime_hour(object o):
+ return PyDateTime_DATE_GET_HOUR(o)
+
+# Get minute of datetime
+cdef inline int datetime_minute(object o):
+ return PyDateTime_DATE_GET_MINUTE(o)
+
+# Get second of datetime
+cdef inline int datetime_second(object o):
+ return PyDateTime_DATE_GET_SECOND(o)
+
+# Get microsecond of datetime
+cdef inline int datetime_microsecond(object o):
+ return PyDateTime_DATE_GET_MICROSECOND(o)
+
+# Get days of timedelta
+cdef inline int timedelta_days(object o):
+ return (<PyDateTime_Delta*>o).days
+
+# Get seconds of timedelta
+cdef inline int timedelta_seconds(object o):
+ return (<PyDateTime_Delta*>o).seconds
+
+# Get microseconds of timedelta
+cdef inline int timedelta_microseconds(object o):
+ return (<PyDateTime_Delta*>o).microseconds
diff --git a/contrib/tools/cython/Cython/Includes/cpython/dict.pxd b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd
new file mode 100644
index 0000000000..16dd5e1458
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/dict.pxd
@@ -0,0 +1,165 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.4.1 Dictionary Objects
+ ############################################################################
+
+ # PyDictObject
+ #
+ # This subtype of PyObject represents a Python dictionary object
+ # (i.e. the 'dict' type).
+
+ # PyTypeObject PyDict_Type
+ #
+ # This instance of PyTypeObject represents the Python dictionary
+ # type. This is exposed to Python programs as dict and
+ # types.DictType.
+
+ bint PyDict_Check(object p)
+ # Return true if p is a dict object or an instance of a subtype of
+ # the dict type.
+
+ bint PyDict_CheckExact(object p)
+ # Return true if p is a dict object, but not an instance of a
+ # subtype of the dict type.
+
+ dict PyDict_New()
+ # Return value: New reference.
+ # Return a new empty dictionary, or NULL on failure.
+
+ object PyDictProxy_New(object dict)
+ # Return value: New reference.
+ # Return a proxy object for a mapping which enforces read-only
+ # behavior. This is normally used to create a proxy to prevent
+ # modification of the dictionary for non-dynamic class types.
+
+ void PyDict_Clear(object p)
+ # Empty an existing dictionary of all key-value pairs.
+
+ int PyDict_Contains(object p, object key) except -1
+ # Determine if dictionary p contains key. If an item in p is
+ # matches key, return 1, otherwise return 0. On error, return
+ # -1. This is equivalent to the Python expression "key in p".
+
+ dict PyDict_Copy(object p)
+ # Return value: New reference.
+ # Return a new dictionary that contains the same key-value pairs as p.
+
+ int PyDict_SetItem(object p, object key, object val) except -1
+ # Insert value into the dictionary p with a key of key. key must
+ # be hashable; if it isn't, TypeError will be raised. Return 0 on
+ # success or -1 on failure.
+
+ int PyDict_SetItemString(object p, const char *key, object val) except -1
+ # Insert value into the dictionary p using key as a key. key
+ # should be a char*. The key object is created using
+ # PyString_FromString(key). Return 0 on success or -1 on failure.
+
+ int PyDict_DelItem(object p, object key) except -1
+ # Remove the entry in dictionary p with key key. key must be
+ # hashable; if it isn't, TypeError is raised. Return 0 on success
+ # or -1 on failure.
+
+ int PyDict_DelItemString(object p, const char *key) except -1
+ # Remove the entry in dictionary p which has a key specified by
+ # the string key. Return 0 on success or -1 on failure.
+
+ PyObject* PyDict_GetItem(object p, object key)
+ # Return value: Borrowed reference.
+ # Return the object from dictionary p which has a key key. Return
+ # NULL if the key key is not present, but without setting an
+ # exception.
+
+ 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*.
+
+ list PyDict_Items(object p)
+ # Return value: New reference.
+ # Return a PyListObject containing all the items from the
+ # dictionary, as in the dictionary method items() (see the Python
+ # Library Reference).
+
+ list PyDict_Keys(object p)
+ # Return value: New reference.
+ # Return a PyListObject containing all the keys from the
+ # dictionary, as in the dictionary method keys() (see the Python
+ # Library Reference).
+
+ list PyDict_Values(object p)
+ # Return value: New reference.
+ # Return a PyListObject containing all the values from the
+ # dictionary p, as in the dictionary method values() (see the
+ # Python Library Reference).
+
+ Py_ssize_t PyDict_Size(object p) except -1
+ # Return the number of items in the dictionary. This is equivalent
+ # to "len(p)" on a dictionary.
+
+ int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue)
+ # Iterate over all key-value pairs in the dictionary p. The int
+ # referred to by ppos must be initialized to 0 prior to the first
+ # call to this function to start the iteration; the function
+ # returns true for each pair in the dictionary, and false once all
+ # pairs have been reported. The parameters pkey and pvalue should
+ # either point to PyObject* variables that will be filled in with
+ # each key and value, respectively, or may be NULL. Any references
+ # returned through them are borrowed. ppos should not be altered
+ # during iteration. Its value represents offsets within the
+ # internal dictionary structure, and since the structure is
+ # sparse, the offsets are not consecutive.
+ # For example:
+ #
+ #object key, *value;
+ #int pos = 0;
+ #
+ #while (PyDict_Next(self->dict, &pos, &key, &value)) {
+ # /* do something interesting with the values... */
+ # ...
+ #}
+ # The dictionary p should not be mutated during iteration. It is
+ # safe (since Python 2.1) to modify the values of the keys as you
+ # iterate over the dictionary, but only so long as the set of keys
+ # does not change. For example:
+ # object key, *value;
+ # int pos = 0;
+ # while (PyDict_Next(self->dict, &pos, &key, &value)) {
+ # int i = PyInt_AS_LONG(value) + 1;
+ # object o = PyInt_FromLong(i);
+ # if (o == NULL)
+ # return -1;
+ # if (PyDict_SetItem(self->dict, key, o) < 0) {
+ # Py_DECREF(o);
+ # return -1;
+ # }
+ # Py_DECREF(o);
+ # }
+
+ int PyDict_Merge(object a, object b, int override) except -1
+ # Iterate over mapping object b adding key-value pairs to
+ # dictionary a. b may be a dictionary, or any object supporting
+ # PyMapping_Keys() and PyObject_GetItem(). If override is true,
+ # existing pairs in a will be replaced if a matching key is found
+ # in b, otherwise pairs will only be added if there is not a
+ # matching key in a. Return 0 on success or -1 if an exception was
+ # raised.
+
+ int PyDict_Update(object a, object b) except -1
+ # This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b)
+ # in Python. Return 0 on success or -1 if an exception was raised.
+
+ int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1
+ # Update or merge into dictionary a, from the key-value pairs in
+ # seq2. seq2 must be an iterable object producing iterable objects
+ # of length 2, viewed as key-value pairs. In case of duplicate
+ # keys, the last wins if override is true, else the first
+ # wins. Return 0 on success or -1 if an exception was
+ # raised. Equivalent Python (except for the return value):
+ #
+ #def PyDict_MergeFromSeq2(a, seq2, override):
+ # for key, value in seq2:
+ # if override or key not in a:
+ # a[key] = value
diff --git a/contrib/tools/cython/Cython/Includes/cpython/exc.pxd b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd
new file mode 100644
index 0000000000..bc57c0e571
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/exc.pxd
@@ -0,0 +1,257 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ #####################################################################
+ # 3. Exception Handling
+ #####################################################################
+
+ # The functions described in this chapter will let you handle and
+ # raise Python exceptions. It is important to understand some of
+ # the basics of Python exception handling. It works somewhat like
+ # the Unix errno variable: there is a global indicator (per
+ # thread) of the last error that occurred. Most functions don't
+ # clear this on success, but will set it to indicate the cause of
+ # the error on failure. Most functions also return an error
+ # indicator, usually NULL if they are supposed to return a
+ # pointer, or -1 if they return an integer (exception: the
+ # PyArg_*() functions return 1 for success and 0 for failure).
+
+ # When a function must fail because some function it called
+ # failed, it generally doesn't set the error indicator; the
+ # function it called already set it. It is responsible for either
+ # handling the error and clearing the exception or returning after
+ # cleaning up any resources it holds (such as object references or
+ # memory allocations); it should not continue normally if it is
+ # not prepared to handle the error. If returning due to an error,
+ # it is important to indicate to the caller that an error has been
+ # set. If the error is not handled or carefully propagated,
+ # additional calls into the Python/C API may not behave as
+ # intended and may fail in mysterious ways.
+
+ # The error indicator consists of three Python objects
+ # corresponding to the Python variables sys.exc_type,
+ # sys.exc_value and sys.exc_traceback. API functions exist to
+ # interact with the error indicator in various ways. There is a
+ # separate error indicator for each thread.
+
+ void PyErr_Print()
+ # Print a standard traceback to sys.stderr and clear the error
+ # indicator. Call this function only when the error indicator is
+ # set. (Otherwise it will cause a fatal error!)
+
+ PyObject* PyErr_Occurred()
+ # Return value: Borrowed reference.
+ # Test whether the error indicator is set. If set, return the
+ # exception type (the first argument to the last call to one of
+ # the PyErr_Set*() functions or to PyErr_Restore()). If not set,
+ # return NULL. You do not own a reference to the return value, so
+ # you do not need to Py_DECREF() it. Note: Do not compare the
+ # return value to a specific exception; use
+ # PyErr_ExceptionMatches() instead, shown below. (The comparison
+ # could easily fail since the exception may be an instance instead
+ # of a class, in the case of a class exception, or it may be a
+ # subclass of the expected exception.)
+
+ bint PyErr_ExceptionMatches(object exc)
+ # Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(),
+ # exc)". This should only be called when an exception is actually
+ # set; a memory access violation will occur if no exception has
+ # been raised.
+
+ bint PyErr_GivenExceptionMatches(object given, object exc)
+ # Return true if the given exception matches the exception in
+ # exc. If exc is a class object, this also returns true when given
+ # is an instance of a subclass. If exc is a tuple, all exceptions
+ # in the tuple (and recursively in subtuples) are searched for a
+ # match. If given is NULL, a memory access violation will occur.
+
+ void PyErr_NormalizeException(PyObject** exc, PyObject** val, PyObject** tb)
+ # Under certain circumstances, the values returned by
+ # PyErr_Fetch() below can be ``unnormalized'', meaning that *exc
+ # is a class object but *val is not an instance of the same
+ # class. This function can be used to instantiate the class in
+ # that case. If the values are already normalized, nothing
+ # happens. The delayed normalization is implemented to improve
+ # performance.
+
+ void PyErr_Clear()
+ # Clear the error indicator. If the error indicator is not set, there is no effect.
+
+ void PyErr_Fetch(PyObject** ptype, PyObject** pvalue, PyObject** ptraceback)
+ # Retrieve the error indicator into three variables whose
+ # addresses are passed. If the error indicator is not set, set all
+ # three variables to NULL. If it is set, it will be cleared and
+ # you own a reference to each object retrieved. The value and
+ # traceback object may be NULL even when the type object is
+ # not. Note: This function is normally only used by code that
+ # needs to handle exceptions or by code that needs to save and
+ # restore the error indicator temporarily.
+
+ 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
+ # are NULL, the error indicator is cleared. Do not pass a NULL
+ # type and non-NULL value or traceback. The exception type should
+ # be a class. Do not pass an invalid exception type or
+ # value. (Violating these rules will cause subtle problems later.)
+ # This call takes away a reference to each object: you must own a
+ # reference to each object before the call and after the call you
+ # no longer own these references. (If you don't understand this,
+ # don't use this function. I warned you.) Note: This function is
+ # normally only used by code that needs to save and restore the
+ # error indicator temporarily; use PyErr_Fetch() to save the
+ # current exception state.
+
+ void PyErr_SetString(object type, char *message)
+ # This is the most common way to set the error indicator. The
+ # first argument specifies the exception type; it is normally one
+ # of the standard exceptions, e.g. PyExc_RuntimeError. You need
+ # not increment its reference count. The second argument is an
+ # error message; it is converted to a string object.
+
+ void PyErr_SetObject(object type, object value)
+ # This function is similar to PyErr_SetString() but lets you
+ # specify an arbitrary Python object for the ``value'' of the
+ # exception.
+
+ PyObject* PyErr_Format(object exception, char *format, ...) except NULL
+ # Return value: Always NULL.
+ # This function sets the error indicator and returns
+ # NULL. exception should be a Python exception (class, not an
+ # instance). format should be a string, containing format codes,
+ # similar to printf(). The width.precision before a format code is
+ # parsed, but the width part is ignored.
+
+ void PyErr_SetNone(object type)
+ # This is a shorthand for "PyErr_SetObject(type, Py_None)".
+
+ int PyErr_BadArgument() except 0
+
+ # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
+ # message)", where message indicates that a built-in operation was
+ # invoked with an illegal argument. It is mostly for internal use.
+
+ PyObject* PyErr_NoMemory() except NULL
+ # Return value: Always NULL.
+ # This is a shorthand for "PyErr_SetNone(PyExc_MemoryError)"; it
+ # returns NULL so an object allocation function can write "return
+ # PyErr_NoMemory();" when it runs out of memory.
+
+ PyObject* PyErr_SetFromErrno(object type) except NULL
+ # Return value: Always NULL.
+ # This is a convenience function to raise an exception when a C
+ # library function has returned an error and set the C variable
+ # errno. It constructs a tuple object whose first item is the
+ # integer errno value and whose second item is the corresponding
+ # error message (gotten from strerror()), and then calls
+ # "PyErr_SetObject(type, object)". On Unix, when the errno value
+ # is EINTR, indicating an interrupted system call, this calls
+ # PyErr_CheckSignals(), and if that set the error indicator,
+ # leaves it set to that. The function always returns NULL, so a
+ # wrapper function around a system call can write "return
+ # PyErr_SetFromErrno(type);" when the system call returns an
+ # error.
+
+ PyObject* PyErr_SetFromErrnoWithFilenameObject(object type, object filenameObject) except NULL
+ # Similar to PyErr_SetFromErrno(), with the additional behavior
+ # that if filenameObject is not NULL, it is passed to the
+ # constructor of type as a third parameter.
+ # In the case of OSError exception, this is used to define
+ # the filename attribute of the exception instance.
+
+ PyObject* PyErr_SetFromErrnoWithFilename(object type, char *filename) except NULL
+ # Return value: Always NULL. Similar to PyErr_SetFromErrno(),
+ # with the additional behavior that if filename is not NULL, it is
+ # passed to the constructor of type as a third parameter. In the
+ # case of exceptions such as IOError and OSError, this is used to
+ # define the filename attribute of the exception instance.
+
+ PyObject* PyErr_SetFromWindowsErr(int ierr) except NULL
+ # Return value: Always NULL. This is a convenience function to
+ # raise WindowsError. If called with ierr of 0, the error code
+ # returned by a call to GetLastError() is used instead. It calls
+ # the Win32 function FormatMessage() to retrieve the Windows
+ # description of error code given by ierr or GetLastError(), then
+ # it constructs a tuple object whose first item is the ierr value
+ # and whose second item is the corresponding error message (gotten
+ # from FormatMessage()), and then calls
+ # "PyErr_SetObject(PyExc_WindowsError, object)". This function
+ # always returns NULL. Availability: Windows.
+
+ PyObject* PyErr_SetExcFromWindowsErr(object type, int ierr) except NULL
+ # Return value: Always NULL. Similar to
+ # PyErr_SetFromWindowsErr(), with an additional parameter
+ # specifying the exception type to be raised. Availability:
+ # Windows. New in version 2.3.
+
+ PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, char *filename) except NULL
+ # Return value: Always NULL. Similar to
+ # PyErr_SetFromWindowsErr(), with the additional behavior that if
+ # filename is not NULL, it is passed to the constructor of
+ # WindowsError as a third parameter. Availability: Windows.
+
+ PyObject* PyErr_SetExcFromWindowsErrWithFilename(object type, int ierr, char *filename) except NULL
+ # Return value: Always NULL.
+ # Similar to PyErr_SetFromWindowsErrWithFilename(), with an
+ # additional parameter specifying the exception type to be
+ # raised. Availability: Windows.
+
+ void PyErr_BadInternalCall()
+ # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
+ # message)", where message indicates that an internal operation
+ # (e.g. a Python/C API function) was invoked with an illegal
+ # argument. It is mostly for internal use.
+
+ int PyErr_WarnEx(object category, char *message, int stacklevel) except -1
+ # Issue a warning message. The category argument is a warning
+ # category (see below) or NULL; the message argument is a message
+ # string. stacklevel is a positive number giving a number of stack
+ # frames; the warning will be issued from the currently executing
+ # line of code in that stack frame. A stacklevel of 1 is the
+ # function calling PyErr_WarnEx(), 2 is the function above that,
+ # and so forth.
+
+ int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) except -1
+ # Issue a warning message with explicit control over all warning
+ # attributes. This is a straightforward wrapper around the Python
+ # function warnings.warn_explicit(), see there for more
+ # information. The module and registry arguments may be set to
+ # NULL to get the default effect described there.
+
+ int PyErr_CheckSignals() except -1
+ # This function interacts with Python's signal handling. It checks
+ # whether a signal has been sent to the processes and if so,
+ # invokes the corresponding signal handler. If the signal module
+ # is supported, this can invoke a signal handler written in
+ # Python. In all cases, the default effect for SIGINT is to raise
+ # the KeyboardInterrupt exception. If an exception is raised the
+ # error indicator is set and the function returns 1; otherwise the
+ # function returns 0. The error indicator may or may not be
+ # cleared if it was previously set.
+
+ void PyErr_SetInterrupt() nogil
+ # This function simulates the effect of a SIGINT signal arriving
+ # -- the next time PyErr_CheckSignals() is called,
+ # KeyboardInterrupt will be raised. It may be called without
+ # holding the interpreter lock.
+
+ object PyErr_NewException(char *name, object base, object dict)
+ # Return value: New reference.
+ # This utility function creates and returns a new exception
+ # object. The name argument must be the name of the new exception,
+ # a C string of the form module.class. The base and dict arguments
+ # are normally NULL. This creates a class object derived from
+ # Exception (accessible in C as PyExc_Exception).
+
+ void PyErr_WriteUnraisable(object obj)
+ # This utility function prints a warning message to sys.stderr
+ # when an exception has been set but it is impossible for the
+ # interpreter to actually raise the exception. It is used, for
+ # example, when an exception occurs in an __del__() method.
+ #
+ # The function is called with a single argument obj that
+ # 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/float.pxd b/contrib/tools/cython/Cython/Includes/cpython/float.pxd
new file mode 100644
index 0000000000..65328f31ea
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/float.pxd
@@ -0,0 +1,39 @@
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.2.3
+ ############################################################################
+ # PyFloatObject
+ #
+ # This subtype of PyObject represents a Python floating point object.
+
+ # PyTypeObject PyFloat_Type
+ #
+ # This instance of PyTypeObject represents the Python floating
+ # point type. This is the same object as float and
+ # types.FloatType.
+
+ bint PyFloat_Check(object p)
+ # Return true if its argument is a PyFloatObject or a subtype of
+ # PyFloatObject.
+
+ bint PyFloat_CheckExact(object p)
+ # Return true if its argument is a PyFloatObject, but not a
+ # subtype of PyFloatObject.
+
+ object PyFloat_FromString(object str, char **pend)
+ # 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
+ # only for backward compatibility.
+
+ object PyFloat_FromDouble(double v)
+ # Return value: New reference.
+ # Create a PyFloatObject object from v, or NULL on failure.
+
+ double PyFloat_AsDouble(object pyfloat) except? -1
+ # Return a C double representation of the contents of pyfloat.
+
+ double PyFloat_AS_DOUBLE(object pyfloat)
+ # Return a C double representation of the contents of pyfloat, but
+ # without error checking.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/function.pxd b/contrib/tools/cython/Cython/Includes/cpython/function.pxd
new file mode 100644
index 0000000000..0002a3f6cb
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/function.pxd
@@ -0,0 +1,65 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.5.3 Function Objects
+ ############################################################################
+ # There are a few functions specific to Python functions.
+
+ # PyFunctionObject
+ #
+ # The C structure used for functions.
+
+ # PyTypeObject PyFunction_Type
+ #
+ # This is an instance of PyTypeObject and represents the Python
+ # function type. It is exposed to Python programmers as
+ # types.FunctionType.
+
+ bint PyFunction_Check(object o)
+ # Return true if o is a function object (has type
+ # PyFunction_Type). The parameter must not be NULL.
+
+ object PyFunction_New(object code, object globals)
+ # Return value: New reference.
+ # Return a new function object associated with the code object
+ # code. globals must be a dictionary with the global variables
+ # accessible to the function.
+ # The function's docstring, name and __module__ are retrieved from
+ # the code object, the argument defaults and closure are set to
+ # NULL.
+
+ PyObject* PyFunction_GetCode(object op) except? NULL
+ # Return value: Borrowed reference.
+ # Return the code object associated with the function object op.
+
+ PyObject* PyFunction_GetGlobals(object op) except? NULL
+ # Return value: Borrowed reference.
+ # Return the globals dictionary associated with the function object op.
+
+ PyObject* PyFunction_GetModule(object op) except? NULL
+ # Return value: Borrowed reference.
+ # Return the __module__ attribute of the function object op. This
+ # is normally a string containing the module name, but can be set
+ # to any other object by Python code.
+
+ PyObject* PyFunction_GetDefaults(object op) except? NULL
+ # Return value: Borrowed reference.
+ # Return the argument default values of the function object
+ # op. This can be a tuple of arguments or NULL.
+
+ int PyFunction_SetDefaults(object op, object defaults) except -1
+ # Set the argument default values for the function object
+ # op. defaults must be Py_None or a tuple.
+ # Raises SystemError and returns -1 on failure.
+
+ PyObject* PyFunction_GetClosure(object op) except? NULL
+ # Return value: Borrowed reference.
+ # Return the closure associated with the function object op. This
+ # can be NULL or a tuple of cell objects.
+
+ int PyFunction_SetClosure(object op, object closure) except -1
+ # Set the closure associated with the function object op. closure
+ # must be Py_None or a tuple of cell objects.
+ # Raises SystemError and returns -1 on failure.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd
new file mode 100644
index 0000000000..337b3cc0ad
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/genobject.pxd
@@ -0,0 +1,25 @@
+from .pystate cimport PyFrameObject
+
+cdef extern from "Python.h":
+
+ ###########################################################################
+ # Generator Objects
+ ###########################################################################
+
+ bint PyGen_Check(object ob)
+ # Return true if ob is a generator object; ob must not be NULL.
+
+ bint PyGen_CheckExact(object ob)
+ # Return true if ob's type is PyGen_Type; ob must not be NULL.
+
+ object PyGen_New(PyFrameObject *frame)
+ # Return value: New reference.
+ # Create and return a new generator object based on the frame object. A
+ # reference to frame is stolen by this function. The argument must not be
+ # NULL.
+
+ object PyGen_NewWithQualName(PyFrameObject *frame, object name, object qualname)
+ # Return value: New reference.
+ # Create and return a new generator object based on the frame object, with
+ # __name__ and __qualname__ set to name and qualname. A reference to frame
+ # is stolen by this function. The frame argument must not be NULL.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd b/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd
new file mode 100644
index 0000000000..be6df3285a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/getargs.pxd
@@ -0,0 +1,12 @@
+
+cdef extern from "Python.h":
+ #####################################################################
+ # 5.5 Parsing arguments and building values
+ #####################################################################
+ ctypedef struct va_list
+ int PyArg_ParseTuple(object args, char *format, ...) except 0
+ int PyArg_VaParse(object args, char *format, va_list vargs) except 0
+ int PyArg_ParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], ...) except 0
+ int PyArg_VaParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], va_list vargs) except 0
+ int PyArg_Parse(object args, char *format, ...) except 0
+ int PyArg_UnpackTuple(object args, char *name, Py_ssize_t min, Py_ssize_t max, ...) except 0
diff --git a/contrib/tools/cython/Cython/Includes/cpython/instance.pxd b/contrib/tools/cython/Cython/Includes/cpython/instance.pxd
new file mode 100644
index 0000000000..aecdc0cfd7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/instance.pxd
@@ -0,0 +1,25 @@
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.5.2 Instance Objects
+ ############################################################################
+
+ # PyTypeObject PyInstance_Type
+ #
+ # Type object for class instances.
+
+ int PyInstance_Check(object obj)
+ # Return true if obj is an instance.
+
+ object PyInstance_New(object cls, object arg, object kw)
+ # Return value: New reference.
+ # Create a new instance of a specific class. The parameters arg
+ # and kw are used as the positional and keyword parameters to the
+ # object's constructor.
+
+ object PyInstance_NewRaw(object cls, object dict)
+ # Return value: New reference.
+ # Create a new instance of a specific class without calling its
+ # constructor. class is the class of new object. The dict
+ # parameter will be used as the object's __dict__; if NULL, a new
+ # dictionary will be created for the instance.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/int.pxd b/contrib/tools/cython/Cython/Includes/cpython/int.pxd
new file mode 100644
index 0000000000..50babff615
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/int.pxd
@@ -0,0 +1,89 @@
+cdef extern from "Python.h":
+ ctypedef unsigned long long PY_LONG_LONG
+
+ ############################################################################
+ # Integer Objects
+ ############################################################################
+ # PyTypeObject PyInt_Type
+ # This instance of PyTypeObject represents the Python plain
+ # integer type. This is the same object as int and types.IntType.
+
+ bint PyInt_Check(object o)
+ # Return true if o is of type PyInt_Type or a subtype of
+ # PyInt_Type.
+
+ bint PyInt_CheckExact(object o)
+ # Return true if o is of type PyInt_Type, but not a subtype of
+ # PyInt_Type.
+
+ object PyInt_FromString(char *str, char **pend, int base)
+ # Return value: New reference.
+ # Return a new PyIntObject or PyLongObject based on the string
+ # value in str, which is interpreted according to the radix in
+ # base. If pend is non-NULL, *pend will point to the first
+ # character in str which follows the representation of the
+ # number. If base is 0, the radix will be determined based on the
+ # leading characters of str: if str starts with '0x' or '0X',
+ # radix 16 will be used; if str starts with '0', radix 8 will be
+ # used; otherwise radix 10 will be used. If base is not 0, it must
+ # be between 2 and 36, inclusive. Leading spaces are ignored. If
+ # there are no digits, ValueError will be raised. If the string
+ # represents a number too large to be contained within the
+ # machine's long int type and overflow warnings are being
+ # suppressed, a PyLongObject will be returned. If overflow
+ # warnings are not being suppressed, NULL will be returned in this
+ # case.
+
+ object PyInt_FromLong(long ival)
+ # Return value: New reference.
+ # Create a new integer object with a value of ival.
+ # The current implementation keeps an array of integer objects for
+ # all integers between -5 and 256, when you create an int in that
+ # range you actually just get back a reference to the existing
+ # object. So it should be possible to change the value of 1. I
+ # suspect the behaviour of Python in this case is undefined. :-)
+
+ object PyInt_FromSsize_t(Py_ssize_t ival)
+ # Return value: New reference.
+ # Create a new integer object with a value of ival. If the value
+ # is larger than LONG_MAX or smaller than LONG_MIN, a long integer
+ # object is returned.
+
+ object PyInt_FromSize_t(size_t ival)
+ # Return value: New reference.
+ # Create a new integer object with a value of ival. If the value
+ # exceeds LONG_MAX, a long integer object is returned.
+
+ long PyInt_AsLong(object io) except? -1
+ # Will first attempt to cast the object to a PyIntObject, if it is
+ # not already one, and then return its value. If there is an
+ # error, -1 is returned, and the caller should check
+ # PyErr_Occurred() to find out whether there was an error, or
+ # whether the value just happened to be -1.
+
+ long PyInt_AS_LONG(object io)
+ # Return the value of the object io. No error checking is performed.
+
+ unsigned long PyInt_AsUnsignedLongMask(object io) except? -1
+ # Will first attempt to cast the object to a PyIntObject or
+ # PyLongObject, if it is not already one, and then return its
+ # value as unsigned long. This function does not check for
+ # overflow.
+
+ PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1
+ # Will first attempt to cast the object to a PyIntObject or
+ # PyLongObject, if it is not already one, and then return its
+ # value as unsigned long long, without checking for overflow.
+
+ Py_ssize_t PyInt_AsSsize_t(object io) except? -1
+ # Will first attempt to cast the object to a PyIntObject or
+ # PyLongObject, if it is not already one, and then return its
+ # value as Py_ssize_t.
+
+ long PyInt_GetMax()
+ # Return the system's idea of the largest integer it can handle
+ # (LONG_MAX, as defined in the system header files).
+
+ int PyInt_ClearFreeList()
+ # Clear the integer free list. Return the number of items that could not be freed.
+ # New in version 2.6.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd b/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd
new file mode 100644
index 0000000000..0e10907f7f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/iterator.pxd
@@ -0,0 +1,36 @@
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 6.5 Iterator Protocol
+ ############################################################################
+ bint PyIter_Check(object o)
+ # Return true if the object o supports the iterator protocol.
+
+ object PyIter_Next(object o)
+ # Return value: New reference.
+ # Return the next value from the iteration o. If the object is an
+ # iterator, this retrieves the next value from the iteration, and
+ # returns NULL with no exception set if there are no remaining
+ # items. If the object is not an iterator, TypeError is raised, or
+ # if there is an error in retrieving the item, returns NULL and
+ # passes along the exception.
+
+ # To write a loop which iterates over an iterator, the C code should look something like this:
+ # PyObject *iterator = PyObject_GetIter(obj);
+ # PyObject *item;
+ # if (iterator == NULL) {
+ # /* propagate error */
+ # }
+ # while (item = PyIter_Next(iterator)) {
+ # /* do something with item */
+ # ...
+ # /* release reference when done */
+ # Py_DECREF(item);
+ # }
+ # Py_DECREF(iterator);
+ # if (PyErr_Occurred()) {
+ # /* propagate error */
+ # }
+ # else {
+ # /* continue doing useful work */
+ # }
diff --git a/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd b/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd
new file mode 100644
index 0000000000..a70aeccb09
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/iterobject.pxd
@@ -0,0 +1,24 @@
+cdef extern from "Python.h":
+
+ ###########################################################################
+ # Iterator Objects
+ ###########################################################################
+
+ bint PySeqIter_Check(object op)
+ # Return true if the type of op is PySeqIter_Type.
+
+ object PySeqIter_New(object seq)
+ # Return value: New reference.
+ # Return an iterator that works with a general sequence object, seq. The
+ # iteration ends when the sequence raises IndexError for the subscripting
+ # operation.
+
+ bint PyCallIter_Check(object op)
+ # Return true if the type of op is PyCallIter_Type.
+
+ object PyCallIter_New(object callable, object sentinel)
+ # Return value: New reference.
+ # Return a new iterator. The first parameter, callable, can be any Python
+ # callable object that can be called with no parameters; each call to it
+ # should return the next item in the iteration. When callable returns a
+ # value equal to sentinel, the iteration will be terminated.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/list.pxd b/contrib/tools/cython/Cython/Includes/cpython/list.pxd
new file mode 100644
index 0000000000..c6a29535c9
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/list.pxd
@@ -0,0 +1,92 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # Lists
+ ############################################################################
+ list PyList_New(Py_ssize_t len)
+ # Return a new list of length len on success, or NULL on failure.
+ #
+ # Note: If length is greater than zero, the returned list object's
+ # items are set to NULL. Thus you cannot use abstract API
+ # functions such as PySequence_SetItem() or expose the object to
+ # Python code before setting all items to a real object with
+ # PyList_SetItem().
+
+ bint PyList_Check(object p)
+ # Return true if p is a list object or an instance of a subtype of
+ # the list type.
+
+ bint PyList_CheckExact(object p)
+ # Return true if p is a list object, but not an instance of a
+ # subtype of the list type.
+
+ Py_ssize_t PyList_Size(object list) except -1
+ # Return the length of the list object in list; this is equivalent
+ # to "len(list)" on a list object.
+
+ Py_ssize_t PyList_GET_SIZE(object list)
+ # Macro form of PyList_Size() without error checking.
+
+ PyObject* PyList_GetItem(object list, Py_ssize_t index) except NULL
+ # Return value: Borrowed reference.
+ # Return the object at position pos in the list pointed to by
+ # p. The position must be positive, indexing from the end of the
+ # list is not supported. If pos is out of bounds, return NULL and
+ # set an IndexError exception.
+
+ PyObject* PyList_GET_ITEM(object list, Py_ssize_t i)
+ # Return value: Borrowed reference.
+ # Macro form of PyList_GetItem() without error checking.
+
+ 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.
+
+ 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*.
+
+ int PyList_Insert(object list, Py_ssize_t index, object item) except -1
+ # Insert the item item into list list in front of index
+ # index. Return 0 if successful; return -1 and set an exception if
+ # unsuccessful. Analogous to list.insert(index, item).
+
+ int PyList_Append(object list, object item) except -1
+ # Append the object item at the end of list list. Return 0 if
+ # successful; return -1 and set an exception if
+ # unsuccessful. Analogous to list.append(item).
+
+ list PyList_GetSlice(object list, Py_ssize_t low, Py_ssize_t high)
+ # Return value: New reference.
+ # Return a list of the objects in list containing the objects
+ # between low and high. Return NULL and set an exception if
+ # unsuccessful. Analogous to list[low:high].
+
+ int PyList_SetSlice(object list, Py_ssize_t low, Py_ssize_t high, object itemlist) except -1
+ # Set the slice of list between low and high to the contents of
+ # itemlist. Analogous to list[low:high] = itemlist. The itemlist
+ # may be NULL, indicating the assignment of an empty list (slice
+ # deletion). Return 0 on success, -1 on failure.
+
+ int PyList_Sort(object list) except -1
+ # Sort the items of list in place. Return 0 on success, -1 on
+ # failure. This is equivalent to "list.sort()".
+
+ int PyList_Reverse(object list) except -1
+ # Reverse the items of list in place. Return 0 on success, -1 on
+ # failure. This is the equivalent of "list.reverse()".
+
+ tuple PyList_AsTuple(object list)
+ # 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
new file mode 100644
index 0000000000..eb8140d417
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/long.pxd
@@ -0,0 +1,149 @@
+
+cdef extern from "Python.h":
+ ctypedef long long PY_LONG_LONG
+ ctypedef unsigned long long uPY_LONG_LONG "unsigned PY_LONG_LONG"
+
+ ############################################################################
+ # 7.2.3 Long Integer Objects
+ ############################################################################
+
+ # PyLongObject
+ #
+ # This subtype of PyObject represents a Python long integer object.
+
+ # PyTypeObject PyLong_Type
+ #
+ # This instance of PyTypeObject represents the Python long integer
+ # type. This is the same object as long and types.LongType.
+
+ bint PyLong_Check(object p)
+ # Return true if its argument is a PyLongObject or a subtype of PyLongObject.
+
+ bint PyLong_CheckExact(object p)
+ # Return true if its argument is a PyLongObject, but not a subtype of PyLongObject.
+
+ object PyLong_FromLong(long v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from v, or NULL on failure.
+
+ object PyLong_FromUnsignedLong(unsigned long v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from a C unsigned long, or NULL on failure.
+
+ object PyLong_FromSsize_t(Py_ssize_t v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from a C Py_ssize_t, or NULL on failure.)
+
+ object PyLong_FromSize_t(size_t v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from a C size_t, or NULL on failure.
+
+ object PyLong_FromLongLong(PY_LONG_LONG v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from a C long long, or NULL on failure.
+
+ object PyLong_FromUnsignedLongLong(uPY_LONG_LONG v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from a C unsigned long long, or NULL on failure.
+
+ object PyLong_FromDouble(double v)
+ # Return value: New reference.
+ # Return a new PyLongObject object from the integer part of v, or NULL on failure.
+
+ object PyLong_FromString(char *str, char **pend, int base)
+ # Return value: New reference.
+ # Return a new PyLongObject based on the string value in str,
+ # which is interpreted according to the radix in base. If pend is
+ # non-NULL, *pend will point to the first character in str which
+ # follows the representation of the number. If base is 0, the
+ # radix will be determined based on the leading characters of str:
+ # if str starts with '0x' or '0X', radix 16 will be used; if str
+ # starts with '0', radix 8 will be used; otherwise radix 10 will
+ # be used. If base is not 0, it must be between 2 and 36,
+ # inclusive. Leading spaces are ignored. If there are no digits,
+ # ValueError will be raised.
+
+ object PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
+ # Return value: New reference.
+ # Convert a sequence of Unicode digits to a Python long integer
+ # value. The first parameter, u, points to the first character of
+ # the Unicode string, length gives the number of characters, and
+ # base is the radix for the conversion. The radix must be in the
+ # range [2, 36]; if it is out of range, ValueError will be
+ # raised.
+
+ # object PyLong_FromUnicodeObject(object u, int base)
+ # Convert a sequence of Unicode digits in the string u to a Python integer
+ # value. The Unicode string is first encoded to a byte string using
+ # PyUnicode_EncodeDecimal() and then converted using PyLong_FromString().
+ # New in version 3.3.
+
+ object PyLong_FromVoidPtr(void *p)
+ # Return value: New reference.
+ # Create a Python integer or long integer from the pointer p. The
+ # pointer value can be retrieved from the resulting value using
+ # PyLong_AsVoidPtr(). If the integer is larger than LONG_MAX, a
+ # positive long integer is returned.
+
+ long PyLong_AsLong(object pylong) except? -1
+ # 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
+ # 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
+ # exception occurs (for example a TypeError or MemoryError), then -1 will
+ # be returned and *overflow will be 0.
+ # New in version 2.7.
+
+ # 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
+ # any other exception occurs (for example a TypeError or MemoryError), then
+ # -1 will be returned and *overflow will be 0.
+ # New in version 2.7.
+
+ Py_ssize_t PyLong_AsSsize_t(object pylong) except? -1
+ # Return a C Py_ssize_t representation of the contents of pylong. If pylong
+ # is greater than PY_SSIZE_T_MAX, an OverflowError is raised and -1 will be
+ # returned.
+
+ unsigned long PyLong_AsUnsignedLong(object pylong) except? -1
+ # Return a C unsigned long representation of the contents of
+ # pylong. If pylong is greater than ULONG_MAX, an OverflowError is
+ # raised.
+
+ PY_LONG_LONG PyLong_AsLongLong(object pylong) except? -1
+ # Return a C long long from a Python long integer. If pylong
+ # cannot be represented as a long long, an OverflowError will be
+ # raised.
+
+ uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) except? -1
+ #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong)
+ # Return a C unsigned long long from a Python long integer. If
+ # pylong cannot be represented as an unsigned long long, an
+ # OverflowError will be raised if the value is positive, or a
+ # TypeError will be raised if the value is negative.
+
+ unsigned long PyLong_AsUnsignedLongMask(object io) except? -1
+ # Return a C unsigned long from a Python long integer, without
+ # checking for overflow.
+
+ uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) except? -1
+ #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io)
+ # Return a C unsigned long long from a Python long integer,
+ # without checking for overflow.
+
+ double PyLong_AsDouble(object pylong) except? -1.0
+ # Return a C double representation of the contents of pylong. If
+ # pylong cannot be approximately represented as a double, an
+ # OverflowError exception is raised and -1.0 will be returned.
+
+ void* PyLong_AsVoidPtr(object pylong) except? NULL
+ # Convert a Python integer or long integer pylong to a C void
+ # pointer. If pylong cannot be converted, an OverflowError will be
+ # raised. This is only assured to produce a usable void pointer
+ # for values created with PyLong_FromVoidPtr(). For values outside
+ # 0..LONG_MAX, both signed and unsigned integers are accepted.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd b/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd
new file mode 100644
index 0000000000..c38c1bff88
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/longintrepr.pxd
@@ -0,0 +1,19 @@
+# Internals of the "long" type (Python 2) or "int" type (Python 3).
+
+cdef extern from "Python.h":
+ """
+ #if PY_MAJOR_VERSION < 3
+ #include "longintrepr.h"
+ #endif
+ """
+ ctypedef unsigned int digit
+ ctypedef int sdigit # Python >= 2.7 only
+
+ ctypedef class __builtin__.py_long [object PyLongObject]:
+ cdef digit* ob_digit
+
+ cdef py_long _PyLong_New(Py_ssize_t s)
+
+ cdef long PyLong_SHIFT
+ cdef digit PyLong_BASE
+ cdef digit PyLong_MASK
diff --git a/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd
new file mode 100644
index 0000000000..3d235b65e2
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/mapping.pxd
@@ -0,0 +1,64 @@
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 6.4 Mapping Protocol
+ ############################################################################
+
+ bint PyMapping_Check(object o)
+ # Return 1 if the object provides mapping protocol, and 0
+ # otherwise. This function always succeeds.
+
+ Py_ssize_t PyMapping_Length(object o) except -1
+ # Returns the number of keys in object o on success, and -1 on
+ # failure. For objects that do not provide mapping protocol, this
+ # is equivalent to the Python expression "len(o)".
+
+ int PyMapping_DelItemString(object o, char *key) except -1
+ # Remove the mapping for object key from the object o. Return -1
+ # on failure. This is equivalent to the Python statement "del
+ # o[key]".
+
+ int PyMapping_DelItem(object o, object key) except -1
+ # Remove the mapping for object key from the object o. Return -1
+ # on failure. This is equivalent to the Python statement "del
+ # o[key]".
+
+ bint PyMapping_HasKeyString(object o, char *key)
+ # On success, return 1 if the mapping object has the key key and 0
+ # otherwise. This is equivalent to the Python expression
+ # "o.has_key(key)". This function always succeeds.
+
+ bint PyMapping_HasKey(object o, object key)
+ # Return 1 if the mapping object has the key key and 0
+ # otherwise. This is equivalent to the Python expression
+ # "o.has_key(key)". This function always succeeds.
+
+ object PyMapping_Keys(object o)
+ # Return value: New reference.
+ # On success, return a list of the keys in object o. On failure,
+ # return NULL. This is equivalent to the Python expression
+ # "o.keys()".
+
+ object PyMapping_Values(object o)
+ # Return value: New reference.
+ # On success, return a list of the values in object o. On failure,
+ # return NULL. This is equivalent to the Python expression
+ # "o.values()".
+
+ object PyMapping_Items(object o)
+ # Return value: New reference.
+ # On success, return a list of the items in object o, where each
+ # item is a tuple containing a key-value pair. On failure, return
+ # NULL. This is equivalent to the Python expression "o.items()".
+
+ object PyMapping_GetItemString(object o, char *key)
+ # Return value: New reference.
+ # Return element of o corresponding to the object key or NULL on
+ # failure. This is the equivalent of the Python expression
+ # "o[key]".
+
+ int PyMapping_SetItemString(object o, char *key, object v) except -1
+ # 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/mem.pxd b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd
new file mode 100644
index 0000000000..af820f2ee0
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/mem.pxd
@@ -0,0 +1,111 @@
+cdef extern from "Python.h":
+
+ #####################################################################
+ # 9.2 Memory Interface
+ #####################################################################
+ # You are definitely *supposed* to use these: "In most situations,
+ # however, it is recommended to allocate memory from the Python
+ # heap specifically because the latter is under control of the
+ # Python memory manager. For example, this is required when the
+ # interpreter is extended with new object types written in
+ # C. Another reason for using the Python heap is the desire to
+ # inform the Python memory manager about the memory needs of the
+ # extension module. Even when the requested memory is used
+ # exclusively for internal, highly-specific purposes, delegating
+ # all memory requests to the Python memory manager causes the
+ # interpreter to have a more accurate image of its memory
+ # footprint as a whole. Consequently, under certain circumstances,
+ # the Python memory manager may or may not trigger appropriate
+ # actions, like garbage collection, memory compaction or other
+ # preventive procedures. Note that by using the C library
+ # allocator as shown in the previous example, the allocated memory
+ # for the I/O buffer escapes completely the Python memory
+ # manager."
+
+ # The following function sets, modeled after the ANSI C standard,
+ # but specifying behavior when requesting zero bytes, are
+ # available for allocating and releasing memory from the Python
+ # heap:
+
+ void* PyMem_RawMalloc(size_t n) nogil
+ void* PyMem_Malloc(size_t n)
+ # Allocates n bytes and returns a pointer of type void* to the
+ # allocated memory, or NULL if the request fails. Requesting zero
+ # bytes returns a distinct non-NULL pointer if possible, as if
+ # PyMem_Malloc(1) had been called instead. The memory will not
+ # have been initialized in any way.
+
+ 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
+ # contents will be unchanged to the minimum of the old and the new
+ # sizes. If p is NULL, the call is equivalent to PyMem_Malloc(n);
+ # 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().
+
+ 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
+ # before, undefined behavior occurs. If p is NULL, no operation is
+ # performed.
+
+ # The following type-oriented macros are provided for
+ # convenience. Note that TYPE refers to any C type.
+
+ # TYPE* PyMem_New(TYPE, size_t n)
+ # Same as PyMem_Malloc(), but allocates (n * sizeof(TYPE)) bytes
+ # of memory. Returns a pointer cast to TYPE*. The memory will not
+ # have been initialized in any way.
+
+ # TYPE* PyMem_Resize(void *p, TYPE, size_t n)
+ # Same as PyMem_Realloc(), but the memory block is resized to (n *
+ # sizeof(TYPE)) bytes. Returns a pointer cast to TYPE*.
+
+ void PyMem_Del(void *p)
+ # Same as PyMem_Free().
+
+ # In addition, the following macro sets are provided for calling
+ # the Python memory allocator directly, without involving the C
+ # API functions listed above. However, note that their use does
+ # not preserve binary compatibility across Python versions and is
+ # therefore deprecated in extension modules.
+
+ # PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
+ # PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().
+
+
+ #####################################################################
+ # Raw object memory interface
+ #####################################################################
+
+ # Functions to call the same malloc/realloc/free as used by Python's
+ # object allocator. If WITH_PYMALLOC is enabled, these may differ from
+ # the platform malloc/realloc/free. The Python object allocator is
+ # designed for fast, cache-conscious allocation of many "small" objects,
+ # and with low hidden memory overhead.
+ #
+ # PyObject_Malloc(0) returns a unique non-NULL pointer if possible.
+ #
+ # PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n).
+ # PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory
+ # at p.
+ #
+ # Returned pointers must be checked for NULL explicitly; no action is
+ # performed on failure other than to return NULL (no warning it printed, no
+ # exception is set, etc).
+ #
+ # For allocating objects, use PyObject_{New, NewVar} instead whenever
+ # possible. The PyObject_{Malloc, Realloc, Free} family is exposed
+ # so that you can exploit Python's small-block allocator for non-object
+ # uses. If you must use these routines to allocate object memory, make sure
+ # the object gets initialized via PyObject_{Init, InitVar} after obtaining
+ # the raw memory.
+
+ void* PyObject_Malloc(size_t size)
+ void* PyObject_Calloc(size_t nelem, size_t elsize)
+ void* PyObject_Realloc(void *ptr, size_t new_size)
+ void PyObject_Free(void *ptr)
diff --git a/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd b/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd
new file mode 100644
index 0000000000..83a84e6f91
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/memoryview.pxd
@@ -0,0 +1,50 @@
+cdef extern from "Python.h":
+
+ ###########################################################################
+ # MemoryView Objects
+ ###########################################################################
+ # A memoryview object exposes the C level buffer interface as a Python
+ # object which can then be passed around like any other object
+
+ object PyMemoryView_FromObject(object obj)
+ # Return value: New reference.
+ # Create a memoryview object from an object that provides the buffer
+ # interface. If obj supports writable buffer exports, the memoryview object
+ # will be read/write, otherwise it may be either read-only or read/write at
+ # the discretion of the exporter.
+
+ object PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags)
+ # Return value: New reference.
+ # Create a memoryview object using mem as the underlying buffer. flags can
+ # be one of PyBUF_READ or PyBUF_WRITE.
+ # New in version 3.3.
+
+ object PyMemoryView_FromBuffer(Py_buffer *view)
+ # Return value: New reference.
+ # Create a memoryview object wrapping the given buffer structure view. For
+ # simple byte buffers, PyMemoryView_FromMemory() is the preferred function.
+
+ object PyMemoryView_GetContiguous(object obj,
+ int buffertype,
+ char order)
+ # Return value: New reference.
+ # Create a memoryview object to a contiguous chunk of memory (in either ‘C’
+ # or ‘F’ortran order) from an object that defines the buffer interface. If
+ # memory is contiguous, the memoryview object points to the original
+ # memory. Otherwise, a copy is made and the memoryview points to a new
+ # bytes object.
+
+ bint PyMemoryView_Check(object obj)
+ # Return true if the object obj is a memoryview object. It is not currently
+ # allowed to create subclasses of memoryview.
+
+ Py_buffer *PyMemoryView_GET_BUFFER(object mview)
+ # Return a pointer to the memoryview’s private copy of the exporter’s
+ # buffer. mview must be a memoryview instance; this macro doesn’t check its
+ # type, you must do it yourself or you will risk crashes.
+
+ Py_buffer *PyMemoryView_GET_BASE(object mview)
+ # Return either a pointer to the exporting object that the memoryview is
+ # based on or NULL if the memoryview has been created by one of the
+ # functions PyMemoryView_FromMemory() or PyMemoryView_FromBuffer(). mview
+ # must be a memoryview instance.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/method.pxd b/contrib/tools/cython/Cython/Includes/cpython/method.pxd
new file mode 100644
index 0000000000..f51ebcc7c7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/method.pxd
@@ -0,0 +1,49 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ ############################################################################
+ # 7.5.4 Method Objects
+ ############################################################################
+
+ # There are some useful functions that are useful for working with method objects.
+ # PyTypeObject PyMethod_Type
+ # This instance of PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType.
+
+ bint PyMethod_Check(object o)
+ # Return true if o is a method object (has type
+ # PyMethod_Type). The parameter must not be NULL.
+
+ object PyMethod_New(object func, object self, object cls)
+ # Return value: New reference.
+ # Return a new method object, with func being any callable object;
+ # this is the function that will be called when the method is
+ # called. If this method should be bound to an instance, self
+ # should be the instance and class should be the class of self,
+ # otherwise self should be NULL and class should be the class
+ # which provides the unbound method..
+
+ PyObject* PyMethod_Class(object meth) except NULL
+ # Return value: Borrowed reference.
+ # Return the class object from which the method meth was created;
+ # if this was created from an instance, it will be the class of
+ # the instance.
+
+ PyObject* PyMethod_GET_CLASS(object meth)
+ # Return value: Borrowed reference.
+ # Macro version of PyMethod_Class() which avoids error checking.
+
+ PyObject* PyMethod_Function(object meth) except NULL
+ # Return value: Borrowed reference.
+ # Return the function object associated with the method meth.
+
+ PyObject* PyMethod_GET_FUNCTION(object meth)
+ # Return value: Borrowed reference.
+ # Macro version of PyMethod_Function() which avoids error checking.
+
+ PyObject* PyMethod_Self(object meth) except? NULL
+ # Return value: Borrowed reference.
+ # Return the instance associated with the method meth if it is bound, otherwise return NULL.
+
+ PyObject* PyMethod_GET_SELF(object meth)
+ # Return value: Borrowed reference.
+ # Macro version of PyMethod_Self() which avoids error checking.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/module.pxd b/contrib/tools/cython/Cython/Includes/cpython/module.pxd
new file mode 100644
index 0000000000..8eb323b010
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/module.pxd
@@ -0,0 +1,188 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ ctypedef struct _inittab
+
+ #####################################################################
+ # 5.3 Importing Modules
+ #####################################################################
+ object PyImport_ImportModule(const char *name)
+ # Return value: New reference.
+ # This is a simplified interface to PyImport_ImportModuleEx()
+ # below, leaving the globals and locals arguments set to
+ # NULL. When the name argument contains a dot (when it specifies a
+ # submodule of a package), the fromlist argument is set to the
+ # list ['*'] so that the return value is the named module rather
+ # than the top-level package containing it as would otherwise be
+ # the case. (Unfortunately, this has an additional side effect
+ # when name in fact specifies a subpackage instead of a submodule:
+ # the submodules specified in the package's __all__ variable are
+ # loaded.) Return a new reference to the imported module, or NULL
+ # with an exception set on failure.
+
+ object PyImport_ImportModuleEx(const char *name, object globals, object locals, object fromlist)
+ # Return value: New reference.
+
+ # Import a module. This is best described by referring to the
+ # built-in Python function __import__(), as the standard
+ # __import__() function calls this function directly.
+
+ # The return value is a new reference to the imported module or
+ # top-level package, or NULL with an exception set on failure
+ # (before Python 2.4, the module may still be created in this
+ # case). Like for __import__(), the return value when a submodule
+ # of a package was requested is normally the top-level package,
+ # unless a non-empty fromlist was given. Changed in version 2.4:
+ # failing imports remove incomplete module objects.
+
+ object PyImport_ImportModuleLevel(char *name, object globals, object locals, object fromlist, int level)
+ # Return value: New reference.
+
+ # Import a module. This is best described by referring to the
+ # built-in Python function __import__(), as the standard
+ # __import__() function calls this function directly.
+
+ # The return value is a new reference to the imported module or
+ # top-level package, or NULL with an exception set on failure. Like
+ # for __import__(), the return value when a submodule of a package
+ # was requested is normally the top-level package, unless a
+ # non-empty fromlist was given.
+
+ object PyImport_Import(object name)
+ # Return value: New reference.
+ # This is a higher-level interface that calls the current ``import
+ # hook function''. It invokes the __import__() function from the
+ # __builtins__ of the current globals. This means that the import
+ # is done using whatever import hooks are installed in the current
+ # environment, e.g. by rexec or ihooks.
+
+ object PyImport_ReloadModule(object m)
+ # Return value: New reference.
+ # Reload a module. This is best described by referring to the
+ # built-in Python function reload(), as the standard reload()
+ # function calls this function directly. Return a new reference to
+ # the reloaded module, or NULL with an exception set on failure
+ # (the module still exists in this case).
+
+ PyObject* PyImport_AddModule(const char *name) except NULL
+ # Return value: Borrowed reference.
+ # Return the module object corresponding to a module name. The
+ # name argument may be of the form package.module. First check the
+ # modules dictionary if there's one there, and if not, create a
+ # new one and insert it in the modules dictionary. Return NULL
+ # with an exception set on failure. Note: This function does not
+ # load or import the module; if the module wasn't already loaded,
+ # you will get an empty module object. Use PyImport_ImportModule()
+ # or one of its variants to import a module. Package structures
+ # implied by a dotted name for name are not created if not already
+ # present.
+
+ object PyImport_ExecCodeModule(char *name, object co)
+ # Return value: New reference.
+ # Given a module name (possibly of the form package.module) and a
+ # code object read from a Python bytecode file or obtained from
+ # the built-in function compile(), load the module. Return a new
+ # reference to the module object, or NULL with an exception set if
+ # an error occurred. Name is removed from sys.modules in error
+ # cases, and even if name was already in sys.modules on entry to
+ # PyImport_ExecCodeModule(). Leaving incompletely initialized
+ # modules in sys.modules is dangerous, as imports of such modules
+ # have no way to know that the module object is an unknown (and
+ # probably damaged with respect to the module author's intents)
+ # state.
+ # This function will reload the module if it was already
+ # imported. See PyImport_ReloadModule() for the intended way to
+ # reload a module.
+ # If name points to a dotted name of the form package.module, any
+ # package structures not already created will still not be
+ # created.
+
+
+ long PyImport_GetMagicNumber()
+ # Return the magic number for Python bytecode files (a.k.a. .pyc
+ # and .pyo files). The magic number should be present in the first
+ # four bytes of the bytecode file, in little-endian byte order.
+
+ PyObject* PyImport_GetModuleDict() except NULL
+ # Return value: Borrowed reference.
+ # Return the dictionary used for the module administration
+ # (a.k.a. sys.modules). Note that this is a per-interpreter
+ # variable.
+
+
+ int PyImport_ImportFrozenModule(char *name) except -1
+ # Load a frozen module named name. Return 1 for success, 0 if the
+ # module is not found, and -1 with an exception set if the
+ # initialization failed. To access the imported module on a
+ # successful load, use PyImport_ImportModule(). (Note the misnomer
+ # -- this function would reload the module if it was already
+ # imported.)
+
+
+ int PyImport_ExtendInittab(_inittab *newtab) except -1
+ # Add a collection of modules to the table of built-in
+ # modules. The newtab array must end with a sentinel entry which
+ # contains NULL for the name field; failure to provide the
+ # sentinel value can result in a memory fault. Returns 0 on
+ # success or -1 if insufficient memory could be allocated to
+ # extend the internal table. In the event of failure, no modules
+ # are added to the internal table. This should be called before
+ # Py_Initialize().
+
+ #####################################################################
+ # 7.5.5 Module Objects
+ #####################################################################
+
+ # PyTypeObject PyModule_Type
+ #
+ # This instance of PyTypeObject represents the Python module
+ # type. This is exposed to Python programs as types.ModuleType.
+
+ bint PyModule_Check(object p)
+ # Return true if p is a module object, or a subtype of a module
+ # object.
+
+ bint PyModule_CheckExact(object p)
+ # Return true if p is a module object, but not a subtype of PyModule_Type.
+
+ object PyModule_New(const char *name)
+ # Return value: New reference.
+ # Return a new module object with the __name__ attribute set to
+ # name. Only the module's __doc__ and __name__ attributes are
+ # filled in; the caller is responsible for providing a __file__
+ # attribute.
+
+ PyObject* PyModule_GetDict(object module) except NULL
+ # Return value: Borrowed reference.
+ # Return the dictionary object that implements module's namespace;
+ # this object is the same as the __dict__ attribute of the module
+ # object. This function never fails. It is recommended extensions
+ # use other PyModule_*() and PyObject_*() functions rather than
+ # directly manipulate a module's __dict__.
+
+ 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.
+
+ 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.
+
+ 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.
+
+ int PyModule_AddIntConstant(object module, const char *name, long value) except -1
+ # Add an integer constant to module as name. This convenience
+ # function can be used from the module's initialization
+ # function. Return -1 on error, 0 on success.
+
+ int PyModule_AddStringConstant(object module, const char *name, const char *value) except -1
+ # Add a string constant to module as name. This convenience
+ # function can be used from the module's initialization
+ # function. The string value must be null-terminated. Return -1 on
+ # error, 0 on success.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/number.pxd b/contrib/tools/cython/Cython/Includes/cpython/number.pxd
new file mode 100644
index 0000000000..ded35c292a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/number.pxd
@@ -0,0 +1,265 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ #####################################################################
+ # 6.2 Number Protocol
+ #####################################################################
+
+ bint PyNumber_Check(object o)
+ # Returns 1 if the object o provides numeric protocols, and false
+ # otherwise. This function always succeeds.
+
+ object PyNumber_Add(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of adding o1 and o2, or NULL on failure. This
+ # is the equivalent of the Python expression "o1 + o2".
+
+ object PyNumber_Subtract(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of subtracting o2 from o1, or NULL on
+ # failure. This is the equivalent of the Python expression "o1 -
+ # o2".
+
+ object PyNumber_Multiply(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of multiplying o1 and o2, or NULL on
+ # failure. This is the equivalent of the Python expression "o1 *
+ # o2".
+
+ object PyNumber_MatrixMultiply(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of matrix multiplication on o1 and o2, or
+ # NULL on failure. This is the equivalent of the Python
+ # expression "o1 @ o2".
+ # New in version 3.5.
+
+ object PyNumber_Divide(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of dividing o1 by o2, or NULL on
+ # failure. This is the equivalent of the Python expression "o1 /
+ # o2".
+
+ object PyNumber_FloorDivide(object o1, object o2)
+ # Return value: New reference.
+ # Return the floor of o1 divided by o2, or NULL on failure. This
+ # is equivalent to the ``classic'' division of integers.
+
+ object PyNumber_TrueDivide(object o1, object o2)
+ # Return value: New reference.
+ # Return a reasonable approximation for the mathematical value of
+ # o1 divided by o2, or NULL on failure. The return value is
+ # ``approximate'' because binary floating point numbers are
+ # approximate; it is not possible to represent all real numbers in
+ # base two. This function can return a floating point value when
+ # passed two integers.
+
+ object PyNumber_Remainder(object o1, object o2)
+ # Return value: New reference.
+ # Returns the remainder of dividing o1 by o2, or NULL on
+ # failure. This is the equivalent of the Python expression "o1 %
+ # o2".
+
+ object PyNumber_Divmod(object o1, object o2)
+ # Return value: New reference.
+ # See the built-in function divmod(). Returns NULL on
+ # failure. This is the equivalent of the Python expression
+ # "divmod(o1, o2)".
+
+ object PyNumber_Power(object o1, object o2, object o3)
+ # Return value: New reference.
+ # See the built-in function pow(). Returns NULL on failure. This
+ # is the equivalent of the Python expression "pow(o1, o2, o3)",
+ # where o3 is optional. If o3 is to be ignored, pass Py_None in
+ # its place (passing NULL for o3 would cause an illegal memory
+ # access).
+
+ object PyNumber_Negative(object o)
+ # Return value: New reference.
+ # Returns the negation of o on success, or NULL on failure. This
+ # is the equivalent of the Python expression "-o".
+
+ object PyNumber_Positive(object o)
+ # Return value: New reference.
+ # Returns o on success, or NULL on failure. This is the equivalent
+ # of the Python expression "+o".
+
+ object PyNumber_Absolute(object o)
+ # Return value: New reference.
+ # Returns the absolute value of o, or NULL on failure. This is the
+ # equivalent of the Python expression "abs(o)".
+
+ object PyNumber_Invert(object o)
+ # Return value: New reference.
+ # Returns the bitwise negation of o on success, or NULL on
+ # failure. This is the equivalent of the Python expression "~o".
+
+ object PyNumber_Lshift(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of left shifting o1 by o2 on success, or NULL
+ # on failure. This is the equivalent of the Python expression "o1
+ # << o2".
+
+ object PyNumber_Rshift(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of right shifting o1 by o2 on success, or
+ # NULL on failure. This is the equivalent of the Python expression
+ # "o1 >> o2".
+
+ object PyNumber_And(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
+ # failure. This is the equivalent of the Python expression "o1 &
+ # o2".
+
+ object PyNumber_Xor(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
+ # NULL on failure. This is the equivalent of the Python expression
+ # "o1 ^ o2".
+
+ object PyNumber_Or(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on failure. This is the equivalent of the Python expression "o1 | o2".
+
+ object PyNumber_InPlaceAdd(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of adding o1 and o2, or NULL on failure. The
+ # operation is done in-place when o1 supports it. This is the
+ # equivalent of the Python statement "o1 += o2".
+
+ object PyNumber_InPlaceSubtract(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of subtracting o2 from o1, or NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 -= o2".
+
+ object PyNumber_InPlaceMultiply(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of multiplying o1 and o2, or NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 *= o2".
+
+ object PyNumber_InPlaceMatrixMultiply(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of matrix multiplication on o1 and o2, or
+ # NULL on failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 @= o2".
+ # New in version 3.5.
+
+ object PyNumber_InPlaceDivide(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of dividing o1 by o2, or NULL on failure. The
+ # operation is done in-place when o1 supports it. This is the
+ # equivalent of the Python statement "o1 /= o2".
+
+ object PyNumber_InPlaceFloorDivide(object o1, object o2)
+ # Return value: New reference.
+ # Returns the mathematical floor of dividing o1 by o2, or NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 //=
+ # o2".
+
+ object PyNumber_InPlaceTrueDivide(object o1, object o2)
+ # Return value: New reference.
+ # Return a reasonable approximation for the mathematical value of
+ # o1 divided by o2, or NULL on failure. The return value is
+ # ``approximate'' because binary floating point numbers are
+ # approximate; it is not possible to represent all real numbers in
+ # base two. This function can return a floating point value when
+ # passed two integers. The operation is done in-place when o1
+ # supports it.
+
+ object PyNumber_InPlaceRemainder(object o1, object o2)
+ # Return value: New reference.
+ # Returns the remainder of dividing o1 by o2, or NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 %= o2".
+
+ object PyNumber_InPlacePower(object o1, object o2, object o3)
+ # Return value: New reference.
+ # See the built-in function pow(). Returns NULL on failure. The
+ # operation is done in-place when o1 supports it. This is the
+ # equivalent of the Python statement "o1 **= o2" when o3 is
+ # Py_None, or an in-place variant of "pow(o1, o2, o3)"
+ # otherwise. If o3 is to be ignored, pass Py_None in its place
+ # (passing NULL for o3 would cause an illegal memory access).
+
+ object PyNumber_InPlaceLshift(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of left shifting o1 by o2 on success, or NULL
+ # on failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 <<= o2".
+
+ object PyNumber_InPlaceRshift(object o1, object o2)
+ # Return value: New reference.
+ # Returns the result of right shifting o1 by o2 on success, or
+ # NULL on failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 >>= o2".
+
+ object PyNumber_InPlaceAnd(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 &= o2".
+
+ object PyNumber_InPlaceXor(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
+ # NULL on failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 ^= o2".
+
+ object PyNumber_InPlaceOr(object o1, object o2)
+ # Return value: New reference.
+ # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python statement "o1 |= o2".
+
+ int PyNumber_Coerce(PyObject **p1, PyObject **p2) except -1
+ # This function takes the addresses of two variables of type
+ # PyObject*. If the objects pointed to by *p1 and *p2 have the
+ # same type, increment their reference count and return 0
+ # (success). If the objects can be converted to a common numeric
+ # type, replace *p1 and *p2 by their converted value (with 'new'
+ # reference counts), and return 0. If no conversion is possible,
+ # or if some other error occurs, return -1 (failure) and don't
+ # increment the reference counts. The call PyNumber_Coerce(&o1,
+ # &o2) is equivalent to the Python statement "o1, o2 = coerce(o1,
+ # o2)".
+
+ object PyNumber_Int(object o)
+ # Return value: New reference.
+ # Returns the o converted to an integer object on success, or NULL
+ # on failure. If the argument is outside the integer range a long
+ # object will be returned instead. This is the equivalent of the
+ # Python expression "int(o)".
+
+ object PyNumber_Long(object o)
+ # Return value: New reference.
+ # Returns the o converted to a long integer object on success, or
+ # NULL on failure. This is the equivalent of the Python expression
+ # "long(o)".
+
+ object PyNumber_Float(object o)
+ # Return value: New reference.
+ # Returns the o converted to a float object on success, or NULL on
+ # failure. This is the equivalent of the Python expression
+ # "float(o)".
+
+ object PyNumber_Index(object o)
+ # Returns the o converted to a Python int or long on success or
+ # NULL with a TypeError exception raised on failure.
+
+ Py_ssize_t PyNumber_AsSsize_t(object o, object exc) except? -1
+ # Returns o converted to a Py_ssize_t value if o can be
+ # interpreted as an integer. If o can be converted to a Python int
+ # or long but the attempt to convert to a Py_ssize_t value would
+ # raise an OverflowError, then the exc argument is the type of
+ # exception that will be raised (usually IndexError or
+ # OverflowError). If exc is NULL, then the exception is cleared
+ # and the value is clipped to PY_SSIZE_T_MIN for a negative
+ # integer or PY_SSIZE_T_MAX for a positive integer.
+
+ bint PyIndex_Check(object)
+ # Returns True if o is an index integer (has the nb_index slot of
+ # the tp_as_number structure filled in).
diff --git a/contrib/tools/cython/Cython/Includes/cpython/object.pxd b/contrib/tools/cython/Cython/Includes/cpython/object.pxd
new file mode 100644
index 0000000000..5a81166393
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/object.pxd
@@ -0,0 +1,399 @@
+from libc.stdio cimport FILE
+cimport cpython.type
+
+cdef extern from "Python.h":
+
+ ctypedef struct PyObject # forward declaration
+
+ ctypedef object (*newfunc)(cpython.type.type, object, object) # (type, args, kwargs)
+
+ ctypedef object (*unaryfunc)(object)
+ ctypedef object (*binaryfunc)(object, object)
+ ctypedef object (*ternaryfunc)(object, object, object)
+ ctypedef int (*inquiry)(object) except -1
+ ctypedef Py_ssize_t (*lenfunc)(object) except -1
+ ctypedef object (*ssizeargfunc)(object, Py_ssize_t)
+ ctypedef object (*ssizessizeargfunc)(object, Py_ssize_t, Py_ssize_t)
+ ctypedef int (*ssizeobjargproc)(object, Py_ssize_t, object) except -1
+ ctypedef int (*ssizessizeobjargproc)(object, Py_ssize_t, Py_ssize_t, object) except -1
+ ctypedef int (*objobjargproc)(object, object, object) except -1
+ ctypedef int (*objobjproc)(object, object) except -1
+
+ ctypedef Py_hash_t (*hashfunc)(object) except -1
+ ctypedef object (*reprfunc)(object)
+
+ ctypedef int (*cmpfunc)(object, object) except -2
+ ctypedef object (*richcmpfunc)(object, object, int)
+
+ # The following functions use 'PyObject*' as first argument instead of 'object' to prevent
+ # accidental reference counting when calling them during a garbage collection run.
+ ctypedef void (*destructor)(PyObject*)
+ ctypedef int (*visitproc)(PyObject*, void *) except -1
+ ctypedef int (*traverseproc)(PyObject*, visitproc, void*) except -1
+ ctypedef void (*freefunc)(void*)
+
+ ctypedef object (*descrgetfunc)(object, object, object)
+ ctypedef int (*descrsetfunc)(object, object, object) except -1
+
+ ctypedef struct PyTypeObject:
+ const char* tp_name
+ const char* tp_doc
+ Py_ssize_t tp_basicsize
+ Py_ssize_t tp_itemsize
+ Py_ssize_t tp_dictoffset
+ unsigned long tp_flags
+
+ newfunc tp_new
+ destructor tp_dealloc
+ traverseproc tp_traverse
+ inquiry tp_clear
+ freefunc tp_free
+
+ ternaryfunc tp_call
+ hashfunc tp_hash
+ reprfunc tp_str
+ reprfunc tp_repr
+
+ cmpfunc tp_compare
+ richcmpfunc tp_richcompare
+
+ PyTypeObject* tp_base
+ PyObject* tp_dict
+
+ descrgetfunc tp_descr_get
+ descrsetfunc tp_descr_set
+
+ ctypedef struct PyObject:
+ Py_ssize_t ob_refcnt
+ PyTypeObject *ob_type
+
+ cdef PyTypeObject *Py_TYPE(object)
+
+ void* PyObject_Malloc(size_t)
+ void* PyObject_Realloc(void *, size_t)
+ void PyObject_Free(void *)
+
+ #####################################################################
+ # 6.1 Object Protocol
+ #####################################################################
+ int PyObject_Print(object o, FILE *fp, int flags) except -1
+ # Print an object o, on file fp. Returns -1 on error. The flags
+ # argument is used to enable certain printing options. The only
+ # option currently supported is Py_PRINT_RAW; if given, the str()
+ # of the object is written instead of the repr().
+
+ bint PyObject_HasAttrString(object o, const char *attr_name)
+ # Returns 1 if o has the attribute attr_name, and 0
+ # otherwise. This is equivalent to the Python expression
+ # "hasattr(o, attr_name)". This function always succeeds.
+
+ object PyObject_GetAttrString(object o, const char *attr_name)
+ # Return value: New reference. Retrieve an attribute named
+ # attr_name from object o. Returns the attribute value on success,
+ # or NULL on failure. This is the equivalent of the Python
+ # expression "o.attr_name".
+
+ bint PyObject_HasAttr(object o, object attr_name)
+ # Returns 1 if o has the attribute attr_name, and 0
+ # otherwise. This is equivalent to the Python expression
+ # "hasattr(o, attr_name)". This function always succeeds.
+
+ object PyObject_GetAttr(object o, object attr_name)
+ # Return value: New reference. Retrieve an attribute named
+ # attr_name from object o. Returns the attribute value on success,
+ # or NULL on failure. This is the equivalent of the Python
+ # expression "o.attr_name".
+
+ object PyObject_GenericGetAttr(object o, object attr_name)
+
+ int PyObject_SetAttrString(object o, const char *attr_name, object v) except -1
+ # Set the value of the attribute named attr_name, for object o, to
+ # the value v. Returns -1 on failure. This is the equivalent of
+ # the Python statement "o.attr_name = v".
+
+ int PyObject_SetAttr(object o, object attr_name, object v) except -1
+ # Set the value of the attribute named attr_name, for object o, to
+ # the value v. Returns -1 on failure. This is the equivalent of
+ # the Python statement "o.attr_name = v".
+
+ int PyObject_GenericSetAttr(object o, object attr_name, object v) except -1
+
+ int PyObject_DelAttrString(object o, const char *attr_name) except -1
+ # Delete attribute named attr_name, for object o. Returns -1 on
+ # failure. This is the equivalent of the Python statement: "del
+ # o.attr_name".
+
+ int PyObject_DelAttr(object o, object attr_name) except -1
+ # Delete attribute named attr_name, for object o. Returns -1 on
+ # failure. This is the equivalent of the Python statement "del
+ # o.attr_name".
+
+ int Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+
+ object PyObject_RichCompare(object o1, object o2, int opid)
+ # Return value: New reference.
+ # Compare the values of o1 and o2 using the operation specified by
+ # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
+ # Py_GE, corresponding to <, <=, ==, !=, >, or >=
+ # respectively. This is the equivalent of the Python expression
+ # "o1 op o2", where op is the operator corresponding to
+ # opid. Returns the value of the comparison on success, or NULL on
+ # failure.
+
+ bint PyObject_RichCompareBool(object o1, object o2, int opid) except -1
+ # Compare the values of o1 and o2 using the operation specified by
+ # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
+ # Py_GE, corresponding to <, <=, ==, !=, >, or >=
+ # respectively. Returns -1 on error, 0 if the result is false, 1
+ # otherwise. This is the equivalent of the Python expression "o1
+ # op o2", where op is the operator corresponding to opid.
+
+ int PyObject_Cmp(object o1, object o2, int *result) except -1
+ # Compare the values of o1 and o2 using a routine provided by o1,
+ # if one exists, otherwise with a routine provided by o2. The
+ # result of the comparison is returned in result. Returns -1 on
+ # failure. This is the equivalent of the Python statement "result
+ # = cmp(o1, o2)".
+
+ int PyObject_Compare(object o1, object o2) except *
+ # Compare the values of o1 and o2 using a routine provided by o1,
+ # if one exists, otherwise with a routine provided by o2. Returns
+ # the result of the comparison on success. On error, the value
+ # returned is undefined; use PyErr_Occurred() to detect an
+ # error. This is equivalent to the Python expression "cmp(o1,
+ # o2)".
+
+ object PyObject_Repr(object o)
+ # Return value: New reference.
+ # Compute a string representation of object o. Returns the string
+ # representation on success, NULL on failure. This is the
+ # equivalent of the Python expression "repr(o)". Called by the
+ # repr() built-in function and by reverse quotes.
+
+ object PyObject_Str(object o)
+ # Return value: New reference.
+ # Compute a string representation of object o. Returns the string
+ # representation on success, NULL on failure. This is the
+ # equivalent of the Python expression "str(o)". Called by the
+ # str() built-in function and by the print statement.
+
+ object PyObject_Unicode(object o)
+ # Return value: New reference.
+ # Compute a Unicode string representation of object o. Returns the
+ # Unicode string representation on success, NULL on failure. This
+ # is the equivalent of the Python expression "unicode(o)". Called
+ # by the unicode() built-in function.
+
+ bint PyObject_IsInstance(object inst, object cls) except -1
+ # Returns 1 if inst is an instance of the class cls or a subclass
+ # of cls, or 0 if not. On error, returns -1 and sets an
+ # exception. If cls is a type object rather than a class object,
+ # PyObject_IsInstance() returns 1 if inst is of type cls. If cls
+ # is a tuple, the check will be done against every entry in
+ # cls. The result will be 1 when at least one of the checks
+ # returns 1, otherwise it will be 0. If inst is not a class
+ # instance and cls is neither a type object, nor a class object,
+ # nor a tuple, inst must have a __class__ attribute -- the class
+ # relationship of the value of that attribute with cls will be
+ # used to determine the result of this function.
+
+ # Subclass determination is done in a fairly straightforward way,
+ # but includes a wrinkle that implementors of extensions to the
+ # class system may want to be aware of. If A and B are class
+ # objects, B is a subclass of A if it inherits from A either
+ # directly or indirectly. If either is not a class object, a more
+ # general mechanism is used to determine the class relationship of
+ # the two objects. When testing if B is a subclass of A, if A is
+ # B, PyObject_IsSubclass() returns true. If A and B are different
+ # objects, B's __bases__ attribute is searched in a depth-first
+ # fashion for A -- the presence of the __bases__ attribute is
+ # considered sufficient for this determination.
+
+ bint PyObject_IsSubclass(object derived, object cls) except -1
+ # Returns 1 if the class derived is identical to or derived from
+ # the class cls, otherwise returns 0. In case of an error, returns
+ # -1. If cls is a tuple, the check will be done against every
+ # entry in cls. The result will be 1 when at least one of the
+ # checks returns 1, otherwise it will be 0. If either derived or
+ # cls is not an actual class object (or tuple), this function uses
+ # the generic algorithm described above. New in version
+ # 2.1. Changed in version 2.3: Older versions of Python did not
+ # support a tuple as the second argument.
+
+ bint PyCallable_Check(object o)
+ # Determine if the object o is callable. Return 1 if the object is
+ # callable and 0 otherwise. This function always succeeds.
+
+ object PyObject_Call(object callable_object, object args, object kw)
+ # Return value: New reference.
+ # Call a callable Python object callable_object, with arguments
+ # given by the tuple args, and named arguments given by the
+ # dictionary kw. If no named arguments are needed, kw may be
+ # NULL. args must not be NULL, use an empty tuple if no arguments
+ # are needed. Returns the result of the call on success, or NULL
+ # on failure. This is the equivalent of the Python expression
+ # "apply(callable_object, args, kw)" or "callable_object(*args,
+ # **kw)".
+
+ object PyObject_CallObject(object callable_object, object args)
+ # Return value: New reference.
+ # Call a callable Python object callable_object, with arguments
+ # given by the tuple args. If no arguments are needed, then args
+ # may be NULL. Returns the result of the call on success, or NULL
+ # on failure. This is the equivalent of the Python expression
+ # "apply(callable_object, args)" or "callable_object(*args)".
+
+ object PyObject_CallFunction(object callable, char *format, ...)
+ # Return value: New reference.
+ # Call a callable Python object callable, with a variable number
+ # of C arguments. The C arguments are described using a
+ # Py_BuildValue() style format string. The format may be NULL,
+ # indicating that no arguments are provided. Returns the result of
+ # the call on success, or NULL on failure. This is the equivalent
+ # of the Python expression "apply(callable, args)" or
+ # "callable(*args)". Note that if you only pass object args,
+ # PyObject_CallFunctionObjArgs is a faster alternative.
+
+ object PyObject_CallMethod(object o, char *method, char *format, ...)
+ # Return value: New reference.
+ # Call the method named method of object o with a variable number
+ # of C arguments. The C arguments are described by a
+ # Py_BuildValue() format string that should produce a tuple. The
+ # format may be NULL, indicating that no arguments are
+ # provided. Returns the result of the call on success, or NULL on
+ # failure. This is the equivalent of the Python expression
+ # "o.method(args)". Note that if you only pass object args,
+ # PyObject_CallMethodObjArgs is a faster alternative.
+
+ #object PyObject_CallFunctionObjArgs(object callable, ..., NULL)
+ object PyObject_CallFunctionObjArgs(object callable, ...)
+ # Return value: New reference.
+ # Call a callable Python object callable, with a variable number
+ # of PyObject* arguments. The arguments are provided as a variable
+ # number of parameters followed by NULL. Returns the result of the
+ # call on success, or NULL on failure.
+
+ #PyObject* PyObject_CallMethodObjArgs(object o, object name, ..., NULL)
+ object PyObject_CallMethodObjArgs(object o, object name, ...)
+ # Return value: New reference.
+ # Calls a method of the object o, where the name of the method is
+ # given as a Python string object in name. It is called with a
+ # variable number of PyObject* arguments. The arguments are
+ # provided as a variable number of parameters followed by
+ # NULL. Returns the result of the call on success, or NULL on
+ # failure.
+
+ long PyObject_Hash(object o) except? -1
+ # Compute and return the hash value of an object o. On failure,
+ # return -1. This is the equivalent of the Python expression
+ # "hash(o)".
+
+ bint PyObject_IsTrue(object o) except -1
+ # Returns 1 if the object o is considered to be true, and 0
+ # otherwise. This is equivalent to the Python expression "not not
+ # o". On failure, return -1.
+
+ bint PyObject_Not(object o) except -1
+ # Returns 0 if the object o is considered to be true, and 1
+ # otherwise. This is equivalent to the Python expression "not
+ # o". On failure, return -1.
+
+ object PyObject_Type(object o)
+ # Return value: New reference.
+ # When o is non-NULL, returns a type object corresponding to the
+ # object type of object o. On failure, raises SystemError and
+ # returns NULL. This is equivalent to the Python expression
+ # type(o). This function increments the reference count of the
+ # return value. There's really no reason to use this function
+ # instead of the common expression o->ob_type, which returns a
+ # pointer of type PyTypeObject*, except when the incremented
+ # reference count is needed.
+
+ bint PyObject_TypeCheck(object o, PyTypeObject *type)
+ # Return true if the object o is of type type or a subtype of
+ # type. Both parameters must be non-NULL.
+
+ Py_ssize_t PyObject_Length(object o) except -1
+ Py_ssize_t PyObject_Size(object o) except -1
+ # Return the length of object o. If the object o provides either
+ # the sequence and mapping protocols, the sequence length is
+ # returned. On error, -1 is returned. This is the equivalent to
+ # the Python expression "len(o)".
+
+ object PyObject_GetItem(object o, object key)
+ # Return value: New reference.
+ # Return element of o corresponding to the object key or NULL on
+ # failure. This is the equivalent of the Python expression
+ # "o[key]".
+
+ int PyObject_SetItem(object o, object key, object v) except -1
+ # Map the object key to the value v. Returns -1 on failure. This
+ # is the equivalent of the Python statement "o[key] = v".
+
+ int PyObject_DelItem(object o, object key) except -1
+ # Delete the mapping for key from o. Returns -1 on failure. This
+ # is the equivalent of the Python statement "del o[key]".
+
+ int PyObject_AsFileDescriptor(object o) except -1
+ # Derives a file-descriptor from a Python object. If the object is
+ # an integer or long integer, its value is returned. If not, the
+ # object's fileno() method is called if it exists; the method must
+ # return an integer or long integer, which is returned as the file
+ # descriptor value. Returns -1 on failure.
+
+ object PyObject_Dir(object o)
+ # Return value: New reference.
+ # This is equivalent to the Python expression "dir(o)", returning
+ # a (possibly empty) list of strings appropriate for the object
+ # argument, or NULL if there was an error. If the argument is
+ # NULL, this is like the Python "dir()", returning the names of
+ # the current locals; in this case, if no execution frame is
+ # active then NULL is returned but PyErr_Occurred() will return
+ # false.
+
+ object PyObject_GetIter(object o)
+ # Return value: New reference.
+ # This is equivalent to the Python expression "iter(o)". It
+ # returns a new iterator for the object argument, or the object
+ # itself if the object is already an iterator. Raises TypeError
+ # and returns NULL if the object cannot be iterated.
+
+ Py_ssize_t Py_SIZE(object o)
+
+ object PyObject_Format(object obj, object format_spec)
+ # Takes an arbitrary object and returns the result of calling
+ # obj.__format__(format_spec).
+ # Added in Py2.6
+
+ # Type flags (tp_flags of PyTypeObject)
+ long Py_TPFLAGS_HAVE_GETCHARBUFFER
+ long Py_TPFLAGS_HAVE_SEQUENCE_IN
+ long Py_TPFLAGS_HAVE_INPLACEOPS
+ long Py_TPFLAGS_CHECKTYPES
+ long Py_TPFLAGS_HAVE_RICHCOMPARE
+ long Py_TPFLAGS_HAVE_WEAKREFS
+ long Py_TPFLAGS_HAVE_ITER
+ long Py_TPFLAGS_HAVE_CLASS
+ long Py_TPFLAGS_HEAPTYPE
+ long Py_TPFLAGS_BASETYPE
+ long Py_TPFLAGS_READY
+ long Py_TPFLAGS_READYING
+ long Py_TPFLAGS_HAVE_GC
+ long Py_TPFLAGS_HAVE_STACKLESS_EXTENSION
+ long Py_TPFLAGS_HAVE_INDEX
+ long Py_TPFLAGS_HAVE_VERSION_TAG
+ long Py_TPFLAGS_VALID_VERSION_TAG
+ long Py_TPFLAGS_IS_ABSTRACT
+ long Py_TPFLAGS_HAVE_NEWBUFFER
+ long Py_TPFLAGS_INT_SUBCLASS
+ long Py_TPFLAGS_LONG_SUBCLASS
+ long Py_TPFLAGS_LIST_SUBCLASS
+ long Py_TPFLAGS_TUPLE_SUBCLASS
+ long Py_TPFLAGS_STRING_SUBCLASS
+ long Py_TPFLAGS_UNICODE_SUBCLASS
+ long Py_TPFLAGS_DICT_SUBCLASS
+ long Py_TPFLAGS_BASE_EXC_SUBCLASS
+ long Py_TPFLAGS_TYPE_SUBCLASS
+ long Py_TPFLAGS_DEFAULT_EXTERNAL
+ long Py_TPFLAGS_DEFAULT_CORE
+ long Py_TPFLAGS_DEFAULT
diff --git a/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd b/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd
new file mode 100644
index 0000000000..0222428ed4
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/oldbuffer.pxd
@@ -0,0 +1,63 @@
+# Legacy Python 2 buffer interface.
+#
+# These functions are no longer available in Python 3, use the new
+# buffer interface instead.
+
+cdef extern from "Python.h":
+ cdef enum _:
+ Py_END_OF_BUFFER
+ # This constant may be passed as the size parameter to
+ # PyBuffer_FromObject() or PyBuffer_FromReadWriteObject(). It
+ # indicates that the new PyBufferObject should refer to base object
+ # from the specified offset to the end of its exported
+ # buffer. Using this enables the caller to avoid querying the base
+ # object for its length.
+
+ bint PyBuffer_Check(object p)
+ # Return true if the argument has type PyBuffer_Type.
+
+ object PyBuffer_FromObject(object base, Py_ssize_t offset, Py_ssize_t size)
+ # Return value: New reference.
+ #
+ # Return a new read-only buffer object. This raises TypeError if
+ # base doesn't support the read-only buffer protocol or doesn't
+ # provide exactly one buffer segment, or it raises ValueError if
+ # offset is less than zero. The buffer will hold a reference to the
+ # base object, and the buffer's contents will refer to the base
+ # object's buffer interface, starting as position offset and
+ # extending for size bytes. If size is Py_END_OF_BUFFER, then the
+ # new buffer's contents extend to the length of the base object's
+ # exported buffer data.
+
+ object PyBuffer_FromReadWriteObject(object base, Py_ssize_t offset, Py_ssize_t size)
+ # Return value: New reference.
+ #
+ # Return a new writable buffer object. Parameters and exceptions
+ # are similar to those for PyBuffer_FromObject(). If the base
+ # object does not export the writeable buffer protocol, then
+ # TypeError is raised.
+
+ object PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
+ # Return value: New reference.
+ #
+ # Return a new read-only buffer object that reads from a specified
+ # location in memory, with a specified size. The caller is
+ # responsible for ensuring that the memory buffer, passed in as
+ # ptr, is not deallocated while the returned buffer object
+ # exists. Raises ValueError if size is less than zero. Note that
+ # Py_END_OF_BUFFER may not be passed for the size parameter;
+ # ValueError will be raised in that case.
+
+ object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
+ # Return value: New reference.
+ #
+ # Similar to PyBuffer_FromMemory(), but the returned buffer is
+ # writable.
+
+ object PyBuffer_New(Py_ssize_t size)
+ # Return value: New reference.
+ #
+ # Return a new writable buffer object that maintains its own memory
+ # buffer of size bytes. ValueError is returned if size is not zero
+ # or positive. Note that the memory buffer (as returned by
+ # PyObject_AsWriteBuffer()) is not specifically aligned.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd
new file mode 100644
index 0000000000..c3d12c7490
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/pycapsule.pxd
@@ -0,0 +1,144 @@
+
+# available since Python 3.1!
+
+
+cdef extern from "Python.h":
+
+ ctypedef struct PyCapsule_Type
+ # This subtype of PyObject represents an opaque value, useful for
+ # C extension modules who need to pass an opaque value (as a void*
+ # pointer) through Python code to other C code. It is often used
+ # to make a C function pointer defined in one module available to
+ # other modules, so the regular import mechanism can be used to
+ # access C APIs defined in dynamically loaded modules.
+
+
+ ctypedef void (*PyCapsule_Destructor)(object o)
+ # The type of a destructor callback for a capsule.
+ #
+ # See PyCapsule_New() for the semantics of PyCapsule_Destructor
+ # callbacks.
+
+
+ bint PyCapsule_CheckExact(object o)
+ # Return true if its argument is a PyCapsule.
+
+
+ object PyCapsule_New(void *pointer, const char *name,
+ PyCapsule_Destructor destructor)
+ # Return value: New reference.
+ #
+ # Create a PyCapsule encapsulating the pointer. The pointer
+ # argument may not be NULL.
+ #
+ # On failure, set an exception and return NULL.
+ #
+ # The name string may either be NULL or a pointer to a valid C
+ # string. If non-NULL, this string must outlive the
+ # capsule. (Though it is permitted to free it inside the
+ # destructor.)
+ #
+ # If the destructor argument is not NULL, it will be called with
+ # the capsule as its argument when it is destroyed.
+ #
+ # If this capsule will be stored as an attribute of a module, the
+ # name should be specified as modulename.attributename. This will
+ # enable other modules to import the capsule using
+ # PyCapsule_Import().
+
+
+ void* PyCapsule_GetPointer(object capsule, const char *name) except? NULL
+ # Retrieve the pointer stored in the capsule. On failure, set an
+ # exception and return NULL.
+ #
+ # The name parameter must compare exactly to the name stored in
+ # the capsule. If the name stored in the capsule is NULL, the name
+ # passed in must also be NULL. Python uses the C function strcmp()
+ # to compare capsule names.
+
+
+ PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) except? NULL
+ # Return the current destructor stored in the capsule. On failure,
+ # set an exception and return NULL.
+ #
+ # It is legal for a capsule to have a NULL destructor. This makes
+ # a NULL return code somewhat ambiguous; use PyCapsule_IsValid()
+ # or PyErr_Occurred() to disambiguate.
+
+
+ const char* PyCapsule_GetName(object capsule) except? NULL
+ # Return the current name stored in the capsule. On failure, set
+ # an exception and return NULL.
+ #
+ # It is legal for a capsule to have a NULL name. This makes a NULL
+ # return code somewhat ambiguous; use PyCapsule_IsValid() or
+ # PyErr_Occurred() to disambiguate.
+
+
+ void* PyCapsule_GetContext(object capsule) except? NULL
+ # Return the current context stored in the capsule. On failure,
+ # set an exception and return NULL.
+ #
+ # It is legal for a capsule to have a NULL context. This makes a
+ # NULL return code somewhat ambiguous; use PyCapsule_IsValid() or
+ # PyErr_Occurred() to disambiguate.
+
+
+ bint PyCapsule_IsValid(object capsule, const char *name)
+ # Determines whether or not capsule is a valid capsule. A valid
+ # capsule is non-NULL, passes PyCapsule_CheckExact(), has a
+ # non-NULL pointer stored in it, and its internal name matches the
+ # name parameter. (See PyCapsule_GetPointer() for information on
+ # how capsule names are compared.)
+ #
+ # In other words, if PyCapsule_IsValid() returns a true value,
+ # calls to any of the accessors (any function starting with
+ # PyCapsule_Get()) are guaranteed to succeed.
+ #
+ # Return a nonzero value if the object is valid and matches the
+ # name passed in. Return 0 otherwise. This function will not fail.
+
+
+ int PyCapsule_SetPointer(object capsule, void *pointer) except -1
+ # Set the void pointer inside capsule to pointer. The pointer may
+ # not be NULL.
+ #
+ # Return 0 on success. Return nonzero and set an exception on
+ # failure.
+
+
+ int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) except -1
+ # Set the destructor inside capsule to destructor.
+ #
+ # Return 0 on success. Return nonzero and set an exception on
+ # failure.
+
+
+ int PyCapsule_SetName(object capsule, const char *name) except -1
+ # Set the name inside capsule to name. If non-NULL, the name must
+ # outlive the capsule. If the previous name stored in the capsule
+ # was not NULL, no attempt is made to free it.
+ #
+ # Return 0 on success. Return nonzero and set an exception on
+ # failure.
+
+
+ int PyCapsule_SetContext(object capsule, void *context) except -1
+ # Set the context pointer inside capsule to context. Return 0 on
+ # success. Return nonzero and set an exception on failure.
+
+
+ void* PyCapsule_Import(const char *name, int no_block) except? NULL
+ # Import a pointer to a C object from a capsule attribute in a
+ # module. The name parameter should specify the full name to the
+ # attribute, as in module.attribute. The name stored in the
+ # capsule must match this string exactly. If no_block is true,
+ # import the module without blocking (using
+ # PyImport_ImportModuleNoBlock()). If no_block is false, import
+ # the module conventionally (using PyImport_ImportModule()).
+ #
+ # Return the capsule’s internal pointer on success. On failure,
+ # 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/pylifecycle.pxd b/contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd
new file mode 100644
index 0000000000..2c71e37163
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/pylifecycle.pxd
@@ -0,0 +1,68 @@
+# Interfaces to configure, query, create & destroy the Python runtime
+
+from libc.stdio cimport FILE
+from .pystate cimport PyThreadState
+
+
+cdef extern from "Python.h":
+ ctypedef int wchar_t
+
+ void Py_SetProgramName(wchar_t *)
+ wchar_t *Py_GetProgramName()
+
+ void Py_SetPythonHome(wchar_t *)
+ wchar_t *Py_GetPythonHome()
+
+ # Only used by applications that embed the interpreter and need to
+ # override the standard encoding determination mechanism
+ int Py_SetStandardStreamEncoding(const char *encoding, const char *errors)
+
+ void Py_Initialize()
+ void Py_InitializeEx(int)
+ void _Py_InitializeEx_Private(int, int)
+ void Py_Finalize()
+ int Py_FinalizeEx()
+ int Py_IsInitialized()
+ PyThreadState *Py_NewInterpreter()
+ void Py_EndInterpreter(PyThreadState *)
+
+
+ # _Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
+ # exit functions.
+ void _Py_PyAtExit(void (*func)(object), object)
+ int Py_AtExit(void (*func)())
+
+ void Py_Exit(int)
+
+ # Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
+ void _Py_RestoreSignals()
+
+ int Py_FdIsInteractive(FILE *, const char *)
+
+ # Bootstrap __main__ (defined in Modules/main.c)
+ int Py_Main(int argc, wchar_t **argv)
+
+ # In getpath.c
+ wchar_t *Py_GetProgramFullPath()
+ wchar_t *Py_GetPrefix()
+ wchar_t *Py_GetExecPrefix()
+ wchar_t *Py_GetPath()
+ void Py_SetPath(const wchar_t *)
+ int _Py_CheckPython3()
+
+ # In their own files
+ const char *Py_GetVersion()
+ const char *Py_GetPlatform()
+ const char *Py_GetCopyright()
+ const char *Py_GetCompiler()
+ const char *Py_GetBuildInfo()
+ const char *_Py_gitidentifier()
+ const char *_Py_gitversion()
+
+ ctypedef void (*PyOS_sighandler_t)(int)
+ PyOS_sighandler_t PyOS_getsig(int)
+ PyOS_sighandler_t PyOS_setsig(int, PyOS_sighandler_t)
+
+ # Random
+ int _PyOS_URandom(void *buffer, Py_ssize_t size)
+ int _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
diff --git a/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd
new file mode 100644
index 0000000000..1af6307931
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/pystate.pxd
@@ -0,0 +1,92 @@
+# Thread and interpreter state structures and their interfaces
+
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ # We make these an opaque types. If the user wants specific attributes,
+ # they can be declared manually.
+
+ ctypedef long PY_INT64_T # FIXME: Py2.7+, not defined here but used here
+
+ ctypedef struct PyInterpreterState:
+ pass
+
+ ctypedef struct PyThreadState:
+ pass
+
+ ctypedef struct PyFrameObject:
+ pass
+
+ # This is not actually a struct, but make sure it can never be coerced to
+ # an int or used in arithmetic expressions
+ ctypedef struct PyGILState_STATE:
+ pass
+
+ # The type of the trace function registered using PyEval_SetProfile() and
+ # PyEval_SetTrace().
+ # Py_tracefunc return -1 when raising an exception, or 0 for success.
+ ctypedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *)
+
+ # The following values are used for 'what' for tracefunc functions
+ enum:
+ PyTrace_CALL
+ PyTrace_EXCEPTION
+ PyTrace_LINE
+ PyTrace_RETURN
+ PyTrace_C_CALL
+ PyTrace_C_EXCEPTION
+ PyTrace_C_RETURN
+
+
+ PyInterpreterState * PyInterpreterState_New()
+ void PyInterpreterState_Clear(PyInterpreterState *)
+ void PyInterpreterState_Delete(PyInterpreterState *)
+ PY_INT64_T PyInterpreterState_GetID(PyInterpreterState *)
+
+ PyThreadState * PyThreadState_New(PyInterpreterState *)
+ void PyThreadState_Clear(PyThreadState *)
+ void PyThreadState_Delete(PyThreadState *)
+
+ PyThreadState * PyThreadState_Get()
+ PyThreadState * PyThreadState_Swap(PyThreadState *) # NOTE: DO NOT USE IN CYTHON CODE !
+ PyObject * PyThreadState_GetDict()
+ int PyThreadState_SetAsyncExc(long, PyObject *)
+
+ # Ensure that the current thread is ready to call the Python
+ # C API, regardless of the current state of Python, or of its
+ # thread lock. This may be called as many times as desired
+ # by a thread so long as each call is matched with a call to
+ # PyGILState_Release(). In general, other thread-state APIs may
+ # be used between _Ensure() and _Release() calls, so long as the
+ # thread-state is restored to its previous state before the Release().
+ # For example, normal use of the Py_BEGIN_ALLOW_THREADS/
+ # Py_END_ALLOW_THREADS macros are acceptable.
+
+ # The return value is an opaque "handle" to the thread state when
+ # PyGILState_Ensure() was called, and must be passed to
+ # PyGILState_Release() to ensure Python is left in the same state. Even
+ # though recursive calls are allowed, these handles can *not* be shared -
+ # each unique call to PyGILState_Ensure must save the handle for its
+ # call to PyGILState_Release.
+
+ # When the function returns, the current thread will hold the GIL.
+
+ # Failure is a fatal error.
+ PyGILState_STATE PyGILState_Ensure()
+
+ # Release any resources previously acquired. After this call, Python's
+ # state will be the same as it was prior to the corresponding
+ # PyGILState_Ensure() call (but generally this state will be unknown to
+ # the caller, hence the use of the GILState API.)
+
+ # Every call to PyGILState_Ensure must be matched by a call to
+ # PyGILState_Release on the same thread.
+ void PyGILState_Release(PyGILState_STATE)
+
+ # Routines for advanced debuggers, requested by David Beazley.
+ # Don't use unless you know what you are doing!
+ PyInterpreterState * PyInterpreterState_Head()
+ PyInterpreterState * PyInterpreterState_Next(PyInterpreterState *)
+ PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *)
+ PyThreadState * PyThreadState_Next(PyThreadState *)
diff --git a/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd b/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd
new file mode 100644
index 0000000000..392bef7d64
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/pythread.pxd
@@ -0,0 +1,53 @@
+
+
+cdef extern from "pythread.h":
+
+ ctypedef void *PyThread_type_lock
+ ctypedef void *PyThread_type_sema
+
+ void PyThread_init_thread()
+ long PyThread_start_new_thread(void (*)(void *), void *) # FIXME: legacy
+ #unsigned long PyThread_start_new_thread(void (*)(void *), void *) # returned 'long' before Py3.7
+ void PyThread_exit_thread()
+ long PyThread_get_thread_ident() # FIXME: legacy
+ #unsigned long PyThread_get_thread_ident() # returned 'long' before Py3.7
+
+ PyThread_type_lock PyThread_allocate_lock()
+ void PyThread_free_lock(PyThread_type_lock)
+ int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil
+ void PyThread_release_lock(PyThread_type_lock) nogil
+
+ enum:
+ # 'mode' in PyThread_acquire_lock()
+ WAIT_LOCK # 1
+ NOWAIT_LOCK # 0
+
+ ctypedef enum PyLockStatus:
+ # return values of PyThread_acquire_lock() in CPython 3.2+
+ PY_LOCK_FAILURE = 0
+ PY_LOCK_ACQUIRED = 1
+ PY_LOCK_INTR
+
+ size_t PyThread_get_stacksize()
+ int PyThread_set_stacksize(size_t)
+
+ # Thread Local Storage (TLS) API deprecated in CPython 3.7+
+ int PyThread_create_key()
+ void PyThread_delete_key(int)
+ int PyThread_set_key_value(int, void *)
+ void * PyThread_get_key_value(int)
+ void PyThread_delete_key_value(int key)
+
+ # Cleanup after a fork
+ void PyThread_ReInitTLS()
+
+ # Thread Specific Storage (TSS) API in CPython 3.7+ (also backported)
+ #ctypedef struct Py_tss_t: pass # Cython built-in type
+ Py_tss_t Py_tss_NEEDS_INIT # Not normally useful: Cython auto-initialises declared "Py_tss_t" variables.
+ Py_tss_t * PyThread_tss_alloc()
+ void PyThread_tss_free(Py_tss_t *key)
+ int PyThread_tss_is_created(Py_tss_t *key)
+ int PyThread_tss_create(Py_tss_t *key)
+ void PyThread_tss_delete(Py_tss_t *key)
+ int PyThread_tss_set(Py_tss_t *key, void *value)
+ void * PyThread_tss_get(Py_tss_t *key)
diff --git a/contrib/tools/cython/Cython/Includes/cpython/ref.pxd b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd
new file mode 100644
index 0000000000..4bc9a7d7c8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/ref.pxd
@@ -0,0 +1,51 @@
+from .object cimport PyObject, PyTypeObject, Py_TYPE # legacy imports for re-export
+
+cdef extern from "Python.h":
+ #####################################################################
+ # 3. Reference Counts
+ #####################################################################
+ # The macros in this section are used for managing reference counts of Python objects.
+ void Py_INCREF(object o)
+ # Increment the reference count for object o. The object must not
+ # be NULL; if you aren't sure that it isn't NULL, use
+ # Py_XINCREF().
+
+ void Py_XINCREF(PyObject* o)
+ # Increment the reference count for object o. The object may be NULL, in which case the macro has no effect.
+
+ void Py_DECREF(object o)
+ # Decrement the reference count for object o. The object must not
+ # be NULL; if you aren't sure that it isn't NULL, use
+ # Py_XDECREF(). If the reference count reaches zero, the object's
+ # type's deallocation function (which must not be NULL) is
+ # invoked.
+
+ # Warning: The deallocation function can cause arbitrary Python
+ # code to be invoked (e.g. when a class instance with a __del__()
+ # method is deallocated). While exceptions in such code are not
+ # propagated, the executed code has free access to all Python
+ # global variables. This means that any object that is reachable
+ # from a global variable should be in a consistent state before
+ # Py_DECREF() is invoked. For example, code to delete an object
+ # from a list should copy a reference to the deleted object in a
+ # temporary variable, update the list data structure, and then
+ # call Py_DECREF() for the temporary variable.
+
+ void Py_XDECREF(PyObject* o)
+ # Decrement the reference count for object o. The object may be
+ # NULL, in which case the macro has no effect; otherwise the
+ # effect is the same as for Py_DECREF(), and the same warning
+ # applies.
+
+ void Py_CLEAR(PyObject* o)
+ # Decrement the reference count for object o. The object may be
+ # NULL, in which case the macro has no effect; otherwise the
+ # effect is the same as for Py_DECREF(), except that the argument
+ # is also set to NULL. The warning for Py_DECREF() does not apply
+ # with respect to the object passed because the macro carefully
+ # uses a temporary variable and sets the argument to NULL before
+ # decrementing its reference count.
+ # 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
new file mode 100644
index 0000000000..eb279968d2
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/sequence.pxd
@@ -0,0 +1,136 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 6.3 Sequence Protocol
+ ############################################################################
+
+ bint PySequence_Check(object o)
+ # Return 1 if the object provides sequence protocol, and 0
+ # otherwise. This function always succeeds.
+
+ Py_ssize_t PySequence_Size(object o) except -1
+ # Returns the number of objects in sequence o on success, and -1
+ # on failure. For objects that do not provide sequence protocol,
+ # this is equivalent to the Python expression "len(o)".
+
+ Py_ssize_t PySequence_Length(object o) except -1
+ # Alternate name for PySequence_Size().
+
+ object PySequence_Concat(object o1, object o2)
+ # Return value: New reference.
+ # Return the concatenation of o1 and o2 on success, and NULL on
+ # failure. This is the equivalent of the Python expression "o1 +
+ # o2".
+
+ object PySequence_Repeat(object o, Py_ssize_t count)
+ # Return value: New reference.
+ # Return the result of repeating sequence object o count times, or
+ # NULL on failure. This is the equivalent of the Python expression
+ # "o * count".
+
+ object PySequence_InPlaceConcat(object o1, object o2)
+ # Return value: New reference.
+ # Return the concatenation of o1 and o2 on success, and NULL on
+ # failure. The operation is done in-place when o1 supports
+ # it. This is the equivalent of the Python expression "o1 += o2".
+
+ object PySequence_InPlaceRepeat(object o, Py_ssize_t count)
+ # Return value: New reference.
+ # Return the result of repeating sequence object o count times, or
+ # NULL on failure. The operation is done in-place when o supports
+ # it. This is the equivalent of the Python expression "o *=
+ # count".
+
+ object PySequence_GetItem(object o, Py_ssize_t i)
+ # Return value: New reference.
+ # Return the ith element of o, or NULL on failure. This is the
+ # equivalent of the Python expression "o[i]".
+
+ object PySequence_GetSlice(object o, Py_ssize_t i1, Py_ssize_t i2)
+ # Return value: New reference.
+ # Return the slice of sequence object o between i1 and i2, or NULL
+ # on failure. This is the equivalent of the Python expression
+ # "o[i1:i2]".
+
+ int PySequence_SetItem(object o, Py_ssize_t i, object v) except -1
+ # Assign object v to the ith element of o. Returns -1 on
+ # failure. This is the equivalent of the Python statement "o[i] =
+ # v". This function does not steal a reference to v.
+
+ int PySequence_DelItem(object o, Py_ssize_t i) except -1
+ # Delete the ith element of object o. Returns -1 on failure. This
+ # is the equivalent of the Python statement "del o[i]".
+
+ int PySequence_SetSlice(object o, Py_ssize_t i1, Py_ssize_t i2, object v) except -1
+ # Assign the sequence object v to the slice in sequence object o
+ # from i1 to i2. This is the equivalent of the Python statement
+ # "o[i1:i2] = v".
+
+ int PySequence_DelSlice(object o, Py_ssize_t i1, Py_ssize_t i2) except -1
+ # Delete the slice in sequence object o from i1 to i2. Returns -1
+ # on failure. This is the equivalent of the Python statement "del
+ # o[i1:i2]".
+
+ int PySequence_Count(object o, object value) except -1
+ # Return the number of occurrences of value in o, that is, return
+ # the number of keys for which o[key] == value. On failure, return
+ # -1. This is equivalent to the Python expression
+ # "o.count(value)".
+
+ int PySequence_Contains(object o, object value) except -1
+ # Determine if o contains value. If an item in o is equal to
+ # value, return 1, otherwise return 0. On error, return -1. This
+ # is equivalent to the Python expression "value in o".
+
+ Py_ssize_t PySequence_Index(object o, object value) except -1
+ # Return the first index i for which o[i] == value. On error,
+ # return -1. This is equivalent to the Python expression
+ # "o.index(value)".
+
+ object PySequence_List(object o)
+ # Return value: New reference.
+ # Return a list object with the same contents as the arbitrary
+ # sequence o. The returned list is guaranteed to be new.
+
+ object PySequence_Tuple(object o)
+ # Return value: New reference.
+ # Return a tuple object with the same contents as the arbitrary
+ # sequence o or NULL on failure. If o is a tuple, a new reference
+ # will be returned, otherwise a tuple will be constructed with the
+ # appropriate contents. This is equivalent to the Python
+ # expression "tuple(o)".
+
+ object PySequence_Fast(object o, char *m)
+ # Return value: New reference.
+ # Returns the sequence o as a tuple, unless it is already a tuple
+ # or list, in which case o is returned. Use
+ # PySequence_Fast_GET_ITEM() to access the members of the
+ # result. Returns NULL on failure. If the object is not a
+ # sequence, raises TypeError with m as the message text.
+
+ PyObject* PySequence_Fast_GET_ITEM(object o, Py_ssize_t i)
+ # Return value: Borrowed reference.
+ # Return the ith element of o, assuming that o was returned by
+ # PySequence_Fast(), o is not NULL, and that i is within bounds.
+
+ PyObject** PySequence_Fast_ITEMS(object o)
+ # Return the underlying array of PyObject pointers. Assumes that o
+ # was returned by PySequence_Fast() and o is not NULL.
+
+ object PySequence_ITEM(object o, Py_ssize_t i)
+ # Return value: New reference.
+ # Return the ith element of o or NULL on failure. Macro form of
+ # PySequence_GetItem() but without checking that
+ # PySequence_Check(o) is true and without adjustment for negative
+ # indices.
+
+ Py_ssize_t PySequence_Fast_GET_SIZE(object o)
+ # Returns the length of o, assuming that o was returned by
+ # PySequence_Fast() and that o is not NULL. The size can also be
+ # 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/set.pxd b/contrib/tools/cython/Cython/Includes/cpython/set.pxd
new file mode 100644
index 0000000000..ae31d28ae3
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/set.pxd
@@ -0,0 +1,119 @@
+cdef extern from "Python.h":
+
+ ############################################################################
+ # 7.5.14 Set Objects
+ ############################################################################
+
+ # This section details the public API for set and frozenset
+ # objects. Any functionality not listed below is best accessed
+ # using the either the abstract object protocol (including
+ # PyObject_CallMethod(), PyObject_RichCompareBool(),
+ # PyObject_Hash(), PyObject_Repr(), PyObject_IsTrue(),
+ # PyObject_Print(), and PyObject_GetIter()) or the abstract number
+ # protocol (including PyNumber_Add(), PyNumber_Subtract(),
+ # PyNumber_Or(), PyNumber_Xor(), PyNumber_InPlaceAdd(),
+ # PyNumber_InPlaceSubtract(), PyNumber_InPlaceOr(), and
+ # PyNumber_InPlaceXor()).
+
+ # PySetObject
+ # This subtype of PyObject is used to hold the internal data for
+ # both set and frozenset objects. It is like a PyDictObject in
+ # that it is a fixed size for small sets (much like tuple storage)
+ # and will point to a separate, variable sized block of memory for
+ # medium and large sized sets (much like list storage). None of
+ # the fields of this structure should be considered public and are
+ # subject to change. All access should be done through the
+ # documented API rather than by manipulating the values in the
+ # structure.
+
+ # PyTypeObject PySet_Type
+ # This is an instance of PyTypeObject representing the Python set type.
+
+ # PyTypeObject PyFrozenSet_Type
+ # This is an instance of PyTypeObject representing the Python frozenset type.
+
+ # The following type check macros work on pointers to any Python
+ # object. Likewise, the constructor functions work with any
+ # iterable Python object.
+
+ bint PyAnySet_Check(object p)
+ # Return true if p is a set object, a frozenset object, or an
+ # instance of a subtype.
+
+ bint PyAnySet_CheckExact(object p)
+ # Return true if p is a set object or a frozenset object but not
+ # an instance of a subtype.
+
+ bint PyFrozenSet_Check(object p)
+ # Return true if p is a frozenset object or an instance of a subtype.
+
+ bint PyFrozenSet_CheckExact(object p)
+ # Return true if p is a frozenset object but not an instance of a subtype.
+
+ bint PySet_Check(object p)
+ # Return true if p is a set object or an instance of a subtype.
+
+ object PySet_New(object iterable)
+ # Return value: New reference.
+ # Return a new set containing objects returned by the
+ # iterable. The iterable may be NULL to create a new empty
+ # set. Return the new set on success or NULL on failure. Raise
+ # TypeError if iterable is not actually iterable. The constructor
+ # is also useful for copying a set (c=set(s)).
+
+ object PyFrozenSet_New(object iterable)
+ # Return value: New reference.
+ # Return a new frozenset containing objects returned by the
+ # iterable. The iterable may be NULL to create a new empty
+ # frozenset. Return the new set on success or NULL on
+ # failure. Raise TypeError if iterable is not actually iterable.
+
+
+ # The following functions and macros are available for instances
+ # of set or frozenset or instances of their subtypes.
+
+ Py_ssize_t PySet_Size(object anyset) except -1
+ # Return the length of a set or frozenset object. Equivalent to
+ # "len(anyset)". Raises a PyExc_SystemError if anyset is not a
+ # set, frozenset, or an instance of a subtype.
+
+ Py_ssize_t PySet_GET_SIZE(object anyset)
+ # Macro form of PySet_Size() without error checking.
+
+ bint PySet_Contains(object anyset, object key) except -1
+ # Return 1 if found, 0 if not found, and -1 if an error is
+ # encountered. Unlike the Python __contains__() method, this
+ # function does not automatically convert unhashable sets into
+ # temporary frozensets. Raise a TypeError if the key is
+ # unhashable. Raise PyExc_SystemError if anyset is not a set,
+ # frozenset, or an instance of a subtype.
+
+
+ # The following functions are available for instances of set or
+ # its subtypes but not for instances of frozenset or its subtypes.
+
+ int PySet_Add(object set, object key) except -1
+ # Add key to a set instance. Does not apply to frozenset
+ # instances. Return 0 on success or -1 on failure. Raise a
+ # TypeError if the key is unhashable. Raise a MemoryError if there
+ # is no room to grow. Raise a SystemError if set is an not an
+ # instance of set or its subtype.
+
+ bint PySet_Discard(object set, object key) except -1
+ # Return 1 if found and removed, 0 if not found (no action taken),
+ # and -1 if an error is encountered. Does not raise KeyError for
+ # missing keys. Raise a TypeError if the key is unhashable. Unlike
+ # the Python discard() method, this function does not
+ # automatically convert unhashable sets into temporary
+ # frozensets. Raise PyExc_SystemError if set is an not an instance
+ # of set or its subtype.
+
+ object PySet_Pop(object set)
+ # Return value: New reference.
+ # Return a new reference to an arbitrary object in the set, and
+ # removes the object from the set. Return NULL on failure. Raise
+ # KeyError if the set is empty. Raise a SystemError if set is an
+ # not an instance of set or its subtype.
+
+ int PySet_Clear(object set)
+ # Empty an existing set of all elements.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/slice.pxd b/contrib/tools/cython/Cython/Includes/cpython/slice.pxd
new file mode 100644
index 0000000000..202dea716c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/slice.pxd
@@ -0,0 +1,70 @@
+cdef extern from "Python.h":
+
+ # PyTypeObject PySlice_Type
+ #
+ # The type object for slice objects. This is the same as slice and types.SliceType
+
+ bint PySlice_Check(object ob)
+ #
+ # Return true if ob is a slice object; ob must not be NULL.
+
+ slice PySlice_New(object start, object stop, object step)
+ #
+ # Return a new slice object with the given values. The start, stop, and step
+ # parameters are used as the values of the slice object attributes of the same
+ # names. Any of the values may be NULL, in which case the None will be used
+ # for the corresponding attribute. Return NULL if the new object could not be
+ # allocated.
+
+ int PySlice_GetIndices(object slice, Py_ssize_t length,
+ Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) except? -1
+ #
+ # Retrieve the start, stop and step indices from the slice object slice,
+ # assuming a sequence of length length. Treats indices greater than length
+ # as errors.
+ #
+ # Returns 0 on success and -1 on error with no exception set (unless one
+ # of the indices was not None and failed to be converted to an integer,
+ # in which case -1 is returned with an exception set).
+ #
+ # You probably do not want to use this function.
+ #
+ # Changed in version 3.2: The parameter type for the slice parameter was
+ # PySliceObject* before.
+
+ int PySlice_GetIndicesEx(object slice, Py_ssize_t length,
+ Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
+ Py_ssize_t *slicelength) except -1
+ #
+ # Usable replacement for PySlice_GetIndices(). Retrieve the start, stop, and step
+ # indices from the slice object slice assuming a sequence of length length, and
+ # store the length of the slice in slicelength. Out of bounds indices are clipped
+ # in a manner consistent with the handling of normal slices.
+ #
+ # Returns 0 on success and -1 on error with exception set.
+ #
+ # Changed in version 3.2: The parameter type for the slice parameter was
+ # PySliceObject* before.
+
+ int PySlice_Unpack(object slice, Py_ssize_t *start, Py_ssize_t *stop,
+ Py_ssize_t *step) except -1
+ # Extract the start, stop and step data members from a slice object as C
+ # integers. Silently reduce values larger than PY_SSIZE_T_MAX to
+ # PY_SSIZE_T_MAX, silently boost the start and stop values less than
+ # PY_SSIZE_T_MIN to PY_SSIZE_T_MIN, and silently boost the step values
+ # less than -PY_SSIZE_T_MAX to -PY_SSIZE_T_MAX.
+
+ # Return -1 on error, 0 on success.
+
+ # New in version 3.6.1.
+
+ Py_ssize_t PySlice_AdjustIndices(Py_ssize_t length, Py_ssize_t *start,
+ Py_ssize_t *stop, Py_ssize_t step)
+ # Adjust start/end slice indices assuming a sequence of the specified
+ # length. Out of bounds indices are clipped in a manner consistent with
+ # the handling of normal slices.
+
+ # Return the length of the slice. Always successful. Doesn’t call Python
+ # code.
+
+ # New in version 3.6.1.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/string.pxd b/contrib/tools/cython/Cython/Includes/cpython/string.pxd
new file mode 100644
index 0000000000..8af78f3dde
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/string.pxd
@@ -0,0 +1,198 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+ ctypedef struct va_list
+
+ ############################################################################
+ # 7.3.1 String Objects
+ ############################################################################
+
+ # These functions raise TypeError when expecting a string
+ # parameter and are called with a non-string parameter.
+ # PyStringObject
+ # This subtype of PyObject represents a Python string object.
+ # PyTypeObject PyString_Type
+ # This instance of PyTypeObject represents the Python string type;
+ # it is the same object as str and types.StringType in the Python
+ # layer.
+
+ bint PyString_Check(object o)
+ # Return true if the object o is a string object or an instance of
+ # a subtype of the string type.
+
+ bint PyString_CheckExact(object o)
+ # Return true if the object o is a string object, but not an instance of a subtype of the string type.
+
+ object PyString_FromString(char *v)
+ # Return value: New reference.
+ # Return a new string object with the value v on success, and NULL
+ # on failure. The parameter v must not be NULL; it will not be
+ # checked.
+
+ object PyString_FromStringAndSize(char *v, Py_ssize_t len)
+ # Return value: New reference.
+ # Return a new string object with the value v and length len on
+ # success, and NULL on failure. If v is NULL, the contents of the
+ # string are uninitialized.
+
+ object PyString_FromFormat(char *format, ...)
+ # Return value: New reference.
+ # Take a C printf()-style format string and a variable number of
+ # arguments, calculate the size of the resulting Python string and
+ # return a string with the values formatted into it. The variable
+ # arguments must be C types and must correspond exactly to the
+ # format characters in the format string. The following format
+ # characters are allowed:
+ # Format Characters Type Comment
+ # %% n/a The literal % character.
+ # %c int A single character, represented as an C int.
+ # %d int Exactly equivalent to printf("%d").
+ # %u unsigned int Exactly equivalent to printf("%u").
+ # %ld long Exactly equivalent to printf("%ld").
+ # %lu unsigned long Exactly equivalent to printf("%lu").
+ # %zd Py_ssize_t Exactly equivalent to printf("%zd").
+ # %zu size_t Exactly equivalent to printf("%zu").
+ # %i int Exactly equivalent to printf("%i").
+ # %x int Exactly equivalent to printf("%x").
+ # %s char* A null-terminated C character array.
+
+ # %p void* The hex representation of a C pointer.
+ # Mostly equivalent to printf("%p") except that it is guaranteed to
+ # start with the literal 0x regardless of what the platform's printf
+ # yields.
+ # An unrecognized format character causes all the rest of the
+ # format string to be copied as-is to the result string, and any
+ # extra arguments discarded.
+
+ object PyString_FromFormatV(char *format, va_list vargs)
+ # Return value: New reference.
+ # Identical to PyString_FromFormat() except that it takes exactly two arguments.
+
+ Py_ssize_t PyString_Size(object string) except -1
+ # Return the length of the string in string object string.
+
+ Py_ssize_t PyString_GET_SIZE(object string)
+ # Macro form of PyString_Size() but without error checking.
+
+ char* PyString_AsString(object string) except NULL
+ # Return a NUL-terminated representation of the contents of
+ # string. The pointer refers to the internal buffer of string, not
+ # a copy. The data must not be modified in any way, unless the
+ # string was just created using PyString_FromStringAndSize(NULL,
+ # size). It must not be deallocated. If string is a Unicode
+ # object, this function computes the default encoding of string
+ # and operates on that. If string is not a string object at all,
+ # PyString_AsString() returns NULL and raises TypeError.
+
+ char* PyString_AS_STRING(object string)
+ # Macro form of PyString_AsString() but without error
+ # checking. Only string objects are supported; no Unicode objects
+ # should be passed.
+
+ int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
+ # Return a NULL-terminated representation of the contents of the
+ # object obj through the output variables buffer and length.
+ #
+ # The function accepts both string and Unicode objects as
+ # input. For Unicode objects it returns the default encoded
+ # version of the object. If length is NULL, the resulting buffer
+ # may not contain NUL characters; if it does, the function returns
+ # -1 and a TypeError is raised.
+
+ # The buffer refers to an internal string buffer of obj, not a
+ # copy. The data must not be modified in any way, unless the
+ # string was just created using PyString_FromStringAndSize(NULL,
+ # size). It must not be deallocated. If string is a Unicode
+ # object, this function computes the default encoding of string
+ # and operates on that. If string is not a string object at all,
+ # PyString_AsStringAndSize() returns -1 and raises TypeError.
+
+ void PyString_Concat(PyObject **string, object newpart)
+ # Create a new string object in *string containing the contents of
+ # newpart appended to string; the caller will own the new
+ # reference. The reference to the old value of string will be
+ # stolen. If the new string cannot be created, the old reference
+ # to string will still be discarded and the value of *string will
+ # be set to NULL; the appropriate exception will be set.
+
+ void PyString_ConcatAndDel(PyObject **string, object newpart)
+ # Create a new string object in *string containing the contents of
+ # newpart appended to string. This version decrements the
+ # reference count of newpart.
+
+ int _PyString_Resize(PyObject **string, Py_ssize_t newsize) except -1
+ # A way to resize a string object even though it is
+ # ``immutable''. Only use this to build up a brand new string
+ # object; don't use this if the string may already be known in
+ # other parts of the code. It is an error to call this function if
+ # the refcount on the input string object is not one. Pass the
+ # address of an existing string object as an lvalue (it may be
+ # written into), and the new size desired. On success, *string
+ # holds the resized string object and 0 is returned; the address
+ # in *string may differ from its input value. If the reallocation
+ # fails, the original string object at *string is deallocated,
+ # *string is set to NULL, a memory exception is set, and -1 is
+ # returned.
+
+ object PyString_Format(object format, object args)
+ # Return value: New reference. Return a new string object from
+ # format and args. Analogous to format % args. The args argument
+ # must be a tuple.
+
+ void PyString_InternInPlace(PyObject **string)
+ # Intern the argument *string in place. The argument must be the
+ # address of a pointer variable pointing to a Python string
+ # object. If there is an existing interned string that is the same
+ # as *string, it sets *string to it (decrementing the reference
+ # count of the old string object and incrementing the reference
+ # count of the interned string object), otherwise it leaves
+ # *string alone and interns it (incrementing its reference
+ # count). (Clarification: even though there is a lot of talk about
+ # reference counts, think of this function as
+ # reference-count-neutral; you own the object after the call if
+ # and only if you owned it before the call.)
+
+ object PyString_InternFromString(char *v)
+ # Return value: New reference.
+ # A combination of PyString_FromString() and
+ # PyString_InternInPlace(), returning either a new string object
+ # that has been interned, or a new (``owned'') reference to an
+ # earlier interned string object with the same value.
+
+ object PyString_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+ # Return value: New reference.
+ # Create an object by decoding size bytes of the encoded buffer s
+ # using the codec registered for encoding. encoding and errors
+ # have the same meaning as the parameters of the same name in the
+ # unicode() built-in function. The codec to be used is looked up
+ # using the Python codec registry. Return NULL if an exception was
+ # raised by the codec.
+
+ object PyString_AsDecodedObject(object str, char *encoding, char *errors)
+ # Return value: New reference.
+ # Decode a string object by passing it to the codec registered for
+ # encoding and return the result as Python object. encoding and
+ # errors have the same meaning as the parameters of the same name
+ # in the 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.
+
+ object PyString_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
+ # Return value: New reference.
+ # Encode the char buffer of the given size by passing it to the
+ # codec registered for encoding and return a Python
+ # object. encoding and errors have the same meaning as the
+ # parameters of the same name in the 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.
+
+ object PyString_AsEncodedObject(object str, char *encoding, char *errors)
+ # Return value: New reference.
+ # Encode a string object using the codec registered for encoding
+ # and return the result as Python object. encoding and errors have
+ # the same meaning as the parameters of the same name in the
+ # 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/tuple.pxd b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd
new file mode 100644
index 0000000000..09c46e0b4b
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/tuple.pxd
@@ -0,0 +1,71 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ ############################################################################
+ # Tuples
+ ############################################################################
+
+ bint PyTuple_Check(object p)
+ # Return true if p is a tuple object or an instance of a subtype
+ # of the tuple type.
+
+ bint PyTuple_CheckExact(object p)
+ # Return true if p is a tuple object, but not an instance of a subtype of the tuple type.
+
+ tuple PyTuple_New(Py_ssize_t len)
+ # Return value: New reference.
+ # Return a new tuple object of size len, or NULL on failure.
+
+ tuple PyTuple_Pack(Py_ssize_t n, ...)
+ # Return value: New reference.
+ # Return a new tuple object of size n, or NULL on failure. The
+ # tuple values are initialized to the subsequent n C arguments
+ # pointing to Python objects. "PyTuple_Pack(2, a, b)" is
+ # equivalent to "Py_BuildValue("(OO)", a, b)".
+
+ Py_ssize_t PyTuple_Size(object p) except -1
+ # Take a pointer to a tuple object, and return the size of that tuple.
+
+ Py_ssize_t PyTuple_GET_SIZE(object p)
+ # Return the size of the tuple p, which must be non-NULL and point
+ # to a tuple; no error checking is performed.
+
+ PyObject* PyTuple_GetItem(object p, Py_ssize_t pos) except NULL
+ # Return value: Borrowed reference.
+ # Return the object at position pos in the tuple pointed to by
+ # p. If pos is out of bounds, return NULL and sets an IndexError
+ # exception.
+
+ PyObject* PyTuple_GET_ITEM(object p, Py_ssize_t pos)
+ # Return value: Borrowed reference.
+ # Like PyTuple_GetItem(), but does no checking of its arguments.
+
+ tuple PyTuple_GetSlice(object p, Py_ssize_t low, Py_ssize_t high)
+ # Return value: New reference.
+ # Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
+
+ 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.
+
+ 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.
+
+ 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
+ # the tuple. Because tuples are supposed to be immutable, this
+ # should only be used if there is only one reference to the
+ # object. Do not use this if the tuple may already be known to
+ # some other part of the code. The tuple will always grow or
+ # shrink at the end. Think of this as destroying the old tuple and
+ # creating a new one, only more efficiently. Returns 0 on
+ # success. Client code should never assume that the resulting
+ # value of *p will be the same as before calling this function. If
+ # 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
new file mode 100644
index 0000000000..a1d094e37c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/type.pxd
@@ -0,0 +1,48 @@
+
+cdef extern from "Python.h":
+ # The C structure of the objects used to describe built-in types.
+
+ ############################################################################
+ # 7.1.1 Type Objects
+ ############################################################################
+
+ ctypedef class __builtin__.type [object PyTypeObject]:
+ pass
+
+ # PyObject* PyType_Type
+ # This is the type object for type objects; it is the same object
+ # as type and types.TypeType in the Python layer.
+
+ bint PyType_Check(object o)
+ # Return true if the object o is a type object, including
+ # instances of types derived from the standard type object. Return
+ # false in all other cases.
+
+ bint PyType_CheckExact(object o)
+ # Return true if the object o is a type object, but not a subtype
+ # of the standard type object. Return false in all other
+ # cases.
+
+ 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.
+
+ bint PyType_IS_GC(object o)
+ # Return true if the type object includes support for the cycle
+ # detector; this tests the type flag Py_TPFLAGS_HAVE_GC.
+
+ bint PyType_IsSubtype(type a, type b)
+ # Return true if a is a subtype of b.
+
+ object PyType_GenericAlloc(object type, Py_ssize_t nitems)
+ # Return value: New reference.
+
+ object PyType_GenericNew(type type, object args, object kwds)
+ # Return value: New reference.
+
+ bint PyType_Ready(type type) except -1
+ # Finalize a type object. This should be called on all type
+ # objects to finish their initialization. This function is
+ # responsible for adding inherited slots from a type's base
+ # class. Return 0 on success, or return -1 and sets an exception
+ # on error.
diff --git a/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd
new file mode 100644
index 0000000000..2072c8cb2a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/unicode.pxd
@@ -0,0 +1,572 @@
+cdef extern from *:
+ # 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.
+ bint PyUnicode_Check(object o)
+
+ # Return true if the object o is a Unicode object, but not an
+ # instance of a subtype. New in version 2.2.
+ bint PyUnicode_CheckExact(object o)
+
+ # Return the size of the object. o has to be a PyUnicodeObject
+ # (not checked).
+ #
+ # Deprecated since version 3.3, will be removed in version 3.10:
+ # Part of the old-style Unicode API, please migrate to using
+ # PyUnicode_GET_LENGTH().
+ Py_ssize_t PyUnicode_GET_SIZE(object o)
+
+ # Return the length of the Unicode string, in code points. o has
+ # to be a Unicode object in the “canonical” representation (not
+ # checked).
+ #
+ # New in version 3.3.
+ Py_ssize_t PyUnicode_GET_LENGTH(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)
+
+ # Return a pointer to the internal Py_UNICODE buffer of the
+ # object. o has to be a PyUnicodeObject (not checked).
+ Py_UNICODE* PyUnicode_AS_UNICODE(object o)
+
+ # Return a pointer to the internal buffer of the object. o has to
+ # be a PyUnicodeObject (not checked).
+ char* PyUnicode_AS_DATA(object o)
+
+ # Return 1 or 0 depending on whether ch is a whitespace character.
+ bint Py_UNICODE_ISSPACE(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a lowercase character.
+ bint Py_UNICODE_ISLOWER(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is an uppercase character.
+ bint Py_UNICODE_ISUPPER(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a titlecase character.
+ bint Py_UNICODE_ISTITLE(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a linebreak character.
+ bint Py_UNICODE_ISLINEBREAK(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a decimal character.
+ bint Py_UNICODE_ISDECIMAL(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a digit character.
+ bint Py_UNICODE_ISDIGIT(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is a numeric character.
+ bint Py_UNICODE_ISNUMERIC(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is an alphabetic character.
+ bint Py_UNICODE_ISALPHA(Py_UCS4 ch)
+
+ # Return 1 or 0 depending on whether ch is an alphanumeric character.
+ bint Py_UNICODE_ISALNUM(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)
+
+ # Return the character ch converted to upper case.
+ # Used to return a Py_UNICODE value before Py3.3.
+ Py_UCS4 Py_UNICODE_TOUPPER(Py_UCS4 ch)
+
+ # Return the character ch converted to title case.
+ # Used to return a Py_UNICODE value before Py3.3.
+ Py_UCS4 Py_UNICODE_TOTITLE(Py_UCS4 ch)
+
+ # Return the character ch converted to a decimal positive
+ # integer. Return -1 if this is not possible. This macro does not
+ # raise exceptions.
+ int Py_UNICODE_TODECIMAL(Py_UCS4 ch)
+
+ # Return the character ch converted to a single digit
+ # integer. Return -1 if this is not possible. This macro does not
+ # raise exceptions.
+ int Py_UNICODE_TODIGIT(Py_UCS4 ch)
+
+ # Return the character ch converted to a double. Return -1.0 if
+ # this is not possible. This macro does not raise exceptions.
+ double Py_UNICODE_TONUMERIC(Py_UCS4 ch)
+
+ # To create Unicode objects and access their basic sequence
+ # properties, use these APIs:
+
+ # Create a Unicode Object from the Py_UNICODE buffer u of the
+ # given size. u may be NULL which causes the contents to be
+ # undefined. It is the user's responsibility to fill in the needed
+ # data. The buffer is copied into the new object. If the buffer is
+ # not NULL, the return value might be a shared object. Therefore,
+ # modification of the resulting Unicode object is only allowed
+ # when u is NULL.
+ unicode PyUnicode_FromUnicode(Py_UNICODE *u, Py_ssize_t size)
+
+ # Create a Unicode Object from the given Unicode code point ordinal.
+ #
+ # The ordinal must be in range(0x10000) on narrow Python builds
+ # (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError
+ # is raised in case it is not.
+ unicode PyUnicode_FromOrdinal(int ordinal)
+
+ # Return a read-only pointer to the Unicode object's internal
+ # Py_UNICODE buffer, NULL if unicode is not a Unicode object.
+ Py_UNICODE* PyUnicode_AsUnicode(object o) except NULL
+
+ # Return the length of the Unicode object.
+ Py_ssize_t PyUnicode_GetSize(object o) except -1
+
+ # Coerce an encoded object obj to an Unicode object and return a
+ # reference with incremented refcount.
+ # String and other char buffer compatible objects are decoded
+ # according to the given encoding and using the error handling
+ # defined by errors. Both can be NULL to have the interface use
+ # the default values (see the next section for details).
+ # All other objects, including Unicode objects, cause a TypeError
+ # to be set.
+ object PyUnicode_FromEncodedObject(object o, char *encoding, char *errors)
+
+ # Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict")
+ # which is used throughout the interpreter whenever coercion to
+ # Unicode is needed.
+ object PyUnicode_FromObject(object obj)
+
+ # If the platform supports wchar_t and provides a header file
+ # wchar.h, Python can interface directly to this type using the
+ # 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)
+
+
+# Unicode Methods
+
+ # Concat two strings giving a new Unicode string.
+ # Return value: New reference.
+ unicode PyUnicode_Concat(object left, object right)
+
+ # Split a string giving a list of Unicode strings. If sep is NULL,
+ # splitting will be done at all whitespace substrings. Otherwise,
+ # splits occur at the given separator. At most maxsplit splits will
+ # be done. If negative, no limit is set. Separators are not included
+ # in the resulting list.
+ # Return value: New reference.
+ list PyUnicode_Split(object s, object sep, Py_ssize_t maxsplit)
+
+ # Split a Unicode string at line breaks, returning a list of Unicode
+ # strings. CRLF is considered to be one line break. If keepend is 0,
+ # the Line break characters are not included in the resulting strings.
+ # Return value: New reference.
+ list PyUnicode_Splitlines(object s, bint keepend)
+
+ # Translate a string by applying a character mapping table to it and
+ # return the resulting Unicode object.
+ #
+ # The mapping table must map Unicode ordinal integers to Unicode ordinal
+ # integers or None (causing deletion of the character).
+ #
+ # Mapping tables need only provide the __getitem__() interface;
+ # dictionaries and sequences work well. Unmapped character ordinals (ones
+ # which cause a LookupError) are left untouched and are copied as-is.
+ #
+ # errors has the usual meaning for codecs. It may be NULL which indicates
+ # to use the default error handling.
+ # Return value: New reference.
+ unicode PyUnicode_Translate(object str, object table, const char *errors)
+
+ # Join a sequence of strings using the given separator and return the
+ # resulting Unicode string.
+ # Return value: New reference.
+ unicode PyUnicode_Join(object separator, object seq)
+
+ # Return 1 if substr matches str[start:end] at the given tail end
+ # (direction == -1 means to do a prefix match, direction == 1 a
+ # suffix match), 0 otherwise.
+ # Return -1 if an error occurred.
+ Py_ssize_t PyUnicode_Tailmatch(object str, object substr,
+ Py_ssize_t start, Py_ssize_t end, int direction) except -1
+
+ # Return the first position of substr in str[start:end] using the given
+ # direction (direction == 1 means to do a forward search, direction == -1
+ # a backward search). The return value is the index of the first match;
+ # a value of -1 indicates that no match was found, and -2 indicates that an
+ # error occurred and an exception has been set.
+ Py_ssize_t PyUnicode_Find(object str, object substr, Py_ssize_t start, Py_ssize_t end, int direction) except -2
+
+ # Return the first position of the character ch in str[start:end] using
+ # the given direction (direction == 1 means to do a forward search,
+ # direction == -1 a backward search). The return value is the index of
+ # the first match; a value of -1 indicates that no match was found, and
+ # -2 indicates that an error occurred and an exception has been set.
+ # New in version 3.3.
+ Py_ssize_t PyUnicode_FindChar(object str, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int direction) except -2
+
+ # Return the number of non-overlapping occurrences of substr in
+ # str[start:end]. Return -1 if an error occurred.
+ Py_ssize_t PyUnicode_Count(object str, object substr, Py_ssize_t start, Py_ssize_t end) except -1
+
+ # Replace at most maxcount occurrences of substr in str with replstr and
+ # return the resulting Unicode object. maxcount == -1 means replace all
+ # occurrences.
+ # Return value: New reference.
+ unicode PyUnicode_Replace(object str, object substr, object replstr, Py_ssize_t maxcount)
+
+ # Compare two strings and return -1, 0, 1 for less than,
+ # equal, and greater than, respectively.
+ int PyUnicode_Compare(object left, object right) except? -1
+
+ # Compare a unicode object, uni, with string and return -1, 0, 1 for less than,
+ # equal, and greater than, respectively. It is best to pass only ASCII-encoded
+ # strings, but the function interprets the input string as ISO-8859-1 if it
+ # contains non-ASCII characters.
+ int PyUnicode_CompareWithASCIIString(object uni, const char *string)
+
+ # Rich compare two unicode strings and return one of the following:
+ #
+ # NULL in case an exception was raised
+ # Py_True or Py_False for successful comparisons
+ # Py_NotImplemented in case the type combination is unknown
+ #
+ # Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in case
+ # the conversion of the arguments to Unicode fails with a UnicodeDecodeError.
+ #
+ # Possible values for op are Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, and Py_LE.
+ object PyUnicode_RichCompare(object left, object right, int op)
+
+ # Return a new string object from format and args; this is analogous to
+ # format % args.
+ # Return value: New reference.
+ unicode PyUnicode_Format(object format, object args)
+
+ # Check whether element is contained in container and return true or false
+ # accordingly.
+ #
+ # element has to coerce to a one element Unicode string. -1 is returned
+ # if there was an error.
+ int PyUnicode_Contains(object container, object element) except -1
+
+ # Intern the argument *string in place. The argument must be the address
+ # of a pointer variable pointing to a Python unicode string object. If
+ # there is an existing interned string that is the same as *string, it sets
+ # *string to it (decrementing the reference count of the old string object
+ # and incrementing the reference count of the interned string object),
+ # otherwise it leaves *string alone and interns it (incrementing its reference
+ # count). (Clarification: even though there is a lot of talk about reference
+ # counts, think of this function as reference-count-neutral; you own the object
+ # after the call if and only if you owned it before the call.)
+ #void PyUnicode_InternInPlace(PyObject **string)
+
+ # A combination of PyUnicode_FromString() and PyUnicode_InternInPlace(),
+ # returning either a new unicode string object that has been interned, or
+ # a new ("owned") reference to an earlier interned string object with the
+ # same value.
+ unicode PyUnicode_InternFromString(const char *v)
+
+
+# Codecs
+
+ # Create a Unicode object by decoding size bytes of the encoded
+ # string s. encoding and errors have the same meaning as the
+ # parameters of the same name in the unicode() builtin
+ # function. The codec to be used is looked up using the Python
+ # codec registry. Return NULL if an exception was raised by the
+ # codec.
+ object PyUnicode_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size and return a
+ # Python string object. encoding and errors have the same meaning
+ # as the parameters of the same name in the Unicode 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.
+ object PyUnicode_Encode(Py_UNICODE *s, Py_ssize_t size,
+ char *encoding, char *errors)
+
+ # Encode a Unicode object and return the result as Python string
+ # object. encoding and errors have the same meaning as the
+ # parameters of the same name in the Unicode 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.
+ object PyUnicode_AsEncodedString(object unicode, char *encoding, char *errors)
+
+# These are the UTF-8 codec APIs:
+
+ # Create a Unicode object by decoding size bytes of the UTF-8
+ # encoded string s. Return NULL if an exception was raised by the
+ # codec.
+ unicode PyUnicode_DecodeUTF8(char *s, Py_ssize_t size, char *errors)
+
+ # If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If
+ # consumed is not NULL, trailing incomplete UTF-8 byte sequences
+ # will not be treated as an error. Those bytes will not be decoded
+ # and the number of bytes that have been decoded will be stored in
+ # consumed. New in version 2.4.
+ unicode PyUnicode_DecodeUTF8Stateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed)
+
+ # Encode the Py_UNICODE buffer of the given size using UTF-8 and
+ # return a Python string object. Return NULL if an exception was
+ # raised by the codec.
+ bytes PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+ # Encode a Unicode objects using UTF-8 and return the result as Python bytes object. Error handling is ``strict''. Return NULL if an exception was raised by the codec.
+ bytes PyUnicode_AsUTF8String(object unicode)
+
+
+ # Return a pointer to the UTF-8 encoding of the Unicode object,
+ # and store the size of the encoded representation (in bytes) in size.
+ # The size argument can be NULL; in this case no size will be stored.
+ # The returned buffer always has an extra null byte appended
+ # (not included in size), regardless of whether there are any
+ # other null code points.
+
+ # In the case of an error, NULL is returned with an exception set and
+ # no size is stored.
+
+ # 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)
+
+# These are the UTF-16 codec APIs:
+
+ # Decode length bytes from a UTF-16 encoded buffer string and
+ # return the corresponding Unicode object. errors (if non-NULL)
+ # defines the error handling. It defaults to ``strict''.
+ #
+ # If byteorder is non-NULL, the decoder starts decoding using the
+ # given byte order:
+ #
+ # *byteorder == -1: little endian
+ # *byteorder == 0: native order
+ # *byteorder == 1: big endian
+ #
+ # and then switches if the first two bytes of the input data are a
+ # byte order mark (BOM) and the specified byte order is native
+ # order. This BOM is not copied into the resulting Unicode
+ # string. After completion, *byteorder is set to the current byte
+ # order at the.
+ #
+ # If byteorder is NULL, the codec starts in native order mode.
+ unicode PyUnicode_DecodeUTF16(char *s, Py_ssize_t size, char *errors, int *byteorder)
+
+ # If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If
+ # consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not
+ # treat trailing incomplete UTF-16 byte sequences (such as an odd
+ # number of bytes or a split surrogate pair) as an error. Those
+ # bytes will not be decoded and the number of bytes that have been
+ # decoded will be stored in consumed. New in version 2.4.
+ unicode PyUnicode_DecodeUTF16Stateful(char *s, Py_ssize_t size, char *errors, int *byteorder, Py_ssize_t *consumed)
+
+ # Return a Python string object holding the UTF-16 encoded value
+ # of the Unicode data in s. If byteorder is not 0, output is
+ # written according to the following byte order:
+ #
+ # byteorder == -1: little endian
+ # byteorder == 0: native byte order (writes a BOM mark)
+ # byteorder == 1: big endian
+ #
+ # If byteorder is 0, the output string will always start with the
+ # Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark
+ # is prepended.
+ #
+ # If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get
+ # represented as a surrogate pair. If it is not defined, each
+ # Py_UNICODE values is interpreted as an UCS-2 character.
+ bytes PyUnicode_EncodeUTF16(Py_UNICODE *s, Py_ssize_t size, char *errors, int byteorder)
+
+ # Return a Python string using the UTF-16 encoding in native byte
+ # order. The string always starts with a BOM mark. Error handling
+ # is ``strict''. Return NULL if an exception was raised by the
+ # codec.
+ bytes PyUnicode_AsUTF16String(object unicode)
+
+# These are the ``Unicode Escape'' codec APIs:
+
+ # Create a Unicode object by decoding size bytes of the
+ # Unicode-Escape encoded string s. Return NULL if an exception was
+ # raised by the codec.
+ object PyUnicode_DecodeUnicodeEscape(char *s, Py_ssize_t size, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size using
+ # Unicode-Escape and return a Python string object. Return NULL if
+ # an exception was raised by the codec.
+ object PyUnicode_EncodeUnicodeEscape(Py_UNICODE *s, Py_ssize_t size)
+
+ # Encode a Unicode objects using Unicode-Escape and return the
+ # result as Python string object. Error handling is
+ # ``strict''. Return NULL if an exception was raised by the codec.
+ object PyUnicode_AsUnicodeEscapeString(object unicode)
+
+# These are the ``Raw Unicode Escape'' codec APIs:
+
+ # Create a Unicode object by decoding size bytes of the
+ # Raw-Unicode-Escape encoded string s. Return NULL if an exception
+ # was raised by the codec.
+ object PyUnicode_DecodeRawUnicodeEscape(char *s, Py_ssize_t size, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size using
+ # Raw-Unicode-Escape and return a Python string object. Return
+ # NULL if an exception was raised by the codec.
+ object PyUnicode_EncodeRawUnicodeEscape(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+ # Encode a Unicode objects using Raw-Unicode-Escape and return the
+ # result as Python string object. Error handling is
+ # ``strict''. Return NULL if an exception was raised by the codec.
+ object PyUnicode_AsRawUnicodeEscapeString(object unicode)
+
+# These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 Unicode ordinals and only these are accepted by the codecs during encoding.
+
+ # Create a Unicode object by decoding size bytes of the Latin-1
+ # encoded string s. Return NULL if an exception was raised by the
+ # codec.
+ unicode PyUnicode_DecodeLatin1(char *s, Py_ssize_t size, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size using Latin-1 and
+ # return a Python bytes object. Return NULL if an exception was
+ # raised by the codec.
+ bytes PyUnicode_EncodeLatin1(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+ # Encode a Unicode objects using Latin-1 and return the result as
+ # Python bytes object. Error handling is ``strict''. Return NULL
+ # if an exception was raised by the codec.
+ bytes PyUnicode_AsLatin1String(object unicode)
+
+# These are the ASCII codec APIs. Only 7-bit ASCII data is
+# accepted. All other codes generate errors.
+
+ # Create a Unicode object by decoding size bytes of the ASCII
+ # encoded string s. Return NULL if an exception was raised by the
+ # codec.
+ unicode PyUnicode_DecodeASCII(char *s, Py_ssize_t size, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size using ASCII and
+ # return a Python bytes object. Return NULL if an exception was
+ # raised by the codec.
+ bytes PyUnicode_EncodeASCII(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+ # Encode a Unicode objects using ASCII and return the result as
+ # Python bytes object. Error handling is ``strict''. Return NULL
+ # if an exception was raised by the codec.
+ bytes PyUnicode_AsASCIIString(object o)
+
+# These are the mapping codec APIs:
+#
+# This codec is special in that it can be used to implement many
+# different codecs (and this is in fact what was done to obtain most
+# of the standard codecs included in the encodings package). The codec
+# uses mapping to encode and decode characters.
+#
+# Decoding mappings must map single string characters to single
+# Unicode characters, integers (which are then interpreted as Unicode
+# ordinals) or None (meaning "undefined mapping" and causing an
+# error).
+#
+# Encoding mappings must map single Unicode characters to single
+# string characters, integers (which are then interpreted as Latin-1
+# ordinals) or None (meaning "undefined mapping" and causing an
+# error).
+#
+# The mapping objects provided must only support the __getitem__
+# mapping interface.
+#
+# If a character lookup fails with a LookupError, the character is
+# copied as-is meaning that its ordinal value will be interpreted as
+# Unicode or Latin-1 ordinal resp. Because of this, mappings only need
+# to contain those mappings which map characters to different code
+# points.
+
+ # Create a Unicode object by decoding size bytes of the encoded
+ # string s using the given mapping object. Return NULL if an
+ # exception was raised by the codec. If mapping is NULL latin-1
+ # decoding will be done. Else it can be a dictionary mapping byte
+ # or a unicode string, which is treated as a lookup table. Byte
+ # values greater that the length of the string and U+FFFE
+ # "characters" are treated as "undefined mapping". Changed in
+ # version 2.4: Allowed unicode string as mapping argument.
+ object PyUnicode_DecodeCharmap(char *s, Py_ssize_t size, object mapping, char *errors)
+
+ # Encode the Py_UNICODE buffer of the given size using the given
+ # mapping object and return a Python string object. Return NULL if
+ # an exception was raised by the codec.
+ #
+ # Deprecated since version 3.3, will be removed in version 4.0.
+ object PyUnicode_EncodeCharmap(Py_UNICODE *s, Py_ssize_t size, object mapping, char *errors)
+
+ # Encode a Unicode objects using the given mapping object and
+ # return the result as Python string object. Error handling is
+ # ``strict''. Return NULL if an exception was raised by the codec.
+ object PyUnicode_AsCharmapString(object o, object mapping)
+
+# The following codec API is special in that maps Unicode to Unicode.
+
+ # Translate a Py_UNICODE buffer of the given length by applying a
+ # character mapping table to it and return the resulting Unicode
+ # object. Return NULL when an exception was raised by the codec.
+ #
+ # The mapping table must map Unicode ordinal integers to Unicode
+ # ordinal integers or None (causing deletion of the character).
+ #
+ # Mapping tables need only provide the __getitem__() interface;
+ # dictionaries and sequences work well. Unmapped character
+ # ordinals (ones which cause a LookupError) are left untouched and
+ # are copied as-is.
+ #
+ # Deprecated since version 3.3, will be removed in version 4.0.
+ object PyUnicode_TranslateCharmap(Py_UNICODE *s, Py_ssize_t size,
+ object table, char *errors)
+
+# These are the MBCS codec APIs. They are currently only available on
+# Windows and use the Win32 MBCS converters to implement the
+# conversions. Note that MBCS (or DBCS) is a class of encodings, not
+# just one. The target encoding is defined by the user settings on the
+# machine running the codec.
+
+ # Create a Unicode object by decoding size bytes of the MBCS
+ # encoded string s. Return NULL if an exception was raised by the
+ # codec.
+ unicode PyUnicode_DecodeMBCS(char *s, Py_ssize_t size, char *errors)
+
+ # If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If
+ # consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not
+ # decode trailing lead byte and the number of bytes that have been
+ # decoded will be stored in consumed. New in version 2.5.
+ # NOTE: Python 2.x uses 'int' values for 'size' and 'consumed' (changed in 3.0)
+ unicode PyUnicode_DecodeMBCSStateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed)
+
+ # Encode the Py_UNICODE buffer of the given size using MBCS and
+ # return a Python string object. Return NULL if an exception was
+ # raised by the codec.
+ bytes PyUnicode_EncodeMBCS(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+ # Encode a Unicode objects using MBCS and return the result as
+ # Python string object. Error handling is ``strict''. Return NULL
+ # if an exception was raised by the codec.
+ bytes PyUnicode_AsMBCSString(object o)
+
+ # Encode the Unicode object using the specified code page and return
+ # a Python bytes object. Return NULL if an exception was raised by the
+ # codec. Use CP_ACP code page to get the MBCS encoder.
+ #
+ # New in version 3.3.
+ bytes PyUnicode_EncodeCodePage(int code_page, object unicode, const char *errors)
+
+
+# Py_UCS4 helpers (new in CPython 3.3)
+
+ # These utility functions work on strings of Py_UCS4 characters and
+ # otherwise behave like the C standard library functions with the same name.
+
+ size_t Py_UCS4_strlen(const Py_UCS4 *u)
+ Py_UCS4* Py_UCS4_strcpy(Py_UCS4 *s1, const Py_UCS4 *s2)
+ Py_UCS4* Py_UCS4_strncpy(Py_UCS4 *s1, const Py_UCS4 *s2, size_t n)
+ Py_UCS4* Py_UCS4_strcat(Py_UCS4 *s1, const Py_UCS4 *s2)
+ int Py_UCS4_strcmp(const Py_UCS4 *s1, const Py_UCS4 *s2)
+ 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)
diff --git a/contrib/tools/cython/Cython/Includes/cpython/version.pxd b/contrib/tools/cython/Cython/Includes/cpython/version.pxd
new file mode 100644
index 0000000000..ce31b249cf
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/version.pxd
@@ -0,0 +1,32 @@
+# Python version constants
+#
+# It's better to evaluate these at runtime (i.e. C compile time) using
+#
+# if PY_MAJOR_VERSION >= 3:
+# do_stuff_in_Py3_0_and_later()
+# if PY_VERSION_HEX >= 0x02070000:
+# do_stuff_in_Py2_7_and_later()
+#
+# than using the IF/DEF statements, which are evaluated at Cython
+# compile time. This will keep your C code portable.
+
+
+cdef extern from *:
+ # the complete version, e.g. 0x010502B2 == 1.5.2b2
+ int PY_VERSION_HEX
+
+ # the individual sections as plain numbers
+ int PY_MAJOR_VERSION
+ int PY_MINOR_VERSION
+ int PY_MICRO_VERSION
+ int PY_RELEASE_LEVEL
+ int PY_RELEASE_SERIAL
+
+ # Note: PY_RELEASE_LEVEL is one of
+ # 0xA (alpha)
+ # 0xB (beta)
+ # 0xC (release candidate)
+ # 0xF (final)
+
+ char PY_VERSION[]
+ char PY_PATCHLEVEL_REVISION[]
diff --git a/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd b/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd
new file mode 100644
index 0000000000..9c4b50f564
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/cpython/weakref.pxd
@@ -0,0 +1,42 @@
+from .object cimport PyObject
+
+cdef extern from "Python.h":
+
+ bint PyWeakref_Check(object ob)
+ # Return true if ob is either a reference or proxy object.
+
+ bint PyWeakref_CheckRef(object ob)
+ # Return true if ob is a reference object.
+
+ bint PyWeakref_CheckProxy(ob)
+ # Return true if *ob* is a proxy object.
+
+ object PyWeakref_NewRef(object ob, object callback)
+ # Return a weak reference object for the object ob. This will
+ # always return a new reference, but is not guaranteed to create a
+ # new object; an existing reference object may be returned. The
+ # second parameter, callback, can be a callable object that
+ # receives notification when ob is garbage collected; it should
+ # accept a single parameter, which will be the weak reference
+ # object itself. callback may also be None or NULL. If ob is not
+ # a weakly-referencable object, or if callback is not callable,
+ # None, or NULL, this will return NULL and raise TypeError.
+
+ object PyWeakref_NewProxy(object ob, object callback)
+ # Return a weak reference proxy object for the object ob. This
+ # will always return a new reference, but is not guaranteed to
+ # create a new object; an existing proxy object may be returned.
+ # The second parameter, callback, can be a callable object that
+ # receives notification when ob is garbage collected; it should
+ # accept a single parameter, which will be the weak reference
+ # object itself. callback may also be None or NULL. If ob is not
+ # a weakly-referencable object, or if callback is not callable,
+ # None, or NULL, this will return NULL and raise TypeError.
+
+ PyObject* PyWeakref_GetObject(object ref) except NULL
+ # Return the referenced object from a weak reference, ref. If the
+ # referent is no longer live, returns None.
+
+ PyObject* PyWeakref_GET_OBJECT(object ref)
+ # Similar to PyWeakref_GetObject, but implemented as a macro that
+ # does no error checking.
diff --git a/contrib/tools/cython/Cython/Includes/libc/__init__.pxd b/contrib/tools/cython/Cython/Includes/libc/__init__.pxd
new file mode 100644
index 0000000000..fa81adaff6
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/__init__.pxd
@@ -0,0 +1 @@
+# empty file
diff --git a/contrib/tools/cython/Cython/Includes/libc/errno.pxd b/contrib/tools/cython/Cython/Includes/libc/errno.pxd
new file mode 100644
index 0000000000..191d47b3dc
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/errno.pxd
@@ -0,0 +1,128 @@
+# 7.5 Errors <errno.h>
+
+cdef extern from "<errno.h>" nogil:
+ enum:
+ EPERM
+ ENOENT
+ ESRCH
+ EINTR
+ EIO
+ ENXIO
+ E2BIG
+ ENOEXEC
+ EBADF
+ ECHILD
+ EAGAIN
+ ENOMEM
+ EACCES
+ EFAULT
+ ENOTBLK
+ EBUSY
+ EEXIST
+ EXDEV
+ ENODEV
+ ENOTDIR
+ EISDIR
+ EINVAL
+ ENFILE
+ EMFILE
+ ENOTTY
+ ETXTBSY
+ EFBIG
+ ENOSPC
+ ESPIPE
+ EROFS
+ EMLINK
+ EPIPE
+ EDOM
+ ERANGE
+ EDEADLOCK
+ ENAMETOOLONG
+ ENOLCK
+ ENOSYS
+ ENOTEMPTY
+ ELOOP
+ ENOMSG
+ EIDRM
+ ECHRNG
+ EL2NSYNC
+ EL3HLT
+ EL3RST
+ ELNRNG
+ EUNATCH
+ ENOCSI
+ EL2HLT
+ EBADE
+ EBADR
+ EXFULL
+ ENOANO
+ EBADRQC
+ EBADSLT
+ EBFONT
+ ENOSTR
+ ENODATA
+ ENOATTR
+ ETIME
+ ENOSR
+ ENONET
+ ENOPKG
+ EREMOTE
+ ENOLINK
+ EADV
+ ESRMNT
+ ECOMM
+ EPROTO
+ EMULTIHOP
+ EDOTDOT
+ EBADMSG
+ EOVERFLOW
+ ENOTUNIQ
+ EBADFD
+ EREMCHG
+ ELIBACC
+ ELIBBAD
+ ELIBSCN
+ ELIBMAX
+ ELIBEXEC
+ EILSEQ
+ ERESTART
+ ESTRPIPE
+ EUSERS
+ ENOTSOCK
+ EDESTADDRREQ
+ EMSGSIZE
+ EPROTOTYPE
+ ENOPROTOOPT
+ EPROTONOSUPPORT
+ ESOCKTNOSUPPORT
+ EOPNOTSUPP
+ EPFNOSUPPORT
+ EAFNOSUPPORT
+ EADDRINUSE
+ EADDRNOTAVAIL
+ ENETDOWN
+ ENETUNREACH
+ ENETRESET
+ ECONNABORTED
+ ECONNRESET
+ ENOBUFS
+ EISCONN
+ ENOTCONN
+ ESHUTDOWN
+ ETOOMANYREFS
+ ETIMEDOUT
+ ECONNREFUSED
+ EHOSTDOWN
+ EHOSTUNREACH
+ EALREADY
+ EINPROGRESS
+ ESTALE
+ EUCLEAN
+ ENOTNAM
+ ENAVAIL
+ EISNAM
+ EREMOTEIO
+ EDQUOT
+
+ int errno
+
diff --git a/contrib/tools/cython/Cython/Includes/libc/float.pxd b/contrib/tools/cython/Cython/Includes/libc/float.pxd
new file mode 100644
index 0000000000..5e4e12d4f4
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/float.pxd
@@ -0,0 +1,43 @@
+# 5.2.4.2.2 Characteristics of floating types <float.h>
+
+cdef extern from "<float.h>":
+
+ const float FLT_RADIX
+
+ const float FLT_MANT_DIG
+ const double DBL_MANT_DIG
+ const long double LDBL_MANT_DIG
+
+ const double DECIMAL_DIG
+
+ const float FLT_DIG
+ const double DBL_DIG
+ const long double LDBL_DIG
+
+ const float FLT_MIN_EXP
+ const double DBL_MIN_EXP
+ const long double LDBL_MIN_EXP
+
+ const float FLT_MIN_10_EXP
+ const double DBL_MIN_10_EXP
+ const long double LDBL_MIN_10_EXP
+
+ const float FLT_MAX_EXP
+ const double DBL_MAX_EXP
+ const long double LDBL_MAX_EXP
+
+ const float FLT_MAX_10_EXP
+ const double DBL_MAX_10_EXP
+ const long double LDBL_MAX_10_EXP
+
+ const float FLT_MAX
+ const double DBL_MAX
+ const long double LDBL_MAX
+
+ const float FLT_EPSILON
+ const double DBL_EPSILON
+ const long double LDBL_EPSILON
+
+ const float FLT_MIN
+ const double DBL_MIN
+ const long double LDBL_MIN
diff --git a/contrib/tools/cython/Cython/Includes/libc/limits.pxd b/contrib/tools/cython/Cython/Includes/libc/limits.pxd
new file mode 100644
index 0000000000..39d10a1ff9
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/limits.pxd
@@ -0,0 +1,28 @@
+# 5.2.4.2.1 Sizes of integer types <limits.h>
+
+cdef extern from "<limits.h>":
+ const int CHAR_BIT
+ const int MB_LEN_MAX
+
+ const char CHAR_MIN
+ const char CHAR_MAX
+
+ const signed char SCHAR_MIN
+ const signed char SCHAR_MAX
+ const unsigned char UCHAR_MAX
+
+ const short SHRT_MIN
+ const short SHRT_MAX
+ const unsigned short USHRT_MAX
+
+ const int INT_MIN
+ const int INT_MAX
+ const unsigned int UINT_MAX
+
+ const long LONG_MIN
+ const long LONG_MAX
+ const unsigned long ULONG_MAX
+
+ const long long LLONG_MIN
+ const long long LLONG_MAX
+ const unsigned long long ULLONG_MAX
diff --git a/contrib/tools/cython/Cython/Includes/libc/locale.pxd b/contrib/tools/cython/Cython/Includes/libc/locale.pxd
new file mode 100644
index 0000000000..5cbec953ef
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/locale.pxd
@@ -0,0 +1,46 @@
+# 7.11 Localization <locale.h>
+
+# deprecated cimport for backwards compatibility:
+from libc.string cimport const_char
+
+
+cdef extern from "<locale.h>" nogil:
+
+ struct lconv:
+ char *decimal_point
+ char *thousands_sep
+ char *grouping
+ char *mon_decimal_point
+ char *mon_thousands_sep
+ char *mon_grouping
+ char *positive_sign
+ char *negative_sign
+ char *currency_symbol
+ char frac_digits
+ char p_cs_precedes
+ char n_cs_precedes
+ char p_sep_by_space
+ char n_sep_by_space
+ char p_sign_posn
+ char n_sign_posn
+ char *int_curr_symbol
+ char int_frac_digits
+ char int_p_cs_precedes
+ char int_n_cs_precedes
+ char int_p_sep_by_space
+ char int_n_sep_by_space
+ char int_p_sign_posn
+ char int_n_sign_posn
+
+ enum: LC_ALL
+ enum: LC_COLLATE
+ enum: LC_CTYPE
+ enum: LC_MONETARY
+ enum: LC_NUMERIC
+ enum: LC_TIME
+
+ # 7.11.1 Locale control
+ char *setlocale (int category, const char *locale)
+
+ # 7.11.2 Numeric formatting convention inquiry
+ lconv *localeconv ()
diff --git a/contrib/tools/cython/Cython/Includes/libc/math.pxd b/contrib/tools/cython/Cython/Includes/libc/math.pxd
new file mode 100644
index 0000000000..b002670b22
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/math.pxd
@@ -0,0 +1,112 @@
+cdef extern from "<math.h>" nogil:
+ const double M_E
+ const double e "M_E" # as in Python's math module
+ const double M_LOG2E
+ const double M_LOG10E
+ const double M_LN2
+ const double M_LN10
+ const double M_PI
+ const double pi "M_PI" # as in Python's math module
+ const double M_PI_2
+ const double M_PI_4
+ const double M_1_PI
+ const double M_2_PI
+ const double M_2_SQRTPI
+ const double M_SQRT2
+ const double M_SQRT1_2
+
+ # C99 constants
+ const float INFINITY
+ const float NAN
+ # note: not providing "nan" and "inf" aliases here as nan() is a function in C
+ const double HUGE_VAL
+ const float HUGE_VALF
+ const long double HUGE_VALL
+
+ double acos(double x)
+ double asin(double x)
+ 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)
+ 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)
+ double cbrt(double x)
+
+ double fabs(double x)
+ 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)
+
+ double copysign(double, double)
+ float copysignf(float, float)
+ long double copysignl(long double, long double)
+
+ double erf(double)
+ float erff(float)
+ long double erfl(long double)
+ double erfc(double)
+ float erfcf(float)
+ long double erfcl(long double)
+
+ double fdim(double x, double y)
+ double fma(double x, double y, double z)
+ double fmax(double x, double y)
+ double fmin(double x, double y)
+ double scalbln(double x, long n)
+ double scalbn(double x, int n)
+
+ double nan(const char*)
+
+ int isinf(long double) # -1 / 0 / 1
+ bint isfinite(long double)
+ bint isnan(long double)
+ bint isnormal(long double)
+ bint signbit(long double)
+ int fpclassify(long double)
+ const int FP_NAN
+ const int FP_INFINITE
+ const int FP_ZERO
+ const int FP_SUBNORMAL
+ const int FP_NORMAL
diff --git a/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd b/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd
new file mode 100644
index 0000000000..6c11a534d4
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/setjmp.pxd
@@ -0,0 +1,10 @@
+cdef extern from "<setjmp.h>" nogil:
+ ctypedef struct jmp_buf:
+ pass
+ int setjmp(jmp_buf state)
+ void longjmp(jmp_buf state, int value)
+
+ ctypedef struct sigjmp_buf:
+ pass
+ int sigsetjmp(sigjmp_buf state, int savesigs)
+ void siglongjmp(sigjmp_buf state, int value)
diff --git a/contrib/tools/cython/Cython/Includes/libc/signal.pxd b/contrib/tools/cython/Cython/Includes/libc/signal.pxd
new file mode 100644
index 0000000000..5d34935543
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/signal.pxd
@@ -0,0 +1,64 @@
+# 7.14 Signal handling <signal.h>
+
+ctypedef void (*sighandler_t)(int SIGNUM) nogil
+
+cdef extern from "<signal.h>" nogil:
+
+ ctypedef int sig_atomic_t
+
+ sighandler_t SIG_DFL
+ sighandler_t SIG_IGN
+ sighandler_t SIG_ERR
+
+ sighandler_t signal (int signum, sighandler_t action)
+ int raise_"raise" (int signum)
+
+ # Signals
+ enum:
+ # Program Error
+ SIGFPE
+ SIGILL
+ SIGSEGV
+ SIGBUS
+ SIGABRT
+ SIGIOT
+ SIGTRAP
+ SIGEMT
+ SIGSYS
+ SIGSTKFLT
+ # Termination
+ SIGTERM
+ SIGINT
+ SIGQUIT
+ SIGKILL
+ SIGHUP
+ # Alarm
+ SIGALRM
+ SIGVTALRM
+ SIGPROF
+ # Asynchronous I/O
+ SIGIO
+ SIGURG
+ SIGPOLL
+ # Job Control
+ SIGCHLD
+ SIGCLD
+ SIGCONT
+ SIGSTOP
+ SIGTSTP
+ SIGTTIN
+ SIGTTOU
+ # Operation Error
+ SIGPIPE
+ SIGLOST
+ SIGXCPU
+ SIGXFSZ
+ SIGPWR
+ # Miscellaneous
+ SIGUSR1
+ SIGUSR2
+ SIGWINCH
+ SIGINFO
+ # Real-time signals
+ SIGRTMIN
+ SIGRTMAX
diff --git a/contrib/tools/cython/Cython/Includes/libc/stddef.pxd b/contrib/tools/cython/Cython/Includes/libc/stddef.pxd
new file mode 100644
index 0000000000..9b0f4c5fd2
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/stddef.pxd
@@ -0,0 +1,9 @@
+# 7.17 Common definitions <stddef.h>
+
+cdef extern from "<stddef.h>":
+
+ ctypedef signed int ptrdiff_t
+
+ ctypedef unsigned int size_t
+
+ ctypedef int wchar_t
diff --git a/contrib/tools/cython/Cython/Includes/libc/stdint.pxd b/contrib/tools/cython/Cython/Includes/libc/stdint.pxd
new file mode 100644
index 0000000000..ced3d46add
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/stdint.pxd
@@ -0,0 +1,105 @@
+# Longness only used for type promotion.
+# Actual compile time size used for conversions.
+
+# 7.18 Integer types <stdint.h>
+cdef extern from "<stdint.h>" nogil:
+
+ # 7.18.1 Integer types
+ # 7.18.1.1 Exact-width integer types
+ ctypedef signed char int8_t
+ ctypedef signed short int16_t
+ ctypedef signed int int32_t
+ ctypedef signed long int64_t
+ ctypedef unsigned char uint8_t
+ ctypedef unsigned short uint16_t
+ ctypedef unsigned int uint32_t
+ ctypedef unsigned long long uint64_t
+ # 7.18.1.2 Minimum-width integer types
+ ctypedef signed char int_least8_t
+ ctypedef signed short int_least16_t
+ ctypedef signed int int_least32_t
+ ctypedef signed long int_least64_t
+ ctypedef unsigned char uint_least8_t
+ ctypedef unsigned short uint_least16_t
+ ctypedef unsigned int uint_least32_t
+ ctypedef unsigned long long uint_least64_t
+ # 7.18.1.3 Fastest minimum-width integer types
+ ctypedef signed char int_fast8_t
+ ctypedef signed short int_fast16_t
+ ctypedef signed int int_fast32_t
+ ctypedef signed long int_fast64_t
+ ctypedef unsigned char uint_fast8_t
+ ctypedef unsigned short uint_fast16_t
+ ctypedef unsigned int uint_fast32_t
+ ctypedef unsigned long long uint_fast64_t
+ # 7.18.1.4 Integer types capable of holding object pointers
+ ctypedef ssize_t intptr_t
+ ctypedef size_t uintptr_t
+ # 7.18.1.5 Greatest-width integer types
+ ctypedef signed long long intmax_t
+ ctypedef unsigned long long uintmax_t
+
+ # 7.18.2 Limits of specified-width integer types
+ # 7.18.2.1 Limits of exact-width integer types
+ int8_t INT8_MIN
+ int16_t INT16_MIN
+ int32_t INT32_MIN
+ int64_t INT64_MIN
+ int8_t INT8_MAX
+ int16_t INT16_MAX
+ int32_t INT32_MAX
+ int64_t INT64_MAX
+ uint8_t UINT8_MAX
+ uint16_t UINT16_MAX
+ uint32_t UINT32_MAX
+ uint64_t UINT64_MAX
+ #7.18.2.2 Limits of minimum-width integer types
+ int_least8_t INT_LEAST8_MIN
+ int_least16_t INT_LEAST16_MIN
+ int_least32_t INT_LEAST32_MIN
+ int_least64_t INT_LEAST64_MIN
+ int_least8_t INT_LEAST8_MAX
+ int_least16_t INT_LEAST16_MAX
+ int_least32_t INT_LEAST32_MAX
+ int_least64_t INT_LEAST64_MAX
+ uint_least8_t UINT_LEAST8_MAX
+ uint_least16_t UINT_LEAST16_MAX
+ uint_least32_t UINT_LEAST32_MAX
+ uint_least64_t UINT_LEAST64_MAX
+ #7.18.2.3 Limits of fastest minimum-width integer types
+ int_fast8_t INT_FAST8_MIN
+ int_fast16_t INT_FAST16_MIN
+ int_fast32_t INT_FAST32_MIN
+ int_fast64_t INT_FAST64_MIN
+ int_fast8_t INT_FAST8_MAX
+ int_fast16_t INT_FAST16_MAX
+ int_fast32_t INT_FAST32_MAX
+ int_fast64_t INT_FAST64_MAX
+ uint_fast8_t UINT_FAST8_MAX
+ uint_fast16_t UINT_FAST16_MAX
+ uint_fast32_t UINT_FAST32_MAX
+ uint_fast64_t UINT_FAST64_MAX
+ #7.18.2.4 Limits of integer types capable of holding object pointers
+ enum: INTPTR_MIN
+ enum: INTPTR_MAX
+ enum: UINTPTR_MAX
+ # 7.18.2.5 Limits of greatest-width integer types
+ enum: INTMAX_MAX
+ enum: INTMAX_MIN
+ enum: UINTMAX_MAX
+
+ # 7.18.3 Limits of other integer types
+ # ptrdiff_t
+ enum: PTRDIFF_MIN
+ enum: PTRDIFF_MAX
+ # sig_atomic_t
+ enum: SIG_ATOMIC_MIN
+ enum: SIG_ATOMIC_MAX
+ # size_t
+ size_t SIZE_MAX
+ # wchar_t
+ enum: WCHAR_MIN
+ enum: WCHAR_MAX
+ # wint_t
+ enum: WINT_MIN
+ enum: WINT_MAX
diff --git a/contrib/tools/cython/Cython/Includes/libc/stdio.pxd b/contrib/tools/cython/Cython/Includes/libc/stdio.pxd
new file mode 100644
index 0000000000..1644a5a0ab
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/stdio.pxd
@@ -0,0 +1,80 @@
+# 7.19 Input/output <stdio.h>
+
+
+# deprecated cimports for backwards compatibility:
+from libc.string cimport const_char, const_void
+
+
+cdef extern from "<stdio.h>" nogil:
+
+ ctypedef struct FILE
+ cdef FILE *stdin
+ cdef FILE *stdout
+ cdef FILE *stderr
+
+ enum: FOPEN_MAX
+ enum: FILENAME_MAX
+ FILE *fopen (const char *filename, const char *opentype)
+ FILE *freopen (const char *filename, const char *opentype, FILE *stream)
+ FILE *fdopen (int fdescriptor, const char *opentype)
+ int fclose (FILE *stream)
+ int remove (const char *filename)
+ int rename (const char *oldname, const char *newname)
+ FILE *tmpfile ()
+
+ int remove (const char *pathname)
+ int rename (const char *oldpath, const char *newpath)
+
+ enum: _IOFBF
+ enum: _IOLBF
+ enum: _IONBF
+ int setvbuf (FILE *stream, char *buf, int mode, size_t size)
+ enum: BUFSIZ
+ void setbuf (FILE *stream, char *buf)
+
+ size_t fread (void *data, size_t size, size_t count, FILE *stream)
+ size_t fwrite (const void *data, size_t size, size_t count, FILE *stream)
+ int fflush (FILE *stream)
+
+ enum: EOF
+ void clearerr (FILE *stream)
+ int feof (FILE *stream)
+ int ferror (FILE *stream)
+
+ enum: SEEK_SET
+ enum: SEEK_CUR
+ enum: SEEK_END
+ int fseek (FILE *stream, long int offset, int whence)
+ void rewind (FILE *stream)
+ long int ftell (FILE *stream)
+
+ ctypedef struct fpos_t
+ ctypedef const fpos_t const_fpos_t "const fpos_t"
+ int fgetpos (FILE *stream, fpos_t *position)
+ int fsetpos (FILE *stream, const fpos_t *position)
+
+ int scanf (const char *template, ...)
+ int sscanf (const char *s, const char *template, ...)
+ int fscanf (FILE *stream, const char *template, ...)
+
+ int printf (const char *template, ...)
+ int sprintf (char *s, const char *template, ...)
+ int snprintf (char *s, size_t size, const char *template, ...)
+ int fprintf (FILE *stream, const char *template, ...)
+
+ void perror (const char *message)
+
+ char *gets (char *s)
+ char *fgets (char *s, int count, FILE *stream)
+ int getchar ()
+ int fgetc (FILE *stream)
+ int getc (FILE *stream)
+ int ungetc (int c, FILE *stream)
+
+ int puts (const char *s)
+ int fputs (const char *s, FILE *stream)
+ int putchar (int c)
+ int fputc (int c, FILE *stream)
+ int putc (int c, FILE *stream)
+
+ size_t getline(char **lineptr, size_t *n, FILE *stream)
diff --git a/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd b/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd
new file mode 100644
index 0000000000..e6fac821c7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/stdlib.pxd
@@ -0,0 +1,72 @@
+# 7.20 General utilities <stdlib.h>
+
+# deprecated cimports for backwards compatibility:
+from libc.string cimport const_char, const_void
+
+
+cdef extern from "<stdlib.h>" nogil:
+
+ # 7.20.1 Numeric conversion functions
+ int atoi (const char *string)
+ long atol (const char *string)
+ long long atoll (const char *string)
+ double atof (const char *string)
+ long strtol (const char *string, char **tailptr, int base)
+ unsigned long int strtoul (const char *string, char **tailptr, int base)
+ long long int strtoll (const char *string, char **tailptr, int base)
+ unsigned long long int strtoull (const char *string, char **tailptr, int base)
+ float strtof (const char *string, char **tailptr)
+ double strtod (const char *string, char **tailptr)
+ long double strtold (const char *string, char **tailptr)
+
+ # 7.20.2 Pseudo-random sequence generation functions
+ enum: RAND_MAX
+ int rand ()
+ void srand (unsigned int seed)
+
+ # 7.20.3 Memory management functions
+ void *calloc (size_t count, size_t eltsize)
+ void free (void *ptr)
+ void *malloc (size_t size)
+ void *realloc (void *ptr, size_t newsize)
+
+ # 7.20.4 Communication with the environment
+ enum: EXIT_FAILURE
+ enum: EXIT_SUCCESS
+ void exit (int status)
+ void _exit (int status)
+ int atexit (void (*function) ())
+ void abort ()
+ char *getenv (const char *name)
+ int system (const char *command)
+
+ #7.20.5 Searching and sorting utilities
+ void *bsearch (const void *key, const void *array,
+ size_t count, size_t size,
+ int (*compare)(const void *, const void *))
+ void qsort (void *array, size_t count, size_t size,
+ int (*compare)(const void *, const void *))
+
+ # 7.20.6 Integer arithmetic functions
+ int abs (int number)
+ long int labs (long int number)
+ long long int llabs (long long int number)
+ ctypedef struct div_t:
+ int quot
+ int rem
+ div_t div (int numerator, int denominator)
+ ctypedef struct ldiv_t:
+ long int quot
+ long int rem
+ ldiv_t ldiv (long int numerator, long int denominator)
+ ctypedef struct lldiv_t:
+ long long int quot
+ long long int rem
+ lldiv_t lldiv (long long int numerator, long long int denominator)
+
+
+ # 7.20.7 Multibyte/wide character conversion functions
+ # XXX TODO
+
+ # 7.20.8 Multibyte/wide string conversion functions
+ # XXX TODO
diff --git a/contrib/tools/cython/Cython/Includes/libc/string.pxd b/contrib/tools/cython/Cython/Includes/libc/string.pxd
new file mode 100644
index 0000000000..e6d96183f2
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/string.pxd
@@ -0,0 +1,50 @@
+# 7.21 String handling <string.h>
+
+cdef extern from *:
+ # deprecated backwards compatibility declarations
+ ctypedef const char const_char "const char"
+ ctypedef const signed char const_schar "const signed char"
+ ctypedef const unsigned char const_uchar "const unsigned char"
+ ctypedef const void const_void "const void"
+
+cdef extern from "<string.h>" nogil:
+
+ void *memcpy (void *pto, const void *pfrom, size_t size)
+ void *memmove (void *pto, const void *pfrom, size_t size)
+ void *memset (void *block, int c, size_t size)
+ int memcmp (const void *a1, const void *a2, size_t size)
+ void *memchr (const void *block, int c, size_t size)
+
+ void *memchr (const void *block, int c, size_t size)
+ void *memrchr (const void *block, int c, size_t size)
+
+ size_t strlen (const char *s)
+ char *strcpy (char *pto, const char *pfrom)
+ char *strncpy (char *pto, const char *pfrom, size_t size)
+ char *strdup (const char *s)
+ char *strndup (const char *s, size_t size)
+ char *strcat (char *pto, const char *pfrom)
+ char *strncat (char *pto, const char *pfrom, size_t size)
+
+ int strcmp (const char *s1, const char *s2)
+ int strcasecmp (const char *s1, const char *s2)
+ int strncmp (const char *s1, const char *s2, size_t size)
+ int strncasecmp (const char *s1, const char *s2, size_t n)
+
+ int strcoll (const char *s1, const char *s2)
+ size_t strxfrm (char *pto, const char *pfrom, size_t size)
+
+ char *strerror (int errnum)
+
+ char *strchr (const char *string, int c)
+ char *strrchr (const char *string, int c)
+
+ char *strstr (const char *haystack, const char *needle)
+ char *strcasestr (const char *haystack, const char *needle)
+
+ size_t strcspn (const char *string, const char *stopset)
+ size_t strspn (const char *string, const char *set)
+ char * strpbrk (const char *string, const char *stopset)
+
+ char *strtok (char *newstring, const char *delimiters)
+ char *strsep (char **string_ptr, const char *delimiter)
diff --git a/contrib/tools/cython/Cython/Includes/libc/time.pxd b/contrib/tools/cython/Cython/Includes/libc/time.pxd
new file mode 100644
index 0000000000..3aa15a2eee
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libc/time.pxd
@@ -0,0 +1,46 @@
+# http://en.wikipedia.org/wiki/C_date_and_time_functions
+
+from libc.stddef cimport wchar_t
+
+cdef extern from "<time.h>" nogil:
+ ctypedef long clock_t
+ ctypedef long time_t
+
+ enum: CLOCKS_PER_SEC
+ clock_t clock() # CPU time
+ time_t time(time_t *) # wall clock time since Unix epoch
+
+ cdef struct tm:
+ int tm_sec
+ int tm_min
+ int tm_hour
+ int tm_mday
+ int tm_mon
+ int tm_year
+ int tm_wday
+ int tm_yday
+ int tm_isdst
+ char *tm_zone
+ long tm_gmtoff
+
+ int daylight # global state
+ long timezone
+ char *tzname[2]
+ void tzset()
+
+ char *asctime(const tm *)
+ char *asctime_r(const tm *, char *)
+ char *ctime(const time_t *)
+ char *ctime_r(const time_t *, char *)
+ double difftime(time_t, time_t)
+ tm *getdate(const char *)
+ tm *gmtime(const time_t *)
+ tm *gmtime_r(const time_t *, tm *)
+ tm *localtime(const time_t *)
+ tm *localtime_r(const time_t *, tm *)
+ time_t mktime(tm *)
+ size_t strftime(char *, size_t, const char *, const tm *)
+ size_t wcsftime(wchar_t *str, size_t cnt, const wchar_t *fmt, tm *time)
+
+ # POSIX not stdC
+ char *strptime(const char *, const char *, tm *)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd b/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd
new file mode 100644
index 0000000000..111ea25c2f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/__init__.pxd
@@ -0,0 +1,4 @@
+cdef extern from *:
+ ctypedef bint bool
+ ctypedef void* nullptr_t
+ nullptr_t nullptr
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd
new file mode 100644
index 0000000000..ec7c3835b4
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/algorithm.pxd
@@ -0,0 +1,43 @@
+from libcpp cimport bool
+
+
+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)
+
+ 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)
+
+ 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)
+
+ void partial_sort[Iter](Iter first, Iter middle, Iter last)
+ void partial_sort[Iter, Compare](Iter first, Iter middle, Iter last,
+ Compare comp)
+
+ void sort[Iter](Iter first, Iter last)
+ void sort[Iter, Compare](Iter first, Iter last, Compare comp)
+
+ # Removing duplicates
+ Iter unique[Iter](Iter first, Iter last)
+ Iter unique[Iter, BinaryPredicate](Iter first, Iter last, BinaryPredicate p)
+
+ # Binary heaps (priority queues)
+ void make_heap[Iter](Iter first, Iter last)
+ void make_heap[Iter, Compare](Iter first, Iter last, Compare comp)
+
+ 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)
+
+ void sort_heap[Iter](Iter first, Iter last)
+ void sort_heap[Iter, Compare](Iter first, Iter last, Compare comp)
+
+ # Copy
+ OutputIter copy[InputIter,OutputIter](InputIter,InputIter,OutputIter)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd b/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd
new file mode 100644
index 0000000000..c3a4d8978f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/cast.pxd
@@ -0,0 +1,12 @@
+# Defines the standard C++ cast operators.
+#
+# Due to type restrictions, these are only defined for pointer parameters,
+# however that is the only case where they are significantly more interesting
+# than the standard C cast operator which can be written "<T>(expression)" in
+# Cython.
+
+cdef extern from * nogil:
+ cdef T dynamic_cast[T](void *) except + # nullptr may also indicate failure
+ cdef T static_cast[T](void *)
+ cdef T reinterpret_cast[T](void *)
+ cdef T const_cast[T](void *)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd
new file mode 100644
index 0000000000..c875d5e5bd
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/complex.pxd
@@ -0,0 +1,101 @@
+# Note: add integer versions of the functions?
+
+cdef extern from "<complex>" namespace "std" nogil:
+ cdef cppclass complex[T]:
+ complex() except +
+ complex(T, T) except +
+ complex(complex[T]&) except +
+ # 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]&)
+
+ bint operator==(complex[T]&, complex[T]&)
+ bint operator==(complex[T]&, T&)
+ bint operator==(T&, complex[T]&)
+ bint operator!=(complex[T]&, complex[T]&)
+ bint operator!=(complex[T]&, T&)
+ bint operator!=(T&, complex[T]&)
+
+ # Access real part
+ T real()
+ void real(T)
+
+ # Access imaginary part
+ T imag()
+ void imag(T)
+
+ # Return real part
+ T real[T](complex[T]&)
+ long double real(long double)
+ double real(double)
+ float real(float)
+
+ # Return imaginary part
+ T imag[T](complex[T]&)
+ long double imag(long double)
+ double imag(double)
+ float imag(float)
+
+ T abs[T](complex[T]&)
+ T arg[T](complex[T]&)
+ long double arg(long double)
+ double arg(double)
+ float arg(float)
+
+ T norm[T](complex[T])
+ long double norm(long double)
+ double norm(double)
+ float norm(float)
+
+ complex[T] conj[T](complex[T]&)
+ complex[long double] conj(long double)
+ complex[double] conj(double)
+ complex[float] conj(float)
+
+ complex[T] proj[T](complex[T])
+ complex[long double] proj(long double)
+ complex[double] proj(double)
+ complex[float] proj(float)
+
+ complex[T] polar[T](T&, T&)
+ complex[T] ploar[T](T&)
+
+ complex[T] exp[T](complex[T]&)
+ complex[T] log[T](complex[T]&)
+ complex[T] log10[T](complex[T]&)
+
+ complex[T] pow[T](complex[T]&, complex[T]&)
+ complex[T] pow[T](complex[T]&, T&)
+ complex[T] pow[T](T&, complex[T]&)
+ # There are some promotion versions too
+
+ complex[T] sqrt[T](complex[T]&)
+
+ complex[T] sin[T](complex[T]&)
+ complex[T] cos[T](complex[T]&)
+ complex[T] tan[T](complex[T]&)
+ complex[T] asin[T](complex[T]&)
+ complex[T] acos[T](complex[T]&)
+ complex[T] atan[T](complex[T]&)
+
+ complex[T] sinh[T](complex[T]&)
+ complex[T] cosh[T](complex[T]&)
+ complex[T] tanh[T](complex[T]&)
+
+ complex[T] asinh[T](complex[T]&)
+ complex[T] acosh[T](complex[T]&)
+ complex[T] atanh[T](complex[T]&)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd
new file mode 100644
index 0000000000..9e2b2291d0
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/deque.pxd
@@ -0,0 +1,86 @@
+cdef extern from "<deque>" namespace "std" nogil:
+ cdef cppclass deque[T,ALLOCATOR=*]:
+ ctypedef T 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:
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ iterator operator+(size_type)
+ iterator operator-(size_type)
+ difference_type operator-(iterator)
+ bint operator==(iterator)
+ bint operator!=(iterator)
+ bint operator<(iterator)
+ bint operator>(iterator)
+ bint operator<=(iterator)
+ bint operator>=(iterator)
+ cppclass reverse_iterator:
+ T& operator*()
+ reverse_iterator operator++()
+ reverse_iterator operator--()
+ reverse_iterator operator+(size_type)
+ reverse_iterator operator-(size_type)
+ difference_type operator-(reverse_iterator)
+ bint operator==(reverse_iterator)
+ bint operator!=(reverse_iterator)
+ bint operator<(reverse_iterator)
+ bint operator>(reverse_iterator)
+ bint operator<=(reverse_iterator)
+ bint operator>=(reverse_iterator)
+ cppclass const_iterator(iterator):
+ pass
+ cppclass const_reverse_iterator(reverse_iterator):
+ pass
+ deque() except +
+ deque(deque&) except +
+ deque(size_t) except +
+ deque(size_t, T&) except +
+ #deque[input_iterator](input_iterator, input_iterator)
+ T& operator[](size_t)
+ #deque& operator=(deque&)
+ bint operator==(deque&, deque&)
+ bint operator!=(deque&, deque&)
+ bint operator<(deque&, deque&)
+ 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)
+ T& back()
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ iterator erase(iterator)
+ iterator erase(iterator, iterator)
+ T& front()
+ iterator insert(iterator, T&)
+ void insert(iterator, size_t, T&)
+ void insert(iterator, input_iterator, input_iterator)
+ size_t max_size()
+ void pop_back()
+ void pop_front()
+ void push_back(T&)
+ void push_front(T&)
+ reverse_iterator rbegin()
+ #const_reverse_iterator rbegin()
+ reverse_iterator rend()
+ #const_reverse_iterator rend()
+ void resize(size_t)
+ void resize(size_t, T&)
+ size_t size()
+ void swap(deque&)
+
+ # C++11 methods
+ void shrink_to_fit()
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd
new file mode 100644
index 0000000000..8c3b240d04
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/forward_list.pxd
@@ -0,0 +1,62 @@
+cdef extern from "<forward_list>" namespace "std" nogil:
+ cdef cppclass forward_list[T,ALLOCATOR=*]:
+ ctypedef T 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:
+ iterator()
+ iterator(iterator &)
+ T& operator*()
+ iterator operator++()
+ bint operator==(iterator)
+ bint operator!=(iterator)
+ cppclass const_iterator(iterator):
+ pass
+ forward_list() except +
+ forward_list(forward_list&) except +
+ forward_list(size_t, T&) except +
+ #forward_list& operator=(forward_list&)
+ bint operator==(forward_list&, forward_list&)
+ bint operator!=(forward_list&, forward_list&)
+ bint operator<(forward_list&, forward_list&)
+ bint operator>(forward_list&, forward_list&)
+ bint operator<=(forward_list&, forward_list&)
+ bint operator>=(forward_list&, forward_list&)
+ void assign(size_t, T&)
+ T& front()
+ iterator before_begin()
+ const_iterator const_before_begin "before_begin"()
+ iterator begin()
+ const_iterator const_begin "begin"()
+ iterator end()
+ const_iterator const_end "end"()
+ bint empty()
+ size_t max_size()
+ void clear()
+ iterator insert_after(iterator, T&)
+ void insert_after(iterator, size_t, T&)
+ iterator erase_after(iterator)
+ iterator erase_after(iterator, iterator)
+ void push_front(T&)
+ void pop_front()
+ void resize(size_t)
+ void resize(size_t, T&)
+ void swap(forward_list&)
+ void merge(forward_list&)
+ void merge[Compare](forward_list&, Compare)
+ void splice_after(iterator, forward_list&)
+ void splice_after(iterator, forward_list&, iterator)
+ void splice_after(iterator, forward_list&, iterator, iterator)
+ void remove(const T&)
+ void remove_if[Predicate](Predicate)
+ void reverse()
+ void unique()
+ void unique[Predicate](Predicate)
+ void sort()
+ void sort[Compare](Compare)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd
new file mode 100644
index 0000000000..94cbd9e1dd
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/functional.pxd
@@ -0,0 +1,13 @@
+cdef extern from "<functional>" namespace "std" nogil:
+ cdef cppclass function[T]:
+ function() except +
+ function(T*) except +
+ function(function&) except +
+ function(void*) except +
+
+ function operator=(T*)
+ function operator=(function&)
+ function operator=(void*)
+ function operator=[U](U)
+
+ bint operator bool()
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd
new file mode 100644
index 0000000000..e0f8bd8d6e
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/iterator.pxd
@@ -0,0 +1,32 @@
+#Basic reference: http://www.cplusplus.com/reference/iterator/
+#Most of these classes are in fact empty structs
+
+cdef extern from "<iterator>" namespace "std" nogil:
+ cdef cppclass iterator[Category,T,Distance,Pointer,Reference]:
+ pass
+ cdef cppclass output_iterator_tag:
+ pass
+ cdef cppclass input_iterator_tag:
+ pass
+ cdef cppclass forward_iterator_tag(input_iterator_tag):
+ pass
+ cdef cppclass bidirectional_iterator_tag(forward_iterator_tag):
+ pass
+ cdef cppclass random_access_iterator_tag(bidirectional_iterator_tag):
+ pass
+
+ cdef cppclass back_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
+ pass
+ cdef cppclass front_insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
+ pass
+ cdef cppclass insert_iterator[T](iterator[output_iterator_tag,void,void,void,void]):
+ pass
+ back_insert_iterator[CONTAINER] back_inserter[CONTAINER](CONTAINER &)
+ front_insert_iterator[CONTAINER] front_inserter[CONTAINER](CONTAINER &)
+ ##Note: this is the C++98 version of inserter.
+ ##The C++11 versions's prototype relies on typedef members of classes, which Cython doesn't currently support:
+ ##template <class Container>
+ ##insert_iterator<Container> inserter (Container& x, typename Container::iterator it)
+ insert_iterator[CONTAINER] inserter[CONTAINER,ITERATOR](CONTAINER &, ITERATOR)
+
+
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd
new file mode 100644
index 0000000000..c325263b72
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/limits.pxd
@@ -0,0 +1,61 @@
+cdef extern from "<limits>" namespace "std" nogil:
+ 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:
+ 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()
+
+ 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 is_iec559
+ const bint is_bounded
+ const bint is_modulo
+
+ 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
new file mode 100644
index 0000000000..b5b0410ad8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/list.pxd
@@ -0,0 +1,78 @@
+cdef extern from "<list>" namespace "std" nogil:
+ cdef cppclass list[T,ALLOCATOR=*]:
+ ctypedef T 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:
+ iterator()
+ iterator(iterator &)
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(iterator)
+ bint operator!=(iterator)
+ cppclass reverse_iterator:
+ reverse_iterator()
+ reverse_iterator(iterator &)
+ T& operator*()
+ reverse_iterator operator++()
+ reverse_iterator operator--()
+ bint operator==(reverse_iterator)
+ bint operator!=(reverse_iterator)
+ cppclass const_iterator(iterator):
+ pass
+ cppclass const_reverse_iterator(reverse_iterator):
+ pass
+ list() except +
+ list(list&) except +
+ list(size_t, T&) except +
+ #list operator=(list&)
+ bint operator==(list&, list&)
+ bint operator!=(list&, list&)
+ bint operator<(list&, list&)
+ bint operator>(list&, list&)
+ bint operator<=(list&, list&)
+ bint operator>=(list&, list&)
+ void assign(size_t, T&)
+ T& back()
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ 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&, BinPred)
+ void pop_back()
+ void pop_front()
+ void push_back(T&)
+ void push_front(T&)
+ reverse_iterator rbegin()
+ const_reverse_iterator const_rbegin "rbegin"()
+ void remove(T&)
+ #void remove_if(UnPred)
+ reverse_iterator rend()
+ const_reverse_iterator const_rend "rend"()
+ void resize(size_t, T&)
+ void reverse()
+ size_t size()
+ void sort()
+ #void sort(BinPred)
+ void splice(iterator, list&)
+ void splice(iterator, list&, iterator)
+ void splice(iterator, list&, iterator, iterator)
+ void swap(list&)
+ void unique()
+ #void unique(BinPred)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd
new file mode 100644
index 0000000000..624a7ac026
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/map.pxd
@@ -0,0 +1,68 @@
+from .utility cimport pair
+
+cdef extern from "<map>" namespace "std" nogil:
+ cdef cppclass map[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
+ cppclass iterator:
+ pair[T, U]& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(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
+ map() except +
+ map(map&) except +
+ #map(key_compare&)
+ U& operator[](T&)
+ #map& operator=(map&)
+ bint operator==(map&, map&)
+ bint operator!=(map&, map&)
+ bint operator<(map&, map&)
+ bint operator>(map&, map&)
+ bint operator<=(map&, map&)
+ bint operator>=(map&, map&)
+ U& at(const T&) except +
+ const U& const_at "at"(const T&) except +
+ iterator begin()
+ const_iterator const_begin "begin" ()
+ void clear()
+ size_t count(const T&)
+ bint empty()
+ iterator end()
+ const_iterator const_end "end" ()
+ pair[iterator, iterator] equal_range(const T&)
+ #pair[const_iterator, const_iterator] equal_range(key_type&)
+ void erase(iterator)
+ void erase(iterator, 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)
+ #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"()
+ reverse_iterator rend()
+ const_reverse_iterator const_rend "rend"()
+ size_t size()
+ void swap(map&)
+ iterator upper_bound(const T&)
+ const_iterator const_upper_bound "upper_bound"(const T&)
+ #value_compare value_comp()
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd
new file mode 100644
index 0000000000..2151c1ec7f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/memory.pxd
@@ -0,0 +1,115 @@
+from libcpp cimport bool, nullptr_t, nullptr
+
+cdef extern from "<memory>" namespace "std" nogil:
+ cdef cppclass default_delete[T]:
+ default_delete()
+
+ cdef cppclass allocator[T]:
+ allocator()
+ allocator(const allocator &)
+ #allocator(const allocator[U] &) #unique_ptr unit tests fail w/this
+ T * address(T &)
+ const T * address(const T &) const
+ T * allocate( size_t n ) # Not to standard. should be a second default argument
+ void deallocate(T * , size_t)
+ size_t max_size() const
+ void construct( T *, const T &) #C++98. The C++11 version is variadic AND perfect-forwarding
+ void destroy(T *) #C++98
+ void destroy[U](U *) #unique_ptr unit tests fail w/this
+
+
+ cdef cppclass unique_ptr[T,DELETER=*]:
+ unique_ptr()
+ unique_ptr(nullptr_t)
+ unique_ptr(T*)
+ unique_ptr(unique_ptr[T]&)
+
+ # Modifiers
+ T* release()
+ void reset()
+ void reset(nullptr_t)
+ void reset(T*)
+ void swap(unique_ptr&)
+
+ # Observers
+ T* get()
+ T& operator*()
+ #T* operator->() # Not Supported
+ bool operator bool()
+ bool operator!()
+
+ bool operator==(const unique_ptr&)
+ bool operator!=(const unique_ptr&)
+ bool operator<(const unique_ptr&)
+ bool operator>(const unique_ptr&)
+ bool operator<=(const unique_ptr&)
+ bool operator>=(const unique_ptr&)
+
+ bool operator==(nullptr_t)
+ bool operator!=(nullptr_t)
+
+ # Forward Declaration not working ("Compiler crash in AnalyseDeclarationsTransform")
+ #cdef cppclass weak_ptr[T]
+
+ cdef cppclass shared_ptr[T]:
+ shared_ptr()
+ shared_ptr(nullptr_t)
+ shared_ptr(T*)
+ shared_ptr(shared_ptr[T]&)
+ shared_ptr(shared_ptr[T]&, T*)
+ shared_ptr(unique_ptr[T]&)
+ #shared_ptr(weak_ptr[T]&) # Not Supported
+
+ # Modifiers
+ void reset()
+ void reset(T*)
+ void swap(shared_ptr&)
+
+ # Observers
+ T* get()
+ T& operator*()
+ #T* operator->() # Not Supported
+ long use_count()
+ bool unique()
+ bool operator bool()
+ bool operator!()
+ #bool owner_before[Y](const weak_ptr[Y]&) # Not Supported
+ bool owner_before[Y](const shared_ptr[Y]&)
+
+ bool operator==(const shared_ptr&)
+ bool operator!=(const shared_ptr&)
+ bool operator<(const shared_ptr&)
+ bool operator>(const shared_ptr&)
+ bool operator<=(const shared_ptr&)
+ bool operator>=(const shared_ptr&)
+
+ bool operator==(nullptr_t)
+ bool operator!=(nullptr_t)
+
+ cdef cppclass weak_ptr[T]:
+ weak_ptr()
+ weak_ptr(weak_ptr[T]&)
+ weak_ptr(shared_ptr[T]&)
+
+ # Modifiers
+ void reset()
+ void swap(weak_ptr&)
+
+ # Observers
+ long use_count()
+ bool expired()
+ shared_ptr[T] lock()
+ bool owner_before[Y](const weak_ptr[Y]&)
+ bool owner_before[Y](const shared_ptr[Y]&)
+
+ # 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 +
+
+ # No checking on the compatibility of T and U.
+ cdef shared_ptr[T] static_pointer_cast[T, U](const shared_ptr[U]&)
+ cdef shared_ptr[T] dynamic_pointer_cast[T, U](const shared_ptr[U]&)
+ cdef shared_ptr[T] const_pointer_cast[T, U](const shared_ptr[U]&)
+ cdef shared_ptr[T] reinterpret_pointer_cast[T, U](const shared_ptr[U]&)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd b/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd
new file mode 100644
index 0000000000..869fe6674d
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/pair.pxd
@@ -0,0 +1 @@
+from .utility cimport pair
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd b/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd
new file mode 100644
index 0000000000..578cbd9159
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/queue.pxd
@@ -0,0 +1,25 @@
+cdef extern from "<queue>" namespace "std" nogil:
+ cdef cppclass queue[T]:
+ queue() except +
+ queue(queue&) except +
+ #queue(Container&)
+ T& back()
+ bint empty()
+ T& front()
+ void pop()
+ void push(T&)
+ size_t size()
+ # C++11 methods
+ void swap(queue&)
+
+ cdef cppclass priority_queue[T]:
+ priority_queue() except +
+ priority_queue(priority_queue&) except +
+ #priority_queue(Container&)
+ bint empty()
+ void pop()
+ void push(T&)
+ size_t size()
+ T& top()
+ # C++11 methods
+ void swap(priority_queue&)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd
new file mode 100644
index 0000000000..1069be7466
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/set.pxd
@@ -0,0 +1,61 @@
+from .utility cimport pair
+
+cdef extern from "<set>" namespace "std" nogil:
+ cdef cppclass set[T]:
+ ctypedef T value_type
+ cppclass iterator:
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(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
+ set() except +
+ set(set&) except +
+ #set(key_compare&)
+ #set& operator=(set&)
+ bint operator==(set&, set&)
+ bint operator!=(set&, set&)
+ bint operator<(set&, set&)
+ bint operator>(set&, set&)
+ bint operator<=(set&, set&)
+ bint operator>=(set&, set&)
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ size_t count(const T&)
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ pair[iterator, iterator] equal_range(const T&)
+ #pair[const_iterator, const_iterator] equal_range(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(const T&) except +
+ iterator insert(iterator, const T&) except +
+ void insert(iterator, iterator) except +
+ #key_compare key_comp()
+ iterator lower_bound(T&)
+ const_iterator const_lower_bound "lower_bound"(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(set&)
+ iterator upper_bound(const T&)
+ const_iterator const_upper_bound "upper_bound"(const T&)
+ #value_compare value_comp()
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd
new file mode 100644
index 0000000000..2dc80992b7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/stack.pxd
@@ -0,0 +1,11 @@
+cdef extern from "<stack>" namespace "std" nogil:
+ cdef cppclass stack[T]:
+ ctypedef T value_type
+ stack() except +
+ stack(stack&) except +
+ #stack(Container&)
+ bint empty()
+ void pop()
+ void push(T&)
+ 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
new file mode 100644
index 0000000000..a894144f1f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/string.pxd
@@ -0,0 +1,227 @@
+
+# deprecated cimport for backwards compatibility:
+from libc.string cimport const_char
+
+cdef extern from "<string>" namespace "std::string" nogil:
+ const size_t npos
+
+cdef extern from "<string>" namespace "std" nogil:
+ cdef cppclass string:
+
+ cppclass iterator:
+ iterator()
+ char& operator*()
+ iterator(iterator&)
+ iterator operator++()
+ iterator operator--()
+ bint operator==(iterator)
+ bint operator!=(iterator)
+
+ cppclass reverse_iterator:
+ char& operator*()
+ iterator operator++()
+ iterator operator--()
+ iterator operator+(size_t)
+ iterator operator-(size_t)
+ bint operator==(reverse_iterator)
+ bint operator!=(reverse_iterator)
+ bint operator<(reverse_iterator)
+ bint operator>(reverse_iterator)
+ bint operator<=(reverse_iterator)
+ bint operator>=(reverse_iterator)
+
+ cppclass const_iterator(iterator):
+ pass
+
+ cppclass const_reverse_iterator(reverse_iterator):
+ pass
+
+ string() except +
+ string(const string& s) except +
+ string(const string& s, size_t pos) except +
+ string(const string& s, size_t pos, size_t len) except +
+ string(const char* s) except +
+ string(const char* s, size_t n) except +
+ string(size_t n, char c) except +
+ string(iterator first, iterator last) except +
+
+ iterator begin()
+ const_iterator const_begin "begin"()
+ iterator end()
+ const_iterator const_end "end"()
+ reverse_iterator rbegin()
+ const_reverse_iterator const_rbegin "rbegin"()
+ reverse_iterator rend()
+ const_reverse_iterator const_rend "rend"()
+
+ const char* c_str()
+ const char* data()
+ size_t size()
+ size_t max_size()
+ size_t length()
+ void resize(size_t) except +
+ void resize(size_t, char) except +
+ void shrink_to_fit() except +
+ size_t capacity()
+ void reserve(size_t) except +
+ void clear()
+ bint empty()
+
+ iterator erase(iterator first, iterator last)
+ iterator erase(iterator p)
+ iterator erase(const_iterator first, const_iterator last)
+ iterator erase(const_iterator p)
+ string& erase(size_t pos, size_t len) except +
+ string& erase(size_t pos) except +
+ string& erase() except +
+
+ char& at(size_t pos) except +
+ char& operator[](size_t pos)
+ char& front()
+ char& back()
+ int compare(const string& s)
+ int compare(size_t pos, size_t len, const string& s) except +
+ int compare(size_t pos, size_t len, const string& s, size_t subpos, size_t sublen) except +
+ int compare(const char* s) except +
+ int compare(size_t pos, size_t len, const char* s) except +
+ int compare(size_t pos, size_t len, const char* s , size_t n) except +
+
+ string& append(const string& s) except +
+ string& append(const string& s, size_t subpos, size_t sublen) except +
+ string& append(const char* s) except +
+ string& append(const char* s, size_t n) except +
+ string& append(size_t n, char c) except +
+
+ void push_back(char c) except +
+ void pop_back()
+
+ string& assign(const string& s) except +
+ string& assign(const string& s, size_t subpos, size_t sublen) except +
+ string& assign(const char* s, size_t n) except +
+ string& assign(const char* s) except +
+ string& assign(size_t n, char c) except +
+
+ string& insert(size_t pos, const string& s, size_t subpos, size_t sublen) except +
+ string& insert(size_t pos, const string& s) except +
+ string& insert(size_t pos, const char* s, size_t n) except +
+ string& insert(size_t pos, const char* s) except +
+ string& insert(size_t pos, size_t n, char c) except +
+ void insert(iterator p, size_t n, char c) except +
+ iterator insert(iterator p, char c) except +
+
+ size_t copy(char* s, size_t len, size_t pos) except +
+ size_t copy(char* s, size_t len) except +
+
+ size_t find(const string& s, size_t pos)
+ size_t find(const string& s)
+ size_t find(const char* s, size_t pos, size_t n)
+ size_t find(const char* s, size_t pos)
+ size_t find(const char* s)
+ size_t find(char c, size_t pos)
+ size_t find(char c)
+
+ size_t rfind(const string&, size_t pos)
+ size_t rfind(const string&)
+ size_t rfind(const char* s, size_t pos, size_t n)
+ size_t rfind(const char* s, size_t pos)
+ size_t rfind(const char* s)
+ size_t rfind(char c, size_t pos)
+ size_t rfind(char c)
+
+ size_t find_first_of(const string&, size_t pos)
+ size_t find_first_of(const string&)
+ size_t find_first_of(const char* s, size_t pos, size_t n)
+ size_t find_first_of(const char* s, size_t pos)
+ size_t find_first_of(const char* s)
+ size_t find_first_of(char c, size_t pos)
+ size_t find_first_of(char c)
+
+ size_t find_first_not_of(const string& s, size_t pos)
+ size_t find_first_not_of(const string& s)
+ size_t find_first_not_of(const char* s, size_t pos, size_t n)
+ size_t find_first_not_of(const char* s, size_t pos)
+ size_t find_first_not_of(const char*)
+ size_t find_first_not_of(char c, size_t pos)
+ size_t find_first_not_of(char c)
+
+ size_t find_last_of(const string& s, size_t pos)
+ size_t find_last_of(const string& s)
+ size_t find_last_of(const char* s, size_t pos, size_t n)
+ size_t find_last_of(const char* s, size_t pos)
+ size_t find_last_of(const char* s)
+ size_t find_last_of(char c, size_t pos)
+ size_t find_last_of(char c)
+
+ size_t find_last_not_of(const string& s, size_t pos)
+ size_t find_last_not_of(const string& s)
+ size_t find_last_not_of(const char* s, size_t pos, size_t n)
+ size_t find_last_not_of(const char* s, size_t pos)
+ size_t find_last_not_of(const char* s)
+ size_t find_last_not_of(char c, size_t pos)
+ size_t find_last_not_of(char c)
+
+ string substr(size_t pos, size_t len) except +
+ string substr(size_t pos) except +
+ string substr()
+
+ #string& operator= (const string&)
+ #string& operator= (const char*)
+ #string& operator= (char)
+
+ string operator+ (const string&) except +
+ string operator+ (const char*) except +
+
+ bint operator==(const string&)
+ bint operator==(const char*)
+
+ bint operator!= (const string&)
+ bint operator!= (const char*)
+
+ bint operator< (const string&)
+ bint operator< (const char*)
+
+ bint operator> (const string&)
+ bint operator> (const char*)
+
+ bint operator<= (const string&)
+ bint operator<= (const char*)
+
+ bint operator>= (const string&)
+ bint operator>= (const char*)
+
+
+ string to_string(int val) except +
+ string to_string(long val) except +
+ string to_string(long long val) except +
+ string to_string(unsigned val) except +
+ string to_string(size_t val) except +
+ string to_string(ssize_t val) except +
+ string to_string(unsigned long val) except +
+ string to_string(unsigned long long val) except +
+ string to_string(float val) except +
+ string to_string(double val) except +
+ string to_string(long double val) except +
+
+ int stoi(const string& s, size_t* idx, int base) except +
+ int stoi(const string& s, size_t* idx) except +
+ int stoi(const string& s) except +
+ long stol(const string& s, size_t* idx, int base) except +
+ long stol(const string& s, size_t* idx) except +
+ long stol(const string& s) except +
+ long long stoll(const string& s, size_t* idx, int base) except +
+ long long stoll(const string& s, size_t* idx) except +
+ long long stoll(const string& s) except +
+
+ unsigned long stoul(const string& s, size_t* idx, int base) except +
+ unsigned long stoul(const string& s, size_t* idx) except +
+ unsigned long stoul(const string& s) except +
+ unsigned long long stoull(const string& s, size_t* idx, int base) except +
+ unsigned long long stoull(const string& s, size_t* idx) except +
+ unsigned long long stoull(const string& s) except +
+
+ float stof(const string& s, size_t* idx) except +
+ float stof(const string& s) except +
+ double stod(const string& s, size_t* idx) except +
+ double stod(const string& s) except +
+ long double stold(const string& s, size_t* idx) except +
+ long double stold(const string& s) except +
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd b/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd
new file mode 100644
index 0000000000..d5b7e9149f
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/typeindex.pxd
@@ -0,0 +1,15 @@
+from libcpp cimport bool
+from .typeinfo cimport type_info
+
+# This class is C++11-only
+cdef extern from "<typeindex>" namespace "std" nogil:
+ cdef cppclass type_index:
+ type_index(const type_info &)
+ const char* name()
+ size_t hash_code()
+ bool operator==(const type_index &)
+ bool operator!=(const type_index &)
+ bool operator<(const type_index &)
+ bool operator<=(const type_index &)
+ bool operator>(const type_index &)
+ bool operator>=(const type_index &)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd b/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd
new file mode 100644
index 0000000000..9118e00649
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/typeinfo.pxd
@@ -0,0 +1,10 @@
+from libcpp cimport bool
+
+cdef extern from "<typeinfo>" namespace "std" nogil:
+ cdef cppclass type_info:
+ const char* name()
+ int before(const type_info&)
+ bool operator==(const type_info&)
+ bool operator!=(const type_info&)
+ # C++11-only
+ size_t hash_code()
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd
new file mode 100644
index 0000000000..a00fbbed28
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_map.pxd
@@ -0,0 +1,74 @@
+from .utility cimport pair
+
+cdef extern from "<unordered_map>" namespace "std" nogil:
+ cdef cppclass unordered_map[T, U, HASH=*, PRED=*, ALLOCATOR=*]:
+ ctypedef T key_type
+ ctypedef U mapped_type
+ ctypedef pair[const T, U] value_type
+ cppclass iterator:
+ pair[T, U]& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(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
+ unordered_map() except +
+ unordered_map(unordered_map&) except +
+ #unordered_map(key_compare&)
+ U& operator[](T&)
+ #unordered_map& operator=(unordered_map&)
+ bint operator==(unordered_map&, unordered_map&)
+ bint operator!=(unordered_map&, unordered_map&)
+ bint operator<(unordered_map&, unordered_map&)
+ 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&)
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ size_t count(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"(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)
+ #key_compare key_comp()
+ iterator lower_bound(T&)
+ const_iterator const_lower_bound "lower_bound"(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&)
+ #value_compare value_comp()
+ void max_load_factor(float)
+ float max_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&)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd
new file mode 100644
index 0000000000..5aa2417528
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/unordered_set.pxd
@@ -0,0 +1,69 @@
+from .utility cimport pair
+
+cdef extern from "<unordered_set>" namespace "std" nogil:
+ cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]:
+ ctypedef T value_type
+ cppclass iterator:
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(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
+ 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"()
+ void clear()
+ size_t count(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&)
+ 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&)
+ 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()
+ 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&)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd b/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd
new file mode 100644
index 0000000000..e0df69b166
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/utility.pxd
@@ -0,0 +1,30 @@
+cdef extern from "<utility>" namespace "std" nogil:
+ cdef cppclass pair[T, U]:
+ ctypedef T first_type
+ ctypedef U second_type
+ T first
+ U second
+ pair() except +
+ pair(pair&) except +
+ pair(T&, U&) except +
+ bint operator==(pair&, pair&)
+ bint operator!=(pair&, pair&)
+ bint operator<(pair&, pair&)
+ bint operator>(pair&, pair&)
+ bint operator<=(pair&, pair&)
+ bint operator>=(pair&, pair&)
+
+cdef extern from * namespace "cython_std" nogil:
+ """
+ #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
+ // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully
+ #include <type_traits>
+
+ namespace cython_std {
+ template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); }
+ template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); }
+ }
+
+ #endif
+ """
+ cdef T move[T](T)
diff --git a/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd
new file mode 100644
index 0000000000..9b007dd0c7
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/libcpp/vector.pxd
@@ -0,0 +1,88 @@
+cdef extern from "<vector>" namespace "std" nogil:
+ cdef cppclass vector[T,ALLOCATOR=*]:
+ ctypedef T 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:
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ iterator operator+(size_type)
+ iterator operator-(size_type)
+ difference_type operator-(iterator)
+ bint operator==(iterator)
+ bint operator!=(iterator)
+ bint operator<(iterator)
+ bint operator>(iterator)
+ bint operator<=(iterator)
+ bint operator>=(iterator)
+ cppclass reverse_iterator:
+ T& operator*()
+ reverse_iterator operator++()
+ reverse_iterator operator--()
+ reverse_iterator operator+(size_type)
+ reverse_iterator operator-(size_type)
+ difference_type operator-(reverse_iterator)
+ bint operator==(reverse_iterator)
+ bint operator!=(reverse_iterator)
+ bint operator<(reverse_iterator)
+ bint operator>(reverse_iterator)
+ bint operator<=(reverse_iterator)
+ bint operator>=(reverse_iterator)
+ cppclass const_iterator(iterator):
+ pass
+ cppclass const_reverse_iterator(reverse_iterator):
+ pass
+ vector() except +
+ vector(vector&) except +
+ vector(size_type) except +
+ vector(size_type, T&) except +
+ #vector[input_iterator](input_iterator, input_iterator)
+ T& operator[](size_type)
+ #vector& operator=(vector&)
+ bint operator==(vector&, vector&)
+ bint operator!=(vector&, vector&)
+ bint operator<(vector&, vector&)
+ bint operator>(vector&, vector&)
+ bint operator<=(vector&, vector&)
+ bint operator>=(vector&, vector&)
+ void assign(size_type, const T&)
+ void assign[input_iterator](input_iterator, input_iterator) except +
+ T& at(size_type) except +
+ T& back()
+ iterator begin()
+ const_iterator const_begin "begin"()
+ size_type capacity()
+ void clear()
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ 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 +
+ size_type max_size()
+ void pop_back()
+ void push_back(T&) except +
+ reverse_iterator rbegin()
+ const_reverse_iterator const_rbegin "crbegin"()
+ reverse_iterator rend()
+ const_reverse_iterator const_rend "crend"()
+ void reserve(size_type)
+ void resize(size_type) except +
+ void resize(size_type, T&) except +
+ size_type size()
+ void swap(vector&)
+
+ # C++11 methods
+ T* data()
+ const T* const_data "data"()
+ void shrink_to_fit()
diff --git a/contrib/tools/cython/Cython/Includes/numpy.pxd b/contrib/tools/cython/Cython/Includes/numpy.pxd
new file mode 100644
index 0000000000..789669dac1
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/numpy.pxd
@@ -0,0 +1,1050 @@
+# 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).
+#
+# 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.
+#
+# 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
+cimport libc.stdio as stdio
+
+cdef extern from "Python.h":
+ ctypedef int Py_intptr_t
+
+cdef extern from "numpy/arrayobject.h":
+ ctypedef Py_intptr_t npy_intp
+ ctypedef size_t npy_uintp
+
+ cdef enum NPY_TYPES:
+ NPY_BOOL
+ NPY_BYTE
+ NPY_UBYTE
+ NPY_SHORT
+ NPY_USHORT
+ NPY_INT
+ NPY_UINT
+ NPY_LONG
+ NPY_ULONG
+ NPY_LONGLONG
+ NPY_ULONGLONG
+ NPY_FLOAT
+ NPY_DOUBLE
+ NPY_LONGDOUBLE
+ NPY_CFLOAT
+ NPY_CDOUBLE
+ NPY_CLONGDOUBLE
+ NPY_OBJECT
+ NPY_STRING
+ NPY_UNICODE
+ NPY_VOID
+ NPY_DATETIME
+ NPY_TIMEDELTA
+ NPY_NTYPES
+ NPY_NOTYPE
+
+ NPY_INT8
+ NPY_INT16
+ NPY_INT32
+ NPY_INT64
+ NPY_INT128
+ NPY_INT256
+ NPY_UINT8
+ NPY_UINT16
+ NPY_UINT32
+ NPY_UINT64
+ NPY_UINT128
+ NPY_UINT256
+ NPY_FLOAT16
+ NPY_FLOAT32
+ NPY_FLOAT64
+ NPY_FLOAT80
+ NPY_FLOAT96
+ NPY_FLOAT128
+ NPY_FLOAT256
+ NPY_COMPLEX32
+ NPY_COMPLEX64
+ NPY_COMPLEX128
+ NPY_COMPLEX160
+ NPY_COMPLEX192
+ NPY_COMPLEX256
+ NPY_COMPLEX512
+
+ NPY_INTP
+
+ ctypedef enum NPY_ORDER:
+ NPY_ANYORDER
+ NPY_CORDER
+ NPY_FORTRANORDER
+ NPY_KEEPORDER
+
+ ctypedef enum NPY_CASTING:
+ NPY_NO_CASTING
+ NPY_EQUIV_CASTING
+ NPY_SAFE_CASTING
+ NPY_SAME_KIND_CASTING
+ NPY_UNSAFE_CASTING
+
+ ctypedef enum NPY_CLIPMODE:
+ NPY_CLIP
+ NPY_WRAP
+ NPY_RAISE
+
+ ctypedef enum NPY_SCALARKIND:
+ NPY_NOSCALAR,
+ NPY_BOOL_SCALAR,
+ NPY_INTPOS_SCALAR,
+ NPY_INTNEG_SCALAR,
+ NPY_FLOAT_SCALAR,
+ NPY_COMPLEX_SCALAR,
+ NPY_OBJECT_SCALAR
+
+ ctypedef enum NPY_SORTKIND:
+ NPY_QUICKSORT
+ NPY_HEAPSORT
+ NPY_MERGESORT
+
+ ctypedef enum NPY_SEARCHSIDE:
+ NPY_SEARCHLEFT
+ NPY_SEARCHRIGHT
+
+ enum:
+ # DEPRECATED since NumPy 1.7 ! Do not use in new code!
+ NPY_C_CONTIGUOUS
+ NPY_F_CONTIGUOUS
+ NPY_CONTIGUOUS
+ NPY_FORTRAN
+ NPY_OWNDATA
+ NPY_FORCECAST
+ NPY_ENSURECOPY
+ NPY_ENSUREARRAY
+ NPY_ELEMENTSTRIDES
+ NPY_ALIGNED
+ NPY_NOTSWAPPED
+ NPY_WRITEABLE
+ NPY_UPDATEIFCOPY
+ NPY_ARR_HAS_DESCR
+
+ NPY_BEHAVED
+ NPY_BEHAVED_NS
+ NPY_CARRAY
+ NPY_CARRAY_RO
+ NPY_FARRAY
+ NPY_FARRAY_RO
+ NPY_DEFAULT
+
+ NPY_IN_ARRAY
+ NPY_OUT_ARRAY
+ NPY_INOUT_ARRAY
+ NPY_IN_FARRAY
+ NPY_OUT_FARRAY
+ NPY_INOUT_FARRAY
+
+ NPY_UPDATE_ALL
+
+ enum:
+ # Added in NumPy 1.7 to replace the deprecated enums above.
+ NPY_ARRAY_C_CONTIGUOUS
+ NPY_ARRAY_F_CONTIGUOUS
+ NPY_ARRAY_OWNDATA
+ NPY_ARRAY_FORCECAST
+ NPY_ARRAY_ENSURECOPY
+ NPY_ARRAY_ENSUREARRAY
+ NPY_ARRAY_ELEMENTSTRIDES
+ NPY_ARRAY_ALIGNED
+ NPY_ARRAY_NOTSWAPPED
+ NPY_ARRAY_WRITEABLE
+ NPY_ARRAY_UPDATEIFCOPY
+
+ NPY_ARRAY_BEHAVED
+ NPY_ARRAY_BEHAVED_NS
+ NPY_ARRAY_CARRAY
+ NPY_ARRAY_CARRAY_RO
+ NPY_ARRAY_FARRAY
+ NPY_ARRAY_FARRAY_RO
+ NPY_ARRAY_DEFAULT
+
+ NPY_ARRAY_IN_ARRAY
+ NPY_ARRAY_OUT_ARRAY
+ NPY_ARRAY_INOUT_ARRAY
+ NPY_ARRAY_IN_FARRAY
+ NPY_ARRAY_OUT_FARRAY
+ NPY_ARRAY_INOUT_FARRAY
+
+ NPY_ARRAY_UPDATE_ALL
+
+ cdef enum:
+ NPY_MAXDIMS
+
+ npy_intp NPY_MAX_ELSIZE
+
+ ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
+
+ ctypedef struct PyArray_ArrayDescr:
+ # shape is a tuple, but Cython doesn't support "tuple shape"
+ # inside a non-PyObject declaration, so we have to declare it
+ # as just a PyObject*.
+ PyObject* shape
+
+ ctypedef struct PyArray_Descr:
+ pass
+
+ ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]:
+ # Use PyDataType_* macros when possible, however there are no macros
+ # for accessing some of the fields, so some are defined.
+ cdef PyTypeObject* typeobj
+ cdef char kind
+ cdef char type
+ # Numpy sometimes mutates this without warning (e.g. it'll
+ # sometimes change "|" to "<" in shared dtype objects on
+ # little-endian machines). If this matters to you, use
+ # PyArray_IsNativeByteOrder(dtype.byteorder) instead of
+ # directly accessing this field.
+ cdef char byteorder
+ cdef char flags
+ cdef int type_num
+ cdef int itemsize "elsize"
+ cdef int alignment
+ cdef dict fields
+ cdef tuple names
+ # Use PyDataType_HASSUBARRAY to test whether this field is
+ # valid (the pointer can be NULL). Most users should access
+ # this field via the inline helper method PyDataType_SHAPE.
+ cdef PyArray_ArrayDescr* subarray
+
+ ctypedef extern class numpy.flatiter [object PyArrayIterObject]:
+ # Use through macros
+ pass
+
+ ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]:
+ # Use through macros
+ pass
+
+ ctypedef struct PyArrayObject:
+ # For use in situations where ndarray can't replace PyArrayObject*,
+ # like PyArrayObject**.
+ pass
+
+ 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
+
+
+ ctypedef unsigned char npy_bool
+
+ ctypedef signed char npy_byte
+ ctypedef signed short npy_short
+ ctypedef signed int npy_int
+ ctypedef signed long npy_long
+ ctypedef signed long long npy_longlong
+
+ ctypedef unsigned char npy_ubyte
+ ctypedef unsigned short npy_ushort
+ ctypedef unsigned int npy_uint
+ ctypedef unsigned long npy_ulong
+ ctypedef unsigned long long npy_ulonglong
+
+ ctypedef float npy_float
+ ctypedef double npy_double
+ ctypedef long double npy_longdouble
+
+ ctypedef signed char npy_int8
+ ctypedef signed short npy_int16
+ ctypedef signed int npy_int32
+ ctypedef signed long long npy_int64
+ ctypedef signed long long npy_int96
+ ctypedef signed long long npy_int128
+
+ ctypedef unsigned char npy_uint8
+ ctypedef unsigned short npy_uint16
+ ctypedef unsigned int npy_uint32
+ ctypedef unsigned long long npy_uint64
+ ctypedef unsigned long long npy_uint96
+ ctypedef unsigned long long npy_uint128
+
+ ctypedef float npy_float32
+ ctypedef double npy_float64
+ ctypedef long double npy_float80
+ ctypedef long double npy_float96
+ ctypedef long double npy_float128
+
+ ctypedef struct npy_cfloat:
+ double real
+ double imag
+
+ ctypedef struct npy_cdouble:
+ double real
+ double imag
+
+ ctypedef struct npy_clongdouble:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex64:
+ float real
+ float imag
+
+ ctypedef struct npy_complex128:
+ double real
+ double imag
+
+ ctypedef struct npy_complex160:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex192:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex256:
+ long double real
+ long double imag
+
+ ctypedef struct PyArray_Dims:
+ npy_intp *ptr
+ int len
+
+ int _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)
+
+ 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 PyArray_DescrCheck(object)
+
+ bint PyArray_Check(object)
+ bint PyArray_CheckExact(object)
+
+ # Cannot be supported due to out arg:
+ # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
+ # bint PyArray_HasArrayInterface(op, out)
+
+
+ bint PyArray_IsZeroDim(object)
+ # Cannot be supported due to ## ## in macro:
+ # bint PyArray_IsScalar(object, verbatim work)
+ bint PyArray_CheckScalar(object)
+ bint PyArray_IsPythonNumber(object)
+ 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)
+
+ object PyArray_FROM_O(object)
+ object PyArray_FROM_OF(object m, int flags)
+ object PyArray_FROM_OT(object m, int type)
+ object PyArray_FROM_OTF(object m, int type, int flags)
+ object PyArray_FROMANY(object m, int type, int min, int max, int flags)
+ object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran)
+ object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran)
+ void PyArray_FILLWBYTE(object, int val)
+ 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)
+ 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_XDECREF_ERR(ndarray)
+ # Cannot be supported due to out arg
+ # void PyArray_DESCR_REPLACE(descr)
+
+
+ object PyArray_Copy(ndarray)
+ object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
+ object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
+ object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
+
+ object PyArray_Cast(ndarray mp, int type_num)
+ object PyArray_Take(ndarray ap, object items, int axis)
+ object PyArray_Put(ndarray ap, object items, object values)
+
+ void PyArray_ITER_RESET(flatiter it) nogil
+ void PyArray_ITER_NEXT(flatiter it) nogil
+ void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
+ void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
+ void* PyArray_ITER_DATA(flatiter it) nogil
+ bint PyArray_ITER_NOTDONE(flatiter it) nogil
+
+ void PyArray_MultiIter_RESET(broadcast multi) nogil
+ void PyArray_MultiIter_NEXT(broadcast multi) nogil
+ void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
+ void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil
+ void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil
+ void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil
+ bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil
+
+ # Functions from __multiarray_api.h
+
+ # Functions taking dtype and returning object/ndarray are disabled
+ # for now as they steal dtype references. I'm conservative and disable
+ # more than is probably needed until it can be checked further.
+ int PyArray_SetNumericOps (object)
+ object PyArray_GetNumericOps ()
+ int PyArray_INCREF (ndarray)
+ int PyArray_XDECREF (ndarray)
+ void PyArray_SetStringFunction (object, int)
+ dtype PyArray_DescrFromType (int)
+ object PyArray_TypeObjectFromType (int)
+ char * PyArray_Zero (ndarray)
+ char * PyArray_One (ndarray)
+ #object PyArray_CastToType (ndarray, dtype, int)
+ int PyArray_CastTo (ndarray, ndarray)
+ int PyArray_CastAnyTo (ndarray, ndarray)
+ int PyArray_CanCastSafely (int, int)
+ npy_bool PyArray_CanCastTo (dtype, dtype)
+ int PyArray_ObjectType (object, int)
+ dtype PyArray_DescrFromObject (object, dtype)
+ #ndarray* PyArray_ConvertToCommonType (object, int *)
+ dtype PyArray_DescrFromScalar (object)
+ dtype PyArray_DescrFromTypeObject (object)
+ npy_intp PyArray_Size (object)
+ #object PyArray_Scalar (void *, dtype, object)
+ #object PyArray_FromScalar (object, dtype)
+ void PyArray_ScalarAsCtype (object, void *)
+ #int PyArray_CastScalarToCtype (object, void *, dtype)
+ #int PyArray_CastScalarDirect (object, dtype, void *, int)
+ object PyArray_ScalarFromObject (object)
+ #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int)
+ object PyArray_FromDims (int, int *, int)
+ #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *)
+ #object PyArray_FromAny (object, dtype, int, int, int, object)
+ object PyArray_EnsureArray (object)
+ object PyArray_EnsureAnyArray (object)
+ #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *)
+ #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *)
+ #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp)
+ #object PyArray_FromIter (object, dtype, npy_intp)
+ object PyArray_Return (ndarray)
+ #object PyArray_GetField (ndarray, dtype, int)
+ #int PyArray_SetField (ndarray, dtype, int, object)
+ object PyArray_Byteswap (ndarray, npy_bool)
+ object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER)
+ int PyArray_MoveInto (ndarray, ndarray)
+ int PyArray_CopyInto (ndarray, ndarray)
+ int PyArray_CopyAnyInto (ndarray, ndarray)
+ int PyArray_CopyObject (ndarray, object)
+ object PyArray_NewCopy (ndarray, NPY_ORDER)
+ object PyArray_ToList (ndarray)
+ object PyArray_ToString (ndarray, NPY_ORDER)
+ int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *)
+ int PyArray_Dump (object, object, int)
+ object PyArray_Dumps (object, int)
+ int PyArray_ValidType (int)
+ void PyArray_UpdateFlags (ndarray, int)
+ object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
+ #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
+ #dtype PyArray_DescrNew (dtype)
+ dtype PyArray_DescrNewFromType (int)
+ double PyArray_GetPriority (object, double)
+ object PyArray_IterNew (object)
+ object PyArray_MultiIterNew (int, ...)
+
+ int PyArray_PyIntAsInt (object)
+ npy_intp PyArray_PyIntAsIntp (object)
+ int PyArray_Broadcast (broadcast)
+ void PyArray_FillObjectArray (ndarray, object)
+ int PyArray_FillWithScalar (ndarray, object)
+ npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
+ dtype PyArray_DescrNewByteorder (dtype, char)
+ object PyArray_IterAllButAxis (object, int *)
+ #object PyArray_CheckFromAny (object, dtype, int, int, int, object)
+ #object PyArray_FromArray (ndarray, dtype, int)
+ object PyArray_FromInterface (object)
+ object PyArray_FromStructInterface (object)
+ #object PyArray_FromArrayAttr (object, dtype, object)
+ #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*)
+ int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND)
+ object PyArray_NewFlagsObject (object)
+ npy_bool PyArray_CanCastScalar (type, type)
+ #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t)
+ int PyArray_RemoveSmallest (broadcast)
+ int PyArray_ElementStrides (object)
+ void PyArray_Item_INCREF (char *, dtype)
+ void PyArray_Item_XDECREF (char *, dtype)
+ object PyArray_FieldNames (object)
+ object PyArray_Transpose (ndarray, PyArray_Dims *)
+ object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE)
+ object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE)
+ object PyArray_PutMask (ndarray, object, object)
+ object PyArray_Repeat (ndarray, object, int)
+ 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)
+ object PyArray_ArgMax (ndarray, int, ndarray)
+ object PyArray_ArgMin (ndarray, int, ndarray)
+ object PyArray_Reshape (ndarray, object)
+ object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER)
+ object PyArray_Squeeze (ndarray)
+ #object PyArray_View (ndarray, dtype, type)
+ object PyArray_SwapAxes (ndarray, int, int)
+ object PyArray_Max (ndarray, int, ndarray)
+ object PyArray_Min (ndarray, int, ndarray)
+ object PyArray_Ptp (ndarray, int, ndarray)
+ object PyArray_Mean (ndarray, int, int, ndarray)
+ object PyArray_Trace (ndarray, int, int, int, int, ndarray)
+ object PyArray_Diagonal (ndarray, int, int, int)
+ object PyArray_Clip (ndarray, object, object, ndarray)
+ object PyArray_Conjugate (ndarray, ndarray)
+ object PyArray_Nonzero (ndarray)
+ object PyArray_Std (ndarray, int, int, ndarray, int)
+ object PyArray_Sum (ndarray, int, int, ndarray)
+ object PyArray_CumSum (ndarray, int, int, ndarray)
+ object PyArray_Prod (ndarray, int, int, ndarray)
+ object PyArray_CumProd (ndarray, int, int, ndarray)
+ object PyArray_All (ndarray, int, ndarray)
+ object PyArray_Any (ndarray, int, ndarray)
+ object PyArray_Compress (ndarray, object, int, ndarray)
+ object PyArray_Flatten (ndarray, NPY_ORDER)
+ object PyArray_Ravel (ndarray, NPY_ORDER)
+ npy_intp PyArray_MultiplyList (npy_intp *, int)
+ int PyArray_MultiplyIntList (int *, int)
+ void * PyArray_GetPtr (ndarray, npy_intp*)
+ int PyArray_CompareLists (npy_intp *, npy_intp *, int)
+ #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype)
+ #int PyArray_As1D (object*, char **, int *, int)
+ #int PyArray_As2D (object*, char ***, int *, int *, int)
+ int PyArray_Free (object, void *)
+ #int PyArray_Converter (object, object*)
+ int PyArray_IntpFromSequence (object, npy_intp *, int)
+ object PyArray_Concatenate (object, int)
+ object PyArray_InnerProduct (object, object)
+ object PyArray_MatrixProduct (object, object)
+ object PyArray_CopyAndTranspose (object)
+ object PyArray_Correlate (object, object, int)
+ int PyArray_TypestrConvert (int, int)
+ #int PyArray_DescrConverter (object, dtype*)
+ #int PyArray_DescrConverter2 (object, dtype*)
+ int PyArray_IntpConverter (object, PyArray_Dims *)
+ #int PyArray_BufferConverter (object, chunk)
+ int PyArray_AxisConverter (object, int *)
+ int PyArray_BoolConverter (object, npy_bool *)
+ int PyArray_ByteorderConverter (object, char *)
+ int PyArray_OrderConverter (object, NPY_ORDER *)
+ unsigned char PyArray_EquivTypes (dtype, dtype)
+ #object PyArray_Zeros (int, npy_intp *, dtype, int)
+ #object PyArray_Empty (int, npy_intp *, dtype, int)
+ object PyArray_Where (object, object, object)
+ object PyArray_Arange (double, double, double, int)
+ #object PyArray_ArangeObj (object, object, object, dtype)
+ int PyArray_SortkindConverter (object, NPY_SORTKIND *)
+ object PyArray_LexSort (object, int)
+ object PyArray_Round (ndarray, int, ndarray)
+ unsigned char PyArray_EquivTypenums (int, int)
+ int PyArray_RegisterDataType (dtype)
+ int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *)
+ int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND)
+ #void PyArray_InitArrFuncs (PyArray_ArrFuncs *)
+ object PyArray_IntTupleFromIntp (int, npy_intp *)
+ int PyArray_TypeNumFromName (char *)
+ int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *)
+ #int PyArray_OutputConverter (object, ndarray*)
+ object PyArray_BroadcastToShape (object, npy_intp *, int)
+ void _PyArray_SigintHandler (int)
+ void* _PyArray_GetSigintBuf ()
+ #int PyArray_DescrAlignConverter (object, dtype*)
+ #int PyArray_DescrAlignConverter2 (object, dtype*)
+ int PyArray_SearchsideConverter (object, void *)
+ object PyArray_CheckAxis (ndarray, int *, int)
+ npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
+ int PyArray_CompareString (char *, char *, size_t)
+ int PyArray_SetBaseObject(ndarray, base) # NOTE: steals a reference to base! Use "set_array_base()" instead.
+
+
+# Typedefs that matches the runtime dtype objects in
+# the numpy module.
+
+# The ones that are commented out needs an IFDEF function
+# in Cython to enable them only on the right systems.
+
+ctypedef npy_int8 int8_t
+ctypedef npy_int16 int16_t
+ctypedef npy_int32 int32_t
+ctypedef npy_int64 int64_t
+#ctypedef npy_int96 int96_t
+#ctypedef npy_int128 int128_t
+
+ctypedef npy_uint8 uint8_t
+ctypedef npy_uint16 uint16_t
+ctypedef npy_uint32 uint32_t
+ctypedef npy_uint64 uint64_t
+#ctypedef npy_uint96 uint96_t
+#ctypedef npy_uint128 uint128_t
+
+ctypedef npy_float32 float32_t
+ctypedef npy_float64 float64_t
+#ctypedef npy_float80 float80_t
+#ctypedef npy_float128 float128_t
+
+ctypedef float complex complex64_t
+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
+ctypedef npy_uintp uintp_t
+
+ctypedef npy_double float_t
+ctypedef npy_double double_t
+ctypedef npy_longdouble longdouble_t
+
+ctypedef npy_cfloat cfloat_t
+ctypedef npy_cdouble cdouble_t
+ctypedef npy_clongdouble clongdouble_t
+
+ctypedef npy_cdouble complex_t
+
+cdef inline object PyArray_MultiIterNew1(a):
+ return PyArray_MultiIterNew(1, <void*>a)
+
+cdef inline object PyArray_MultiIterNew2(a, b):
+ return PyArray_MultiIterNew(2, <void*>a, <void*>b)
+
+cdef inline object PyArray_MultiIterNew3(a, b, c):
+ return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
+
+cdef inline object PyArray_MultiIterNew4(a, b, c, d):
+ return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
+
+cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
+ return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
+
+cdef inline tuple PyDataType_SHAPE(dtype d):
+ if PyDataType_HASSUBARRAY(d):
+ return <tuple>d.subarray.shape
+ 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
+
+
+#
+# ufunc API
+#
+
+cdef extern from "numpy/ufuncobject.h":
+
+ ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
+
+ ctypedef extern class numpy.ufunc [object PyUFuncObject]:
+ cdef:
+ int nin, nout, nargs
+ int identity
+ PyUFuncGenericFunction *functions
+ void **data
+ int ntypes
+ int check_return
+ char *name
+ char *types
+ char *doc
+ void *ptr
+ PyObject *obj
+ PyObject *userloops
+
+ cdef enum:
+ PyUFunc_Zero
+ PyUFunc_One
+ PyUFunc_None
+ UFUNC_ERR_IGNORE
+ UFUNC_ERR_WARN
+ UFUNC_ERR_RAISE
+ UFUNC_ERR_CALL
+ UFUNC_ERR_PRINT
+ UFUNC_ERR_LOG
+ UFUNC_MASK_DIVIDEBYZERO
+ UFUNC_MASK_OVERFLOW
+ UFUNC_MASK_UNDERFLOW
+ UFUNC_MASK_INVALID
+ UFUNC_SHIFT_DIVIDEBYZERO
+ UFUNC_SHIFT_OVERFLOW
+ UFUNC_SHIFT_UNDERFLOW
+ UFUNC_SHIFT_INVALID
+ UFUNC_FPE_DIVIDEBYZERO
+ UFUNC_FPE_OVERFLOW
+ UFUNC_FPE_UNDERFLOW
+ UFUNC_FPE_INVALID
+ UFUNC_ERR_DEFAULT
+ UFUNC_ERR_DEFAULT2
+
+ object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
+ void **, char *, int, int, int, int, char *, char *, int)
+ int PyUFunc_RegisterLoopForType(ufunc, int,
+ PyUFuncGenericFunction, int *, void *)
+ int PyUFunc_GenericFunction \
+ (ufunc, PyObject *, PyObject *, PyArrayObject **)
+ void PyUFunc_f_f_As_d_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_d_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_f_f \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_g_g \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_F_F_As_D_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_F_F \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_D_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_G_G \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_O_O \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_ff_f_As_dd_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_ff_f \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_dd_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_gg_g \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_FF_F_As_DD_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_DD_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_FF_F \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_GG_G \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_OO_O \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_O_O_method \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_OO_O_method \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_On_Om \
+ (char **, npy_intp *, npy_intp *, void *)
+ int PyUFunc_GetPyValues \
+ (char *, int *, int *, PyObject **)
+ int PyUFunc_checkfperr \
+ (int, PyObject *, int *)
+ void PyUFunc_clearfperr()
+ int PyUFunc_getfperr()
+ int PyUFunc_handlefperr \
+ (int, PyObject *, int, int *)
+ int PyUFunc_ReplaceLoopBySignature \
+ (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)
+ object PyUFunc_FromFuncAndDataAndSignature \
+ (PyUFuncGenericFunction *, void **, char *, int, int, int,
+ int, char *, char *, int, char *)
+
+ int _import_umath() except -1
+
+cdef inline void set_array_base(ndarray arr, object base):
+ Py_INCREF(base) # important to do this before stealing the reference below!
+ PyArray_SetBaseObject(arr, base)
+
+cdef inline object get_array_base(ndarray arr):
+ base = PyArray_BASE(arr)
+ if base is NULL:
+ return None
+ return <object>base
+
+# Versions of the import_* functions which are more suitable for
+# Cython code.
+cdef inline int import_array() except -1:
+ try:
+ _import_array()
+ except Exception:
+ raise ImportError("numpy.core.multiarray failed to import")
+
+cdef inline int import_umath() except -1:
+ try:
+ _import_umath()
+ except Exception:
+ raise ImportError("numpy.core.umath failed to import")
+
+cdef inline int import_ufunc() except -1:
+ try:
+ _import_umath()
+ except Exception:
+ raise ImportError("numpy.core.umath failed to import")
diff --git a/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd
new file mode 100644
index 0000000000..15700c05ef
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/numpy/__init__.pxd
@@ -0,0 +1,1049 @@
+# 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).
+#
+# 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.
+#
+# 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
+cimport libc.stdio as stdio
+
+cdef extern from "Python.h":
+ ctypedef int Py_intptr_t
+
+cdef extern from "numpy/arrayobject.h":
+ ctypedef Py_intptr_t npy_intp
+ ctypedef size_t npy_uintp
+
+ cdef enum NPY_TYPES:
+ NPY_BOOL
+ NPY_BYTE
+ NPY_UBYTE
+ NPY_SHORT
+ NPY_USHORT
+ NPY_INT
+ NPY_UINT
+ NPY_LONG
+ NPY_ULONG
+ NPY_LONGLONG
+ NPY_ULONGLONG
+ NPY_FLOAT
+ NPY_DOUBLE
+ NPY_LONGDOUBLE
+ NPY_CFLOAT
+ NPY_CDOUBLE
+ NPY_CLONGDOUBLE
+ NPY_OBJECT
+ NPY_STRING
+ NPY_UNICODE
+ NPY_VOID
+ NPY_DATETIME
+ NPY_TIMEDELTA
+ NPY_NTYPES
+ NPY_NOTYPE
+
+ NPY_INT8
+ NPY_INT16
+ NPY_INT32
+ NPY_INT64
+ NPY_INT128
+ NPY_INT256
+ NPY_UINT8
+ NPY_UINT16
+ NPY_UINT32
+ NPY_UINT64
+ NPY_UINT128
+ NPY_UINT256
+ NPY_FLOAT16
+ NPY_FLOAT32
+ NPY_FLOAT64
+ NPY_FLOAT80
+ NPY_FLOAT96
+ NPY_FLOAT128
+ NPY_FLOAT256
+ NPY_COMPLEX32
+ NPY_COMPLEX64
+ NPY_COMPLEX128
+ NPY_COMPLEX160
+ NPY_COMPLEX192
+ NPY_COMPLEX256
+ NPY_COMPLEX512
+
+ NPY_INTP
+
+ ctypedef enum NPY_ORDER:
+ NPY_ANYORDER
+ NPY_CORDER
+ NPY_FORTRANORDER
+ NPY_KEEPORDER
+
+ ctypedef enum NPY_CASTING:
+ NPY_NO_CASTING
+ NPY_EQUIV_CASTING
+ NPY_SAFE_CASTING
+ NPY_SAME_KIND_CASTING
+ NPY_UNSAFE_CASTING
+
+ ctypedef enum NPY_CLIPMODE:
+ NPY_CLIP
+ NPY_WRAP
+ NPY_RAISE
+
+ ctypedef enum NPY_SCALARKIND:
+ NPY_NOSCALAR,
+ NPY_BOOL_SCALAR,
+ NPY_INTPOS_SCALAR,
+ NPY_INTNEG_SCALAR,
+ NPY_FLOAT_SCALAR,
+ NPY_COMPLEX_SCALAR,
+ NPY_OBJECT_SCALAR
+
+ ctypedef enum NPY_SORTKIND:
+ NPY_QUICKSORT
+ NPY_HEAPSORT
+ NPY_MERGESORT
+
+ ctypedef enum NPY_SEARCHSIDE:
+ NPY_SEARCHLEFT
+ NPY_SEARCHRIGHT
+
+ enum:
+ # DEPRECATED since NumPy 1.7 ! Do not use in new code!
+ NPY_C_CONTIGUOUS
+ NPY_F_CONTIGUOUS
+ NPY_CONTIGUOUS
+ NPY_FORTRAN
+ NPY_OWNDATA
+ NPY_FORCECAST
+ NPY_ENSURECOPY
+ NPY_ENSUREARRAY
+ NPY_ELEMENTSTRIDES
+ NPY_ALIGNED
+ NPY_NOTSWAPPED
+ NPY_WRITEABLE
+ NPY_UPDATEIFCOPY
+ NPY_ARR_HAS_DESCR
+
+ NPY_BEHAVED
+ NPY_BEHAVED_NS
+ NPY_CARRAY
+ NPY_CARRAY_RO
+ NPY_FARRAY
+ NPY_FARRAY_RO
+ NPY_DEFAULT
+
+ NPY_IN_ARRAY
+ NPY_OUT_ARRAY
+ NPY_INOUT_ARRAY
+ NPY_IN_FARRAY
+ NPY_OUT_FARRAY
+ NPY_INOUT_FARRAY
+
+ NPY_UPDATE_ALL
+
+ enum:
+ # Added in NumPy 1.7 to replace the deprecated enums above.
+ NPY_ARRAY_C_CONTIGUOUS
+ NPY_ARRAY_F_CONTIGUOUS
+ NPY_ARRAY_OWNDATA
+ NPY_ARRAY_FORCECAST
+ NPY_ARRAY_ENSURECOPY
+ NPY_ARRAY_ENSUREARRAY
+ NPY_ARRAY_ELEMENTSTRIDES
+ NPY_ARRAY_ALIGNED
+ NPY_ARRAY_NOTSWAPPED
+ NPY_ARRAY_WRITEABLE
+ NPY_ARRAY_UPDATEIFCOPY
+
+ NPY_ARRAY_BEHAVED
+ NPY_ARRAY_BEHAVED_NS
+ NPY_ARRAY_CARRAY
+ NPY_ARRAY_CARRAY_RO
+ NPY_ARRAY_FARRAY
+ NPY_ARRAY_FARRAY_RO
+ NPY_ARRAY_DEFAULT
+
+ NPY_ARRAY_IN_ARRAY
+ NPY_ARRAY_OUT_ARRAY
+ NPY_ARRAY_INOUT_ARRAY
+ NPY_ARRAY_IN_FARRAY
+ NPY_ARRAY_OUT_FARRAY
+ NPY_ARRAY_INOUT_FARRAY
+
+ NPY_ARRAY_UPDATE_ALL
+
+ cdef enum:
+ NPY_MAXDIMS
+
+ npy_intp NPY_MAX_ELSIZE
+
+ ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
+
+ ctypedef struct PyArray_ArrayDescr:
+ # shape is a tuple, but Cython doesn't support "tuple shape"
+ # inside a non-PyObject declaration, so we have to declare it
+ # as just a PyObject*.
+ PyObject* shape
+
+ ctypedef struct PyArray_Descr:
+ pass
+
+ ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]:
+ # Use PyDataType_* macros when possible, however there are no macros
+ # for accessing some of the fields, so some are defined.
+ cdef PyTypeObject* typeobj
+ cdef char kind
+ cdef char type
+ # Numpy sometimes mutates this without warning (e.g. it'll
+ # sometimes change "|" to "<" in shared dtype objects on
+ # little-endian machines). If this matters to you, use
+ # PyArray_IsNativeByteOrder(dtype.byteorder) instead of
+ # directly accessing this field.
+ cdef char byteorder
+ cdef char flags
+ cdef int type_num
+ cdef int itemsize "elsize"
+ cdef int alignment
+ cdef dict fields
+ cdef tuple names
+ # Use PyDataType_HASSUBARRAY to test whether this field is
+ # valid (the pointer can be NULL). Most users should access
+ # this field via the inline helper method PyDataType_SHAPE.
+ cdef PyArray_ArrayDescr* subarray
+
+ ctypedef class numpy.flatiter [object PyArrayIterObject, check_size ignore]:
+ # Use through macros
+ pass
+
+ ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]:
+ # Use through macros
+ pass
+
+ ctypedef struct PyArrayObject:
+ # For use in situations where ndarray can't replace PyArrayObject*,
+ # like PyArrayObject**.
+ pass
+
+ 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
+
+ ctypedef unsigned char npy_bool
+
+ ctypedef signed char npy_byte
+ ctypedef signed short npy_short
+ ctypedef signed int npy_int
+ ctypedef signed long npy_long
+ ctypedef signed long long npy_longlong
+
+ ctypedef unsigned char npy_ubyte
+ ctypedef unsigned short npy_ushort
+ ctypedef unsigned int npy_uint
+ ctypedef unsigned long npy_ulong
+ ctypedef unsigned long long npy_ulonglong
+
+ ctypedef float npy_float
+ ctypedef double npy_double
+ ctypedef long double npy_longdouble
+
+ ctypedef signed char npy_int8
+ ctypedef signed short npy_int16
+ ctypedef signed int npy_int32
+ ctypedef signed long long npy_int64
+ ctypedef signed long long npy_int96
+ ctypedef signed long long npy_int128
+
+ ctypedef unsigned char npy_uint8
+ ctypedef unsigned short npy_uint16
+ ctypedef unsigned int npy_uint32
+ ctypedef unsigned long long npy_uint64
+ ctypedef unsigned long long npy_uint96
+ ctypedef unsigned long long npy_uint128
+
+ ctypedef float npy_float32
+ ctypedef double npy_float64
+ ctypedef long double npy_float80
+ ctypedef long double npy_float96
+ ctypedef long double npy_float128
+
+ ctypedef struct npy_cfloat:
+ double real
+ double imag
+
+ ctypedef struct npy_cdouble:
+ double real
+ double imag
+
+ ctypedef struct npy_clongdouble:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex64:
+ float real
+ float imag
+
+ ctypedef struct npy_complex128:
+ double real
+ double imag
+
+ ctypedef struct npy_complex160:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex192:
+ long double real
+ long double imag
+
+ ctypedef struct npy_complex256:
+ long double real
+ long double imag
+
+ ctypedef struct PyArray_Dims:
+ npy_intp *ptr
+ int len
+
+ int _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)
+
+ 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 PyArray_DescrCheck(object)
+
+ bint PyArray_Check(object)
+ bint PyArray_CheckExact(object)
+
+ # Cannot be supported due to out arg:
+ # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
+ # bint PyArray_HasArrayInterface(op, out)
+
+
+ bint PyArray_IsZeroDim(object)
+ # Cannot be supported due to ## ## in macro:
+ # bint PyArray_IsScalar(object, verbatim work)
+ bint PyArray_CheckScalar(object)
+ bint PyArray_IsPythonNumber(object)
+ 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)
+
+ object PyArray_FROM_O(object)
+ object PyArray_FROM_OF(object m, int flags)
+ object PyArray_FROM_OT(object m, int type)
+ object PyArray_FROM_OTF(object m, int type, int flags)
+ object PyArray_FROMANY(object m, int type, int min, int max, int flags)
+ object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran)
+ object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran)
+ void PyArray_FILLWBYTE(object, int val)
+ 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)
+ 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_XDECREF_ERR(ndarray)
+ # Cannot be supported due to out arg
+ # void PyArray_DESCR_REPLACE(descr)
+
+
+ object PyArray_Copy(ndarray)
+ object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
+ object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
+ object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
+
+ object PyArray_Cast(ndarray mp, int type_num)
+ object PyArray_Take(ndarray ap, object items, int axis)
+ object PyArray_Put(ndarray ap, object items, object values)
+
+ void PyArray_ITER_RESET(flatiter it) nogil
+ void PyArray_ITER_NEXT(flatiter it) nogil
+ void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
+ void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
+ void* PyArray_ITER_DATA(flatiter it) nogil
+ bint PyArray_ITER_NOTDONE(flatiter it) nogil
+
+ void PyArray_MultiIter_RESET(broadcast multi) nogil
+ void PyArray_MultiIter_NEXT(broadcast multi) nogil
+ void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
+ void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil
+ void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil
+ void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil
+ bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil
+
+ # Functions from __multiarray_api.h
+
+ # Functions taking dtype and returning object/ndarray are disabled
+ # for now as they steal dtype references. I'm conservative and disable
+ # more than is probably needed until it can be checked further.
+ int PyArray_SetNumericOps (object)
+ object PyArray_GetNumericOps ()
+ int PyArray_INCREF (ndarray)
+ int PyArray_XDECREF (ndarray)
+ void PyArray_SetStringFunction (object, int)
+ dtype PyArray_DescrFromType (int)
+ object PyArray_TypeObjectFromType (int)
+ char * PyArray_Zero (ndarray)
+ char * PyArray_One (ndarray)
+ #object PyArray_CastToType (ndarray, dtype, int)
+ int PyArray_CastTo (ndarray, ndarray)
+ int PyArray_CastAnyTo (ndarray, ndarray)
+ int PyArray_CanCastSafely (int, int)
+ npy_bool PyArray_CanCastTo (dtype, dtype)
+ int PyArray_ObjectType (object, int)
+ dtype PyArray_DescrFromObject (object, dtype)
+ #ndarray* PyArray_ConvertToCommonType (object, int *)
+ dtype PyArray_DescrFromScalar (object)
+ dtype PyArray_DescrFromTypeObject (object)
+ npy_intp PyArray_Size (object)
+ #object PyArray_Scalar (void *, dtype, object)
+ #object PyArray_FromScalar (object, dtype)
+ void PyArray_ScalarAsCtype (object, void *)
+ #int PyArray_CastScalarToCtype (object, void *, dtype)
+ #int PyArray_CastScalarDirect (object, dtype, void *, int)
+ object PyArray_ScalarFromObject (object)
+ #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int)
+ object PyArray_FromDims (int, int *, int)
+ #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *)
+ #object PyArray_FromAny (object, dtype, int, int, int, object)
+ object PyArray_EnsureArray (object)
+ object PyArray_EnsureAnyArray (object)
+ #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *)
+ #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *)
+ #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp)
+ #object PyArray_FromIter (object, dtype, npy_intp)
+ object PyArray_Return (ndarray)
+ #object PyArray_GetField (ndarray, dtype, int)
+ #int PyArray_SetField (ndarray, dtype, int, object)
+ object PyArray_Byteswap (ndarray, npy_bool)
+ object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER)
+ int PyArray_MoveInto (ndarray, ndarray)
+ int PyArray_CopyInto (ndarray, ndarray)
+ int PyArray_CopyAnyInto (ndarray, ndarray)
+ int PyArray_CopyObject (ndarray, object)
+ object PyArray_NewCopy (ndarray, NPY_ORDER)
+ object PyArray_ToList (ndarray)
+ object PyArray_ToString (ndarray, NPY_ORDER)
+ int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *)
+ int PyArray_Dump (object, object, int)
+ object PyArray_Dumps (object, int)
+ int PyArray_ValidType (int)
+ void PyArray_UpdateFlags (ndarray, int)
+ object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
+ #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
+ #dtype PyArray_DescrNew (dtype)
+ dtype PyArray_DescrNewFromType (int)
+ double PyArray_GetPriority (object, double)
+ object PyArray_IterNew (object)
+ object PyArray_MultiIterNew (int, ...)
+
+ int PyArray_PyIntAsInt (object)
+ npy_intp PyArray_PyIntAsIntp (object)
+ int PyArray_Broadcast (broadcast)
+ void PyArray_FillObjectArray (ndarray, object)
+ int PyArray_FillWithScalar (ndarray, object)
+ npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
+ dtype PyArray_DescrNewByteorder (dtype, char)
+ object PyArray_IterAllButAxis (object, int *)
+ #object PyArray_CheckFromAny (object, dtype, int, int, int, object)
+ #object PyArray_FromArray (ndarray, dtype, int)
+ object PyArray_FromInterface (object)
+ object PyArray_FromStructInterface (object)
+ #object PyArray_FromArrayAttr (object, dtype, object)
+ #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*)
+ int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND)
+ object PyArray_NewFlagsObject (object)
+ npy_bool PyArray_CanCastScalar (type, type)
+ #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t)
+ int PyArray_RemoveSmallest (broadcast)
+ int PyArray_ElementStrides (object)
+ void PyArray_Item_INCREF (char *, dtype)
+ void PyArray_Item_XDECREF (char *, dtype)
+ object PyArray_FieldNames (object)
+ object PyArray_Transpose (ndarray, PyArray_Dims *)
+ object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE)
+ object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE)
+ object PyArray_PutMask (ndarray, object, object)
+ object PyArray_Repeat (ndarray, object, int)
+ 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_ArgMax (ndarray, int, ndarray)
+ object PyArray_ArgMin (ndarray, int, ndarray)
+ object PyArray_Reshape (ndarray, object)
+ object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER)
+ object PyArray_Squeeze (ndarray)
+ #object PyArray_View (ndarray, dtype, type)
+ object PyArray_SwapAxes (ndarray, int, int)
+ object PyArray_Max (ndarray, int, ndarray)
+ object PyArray_Min (ndarray, int, ndarray)
+ object PyArray_Ptp (ndarray, int, ndarray)
+ object PyArray_Mean (ndarray, int, int, ndarray)
+ object PyArray_Trace (ndarray, int, int, int, int, ndarray)
+ object PyArray_Diagonal (ndarray, int, int, int)
+ object PyArray_Clip (ndarray, object, object, ndarray)
+ object PyArray_Conjugate (ndarray, ndarray)
+ object PyArray_Nonzero (ndarray)
+ object PyArray_Std (ndarray, int, int, ndarray, int)
+ object PyArray_Sum (ndarray, int, int, ndarray)
+ object PyArray_CumSum (ndarray, int, int, ndarray)
+ object PyArray_Prod (ndarray, int, int, ndarray)
+ object PyArray_CumProd (ndarray, int, int, ndarray)
+ object PyArray_All (ndarray, int, ndarray)
+ object PyArray_Any (ndarray, int, ndarray)
+ object PyArray_Compress (ndarray, object, int, ndarray)
+ object PyArray_Flatten (ndarray, NPY_ORDER)
+ object PyArray_Ravel (ndarray, NPY_ORDER)
+ npy_intp PyArray_MultiplyList (npy_intp *, int)
+ int PyArray_MultiplyIntList (int *, int)
+ void * PyArray_GetPtr (ndarray, npy_intp*)
+ int PyArray_CompareLists (npy_intp *, npy_intp *, int)
+ #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype)
+ #int PyArray_As1D (object*, char **, int *, int)
+ #int PyArray_As2D (object*, char ***, int *, int *, int)
+ int PyArray_Free (object, void *)
+ #int PyArray_Converter (object, object*)
+ int PyArray_IntpFromSequence (object, npy_intp *, int)
+ object PyArray_Concatenate (object, int)
+ object PyArray_InnerProduct (object, object)
+ object PyArray_MatrixProduct (object, object)
+ object PyArray_CopyAndTranspose (object)
+ object PyArray_Correlate (object, object, int)
+ int PyArray_TypestrConvert (int, int)
+ #int PyArray_DescrConverter (object, dtype*)
+ #int PyArray_DescrConverter2 (object, dtype*)
+ int PyArray_IntpConverter (object, PyArray_Dims *)
+ #int PyArray_BufferConverter (object, chunk)
+ int PyArray_AxisConverter (object, int *)
+ int PyArray_BoolConverter (object, npy_bool *)
+ int PyArray_ByteorderConverter (object, char *)
+ int PyArray_OrderConverter (object, NPY_ORDER *)
+ unsigned char PyArray_EquivTypes (dtype, dtype)
+ #object PyArray_Zeros (int, npy_intp *, dtype, int)
+ #object PyArray_Empty (int, npy_intp *, dtype, int)
+ object PyArray_Where (object, object, object)
+ object PyArray_Arange (double, double, double, int)
+ #object PyArray_ArangeObj (object, object, object, dtype)
+ int PyArray_SortkindConverter (object, NPY_SORTKIND *)
+ object PyArray_LexSort (object, int)
+ object PyArray_Round (ndarray, int, ndarray)
+ unsigned char PyArray_EquivTypenums (int, int)
+ int PyArray_RegisterDataType (dtype)
+ int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *)
+ int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND)
+ #void PyArray_InitArrFuncs (PyArray_ArrFuncs *)
+ object PyArray_IntTupleFromIntp (int, npy_intp *)
+ int PyArray_TypeNumFromName (char *)
+ int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *)
+ #int PyArray_OutputConverter (object, ndarray*)
+ object PyArray_BroadcastToShape (object, npy_intp *, int)
+ void _PyArray_SigintHandler (int)
+ void* _PyArray_GetSigintBuf ()
+ #int PyArray_DescrAlignConverter (object, dtype*)
+ #int PyArray_DescrAlignConverter2 (object, dtype*)
+ int PyArray_SearchsideConverter (object, void *)
+ object PyArray_CheckAxis (ndarray, int *, int)
+ npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
+ int PyArray_CompareString (char *, char *, size_t)
+ int PyArray_SetBaseObject(ndarray, base) # NOTE: steals a reference to base! Use "set_array_base()" instead.
+
+
+# Typedefs that matches the runtime dtype objects in
+# the numpy module.
+
+# The ones that are commented out needs an IFDEF function
+# in Cython to enable them only on the right systems.
+
+ctypedef npy_int8 int8_t
+ctypedef npy_int16 int16_t
+ctypedef npy_int32 int32_t
+ctypedef npy_int64 int64_t
+#ctypedef npy_int96 int96_t
+#ctypedef npy_int128 int128_t
+
+ctypedef npy_uint8 uint8_t
+ctypedef npy_uint16 uint16_t
+ctypedef npy_uint32 uint32_t
+ctypedef npy_uint64 uint64_t
+#ctypedef npy_uint96 uint96_t
+#ctypedef npy_uint128 uint128_t
+
+ctypedef npy_float32 float32_t
+ctypedef npy_float64 float64_t
+#ctypedef npy_float80 float80_t
+#ctypedef npy_float128 float128_t
+
+ctypedef float complex complex64_t
+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
+ctypedef npy_uintp uintp_t
+
+ctypedef npy_double float_t
+ctypedef npy_double double_t
+ctypedef npy_longdouble longdouble_t
+
+ctypedef npy_cfloat cfloat_t
+ctypedef npy_cdouble cdouble_t
+ctypedef npy_clongdouble clongdouble_t
+
+ctypedef npy_cdouble complex_t
+
+cdef inline object PyArray_MultiIterNew1(a):
+ return PyArray_MultiIterNew(1, <void*>a)
+
+cdef inline object PyArray_MultiIterNew2(a, b):
+ return PyArray_MultiIterNew(2, <void*>a, <void*>b)
+
+cdef inline object PyArray_MultiIterNew3(a, b, c):
+ return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
+
+cdef inline object PyArray_MultiIterNew4(a, b, c, d):
+ return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
+
+cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
+ return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
+
+cdef inline tuple PyDataType_SHAPE(dtype d):
+ if PyDataType_HASSUBARRAY(d):
+ return <tuple>d.subarray.shape
+ 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
+
+
+#
+# ufunc API
+#
+
+cdef extern from "numpy/ufuncobject.h":
+
+ ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
+
+ ctypedef class numpy.ufunc [object PyUFuncObject, check_size ignore]:
+ cdef:
+ int nin, nout, nargs
+ int identity
+ PyUFuncGenericFunction *functions
+ void **data
+ int ntypes
+ int check_return
+ char *name
+ char *types
+ char *doc
+ void *ptr
+ PyObject *obj
+ PyObject *userloops
+
+ cdef enum:
+ PyUFunc_Zero
+ PyUFunc_One
+ PyUFunc_None
+ UFUNC_ERR_IGNORE
+ UFUNC_ERR_WARN
+ UFUNC_ERR_RAISE
+ UFUNC_ERR_CALL
+ UFUNC_ERR_PRINT
+ UFUNC_ERR_LOG
+ UFUNC_MASK_DIVIDEBYZERO
+ UFUNC_MASK_OVERFLOW
+ UFUNC_MASK_UNDERFLOW
+ UFUNC_MASK_INVALID
+ UFUNC_SHIFT_DIVIDEBYZERO
+ UFUNC_SHIFT_OVERFLOW
+ UFUNC_SHIFT_UNDERFLOW
+ UFUNC_SHIFT_INVALID
+ UFUNC_FPE_DIVIDEBYZERO
+ UFUNC_FPE_OVERFLOW
+ UFUNC_FPE_UNDERFLOW
+ UFUNC_FPE_INVALID
+ UFUNC_ERR_DEFAULT
+ UFUNC_ERR_DEFAULT2
+
+ object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
+ void **, char *, int, int, int, int, char *, char *, int)
+ int PyUFunc_RegisterLoopForType(ufunc, int,
+ PyUFuncGenericFunction, int *, void *)
+ int PyUFunc_GenericFunction \
+ (ufunc, PyObject *, PyObject *, PyArrayObject **)
+ void PyUFunc_f_f_As_d_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_d_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_f_f \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_g_g \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_F_F_As_D_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_F_F \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_D_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_G_G \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_O_O \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_ff_f_As_dd_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_ff_f \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_dd_d \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_gg_g \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_FF_F_As_DD_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_DD_D \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_FF_F \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_GG_G \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_OO_O \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_O_O_method \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_OO_O_method \
+ (char **, npy_intp *, npy_intp *, void *)
+ void PyUFunc_On_Om \
+ (char **, npy_intp *, npy_intp *, void *)
+ int PyUFunc_GetPyValues \
+ (char *, int *, int *, PyObject **)
+ int PyUFunc_checkfperr \
+ (int, PyObject *, int *)
+ void PyUFunc_clearfperr()
+ int PyUFunc_getfperr()
+ int PyUFunc_handlefperr \
+ (int, PyObject *, int, int *)
+ int PyUFunc_ReplaceLoopBySignature \
+ (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)
+ object PyUFunc_FromFuncAndDataAndSignature \
+ (PyUFuncGenericFunction *, void **, char *, int, int, int,
+ int, char *, char *, int, char *)
+
+ int _import_umath() except -1
+
+cdef inline void set_array_base(ndarray arr, object base):
+ Py_INCREF(base) # important to do this before stealing the reference below!
+ PyArray_SetBaseObject(arr, base)
+
+cdef inline object get_array_base(ndarray arr):
+ base = PyArray_BASE(arr)
+ if base is NULL:
+ return None
+ return <object>base
+
+# Versions of the import_* functions which are more suitable for
+# Cython code.
+cdef inline int import_array() except -1:
+ try:
+ _import_array()
+ except Exception:
+ raise ImportError("numpy.core.multiarray failed to import")
+
+cdef inline int import_umath() except -1:
+ try:
+ _import_umath()
+ except Exception:
+ raise ImportError("numpy.core.umath failed to import")
+
+cdef inline int import_ufunc() except -1:
+ try:
+ _import_umath()
+ except Exception:
+ raise ImportError("numpy.core.umath failed to import")
diff --git a/contrib/tools/cython/Cython/Includes/numpy/math.pxd b/contrib/tools/cython/Cython/Includes/numpy/math.pxd
new file mode 100644
index 0000000000..c16df1c51a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/numpy/math.pxd
@@ -0,0 +1,133 @@
+# NumPy math library
+#
+# This exports the functionality of the NumPy core math library, aka npymath,
+# which provides implementations of C99 math functions and macros for system
+# with a C89 library (such as MSVC). npymath is available with NumPy >=1.3,
+# although some functions will require later versions. The spacing function is
+# not in C99, but comes from Fortran.
+#
+# On the Cython side, the npymath functions are available without the "npy_"
+# prefix that they have in C, to make this is a drop-in replacement for
+# libc.math. The same is true for the constants, where possible.
+#
+# See the NumPy documentation for linking instructions.
+#
+# Complex number support and NumPy 2.0 half-precision functions are currently
+# not exported.
+#
+# Author: Lars Buitinck
+
+cdef extern from "numpy/npy_math.h" nogil:
+ # Floating-point classification
+ long double NAN "NPY_NAN"
+ long double INFINITY "NPY_INFINITY"
+ long double PZERO "NPY_PZERO" # positive zero
+ long double NZERO "NPY_NZERO" # negative zero
+
+ # These four are actually macros and work on any floating-point type.
+ int isinf "npy_isinf"(long double) # -1 / 0 / 1
+ bint isfinite "npy_isfinite"(long double)
+ bint isnan "npy_isnan"(long double)
+ bint signbit "npy_signbit"(long double)
+
+ # Math constants
+ long double E "NPY_E"
+ long double LOG2E "NPY_LOG2E" # ln(e) / ln(2)
+ long double LOG10E "NPY_LOG10E" # ln(e) / ln(10)
+ long double LOGE2 "NPY_LOGE2" # ln(2)
+ long double LOGE10 "NPY_LOGE10" # ln(10)
+ long double PI "NPY_PI"
+ long double PI_2 "NPY_PI_2" # pi / 2
+ long double PI_4 "NPY_PI_4" # pi / 4
+ long double NPY_1_PI # 1 / pi; NPY_ because of ident syntax
+ long double NPY_2_PI # 2 / pi
+ long double EULER "NPY_EULER" # Euler constant (gamma, 0.57721)
+
+ # Low-level floating point manipulation (NumPy >=1.4)
+ float copysignf "npy_copysignf"(float, float)
+ float nextafterf "npy_nextafterf"(float x, float y)
+ float spacingf "npy_spacingf"(float x)
+ double copysign "npy_copysign"(double, double)
+ double nextafter "npy_nextafter"(double x, double y)
+ double spacing "npy_spacing"(double x)
+ long double copysignl "npy_copysignl"(long double, long double)
+ long double nextafterl "npy_nextafterl"(long double x, long double y)
+ long double spacingl "npy_spacingl"(long double x)
+
+ # Float C99 functions
+ float sinf "npy_sinf"(float x)
+ float cosf "npy_cosf"(float x)
+ float tanf "npy_tanf"(float x)
+ float sinhf "npy_sinhf"(float x)
+ float coshf "npy_coshf"(float x)
+ float tanhf "npy_tanhf"(float x)
+ float fabsf "npy_fabsf"(float x)
+ float floorf "npy_floorf"(float x)
+ float ceilf "npy_ceilf"(float x)
+ float rintf "npy_rintf"(float x)
+ float sqrtf "npy_sqrtf"(float x)
+ float log10f "npy_log10f"(float x)
+ float logf "npy_logf"(float x)
+ float expf "npy_expf"(float x)
+ float expm1f "npy_expm1f"(float x)
+ float asinf "npy_asinf"(float x)
+ float acosf "npy_acosf"(float x)
+ float atanf "npy_atanf"(float x)
+ float asinhf "npy_asinhf"(float x)
+ float acoshf "npy_acoshf"(float x)
+ float atanhf "npy_atanhf"(float x)
+ float log1pf "npy_log1pf"(float x)
+ float exp2f "npy_exp2f"(float x)
+ float log2f "npy_log2f"(float x)
+ float atan2f "npy_atan2f"(float x, float y)
+ float hypotf "npy_hypotf"(float x, float y)
+ float powf "npy_powf"(float x, float y)
+ float fmodf "npy_fmodf"(float x, float y)
+ float modff "npy_modff"(float x, float* y)
+
+ # Long double C99 functions
+ long double sinl "npy_sinl"(long double x)
+ long double cosl "npy_cosl"(long double x)
+ long double tanl "npy_tanl"(long double x)
+ long double sinhl "npy_sinhl"(long double x)
+ long double coshl "npy_coshl"(long double x)
+ long double tanhl "npy_tanhl"(long double x)
+ long double fabsl "npy_fabsl"(long double x)
+ long double floorl "npy_floorl"(long double x)
+ long double ceill "npy_ceill"(long double x)
+ long double rintl "npy_rintl"(long double x)
+ long double sqrtl "npy_sqrtl"(long double x)
+ long double log10l "npy_log10l"(long double x)
+ long double logl "npy_logl"(long double x)
+ long double expl "npy_expl"(long double x)
+ long double expm1l "npy_expm1l"(long double x)
+ long double asinl "npy_asinl"(long double x)
+ long double acosl "npy_acosl"(long double x)
+ long double atanl "npy_atanl"(long double x)
+ long double asinhl "npy_asinhl"(long double x)
+ long double acoshl "npy_acoshl"(long double x)
+ long double atanhl "npy_atanhl"(long double x)
+ long double log1pl "npy_log1pl"(long double x)
+ long double exp2l "npy_exp2l"(long double x)
+ long double log2l "npy_log2l"(long double x)
+ long double atan2l "npy_atan2l"(long double x, long double y)
+ long double hypotl "npy_hypotl"(long double x, long double y)
+ long double powl "npy_powl"(long double x, long double y)
+ long double fmodl "npy_fmodl"(long double x, long double y)
+ long double modfl "npy_modfl"(long double x, long double* y)
+
+ # NumPy extensions
+ float deg2radf "npy_deg2radf"(float x)
+ float rad2degf "npy_rad2degf"(float x)
+ float logaddexpf "npy_logaddexpf"(float x, float y)
+ float logaddexp2f "npy_logaddexp2f"(float x, float y)
+
+ double deg2rad "npy_deg2rad"(double x)
+ double rad2deg "npy_rad2deg"(double x)
+ double logaddexp "npy_logaddexp"(double x, double y)
+ double logaddexp2 "npy_logaddexp2"(double x, double y)
+
+ long double deg2radl "npy_deg2radl"(long double x)
+ long double rad2degl "npy_rad2degl"(long double x)
+ long double logaddexpl "npy_logaddexpl"(long double x, long double y)
+ long double logaddexp2l "npy_logaddexp2l"(long double x, long double y)
diff --git a/contrib/tools/cython/Cython/Includes/openmp.pxd b/contrib/tools/cython/Cython/Includes/openmp.pxd
new file mode 100644
index 0000000000..30873a588b
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/openmp.pxd
@@ -0,0 +1,51 @@
+cdef extern from "<omp.h>":
+ ctypedef struct omp_lock_t:
+ pass
+ ctypedef struct omp_nest_lock_t:
+ pass
+
+ ctypedef enum omp_sched_t:
+ omp_sched_static = 1,
+ omp_sched_dynamic = 2,
+ omp_sched_guided = 3,
+ omp_sched_auto = 4
+
+ extern void omp_set_num_threads(int) nogil
+ extern int omp_get_num_threads() nogil
+ extern int omp_get_max_threads() nogil
+ extern int omp_get_thread_num() nogil
+ extern int omp_get_num_procs() nogil
+
+ extern int omp_in_parallel() nogil
+
+ extern void omp_set_dynamic(int) nogil
+ extern int omp_get_dynamic() nogil
+
+ extern void omp_set_nested(int) nogil
+ extern int omp_get_nested() nogil
+
+ extern void omp_init_lock(omp_lock_t *) nogil
+ extern void omp_destroy_lock(omp_lock_t *) nogil
+ extern void omp_set_lock(omp_lock_t *) nogil
+ extern void omp_unset_lock(omp_lock_t *) nogil
+ extern int omp_test_lock(omp_lock_t *) nogil
+
+ extern void omp_init_nest_lock(omp_nest_lock_t *) nogil
+ extern void omp_destroy_nest_lock(omp_nest_lock_t *) nogil
+ extern void omp_set_nest_lock(omp_nest_lock_t *) nogil
+ extern void omp_unset_nest_lock(omp_nest_lock_t *) nogil
+ extern int omp_test_nest_lock(omp_nest_lock_t *) nogil
+
+ extern double omp_get_wtime() nogil
+ extern double omp_get_wtick() nogil
+
+ void omp_set_schedule(omp_sched_t, int) nogil
+ void omp_get_schedule(omp_sched_t *, int *) nogil
+ int omp_get_thread_limit() nogil
+ void omp_set_max_active_levels(int) nogil
+ int omp_get_max_active_levels() nogil
+ int omp_get_level() nogil
+ 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/__init__.pxd b/contrib/tools/cython/Cython/Includes/posix/__init__.pxd
new file mode 100644
index 0000000000..fa81adaff6
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/__init__.pxd
@@ -0,0 +1 @@
+# empty file
diff --git a/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd
new file mode 100644
index 0000000000..cff5bea15a
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/dlfcn.pxd
@@ -0,0 +1,14 @@
+# POSIX dynamic linking/loading interface.
+# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html
+
+cdef extern from "<dlfcn.h>" nogil:
+ void *dlopen(const char *, int)
+ char *dlerror()
+ void *dlsym(void *, const char *)
+ int dlclose(void *)
+
+ enum:
+ RTLD_LAZY
+ RTLD_NOW
+ RTLD_GLOBAL
+ RTLD_LOCAL
diff --git a/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd
new file mode 100644
index 0000000000..9afc33a368
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/fcntl.pxd
@@ -0,0 +1,68 @@
+# http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html
+
+cdef extern from "<fcntl.h>" nogil:
+
+ enum: F_DUPFD
+ enum: F_GETFD
+ enum: F_SETFD
+ enum: F_GETFL
+ enum: F_SETFL
+ enum: F_GETLK
+ enum: F_SETLK
+ enum: F_SETLKW
+ enum: F_GETOWN
+ enum: F_SETOWN
+
+ enum: FD_CLOEXEC
+
+ enum: F_RDLCK
+ enum: F_UNLCK
+ enum: F_WRLCK
+
+ enum: SEEK_SET
+ enum: SEEK_CUR
+ enum: SEEK_END
+
+ enum: O_CREAT
+ enum: O_DIRECT
+ enum: O_EXCL
+ enum: O_NOCTTY
+ enum: O_TRUNC
+
+ enum: O_APPEND
+ enum: O_DSYNC
+ enum: O_NONBLOCK
+ enum: O_RSYNC
+ enum: O_SYNC
+
+ enum: O_ACCMODE # O_RDONLY|O_WRONLY|O_RDWR
+
+ enum: O_RDONLY
+ enum: O_WRONLY
+ enum: O_RDWR
+
+ enum: S_IFMT
+ enum: S_IFBLK
+ enum: S_IFCHR
+ enum: S_IFIFO
+ enum: S_IFREG
+ enum: S_IFDIR
+ enum: S_IFLNK
+ enum: S_IFSOCK
+
+ ctypedef int mode_t
+ ctypedef signed pid_t
+ ctypedef signed off_t
+
+ struct flock:
+ short l_type
+ short l_whence
+ off_t l_start
+ off_t l_len
+ pid_t l_pid
+
+ int creat(char *, mode_t)
+ int fcntl(int, int, ...)
+ int open(char *, int, ...)
+ #int open (char *, int, mode_t)
+
diff --git a/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd b/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd
new file mode 100644
index 0000000000..dacbc307f3
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/ioctl.pxd
@@ -0,0 +1,4 @@
+cdef extern from "<sys/ioctl.h>" nogil:
+ enum: FIONBIO
+
+ int ioctl(int fd, int request, ...)
diff --git a/contrib/tools/cython/Cython/Includes/posix/mman.pxd b/contrib/tools/cython/Cython/Includes/posix/mman.pxd
new file mode 100644
index 0000000000..c810f431b3
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/mman.pxd
@@ -0,0 +1,99 @@
+# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/mman.h.html
+
+from posix.types cimport off_t, mode_t
+
+cdef extern from "<sys/mman.h>" nogil:
+ enum: PROT_EXEC # protection bits for mmap/mprotect
+ enum: PROT_READ
+ enum: PROT_WRITE
+ enum: PROT_NONE
+
+ enum: MAP_PRIVATE # flag bits for mmap
+ enum: MAP_SHARED
+ enum: MAP_FIXED
+ enum: MAP_ANON # These three are not in POSIX, but are
+ enum: MAP_ANONYMOUS # fairly common in spelling/semantics
+ enum: MAP_STACK
+
+ enum: MAP_LOCKED # Typically available only on Linux
+ enum: MAP_HUGETLB
+ enum: MAP_POPULATE
+ enum: MAP_NORESERVE
+ enum: MAP_GROWSDOWN
+
+ enum: MAP_NOCORE # Typically available only on BSD
+ enum: MAP_NOSYNC
+
+ void *MAP_FAILED
+
+ void *mmap(void *addr, size_t Len, int prot, int flags, int fd, off_t off)
+ int munmap(void *addr, size_t Len)
+ int mprotect(void *addr, size_t Len, int prot)
+
+ enum: MS_ASYNC
+ enum: MS_SYNC
+ enum: MS_INVALIDATE
+ int msync(void *addr, size_t Len, int flags)
+
+ enum: POSIX_MADV_NORMAL # POSIX advice flags
+ enum: POSIX_MADV_SEQUENTIAL
+ enum: POSIX_MADV_RANDOM
+ enum: POSIX_MADV_WILLNEED
+ enum: POSIX_MADV_DONTNEED
+ int posix_madvise(void *addr, size_t Len, int advice)
+
+ enum: MCL_CURRENT
+ enum: MCL_FUTURE
+ int mlock(const void *addr, size_t Len)
+ int munlock(const void *addr, size_t Len)
+ int mlockall(int flags)
+ int munlockall()
+ # Linux-specific
+ enum: MLOCK_ONFAULT
+ enum: MCL_ONFAULT
+ int mlock2(const void *addr, size_t len, int flags)
+
+ int shm_open(const char *name, int oflag, mode_t mode)
+ int shm_unlink(const char *name)
+
+ # often available
+ enum: MADV_NORMAL # pre-POSIX advice flags; should translate 1-1 to POSIX_*
+ enum: MADV_RANDOM # but in practice it is not always the same.
+ enum: MADV_SEQUENTIAL
+ enum: MADV_WILLNEED
+ enum: MADV_DONTNEED
+ enum: MADV_REMOVE # other pre-POSIX advice flags; often available
+ enum: MADV_DONTFORK
+ enum: MADV_DOFORK
+ enum: MADV_HWPOISON
+ enum: MADV_MERGEABLE,
+ enum: MADV_UNMERGEABLE
+ enum: MADV_SOFT_OFFLINE
+ enum: MADV_HUGEPAGE
+ enum: MADV_NOHUGEPAGE
+ enum: MADV_DONTDUMP
+ enum: MADV_DODUMP
+ enum: MADV_FREE
+ enum: MADV_WIPEONFORK
+ enum: MADV_KEEPONFORK
+ int madvise(void *addr, size_t Len, int advice)
+
+ # sometimes available
+ int mincore(void *addr, size_t Len, unsigned char *vec)
+
+ # These two are Linux specific but sometimes very efficient
+ void *mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
+ int remap_file_pages(void *addr, size_t Len, int prot,
+ size_t pgoff, int flags)
+
+ # The rare but standardized typed memory option
+ enum: POSIX_TYPED_MEM_ALLOCATE
+ enum: POSIX_TYPED_MEM_ALLOCATE_CONTIG
+ enum: POSIX_TYPED_MEM_MAP_ALLOCATABLE
+ int posix_typed_mem_open(const char *name, int oflag, int tflag)
+ int posix_mem_offset(const void *addr, size_t Len, off_t *off,
+ size_t *contig_len, int *fildes)
+
+ cdef struct posix_typed_mem_info:
+ size_t posix_tmi_length
+ int posix_typed_mem_get_info(int fildes, posix_typed_mem_info *info)
diff --git a/contrib/tools/cython/Cython/Includes/posix/resource.pxd b/contrib/tools/cython/Cython/Includes/posix/resource.pxd
new file mode 100644
index 0000000000..9f55c6ab4e
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/resource.pxd
@@ -0,0 +1,55 @@
+# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html
+
+from posix.time cimport timeval
+from posix.types cimport id_t
+
+cdef extern from "<sys/resource.h>" nogil:
+
+ enum: PRIO_PROCESS
+ enum: PRIO_PGRP
+ enum: PRIO_USER
+
+ enum: RLIM_INFINITY
+ enum: RLIM_SAVED_MAX
+ enum: RLIM_SAVED_CUR
+
+ enum: RUSAGE_SELF
+ enum: RUSAGE_CHILDREN
+
+ enum: RLIMIT_CORE
+ enum: RLIMIT_CPU
+ enum: RLIMIT_DATA
+ enum: RLIMIT_FSIZE
+ enum: RLIMIT_NOFILE
+ enum: RLIMIT_STACK
+ enum: RLIMIT_AS
+
+ ctypedef unsigned long rlim_t
+
+ cdef struct rlimit:
+ rlim_t rlim_cur
+ rlim_t rlim_max
+
+ cdef struct rusage:
+ timeval ru_utime
+ timeval ru_stime
+ long ru_maxrss
+ long ru_ixrss
+ long ru_idrss
+ long ru_isrss
+ long ru_minflt
+ long ru_majflt
+ long ru_nswap
+ long ru_inblock
+ long ru_oublock
+ long ru_msgsnd
+ long ru_msgrcv
+ long ru_nsignals
+ long ru_nvcsw
+ long ru_nivcsw
+
+ int getpriority(int, id_t)
+ int getrlimit(int, rlimit *)
+ int getrusage(int, rusage *)
+ int setpriority(int, id_t, int)
+ int setrlimit(int, const rlimit *)
diff --git a/contrib/tools/cython/Cython/Includes/posix/select.pxd b/contrib/tools/cython/Cython/Includes/posix/select.pxd
new file mode 100644
index 0000000000..46703df104
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/select.pxd
@@ -0,0 +1,19 @@
+from .types cimport sigset_t
+from .time cimport timeval, timespec
+
+cdef extern from "<sys/select.h>" nogil:
+ ctypedef struct fd_set:
+ pass
+
+ int FD_SETSIZE
+ void FD_SET(int, fd_set*)
+ void FD_CLR(int, fd_set*)
+ bint FD_ISSET(int, fd_set*)
+ void FD_ZERO(fd_set*)
+
+ int select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, const timeval *timeout)
+
+ int pselect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, const timespec *timeout,
+ const sigset_t *sigmask)
diff --git a/contrib/tools/cython/Cython/Includes/posix/signal.pxd b/contrib/tools/cython/Cython/Includes/posix/signal.pxd
new file mode 100644
index 0000000000..9fe7d9c36c
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/signal.pxd
@@ -0,0 +1,73 @@
+# 7.14 Signal handling <signal.h>
+
+from posix.types cimport pid_t, sigset_t, uid_t
+
+cdef extern from "<signal.h>" nogil:
+
+ cdef union sigval:
+ int sival_int
+ void *sival_ptr
+
+ cdef struct sigevent:
+ int sigev_notify
+ int sigev_signo
+ sigval sigev_value
+ void sigev_notify_function(sigval)
+
+ ctypedef struct siginfo_t:
+ int si_signo
+ int si_code
+ int si_errno
+ pid_t si_pid
+ uid_t si_uid
+ void *si_addr
+ int si_status
+ long si_band
+ sigval si_value
+
+ cdef struct sigaction_t "sigaction":
+ void sa_handler(int)
+ void sa_sigaction(int, siginfo_t *, void *)
+ sigset_t sa_mask
+ int sa_flags
+
+ ctypedef struct stack_t:
+ void *ss_sp
+ int ss_flags
+ size_t ss_size
+
+ enum: SA_NOCLDSTOP
+ enum: SIG_BLOCK
+ enum: SIG_UNBLOCK
+ enum: SIG_SETMASK
+ enum: SA_ONSTACK
+ enum: SA_RESETHAND
+ enum: SA_RESTART
+ enum: SA_SIGINFO
+ enum: SA_NOCLDWAIT
+ enum: SA_NODEFER
+ enum: SS_ONSTACK
+ enum: SS_DISABLE
+ enum: MINSIGSTKSZ
+ enum: SIGSTKSZ
+
+ enum: SIGEV_NONE
+ enum: SIGEV_SIGNAL
+ enum: SIGEV_THREAD
+ enum: SIGEV_THREAD_ID
+
+
+ int kill (pid_t, int)
+ int killpg (pid_t, int)
+ int sigaction (int, const sigaction_t *, sigaction_t *)
+ int sigpending (sigset_t *)
+ int sigprocmask (int, const sigset_t *, sigset_t *)
+ int sigsuspend (const sigset_t *)
+
+ int sigaddset (sigset_t *, int)
+ int sigdelset (sigset_t *, int)
+ int sigemptyset (sigset_t *)
+ int sigfillset (sigset_t *)
+ int sigismember (const sigset_t *, int)
+
+ int sigaltstack(const stack_t *, stack_t *)
diff --git a/contrib/tools/cython/Cython/Includes/posix/stat.pxd b/contrib/tools/cython/Cython/Includes/posix/stat.pxd
new file mode 100644
index 0000000000..69c2eca166
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/stat.pxd
@@ -0,0 +1,71 @@
+from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t,
+ nlink_t, off_t, time_t, uid_t)
+
+
+cdef extern from "<sys/stat.h>" nogil:
+ cdef struct struct_stat "stat":
+ dev_t st_dev
+ ino_t st_ino
+ mode_t st_mode
+ nlink_t st_nlink
+ uid_t st_uid
+ gid_t st_gid
+ dev_t st_rdev
+ off_t st_size
+ blksize_t st_blksize
+ blkcnt_t st_blocks
+ time_t st_atime
+ time_t st_mtime
+ time_t st_ctime
+
+ # st_birthtime exists on *BSD and OS X.
+ # Under Linux, defining it here does not hurt. Compilation under Linux
+ # will only (and rightfully) fail when attempting to use the field.
+ time_t st_birthtime
+
+# 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 fstat(int, struct_stat *)
+ int lstat(const char *, struct_stat *)
+ int stat(const char *, struct_stat *)
+
+ # Macros for st_mode
+ mode_t S_ISREG(mode_t)
+ mode_t S_ISDIR(mode_t)
+ mode_t S_ISCHR(mode_t)
+ mode_t S_ISBLK(mode_t)
+ mode_t S_ISFIFO(mode_t)
+ mode_t S_ISLNK(mode_t)
+ mode_t S_ISSOCK(mode_t)
+
+ mode_t S_IFMT
+ mode_t S_IFREG
+ mode_t S_IFDIR
+ mode_t S_IFCHR
+ mode_t S_IFBLK
+ mode_t S_IFIFO
+ mode_t S_IFLNK
+ mode_t S_IFSOCK
+
+ # Permissions
+ mode_t S_ISUID
+ mode_t S_ISGID
+ mode_t S_ISVTX
+
+ mode_t S_IRWXU
+ mode_t S_IRUSR
+ mode_t S_IWUSR
+ mode_t S_IXUSR
+
+ mode_t S_IRWXG
+ mode_t S_IRGRP
+ mode_t S_IWGRP
+ mode_t S_IXGRP
+
+ mode_t S_IRWXO
+ mode_t S_IROTH
+ mode_t S_IWOTH
+ mode_t S_IXOTH
diff --git a/contrib/tools/cython/Cython/Includes/posix/stdio.pxd b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd
new file mode 100644
index 0000000000..53913fdf45
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/stdio.pxd
@@ -0,0 +1,37 @@
+# POSIX additions to <stdio.h>.
+# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html
+
+from libc.stdio cimport FILE
+from libc.stddef cimport wchar_t
+from posix.types cimport off_t
+
+cdef extern from "<stdio.h>" nogil:
+ # File descriptors
+ FILE *fdopen(int, const char *)
+ int fileno(FILE *)
+
+ # Pipes
+ FILE *popen(const char *, const char *)
+ int pclose(FILE *)
+
+ # Memory streams (POSIX.2008)
+ FILE *fmemopen(void *, size_t, const char *)
+ FILE *open_memstream(char **, size_t *)
+ FILE *open_wmemstream(wchar_t **, size_t *)
+
+ # Seek and tell with off_t
+ int fseeko(FILE *, off_t, int)
+ off_t ftello(FILE *)
+
+ # Locking (for multithreading)
+ void flockfile(FILE *)
+ int ftrylockfile(FILE *)
+ void funlockfile(FILE *)
+ int getc_unlocked(FILE *)
+ int getchar_unlocked()
+ int putc_unlocked(int, FILE *)
+ int putchar_unlocked(int)
+
+ # Reading lines and records (POSIX.2008)
+ ssize_t getline(char **, size_t *, FILE *)
+ ssize_t getdelim(char **, size_t *, int, FILE *)
diff --git a/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd
new file mode 100644
index 0000000000..513de938a8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/stdlib.pxd
@@ -0,0 +1,29 @@
+# POSIX additions to <stdlib.h>
+# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
+
+cdef extern from "<stdlib.h>" nogil:
+ void _Exit(int)
+ double drand48()
+ double erand48(unsigned short *)
+ int getsubopt(char **, char *const *, char **)
+ void lcong48(unsigned short *)
+ long lrand()
+ char *mkdtemp(char *)
+ int mkstemp(char *)
+ long mrand()
+ long nrand48(unsigned short *)
+ int posix_memalign(void **, size_t, size_t)
+ int posix_openpt(int)
+ char *ptsname(int)
+ int putenv(char *)
+ int rand_r(unsigned *)
+ long random()
+ char *realpath(const char *, char *)
+ unsigned short *seed48(unsigned short *)
+ int setenv(const char *, const char *, int)
+ void setkey(const char *)
+ char *setstate(char *)
+ void srand48(long)
+ void srandom(unsigned)
+ int unlockpt(int)
+ int unsetenv(const char *)
diff --git a/contrib/tools/cython/Cython/Includes/posix/strings.pxd b/contrib/tools/cython/Cython/Includes/posix/strings.pxd
new file mode 100644
index 0000000000..6ee48491eb
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/strings.pxd
@@ -0,0 +1,9 @@
+cdef extern from "<strings.h>" nogil:
+ int bcmp(const void *, const void *, size_t)
+ void bcopy(const void *, void *, size_t)
+ void bzero(void *, size_t)
+ int ffs(int)
+ char *index(const char *, int)
+ char *rindex(const char *, int)
+ int strcasecmp(const char *, const char *)
+ int strncasecmp(const char *, const char *, size_t)
diff --git a/contrib/tools/cython/Cython/Includes/posix/time.pxd b/contrib/tools/cython/Cython/Includes/posix/time.pxd
new file mode 100644
index 0000000000..6bc81bfea0
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/time.pxd
@@ -0,0 +1,71 @@
+# http://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
+
+cdef extern from "<sys/time.h>" nogil:
+ enum: CLOCK_REALTIME
+ enum: TIMER_ABSTIME
+ enum: CLOCK_MONOTONIC
+
+ # FreeBSD-specific clocks
+ enum: CLOCK_UPTIME
+ enum: CLOCK_UPTIME_PRECISE
+ enum: CLOCK_UPTIME_FAST
+ enum: CLOCK_REALTIME_PRECISE
+ enum: CLOCK_REALTIME_FAST
+ enum: CLOCK_MONOTONIC_PRECISE
+ enum: CLOCK_MONOTONIC_FAST
+ enum: CLOCK_SECOND
+
+ # Linux-specific clocks
+ enum: CLOCK_PROCESS_CPUTIME_ID
+ enum: CLOCK_THREAD_CPUTIME_ID
+ enum: CLOCK_MONOTONIC_RAW
+ enum: CLOCK_REALTIME_COARSE
+ enum: CLOCK_MONOTONIC_COARSE
+ enum: CLOCK_BOOTTIME
+ enum: CLOCK_REALTIME_ALARM
+ enum: CLOCK_BOOTTIME_ALARM
+
+ enum: ITIMER_REAL
+ enum: ITIMER_VIRTUAL
+ enum: ITIMER_PROF
+
+ cdef struct timezone:
+ int tz_minuteswest
+ int dsttime
+
+ cdef struct timeval:
+ time_t tv_sec
+ suseconds_t tv_usec
+
+ cdef struct timespec:
+ time_t tv_sec
+ long tv_nsec
+
+ cdef struct itimerval:
+ timeval it_interval
+ timeval it_value
+
+ cdef struct itimerspec:
+ timespec it_interval
+ timespec it_value
+
+ int nanosleep(const timespec *, timespec *)
+
+ int getitimer(int, itimerval *)
+ int gettimeofday(timeval *tp, timezone *tzp)
+ int setitimer(int, const itimerval *, itimerval *)
+
+ int clock_getcpuclockid(pid_t, clockid_t *)
+ int clock_getres(clockid_t, timespec *)
+ int clock_gettime(clockid_t, timespec *)
+ int clock_nanosleep(clockid_t, int, const timespec *, timespec *)
+ int clock_settime(clockid_t, const timespec *)
+
+ int timer_create(clockid_t, sigevent *, timer_t *)
+ int timer_delete(timer_t)
+ int timer_gettime(timer_t, itimerspec *)
+ int timer_getoverrun(timer_t)
+ int timer_settime(timer_t, int, const itimerspec *, itimerspec *)
diff --git a/contrib/tools/cython/Cython/Includes/posix/types.pxd b/contrib/tools/cython/Cython/Includes/posix/types.pxd
new file mode 100644
index 0000000000..308f2954ee
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/types.pxd
@@ -0,0 +1,30 @@
+# Note that the actual size of these types is system-dependent, and
+# can't be detected at C compile time. However, the generated C code
+# will correctly use the actual size of these types *except* for
+# determining promotion in binary arithmetic expressions involving
+# mixed types. In this case, operands are promoted to the declared
+# larger type, with a bias towards typedef types. Thus, with the
+# declarations below, long + time_t will result in a time_t whereas
+# long long + time_t will result in a long long which should be
+# acceptable for either 32-bit or 64-bit signed time_t (though admittedly
+# the POSIX standard doesn't even specify that time_t must be an integral
+# type).
+
+cdef extern from "<sys/types.h>":
+ ctypedef long blkcnt_t
+ ctypedef long blksize_t
+ ctypedef long clockid_t
+ ctypedef long dev_t
+ ctypedef long gid_t
+ ctypedef long id_t
+ ctypedef unsigned long ino_t
+ ctypedef long mode_t
+ ctypedef long nlink_t
+ ctypedef long off_t
+ ctypedef long pid_t
+ ctypedef struct sigset_t:
+ pass
+ ctypedef long suseconds_t
+ ctypedef long time_t
+ ctypedef long timer_t
+ ctypedef long uid_t
diff --git a/contrib/tools/cython/Cython/Includes/posix/unistd.pxd b/contrib/tools/cython/Cython/Includes/posix/unistd.pxd
new file mode 100644
index 0000000000..1afeca3854
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/unistd.pxd
@@ -0,0 +1,271 @@
+# http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html
+
+from posix.types cimport gid_t, pid_t, off_t, uid_t
+
+cdef extern from "<unistd.h>" nogil:
+
+ #:NULL
+
+ enum: R_OK
+ enum: W_OK
+ enum: X_OK
+ enum: F_OK
+
+ enum: _CS_PATH
+ enum: _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+ enum: _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+ enum: _CS_POSIX_V6_ILP32_OFF32_LIBS
+ enum: _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+ enum: _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+ enum: _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+ enum: _CS_POSIX_V6_LP64_OFF64_CFLAGS
+ enum: _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+ enum: _CS_POSIX_V6_LP64_OFF64_LIBS
+ enum: _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+ enum: _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+ enum: _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+ enum: _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS
+
+ enum: SEEK_SET
+ enum: SEEK_CUR
+ enum: SEEK_END
+
+ enum: F_LOCK
+ enum: F_TEST
+ enum: F_TLOCK
+ enum: F_ULOCK
+
+ enum: _PC_2_SYMLINKS
+ enum: _PC_ALLOC_SIZE_MIN
+ enum: _PC_ASYNC_IO
+ enum: _PC_CHOWN_RESTRICTED
+ enum: _PC_FILESIZEBITS
+ enum: _PC_LINK_MAX
+ enum: _PC_MAX_CANON
+ enum: _PC_MAX_INPUT
+ enum: _PC_NAME_MAX
+ enum: _PC_NO_TRUNC
+ enum: _PC_PATH_MAX
+ enum: _PC_PIPE_BUF
+ enum: _PC_PRIO_IO
+ enum: _PC_REC_INCR_XFER_SIZE
+ enum: _PC_REC_MIN_XFER_SIZE
+ enum: _PC_REC_XFER_ALIGN
+ enum: _PC_SYMLINK_MAX
+ enum: _PC_SYNC_IO
+ enum: _PC_VDISABLE
+
+ enum: _SC_2_C_BIND
+ enum: _SC_2_C_DEV
+ enum: _SC_2_CHAR_TERM
+ enum: _SC_2_FORT_DEV
+ enum: _SC_2_FORT_RUN
+ enum: _SC_2_LOCALEDEF
+ enum: _SC_2_PBS
+ enum: _SC_2_PBS_ACCOUNTING
+ enum: _SC_2_PBS_CHECKPOINT
+ enum: _SC_2_PBS_LOCATE
+ enum: _SC_2_PBS_MESSAGE
+ enum: _SC_2_PBS_TRACK
+ enum: _SC_2_SW_DEV
+ enum: _SC_2_UPE
+ enum: _SC_2_VERSION
+ enum: _SC_ADVISORY_INFO
+ enum: _SC_AIO_LISTIO_MAX
+ enum: _SC_AIO_MAX
+ enum: _SC_AIO_PRIO_DELTA_MAX
+ enum: _SC_ARG_MAX
+ enum: _SC_ASYNCHRONOUS_IO
+ enum: _SC_ATEXIT_MAX
+ enum: _SC_BARRIERS
+ enum: _SC_BC_BASE_MAX
+ enum: _SC_BC_DIM_MAX
+ enum: _SC_BC_SCALE_MAX
+ enum: _SC_BC_STRING_MAX
+ enum: _SC_CHILD_MAX
+ enum: _SC_CLK_TCK
+ enum: _SC_CLOCK_SELECTION
+ enum: _SC_COLL_WEIGHTS_MAX
+ enum: _SC_CPUTIME
+ enum: _SC_DELAYTIMER_MAX
+ enum: _SC_EXPR_NEST_MAX
+ enum: _SC_FSYNC
+ enum: _SC_GETGR_R_SIZE_MAX
+ enum: _SC_GETPW_R_SIZE_MAX
+ enum: _SC_HOST_NAME_MAX
+ enum: _SC_IOV_MAX
+ enum: _SC_IPV6
+ enum: _SC_JOB_CONTROL
+ enum: _SC_LINE_MAX
+ enum: _SC_LOGIN_NAME_MAX
+ enum: _SC_MAPPED_FILES
+ enum: _SC_MEMLOCK
+ enum: _SC_MEMLOCK_RANGE
+ enum: _SC_MEMORY_PROTECTION
+ enum: _SC_MESSAGE_PASSING
+ enum: _SC_MONOTONIC_CLOCK
+ enum: _SC_MQ_OPEN_MAX
+ enum: _SC_MQ_PRIO_MAX
+ enum: _SC_NGROUPS_MAX
+ enum: _SC_OPEN_MAX
+ enum: _SC_PAGE_SIZE
+ enum: _SC_PAGESIZE
+ enum: _SC_PRIORITIZED_IO
+ enum: _SC_PRIORITY_SCHEDULING
+ enum: _SC_RAW_SOCKETS
+ enum: _SC_RE_DUP_MAX
+ enum: _SC_READER_WRITER_LOCKS
+ enum: _SC_REALTIME_SIGNALS
+ enum: _SC_REGEXP
+ enum: _SC_RTSIG_MAX
+ enum: _SC_SAVED_IDS
+ enum: _SC_SEM_NSEMS_MAX
+ enum: _SC_SEM_VALUE_MAX
+ enum: _SC_SEMAPHORES
+ enum: _SC_SHARED_MEMORY_OBJECTS
+ enum: _SC_SHELL
+ enum: _SC_SIGQUEUE_MAX
+ enum: _SC_SPAWN
+ enum: _SC_SPIN_LOCKS
+ enum: _SC_SPORADIC_SERVER
+ enum: _SC_SS_REPL_MAX
+ enum: _SC_STREAM_MAX
+ enum: _SC_SYMLOOP_MAX
+ enum: _SC_SYNCHRONIZED_IO
+ enum: _SC_THREAD_ATTR_STACKADDR
+ enum: _SC_THREAD_ATTR_STACKSIZE
+ enum: _SC_THREAD_CPUTIME
+ enum: _SC_THREAD_DESTRUCTOR_ITERATIONS
+ enum: _SC_THREAD_KEYS_MAX
+ enum: _SC_THREAD_PRIO_INHERIT
+ enum: _SC_THREAD_PRIO_PROTECT
+ enum: _SC_THREAD_PRIORITY_SCHEDULING
+ enum: _SC_THREAD_PROCESS_SHARED
+ enum: _SC_THREAD_SAFE_FUNCTIONS
+ enum: _SC_THREAD_SPORADIC_SERVER
+ enum: _SC_THREAD_STACK_MIN
+ enum: _SC_THREAD_THREADS_MAX
+ enum: _SC_THREADS
+ enum: _SC_TIMEOUTS
+ enum: _SC_TIMER_MAX
+ enum: _SC_TIMERS
+ enum: _SC_TRACE
+ enum: _SC_TRACE_EVENT_FILTER
+ enum: _SC_TRACE_EVENT_NAME_MAX
+ enum: _SC_TRACE_INHERIT
+ enum: _SC_TRACE_LOG
+ enum: _SC_TRACE_NAME_MAX
+ enum: _SC_TRACE_SYS_MAX
+ enum: _SC_TRACE_USER_EVENT_MAX
+ enum: _SC_TTY_NAME_MAX
+ enum: _SC_TYPED_MEMORY_OBJECTS
+ enum: _SC_TZNAME_MAX
+ enum: _SC_V6_ILP32_OFF32
+ enum: _SC_V6_ILP32_OFFBIG
+ enum: _SC_V6_LP64_OFF64
+ enum: _SC_V6_LPBIG_OFFBIG
+ enum: _SC_VERSION
+ enum: _SC_XBS5_ILP32_OFF32
+ enum: _SC_XBS5_ILP32_OFFBIG
+ enum: _SC_XBS5_LP64_OFF64
+ enum: _SC_XBS5_LPBIG_OFFBIG
+ enum: _SC_XOPEN_CRYPT
+ enum: _SC_XOPEN_ENH_I18N
+ enum: _SC_XOPEN_LEGACY
+ enum: _SC_XOPEN_REALTIME
+ enum: _SC_XOPEN_REALTIME_THREADS
+ enum: _SC_XOPEN_SHM
+ enum: _SC_XOPEN_STREAMS
+ enum: _SC_XOPEN_UNIX
+ enum: _SC_XOPEN_VERSION
+
+ enum: STDIN_FILENO #0
+ enum: STDOUT_FILENO #1
+ enum: STDERR_FILENO #2
+
+ ctypedef unsigned useconds_t
+
+ int access(const char *, int)
+ unsigned alarm(unsigned)
+ int chdir(const char *)
+ int chown(const char *, uid_t, gid_t)
+ int close(int)
+ size_t confstr(int, char *, size_t)
+ char *crypt(const char *, const char *)
+ char *ctermid(char *)
+ int dup(int)
+ int dup2(int, int)
+ void encrypt(char[64], int)
+ int execl(const char *, const char *, ...)
+ int execle(const char *, const char *, ...)
+ int execlp(const char *, const char *, ...)
+ int execv(const char *, char *[])
+ int execve(const char *, char *[], char *[])
+ int execvp(const char *, char *[])
+ void _exit(int)
+ int fchown(int, uid_t, gid_t)
+ int fchdir(int)
+ int fdatasync(int)
+ pid_t fork()
+ long fpathconf(int, int)
+ int fsync(int)
+ int ftruncate(int, off_t)
+ char *getcwd(char *, size_t)
+ gid_t getegid()
+ uid_t geteuid()
+ gid_t getgid()
+ int getgroups(int, gid_t [])
+ long gethostid()
+ int gethostname(char *, size_t)
+ char *getlogin()
+ int getlogin_r(char *, size_t)
+ int getopt(int, char * [], const char *)
+ pid_t getpgid(pid_t)
+ pid_t getpgrp()
+ pid_t getpid()
+ pid_t getppid()
+ pid_t getsid(pid_t)
+ uid_t getuid()
+ char *getwd(char *)
+ int isatty(int)
+ int lchown(const char *, uid_t, gid_t)
+ int link(const char *, const char *)
+ int lockf(int, int, off_t)
+ off_t lseek(int, off_t, int)
+ int nice(int)
+ long pathconf(char *, int)
+ int pause()
+ int pipe(int [2])
+ ssize_t pread(int, void *, size_t, off_t)
+ ssize_t pwrite(int, const void *, size_t, off_t)
+ ssize_t read(int, void *, size_t)
+ ssize_t readlink(const char *, char *, size_t)
+ int rmdir(const char *)
+ int setegid(gid_t)
+ int seteuid(uid_t)
+ int setgid(gid_t)
+ int setpgid(pid_t, pid_t)
+ pid_t setpgrp()
+ int setregid(gid_t, gid_t)
+ int setreuid(uid_t, uid_t)
+ pid_t setsid()
+ int setuid(uid_t)
+ unsigned sleep(unsigned)
+ void swab(const void *, void *, ssize_t)
+ int symlink(const char *, const char *)
+ void sync()
+ long sysconf(int)
+ pid_t tcgetpgrp(int)
+ int tcsetpgrp(int, pid_t)
+ int truncate(const char *, off_t)
+ char *ttyname(int)
+ int ttyname_r(int, char *, size_t)
+ useconds_t ualarm(useconds_t, useconds_t)
+ int unlink(const char *)
+ int usleep(useconds_t)
+ pid_t vfork()
+ ssize_t write(int, const void *, size_t)
+ char *optarg
+ int optind
+ int opterr
+ int optopt
diff --git a/contrib/tools/cython/Cython/Includes/posix/wait.pxd b/contrib/tools/cython/Cython/Includes/posix/wait.pxd
new file mode 100644
index 0000000000..d18cff9cf8
--- /dev/null
+++ b/contrib/tools/cython/Cython/Includes/posix/wait.pxd
@@ -0,0 +1,38 @@
+# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/wait.h.html
+
+from posix.types cimport pid_t, id_t
+from posix.signal cimport siginfo_t
+from posix.resource cimport rusage
+
+cdef extern from "<sys/wait.h>" nogil:
+ enum: WNOHANG
+ enum: WUNTRACED
+ enum: WCONTINUED
+ enum: WEXITED
+ enum: WSTOPPED
+ enum: WNOWAIT
+
+ int WEXITSTATUS(int status)
+ int WIFCONTINUED(int status)
+ int WIFEXITED(int status)
+ int WIFSIGNALED(int status)
+ int WIFSTOPPED(int status)
+ int WSTOPSIG(int status)
+ int WTERMSIG(int status)
+
+ ctypedef int idtype_t
+ enum: P_ALL # idtype_t values
+ enum: P_PID
+ enum: P_PGID
+
+ pid_t wait(int *stat_loc)
+ pid_t waitpid(pid_t pid, int *status, int options)
+ int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)
+
+# wait3 was in POSIX until 2008 while wait4 was never standardized.
+# Even so, these calls are in almost every Unix, always in sys/wait.h.
+# Hence, posix.wait is the least surprising place to declare them for Cython.
+# libc may require _XXX_SOURCE to be defined at C-compile time to provide them.
+
+ pid_t wait3(int *status, int options, rusage *rusage)
+ pid_t wait4(pid_t pid, int *status, int options, rusage *rusage)