我有一个SWIG生成的函数,如下所示:SWIG倍率功能或修改C++结果对象
SWIGINTERN PyObject *_wrap_StrVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
std::vector<std::string> *arg1 = (std::vector<std::string> *) 0 ;
PySliceObject *arg2 = (PySliceObject *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
std::vector< std::string,std::allocator<std::string> > *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:StrVector___getitem__",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 | 0);
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StrVector___getitem__" "', argument " "1"" of type '" "std::vector<std::string> *""'");
}
arg1 = reinterpret_cast< std::vector<std::string> * >(argp1);
{
if (!PySlice_Check(obj1)) {
SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StrVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
}
arg2 = (PySliceObject *) obj1;
}
try {
result = (std::vector< std::string,std::allocator<std::string> > *)std_vector_Sl_std_string_Sg____getitem____SWIG_0(arg1,arg2);
}
catch(std::out_of_range &_e) {
SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
}
*****1*****
***//I want to modify or print variable result here like printf("%s", result->c_str());***
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 | 0);
return resultobj;
fail:
return NULL;
}
我需要打印位置1处的变量的结果(如在代码中提到)。 Typemap(argout)在这里似乎没有多大帮助。
你能显示该函数的原始声明吗?我认为这是你在这里定位的Python? – Flexo 2012-01-17 16:16:40