[Insight-developers] Roadblock in Filling CSwig wrapping gaps

Brad King brad.king at kitware.com
Wed Jan 12 11:24:19 EST 2005


Kent Williams wrote:
> So to wrap these classes, I added this to 
> wrap_itkHistogramMatchingImageFilter.cxx:
> 
> +     typedef itk::SpatialObject<2> SO2;
> +     typedef itk::SpatialObject<3> SO3;
> +     ITK_WRAP_OBJECT1(TreeNode,SO2,TreeeNodeSO2);   +     
> ITK_WRAP_OBJECT1(TreeNode,SO3,TreeeNodeSO3);
> 
> Now compilation fails -- because, among other things,  
> SwigValueWrapper<T>::~SwigValueWrapper() wants to call ~T(), and 
> itk::SpatialObject's destructor is private. Full error message below.

Any type defined in the _cable_::wrappers namespace will be treated as 
something to wrap.  The ITK_WRAP_* macros expand into typedef lines. 
The typedef lines for SO2 and SO3 are actually instructions to CSwig to 
wrap those classes and call them SO2 and SO3, which is not what you want.

Instead put the SO2 and SO3 typedefs in a namespace before _cable_ begins:

namespace itkso
{
   typedef itk::SpatialObject<2> SO2;
   typedef itk::SpatialObject<3> SO3;
}

And then use these wrapping lines:

ITK_WRAP_OBJECT1(TreeNode, itkso::SO2, TreeNodeSO2);
ITK_WRAP_OBJECT1(TreeNode, itkso::SO3, TreeNodeSO3);

-Brad


More information about the Insight-developers mailing list