[GRASS-user] Question with Python-SWIG example [SEC=UNCLASSIFIED]

Glynn Clements glynn at gclements.plus.com
Thu Apr 22 11:52:44 EDT 2010


Andrew MacIntyre wrote:

> > That was what I tried first, but it results in Rast_get_c_row()
> > segfaulting.
> 
> Then it seems to me that there's some problem with the SWIG wrapper for
> Rast_get_c_row(), if it won't accept a valid SWIG pointer object
> returned from another wrapped function.

That's what I suspect, namely that the typemap for pointers is getting
in the way.

Removing the typemap would mean that you couldn't pass a Python
string, array, buffer, sequence, etc directly to a GRASS function, but
would have to explicitly allocate and populate a block of memory.

> > There is a typemap for pointers, which converts a CObject, string,
> > buffer or sequence. I have no idea how to test for or convert a
> > SWIG-wrapped pointer.
> 
> In the SWIG wrapper?  I see a note about SWIG_ConvertPtr() in
> http://www.swig.org/Doc1.3/Python.html#Python_nn64 ?

That might help, although I still don't know how to test whether a
given "PyObject *" is a SWIG-wrapped pointer.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list