Hi, Everyone,
I am a newbie to both Swig and Python. I am trying to export a set of C APIs to 
Python. 
My C function is 
int getInfor( char* name, int height, int weight, Infor** infor) //where infor 
is an OUTPUT parameter
{
......
*infor = (Infor*)malloc(sizeof(Infor));
......
}
 
The declare of structure Infor is :
 typedef struct {
 char  name[20];
 int   height;
 int   weight;
} Infor
 
When wrote the below lines in the interface file named Extest.i
%module Extest
%{
#include "Extest.h"
%}
%typemap(out) Infor **OUTPUT {Infor **c}
%apply int *OUTPUT {int *c}
%include "Extest.h"
 
And then, How to write testing python file to call the function named 
getInfor()?
such as in test.py
 
infor = Extest.Infor()
res = Extest.getInfor("Test Name", 175, 80, infor)
 
when run upper's test.py, Error occured. The message is 
TypeError: in method 'getInfor', argument 4 of type 'Infor **'
 
How to write the test.py to transfer the  'Infor **' type's parameter?
After putting lot of trail and errors, I am writing this mail.
Could you please help me to write the test.py or swig interface file for the 
above function?
Thank you,
jemmy
Awaiting you
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to