[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

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.


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


More information about the Cplusplus-sig mailing list