[Mono-list] gtk-sharp problem

Paolo Molaro lupus@ximian.com
Mon, 22 Jul 2002 16:46:07 +0200


On 07/22/02 Dietmar Maurer wrote:
> >  And if we need to use the ref
> > keyword, how do I deal with the function:
> > 
> > MyValueType Foo ();
> > 
> > If the native function is really returning a MyValueType pointer, I
> > can't use the ref keyword on a return value to indicate that.
> 
> Well, thats a problem. Maybe the easiest way to wrap such functions is
> to use IntPtr and then call PtrToStructure.

I think we need to deal with this issues in a type-by-type basis.
From the point of view of the C# API as default it should be just fine to 
pass valutypes by ref (with ref or out) when they are parameters and just 
return the valuetype when it's a return type (unless not making the copy
is important for some reason, in that case we should use a reference,
not a struct).
From the point of view of the binding to the Gtk+ library, I don't see
other ways than the PtrToStructure hack that Dietmar suggested.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better