[Gtk-sharp-list] gapi not including correct function signature?

Mike Kestner mkestner at gmail.com
Sun Aug 15 11:52:13 EDT 2010


On Sun, 2010-08-15 at 11:03 -0400, Alex Launi wrote:

> but the generated code looks like this. Shouldn't the IntPtr separator
> param be a char type?
> 
> 
> [DllImport("libglib-2.0.dll")]
> static extern void g_key_file_set_list_separator(IntPtr raw, IntPtr
> separator);
> 
> 
> public string ListSeparator { 
>         set {
>                  g_key_file_set_list_separator(Handle,
> GLib.Marshaller.StringToPtrGStrdup(value));
>         }
> }
> 
> 
> Should I just write the method myself in the .custom file, or is there
> a fixup I can do for this? It looks like it should be fine.

Turning it into a char implies it can accept utf16 chars.  It looks like
this C API only supports ascii separator chars, which is unusual for
glib APIs.  Probably 99% of the gchar API in gtk+ is utf8 strings, and
the other 1% is filename encoded strings.

Binding it manually in a custom is likely an easier solution than
supporting generation of gchar alongside gchar*, especially considering
the fact that accurately binding a gchar param probably requires
additional information.

My suggestion in this scenario would be to use "byte separator" for the
pinvoke parameter and use "(byte) value" to cast down a char value.

Another solution might be to change the separator element's type attr to
guint8 with metadata.  That would get you a generated "byte" API which
the user can use by casting down their own char values, and it would be
obvious at a glance that utf16 isn't supported.



More information about the Gtk-sharp-list mailing list