pyogrio 0.8.0__cp311-cp311-win_amd64.whl → 0.10.0__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyogrio might be problematic. Click here for more details.
- pyogrio/__init__.py +26 -18
- pyogrio/_compat.py +7 -1
- pyogrio/_env.py +4 -6
- pyogrio/_err.c +460 -445
- pyogrio/_err.cp311-win_amd64.pyd +0 -0
- pyogrio/_geometry.c +645 -612
- pyogrio/_geometry.cp311-win_amd64.pyd +0 -0
- pyogrio/_io.c +7764 -7602
- pyogrio/_io.cp311-win_amd64.pyd +0 -0
- pyogrio/_ogr.c +601 -609
- pyogrio/_ogr.cp311-win_amd64.pyd +0 -0
- pyogrio/_version.py +3 -3
- pyogrio/_vsi.c +7570 -2514
- pyogrio/_vsi.cp311-win_amd64.pyd +0 -0
- pyogrio/core.py +86 -20
- pyogrio/errors.py +9 -16
- pyogrio/gdal_data/GDAL-targets.cmake +1 -1
- pyogrio/gdal_data/GDALConfig.cmake +0 -1
- pyogrio/gdal_data/GDALConfigVersion.cmake +3 -3
- pyogrio/gdal_data/MM_m_idofic.csv +321 -0
- pyogrio/gdal_data/gdaltileindex.xsd +269 -0
- pyogrio/gdal_data/gdalvrt.xsd +130 -22
- pyogrio/gdal_data/ogrinfo_output.schema.json +23 -0
- pyogrio/gdal_data/ogrvrt.xsd +3 -0
- pyogrio/gdal_data/pci_datum.txt +222 -155
- pyogrio/gdal_data/pci_ellips.txt +90 -38
- pyogrio/gdal_data/vcpkg.spdx.json +21 -21
- pyogrio/gdal_data/vcpkg_abi_info.txt +27 -27
- pyogrio/geopandas.py +44 -27
- pyogrio/proj_data/proj-config-version.cmake +2 -2
- pyogrio/proj_data/proj-targets.cmake +1 -1
- pyogrio/proj_data/proj.db +0 -0
- pyogrio/proj_data/proj4-targets.cmake +1 -1
- pyogrio/proj_data/projjson.schema.json +1 -1
- pyogrio/proj_data/vcpkg.spdx.json +17 -17
- pyogrio/proj_data/vcpkg_abi_info.txt +15 -15
- pyogrio/raw.py +46 -30
- pyogrio/tests/conftest.py +206 -12
- pyogrio/tests/fixtures/README.md +32 -13
- pyogrio/tests/fixtures/curve.gpkg +0 -0
- pyogrio/tests/fixtures/{test_multisurface.gpkg → curvepolygon.gpkg} +0 -0
- pyogrio/tests/fixtures/line_zm.gpkg +0 -0
- pyogrio/tests/fixtures/multisurface.gpkg +0 -0
- pyogrio/tests/test_arrow.py +178 -24
- pyogrio/tests/test_core.py +162 -72
- pyogrio/tests/test_geopandas_io.py +341 -96
- pyogrio/tests/test_path.py +30 -17
- pyogrio/tests/test_raw_io.py +165 -54
- pyogrio/tests/test_util.py +56 -0
- pyogrio/util.py +55 -31
- pyogrio-0.10.0.dist-info/DELVEWHEEL +2 -0
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/LICENSE +1 -1
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/METADATA +37 -8
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/RECORD +74 -89
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/WHEEL +1 -1
- pyogrio.libs/{Lerc-62a2c1c74500e7815994b3e49b36750c.dll → Lerc-089e3fef3df84b17326dcddbf1dedaa4.dll} +0 -0
- pyogrio.libs/{gdal-2bfc6a9f962a8953b0640db9a272d797.dll → gdal-debee5933f0da7bb90b4bcd009023377.dll} +0 -0
- pyogrio.libs/{geos-289d7171bd083dfed1f8a90e4ae57442.dll → geos-ace4c5b5c1f569bb4213e7bbd0b0322e.dll} +0 -0
- pyogrio.libs/{geos_c-2a12859cd876719c648f1eb950b7d94c.dll → geos_c-7478ca0a86136b280d9b2d245c6f6627.dll} +0 -0
- pyogrio.libs/geotiff-c8fe8a095520a4ea4e465d27e06add3a.dll +0 -0
- pyogrio.libs/{iconv-2-f2d9304f8dc4cdd981024b520b73a099.dll → iconv-2-27352d156a5467ca5383d3951093ea5a.dll} +0 -0
- pyogrio.libs/{jpeg62-a67b2bf7fd32d34c565ae5bb6d47c224.dll → jpeg62-e56b6f95a95af498f4623b8da4cebd46.dll} +0 -0
- pyogrio.libs/{json-c-79a8df7e59952f5c5d594620e4b66c13.dll → json-c-c84940e2654a4f8468bfcf2ce992aa93.dll} +0 -0
- pyogrio.libs/libcurl-d69cfd4ad487d53d58743b6778ec85e7.dll +0 -0
- pyogrio.libs/{libexpat-fa55f107b678de136400c6d953c3cdde.dll → libexpat-6576a8d02641b6a3dbad35901ec200a7.dll} +0 -0
- pyogrio.libs/liblzma-9ee4accb476ec1ae24e924953140273d.dll +0 -0
- pyogrio.libs/{libpng16-6227e9a35c2a350ae6b0586079c10b9e.dll → libpng16-7c36142dda59f186f6bb683e8dae2bfe.dll} +0 -0
- pyogrio.libs/{msvcp140-46db46e967c8db2cb7a20fc75872a57e.dll → msvcp140-98b3e5b80de1e5e9d1703b786d795623.dll} +0 -0
- pyogrio.libs/proj-a408c5327f3fd2f5fabe8c56815beed7.dll +0 -0
- pyogrio.libs/{qhull_r-d8840f4ed1f7d452ff9a30237320bcfd.dll → qhull_r-516897f855568caab1ab1fe37912766c.dll} +0 -0
- pyogrio.libs/sqlite3-9bc109d8536d5ed9666332fec94485fc.dll +0 -0
- pyogrio.libs/{tiff-ffca1ff19d0e95dad39df0078fb037af.dll → tiff-9b3f605fffe0bccc0a964c374ee4f820.dll} +0 -0
- pyogrio.libs/{zlib1-aaba6ea052f6d3fa3d84a301e3eb3d30.dll → zlib1-e5af16a15c63f05bd82d90396807ae5b.dll} +0 -0
- pyogrio/_err.pxd +0 -4
- pyogrio/_err.pyx +0 -250
- pyogrio/_geometry.pxd +0 -4
- pyogrio/_geometry.pyx +0 -129
- pyogrio/_io.pxd +0 -0
- pyogrio/_io.pyx +0 -2738
- pyogrio/_ogr.pxd +0 -441
- pyogrio/_ogr.pyx +0 -346
- pyogrio/_vsi.pxd +0 -4
- pyogrio/_vsi.pyx +0 -140
- pyogrio/arrow_bridge.h +0 -115
- pyogrio/gdal_data/bag_template.xml +0 -201
- pyogrio/gdal_data/gmlasconf.xml +0 -169
- pyogrio/gdal_data/gmlasconf.xsd +0 -1066
- pyogrio/gdal_data/netcdf_config.xsd +0 -143
- pyogrio/gdal_data/template_tiles.mapml +0 -28
- pyogrio/tests/fixtures/test_datetime.geojson +0 -7
- pyogrio/tests/fixtures/test_datetime_tz.geojson +0 -8
- pyogrio/tests/fixtures/test_fgdb.gdb.zip +0 -0
- pyogrio/tests/fixtures/test_nested.geojson +0 -18
- pyogrio/tests/fixtures/test_ogr_types_list.geojson +0 -12
- pyogrio-0.8.0.dist-info/DELVEWHEEL +0 -2
- pyogrio.libs/geotiff-d1c0fcc3c454409ad8be61ff04a7422c.dll +0 -0
- pyogrio.libs/libcurl-7fef9869f6520a5fbdb2bc9ce4c496cc.dll +0 -0
- pyogrio.libs/liblzma-5a1f648afc3d4cf36e3aef2266d55143.dll +0 -0
- pyogrio.libs/proj-74051a73897c9fa6d7bfef4561688568.dll +0 -0
- pyogrio.libs/sqlite3-fe7a86058d1c5658d1f9106228a7fd83.dll +0 -0
- {pyogrio-0.8.0.dist-info → pyogrio-0.10.0.dist-info}/top_level.txt +0 -0
pyogrio/_geometry.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by Cython 3.0.
|
|
1
|
+
/* Generated by Cython 3.0.11 */
|
|
2
2
|
|
|
3
3
|
/* BEGIN: Cython Metadata
|
|
4
4
|
{
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"depends": [
|
|
7
7
|
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\cpl_conv.h",
|
|
8
8
|
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\cpl_error.h",
|
|
9
|
+
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\cpl_port.h",
|
|
9
10
|
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\cpl_string.h",
|
|
10
11
|
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\cpl_vsi.h",
|
|
11
12
|
"C:\\vcpkg\\installed\\x64-windows-dynamic-release\\include\\gdal.h",
|
|
@@ -57,10 +58,10 @@ END: Cython Metadata */
|
|
|
57
58
|
#else
|
|
58
59
|
#define __PYX_EXTRA_ABI_MODULE_NAME ""
|
|
59
60
|
#endif
|
|
60
|
-
#define CYTHON_ABI "
|
|
61
|
+
#define CYTHON_ABI "3_0_11" __PYX_EXTRA_ABI_MODULE_NAME
|
|
61
62
|
#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
|
|
62
63
|
#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
|
|
63
|
-
#define CYTHON_HEX_VERSION
|
|
64
|
+
#define CYTHON_HEX_VERSION 0x03000BF0
|
|
64
65
|
#define CYTHON_FUTURE_DIVISION 1
|
|
65
66
|
#include <stddef.h>
|
|
66
67
|
#ifndef offsetof
|
|
@@ -1257,6 +1258,7 @@ static CYTHON_INLINE float __PYX_NAN() {
|
|
|
1257
1258
|
#include <stdio.h>
|
|
1258
1259
|
#include "cpl_conv.h"
|
|
1259
1260
|
#include "cpl_error.h"
|
|
1261
|
+
#include "cpl_port.h"
|
|
1260
1262
|
#include "cpl_string.h"
|
|
1261
1263
|
#include "cpl_vsi.h"
|
|
1262
1264
|
#include "ogr_core.h"
|
|
@@ -1527,7 +1529,7 @@ static const char *__pyx_f[] = {
|
|
|
1527
1529
|
/*--- Type declarations ---*/
|
|
1528
1530
|
struct __pyx_opt_args_7pyogrio_4_ogr_get_string;
|
|
1529
1531
|
|
|
1530
|
-
/* "pyogrio/_ogr.pxd":
|
|
1532
|
+
/* "pyogrio/_ogr.pxd":452
|
|
1531
1533
|
*
|
|
1532
1534
|
*
|
|
1533
1535
|
* cdef get_string(const char *c_str, str encoding=*) # <<<<<<<<<<<<<<
|
|
@@ -1824,9 +1826,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
|
|
|
1824
1826
|
/* RaiseException.proto */
|
|
1825
1827
|
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
|
|
1826
1828
|
|
|
1827
|
-
/*
|
|
1828
|
-
#
|
|
1829
|
-
|
|
1829
|
+
/* PyObject_Unicode.proto */
|
|
1830
|
+
#if PY_MAJOR_VERSION >= 3
|
|
1831
|
+
#define __Pyx_PyObject_Unicode(obj)\
|
|
1832
|
+
(likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))
|
|
1833
|
+
#else
|
|
1834
|
+
#define __Pyx_PyObject_Unicode(obj)\
|
|
1835
|
+
(likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj))
|
|
1836
|
+
#endif
|
|
1830
1837
|
|
|
1831
1838
|
/* SwapException.proto */
|
|
1832
1839
|
#if CYTHON_FAST_THREAD_STATE
|
|
@@ -2053,7 +2060,7 @@ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt
|
|
|
2053
2060
|
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
|
|
2054
2061
|
|
|
2055
2062
|
/* FunctionImport.proto */
|
|
2056
|
-
static int
|
|
2063
|
+
static int __Pyx_ImportFunction_3_0_11(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
|
|
2057
2064
|
|
|
2058
2065
|
/* InitStrings.proto */
|
|
2059
2066
|
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
|
|
@@ -2612,18 +2619,19 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2612
2619
|
int __pyx_t_9;
|
|
2613
2620
|
PyObject *__pyx_t_10 = NULL;
|
|
2614
2621
|
PyObject *__pyx_t_11 = NULL;
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2622
|
+
unsigned int __pyx_t_12;
|
|
2623
|
+
PyObject *__pyx_t_13 = NULL;
|
|
2624
|
+
int __pyx_t_14;
|
|
2625
|
+
char const *__pyx_t_15;
|
|
2619
2626
|
PyObject *__pyx_t_16 = NULL;
|
|
2620
2627
|
PyObject *__pyx_t_17 = NULL;
|
|
2621
2628
|
PyObject *__pyx_t_18 = NULL;
|
|
2622
2629
|
PyObject *__pyx_t_19 = NULL;
|
|
2623
2630
|
PyObject *__pyx_t_20 = NULL;
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2631
|
+
PyObject *__pyx_t_21 = NULL;
|
|
2632
|
+
int __pyx_t_22;
|
|
2633
|
+
Py_ssize_t __pyx_t_23;
|
|
2634
|
+
Py_UCS4 __pyx_t_24;
|
|
2627
2635
|
int __pyx_lineno = 0;
|
|
2628
2636
|
const char *__pyx_filename = NULL;
|
|
2629
2637
|
int __pyx_clineno = 0;
|
|
@@ -2709,7 +2717,7 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2709
2717
|
__Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_DataLayerError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 89, __pyx_L5_except_error)
|
|
2710
2718
|
__Pyx_GOTREF(__pyx_t_10);
|
|
2711
2719
|
__pyx_t_11 = NULL;
|
|
2712
|
-
|
|
2720
|
+
__pyx_t_12 = 0;
|
|
2713
2721
|
#if CYTHON_UNPACK_METHODS
|
|
2714
2722
|
if (unlikely(PyMethod_Check(__pyx_t_10))) {
|
|
2715
2723
|
__pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
|
|
@@ -2718,13 +2726,13 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2718
2726
|
__Pyx_INCREF(__pyx_t_11);
|
|
2719
2727
|
__Pyx_INCREF(function);
|
|
2720
2728
|
__Pyx_DECREF_SET(__pyx_t_10, function);
|
|
2721
|
-
|
|
2729
|
+
__pyx_t_12 = 1;
|
|
2722
2730
|
}
|
|
2723
2731
|
}
|
|
2724
2732
|
#endif
|
|
2725
2733
|
{
|
|
2726
2734
|
PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_kp_u_Could_not_get_layer_definition};
|
|
2727
|
-
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-
|
|
2735
|
+
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
|
|
2728
2736
|
__Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
|
|
2729
2737
|
if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 89, __pyx_L5_except_error)
|
|
2730
2738
|
__Pyx_GOTREF(__pyx_t_8);
|
|
@@ -2768,26 +2776,26 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2768
2776
|
*/
|
|
2769
2777
|
__Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_DataLayerError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 92, __pyx_L16_error)
|
|
2770
2778
|
__Pyx_GOTREF(__pyx_t_10);
|
|
2771
|
-
__pyx_t_11 =
|
|
2779
|
+
__pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_v_exc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 92, __pyx_L16_error)
|
|
2772
2780
|
__Pyx_GOTREF(__pyx_t_11);
|
|
2773
|
-
|
|
2774
|
-
|
|
2781
|
+
__pyx_t_13 = NULL;
|
|
2782
|
+
__pyx_t_12 = 0;
|
|
2775
2783
|
#if CYTHON_UNPACK_METHODS
|
|
2776
2784
|
if (unlikely(PyMethod_Check(__pyx_t_10))) {
|
|
2777
|
-
|
|
2778
|
-
if (likely(
|
|
2785
|
+
__pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
|
|
2786
|
+
if (likely(__pyx_t_13)) {
|
|
2779
2787
|
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
|
|
2780
|
-
__Pyx_INCREF(
|
|
2788
|
+
__Pyx_INCREF(__pyx_t_13);
|
|
2781
2789
|
__Pyx_INCREF(function);
|
|
2782
2790
|
__Pyx_DECREF_SET(__pyx_t_10, function);
|
|
2783
|
-
|
|
2791
|
+
__pyx_t_12 = 1;
|
|
2784
2792
|
}
|
|
2785
2793
|
}
|
|
2786
2794
|
#endif
|
|
2787
2795
|
{
|
|
2788
|
-
PyObject *__pyx_callargs[2] = {
|
|
2789
|
-
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-
|
|
2790
|
-
__Pyx_XDECREF(
|
|
2796
|
+
PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_11};
|
|
2797
|
+
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
|
|
2798
|
+
__Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
|
|
2791
2799
|
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
|
|
2792
2800
|
if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 92, __pyx_L16_error)
|
|
2793
2801
|
__Pyx_GOTREF(__pyx_t_8);
|
|
@@ -2810,35 +2818,35 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2810
2818
|
/*exception exit:*/{
|
|
2811
2819
|
__Pyx_PyThreadState_declare
|
|
2812
2820
|
__Pyx_PyThreadState_assign
|
|
2813
|
-
|
|
2821
|
+
__pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
|
|
2814
2822
|
__Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
|
|
2815
2823
|
__Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
|
|
2816
|
-
__Pyx_XDECREF(
|
|
2824
|
+
__Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
|
|
2817
2825
|
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
|
|
2818
|
-
if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&
|
|
2819
|
-
if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&
|
|
2820
|
-
__Pyx_XGOTREF(__pyx_t_15);
|
|
2826
|
+
if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
|
|
2827
|
+
if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
|
|
2821
2828
|
__Pyx_XGOTREF(__pyx_t_16);
|
|
2822
2829
|
__Pyx_XGOTREF(__pyx_t_17);
|
|
2823
2830
|
__Pyx_XGOTREF(__pyx_t_18);
|
|
2824
2831
|
__Pyx_XGOTREF(__pyx_t_19);
|
|
2825
2832
|
__Pyx_XGOTREF(__pyx_t_20);
|
|
2826
|
-
|
|
2833
|
+
__Pyx_XGOTREF(__pyx_t_21);
|
|
2834
|
+
__pyx_t_9 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
|
|
2827
2835
|
{
|
|
2828
2836
|
__Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0;
|
|
2829
2837
|
}
|
|
2830
2838
|
if (PY_MAJOR_VERSION >= 3) {
|
|
2831
|
-
__Pyx_XGIVEREF(__pyx_t_18);
|
|
2832
2839
|
__Pyx_XGIVEREF(__pyx_t_19);
|
|
2833
2840
|
__Pyx_XGIVEREF(__pyx_t_20);
|
|
2834
|
-
|
|
2841
|
+
__Pyx_XGIVEREF(__pyx_t_21);
|
|
2842
|
+
__Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
|
|
2835
2843
|
}
|
|
2836
|
-
__Pyx_XGIVEREF(__pyx_t_15);
|
|
2837
2844
|
__Pyx_XGIVEREF(__pyx_t_16);
|
|
2838
2845
|
__Pyx_XGIVEREF(__pyx_t_17);
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2846
|
+
__Pyx_XGIVEREF(__pyx_t_18);
|
|
2847
|
+
__Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
|
|
2848
|
+
__pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
|
|
2849
|
+
__pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
|
|
2842
2850
|
goto __pyx_L5_except_error;
|
|
2843
2851
|
}
|
|
2844
2852
|
}
|
|
@@ -2881,10 +2889,10 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2881
2889
|
__Pyx_GOTREF(__pyx_t_5);
|
|
2882
2890
|
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_GEOMETRY_TYPES); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 96, __pyx_L1_error)
|
|
2883
2891
|
__Pyx_GOTREF(__pyx_t_6);
|
|
2884
|
-
|
|
2892
|
+
__pyx_t_22 = (__Pyx_PySequence_ContainsTF(__pyx_t_5, __pyx_t_6, Py_NE)); if (unlikely((__pyx_t_22 < 0))) __PYX_ERR(0, 96, __pyx_L1_error)
|
|
2885
2893
|
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
|
2886
2894
|
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
2887
|
-
if (unlikely(
|
|
2895
|
+
if (unlikely(__pyx_t_22)) {
|
|
2888
2896
|
|
|
2889
2897
|
/* "pyogrio/_geometry.pyx":97
|
|
2890
2898
|
*
|
|
@@ -2901,7 +2909,7 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2901
2909
|
__Pyx_GOTREF(__pyx_t_8);
|
|
2902
2910
|
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
|
|
2903
2911
|
__pyx_t_7 = NULL;
|
|
2904
|
-
|
|
2912
|
+
__pyx_t_12 = 0;
|
|
2905
2913
|
#if CYTHON_UNPACK_METHODS
|
|
2906
2914
|
if (unlikely(PyMethod_Check(__pyx_t_5))) {
|
|
2907
2915
|
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
|
|
@@ -2910,13 +2918,13 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2910
2918
|
__Pyx_INCREF(__pyx_t_7);
|
|
2911
2919
|
__Pyx_INCREF(function);
|
|
2912
2920
|
__Pyx_DECREF_SET(__pyx_t_5, function);
|
|
2913
|
-
|
|
2921
|
+
__pyx_t_12 = 1;
|
|
2914
2922
|
}
|
|
2915
2923
|
}
|
|
2916
2924
|
#endif
|
|
2917
2925
|
{
|
|
2918
2926
|
PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_8};
|
|
2919
|
-
__pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-
|
|
2927
|
+
__pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
|
|
2920
2928
|
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
|
|
2921
2929
|
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
|
|
2922
2930
|
if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 97, __pyx_L1_error)
|
|
@@ -2943,8 +2951,8 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2943
2951
|
* original_type = GEOMETRY_TYPES[ogr_type]
|
|
2944
2952
|
*
|
|
2945
2953
|
*/
|
|
2946
|
-
|
|
2947
|
-
if (
|
|
2954
|
+
__pyx_t_22 = (OGR_GT_HasM(__pyx_v_ogr_type) != 0);
|
|
2955
|
+
if (__pyx_t_22) {
|
|
2948
2956
|
|
|
2949
2957
|
/* "pyogrio/_geometry.pyx":100
|
|
2950
2958
|
*
|
|
@@ -2995,10 +3003,10 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
2995
3003
|
*/
|
|
2996
3004
|
__pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 107, __pyx_L1_error)
|
|
2997
3005
|
__Pyx_GOTREF(__pyx_t_5);
|
|
2998
|
-
|
|
2999
|
-
|
|
3006
|
+
__pyx_t_23 = 0;
|
|
3007
|
+
__pyx_t_24 = 127;
|
|
3000
3008
|
__Pyx_INCREF(__pyx_kp_u_Measured_M_geometry_types_are_no);
|
|
3001
|
-
|
|
3009
|
+
__pyx_t_23 += 62;
|
|
3002
3010
|
__Pyx_GIVEREF(__pyx_kp_u_Measured_M_geometry_types_are_no);
|
|
3003
3011
|
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Measured_M_geometry_types_are_no);
|
|
3004
3012
|
|
|
@@ -3011,13 +3019,13 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
3011
3019
|
*/
|
|
3012
3020
|
__pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_original_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error)
|
|
3013
3021
|
__Pyx_GOTREF(__pyx_t_7);
|
|
3014
|
-
|
|
3015
|
-
|
|
3022
|
+
__pyx_t_24 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_24) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_24;
|
|
3023
|
+
__pyx_t_23 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
|
|
3016
3024
|
__Pyx_GIVEREF(__pyx_t_7);
|
|
3017
3025
|
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
|
|
3018
3026
|
__pyx_t_7 = 0;
|
|
3019
3027
|
__Pyx_INCREF(__pyx_kp_u_is_converted_to);
|
|
3020
|
-
|
|
3028
|
+
__pyx_t_23 += 19;
|
|
3021
3029
|
__Pyx_GIVEREF(__pyx_kp_u_is_converted_to);
|
|
3022
3030
|
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_is_converted_to);
|
|
3023
3031
|
|
|
@@ -3039,13 +3047,13 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
3039
3047
|
__pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 109, __pyx_L1_error)
|
|
3040
3048
|
__Pyx_GOTREF(__pyx_t_10);
|
|
3041
3049
|
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
|
|
3042
|
-
|
|
3043
|
-
|
|
3050
|
+
__pyx_t_24 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_24) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_24;
|
|
3051
|
+
__pyx_t_23 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
|
|
3044
3052
|
__Pyx_GIVEREF(__pyx_t_10);
|
|
3045
3053
|
PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_10);
|
|
3046
3054
|
__pyx_t_10 = 0;
|
|
3047
3055
|
__Pyx_INCREF(__pyx_kp_u_);
|
|
3048
|
-
|
|
3056
|
+
__pyx_t_23 += 1;
|
|
3049
3057
|
__Pyx_GIVEREF(__pyx_kp_u_);
|
|
3050
3058
|
PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_kp_u_);
|
|
3051
3059
|
|
|
@@ -3056,11 +3064,11 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
3056
3064
|
* f"Original type '{original_type}' "
|
|
3057
3065
|
* f"is converted to '{GEOMETRY_TYPES[ogr_type]}'")
|
|
3058
3066
|
*/
|
|
3059
|
-
__pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_5, 5,
|
|
3067
|
+
__pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_5, 5, __pyx_t_23, __pyx_t_24); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 107, __pyx_L1_error)
|
|
3060
3068
|
__Pyx_GOTREF(__pyx_t_10);
|
|
3061
3069
|
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
|
3062
3070
|
__pyx_t_5 = NULL;
|
|
3063
|
-
|
|
3071
|
+
__pyx_t_12 = 0;
|
|
3064
3072
|
#if CYTHON_UNPACK_METHODS
|
|
3065
3073
|
if (unlikely(PyMethod_Check(__pyx_t_6))) {
|
|
3066
3074
|
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
|
|
@@ -3069,13 +3077,13 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
3069
3077
|
__Pyx_INCREF(__pyx_t_5);
|
|
3070
3078
|
__Pyx_INCREF(function);
|
|
3071
3079
|
__Pyx_DECREF_SET(__pyx_t_6, function);
|
|
3072
|
-
|
|
3080
|
+
__pyx_t_12 = 1;
|
|
3073
3081
|
}
|
|
3074
3082
|
}
|
|
3075
3083
|
#endif
|
|
3076
3084
|
{
|
|
3077
3085
|
PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_10};
|
|
3078
|
-
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-
|
|
3086
|
+
__pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
|
|
3079
3087
|
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
|
|
3080
3088
|
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
|
|
3081
3089
|
if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 106, __pyx_L1_error)
|
|
@@ -3130,7 +3138,7 @@ static PyObject *__pyx_f_7pyogrio_9_geometry_get_geometry_type(void *__pyx_v_ogr
|
|
|
3130
3138
|
__Pyx_XDECREF(__pyx_t_8);
|
|
3131
3139
|
__Pyx_XDECREF(__pyx_t_10);
|
|
3132
3140
|
__Pyx_XDECREF(__pyx_t_11);
|
|
3133
|
-
__Pyx_XDECREF(
|
|
3141
|
+
__Pyx_XDECREF(__pyx_t_13);
|
|
3134
3142
|
__Pyx_AddTraceback("pyogrio._geometry.get_geometry_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
|
|
3135
3143
|
__pyx_r = 0;
|
|
3136
3144
|
__pyx_L0:;
|
|
@@ -3157,7 +3165,7 @@ static OGRwkbGeometryType __pyx_f_7pyogrio_9_geometry_get_geometry_type_code(PyO
|
|
|
3157
3165
|
PyObject *__pyx_t_3 = NULL;
|
|
3158
3166
|
PyObject *__pyx_t_4 = NULL;
|
|
3159
3167
|
PyObject *__pyx_t_5 = NULL;
|
|
3160
|
-
int __pyx_t_6;
|
|
3168
|
+
unsigned int __pyx_t_6;
|
|
3161
3169
|
OGRwkbGeometryType __pyx_t_7;
|
|
3162
3170
|
int __pyx_lineno = 0;
|
|
3163
3171
|
const char *__pyx_filename = NULL;
|
|
@@ -3459,7 +3467,7 @@ static int __Pyx_modinit_function_import_code(void) {
|
|
|
3459
3467
|
/*--- Function import code ---*/
|
|
3460
3468
|
__pyx_t_1 = PyImport_ImportModule("pyogrio._err"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
|
|
3461
3469
|
__Pyx_GOTREF(__pyx_t_1);
|
|
3462
|
-
if (
|
|
3470
|
+
if (__Pyx_ImportFunction_3_0_11(__pyx_t_1, "exc_wrap_pointer", (void (**)(void))&__pyx_f_7pyogrio_4_err_exc_wrap_pointer, "void *(void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
|
|
3463
3471
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3464
3472
|
__Pyx_RefNannyFinishContext();
|
|
3465
3473
|
return 0;
|
|
@@ -6856,12 +6864,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_OGRwkbGeometryType(OGRwkbGeometr
|
|
|
6856
6864
|
}
|
|
6857
6865
|
}
|
|
6858
6866
|
{
|
|
6859
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
6860
6867
|
unsigned char *bytes = (unsigned char *)&value;
|
|
6861
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
6868
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
6869
|
+
if (is_unsigned) {
|
|
6870
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
6871
|
+
} else {
|
|
6872
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
6873
|
+
}
|
|
6874
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
6875
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
6862
6876
|
return _PyLong_FromByteArray(bytes, sizeof(OGRwkbGeometryType),
|
|
6863
6877
|
little, !is_unsigned);
|
|
6864
6878
|
#else
|
|
6879
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
6865
6880
|
PyObject *from_bytes, *result = NULL;
|
|
6866
6881
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
6867
6882
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -6911,151 +6926,174 @@ static CYTHON_INLINE OGRwkbGeometryType __Pyx_PyInt_As_OGRwkbGeometryType(PyObje
|
|
|
6911
6926
|
}
|
|
6912
6927
|
return (OGRwkbGeometryType) val;
|
|
6913
6928
|
}
|
|
6914
|
-
}
|
|
6929
|
+
}
|
|
6915
6930
|
#endif
|
|
6916
|
-
if (
|
|
6917
|
-
|
|
6931
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
6932
|
+
OGRwkbGeometryType val;
|
|
6933
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
6934
|
+
if (!tmp) return (OGRwkbGeometryType) -1;
|
|
6935
|
+
val = __Pyx_PyInt_As_OGRwkbGeometryType(tmp);
|
|
6936
|
+
Py_DECREF(tmp);
|
|
6937
|
+
return val;
|
|
6938
|
+
}
|
|
6939
|
+
if (is_unsigned) {
|
|
6918
6940
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
}
|
|
6941
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
6942
|
+
goto raise_neg_overflow;
|
|
6943
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
6944
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
6945
|
+
} else {
|
|
6946
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
6947
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
6948
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
6949
|
+
case 2:
|
|
6950
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 1 * PyLong_SHIFT)) {
|
|
6951
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
6952
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
6953
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) >= 2 * PyLong_SHIFT)) {
|
|
6954
|
+
return (OGRwkbGeometryType) (((((OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0]));
|
|
6934
6955
|
}
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6956
|
+
}
|
|
6957
|
+
break;
|
|
6958
|
+
case 3:
|
|
6959
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 2 * PyLong_SHIFT)) {
|
|
6960
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
6961
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
6962
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) >= 3 * PyLong_SHIFT)) {
|
|
6963
|
+
return (OGRwkbGeometryType) (((((((OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0]));
|
|
6943
6964
|
}
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6965
|
+
}
|
|
6966
|
+
break;
|
|
6967
|
+
case 4:
|
|
6968
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 3 * PyLong_SHIFT)) {
|
|
6969
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
6970
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
6971
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) >= 4 * PyLong_SHIFT)) {
|
|
6972
|
+
return (OGRwkbGeometryType) (((((((((OGRwkbGeometryType)digits[3]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0]));
|
|
6952
6973
|
}
|
|
6953
|
-
|
|
6954
|
-
|
|
6974
|
+
}
|
|
6975
|
+
break;
|
|
6955
6976
|
}
|
|
6977
|
+
}
|
|
6956
6978
|
#endif
|
|
6957
6979
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6980
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
6981
|
+
goto raise_neg_overflow;
|
|
6982
|
+
}
|
|
6961
6983
|
#else
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6984
|
+
{
|
|
6985
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
6986
|
+
if (unlikely(result < 0))
|
|
6987
|
+
return (OGRwkbGeometryType) -1;
|
|
6988
|
+
if (unlikely(result == 1))
|
|
6989
|
+
goto raise_neg_overflow;
|
|
6990
|
+
}
|
|
6969
6991
|
#endif
|
|
6970
|
-
|
|
6971
|
-
|
|
6992
|
+
if ((sizeof(OGRwkbGeometryType) <= sizeof(unsigned long))) {
|
|
6993
|
+
__PYX_VERIFY_RETURN_INT_EXC(OGRwkbGeometryType, unsigned long, PyLong_AsUnsignedLong(x))
|
|
6972
6994
|
#ifdef HAVE_LONG_LONG
|
|
6973
|
-
|
|
6974
|
-
|
|
6995
|
+
} else if ((sizeof(OGRwkbGeometryType) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
6996
|
+
__PYX_VERIFY_RETURN_INT_EXC(OGRwkbGeometryType, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
6975
6997
|
#endif
|
|
6976
|
-
|
|
6977
|
-
|
|
6998
|
+
}
|
|
6999
|
+
} else {
|
|
6978
7000
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
}
|
|
7001
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
7002
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
7003
|
+
} else {
|
|
7004
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7005
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7006
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
7007
|
+
case -2:
|
|
7008
|
+
if ((8 * sizeof(OGRwkbGeometryType) - 1 > 1 * PyLong_SHIFT)) {
|
|
7009
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7010
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7011
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 2 * PyLong_SHIFT)) {
|
|
7012
|
+
return (OGRwkbGeometryType) (((OGRwkbGeometryType)-1)*(((((OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
6992
7013
|
}
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7014
|
+
}
|
|
7015
|
+
break;
|
|
7016
|
+
case 2:
|
|
7017
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 1 * PyLong_SHIFT)) {
|
|
7018
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7019
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7020
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 2 * PyLong_SHIFT)) {
|
|
7021
|
+
return (OGRwkbGeometryType) ((((((OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
7001
7022
|
}
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7023
|
+
}
|
|
7024
|
+
break;
|
|
7025
|
+
case -3:
|
|
7026
|
+
if ((8 * sizeof(OGRwkbGeometryType) - 1 > 2 * PyLong_SHIFT)) {
|
|
7027
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7028
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7029
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 3 * PyLong_SHIFT)) {
|
|
7030
|
+
return (OGRwkbGeometryType) (((OGRwkbGeometryType)-1)*(((((((OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
7010
7031
|
}
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7032
|
+
}
|
|
7033
|
+
break;
|
|
7034
|
+
case 3:
|
|
7035
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 2 * PyLong_SHIFT)) {
|
|
7036
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7037
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7038
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 3 * PyLong_SHIFT)) {
|
|
7039
|
+
return (OGRwkbGeometryType) ((((((((OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
7019
7040
|
}
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7041
|
+
}
|
|
7042
|
+
break;
|
|
7043
|
+
case -4:
|
|
7044
|
+
if ((8 * sizeof(OGRwkbGeometryType) - 1 > 3 * PyLong_SHIFT)) {
|
|
7045
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7046
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7047
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 4 * PyLong_SHIFT)) {
|
|
7048
|
+
return (OGRwkbGeometryType) (((OGRwkbGeometryType)-1)*(((((((((OGRwkbGeometryType)digits[3]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
7028
7049
|
}
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7050
|
+
}
|
|
7051
|
+
break;
|
|
7052
|
+
case 4:
|
|
7053
|
+
if ((8 * sizeof(OGRwkbGeometryType) > 3 * PyLong_SHIFT)) {
|
|
7054
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7055
|
+
__PYX_VERIFY_RETURN_INT(OGRwkbGeometryType, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7056
|
+
} else if ((8 * sizeof(OGRwkbGeometryType) - 1 > 4 * PyLong_SHIFT)) {
|
|
7057
|
+
return (OGRwkbGeometryType) ((((((((((OGRwkbGeometryType)digits[3]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[2]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[1]) << PyLong_SHIFT) | (OGRwkbGeometryType)digits[0])));
|
|
7037
7058
|
}
|
|
7038
|
-
|
|
7039
|
-
|
|
7059
|
+
}
|
|
7060
|
+
break;
|
|
7040
7061
|
}
|
|
7062
|
+
}
|
|
7041
7063
|
#endif
|
|
7042
|
-
|
|
7043
|
-
|
|
7064
|
+
if ((sizeof(OGRwkbGeometryType) <= sizeof(long))) {
|
|
7065
|
+
__PYX_VERIFY_RETURN_INT_EXC(OGRwkbGeometryType, long, PyLong_AsLong(x))
|
|
7044
7066
|
#ifdef HAVE_LONG_LONG
|
|
7045
|
-
|
|
7046
|
-
|
|
7067
|
+
} else if ((sizeof(OGRwkbGeometryType) <= sizeof(PY_LONG_LONG))) {
|
|
7068
|
+
__PYX_VERIFY_RETURN_INT_EXC(OGRwkbGeometryType, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
7047
7069
|
#endif
|
|
7048
|
-
}
|
|
7049
7070
|
}
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
return (OGRwkbGeometryType) -1;
|
|
7053
|
-
} else {
|
|
7071
|
+
}
|
|
7072
|
+
{
|
|
7054
7073
|
OGRwkbGeometryType val;
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7074
|
+
int ret = -1;
|
|
7075
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
7076
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
7077
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
7078
|
+
if (unlikely(bytes_copied == -1)) {
|
|
7079
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
7080
|
+
goto raise_overflow;
|
|
7081
|
+
} else {
|
|
7082
|
+
ret = 0;
|
|
7083
|
+
}
|
|
7084
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7085
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7086
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
7087
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
7088
|
+
bytes, sizeof(val),
|
|
7089
|
+
is_little, !is_unsigned);
|
|
7090
|
+
#else
|
|
7091
|
+
PyErr_SetString(PyExc_RuntimeError,
|
|
7092
|
+
"_PyLong_AsByteArray() or PyLong_AsNativeBytes() not available, cannot convert large enums");
|
|
7093
|
+
val = (OGRwkbGeometryType) -1;
|
|
7094
|
+
#endif
|
|
7095
|
+
if (unlikely(ret))
|
|
7096
|
+
return (OGRwkbGeometryType) -1;
|
|
7059
7097
|
return val;
|
|
7060
7098
|
}
|
|
7061
7099
|
raise_overflow:
|
|
@@ -7115,12 +7153,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
|
|
|
7115
7153
|
}
|
|
7116
7154
|
}
|
|
7117
7155
|
{
|
|
7118
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7119
7156
|
unsigned char *bytes = (unsigned char *)&value;
|
|
7120
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
7157
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
7158
|
+
if (is_unsigned) {
|
|
7159
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
7160
|
+
} else {
|
|
7161
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
7162
|
+
}
|
|
7163
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
7164
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7121
7165
|
return _PyLong_FromByteArray(bytes, sizeof(long),
|
|
7122
7166
|
little, !is_unsigned);
|
|
7123
7167
|
#else
|
|
7168
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
7124
7169
|
PyObject *from_bytes, *result = NULL;
|
|
7125
7170
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
7126
7171
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -7170,245 +7215,239 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
|
|
|
7170
7215
|
}
|
|
7171
7216
|
return (long) val;
|
|
7172
7217
|
}
|
|
7173
|
-
}
|
|
7218
|
+
}
|
|
7174
7219
|
#endif
|
|
7175
|
-
if (
|
|
7176
|
-
|
|
7220
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
7221
|
+
long val;
|
|
7222
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
7223
|
+
if (!tmp) return (long) -1;
|
|
7224
|
+
val = __Pyx_PyInt_As_long(tmp);
|
|
7225
|
+
Py_DECREF(tmp);
|
|
7226
|
+
return val;
|
|
7227
|
+
}
|
|
7228
|
+
if (is_unsigned) {
|
|
7177
7229
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
}
|
|
7230
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
7231
|
+
goto raise_neg_overflow;
|
|
7232
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
7233
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
7234
|
+
} else {
|
|
7235
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7236
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7237
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
7238
|
+
case 2:
|
|
7239
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
7240
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7241
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7242
|
+
} else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
|
|
7243
|
+
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
7193
7244
|
}
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7245
|
+
}
|
|
7246
|
+
break;
|
|
7247
|
+
case 3:
|
|
7248
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
7249
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7250
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7251
|
+
} else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
|
|
7252
|
+
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
7202
7253
|
}
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7254
|
+
}
|
|
7255
|
+
break;
|
|
7256
|
+
case 4:
|
|
7257
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
7258
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7259
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7260
|
+
} else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
|
|
7261
|
+
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
7211
7262
|
}
|
|
7212
|
-
|
|
7213
|
-
|
|
7263
|
+
}
|
|
7264
|
+
break;
|
|
7214
7265
|
}
|
|
7266
|
+
}
|
|
7215
7267
|
#endif
|
|
7216
7268
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7269
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
7270
|
+
goto raise_neg_overflow;
|
|
7271
|
+
}
|
|
7220
7272
|
#else
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7273
|
+
{
|
|
7274
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7275
|
+
if (unlikely(result < 0))
|
|
7276
|
+
return (long) -1;
|
|
7277
|
+
if (unlikely(result == 1))
|
|
7278
|
+
goto raise_neg_overflow;
|
|
7279
|
+
}
|
|
7228
7280
|
#endif
|
|
7229
|
-
|
|
7230
|
-
|
|
7281
|
+
if ((sizeof(long) <= sizeof(unsigned long))) {
|
|
7282
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
|
|
7231
7283
|
#ifdef HAVE_LONG_LONG
|
|
7232
|
-
|
|
7233
|
-
|
|
7284
|
+
} else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
7285
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
7234
7286
|
#endif
|
|
7235
|
-
|
|
7236
|
-
|
|
7287
|
+
}
|
|
7288
|
+
} else {
|
|
7237
7289
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
}
|
|
7290
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
7291
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
7292
|
+
} else {
|
|
7293
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7294
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7295
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
7296
|
+
case -2:
|
|
7297
|
+
if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
|
|
7298
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7299
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7300
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
7301
|
+
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7251
7302
|
}
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7303
|
+
}
|
|
7304
|
+
break;
|
|
7305
|
+
case 2:
|
|
7306
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
7307
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7308
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7309
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
7310
|
+
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7260
7311
|
}
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7312
|
+
}
|
|
7313
|
+
break;
|
|
7314
|
+
case -3:
|
|
7315
|
+
if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
7316
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7317
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7318
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
7319
|
+
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7269
7320
|
}
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7321
|
+
}
|
|
7322
|
+
break;
|
|
7323
|
+
case 3:
|
|
7324
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
7325
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7326
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7327
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
7328
|
+
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7278
7329
|
}
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7330
|
+
}
|
|
7331
|
+
break;
|
|
7332
|
+
case -4:
|
|
7333
|
+
if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
7334
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7335
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7336
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
7337
|
+
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7287
7338
|
}
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7339
|
+
}
|
|
7340
|
+
break;
|
|
7341
|
+
case 4:
|
|
7342
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
7343
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7344
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7345
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
7346
|
+
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
7296
7347
|
}
|
|
7297
|
-
|
|
7298
|
-
|
|
7348
|
+
}
|
|
7349
|
+
break;
|
|
7299
7350
|
}
|
|
7351
|
+
}
|
|
7300
7352
|
#endif
|
|
7301
|
-
|
|
7302
|
-
|
|
7353
|
+
if ((sizeof(long) <= sizeof(long))) {
|
|
7354
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
|
|
7303
7355
|
#ifdef HAVE_LONG_LONG
|
|
7304
|
-
|
|
7305
|
-
|
|
7356
|
+
} else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
|
|
7357
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
7306
7358
|
#endif
|
|
7307
|
-
|
|
7359
|
+
}
|
|
7360
|
+
}
|
|
7361
|
+
{
|
|
7362
|
+
long val;
|
|
7363
|
+
int ret = -1;
|
|
7364
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
7365
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
7366
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
7367
|
+
if (unlikely(bytes_copied == -1)) {
|
|
7368
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
7369
|
+
goto raise_overflow;
|
|
7370
|
+
} else {
|
|
7371
|
+
ret = 0;
|
|
7372
|
+
}
|
|
7373
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7374
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7375
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
7376
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
7377
|
+
bytes, sizeof(val),
|
|
7378
|
+
is_little, !is_unsigned);
|
|
7379
|
+
#else
|
|
7380
|
+
PyObject *v;
|
|
7381
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7382
|
+
int bits, remaining_bits, is_negative = 0;
|
|
7383
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7384
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
7385
|
+
v = __Pyx_NewRef(x);
|
|
7386
|
+
} else {
|
|
7387
|
+
v = PyNumber_Long(x);
|
|
7388
|
+
if (unlikely(!v)) return (long) -1;
|
|
7389
|
+
assert(PyLong_CheckExact(v));
|
|
7308
7390
|
}
|
|
7309
7391
|
{
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
#if PY_MAJOR_VERSION < 3
|
|
7313
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
7314
|
-
PyObject *tmp = v;
|
|
7315
|
-
v = PyNumber_Long(tmp);
|
|
7316
|
-
Py_DECREF(tmp);
|
|
7317
|
-
}
|
|
7318
|
-
#endif
|
|
7319
|
-
if (likely(v)) {
|
|
7320
|
-
int ret = -1;
|
|
7321
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7322
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7323
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
7324
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
7325
|
-
bytes, sizeof(val),
|
|
7326
|
-
is_little, !is_unsigned);
|
|
7327
|
-
#else
|
|
7328
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7329
|
-
int bits, remaining_bits, is_negative = 0;
|
|
7330
|
-
long idigit;
|
|
7331
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7332
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
7333
|
-
PyObject *tmp = v;
|
|
7334
|
-
v = PyNumber_Long(v);
|
|
7335
|
-
assert(PyLong_CheckExact(v));
|
|
7336
|
-
Py_DECREF(tmp);
|
|
7337
|
-
if (unlikely(!v)) return (long) -1;
|
|
7338
|
-
}
|
|
7339
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7340
|
-
if (Py_SIZE(x) == 0)
|
|
7341
|
-
return (long) 0;
|
|
7342
|
-
is_negative = Py_SIZE(x) < 0;
|
|
7343
|
-
#else
|
|
7344
|
-
{
|
|
7345
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7346
|
-
if (unlikely(result < 0))
|
|
7347
|
-
return (long) -1;
|
|
7348
|
-
is_negative = result == 1;
|
|
7349
|
-
}
|
|
7350
|
-
#endif
|
|
7351
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
7352
|
-
goto raise_neg_overflow;
|
|
7353
|
-
} else if (is_negative) {
|
|
7354
|
-
stepval = PyNumber_Invert(v);
|
|
7355
|
-
if (unlikely(!stepval))
|
|
7356
|
-
return (long) -1;
|
|
7357
|
-
} else {
|
|
7358
|
-
stepval = __Pyx_NewRef(v);
|
|
7359
|
-
}
|
|
7360
|
-
val = (long) 0;
|
|
7361
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
7362
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
7363
|
-
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
7364
|
-
PyObject *tmp, *digit;
|
|
7365
|
-
digit = PyNumber_And(stepval, mask);
|
|
7366
|
-
if (unlikely(!digit)) goto done;
|
|
7367
|
-
idigit = PyLong_AsLong(digit);
|
|
7368
|
-
Py_DECREF(digit);
|
|
7369
|
-
if (unlikely(idigit < 0)) goto done;
|
|
7370
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
7371
|
-
if (unlikely(!tmp)) goto done;
|
|
7372
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
7373
|
-
val |= ((long) idigit) << bits;
|
|
7374
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7375
|
-
if (Py_SIZE(stepval) == 0)
|
|
7376
|
-
goto unpacking_done;
|
|
7377
|
-
#endif
|
|
7378
|
-
}
|
|
7379
|
-
idigit = PyLong_AsLong(stepval);
|
|
7380
|
-
if (unlikely(idigit < 0)) goto done;
|
|
7381
|
-
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
7382
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
7383
|
-
goto raise_overflow;
|
|
7384
|
-
val |= ((long) idigit) << bits;
|
|
7385
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7386
|
-
unpacking_done:
|
|
7387
|
-
#endif
|
|
7388
|
-
if (!is_unsigned) {
|
|
7389
|
-
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
7390
|
-
goto raise_overflow;
|
|
7391
|
-
if (is_negative)
|
|
7392
|
-
val = ~val;
|
|
7393
|
-
}
|
|
7394
|
-
ret = 0;
|
|
7395
|
-
done:
|
|
7396
|
-
Py_XDECREF(shift);
|
|
7397
|
-
Py_XDECREF(mask);
|
|
7398
|
-
Py_XDECREF(stepval);
|
|
7399
|
-
#endif
|
|
7392
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
7393
|
+
if (unlikely(result < 0)) {
|
|
7400
7394
|
Py_DECREF(v);
|
|
7401
|
-
|
|
7402
|
-
return val;
|
|
7395
|
+
return (long) -1;
|
|
7403
7396
|
}
|
|
7404
|
-
|
|
7397
|
+
is_negative = result == 1;
|
|
7405
7398
|
}
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7399
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
7400
|
+
Py_DECREF(v);
|
|
7401
|
+
goto raise_neg_overflow;
|
|
7402
|
+
} else if (is_negative) {
|
|
7403
|
+
stepval = PyNumber_Invert(v);
|
|
7404
|
+
Py_DECREF(v);
|
|
7405
|
+
if (unlikely(!stepval))
|
|
7406
|
+
return (long) -1;
|
|
7407
|
+
} else {
|
|
7408
|
+
stepval = v;
|
|
7409
|
+
}
|
|
7410
|
+
v = NULL;
|
|
7411
|
+
val = (long) 0;
|
|
7412
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
7413
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
7414
|
+
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
7415
|
+
PyObject *tmp, *digit;
|
|
7416
|
+
long idigit;
|
|
7417
|
+
digit = PyNumber_And(stepval, mask);
|
|
7418
|
+
if (unlikely(!digit)) goto done;
|
|
7419
|
+
idigit = PyLong_AsLong(digit);
|
|
7420
|
+
Py_DECREF(digit);
|
|
7421
|
+
if (unlikely(idigit < 0)) goto done;
|
|
7422
|
+
val |= ((long) idigit) << bits;
|
|
7423
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
7424
|
+
if (unlikely(!tmp)) goto done;
|
|
7425
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
7426
|
+
}
|
|
7427
|
+
Py_DECREF(shift); shift = NULL;
|
|
7428
|
+
Py_DECREF(mask); mask = NULL;
|
|
7429
|
+
{
|
|
7430
|
+
long idigit = PyLong_AsLong(stepval);
|
|
7431
|
+
if (unlikely(idigit < 0)) goto done;
|
|
7432
|
+
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
7433
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
7434
|
+
goto raise_overflow;
|
|
7435
|
+
val |= ((long) idigit) << bits;
|
|
7436
|
+
}
|
|
7437
|
+
if (!is_unsigned) {
|
|
7438
|
+
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
7439
|
+
goto raise_overflow;
|
|
7440
|
+
if (is_negative)
|
|
7441
|
+
val = ~val;
|
|
7442
|
+
}
|
|
7443
|
+
ret = 0;
|
|
7444
|
+
done:
|
|
7445
|
+
Py_XDECREF(shift);
|
|
7446
|
+
Py_XDECREF(mask);
|
|
7447
|
+
Py_XDECREF(stepval);
|
|
7448
|
+
#endif
|
|
7449
|
+
if (unlikely(ret))
|
|
7450
|
+
return (long) -1;
|
|
7412
7451
|
return val;
|
|
7413
7452
|
}
|
|
7414
7453
|
raise_overflow:
|
|
@@ -7443,245 +7482,239 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
|
|
|
7443
7482
|
}
|
|
7444
7483
|
return (int) val;
|
|
7445
7484
|
}
|
|
7446
|
-
}
|
|
7485
|
+
}
|
|
7447
7486
|
#endif
|
|
7448
|
-
if (
|
|
7449
|
-
|
|
7487
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
7488
|
+
int val;
|
|
7489
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
7490
|
+
if (!tmp) return (int) -1;
|
|
7491
|
+
val = __Pyx_PyInt_As_int(tmp);
|
|
7492
|
+
Py_DECREF(tmp);
|
|
7493
|
+
return val;
|
|
7494
|
+
}
|
|
7495
|
+
if (is_unsigned) {
|
|
7450
7496
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
}
|
|
7497
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
7498
|
+
goto raise_neg_overflow;
|
|
7499
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
7500
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
7501
|
+
} else {
|
|
7502
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7503
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7504
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
7505
|
+
case 2:
|
|
7506
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
7507
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7508
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7509
|
+
} else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
|
|
7510
|
+
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7466
7511
|
}
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7512
|
+
}
|
|
7513
|
+
break;
|
|
7514
|
+
case 3:
|
|
7515
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
7516
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7517
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7518
|
+
} else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
|
|
7519
|
+
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7475
7520
|
}
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7521
|
+
}
|
|
7522
|
+
break;
|
|
7523
|
+
case 4:
|
|
7524
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
7525
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7526
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7527
|
+
} else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
|
|
7528
|
+
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
7484
7529
|
}
|
|
7485
|
-
|
|
7486
|
-
|
|
7530
|
+
}
|
|
7531
|
+
break;
|
|
7487
7532
|
}
|
|
7533
|
+
}
|
|
7488
7534
|
#endif
|
|
7489
7535
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7536
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
7537
|
+
goto raise_neg_overflow;
|
|
7538
|
+
}
|
|
7493
7539
|
#else
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7540
|
+
{
|
|
7541
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7542
|
+
if (unlikely(result < 0))
|
|
7543
|
+
return (int) -1;
|
|
7544
|
+
if (unlikely(result == 1))
|
|
7545
|
+
goto raise_neg_overflow;
|
|
7546
|
+
}
|
|
7501
7547
|
#endif
|
|
7502
|
-
|
|
7503
|
-
|
|
7548
|
+
if ((sizeof(int) <= sizeof(unsigned long))) {
|
|
7549
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
|
|
7504
7550
|
#ifdef HAVE_LONG_LONG
|
|
7505
|
-
|
|
7506
|
-
|
|
7551
|
+
} else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
7552
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
7507
7553
|
#endif
|
|
7508
|
-
|
|
7509
|
-
|
|
7554
|
+
}
|
|
7555
|
+
} else {
|
|
7510
7556
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
}
|
|
7557
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
7558
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
7559
|
+
} else {
|
|
7560
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
7561
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
7562
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
7563
|
+
case -2:
|
|
7564
|
+
if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
|
|
7565
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7566
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7567
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7568
|
+
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7524
7569
|
}
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7570
|
+
}
|
|
7571
|
+
break;
|
|
7572
|
+
case 2:
|
|
7573
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
7574
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
7575
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7576
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7577
|
+
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7533
7578
|
}
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7579
|
+
}
|
|
7580
|
+
break;
|
|
7581
|
+
case -3:
|
|
7582
|
+
if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
7583
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7584
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7585
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7586
|
+
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7542
7587
|
}
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7588
|
+
}
|
|
7589
|
+
break;
|
|
7590
|
+
case 3:
|
|
7591
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
7592
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
7593
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7594
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7595
|
+
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7551
7596
|
}
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7597
|
+
}
|
|
7598
|
+
break;
|
|
7599
|
+
case -4:
|
|
7600
|
+
if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
7601
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7602
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7603
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
7604
|
+
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7560
7605
|
}
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7606
|
+
}
|
|
7607
|
+
break;
|
|
7608
|
+
case 4:
|
|
7609
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
7610
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
7611
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
7612
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
7613
|
+
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
7569
7614
|
}
|
|
7570
|
-
|
|
7571
|
-
|
|
7615
|
+
}
|
|
7616
|
+
break;
|
|
7572
7617
|
}
|
|
7618
|
+
}
|
|
7573
7619
|
#endif
|
|
7574
|
-
|
|
7575
|
-
|
|
7620
|
+
if ((sizeof(int) <= sizeof(long))) {
|
|
7621
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
|
|
7576
7622
|
#ifdef HAVE_LONG_LONG
|
|
7577
|
-
|
|
7578
|
-
|
|
7623
|
+
} else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
|
|
7624
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
7579
7625
|
#endif
|
|
7580
|
-
|
|
7626
|
+
}
|
|
7627
|
+
}
|
|
7628
|
+
{
|
|
7629
|
+
int val;
|
|
7630
|
+
int ret = -1;
|
|
7631
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
7632
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
7633
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
7634
|
+
if (unlikely(bytes_copied == -1)) {
|
|
7635
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
7636
|
+
goto raise_overflow;
|
|
7637
|
+
} else {
|
|
7638
|
+
ret = 0;
|
|
7639
|
+
}
|
|
7640
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7641
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7642
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
7643
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
7644
|
+
bytes, sizeof(val),
|
|
7645
|
+
is_little, !is_unsigned);
|
|
7646
|
+
#else
|
|
7647
|
+
PyObject *v;
|
|
7648
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7649
|
+
int bits, remaining_bits, is_negative = 0;
|
|
7650
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7651
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
7652
|
+
v = __Pyx_NewRef(x);
|
|
7653
|
+
} else {
|
|
7654
|
+
v = PyNumber_Long(x);
|
|
7655
|
+
if (unlikely(!v)) return (int) -1;
|
|
7656
|
+
assert(PyLong_CheckExact(v));
|
|
7581
7657
|
}
|
|
7582
7658
|
{
|
|
7583
|
-
int
|
|
7584
|
-
|
|
7585
|
-
#if PY_MAJOR_VERSION < 3
|
|
7586
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
7587
|
-
PyObject *tmp = v;
|
|
7588
|
-
v = PyNumber_Long(tmp);
|
|
7589
|
-
Py_DECREF(tmp);
|
|
7590
|
-
}
|
|
7591
|
-
#endif
|
|
7592
|
-
if (likely(v)) {
|
|
7593
|
-
int ret = -1;
|
|
7594
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
7595
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
7596
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
7597
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
7598
|
-
bytes, sizeof(val),
|
|
7599
|
-
is_little, !is_unsigned);
|
|
7600
|
-
#else
|
|
7601
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
7602
|
-
int bits, remaining_bits, is_negative = 0;
|
|
7603
|
-
long idigit;
|
|
7604
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
7605
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
7606
|
-
PyObject *tmp = v;
|
|
7607
|
-
v = PyNumber_Long(v);
|
|
7608
|
-
assert(PyLong_CheckExact(v));
|
|
7609
|
-
Py_DECREF(tmp);
|
|
7610
|
-
if (unlikely(!v)) return (int) -1;
|
|
7611
|
-
}
|
|
7612
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7613
|
-
if (Py_SIZE(x) == 0)
|
|
7614
|
-
return (int) 0;
|
|
7615
|
-
is_negative = Py_SIZE(x) < 0;
|
|
7616
|
-
#else
|
|
7617
|
-
{
|
|
7618
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
7619
|
-
if (unlikely(result < 0))
|
|
7620
|
-
return (int) -1;
|
|
7621
|
-
is_negative = result == 1;
|
|
7622
|
-
}
|
|
7623
|
-
#endif
|
|
7624
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
7625
|
-
goto raise_neg_overflow;
|
|
7626
|
-
} else if (is_negative) {
|
|
7627
|
-
stepval = PyNumber_Invert(v);
|
|
7628
|
-
if (unlikely(!stepval))
|
|
7629
|
-
return (int) -1;
|
|
7630
|
-
} else {
|
|
7631
|
-
stepval = __Pyx_NewRef(v);
|
|
7632
|
-
}
|
|
7633
|
-
val = (int) 0;
|
|
7634
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
7635
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
7636
|
-
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
7637
|
-
PyObject *tmp, *digit;
|
|
7638
|
-
digit = PyNumber_And(stepval, mask);
|
|
7639
|
-
if (unlikely(!digit)) goto done;
|
|
7640
|
-
idigit = PyLong_AsLong(digit);
|
|
7641
|
-
Py_DECREF(digit);
|
|
7642
|
-
if (unlikely(idigit < 0)) goto done;
|
|
7643
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
7644
|
-
if (unlikely(!tmp)) goto done;
|
|
7645
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
7646
|
-
val |= ((int) idigit) << bits;
|
|
7647
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7648
|
-
if (Py_SIZE(stepval) == 0)
|
|
7649
|
-
goto unpacking_done;
|
|
7650
|
-
#endif
|
|
7651
|
-
}
|
|
7652
|
-
idigit = PyLong_AsLong(stepval);
|
|
7653
|
-
if (unlikely(idigit < 0)) goto done;
|
|
7654
|
-
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
7655
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
7656
|
-
goto raise_overflow;
|
|
7657
|
-
val |= ((int) idigit) << bits;
|
|
7658
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
7659
|
-
unpacking_done:
|
|
7660
|
-
#endif
|
|
7661
|
-
if (!is_unsigned) {
|
|
7662
|
-
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
7663
|
-
goto raise_overflow;
|
|
7664
|
-
if (is_negative)
|
|
7665
|
-
val = ~val;
|
|
7666
|
-
}
|
|
7667
|
-
ret = 0;
|
|
7668
|
-
done:
|
|
7669
|
-
Py_XDECREF(shift);
|
|
7670
|
-
Py_XDECREF(mask);
|
|
7671
|
-
Py_XDECREF(stepval);
|
|
7672
|
-
#endif
|
|
7659
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
7660
|
+
if (unlikely(result < 0)) {
|
|
7673
7661
|
Py_DECREF(v);
|
|
7674
|
-
|
|
7675
|
-
return val;
|
|
7662
|
+
return (int) -1;
|
|
7676
7663
|
}
|
|
7677
|
-
|
|
7664
|
+
is_negative = result == 1;
|
|
7678
7665
|
}
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7666
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
7667
|
+
Py_DECREF(v);
|
|
7668
|
+
goto raise_neg_overflow;
|
|
7669
|
+
} else if (is_negative) {
|
|
7670
|
+
stepval = PyNumber_Invert(v);
|
|
7671
|
+
Py_DECREF(v);
|
|
7672
|
+
if (unlikely(!stepval))
|
|
7673
|
+
return (int) -1;
|
|
7674
|
+
} else {
|
|
7675
|
+
stepval = v;
|
|
7676
|
+
}
|
|
7677
|
+
v = NULL;
|
|
7678
|
+
val = (int) 0;
|
|
7679
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
7680
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
7681
|
+
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
7682
|
+
PyObject *tmp, *digit;
|
|
7683
|
+
long idigit;
|
|
7684
|
+
digit = PyNumber_And(stepval, mask);
|
|
7685
|
+
if (unlikely(!digit)) goto done;
|
|
7686
|
+
idigit = PyLong_AsLong(digit);
|
|
7687
|
+
Py_DECREF(digit);
|
|
7688
|
+
if (unlikely(idigit < 0)) goto done;
|
|
7689
|
+
val |= ((int) idigit) << bits;
|
|
7690
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
7691
|
+
if (unlikely(!tmp)) goto done;
|
|
7692
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
7693
|
+
}
|
|
7694
|
+
Py_DECREF(shift); shift = NULL;
|
|
7695
|
+
Py_DECREF(mask); mask = NULL;
|
|
7696
|
+
{
|
|
7697
|
+
long idigit = PyLong_AsLong(stepval);
|
|
7698
|
+
if (unlikely(idigit < 0)) goto done;
|
|
7699
|
+
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
7700
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
7701
|
+
goto raise_overflow;
|
|
7702
|
+
val |= ((int) idigit) << bits;
|
|
7703
|
+
}
|
|
7704
|
+
if (!is_unsigned) {
|
|
7705
|
+
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
7706
|
+
goto raise_overflow;
|
|
7707
|
+
if (is_negative)
|
|
7708
|
+
val = ~val;
|
|
7709
|
+
}
|
|
7710
|
+
ret = 0;
|
|
7711
|
+
done:
|
|
7712
|
+
Py_XDECREF(shift);
|
|
7713
|
+
Py_XDECREF(mask);
|
|
7714
|
+
Py_XDECREF(stepval);
|
|
7715
|
+
#endif
|
|
7716
|
+
if (unlikely(ret))
|
|
7717
|
+
return (int) -1;
|
|
7685
7718
|
return val;
|
|
7686
7719
|
}
|
|
7687
7720
|
raise_overflow:
|
|
@@ -7775,9 +7808,9 @@ bad:
|
|
|
7775
7808
|
}
|
|
7776
7809
|
|
|
7777
7810
|
/* FunctionImport */
|
|
7778
|
-
#ifndef
|
|
7779
|
-
#define
|
|
7780
|
-
static int
|
|
7811
|
+
#ifndef __PYX_HAVE_RT_ImportFunction_3_0_11
|
|
7812
|
+
#define __PYX_HAVE_RT_ImportFunction_3_0_11
|
|
7813
|
+
static int __Pyx_ImportFunction_3_0_11(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
|
7781
7814
|
PyObject *d = 0;
|
|
7782
7815
|
PyObject *cobj = 0;
|
|
7783
7816
|
union {
|