C++/通过引用传递的SWIG类型映射 我有以下C++代码,我想从Python中使用。这包装是用泔水做的

C++/通过引用传递的SWIG类型映射 我有以下C++代码,我想从Python中使用。这包装是用泔水做的,python,c++,c,swig,Python,C++,C,Swig,头文件: #ifndef FSINDEXTRANSFORM_H #define FSINDEXTRANSFORM_H class FSIndexTransform { public: typedef int IndexVec3; void Transform(const IndexVec3 indices, const IndexVec3 begin1, const IndexVec3 begin2, IndexVec3& result) const; }; #endif 源文件

头文件:

#ifndef FSINDEXTRANSFORM_H
#define FSINDEXTRANSFORM_H

class FSIndexTransform
{
public:
typedef int IndexVec3;

void Transform(const IndexVec3 indices, const IndexVec3 begin1, const IndexVec3 begin2, IndexVec3& result) const;
};

#endif
源文件:

#include <iostream>
#include "FSIndexTransform.h"

void FSIndexTransform::Transform(const IndexVec3 indices,
                                const IndexVec3 begin1,
                                const IndexVec3 begin2,
                                IndexVec3& result) const
{
std::cout << "OK" << std::endl;
}
我尝试使用生成的Python模块,如下所示:

from FSIndexTransform import FSIndexTransform
transform = FSIndexTransform()
transform.Transform(1, 2, 3, 4)
根据,const IndexVec3和IndexVec3&参数的处理方式应该相同。但这不是我观察到的行为:

Traceback (most recent call last):
File "test.py", line 13, in <module>
    transform.Transform(1, 2, 3, 4)
File "/projects/fsdm/dev/st15435/FlowSim/FSDM/trunk/test_fsindextransform/bin/FSIndexTransform.py", line 101, in Transform
    return _FSIndexTransform.FSIndexTransform_Transform(self, indices, begin1, begin2, result)
TypeError: in method 'FSIndexTransform_Transform', argument 5 of type 'FSIndexTransform::IndexVec3 &'
我没有设法使用(或理解)我发现的类似讨论

Traceback (most recent call last):
File "test.py", line 13, in <module>
    transform.Transform(1, 2, 3, 4)
File "/projects/fsdm/dev/st15435/FlowSim/FSDM/trunk/test_fsindextransform/bin/FSIndexTransform.py", line 101, in Transform
    return _FSIndexTransform.FSIndexTransform_Transform(self, indices, begin1, begin2, result)
TypeError: in method 'FSIndexTransform_Transform', argument 5 of type 'FSIndexTransform::IndexVec3 &'
FSIndexTransform::IndexVec3 arg2 ; 
FSIndexTransform::IndexVec3 arg3 ;
FSIndexTransform::IndexVec3 arg4 ; 
FSIndexTransform::IndexVec3 *arg5 = 0