[C++-sig] Pointers to simple types, arrays and arrays of pointers to types

Niall Douglas s_sourceforge at nedprod.com
Sun Oct 5 05:11:56 CEST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 4 Oct 2003 at 23:50, Nicodemus wrote:

> >This won't compile because FXColor is not a class. Ideally I'd like
> >the python side to be able to access the array of FXColor's being
> >returned - no limits are needed because other methods return the
> >length.
> 
> I don't think that's possible, since ints are immutable... it would at
> least be very troublesome. 8/ Do you plan to change the values in
> Python? If not, create a wrapper that returns a list of ints. If you
> want to change it in Python, you will have to create a function
> setData, that receives a list of ints and changes the original array.
> Notice that this function can be present just in the binding, you
> don't have to code it for the C++ class. This interface seems more
> Pythonic to me. 8)

Basically FXImage is an image - whereby you can alter it by drawing 
on it, or modifiying its bitmap directly. If you were to make copies 
into a list, it would be sure slow.

I think the best solution might be for it to return a wrapper class 
which provides operator[]. This may in fact solve all my problems.

> >Lastly, some other methods return a type ** ie; an array of pointers
> >to object instances. How on earth can this get wrapped? Is that
> >indexing suite the right answer for these?
> 
> I think creating wrappers is the solution here.

Agreed, cheers for the help. I'll try hacking together some code to 
do this tomorrow, and if acceptable it might be an idea for pyste.

Cheers,
Niall





-----BEGIN PGP SIGNATURE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2

iQA/AwUBP3+L/cEcvDLFGKbPEQIqwACdEll60itBK9fPqOJgkp+M7VGdZjQAoLZe
TZ3ssdaFLiCRv3+Wi8WTCwL9
=eYRy
-----END PGP SIGNATURE-----




More information about the Cplusplus-sig mailing list