[GRASS-user] Question with Python-SWIG example [SEC=UNCLASSIFIED]
Andrew MacIntyre
Andrew.MacIntyre at acma.gov.au
Tue Apr 20 20:55:44 EDT 2010
[Oops - original inadvertently sent only to Glynn, again :-(]
> From: Glynn Clements
>
> Andrew MacIntyre wrote:
>
> > After some googling, it seems that the pointer address should be
> > obtainable by using int() on the pointer object returned by the SWIG
> > wrapper (i.e. int(p) in the above example), with the resulting value
> > usable in ctypes' from_address() method. I might be wrong, but I
> > think that e.g. ctypes.c_void_p(int(p)) might also work to create a
> > ctypes void pointer instance.
>
> That doesn't seem to work either:
>
> > import grass.lib.grass as gis
> > import grass.lib.raster as rast
> > import ctypes
> > gis.G_gisinit("")
> > p = rast.Rast_allocate_c_buf()
> > a = ctypes.cast(int(p), ctypes.POINTER(ctypes.c_int))
> > infd = rast.Rast_open_old("elevation.dem", "")
> > rast.Rast_get_c_row(infd, a, 10)
I think the above line should read:
rast. Rast_get_c_row(infd, p, 10)
> > a[0]
Then this might work.
-------------------------> "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