|
From: Imoteph <vip...@we...> - 2010-04-03 15:55:35
|
Hello all,
I have a really frustrating problem trying to bind Multi-argument handling
char* type. For testing I wrote a simple function:
void chartest(char* str1, char* str2, char* b, char* t)
{
str1 = new char[strlen(b)+1];
str2 = new char[strlen(t)+1];
strcpy(str1,b);
strcpy(str2,t);
}
and add the swig instruction:
%typemap(in,numinputs=0) char* str1(char temp) {
$1 = &temp;
}
%typemap(in,numinputs=0) char* str2(char temp) {
$1 = &temp;
}
%typemap(argout)char* str1
{
$result=SWIG_Python_AppendOutput($result,
PyString_FromStringAndSize($1,strlen($1)));
}
%typemap(argout)char* str2
{
$result=SWIG_Python_AppendOutput($result,
PyString_FromStringAndSize($1,strlen($1)));
}
Well using this in python I get this output:
bla.chartest("k","k")
[\xb7\x0c\x7f\xee\x08\xcc\xe8z\xb7X\xe1\xb1\xbf\xd0\xc0\r\x08',
'z\xb7\x0c\x7f\xee\x08\xcc\xe8z\xb7X\xe1\xb1\xbf\xd0\xc0\r\x08']
Well, as you can think, that is not what I expected... What is wrong? Where
is my mistake?
How can I fix this?
I'm glad for any advice!
best regards
Imoteph
--
View this message in context: http://old.nabble.com/Problems-by-returning-char*-in-function-arguments-using-argout-tp28127588p28127588.html
Sent from the swig-user mailing list archive at Nabble.com.
|