Hello Java, > ... > extern int doIt(char *a, MY_DIGIT **digit); > %include cpointer.i > %pointer_functions(MY_DIGIT, md_prt); Don't you mean md_ptr?
> %typemap(in) (char *a, MY_DIGIT **argv) { > /* Check if is a list */ > if (PyList_Check($input)) { > int i; > $1 = PyList_Size($input); > $2 = (MY_DIGIT **) malloc(($1+1)*sizeof(long *)); > for (i = 0; i < $1; i++) { > PyObject *o = PyList_GetItem($input,i); > if (PyString_Check(o)) > $2[i] = PyString_AsString(PyList_GetItem($input,i)); > else { > PyErr_SetString(PyExc_TypeError,"list must contain strings"); > free($2); > return NULL; > } > } > $2[i] = 0; > } else { > PyErr_SetString(PyExc_TypeError,"not a list"); > return NULL; > } > } > > %typemap(freearg) (char *a, MY_DIGIT **argv) { > free((MY_DIGIT *) $2); > } > > > ..from Python I am trying > > >> ptr = [] > >> doIt("blah", ptr) > > I thought this was the correct approach as described here: > http://www.swig.org/Doc1.3/SWIGDocumentation.html#Python_nn59 > > However, python comes back and says "TypeError: argument number 2: a > 'MY_DIGIT **' is expected, 'list([])' is received" > > ..any ideas? Didn't check it but from http://www.swig.org/Doc1.3/Library.html it looks like you need to do: ptr = new_md_prt() HTH. -- ------------------------------------------------------------------------ Miki Tebeka <[EMAIL PROTECTED]> http://tebeka.bizhat.com The only difference between children and adults is the price of the toys
pgpti3bVY1t95.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list