diff --git a/build.py b/build.py index 9b26b89..085fc13 100644 --- a/build.py +++ b/build.py @@ -50,7 +50,6 @@ include_dirs=[str(PurePath(__file__).parent / "cbflib" / "include")], define_macros=[ ("CBF_NO_REGEX", None), - ("SWIG_PYTHON_STRICT_BYTE_CHAR", None), ], ) ] diff --git a/newsfragments/2.feature b/newsfragments/2.feature new file mode 100644 index 0000000..c1bda97 --- /dev/null +++ b/newsfragments/2.feature @@ -0,0 +1 @@ +Fix byte/str handling for Python 3. Methods that deal with image or other data now take/return bytes, and all others have been left as str. diff --git a/pycbf_wrap.c b/pycbf_wrap.c index 0129f01..d4098a2 100644 --- a/pycbf_wrap.c +++ b/pycbf_wrap.c @@ -10610,7 +10610,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_3d_image_as_string(PyObject *SW } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -10696,7 +10700,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_3d_image_fs_as_string(PyObject } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -10782,7 +10790,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_3d_image_sf_as_string(PyObject } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -12260,7 +12272,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_image_as_string(PyObject *SWIGU } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -12338,7 +12354,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_image_fs_as_string(PyObject *SW } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -12416,7 +12436,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_image_sf_as_string(PyObject *SW } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -12626,7 +12650,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_integerarray_as_string(PyObject } resultobj = SWIG_Py_Void(); if (*arg2) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg2,*arg3)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg2,*arg3)); +#endif free(*arg2); } return resultobj; @@ -13744,7 +13772,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_3d_image_as_string(PyObjec } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -13822,7 +13854,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_3d_image_fs_as_string(PyOb } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -13900,7 +13936,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_3d_image_sf_as_string(PyOb } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -13970,7 +14010,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_image_as_string(PyObject * } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -14040,7 +14084,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_image_fs_as_string(PyObjec } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -14110,7 +14158,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_real_image_sf_as_string(PyObjec } resultobj = SWIG_Py_Void(); if (*arg3) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg3,*arg4)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg3,*arg4)); +#endif free(*arg3); } return resultobj; @@ -14149,7 +14201,11 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_get_realarray_as_string(PyObject *S } resultobj = SWIG_Py_Void(); if (*arg2) { +#if PY_VERSION_HEX >= 0x03000000 + resultobj = SWIG_Python_AppendOutput(resultobj, PyBytes_FromStringAndSize(*arg2,*arg3)); +#else resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtrAndSize(*arg2,*arg3)); +#endif free(*arg2); } return resultobj; @@ -16802,8 +16858,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image(PyObject *SWIGUNUSEDPA int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -16832,12 +16887,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image(PyObject *SWIGUNUSEDPA SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_3d_image" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_3d_image" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_3d_image" "', argument " "6"" of type '" "int""'"); @@ -16873,10 +16928,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image(PyObject *SWIGUNUSEDPA } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -16901,8 +16954,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_fs(PyObject *SWIGUNUSE int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -16931,12 +16983,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_fs(PyObject *SWIGUNUSE SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_3d_image_fs" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_3d_image_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_3d_image_fs" "', argument " "6"" of type '" "int""'"); @@ -16972,10 +17024,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_fs(PyObject *SWIGUNUSE } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -17000,8 +17050,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_sf(PyObject *SWIGUNUSE int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -17030,12 +17079,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_sf(PyObject *SWIGUNUSE SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_3d_image_sf" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_3d_image_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_3d_image_sf" "', argument " "6"" of type '" "int""'"); @@ -17071,10 +17120,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_3d_image_sf(PyObject *SWIGUNUSE } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -17699,8 +17746,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image(PyObject *SWIGUNUSEDPARM( int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -17727,12 +17773,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image(PyObject *SWIGUNUSEDPARM( SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_image" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_image" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_image" "', argument " "6"" of type '" "int""'"); @@ -17763,10 +17809,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image(PyObject *SWIGUNUSEDPARM( } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -17790,8 +17834,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_fs(PyObject *SWIGUNUSEDPA int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -17818,12 +17861,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_fs(PyObject *SWIGUNUSEDPA SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_image_fs" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_image_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_image_fs" "', argument " "6"" of type '" "int""'"); @@ -17854,10 +17897,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_fs(PyObject *SWIGUNUSEDPA } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -17881,8 +17922,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_sf(PyObject *SWIGUNUSEDPA int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -17909,12 +17949,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_sf(PyObject *SWIGUNUSEDPA SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_image_sf" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_image_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_image_sf" "', argument " "6"" of type '" "int""'"); @@ -17945,10 +17985,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_image_sf(PyObject *SWIGUNUSEDPA } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -17971,8 +18009,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray(PyObject *SWIGUNUS int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -17997,12 +18034,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray(PyObject *SWIGUNUS SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_integerarray" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_integerarray" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_integerarray" "', argument " "6"" of type '" "int""'"); @@ -18028,10 +18065,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray(PyObject *SWIGUNUS } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -18060,8 +18095,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims(PyObject *SW int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -18098,12 +18132,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims(PyObject *SW SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_integerarray_wdims" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_integerarray_wdims" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_integerarray_wdims" "', argument " "6"" of type '" "int""'"); @@ -18155,11 +18189,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims(PyObject *SW } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return NULL; } @@ -18189,8 +18221,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_fs(PyObject int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -18227,12 +18258,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_fs(PyObject SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_integerarray_wdims_fs" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_integerarray_wdims_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_integerarray_wdims_fs" "', argument " "6"" of type '" "int""'"); @@ -18284,11 +18315,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_fs(PyObject } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return NULL; } @@ -18318,8 +18347,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_sf(PyObject int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -18356,12 +18384,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_sf(PyObject SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_integerarray_wdims_sf" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_integerarray_wdims_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_integerarray_wdims_sf" "', argument " "6"" of type '" "int""'"); @@ -18413,11 +18441,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_integerarray_wdims_sf(PyObject } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc9 == SWIG_NEWOBJ) free((char*)buf9); return NULL; } @@ -18866,8 +18892,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image(PyObject *SWIGUNU int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -18894,12 +18919,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image(PyObject *SWIGUNU SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_3d_image" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_3d_image" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_3d_image" "', argument " "6"" of type '" "int""'"); @@ -18930,10 +18955,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image(PyObject *SWIGUNU } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -18957,8 +18980,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_fs(PyObject *SWIG int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -18985,12 +19007,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_fs(PyObject *SWIG SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_3d_image_fs" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_3d_image_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_3d_image_fs" "', argument " "6"" of type '" "int""'"); @@ -19021,10 +19043,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_fs(PyObject *SWIG } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19048,8 +19068,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_sf(PyObject *SWIG int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19076,12 +19095,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_sf(PyObject *SWIG SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_3d_image_sf" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_3d_image_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_3d_image_sf" "', argument " "6"" of type '" "int""'"); @@ -19112,10 +19131,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_3d_image_sf(PyObject *SWIG } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19138,8 +19155,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image(PyObject *SWIGUNUSED int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19164,12 +19180,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image(PyObject *SWIGUNUSED SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_image" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_image" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_image" "', argument " "6"" of type '" "int""'"); @@ -19195,10 +19211,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image(PyObject *SWIGUNUSED } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19221,8 +19235,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_fs(PyObject *SWIGUNU int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19247,12 +19260,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_fs(PyObject *SWIGUNU SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_image_fs" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_image_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_image_fs" "', argument " "6"" of type '" "int""'"); @@ -19278,10 +19291,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_fs(PyObject *SWIGUNU } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19304,8 +19315,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_sf(PyObject *SWIGUNU int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19330,12 +19340,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_sf(PyObject *SWIGUNU SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_real_image_sf" "', argument " "3"" of type '" "unsigned int""'"); } arg3 = (unsigned int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_real_image_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_real_image_sf" "', argument " "6"" of type '" "int""'"); @@ -19361,10 +19371,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_real_image_sf(PyObject *SWIGUNU } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19386,8 +19394,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray(PyObject *SWIGUNUSEDP int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19410,12 +19417,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray(PyObject *SWIGUNUSEDP SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_realarray" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_realarray" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_realarray" "', argument " "6"" of type '" "int""'"); @@ -19436,10 +19443,8 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray(PyObject *SWIGUNUSEDP } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); return NULL; } @@ -19467,8 +19472,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims(PyObject *SWIGU int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19503,12 +19507,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims(PyObject *SWIGU SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_realarray_wdims" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_realarray_wdims" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_realarray_wdims" "', argument " "6"" of type '" "int""'"); @@ -19555,11 +19559,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims(PyObject *SWIGU } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return NULL; } @@ -19588,8 +19590,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_fs(PyObject *SW int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19624,12 +19625,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_fs(PyObject *SW SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_realarray_wdims_fs" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_realarray_wdims_fs" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_realarray_wdims_fs" "', argument " "6"" of type '" "int""'"); @@ -19676,11 +19677,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_fs(PyObject *SW } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return NULL; } @@ -19709,8 +19708,7 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_sf(PyObject *SW int ecode3 = 0 ; int res4 ; char *buf4 = 0 ; - size_t size4 = 0 ; - int alloc4 = 0 ; + Py_ssize_t size4 = 0 ; int val6 ; int ecode6 = 0 ; int val7 ; @@ -19745,12 +19743,12 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_sf(PyObject *SW SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cbf_handle_struct_set_realarray_wdims_sf" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, &size4, &alloc4); + res4 = PyBytes_AsStringAndSize(swig_obj[3], &buf4, &size4) == -1 ? SWIG_TypeError : SWIG_OK; if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "cbf_handle_struct_set_realarray_wdims_sf" "', argument " "4"" of type '" "char *""'"); - } + } arg4 = (char *)(buf4); - arg5 = (int)(size4 - 1); + arg5 = (int)(size4); ecode6 = SWIG_AsVal_int(swig_obj[4], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "cbf_handle_struct_set_realarray_wdims_sf" "', argument " "6"" of type '" "int""'"); @@ -19797,11 +19795,9 @@ SWIGINTERN PyObject *_wrap_cbf_handle_struct_set_realarray_wdims_sf(PyObject *SW } } resultobj = SWIG_Py_Void(); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return resultobj; fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return NULL; } diff --git a/swig/cbfhandlewrappers.i b/swig/cbfhandlewrappers.i index f2e4bc7..646aa48 100644 --- a/swig/cbfhandlewrappers.i +++ b/swig/cbfhandlewrappers.i @@ -21,6 +21,37 @@ typedef enum } CBF_NODETYPE; +// Tell SWIG to return a string-output-argument as a bytestring +%define %bytestring_output_allocate_size(TYPEMAP, SIZE, RELEASE) + %typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { + $1 = &temp; $2 = &tempn; + } + %typemap(freearg,match="in") (TYPEMAP, SIZE) ""; + %typemap(argout,noblock=1)(TYPEMAP, SIZE) { + if (*$1) { +%#if PY_VERSION_HEX >= 0x03000000 + %append_output(PyBytes_FromStringAndSize(*$1,*$2)); +%#else + %append_output(SWIG_FromCharPtrAndSize(*$1,*$2)); +%#endif + RELEASE; + } + } +%enddef + +// Typemap to read a python bytes object as array data +%typemap(in,noblock=1) + (char *DATASTRING, size_t LENGTH) (int res, char *buf = 0, Py_ssize_t size = 0), + (const char *DATASTRING, size_t LENGTH) (int res, char *buf = 0, Py_ssize_t size = 0) +{ + res = PyBytes_AsStringAndSize($input, &buf, &size) == -1 ? SWIG_TypeError : SWIG_OK; + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(buf, $1_ltype); + $2 = %numeric_cast(size, $2_ltype); +} +%typemap(in) (char *DATASTRING, int LENGTH) = (char *DATASTRING, size_t LENGTH); // Tell SWIG what the object is, so we can build the class @@ -850,7 +881,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_as_string; // Get the length correct @@ -913,7 +944,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_fs_as_string; // Get the length correct @@ -976,7 +1007,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_sf_as_string; // Get the length correct @@ -2241,7 +2272,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_as_string; // Get the length correct @@ -2302,7 +2333,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_fs_as_string; // Get the length correct @@ -2363,7 +2394,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_fs_as_string; // Get the length correct @@ -2533,7 +2564,7 @@ Returns an error code on failure or 0 for success. SEE ALSO // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_integerarray_as_string; // Get the length correct @@ -3254,7 +3285,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_as_string; // Get the length correct @@ -3316,7 +3347,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_fs_as_string; // Get the length correct @@ -3378,7 +3409,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_sf_as_string; // Get the length correct @@ -3439,7 +3470,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_as_string; // Get the length correct @@ -3501,7 +3532,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_fs_as_string; // Get the length correct @@ -3563,7 +3594,7 @@ ndimslow and ndimmid should be the // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_sf_as_string; // Get the length correct @@ -3637,7 +3668,7 @@ Returns an error code on failure or 0 for success. SEE ALSO // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_realarray_as_string; // Get the length correct @@ -5745,7 +5776,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image(unsigned int element_number, unsigned int compression, @@ -5834,7 +5865,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image_fs(unsigned int element_number, unsigned int compression, @@ -5923,7 +5954,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image_sf(unsigned int element_number, unsigned int compression, @@ -6340,7 +6371,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image; void set_image(unsigned int element_number, unsigned int compression, @@ -6429,7 +6460,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image; void set_image_fs(unsigned int element_number, unsigned int compression, @@ -6518,7 +6549,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image_sf; void set_image_sf(unsigned int element_number, unsigned int compression, @@ -6596,7 +6627,7 @@ SEE ALSO /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray; void set_integerarray(unsigned int compression, int binary_id, char *data, int len, int elsize, int elsigned, int elements){ @@ -6676,7 +6707,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims; void set_integerarray_wdims(unsigned int compression, int binary_id, @@ -6762,7 +6793,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_fs; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims_fs; void set_integerarray_wdims_fs(unsigned int compression, int binary_id, @@ -6848,7 +6879,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_sf; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims_sf; void set_integerarray_wdims_sf(unsigned int compression, int binary_id, @@ -7215,7 +7246,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; void set_real_3d_image(unsigned int element_number, unsigned int compression, @@ -7304,7 +7335,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_fs; void set_real_3d_image_fs(unsigned int element_number, unsigned int compression, @@ -7393,7 +7424,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; void set_real_3d_image_sf(unsigned int element_number, unsigned int compression, @@ -7482,7 +7513,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image; void set_real_image(unsigned int element_number, unsigned int compression, @@ -7571,7 +7602,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image; void set_real_image_fs(unsigned int element_number, unsigned int compression, @@ -7660,7 +7691,7 @@ Returns an error code on failure or 0 for success. /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image_sf; void set_real_image_sf(unsigned int element_number, unsigned int compression, @@ -7738,7 +7769,7 @@ SEE ALSO /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray; void set_realarray(unsigned int compression, int binary_id, char *data, int len, int elsize, int elements){ @@ -7818,7 +7849,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims; void set_realarray_wdims(unsigned int compression, int binary_id, @@ -7904,7 +7935,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_fs; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims_fs; void set_realarray_wdims_fs(unsigned int compression, int binary_id, @@ -7990,7 +8021,7 @@ SEE ALSO which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_sf; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims_sf; void set_realarray_wdims_sf(unsigned int compression, int binary_id, diff --git a/swig/make_pycbf.py b/swig/make_pycbf.py index 2f995c2..0cfd298 100755 --- a/swig/make_pycbf.py +++ b/swig/make_pycbf.py @@ -581,7 +581,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_integerarray_as_string; // Get the length correct @@ -618,7 +618,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_as_string; // Get the length correct @@ -654,7 +654,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_fs_as_string; // Get the length correct @@ -690,7 +690,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_image_fs_as_string; // Get the length correct @@ -726,7 +726,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_as_string; // Get the length correct @@ -756,7 +756,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_fs_as_string; // Get the length correct @@ -786,7 +786,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_image_sf_as_string; // Get the length correct @@ -816,7 +816,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_as_string; // Get the length correct @@ -853,7 +853,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_fs_as_string; // Get the length correct @@ -890,7 +890,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_3d_image_sf_as_string; // Get the length correct @@ -927,7 +927,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_as_string; // Get the length correct @@ -963,7 +963,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_fs_as_string; // Get the length correct @@ -999,7 +999,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_real_3d_image_sf_as_string; // Get the length correct @@ -1035,7 +1035,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): """ // Ensure we free the local temporary -%cstring_output_allocate_size(char ** s, int *slen, free(*$1)) +%bytestring_output_allocate_size(char ** s, int *slen, free(*$1)) get_realarray_as_string; // Get the length correct @@ -1072,7 +1072,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray; void set_integerarray(unsigned int compression, int binary_id, char *data, int len, int elsize, int elsigned, int elements){ @@ -1107,7 +1107,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims; void set_integerarray_wdims(unsigned int compression, int binary_id, @@ -1153,7 +1153,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_sf; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims_sf; void set_integerarray_wdims_sf(unsigned int compression, int binary_id, @@ -1199,7 +1199,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_integerarray_wdims_fs; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_integerarray_wdims_fs; void set_integerarray_wdims_fs(unsigned int compression, int binary_id, @@ -1244,7 +1244,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray; void set_realarray(unsigned int compression, int binary_id, char *data, int len, int elsize, int elements){ @@ -1278,7 +1278,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims; void set_realarray_wdims(unsigned int compression, int binary_id, @@ -1323,7 +1323,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_sf; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims_sf; void set_realarray_wdims_sf(unsigned int compression, int binary_id, @@ -1368,7 +1368,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_realarray_wdims_fs; %apply (char *STRING, int LENGTH) { (char *bo, int bolen) } set_realarray_wdims_fs; void set_realarray_wdims_fs(unsigned int compression, int binary_id, @@ -1412,7 +1412,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image; void set_image(unsigned int element_number, unsigned int compression, @@ -1449,7 +1449,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image; void set_image_fs(unsigned int element_number, unsigned int compression, @@ -1486,7 +1486,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_image_sf; void set_image_sf(unsigned int element_number, unsigned int compression, @@ -1523,7 +1523,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image; void set_real_image(unsigned int element_number, unsigned int compression, @@ -1559,7 +1559,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image; void set_real_image_fs(unsigned int element_number, unsigned int compression, @@ -1595,7 +1595,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_image_sf; void set_real_image_sf(unsigned int element_number, unsigned int compression, @@ -1631,7 +1631,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image(unsigned int element_number, unsigned int compression, @@ -1669,7 +1669,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image_fs(unsigned int element_number, unsigned int compression, @@ -1707,7 +1707,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_3d_image; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_3d_image; void set_3d_image_sf(unsigned int element_number, unsigned int compression, @@ -1745,7 +1745,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; void set_real_3d_image(unsigned int element_number, unsigned int compression, @@ -1782,7 +1782,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_fs; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_fs; void set_real_3d_image_fs(unsigned int element_number, unsigned int compression, @@ -1819,7 +1819,7 @@ def docstringwrite(pyfunc, input, output, prototype, cbflibdoc): /* CBFlib must NOT modify the data string which belongs to the scripting language we will get and check the length via a typemap */ -%apply (char *STRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; +%apply (char *DATASTRING, int LENGTH) { (char *data, int len) } set_real_3d_image_sf; void set_real_3d_image_sf(unsigned int element_number, unsigned int compression, @@ -3121,6 +3121,37 @@ def __init__(self): } CBF_NODETYPE; +// Tell SWIG to return a string-output-argument as a bytestring +%define %bytestring_output_allocate_size(TYPEMAP, SIZE, RELEASE) + %typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { + $1 = &temp; $2 = &tempn; + } + %typemap(freearg,match="in") (TYPEMAP, SIZE) ""; + %typemap(argout,noblock=1)(TYPEMAP, SIZE) { + if (*$1) { +%#if PY_VERSION_HEX >= 0x03000000 + %append_output(PyBytes_FromStringAndSize(*$1,*$2)); +%#else + %append_output(SWIG_FromCharPtrAndSize(*$1,*$2)); +%#endif + RELEASE; + } + } +%enddef + +// Typemap to read a python bytes object as array data +%typemap(in,noblock=1) + (char *DATASTRING, size_t LENGTH) (int res, char *buf = 0, Py_ssize_t size = 0), + (const char *DATASTRING, size_t LENGTH) (int res, char *buf = 0, Py_ssize_t size = 0) +{ + res = PyBytes_AsStringAndSize($input, &buf, &size) == -1 ? SWIG_TypeError : SWIG_OK; + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(buf, $1_ltype); + $2 = %numeric_cast(size, $2_ltype); +} +%typemap(in) (char *DATASTRING, int LENGTH) = (char *DATASTRING, size_t LENGTH); // Tell SWIG what the object is, so we can build the class