[Gtk-sharp-list] problem marshalling struct data

Mike Kestner mkestner@speakeasy.net
11 Apr 2003 21:24:54 -0500


On Thu, 2003-04-10 at 12:46, Lee Mallabone wrote:

> Could someone who knows about wrapping structs take a look and tell me
> what I'm doing wrong? I've attached a test program that should work but
> currently throws a NullReferenceException.
> 
> I've been staring at this for hours now; I'm sure the solution is
> simple, it just won't present itself to me!

There's really no way for the runtime to marshal a ptr into an array. 
At least I don't think there is.  Dietmar? Paolo?  In order to do so, it
would have to know how many elements are in the array, and it can't know
that, really.

Only thing I can think of is to return an IntPtr, and in a .custom,
increment the pointer while iterating on n_color using Gdk.Color.New to
marshal the individual Colors. May need to go into unsafe mode to
increment the IntPtr, but I'm not sure off the top of my head.

-- 
Mike Kestner <mkestner@speakeasy.net>