[Gtk-sharp-list] Upcoming problems.

Rachel Hestilow rachel@nullenvoid.com
27 May 2003 16:33:07 -0500

Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Tue, 2003-05-27 at 11:41, Mike Kestner wrote:
> Surely there are not 162 instances of const char * returns.  It seems to
> me like the majority of string returns in gtk are owned by the caller.=20
> We should only be changing the DllImports for those that aren't owned by
> us.
> So that is going to require an audit of those API calls and some tagging
> in the XML. Otherwise, we are going to leak all the owned strings. It
> should be a pretty small change to the generator to handle a tag like
> that.
> > I've got some free time so I'll see if I can fix this tonight. Mike, I
> > know you had some more pending changes to the generator, so sorry in
> > advance if I cause any conflicts :-).
> If you have the time, great.  This will most likely be isolated to
> Method.cs, and I don't think I've changed it much, if at all.

I haven't committed my changes yet, but I think it's actually far
simpler than that for the autogenerated code. Here is what I did:

1) I created a new ConstStringGen class which sets MarshalReturnType to
IntPtr and outputs a call to PtrToStringAuto in FromNativeReturn.
2) I updated SymbolTable to use ConstStringGen for the const-char and
const-gchar cases. I also had to add a small hack in Trim to not remove
the const in this case (as otherwise it would go to the regular string

Combined with an audit of the glue, glib, and .custom sources, we're
left with 50 other functions which, on cursory glance, all return new
strings. So no metadata hacking is required.

All in all, I'm impressed with the generator refactoring, the actual
generator modifications only took half an hour. Kudos on the great
design, Mike.

Shall I commit?

-- Rachel

Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

Version: GnuPG v1.0.7 (GNU/Linux)