Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/Bridge/NumPy/include/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ PyBuffer<TImage>::_GetImageViewFromArray(PyObject * arr, PyObject * shape, PyObj
{
PyErr_SetString(PyExc_RuntimeError, "Size mismatch of image and Buffer.");
PyBuffer_Release(&pyBuffer);
Py_DECREF(shapeseq);
SWIG_Py_DECREF(shapeseq);
return nullptr;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ PyBuffer<TImage>::_GetImageViewFromArray(PyObject * arr, PyObject * shape, PyObj
output->SetPixelContainer(importer);
output->SetNumberOfComponentsPerPixel(numberOfComponents);

Py_DECREF(shapeseq);
SWIG_Py_DECREF(shapeseq);
PyBuffer_Release(&pyBuffer);

return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ foreach(d ${ITK_WRAP_IMAGE_DIMS})
# `double` because of OptimizerParameters is hardcoded as templated
# over `double` in parent class `ShapeSignedDistanceFunction`.
foreach(t ${types})
string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "DECL_PYTHON_STD_VEC_RAW_TO_SMARTPTR_TYPEMAP(itkImage${ITKM_${t}}${d}, itkImage${ITKM_${t}}${d}_Pointer)\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expected to work in remote modules? Should I replace the old way with this style?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

itk_wrap_template("${ITKM_D}${d}${ITKM_I${t}${d}}" "${ITKT_D},${d},${ITKT_I${t}${d}}")
endforeach()
endforeach()
Expand Down
4 changes: 2 additions & 2 deletions Wrapping/Generators/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ macro(
add_custom_command(
OUTPUT ${cpp_file} ${python_file}
COMMAND
${swig_command} -c++ -python -O -features autodoc=2 -py3 -doxygen -Werror
${swig_command} -c++ -python -fastdispatch -fvirtual -features autodoc=2 -doxygen -Werror
-w302 # Identifier 'name' redefined (ignored)
-w303 # %extend defined for an undeclared class 'name' (to avoid warning about customization in pyBase.i)
-w312 # Unnamed nested class not currently supported (ignored)
Expand Down Expand Up @@ -406,7 +406,7 @@ macro(itk_end_wrap_submodule_python group_name)
PyImport_AddModule(\"itk._${base_name}Python\");
PyObject * ${base_name}Module = PyInit__${base_name}Python();
PyDict_SetItemString(sysModules, \"itk._${base_name}Python\", ${base_name}Module);
Py_DECREF( ${base_name}Module);
SWIG_Py_DECREF( ${base_name}Module);
}
")

Expand Down
10 changes: 0 additions & 10 deletions Wrapping/Generators/Python/PyBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ add_python_config_template(
"std::ios_base"
"ios_base"
"")
add_python_config_template(
"ios_base_sync_with_stdio"
"std::ios_base_sync_with_stdio"
"ios_base_sync_with_stdio"
"")
add_python_config_template(
"ios_base_xalloc"
"std::ios_base_xalloc"
"ios_base_xalloc"
"")
add_python_config_template(
"iostream"
"std::iostream"
Expand Down
28 changes: 14 additions & 14 deletions Wrapping/Generators/Python/PyBase/pyBase.i
Original file line number Diff line number Diff line change
Expand Up @@ -867,11 +867,11 @@ str = str
} else if (PyFloat_Check(o)) {
itks[i] = (type)PyFloat_AsDouble(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int or float");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = &itks;
}else if (PyInt_Check($input)) {
Expand Down Expand Up @@ -915,11 +915,11 @@ str = str
} else if (PyFloat_Check(o)) {
itks[i] = (type)PyFloat_AsDouble(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int or float");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = itks;
}else if (PyInt_Check($input)) {
Expand Down Expand Up @@ -991,11 +991,11 @@ str = str
} else if (PyFloat_Check(o)) {
itks[i] = (value_type)PyFloat_AsDouble(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int or float");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = &itks;
}
Expand Down Expand Up @@ -1024,11 +1024,11 @@ str = str
} else if (PyFloat_Check(o)) {
itks[i] = (value_type)PyFloat_AsDouble(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int or float");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = itks;
}
Expand Down Expand Up @@ -1078,11 +1078,11 @@ str = str
if (PyInt_Check(o) || PyLong_Check(o)) {
itks[i] = PyInt_AsLong(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int (or long)");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = &itks;
}else if (PyInt_Check($input) || PyLong_Check($input)) {
Expand Down Expand Up @@ -1119,11 +1119,11 @@ str = str
if (PyInt_Check(o) || PyLong_Check(o)) {
itks[i] = PyInt_AsLong(o);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of int (or long)");
return NULL;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = itks;
}else if (PyInt_Check($input) || PyLong_Check($input)) {
Expand Down Expand Up @@ -1208,11 +1208,11 @@ str = str
if(SWIG_ConvertPtr(o,(void **)(&raw_ptr),$descriptor(swig_name *), 0) == 0) {
vec_smartptr.push_back(raw_ptr);
} else {
Py_DECREF(o);
SWIG_Py_DECREF(o);
PyErr_SetString(PyExc_ValueError,"Expecting a sequence of raw pointers (" #swig_name ")." );
SWIG_fail;
}
Py_DECREF(o);
SWIG_Py_DECREF(o);
}
$1 = vec_smartptr;
}
Expand Down
38 changes: 19 additions & 19 deletions Wrapping/Generators/Python/PyUtils/itkPyImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ PyImageFilter<TInputImage, TOutputImage>::~PyImageFilter()
{
if (this->m_GenerateDataCallable)
{
Py_DECREF(this->m_GenerateDataCallable);
SWIG_Py_DECREF(this->m_GenerateDataCallable);
}
this->m_GenerateDataCallable = nullptr;
if (this->m_GenerateInputRequestedRegionCallable)
{
Py_DECREF(this->m_GenerateInputRequestedRegionCallable);
SWIG_Py_DECREF(this->m_GenerateInputRequestedRegionCallable);
}
this->m_GenerateInputRequestedRegionCallable = nullptr;
}
Expand All @@ -51,7 +51,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateData(PyObject * o)
if (this->m_GenerateDataCallable)
{
// get rid of our reference
Py_DECREF(this->m_GenerateDataCallable);
SWIG_Py_DECREF(this->m_GenerateDataCallable);
}

// store the new object
Expand All @@ -62,7 +62,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateData(PyObject * o)
{
// take out reference (so that the calling code doesn't
// have to keep a binding to the callable around)
Py_INCREF(this->m_GenerateDataCallable);
SWIG_Py_INCREF(this->m_GenerateDataCallable);
}
}
}
Expand All @@ -77,7 +77,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateOutputInformation(PyObjec
if (this->m_GenerateOutputInformationCallable)
{
// get rid of our reference
Py_DECREF(this->m_GenerateOutputInformationCallable);
SWIG_Py_DECREF(this->m_GenerateOutputInformationCallable);
}

// store the new object
Expand All @@ -88,7 +88,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateOutputInformation(PyObjec
{
// take out reference (so that the calling code doesn't
// have to keep a binding to the callable around)
Py_INCREF(this->m_GenerateOutputInformationCallable);
SWIG_Py_INCREF(this->m_GenerateOutputInformationCallable);
}
}
}
Expand All @@ -103,7 +103,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyEnlargeOutputRequestedRegion(PyOb
if (this->m_EnlargeOutputRequestedRegionCallable)
{
// get rid of our reference
Py_DECREF(this->m_EnlargeOutputRequestedRegionCallable);
SWIG_Py_DECREF(this->m_EnlargeOutputRequestedRegionCallable);
}

// store the new object
Expand All @@ -114,7 +114,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyEnlargeOutputRequestedRegion(PyOb
{
// take out reference (so that the calling code doesn't
// have to keep a binding to the callable around)
Py_INCREF(this->m_EnlargeOutputRequestedRegionCallable);
SWIG_Py_INCREF(this->m_EnlargeOutputRequestedRegionCallable);
}
}
}
Expand All @@ -129,7 +129,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateInputRequestedRegion(PyOb
if (this->m_GenerateInputRequestedRegionCallable)
{
// get rid of our reference
Py_DECREF(this->m_GenerateInputRequestedRegionCallable);
SWIG_Py_DECREF(this->m_GenerateInputRequestedRegionCallable);
}

// store the new object
Expand All @@ -140,7 +140,7 @@ PyImageFilter<TInputImage, TOutputImage>::SetPyGenerateInputRequestedRegion(PyOb
{
// take out reference (so that the calling code doesn't
// have to keep a binding to the callable around)
Py_INCREF(this->m_GenerateInputRequestedRegionCallable);
SWIG_Py_INCREF(this->m_GenerateInputRequestedRegionCallable);
}
}
}
Expand All @@ -159,11 +159,11 @@ PyImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()

PyObject * args = PyTuple_Pack(1, this->m_Self);
result = PyObject_Call(this->m_GenerateOutputInformationCallable, args, (PyObject *)NULL);
Py_DECREF(args);
SWIG_Py_DECREF(args);

if (result)
{
Py_DECREF(result);
SWIG_Py_DECREF(result);
}
else
{
Expand Down Expand Up @@ -191,12 +191,12 @@ PyImageFilter<TInputImage, TOutputImage>::EnlargeOutputRequestedRegion(DataObjec
PyObject * pyDataObject = PyObject_CallMethod(this->m_Self, "GetOutput", (const char *)NULL);
PyObject * args = PyTuple_Pack(2, this->m_Self, pyDataObject);
PyObject * result = PyObject_Call(this->m_EnlargeOutputRequestedRegionCallable, args, (PyObject *)NULL);
Py_DECREF(args);
Py_DECREF(pyDataObject);
SWIG_Py_DECREF(args);
SWIG_Py_DECREF(pyDataObject);

if (result)
{
Py_DECREF(result);
SWIG_Py_DECREF(result);
}
else
{
Expand Down Expand Up @@ -224,11 +224,11 @@ PyImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()

PyObject * args = PyTuple_Pack(1, this->m_Self);
result = PyObject_Call(this->m_GenerateInputRequestedRegionCallable, args, (PyObject *)NULL);
Py_DECREF(args);
SWIG_Py_DECREF(args);

if (result)
{
Py_DECREF(result);
SWIG_Py_DECREF(result);
}
else
{
Expand Down Expand Up @@ -261,11 +261,11 @@ PyImageFilter<TInputImage, TOutputImage>::GenerateData()

PyObject * args = PyTuple_Pack(1, this->m_Self);
result = PyObject_Call(this->m_GenerateDataCallable, args, (PyObject *)NULL);
Py_DECREF(args);
SWIG_Py_DECREF(args);

if (result)
{
Py_DECREF(result);
SWIG_Py_DECREF(result);
}
else
{
Expand Down
Loading