[GRASS-user] Question with Python-SWIG example [SEC=UNCLASSIFIED]
Andrew MacIntyre
Andrew.MacIntyre at acma.gov.au
Tue May 11 20:48:25 EDT 2010
> -----Original Message-----
> From: Glynn Clements [mailto:glynn at gclements.plus.com]
> Sent: Wednesday, 12 May 2010 1:43 AM
> To: Andrew MacIntyre
> Cc: GRASS user list; grass-dev at lists.osgeo.org
> Subject: RE: [GRASS-user] Question with Python-SWIG example
> [SEC=UNCLASSIFIED]
>
>
> Andrew MacIntyre wrote:
>
> > From the SWIG examples I inferred the following type references for
> > the pointers in question:
> >
> > CELL* => SWIGTYPE_p_CELL
> > FCELL* => SWIGTYPE_p_FCELL
> > DCELL* => SWIGTYPE_p_DCELL
> >
> > provided that CELL*/FCELL*/DCELL* are typedef'ed.
> >
> > So I expected that in pyobj_to_ptr() you could do something like
>
> But I still don't see what happens when a function returns a CELL*
> which is subsequently passed to a function accepting a void*, or
> vice-versa. This is common enough that if SWIG can't handle it, we
> need to use something other than SWIG.
That seems to be what the SWIG Pointer Library function ptrcast() is
for,
according to http://www.swig.org/Doc1.1/HTML/Typemaps.html, so
something like (in Python):
import GrassMod
pCELL = GrassMod.Returns_CELLptr()
pvoid = GrassMod.castptr(pCELL, "void *")
result = GrassMod.Takes_voidptr(pvoid)
(substitute the correct name of the GRASS SWIG module for "GrassMod")
> > If you decide to investigate using ctypes, the following links might
be
> > of interest:
> >
> > - http://starship.python.net/crew/theller/ctypes/old/codegen.html
>
> AFAICT, this has been superseded by ctypeslib:
>
> http://pypi.python.org/pypi/ctypeslib/
Thanks, the old page was something I had bookmarked.
> > - http://www.language-binding.net/pygccxml/pygccxml.html
>
> I wasn't aware of this one.
>
> I also found ctypesgen:
>
> http://code.google.com/p/ctypesgen/
And that one's new to me, for which thanks.
Cheers,
Andrew.
-------------------------> "These thoughts are mine alone!" <---------
Andrew MacIntyre Operations Branch
tel: +61 2 6219 5356 Communications Infrastructure Division
fax: +61 2 6253 3277 Australian Communications & Media Authority
email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/
If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents.
Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA.
More information about the grass-user
mailing list