logo       

newbie problem with python lists as c-function arguments: msg#00175

programming.swig

Subject: newbie problem with python lists as c-function arguments

Hi,

I want to wrap the following function for python:

test.h:
#--------------------------------
#include <map>
#include <vector>
#include <valarray>
#include <list>
#include <math.h>
#include <stdio.h>

double Calcvalues ( const int*,
const int,
const double*,
const int,
const int,
const double*,
double*,
double*);
#---------------------------------
test.i:
#---------------------------------
%module test

%{
#include "test.h"
%}
%include "carrays.i"
%include "cpointer.i"

%include "test.h"
#---------------------------------
compiles to _test.dll


usetest.py:
#---------------------------------
import test

a=[1,2,3]
b=5
c=[1.0,2.0]
etc.....

print test.Calcvalues(a,b,c....)

Error message:

TypeError: Type error. Expected _p_int
#---------------------------------

I have tried converting all lists to Numeric.arrrays, but this didn't work
either.
What's wrong?

The second thing is that I actually not only want to get the return value,
but also
pass two empty lists (the last two arguments) that are filled within the
function.
I know that I have read somewhere what to do in this case, but I don't
find it any more.

Any help is really appreciated.

Thanks
marcus

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise