From f6f9fd0c79dc18dcc3e5574ea1d3137c90dabe98 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 1 Jun 2005 17:58:28 +0000 Subject: [PATCH] * glib/Value.cs: Add a constructor and an explicit cast for string[] (using a G_TYPE_STRV boxed value). * generator/SymbolTable.cs (SymbolTable): Map GStrv to string[]. (The mapping relies on the above GLib.Value magic, so it only works correctly for properties, but that's ok, because GStrv isn't a real type anyway and only shows up in the api files for G_TYPE_STRV properties.) Makes the Gtk.AboutDialog Artists, Authors, and Documenters properties show up. * gtk/Gtk.metadata: hide AboutDialog.Get/SetArtists/Authors/Documenters, which can't be used to implement the Artists/Authors/Documenters properties, because the generated code doesn't know to NULL-terminate the arrays. svn path=/trunk/gtk-sharp/; revision=45301 --- ChangeLog | 18 +++++ doc/ChangeLog | 7 ++ doc/en/GLib/Value.xml | 148 ++++++++++++++++++++++--------------- doc/en/Gtk/AboutDialog.xml | 51 +++++++++++++ generator/SymbolTable.cs | 1 + glib/Value.cs | 36 +++++++++ gtk/Gtk.metadata | 6 ++ 7 files changed, 207 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index c044296ba..1dc8bd7ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-06-01 Dan Winship + + * glib/Value.cs: Add a constructor and an explicit cast for + string[] (using a G_TYPE_STRV boxed value). + + * generator/SymbolTable.cs (SymbolTable): Map GStrv to string[]. + (The mapping relies on the above GLib.Value magic, so it only + works correctly for properties, but that's ok, because GStrv isn't + a real type anyway and only shows up in the api files for + G_TYPE_STRV properties.) Makes the Gtk.AboutDialog Artists, + Authors, and Documenters properties show up. + + * gtk/Gtk.metadata: hide + AboutDialog.Get/SetArtists/Authors/Documenters, which can't be + used to implement the Artists/Authors/Documenters properties, + because the generated code doesn't know to NULL-terminate the + arrays. + 2005-05-31 Mike Kestner * glib/Object.cs : rework the weakref release mechanism to avoid a diff --git a/doc/ChangeLog b/doc/ChangeLog index f91a8e513..fdfb0b088 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2005-06-01 Dan Winship + + * en/GLib/Value.xml: document the new string[] methods (and all of + the previously-undocumented explicit cast operators). + + * en/Gtk/AboutDialog.xml: document Authors, Artists, Documenters. + 2005-05-24 Dan Winship * en/Gdk/PixdataType.xml: diff --git a/doc/en/GLib/Value.xml b/doc/en/GLib/Value.xml index 0ed9e3496..d1a9aea90 100644 --- a/doc/en/GLib/Value.xml +++ b/doc/en/GLib/Value.xml @@ -353,10 +353,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a boolean value from a . + The boolean value. + @@ -369,10 +369,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an integer value from a . + The integer value. + @@ -385,10 +385,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an unsigned integer value from a . + The unsigned integer value. + @@ -401,10 +401,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an unsigned short value from a . + The unsigned short value. + @@ -417,10 +417,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a long integer value from a . + The long integer value. + @@ -433,10 +433,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an unsigned long integer value from a . + The unsigned long integer value. + @@ -449,10 +449,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an enumeration value from a . + The enumeration value. + @@ -465,10 +465,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a floating-point value from a . + The floating-point value. + @@ -481,10 +481,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a double-precision floating-point value from a . + The double-precision floating-point value. + @@ -497,10 +497,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a string value from a . + The string value. + @@ -513,10 +513,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an untyped pointer value from a . + The untyped pointer value. + @@ -529,10 +529,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an opaque object value from a . + The opaque object value. + @@ -545,10 +545,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts a boxed type value from a . + The boxed type value. + @@ -561,10 +561,10 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an object value from a . + The object value. + @@ -577,10 +577,38 @@ - To be added. - To be added. - To be added. - To be added. + a + Extracts an unwrapped object value from a . + The unwrapped object value. + + + + + + Constructor + + + + + a + Constructs a Value from a specified string array. + + + + + + Method + + System.String[] + + + + + + a + Extracts a string array from a . + The string array value. + diff --git a/doc/en/Gtk/AboutDialog.xml b/doc/en/Gtk/AboutDialog.xml index 10a4fa2c1..de27813cb 100644 --- a/doc/en/Gtk/AboutDialog.xml +++ b/doc/en/Gtk/AboutDialog.xml @@ -287,5 +287,56 @@ To make constructing a as convenient as possibl + + + Property + + + GLib.Property(Name="documenters") + + + + System.String[] + + + The people documenting the program. + a . + Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details. + + + + + Property + + + GLib.Property(Name="authors") + + + + System.String[] + + + The authors of the program. + a . + Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details. + + + + + Property + + + GLib.Property(Name="artists") + + + + System.String[] + + + The people who contributed artwork to the program. + a . + Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details. + + diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 5a587a463..85d1bc815 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -92,6 +92,7 @@ namespace GtkSharp.Generation { AddType (new ConstStringGen ("const-char")); AddType (new MarshalGen ("gchar", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); AddType (new MarshalGen ("char", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); + AddType (new SimpleGen ("GStrv", "string[]")); // manually wrapped types requiring more complex marshaling AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})")); diff --git a/glib/Value.cs b/glib/Value.cs index 2380e081a..9d7a332a9 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -167,6 +167,25 @@ namespace GLib { g_value_set_boxed (ref this, val.Handle); } + public Value (string[] val) : this (new GLib.GType (g_strv_get_type ())) + { + if (val == null) { + g_value_set_boxed (ref this, IntPtr.Zero); + return; + } + + IntPtr native_array = Marshal.AllocHGlobal ((val.Length + 1) * IntPtr.Size); + for (int i = 0; i < val.Length; i++) + Marshal.WriteIntPtr (native_array, i * IntPtr.Size, GLib.Marshaller.StringToPtrGStrdup (val[i])); + Marshal.WriteIntPtr (native_array, val.Length * IntPtr.Size, IntPtr.Zero); + + g_value_set_boxed (ref this, native_array); + + for (int i = 0; i < val.Length; i++) + GLib.Marshaller.Free (Marshal.ReadIntPtr (native_array, i * IntPtr.Size)); + Marshal.FreeHGlobal (native_array); + } + public void Dispose () { @@ -258,6 +277,20 @@ namespace GLib { return new UnwrappedObject (g_value_get_object (ref val)); } + public static explicit operator string[] (Value val) + { + IntPtr native_array = g_value_get_boxed (ref val); + if (native_array == IntPtr.Zero) + return null; + + int count = 0; + while (Marshal.ReadIntPtr (native_array, count * IntPtr.Size) != IntPtr.Zero) + count++; + string[] strings = new string[count]; + for (int i = 0; i < count; i++) + strings[i] = GLib.Marshaller.Utf8PtrToString (Marshal.ReadIntPtr (native_array, i * IntPtr.Size)); + return strings; + } public object Val { @@ -437,5 +470,8 @@ namespace GLib { [DllImport("libgobject-2.0-0.dll")] static extern bool g_type_is_a (IntPtr type, IntPtr is_a_type); + + [DllImport("libgobject-2.0-0.dll")] + static extern IntPtr g_strv_get_type (); } } diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index ccd3049a4..7a35ba2f5 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -109,6 +109,12 @@ EmitRowsReordered ChangeSortColumn label + 1 + 1 + 1 + 1 + 1 + 1 Activated 1 call