* 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
This commit is contained in:
Dan Winship 2005-06-01 17:58:28 +00:00
parent 6334f60e2e
commit f6f9fd0c79
7 changed files with 207 additions and 60 deletions

View File

@ -1,3 +1,21 @@
2005-06-01 Dan Winship <danw@novell.com>
* 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 <mkestner@novell.com>
* glib/Object.cs : rework the weakref release mechanism to avoid a

View File

@ -1,3 +1,10 @@
2005-06-01 Dan Winship <danw@novell.com>
* 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 <danw@novell.com>
* en/Gdk/PixdataType.xml:

View File

@ -353,10 +353,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a boolean value from a <see cref="T:GLib.Value" />.</summary>
<returns>The boolean value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -369,10 +369,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an integer value from a <see cref="T:GLib.Value" />.</summary>
<returns>The integer value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -385,10 +385,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an unsigned integer value from a <see cref="T:GLib.Value" />.</summary>
<returns>The unsigned integer value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -401,10 +401,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an unsigned short value from a <see cref="T:GLib.Value" />.</summary>
<returns>The unsigned short value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -417,10 +417,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a long integer value from a <see cref="T:GLib.Value" />.</summary>
<returns>The long integer value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -433,10 +433,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an unsigned long integer value from a <see cref="T:GLib.Value" />.</summary>
<returns>The unsigned long integer value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -449,10 +449,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an enumeration value from a <see cref="T:GLib.Value" />.</summary>
<returns>The enumeration value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -465,10 +465,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a floating-point value from a <see cref="T:GLib.Value" />.</summary>
<returns>The floating-point value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -481,10 +481,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a double-precision floating-point value from a <see cref="T:GLib.Value" />.</summary>
<returns>The double-precision floating-point value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -497,10 +497,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a string value from a <see cref="T:GLib.Value" />.</summary>
<returns>The string value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -513,10 +513,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an untyped pointer value from a <see cref="T:GLib.Value" />.</summary>
<returns>The untyped pointer value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -529,10 +529,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an opaque object value from a <see cref="T:GLib.Value" />.</summary>
<returns>The opaque object value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -545,10 +545,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a boxed type value from a <see cref="T:GLib.Value" />.</summary>
<returns>The boxed type value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -561,10 +561,10 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an object value from a <see cref="T:GLib.Value" />.</summary>
<returns>The object value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
@ -577,10 +577,38 @@
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts an unwrapped object value from a <see cref="T:GLib.Value" />.</summary>
<returns>The unwrapped object value.</returns>
<remarks />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Value (string[] val);" />
<MemberType>Constructor</MemberType>
<Parameters>
<Parameter Name="val" Type="System.String[]" />
</Parameters>
<Docs>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Constructs a Value from a specified string array.</summary>
<remarks />
</Docs>
</Member>
<Member MemberName="op_Explicit">
<MemberSignature Language="C#" Value="public static string[] op_Explicit (GLib.Value val);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.String[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="val" Type="GLib.Value" />
</Parameters>
<Docs>
<param name="val">a <see cref="T:GLib.Value" /></param>
<summary>Extracts a string array from a <see cref="T:GLib.Value" />.</summary>
<returns>The string array value.</returns>
<remarks />
</Docs>
</Member>
</Members>

View File

@ -287,5 +287,56 @@ To make constructing a <see cref="T:Gtk.AboutDialog" /> as convenient as possibl
<remarks />
</Docs>
</Member>
<Member MemberName="Documenters">
<MemberSignature Language="C#" Value="public string[] Documenters { set; get; };" />
<MemberType>Property</MemberType>
<Attributes>
<Attribute>
<AttributeName>GLib.Property(Name="documenters")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String[]</ReturnType>
</ReturnValue>
<Docs>
<summary>The people documenting the program.</summary>
<value>a <see cref="T:System.String[]" />.</value>
<remarks>Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.</remarks>
</Docs>
</Member>
<Member MemberName="Authors">
<MemberSignature Language="C#" Value="public string[] Authors { set; get; };" />
<MemberType>Property</MemberType>
<Attributes>
<Attribute>
<AttributeName>GLib.Property(Name="authors")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String[]</ReturnType>
</ReturnValue>
<Docs>
<summary>The authors of the program.</summary>
<value>a <see cref="T:System.String[]" />.</value>
<remarks>Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.</remarks>
</Docs>
</Member>
<Member MemberName="Artists">
<MemberSignature Language="C#" Value="public string[] Artists { set; get; };" />
<MemberType>Property</MemberType>
<Attributes>
<Attribute>
<AttributeName>GLib.Property(Name="artists")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String[]</ReturnType>
</ReturnValue>
<Docs>
<summary>The people who contributed artwork to the program.</summary>
<value>a <see cref="T:System.String[]" />.</value>
<remarks>Each string may contain email addresses and URLs, which will be displayed as links, see the introduction for more details.</remarks>
</Docs>
</Member>
</Members>
</Type>

View File

@ -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})"));

View File

@ -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 ();
}
}

View File

@ -109,6 +109,12 @@
<attr path="/api/namespace/interface[@cname='GtkTreeModel']/method[@name='RowsReordered']" name="name">EmitRowsReordered</attr>
<attr path="/api/namespace/interface[@cname='GtkTreeSortable']/method[@name='SortColumnChanged']" name="name">ChangeSortColumn</attr>
<attr path="/api/namespace/object[@cname='GtkAccelLabel']/constructor[@cname='gtk_accel_label_new']/*/*[@name='string']" name="property_name">label</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='GetArtists']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='GetAuthors']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='GetDocumenters']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='SetArtists']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='SetAuthors']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAboutDialog']/method[@name='SetDocumenters']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAction']/signal[@name='Activate']" name="name">Activated</attr>
<attr path="/api/namespace/object[@cname='GtkAction']/method[@name='GetProxies']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkAccelGroup']/method[@name='Find']/*/*[@name='find_func']" name="scope">call</attr>